<friskd> how do i check what version of a gem i have
<thomasfedb> friskd, `gem list –local` should print the versions
<bluecatze> can i add keys to a hash after it has been initialized
<banisterfiend> bluecatze: yes and no
<bluecatze> I’m trying to loop through a text file and use some of the lines as keys then other lines as values to those keys
<banisterfiend> bluecatze: yes you can
<banisterfiend> bluecatze: h = {}
<banisterfiend> bluecatze: h[:hello] = “yo”
<bluecatze> so I have to assign the key with a value, I can’t just assign the key by itself? Just to clarify
<thomasfedb> bluecatze, that is correct.
<bluecatze> thank you. one last question, if I wanted to use a local variable as a key, how would I do that, I’m using hash[:key] = “value” to assign
<bluecatze> for example if my local variable is hash[:unique_id] = “vale” it assigns the string “unique_id” as the key instead of the local variable
<bluecatze> I did just hash[local_variable] = “value” and nothing gets assigned
<thomasfedb> bluecatze, either: 1) no you didn’t, or 2) yes it did
<bluecatze> ok ill try messing with it more
<bluecatze> yeah it was about scope, thanks for pointing that out
<friskd> Hey guys, i’m looking for a good html parser that will allow me to pass it the html of page. Extract out all the text and just leave me w/ an html tree.
<friskd> So that i can write out the html tree to a file.
<thomasfedb> nokogiri
<RubyPanther> friskd: Hpricot works well for that, too
<RubyPanther> Hpricot is very fast at dealing with (potentially ill-formed) HTML
<friskd> i’m trying to find what funciton call i would use to just get the html tree
<thomasfedb> friskd, it will be a bit more complex than that.
<friskd> thomasfedb:
<friskd> ?
<acrussell> I a trying to build a gem but it is not finding some native libs I have installed. I can link against tese libs without a problem when I try to compile and link a C program as a test. I tried messing around<acrussell> how do I get ruby to find these libs ?
<RubyPanther> friskd: ruby -r hpricot -r open-uri -e ‘puts Hpricot(open(“http://slashdot.org/”).read).inner_text’ | less
<RubyPanther> Hpricot tastes great, _and_ is less filling!
<RubyPanther> I love 5 year old C extensions that happily compile and work with new versions of Ruby… that is good clean code!
<friskd> RubyPanther: that is is great!
<RubyPanther> I think it is the opposite of what you asked, but that one is probably also trivial
<friskd> o. wait.
<friskd> yea. i need the html structure
<friskd> not the text
<sdferfx> Does nokogiri or hpricot allow us to build a tree of DOM objects? We don’t want innerhtml necessarily, we want something like Python’s etree allows where we can export the structure of the document. See http:<thomasfedb> sdferfx, yes.
<thomasfedb> sdferfx, though you will need to traverse the tree
<sdferfx> thomasfedb, in which library, nokogiri or hpricot or both?
<thomasfedb> sdferfx, either
<Jarred> Hi all. I’m trying to parse values within an XML document by its XPath using Nokogiri. Nokogiri is just returning an empty array for the given XPath. The XPath is correct — I used Firedebug to get it. Here’s <Jarred1> Sorry, my computer crashed.
<ZenBalance> Jarred1: I am working with nokogiri right now as well
<ZenBalance> Jarred1: have you checked your cookies?
<ZenBalance> Jarred1: Some websites require that you pass a cookie as well when opening the url in order to get the correct string
<ZenBalance> In my case, I’ve realized that some ID’s just don’t seem to work so I broke it down and worked around them
<ceej> evening. is it possible to open a file read it into a variable and also get it’s last modified date in one File.open block?
<rippa> ceej: File#mtime
<ceej> rippa: can I do that inside of a File.open block though?
<RubyPanther> ceej: ruby -e ‘File.open(“/proc/cpuinfo”,”r”) {|f| puts f.mtime }’
<rippa> ceej: File.open(file) {|f| [f.mtime, f.read]}
<ceej> ah ty :)
<ceej> you’ve made my late night :)
<ZenBalance> Does anyone have any resource to point me to on how to throttle a scraper?
<vdemedes> Hello!
<vdemedes> Could you please point me to pleasure-to-work-with gem for sending GET/POST requests?
<brainopia> vdemedes: https://www.ruby-toolbox.com/categories/http_clients
<alem0lars> i need to create an expression parser. I toke a look at parslet, treetop, citrus getting started. Which one do you suggest me?
<alem0lars> Expressions that I need to parse aren’t very complex, so I don’t need a full featured PEG
<thomasfedb> alem0lars, treetop is quite good. i haven’t user the others
<alem0lars> thomasfedb: Is there a more in depth documentation than in the documentation page of the official site?
<thomasfedb> alem0lars, not really.
<alem0lars> thomasfedb: ah ok. thanks
<thomasfedb> alem0lars, sorry I couldn’t be of more help/
<alem0lars> thomasfedb: thanks anyways
<banister_> thomasfedb: do u wanna try a multiplayer irb session?
<thomasfedb> banister_, um… ok i guess
<thomasfedb> banister_, how do we pick the winner?
<banister_> thomasfedb: well, you can try to distance my irb instance
<banister_> if i stop talking then you know youve won
<thomasfedb> hmm
<thomasfedb> so. how do we go about this?
<banister_> thomasfedb: are you on 1.9.3 and on *nix ?
<thomasfedb> yep
* thomasfedb changes ruby version
<banister_> thomasfedb: ok, just type: gem install pry-remote-em
<banister_> then once that is complete
<banister_> thomasfedb: i gave u l/p in PM
<thomasfedb> hokay
<banister_> let me know when u join
<thomasfedb> banister_, is rubygems.org under high load or is it just me?
<banister_> thomasfedb: yeah it seems screwy for me too
<banister_> thomasfedb: bad timing :(
<banister_> thomasfedb: ah well, we can give it a go another day
<thomasfedb> banister_, pest.
<clyfe> rubygems is down :(
<banister_> thomasfedb: ?
<clyfe> what can we do ?
<banister_> clyfe: time for pr0n i guess
<thomasfedb> clyfe, eat noodles and rant.
<vdemedes> Hello
<vdemedes> Could you please help me to solve this problem, related to inner classes http://drp.so/d49b74
<vdemedes> I created quick code snippet to demonstrate what I want
<banister_> vdemedes: you cant access it
<banister_> vdemedes: ruby doesnt really have inner classes
<banister_> Mon_Ouie: wb monny ;)
<vdemedes> banister_: But how do libraries do that? For example, Twitter::Search.new, it needs access to tokens
<vdemedes> how does it implement that?
<banister_> vdemedes: what tokens?
<vdemedes> banister_: oAuth tokens
<banister_> vdemedes: well it’s obviously not working the way you think it is, so read the source
<vdemedes> so, that B class is fully separate from A, right?
<banister_> i have no idea what it’s doing, but it’s def. not accessing ivars from the outer class
<banister_> vdemedes: yes
<vdemedes> banister_: ok, thank you!
<cek> hey, wazap with rackpace / rubygems.org?
<fragmachine> can you use ruby for quick calculations on the command line without irb?
<fragmachine> like “ruby puts “hello world”"
<xea_> ruby -e “puts ‘hello world’
<fragmachine> awesome
<xea_> indeed :)
<apeiros_> or `ruby`, hit enter, type code, hit ctrl-d
<fragmachine> haha that’s awesome too!
<fred> apeiros_: fragmachine: ‘irb’.
<apeiros_> fred: ‘fragmachine: “…without irb?”‘
<fred> oh, I’m blind, sorry.
<shevy> right said fred
<shevy> I’m too sexy for my …
<overclucker> i’m getting ‘undefined local variable or method `exitstatus’ for main:Object (NameError)’ after these lines in my script: ‘output = IO.popen(‘xset -q’) { |pipe| pipe.gets }; $?.exitstatus’ is this a corr<fallenstorm> what func makes from number 123 string “000000123″ fixed length filled with default value?
<apeiros_> fallenstorm: sprintf, to_s+ljust, maybe others
<overclucker> “%08d” % integer
<cek> rjust
<fallenstorm> apeiros_ tnx
<UidX> how do i make “rakefile” things?
<UidX> “Gemfile” and “Rakefile” ?
<banister_> UidX: Gemfile, Rakefile, Thorfile, .gemspec, .rspec, .travis.yml, .irbrc, there’s too much to learn!
<UidX> im totally new to ruby and i made an rb file for my siriproxy plugin.. and it seems that it requires that rakefile, gemspec and gemfile
<`brendan> morning all
<Alcohol> Please vote http://missdv.ru/vote/566/
<shevy> hmm
<shevy> as great as ruby is
<shevy> something I’d wish there’d be a better language
<apeiros_> shevy: create one
<shevy> apeiros_ yeah I often want to, but the problem is that it takes so much effort and time. I don’t think I have that available anymore :(
<apeiros_> :)
<UidX> can you guys access github right now?
<banister_> UidX: no
<visof> hello
<visof> is there random selection function for a list?
<banister_> visof: sample
<banister_> visof: [1,2,3,4,5.sample
<banister_> visof: [1,2,3,4,5].sample
<shevy> visof also array.shuffle.first could work in case .sample would not
<linduxed> so i started using rbenv yesterday, and it seems like the gems aren’t working
<linduxed> or well no
<linduxed> not that they’re not working, they do if i do bundle exec something
<linduxed> but i can’t just type cucumber
<linduxed> or something like that
<linduxed> is there some command i need to run to make those commads appear?
<shevy> ^^^ another example why people shouldn’t use rbenv or RVM ;)
<shevy> they add a layer of complexity over a given problem
<linduxed> shevy: probably, but then again it’s far easier than combating the different versions that ruby projects have
<linduxed> i’m only starting out with ruby really, but the projects i’m already in contact with span over three different versions
<linduxed> and then you tell me that i shouldn’t use rbenv or RVM…
<linduxed> sorry but i have no idea how to do it otherwise
<shevy> linduxed oh, I don’t specifically so to not use them
<shevy> I mean if they solve a problem, it’s great
<shevy> what you should do is try to give a better problem description. “it seems like the gems aren’t working” you should follow up on that, and also upload the result of “gem env” somewhere
<shevy> for comparison, this is my “gem env” result linduxed http://pastie.org/3361251
<anjonas> hi guys
<andrew_au> Hi, I used ruby on rails ages ago but completely forgotten it all, I was wondering if anyone can say if a small script is in just ruby or needs rails?
<anjonas> im having trouble with using the split method
<anjonas> week_meny.push(node.text.match(/MÃ¥n(.*)/).split(‘•’))
<anjonas> i get the error block in get_meny’: undefined method `split’ for nil:NilClass (NoMethodError)
<shevy> anjonas you try to apply the .split method on a nil object
<shevy> whatever week_meny.push(node.text.match(/MÃ¥n(.*)/) results, must be nil, so that is where your error is
<linduxed> shevy: in that case my question would be the following
<linduxed> i’ve used rbenv to install ruby 1.9.2-p290. along with it came rubygems 1.8.10 and most likely some other stuff. when i run “bundle show cucumber” (cucumber being one of the gems i’ve installed with bundle i<linduxed> however when i run “gem list ” i only get rdoc, rake and minitest
<linduxed> i guess this is due to it being a 1.9.1 gem
<linduxed> but i’m not quite sure
<shevy> can’t you switch rbenv versions context?
<linduxed> yes i can, let me test
<shevy> I myself install ruby into /Programs/Ruby/VERSION_HERE and just change a symlink to use another version
<linduxed> hmmm
<linduxed> can’t switch
<linduxed> when i run “rbenv versions” i only have one
<shevy> I dont use either, but with rvm you can switch like so:
<shevy> rvm –default use 1.9.3
<shevy> you have to find out where gem stored your gems too
<shevy> for me here, all gems reside under /usr/lib/ruby/gems/1.8/cache/
<linduxed> yeah i know, i used to type “rvm use someversion”
<richo> is there a teardown equivalent to #intitialize ?
<shevy> but btw, since gem are just tarballed .gem files, you could locate them and install them even by managing the dependency on your own
<shevy> gem install –ignore-dependencies *.gem
<shevy> once you found out where your gems are that is ;)
<shevy> richo what means “teardown”?
<linduxed> shevy: post-test actions
<shevy> hmm
<richo> teardown is the wrong word maybe, in python we use __init__() for when an object is created, and __del__ for when the object reaches refcount 0 and is gc’d
<shevy> I dont think ruby has anything like __del__
<richo> technically though I may be looking for an atexit(3) hook though
<richo> *shrug*, I shall deal with this later then
<richo> :D
<shevy> atexit can be a problem, I think it is tied down to a specific file, not an object
<shevy> I could be wrong though
<richo> well, the reason I may be looking for atexit is because I’d need the object to test that it’s the last instance of it’s metaclass
<richo> which probably means I’m better off just binding the action to interpreter exit and leaving it as an open bug
<richo> in theory, it should fire it’s exit action twice if you create an object, hose it, create another one andt hen quit
<richo> but that’s an edge case I can leave for now
<shevy> hmm
<shevy> there are some hooks … like #included … perhaps there may be another hook for your use case
<richo> it’s ok, I’ll fix all the core behavior and fix the silly little things lik eputting the users terminal back together later
<linduxed> gaaah
<linduxed> now when i run “bundle exec cucumber” on another computer, i get the following http://paste.pocoo.org/show/549317/
<linduxed> it looks like it’s version related, but i’m not sure
<linduxed> what’s weird is that the computer on which i wrote the code has the same rbenv setup and the same ruby version installed
<shevy> I think you use an old rubygems version
<shevy> try the 1.8.15 one http://rubyforge.org/frs/download.php/75711/rubygems-1.8.15.tgz
<Rishi_> hey guys, does pygments.rb wrap code automatically?
<Rishi_> I tried passing :nowrap => false and there seems to be no effect
<methoddk> ahh
<linduxed> ok wtf is going on…
<linduxed> bundler is not in the list when i do “gem list”
<linduxed> but i can do bundler
<linduxed> ….
<linduxed> “bundle” i mean
<linduxed> hmmm, bundle is in /usr/bin/bundle
<linduxed> ooooh
<linduxed> now i get it
<linduxed> it’s my residual system install
<linduxed> from my package manager
<wroathe> So… why? 99.remainder(2) == 1 99.modulo(2) == 1 99 % 2 == 1 99.remainder(2).eql? 1
<wroathe> There are like 15 different ways you can do that expression in ruby
<rippa> why not
<wroathe> I would argue adding those methods for readability is basically solving a non-existant problem.
<wroathe> If you can’t read 99 % 2 == 1 then you maybe shouldn’t be programming.
<rippa> don’t like – don’t use
<wroathe> I get that :P I’m just wondering why the core team thought that was necessary.
<canton7> wroathe, there is a difference…. 99 % -2 == -1, 99.remainder(-2) == 1
<wroathe> But % and modulo are canonical?
<canton7> wroathe, similarly, -99 % 2 == 1, -99.remainder(2) == -1
<linduxed> ok so ruby version hell time
<linduxed> i’ve got rbenv installed
<linduxed> lots of gems there, all working fine
<linduxed> same with RVM some time ago, although i don’t use it anymore
<linduxed> however
<linduxed> some time ago i instlled ruby with my package manager
<linduxed> needed it to install RVM i think, don’t remember
<linduxed> the point is that this package manager tied ruby was still around
<linduxed> RVM seems to override it, but rbenv doesn’t
<linduxed> or at least so it seems
<linduxed> because apparently when i did bundle install inside a rails director9y, directory it asked me for a password and it installed the gems into /usr/lib/ruby/…..
<linduxed> now i’ve uninstalled the package manager ruby, so it now works fine as it should with rbenv
<linduxed> but those gems, the /usr/bin/bundle command and most likely some other stuff are still around, untracked by neither the package mangear nor rbenv/rvm
<linduxed> so my question is, how do i figure out what to remove to clean up?
<gioele> It seems that webrick does not ignore the glob patterns passed in `:NondisclosureName`. Is there something that I am doing wrong?
<gioele> the code is at http://pastie.org/3361756 from line 47 to 53. `p config` confirms me that the :NondisclosureName has been set to an array of strings, just like I thought, although webrick does not honors it
<richo> Is there a syntax to tell ruby to continue testing criteria in a case when block?
<shevy> richo how do you mean
<shevy> multiple when conditions to be true at the same time?
<richo> Wait, I’ll make a gist
<richo> yeah, pretty much
<shevy> hmm I dont think so.
<richo> it’s ok, I’ll just unwrap it a bit
<plato> hi guys, could anyone help me figure out why the hell i have a syntax error in this code? http://codepad.org/AeKh7uAK
<plato> line 72
<plato> syntax error, unexpected ‘n’, expecting tCOLON2 or ‘[' or '.'
<plato> when i require 'pastebin'
<Mon_Ouie> *imported['json_data']['metakey'].each_pair do |imp_subkey, imp_subvalue|
<Mon_Ouie> There should be no “*” there
<plato> what is the * doing
<plato> i cribbed it from http://flori.github.com/json/doc/index.html
<plato> and it seemed to fail without the *
<plato> awesome that worked
<gioele> is there a problem with rubygems.org? I pushed two versions of my gem but “gem install servedir” fails to install it. It says «ERROR: Could not find a valid gem ‘servedir’ (>= 0) in any repository»
<plato> it DOES fail without the * in a prior line, reconstructed=new(*imported['json_data']['datakey'])
<plato> what does the * do
<gioele> plato: make ruby use the elements of an array as a series of parameters to a function
<gioele> plato: `x = [a, b, c]; fn(*x)` is equivalent to `fn(a,b,c)`
<plato> that seems odd then
<plato> because reconstructed=new(*imported['json_data']['datakey']) should pass exactly one parameter
<plato> im surprised it doesn’t correctly import when i remove that *
<plato> nvm it does. stupid error on my part
<plato> thanks gioele
<plato> so when i convert my Hypercard to json and back, i’m calling Hypercard.new() to build a new one
<plato> b=a.to_json; c=JSON.parse(b)
<plato> now a==c evaluates to false although they both contain the same information. the IDs are different. how do I override the == operator?
<plato> class Hypercard; def ==; #mycode; end; end
<plato> ?
<plato> or is it a class method
<gioele> plato: class Hypercard; def ==(other); yourcode; end; end
<gioele> plato: it is an instance method, not class
<richo> is rubygems toast? I’ve pushed a few gems but none of the new versions are being seen by gem(1)
<gioele> richo: I have the same problem
<richo> Cool, not just me then. It shows up on the site. I couldn’t even push gems earlier so hopefully it comes good soon
<plato> thanks again gioele
<gioele> plato: np
<moshee> anybody got a link to some documentation for the VIM module for extensions in ruby?
<moshee> nvm, found it
<shevy> gioele usually I think it takes a while before it is available … but today the site seems to have some lag or something
<banseljaj> Hi. is there a gem or library that can read XML data dumps?
<gioele> banseljaj: Nokogiri can read XML
<gioele> banseljaj: what do you mean with “data dump”?
<banseljaj> gioele: and convert it into obects?

© 2011 Techdot IRC Resources Suffusion theme by Sayontan Sinha