apeiros_ changed the topic of #ruby to: programming language || ruby-lang.org || Paste >3 lines of text in http://pastie.org || Rails is in #rubyonrails
wimplash has joined #ruby
chson has joined #ruby
Divinite has joined #ruby
<Kovensky> (btw, the xor with (2**32)-1 worked; probably because (2**32)-1 is a bignum itself and promotes any fixnum to bignum before running the xor)
srnty has joined #ruby
lucasefe has joined #ruby
albemuth has joined #ruby
n3m has joined #ruby
malkomalko has joined #ruby
Diranged has quit [#ruby]
nopolitica has joined #ruby
albemuth has joined #ruby
aef has joined #ruby
denysonique has joined #ruby
Divinite has joined #ruby
frogstarr78 has joined #ruby
albemuth has joined #ruby
liluo has joined #ruby
bananas has joined #ruby
<bananas> hi! i'd like to get a fullname of a file. i only have the basename though... (the problem is the file can be x.jpeg, x.jpg, x.png,...) how can i get around this?
<banisterfiend> bananas: File.expand_path
<Boohbah> xcyclist: $LOAD_PATH.unshift File.dirname(__FILE__)
brngardner has joined #ruby
<Boohbah> xcyclist: at the top of sfs00.rb
<bananas> i'll rephrase. given the basename of a file, how can i get the extension of such a file?
<xcyclist> Boohbah, are you responding to bananas instead of me?
<xcyclist> I don't see how this pertains to minitest.
<Boohbah> bananas: File.extname
Hsparks has joined #ruby
<bananas> Boohbah: i don't know the full name of the file. i only know "x" (considering x as in my post 8 minutes ago)
<xcyclist> Boohbah. I don't see any difference.
denysonique has joined #ruby
metasansana has joined #ruby
rellon has joined #ruby
nT4BR has joined #ruby
<nT4BR> hey, anybody here can help my with a rspec/rails question? (has no active ppl on the respective channels)
<xcyclist> [".", "/home/me/shop/minitest", "/usr/local/rbenv/versions/1.9.2-p290/lib/ruby/site_ruby/1.9.1", "/usr/local/rbenv/versions/1.9.2-p290/lib/ruby/site_ruby/1.9.1/x86_64-linux", "/usr/local/rbenv/versions/1.9.2-p290/lib/ruby/site_ruby", "/usr/local/rbenv/versions/1.9.2-p290/lib/ruby/vendor_ruby/1.9.1", "/usr/local/rbenv/versions/1.9.2-p290/lib/ruby/vendor_ruby/1.9.1/x86_64-linux", "/usr/local/rbenv/versions/1.9.2-p290/lib/ruby/vendor_ruby", "/usr/local/rbenv
<xcyclist> /versions/1.9.2-p290/lib/ruby/1.9.1", "/usr/local/rbenv/versions/1.9.2-p290/lib/ruby/1.9.1/x86_64-linux"]
<xcyclist> I'm not sure if that's what Boohbah wants. Obviously, I'm using rbenv.
<xcyclist> My apologies for the length. It should have been a pastie.
shevy has joined #ruby
<bananas> got it! Dir.glob('./path/' + base + '*')
<bananas> not the cleanest...
jergason has joined #ruby
jfelchner has joined #ruby
Nanuq has joined #ruby
tomzx has joined #ruby
nif has joined #ruby
Diranged has joined #ruby
<Diranged> can i make a ruby script exit quietly if a package is not loadable?
<Diranged> ie… require 'foo' … if it errors out, exit super silently?
radic has joined #ruby
ZachBeta has joined #ruby
freeayu has joined #ruby
kevinbond has joined #ruby
niklasb has joined #ruby
MrGando has joined #ruby
Haydos has quit ["Leaving"]
EzeQL has joined #ruby
chad_ has joined #ruby
dv310p3r has joined #ruby
apok_ has joined #ruby
williamcotton has joined #ruby
juul has joined #ruby
igotnolegs has joined #ruby
kevinbond has joined #ruby
<Prudhvi> Diranged: it generates a LoadError, so you will have to handle that IMO
Akuma has joined #ruby
bwlang has joined #ruby
brngardner has joined #ruby
Diranged has quit [#ruby]
blueadept` has joined #ruby
chad_ has joined #ruby
CheeToS has joined #ruby
lewis has joined #ruby
thams has joined #ruby
lkba has joined #ruby
dmn001 has joined #ruby
MrGando has joined #ruby
carlyle has joined #ruby
philcrissman_ has joined #ruby
niku4i_ has joined #ruby
chomp has joined #ruby
shadoi has joined #ruby
clark has joined #ruby
bananas has quit [#ruby]
dwon has joined #ruby
manizzle has joined #ruby
<lectrick> Is there any way I could pipe a string to a unix command and receive the output as a string, without first writing to a file and doing `command file1 file2`?
krzkrzkrz has joined #ruby
SolarisBoy1 has quit [#ruby]
SolarisBoy1 has joined #ruby
queequeg1 has joined #ruby
ed_hz_ has joined #ruby
<heftig> lectrick: popen
Sailias has joined #ruby
clark has quit ["Leaving"]
squareduck has joined #ruby
liluo has joined #ruby
mailtruck has joined #ruby
shadoi has joined #ruby
ZachBeta has joined #ruby
nate_h has joined #ruby
phipes has joined #ruby
wefawa has joined #ruby
maletor has joined #ruby
ringotwo has joined #ruby
jobicoppola has joined #ruby
SegFault1X has joined #ruby
SolarisBoy has joined #ruby
bwlang has joined #ruby
akasukuf has joined #ruby
youdonotexist has joined #ruby
youdonotexist has joined #ruby
abra has joined #ruby
ZachBeta has joined #ruby
tomzx has joined #ruby
Oog_ has joined #ruby
girlself2 has joined #ruby
<girlself2> hey
<Oog_> i am forking to create new processes. i want the stdout of the children to go to the parent. how do i do this?
<girlself2> that
<Oog_> i tried mystudout = $stdout fork do $stdout.reopen(mystdout) end
<Oog_> but that didnt seem to work...
<girlself2> you
<girlself2> hey
<girlself2> how a treotyu guys a.l;?
<girlself2> infer it
<girlself2> does anmyone know some really advanced ruby?
<girlself2> what is it in it?
<girlself2> hi/
<girlself2> hmm
<girlself2> asd.asd.asd.asd
<girlself2> hey
<girlself2> it?
pdtpatr1ck has joined #ruby
jrhorn424 has joined #ruby
<shevy> girlself2 omg
ilyam has joined #ruby
thecreators has joined #ruby
meskyanichi has joined #ruby
shobhitg has joined #ruby
nwertman has joined #ruby
nwertman has joined #ruby
<nwertman> Are there any coverage tools for ruby other than rcov? I've hit a spot where it falls over badly.
stefanp_ has joined #ruby
bwlang has joined #ruby
brngardner has joined #ruby
danielvdotcom has joined #ruby
vitor-br has joined #ruby
ckrailo has joined #ruby
libertyprime has joined #ruby
ben225 has joined #ruby
ScottNYC has joined #ruby
brianpWins has joined #ruby
jgrevich_ has joined #ruby
jgrevich_ has joined #ruby
ScottNYC has joined #ruby
indeterminate has joined #ruby
<ozzloy> i'm trying to get erb and rhtml files hilited in emacs. i have rinari installed and it shows the mode loaded when i open an erb file, but i get no syntax hiliting. how do i do get syntax hiliting?
x0F has joined #ruby
ryan_dev70 has joined #ruby
abra has joined #ruby
kenperkins has joined #ruby
Progster has joined #ruby
danrasband has joined #ruby
danrasband has quit [#ruby]
renanoronfle has joined #ruby
linoj has joined #ruby
yoklov has joined #ruby
dankest has joined #ruby
baroquebobcat has joined #ruby
92AAAO4FF has joined #ruby
ben225 has joined #ruby
nerdy has joined #ruby
moshee has joined #ruby
moshee has joined #ruby
limon7 has joined #ruby
davejacobs has joined #ruby
rramsden has joined #ruby
zakwilson has joined #ruby
limon7 has joined #ruby
ben225 has joined #ruby
youdonotexist_ has joined #ruby
michaelmartinez has joined #ruby
brngardner has joined #ruby
kevinbond has joined #ruby
bluOxigen has joined #ruby
dhruvasagar has joined #ruby
ken_barber has joined #ruby
tommyvyo has joined #ruby
blueadept` has joined #ruby
dkissell has joined #ruby
looopy has joined #ruby
Diranged has joined #ruby
Diranged has quit [#ruby]
nipra has joined #ruby
grapentine has joined #ruby
Diranged has joined #ruby
<Diranged> is there a function in ruby for doing some kind of reproducible randomization
<Diranged> ie.. if i have an array of 5 elements, and a server hostname "foo".. i want to do elemenum=rand(foo,5) and get a random number between 1 and 5.. every time, the same number..
becom33 has joined #ruby
jwmann has joined #ruby
savage- has joined #ruby
banisterfiend has joined #ruby
<becom33> in this paste I get the output as 'Hello lol john' I also wanna get a output 'lol'removed from the output . how can I get a a word removed from a sentence ? http://pastie.org/3820742
two- has joined #ruby
banisterfiend has joined #ruby
<becom33> anyone ?
baroquebobcat has joined #ruby
pjn_oz has joined #ruby
rippa has joined #ruby
TheIronWolf has joined #ruby
TheIronWolf has joined #ruby
TheIronWolf has joined #ruby
dfamorato has joined #ruby
n8ji has joined #ruby
symb0l has joined #ruby
ilyam has joined #ruby
michaelmartinez has quit [#ruby]
snip_it has joined #ruby
lkba has joined #ruby
banjara has joined #ruby
dhruvasagar has joined #ruby
nfluxx has joined #ruby
jgrevich_ has joined #ruby
jgrevich_ has joined #ruby
qos has joined #ruby
albemuth has joined #ruby
atmosx has joined #ruby
michaelmartinez has joined #ruby
TandemAdam has joined #ruby
rohit has joined #ruby
Morkel has joined #ruby
a_a_g has joined #ruby
snip_it has joined #ruby
jitesh_shetty has joined #ruby
tomsthumb has joined #ruby
banisterfiend has joined #ruby
maletor has joined #ruby
banister_ has joined #ruby
machine2 has joined #ruby
banjara has quit [#ruby]
limon7 has joined #ruby
mksm has joined #ruby
greenarrow has joined #ruby
banseljaj has joined #ruby
TheMoonMaster has joined #ruby
lenochka has joined #ruby
Rizzle has joined #ruby
<lenochka> any idea how to run ruby script as a scheduled task in Windows?
yxhuvud has joined #ruby
CheeToS has joined #ruby
Derander has joined #ruby
Sou|cutter has joined #ruby
rramsden has joined #ruby
rramsden_ has joined #ruby
rohit has joined #ruby
luckyruby has joined #ruby
JohnBat26 has joined #ruby
ElderFain has joined #ruby
timonv has joined #ruby
Bosma has joined #ruby
<rippa> lenochka: schedule it in scheduler
rohit has joined #ruby
dfamorato has joined #ruby
grapentine has joined #ruby
campanolix has joined #ruby
pubis has joined #ruby
prometheus has joined #ruby
<xcyclist> ls
nilg has joined #ruby
Cork has joined #ruby
fbernier has joined #ruby
redgetan has joined #ruby
liluo has joined #ruby
<Cork> is there anyway to overide a class constant through extending it?
<Cork> (the class)
deobald_ has joined #ruby
<rippa> override?
<xcyclist> Cork: You could use Class variable instead, with some kind of naming that implies they should be constant for each class. I seem to recall, since it's at some kind of mixin level, you cannot redefine an invariant in any inheritance for constants...???
<xcyclist> I guess they use "immutable".
<Cork> xcyclist: the problem its a rails actionpack lib
<Cork> and its a broken regex i need to fix
<Cork> and i would prefer to not have to monky patch it
<Cork> TRUSTED_PROXIES = /^127\.0\.0\.1$|^(10|172\.(1[6-9]|2[0-9]|30|31)|192\.168)\./i
<Cork> the problem is my proxy uses unix sockets
<Cork> so i can't use HTTP_X_FORWARDED_FOR
sroy2 has joined #ruby
mailtruck has joined #ruby
sohocoke has joined #ruby
<rippa> Cork: can you inherit from it?
<xcyclist> Page 324 of Pickaxe for 1.9
<xcyclist> MY_CONST = "Tim"
<xcyclist> MY_CONST[0] = "J"
<Cork> it needs to keep the old name
<xcyclist> MY_CONST # => "Jim"
mdw has joined #ruby
<xcyclist> So, it says you can modify the string referenced by the constant by changing the character.
<xcyclist> I would comment it very well if you do.
<Cork> ya...
<Cork> well i'll try
qos has joined #ruby
nlc has joined #ruby
<rippa> Const.replace "derp"
<Cork> Constr.replace?
<Cork> uh
<Cork> *Const
<rippa> if it's a string
<rippa> it's not though
<rippa> it's a regexp
becom33 has joined #ruby
jaysern has joined #ruby
<jaysern> i'm having trouble with getting RVM to install 1.9.3 on my OS X 10.6 machine - it chokes on openssl, apparently: openssl_missing.h:71: error: conflicting types for ‘HMAC_CTX_copy’
<jaysern> anyone solved this before?
x0F_ has joined #ruby
KL-7 has joined #ruby
apeiros_ has joined #ruby
francisfish has joined #ruby
andrewhl has joined #ruby
srnty has joined #ruby
mborromeo has joined #ruby
schovi has joined #ruby
dfamorato has joined #ruby
shruggar has joined #ruby
mailtruck has joined #ruby
fivetwentysix has joined #ruby
<fivetwentysix> hello rubyists
Advocation has joined #ruby
dhruvasagar has joined #ruby
symb0l has joined #ruby
alem0lars has joined #ruby
sohocoke has joined #ruby
IPGlider has joined #ruby
apeiros_ has joined #ruby
alem0lars_ has joined #ruby
maesbn has joined #ruby
workmad3 has joined #ruby
ctwiz has joined #ruby
c0rn has joined #ruby
nikhil_ has joined #ruby
Eldariof-ru has joined #ruby
symb0l has joined #ruby
<xcyclist> So, there is some evidence that my use of rbenv is breaking the must_be_silent method from minitest. Has anyone else heard of this happening?
duey has quit ["Leaving"]
c0rn has joined #ruby
jrist-mtgs has joined #ruby
sspiff has joined #ruby
sspiff has joined #ruby
nilg has joined #ruby
Careott has joined #ruby
Careott has quit [#ruby]
dhruvasagar has joined #ruby
zommi has joined #ruby
fbernier has joined #ruby
nilg` has joined #ruby
heldopslippers has joined #ruby
SPYGAME has joined #ruby
LMolr has joined #ruby
djdb has joined #ruby
shiroginne has joined #ruby
ephemerian has joined #ruby
<shiroginne> ohayo all
Vendethiel has joined #ruby
<Boohbah> oha!
dhruvasagar has joined #ruby
Ammar01 has joined #ruby
bluOxigen has joined #ruby
vulpes has joined #ruby
<lenochka> rippa: that I heard of, but how do you do that?
ben225 has joined #ruby
telling has joined #ruby
apeiros_ has joined #ruby
sts has quit [#ruby]
nricciar has joined #ruby
polysics has joined #ruby
dhruvasagar has joined #ruby
piotr_ has joined #ruby
senny has joined #ruby
KL-7 has joined #ruby
cezar has joined #ruby
etehtsea has joined #ruby
<senny> is it possible to ignore the default internal encoding when reading in a file? I have an internal encoding of 'UTF-8' but I need to read a file in 'iso8859-1' and keep it in 'iso8859-1'. Is there a way to skip the transcoding to utf-8? When I supply 'r:iso8859-1:iso8859-1' when reading a file, it works but results in a warning.
<apeiros_> File.read(path, encoding: 'whatever')
<apeiros_> or File.open(path, 'rb:whatever') { …
<apeiros_> see IO docs for more
<senny> apeiros_: this does not work. since I set the default_internal encoding it automatically transcodes the contents to UTF-8
liluo has joined #ruby
<apeiros_> oh, right, you're talking about internal encoding. hm, would have to consult the IO docs myself.
<senny> apeiros_: i really went through the docs, even consulted "the ruby programming language" book but I cant find a better solution :S
<rippa> try options hash
<rippa> :internal_encoding Internal encoding for the IO. “-” is a synonym for the default internal encoding.
<rippa>
<rippa> If the value is nil no conversion occurs.
<rippa>
mdw has joined #ruby
<luckyruby> in my log file, i'm tracking xml request, http request, and http response, in that order using a uuid generated per transaction. Is there something better than uuid to accomplish the grouping of log messages?
khakimov has joined #ruby
<senny> rippa: amazing thanks!
dhruvasagar has joined #ruby
nricciar has joined #ruby
jenglish has joined #ruby
dankest has joined #ruby
shruggar has joined #ruby
wvdschel has joined #ruby
shruggar1 has joined #ruby
Advocation has joined #ruby
francisfish has joined #ruby
artm has joined #ruby
dhruvasagar has joined #ruby
sebastian_pl has joined #ruby
tvw has joined #ruby
jrhorn424_ has joined #ruby
Squarism has joined #ruby
wedgeV has joined #ruby
c0rn has joined #ruby
agilobable has joined #ruby
ukwiz has joined #ruby
apok has joined #ruby
Indian has joined #ruby
d34th4ck3r has joined #ruby
nilg has joined #ruby
peterhil` has joined #ruby
simao has joined #ruby
Indian has joined #ruby
nilg has joined #ruby
piotr__ has joined #ruby
burgestrand has joined #ruby
Mokona has joined #ruby
freeayu has joined #ruby
spuz has joined #ruby
lolmaus has joined #ruby
<lolmaus> I would like to perform a `du` command and then obtain its result in a Ruby script. How do i do that?
<apeiros_> exactly like that
<apeiros_> result = `du`
davidw has joined #ruby
savage-_ has joined #ruby
<apeiros_> note that this only captures stdout, stderr will be directed to rubys stderr.
tayy has joined #ruby
[eko] has joined #ruby
luckyruby has joined #ruby
roolo has joined #ruby
qos_ has joined #ruby
mrkris_ has joined #ruby
maletor_ has joined #ruby
banseljaj has joined #ruby
__main__ has joined #ruby
M- has joined #ruby
blast_hardcheese has joined #ruby
DuoSRX has joined #ruby
lolmaus has joined #ruby
tuxr has joined #ruby
jimeh has joined #ruby
<lolmaus> Sorry, was offline
<lolmaus> I would like to perform a `du` command and then obtain its result in a Ruby script. How do i do that?
Drewch has joined #ruby
<apeiros_> 10:30 apeiros_: exactly like that
<apeiros_> 10:30 apeiros_: result = `du`
<apeiros_> 10:32 apeiros_: note that this only captures stdout, stderr will be directed to rubys stderr.
<jimeh> lolmaus: Have a look a this article about 6 ways to run shell commands in ruby: http://tech.natemurray.com/2007/03/ruby-shell-commands.html
MissionCritical has joined #ruby
<lolmaus> jimeh, thank you man ^_^
<jimeh> no problem :)
tuxr has quit [#ruby]
tatsuya_o has joined #ruby
lidashuang_ has joined #ruby
Ethan has joined #ruby
workmad3 has joined #ruby
piotr_ has joined #ruby
rohit has joined #ruby
frogstarr78 has joined #ruby
<lolmaus> I've written my first unit tests evah! I've got no idea whether my approach in not nonsense :(
<polysics> it never is :-)
bier|tp has joined #ruby
<polysics> got something to gist?
bier has joined #ruby
roflmaus has joined #ruby
tayy has joined #ruby
dhruvasa1ar has joined #ruby
berserkr has joined #ruby
dhruvasagar has joined #ruby
<Cork> rippa, xcyclist: ended up with http://pastebin.com/igjANdcc
<Cork> its stable enough for me to feel confy about it
aibo has joined #ruby
xkx has joined #ruby
rohit has joined #ruby
dhruvasa1ar has joined #ruby
kedare has joined #ruby
ex0a has joined #ruby
shruggar has joined #ruby
monokrome has joined #ruby
shruggar has quit [#ruby]
schovi has joined #ruby
neekfenwick has joined #ruby
<neekfenwick> very n00b question: i'm installing octopress on my linux fedora 16 system. needs 1.9.2, fedora only packages 1.8.x, so ok, http://www.ruby-lang.org/en/downloads/ says I should install from source. RVM can install for the current user, but I'm concerned how it seems to install to the user's home dir. If my user neek, and apache, both want to be able to run ruby, should I install as root?
<neekfenwick> or perhaps i should do the rvm-installer as root, then use it to install a system-wide ruby, then neek and apache can both access ruby?
knopkodav has joined #ruby
<Cork> neekfenwick: thats how i solved it
<Cork> not sure if its the recomended way though
<roflmaus> I'm writing a unit test and using `an_array.count`. This produces a error: ArgumentError: wrong number of arguments (at least 1) in `count'. WHYYY
<Cork> if you install as root it installs in /usr/local/rvm/gems
<neekfenwick> Cork, ok thanks. i stumbled through this on a VPS the other day, but now am on my own machine and dont want to screw it up :)
<Cork> ya, i know the feeling
<Cork> was a bit scary to migrate to rvm :)
statarb3 has joined #ruby
statarb3 has joined #ruby
<neekfenwick> when i even cd into my octopress directory now, i get "Using /home/neek/.rvm/gems/ruby-1.9.2-p318" echoed to the console. it's a bit scary. i've no idea what hooks it has inserted into my environment, and what multi-user concerns there are
<roflmaus> Oh, i had an error in another place
<roflmaus> IRB rocks. ^_^
<apeiros_> pry rocks even more
matti has joined #ruby
matti has joined #ruby
<Cork> neekfenwick: .rvmrc
<Cork> neekfenwick: when its found in a folter its executed
<neekfenwick> i'm not familiar with that kind of auto-execute script. what's controlling that? .rvmrc has a single simple line
<Cork> neekfenwick: its part of rvm
<Cork> haven't checked how it does it
<neekfenwick> i guess it's a bash thing of some sort
<Cork> but if you move cross a folder with that file its executed
shruggar has joined #ruby
<neekfenwick> i just haven't seen a script auto execute due to cd before
<Cork> its a simple bach like script
<neekfenwick> doesn't even have the execute bit set
<Cork> neekfenwick: the rvm installer explains this
manizzle has joined #ruby
<Cork> neekfenwick: scripts doens't need exec
<Cork> only programs
<neekfenwick> yes i know a fair bit about shbang, exec permissions, and what-not
<neekfenwick> but e.g. when i cd into my home dir, why aren't all the files starting with '.' executed there too?
<Cork> neekfenwick: cause theres a hook installed by rvm that looks explicitly for ".rvmrc"
<Cork> its kinda like the .bashrc
<Cork> the . just means its normally hidden
bawer has joined #ruby
<neekfenwick> the RVM install line at http://www.ruby-lang.org/en/downloads/ ($ bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)) doesn't work for me .. perhaps the page is down. but https://rvm.io/ seems good
d34th4ck3r has joined #ruby
becom33 has joined #ruby
iocor has joined #ruby
shruggar has joined #ruby
ilyam has joined #ruby
nilg` has joined #ruby
gener1c has joined #ruby
<gener1c> there are alot of ruby gems for mysql, i want to access my db with a script that will insert some stuff and then its going to be discarded, which lib would be suitable for that?
<gener1c> just a one time update from a csv
<gener1c> mysql/mysql2? something else?
elliot_ has joined #ruby
apeiros_ has joined #ruby
Shrink has joined #ruby
QaDeS has joined #ruby
jimeh has joined #ruby
nilg has joined #ruby
moparirc_G4gDm has joined #ruby
moparirc_G4gDm has quit [#ruby]
DMKE has joined #ruby
banjara has joined #ruby
prtksxna has joined #ruby
dhruvasagar has joined #ruby
<roflmaus> I'm trying to write a unit test that makes sure the class raises an exception on certain ocasion. I'm using `raise` to raise a error and `assert_raises` to check that it does. But instead of accepting/failing the test, it complains about the raised error. How do i do that correctly?
aibo_ has joined #ruby
<banister_> roflmaus: you could always just rescue the exception and assert on the caught exception
nilg has joined #ruby
<roflmaus> banister_, so all the exceptions tested should have resques? Otherwise you can't test them?
<banister_> roflmaus: the testing library should have support for it, you haven't even said what testing lib your'e using :) but aside from the particular testing lib you're using, you could write a helper than wraps the begin/rescue of a piece of code and you could assert on the rescued exception
tk__ has joined #ruby
<canton7> I know, for instane, that in rspec you have to put a block around your exception-raising method, and pass that to an rspec method
<roflmaus> banister_, i'm using minitest with Ruby 1.9.3.
<banister_> roflmaus: in bacon we do this: lambda { code }.should.raise Blah
<roflmaus> banister_, i was doing it wrong! Had put the tested block into where error type should be.
anildigital_work has joined #ruby
<roflmaus> banister_, now it works without rescues and wrappers ^_^
<banister_> roflmaus: good
<anildigital_work> Guys.. how to know how much CPU % is being used from Ruby?
falena has joined #ruby
<roflmaus> Is there a Minitest assertion like assert_not_raise?
<bigkevmcd> roflmaus: just call the code, if it raises, it will cause the test to fail
<roflmaus> bigkevmcd, kinda "assert(Foo.new)"?
<bigkevmcd> roflmaus: should work
<bigkevmcd> roflmaus: am not even sure you need assert() around it
<bigkevmcd> roflmaus: if Foo.new raises an error, your test will fail...
fr0gprince_mac has joined #ruby
<roflmaus> bigkevmcd, yeoup
<roflmaus> THx
michaeljordan has joined #ruby
apeiros_ has joined #ruby
michaeljordan has joined #ruby
bluenemo has joined #ruby
bluenemo has joined #ruby
yeggeps has quit [#ruby]
lenochka has quit [#ruby]
etehtsea has joined #ruby
rohit has joined #ruby
bluenemo has joined #ruby
eka has joined #ruby
jitesh_shetty has joined #ruby
mattyoho has joined #ruby
mattyoho has joined #ruby
<ksk> hi
davidcelis has joined #ruby
<ksk> im able to use "sting.match" go get matching stings - but how to get only the matching part?
asno has joined #ruby
<asno> hi all! Is anybody experienced with ruports?
<asno> thanks!
<roflmaus> ksk, what's the difference between "matching string" and "matching part"?
<ksk> i want "grep -o" behaviour
<ksk> uhm, nevermind. :)
sohocoke has joined #ruby
<ksk> it just does what i want, just used the wrong regex
<ksk> thanks
emmanuel__ has joined #ruby
stu314 has joined #ruby
nanderoo has joined #ruby
seanstickle has joined #ruby
Drewch has joined #ruby
maddog_ has joined #ruby
peterhil` has joined #ruby
dv310p3r has joined #ruby
shruggar has joined #ruby
stu314 has quit [#ruby]
maesbn has joined #ruby
mdw has joined #ruby
nikhgupta has joined #ruby
liluo has joined #ruby
crankycoder has joined #ruby
waxjar has joined #ruby
`brendan has joined #ruby
BSaboia has joined #ruby
crankycoder has joined #ruby
BSaboia__ has joined #ruby
waxjar has joined #ruby
Progster has joined #ruby
fbernier has joined #ruby
apeiros_ has joined #ruby
thams has joined #ruby
waxjar has joined #ruby
sbanwart has joined #ruby
Orva has quit [#ruby]
bwlang has joined #ruby
dql has joined #ruby
emmanuelux has joined #ruby
g0bl1n has joined #ruby
jitesh_shetty has joined #ruby
eeadc has joined #ruby
eeadc has joined #ruby
brunosaboia__ has joined #ruby
yannis has joined #ruby
alem0lars_ has joined #ruby
LMolr has joined #ruby
bwlang_ has joined #ruby
eeadc has joined #ruby
virunga has joined #ruby
eeadc has joined #ruby
eeadc has joined #ruby
meskyanichi has joined #ruby
eeadc has joined #ruby
fr0gprince_mac has joined #ruby
chad_ has joined #ruby
emmanuel__ has joined #ruby
dustybrains has joined #ruby
eeadc has joined #ruby
pu22l3r has joined #ruby
eeadc has joined #ruby
eeadc has joined #ruby
eeadc has joined #ruby
mattyoho has joined #ruby
eeadc has joined #ruby
eeadc has joined #ruby
eeadc has joined #ruby
tommyvyo has joined #ruby
MissionCritical has joined #ruby
eeadc has joined #ruby
<gener1c> humz
eeadc has joined #ruby
eeadc has joined #ruby
eeadc has joined #ruby
eeadc has joined #ruby
eeadc has joined #ruby
Morkel has joined #ruby
eeadc has joined #ruby
thecreators has joined #ruby
x0F_ has joined #ruby
Squarepy has joined #ruby
soveran has joined #ruby
Squarepy has joined #ruby
cookies has joined #ruby
cookies has joined #ruby
fr0gprince_mac has joined #ruby
dv310p3r has joined #ruby
BeLucid has joined #ruby
geekbri has joined #ruby
zealinux has joined #ruby
imsplitbit has joined #ruby
td123 has joined #ruby
wefawa has quit [#ruby]
d3c has joined #ruby
hackbox has joined #ruby
<hackbox> hello everyone, anyone knows where to get good webrick tutorial?
chad_ has joined #ruby
cookies has joined #ruby
albemuth has joined #ruby
linoj has joined #ruby
Shrink has joined #ruby
Shrink has joined #ruby
BrianE has joined #ruby
mrwalker has joined #ruby
<Tasser> what do you want to know?
twinturbo has joined #ruby
kjs3 has joined #ruby
ccapndave3 has joined #ruby
<hackbox> webrick tutorial
kjs3 has quit [#ruby]
bbttxu has joined #ruby
dbgster has joined #ruby
chad_ has joined #ruby
<Tasser> hackbox, which part of webrick? you want to run it for a rack app and don't care about the internals? you want to mess with them?
Bonkers has joined #ruby
BeLucid has joined #ruby
boonedocks has joined #ruby
yoklov has joined #ruby
jgarvey has joined #ruby
ryannielson has joined #ruby
brngardner has joined #ruby
<hackbox> mess with them, i will use it as server running on a particular port
<hackbox> to accept incoming request to an underlying api providing a service
kpshek has joined #ruby
mstratman has joined #ruby
btaitelb has joined #ruby
mutewinter has joined #ruby
Indian_ has joined #ruby
kevinbond has joined #ruby
mrmist has joined #ruby
nilg` has joined #ruby
jjp has joined #ruby
phantasm66 has joined #ruby
aszurom has joined #ruby
<aszurom> clear
_root_ has joined #ruby
Sailias has joined #ruby
<aszurom> apparently typing the / helps
<aszurom> does ruby understand posix path shortcuts like ~/ or must I give a full path to a file I want to open?
<MarcWeber> aszurom: I'm pretty sure there is File.expand or such.
<aszurom> I'm embarking on my first ever lines of ruby code today, and the project I picked for it is opening a CSV file, totalling up the columns and finding the max and average of each column.
<aszurom> looking at ruby-doc for csv, I see where I could do CSV.parse( ) either by row or into an array of arrays
uris has joined #ruby
<aszurom> CSV.foreach("path/to/file.csv")
fmcgeough has joined #ruby
davidw has joined #ruby
fmcgeough has joined #ruby
<aszurom> if I did this in powershell, it would create an object for the CSV file's contents and it automatically knows what the row headers are and such. Not sure what I'm going to get with ruby
<apeiros_> aszurom, MarcWeber: File.expand_path
<workmad3> aszurom: CSV.foreach(path, :headers => true, :header_convertors => :symbol) do...
<aszurom> hot, thanks
tomzx has joined #ruby
<workmad3> aszurom: you can then access each header with row[:title]
<aszurom> boy that sure doesn't look like perl :-)
<workmad3> :)
<workmad3> aszurom: do be careful with the headers in the CSV though, they need to be header1,header2,header3,... (i.e. no whitespace)
<aszurom> so the :headers => true is a boolean test to see if the file object responds to the headers method?
<workmad3> aszurom: no, it's a config option to the CSV.foreach method to say 'this CSV file has headers'
<aszurom> I have no clue what that :stuff => does
<aszurom> ok
<workmad3> aszurom: it's a common ruby idiom for passing in things that look like named arguments (you'll understand what's actually happening as you learn more, but they're basically used as named parameters to methods :) )
<aszurom> ok, makes sense
<workmad3> aszurom: so in that case, you're saying 'this CSV file has headers, and convert headers to symbols' which is why you can do 'row[:foo]' rather than 'row["foo"]'
steg132 has joined #ruby
maesbn has joined #ruby
<aszurom> how would I incorporate apeiros's File.expan_path into that?
elliot_ has joined #ruby
LBRapid has joined #ruby
<workmad3> aszurom: CSV.foreach(File.expand_path("relative/path"), :headers => ...)
<aszurom> actually...
<workmad3> (that would do it inline, anyway)
<aszurom> let's say I'm going to pass the filename to the app when I invoke it on the command line
<aszurom> ruby myapp.rb filename.csv
<aszurom> can I do it like that?
netzapper has joined #ruby
<hackbox> yes then you access it with ruby constant ARGV
<hackbox> ARGV holds an array
lucasefe has joined #ruby
DMKE has joined #ruby
<shevy> and a baby
<shevy> aszurom filename.csv would be contained in ARGV[0] in that example
<aszurom> cool
<hackbox> yes
<aszurom> ugh. I attempted "gem install redcar" and it blew up. Gem uninstall redcar isn't letting me remove the partially installed thing. Is the common?
<Tasser> aszurom, and the file object in ARGF[0]
<aszurom> can I clean it up by hand?
<aszurom> nevermind, I puzzled it out
cookies has joined #ruby
<aszurom> just some rm -R fun
cookiescrumbs has joined #ruby
SheikPunk has joined #ruby
looopy has joined #ruby
maxamillion has joined #ruby
theRoUS has joined #ruby
mattyoho has joined #ruby
thone_ has joined #ruby
<aszurom> CSV is a built in class, right?
jeebster has joined #ruby
jenglish has joined #ruby
<aszurom> my oop terminology may be poor, since I don't do much other than some simple scripting and it's generally not object oriented
snip_it has joined #ruby
<hackbox> yes built in
<hackbox> stdlib
<aszurom> should it function in irb?
<hackbox> yes using require it will
<shevy> aszurom you can clean up by hand
<aszurom> shevy, I got it already
<aszurom> thanks
<shevy> you learn quickly
<aszurom> I couldn't get the automation to do it but it was plain enough once I went into the folder
<aszurom> I'm a master deleter
<shevy> I too
<aszurom> rm -R /*
<shevy> I removed /usr/include and thought I could recover
<shevy> now I cant compile anything :(
<aszurom> compilation is overrated anyway
<shevy> aszurom I did that once, but with a misplaced tab completion expanding a long line with a / too
ElitestFX has joined #ruby
<aszurom> I haven't done it, but a sysadmin at my first job did. He was sitting next to me. I saw the "oh shi" look hit him
<aszurom> hackbox, so at the irb prompt I should type "require CSV" or what?
josefig has joined #ruby
<aszurom> I'm apparently doing it wrong
<shevy> require always wants a string
<shevy> when you do:
<shevy> require CSV
<shevy> you would try to require some constant
<shevy> require 'csv'
<aszurom> ah
<shevy> should do... or 'fastercvs' or 'csv' I cant get it right
<hackbox> yes
zakwilson has joined #ruby
<hackbox> aszurom worked?
<aszurom> amazing, it worked
<aszurom> since the headers have spaces in some of them it looks like I'll have to address that by hand somehow
<aszurom> so if I do var = CSV.read("file.csv") then var is now an array of the lines in the file. Is each item in var an array or list of the comma separated values that were on the line? Is there a difference in a list and an array in this case?
cookiescrumbs has quit ["Leaving..."]
<hackbox> try var.each{|y| puts y} to be sure
fmcgeough has joined #ruby
keymone has joined #ruby
<aszurom> I get the same output as if I'd said "puts var"
_root_ has joined #ruby
<aszurom> each row is "item", "item", "item"
<aszurom> actually...
Synthead has joined #ruby
<aszurom> ["item", "item", "item"]
<hackbox> aszurom let csv process the file output(not too familiar with csv)
<hackbox> there must be a method
chson has joined #ruby
thams has joined #ruby
CreativeEmbassy has joined #ruby
<aszurom> is there a ruby ide that has enough autosense to be able to expand when I type something like File.ex? to expand that?
<aszurom> Chocolat and Sublime Text don't do it
<aszurom> is Rubymine that smart?
tarelerulz has joined #ruby
michael_mp has joined #ruby
tommyvyo has joined #ruby
mcwise has joined #ruby
<robacarp> autocomplete is the debbil
SQLStud has joined #ruby
<hackbox> get netbeans and install ruby plugin
thecreators has joined #ruby
<gogiel> aszurom: RubyMine is great tool. try it
lkba has joined #ruby
<aszurom> yeah, I was just checking out rubymine over in the coder pit
<aszurom> our dev team uses it
<tarelerulz> What is the most complex program any of you have made in Ruby ?
<hackbox> you will hear of mine when i'm done so far i have written over 2000 lines in ruby alone
KL-7 has joined #ruby
mutewinter has joined #ruby
<robacarp> what
kvirani has joined #ruby
<shevy> lol
<shevy> hackbox that should not take long
<shevy> tarelerulz, define "program"
<shevy> a single standalone class that does not use any other class?
<shevy> in that case, I suppose that is around 300 or 400 lines
<hackbox> yeah but that's not the only thing i'm doing...
bglusman has joined #ruby
<robacarp> hackbox: I want to hear of yours now, what is it?
vitor-br has joined #ruby
<tarelerulz> Could you make a calculator ?
sebastian_pl has joined #ruby
<hackbox> i would have loved to but you know, business ethics will not allow me to
<robacarp> tarelerulz: why are you asking these nonsensical questions?
<tarelerulz> How would you chose what program language to start with?
<hackbox> Thank You ALL, You all are nice cool guys have a nice time, i'm out
asumu has joined #ruby
hackbox has quit [#ruby]
<robacarp> tarelerulz: as a brand new programmer?
<asumu> Hi. I've been experimenting with yield and had a quick question about this code: http://pastebin.com/kdmRspVK
<asumu> The code works as expected with the order of arguments in the block in useInject.
<shevy> tarelerulz what kind of questions are that. you dont even give any feedback to us
<asumu> But this order seems to be the reverse of the yield.
<asumu> Is that how yield should work? (a few sources seem to say no)
<shevy> I dont even know what is going on in that code asumu
<asumu> shevy: useInject() should sum the even numbers from 1 to 1000.
<tarelerulz> Well, I'm learn C++ and having hard time and I though I learned something else I could learn the basic concepts and learn a better language in the future
<shevy> that is cool asumu which inject() are you using?
<shevy> tarelerulz ruby is a lot easier than C++
<shevy> you can learn ruby any time. C++ is harder, as is C.
<asumu> shevy: there's a definition of inject() in the paste too, which is what I think I'm using.
<shevy> asumu I see that there is a definition of inject(), the question is still whether you are using it or not
<shevy> the only usage of an inject I see is this:
<shevy> (1..1000).inject(0)
goldenwest has joined #ruby
<shevy> and that is calling the inject method on a Range I suppose
<shevy> class Range; def inject
<shevy> (or wherever inject is defined, perhaps Enumerable.)
jbw has joined #ruby
mikepack has joined #ruby
<asumu> shevy: Ah, I see. It's calling the built-in inject. That's my problem, I think. Thanks. :)
<shevy> you should also consider changing the code with yield a bit
<shevy> for instance, right now it always tries to yield
<shevy> even when there is no block given to a method
<shevy> call_my_method('bla')
<shevy> vs
<shevy> call_my_method('bla') { 'this is what I pass in the block' }
<shevy> you can do something like:
<shevy> yield(v, state) if block_given?
<shevy> well
<shevy> state would not be defined in that case
<shevy> but I think your code returns nil if no block was given right now anyway
CheeToS has joined #ruby
<asumu> I see, thanks. The code worked once I renamed inject to myInject to avoid the name clash.
<shevy> hehe cool
ephemerian has joined #ruby
oooPaul has joined #ruby
BSaboia__ has joined #ruby
IPGlider has joined #ruby
replore_ has joined #ruby
looopy has joined #ruby
Jackneill has joined #ruby
_ramok has joined #ruby
ckrailo has joined #ruby
boonedocks has joined #ruby
dwon has joined #ruby
bluenemo_ has joined #ruby
bluenemo_ has joined #ruby
<robacarp> blocks man. brilliant.
<netzapper> I'm writing a dsl in ruby (a macro language for an assembler). Is there a good way for a DSL call like "foo(x, y, z)" to be converted to a ruby call like "foo(:x, :y, :z)"? Or is my best bet to intercept in method_missing?
shruggar has joined #ruby
bawer has joined #ruby
<any-key> def foo(*arr); arr.map!(&:to_sym); end
adeponte has joined #ruby
bluenemo has joined #ruby
bluenemo has joined #ruby
bluenemo has joined #ruby
martman has joined #ruby
<netzapper> any-key: that gives me "undefined local variable or method `x' for main:Object" in irb. Which is kind of to be expected, since it's going to try to bind 'x' before passing it as an argument.
<martman> is there anyway to store a method's call, with its arguement and not execute it? just save it to a variable so it can be execuated later?
<martman> i see .method does something like this
<martman> but i dont think it can keep the arguments too
<netzapper> martman: you can just keep them in an array. Like 'saved_call = [method, arga, argb, argc]'. Then you can call it with 'saved_call[0](*saved_call[1..-1])'.
Sou|cutter has joined #ruby
eph3meral has joined #ruby
<martman> netzapper awesome, ill try that
<martman> thanks alot
jlogsdon has joined #ruby
<Tasser> netzapper, nope, you can't
<any-key> netzapper: you wanted foo to process a series of symbols, right?
ben_alman has joined #ruby
<netzapper> Tasser: I can't? Damn. Thought that worked.
<Tasser> netzapper, ... the first one, at least
<Tasser> you could, with the scope your method call in defining method_missing
<netzapper> Tasser: yeah, that's what I thought I'd need to do.
carlyle has joined #ruby
<Tasser> netzapper, for any heavy macros, use lisp :-)
twinturbo has joined #ruby
<netzapper> Tasser: it's already weird enough to write an assembler in ruby. I don't think added a lisp interpreter is a good idea.
<Tasser> ^^
zakwilson has joined #ruby
<Tasser> or you could use ripper and parse the ruby yourself
<martman> saved_call[0](*saved_call[1..-1])
flagg0204 has joined #ruby
<martman> gives me syntax error, unexpected '(', expecting $end netzapper
grin has joined #ruby
LiquidInsect has joined #ruby
nilg` has joined #ruby
<netzapper> martman: oh, hell. It may be saved_call[0].call(). I don't remember. But, that basic idea should work.
<netzapper> or some sort of nonsense with & operator or something.
bluenemo has joined #ruby
bluenemo has joined #ruby
bluenemo has joined #ruby
bluenemo has joined #ruby
<martman> mind taking a look at http://pastie.org/3823317
<martman> gives me : args.rb:1:in `foo': wrong number of arguments (0 for 2) (ArgumentError) from args.rb:9:in `<main>'
theRoUS has joined #ruby
theRoUS has joined #ruby
jirifabian has joined #ruby
albemuth has joined #ruby
<netzapper> martman: splat the array? Like ".call(*saved_call[1..-1])".
<netzapper> oh!
<martman> hmm, same error
<martman> ...idea?
<netzapper> yeah, it's actually trying to call 'foo'. I thought [&foo,...], but that's not it.
<robacarp> I guess no answers in 16 hours means I'm not terribly crazy.
nlc has joined #ruby
frogstarr78 has joined #ruby
<netzapper> martman: it looks like Proc will handle the args, too.
bluenemo_ has joined #ruby
baroquebobcat has joined #ruby
<martman> hmmm
<martman> and that wont execute it?
dkissell has joined #ruby
<netzapper> martman: "saved_call = [lambda {|a, b, c| foo(a, b, c)}, x, y, z]"...."saved_call[0].call(*saved_call[1..-1])"
strk has joined #ruby
flagg0204 has joined #ruby
niklasb has joined #ruby
<martman> woah
keymone has quit [#ruby]
bluenemo__ has joined #ruby
bluenemo__ has joined #ruby
<martman> bit confused by whats a variable and whats just a place holder
<netzapper> martman: sorry. Let me pastebin that shit for you.
<martman> ...
<martman> ?
<shevy> omg
<shevy> omg
<shevy> [lambda {|a, b, c| foo(a, b, c)}, x, y, z]"...."saved_call[0].call(*saved_call[1..-1])
PaciFisT has joined #ruby
<shevy> !!!!!!!!!
<shevy> someone is abusing ruby!
<martman> ?
<oooPaul> I abuse it all the time. :)
<shevy> oooPaul I have yet to see code from you like that!
<oooPaul> Didn't you see my [x.to_i, x.to_f].max solution yesterday? ;)
<netzapper> martman: http://pastie.org/3823381
<shevy> that is simple short and clean
<Mon_Ouie> Veejay: I think either a case construct or message passing can be used instead most of the time in Ruby
kenperkins has joined #ruby
<martman> and then later i execute it with saved_call[0].call(saved_call[1..-1])
eywu has joined #ruby
<martman> netzapper? that gives me args.rb:6:in `block in package_foo': wrong number of arguments (1 for 3) (ArgumentError)
<netzapper> martman: that sucks.
<martman> yep
<shevy> hehehe
eywu has joined #ruby
<martman> also sucks since that actually made some sense to me...
<netzapper> martman: it works for me. Like, I copied that into a script, ran it. It works for me.
rramsden has joined #ruby
lidashuang_ has quit ["离开"]
bluenemo has joined #ruby
<martman> netzapper so it looks like this? http://pastie.org/3823412
rramsden has joined #ruby
<netzapper> martman: no. Did you miss the function "run_saved_call". That has the syntax in it you need. Or, you can just call that function with your saved call arrray.
<Veejay> Mon_Ouie: Yeah, it is neither useful nor efficient
goldenwest has joined #ruby
<Veejay> It makes for very readable code though
<martman> fml
<martman> thanks alot
<Veejay> Mon_Ouie: Like this https://gist.github.com/2429854
<Veejay> 30 times slower than map haha
<shevy> well done
jgrevich has joined #ruby
jgrevich has joined #ruby
ecolitan has joined #ruby
<Veejay> But I really like how it's more natural a style when coming from FP
<shevy> that -> is so weird to see
<oooPaul> shevy: I have code in this project that dynamically creates classes based on the contents of a WSDL... There's some pretty hairy abuse in there. ;)
<Veejay> Ruby really is a neat language
davidcelis has joined #ruby
<oooPaul> +1
bluenemo has joined #ruby
bluenemo has joined #ruby
devjj has joined #ruby
ephemerian has joined #ruby
cloke has joined #ruby
cloke has joined #ruby
luckyruby has joined #ruby
bluenemo has joined #ruby
bluenemo has joined #ruby
rippa has joined #ruby
luxurymode has joined #ruby
_Garbage_ has joined #ruby
cooler has joined #ruby
<cooler> goof morning
Araxia_ has joined #ruby
desrever1 has joined #ruby
netzapper has joined #ruby
cpruitt has joined #ruby
npinchot has joined #ruby
Vert has joined #ruby
<SheikPunk> hello guys.
<SheikPunk> somebody can help me with an encoding string question?
stu__ has joined #ruby
n1x has joined #ruby
macmartine has joined #ruby
tobor_one has joined #ruby
tewecske has joined #ruby
zakwilson has joined #ruby
cwang has joined #ruby
maletor has joined #ruby
lorandi has joined #ruby
thams has joined #ruby
andrewhl has joined #ruby
anildigital has quit [#ruby]
williamcotton has joined #ruby
strk has quit [#ruby]
savage- has joined #ruby
davidpk has joined #ruby
adamkittelson has joined #ruby
thams has joined #ruby
zakwilson has joined #ruby
williamcotton_ has joined #ruby
bluenemo has joined #ruby
bluenemo has joined #ruby
bluenemo has joined #ruby
bluenemo has joined #ruby
bluenemo has joined #ruby
bluenemo has joined #ruby
<shevy> SheikPunk it is useless to ask to ask. people could say "yes" but what if they can not answer your question? you should ask your question directly, and then you will see whether someone can help or not
<SheikPunk> shevy: thats ok… let me ask.
<SheikPunk> shevy: I'm making some http requests like a web service. my request body is xml content and the web service response is xml too.
ctwiz has joined #ruby
<SheikPunk> I'm using httparty for that.
stkowski has joined #ruby
Chryson has joined #ruby
johnmilton has joined #ruby
<SheikPunk> so… the problem is… the response have some invalid chars… something like a encoding problem
<SheikPunk> and i need fix that.
robbyoconnor has joined #ruby
<SheikPunk> somebody knows?!
johnmilton has joined #ruby
r0bby has joined #ruby
<shevy> it contains invalid encoding like disp?e
williamcotton_ has joined #ruby
tommyvyo has joined #ruby
<shevy> you could try to force it into some encoding
<shevy> like:
<shevy> z = y.force_encoding("ASCII-8BIT")
guns has joined #ruby
rippa has joined #ruby
Zoxc has joined #ruby
kjellski_ has joined #ruby
minijupe has joined #ruby
francisfish has joined #ruby
brianpWins has joined #ruby
greenarrow has joined #ruby
Advocation has joined #ruby
SegFaultAX|work has joined #ruby
Ankhers has joined #ruby
<minijupe> Is there way to suppress deprecation warnings? I'm working on an old app that has a plugin causing deprecation warnings. I'd rather not change that plugin manually.
ed_hz_ has joined #ruby
replor___ has joined #ruby
<SheikPunk> shevy: i think it not have big changes...
bluenemo has joined #ruby
bluenemo has joined #ruby
<shevy> minijupe perhaps modify $VERBOSE before loading that, and re-enable it again lateron
td123 has joined #ruby
<minijupe> shevy: you mean before requiring the file? I think the parts of the plugin that are triggering the warning happen at runtime, not load time.
maxok has joined #ruby
<minijupe> I'd also rather not disable all deprecation warnings, just the ones from that plugin.
<shevy> hmm
<minijupe> Is there a way to disable on a line by line basis?
<shevy> I think there is not :(
<minijupe> I think I remember other languages (like php, perl) have this feature.
xcvd has joined #ruby
Zolrath has joined #ruby
ElitestFX has joined #ruby
ElitestFX has joined #ruby
Eiam has joined #ruby
filemon_CZ has joined #ruby
<SheikPunk> shevy: so… i think that string already have the ascii encoding.
<SheikPunk> pry(#<HotelService::Transhotel:0x10166a010>):1> request.body.encoding
<SheikPunk> => #<Encoding:ASCII-8BIT>
sebastian_pl has joined #ruby
Drewch has joined #ruby
<shevy> SheikPunk then it should not fail
nfluxx has joined #ruby
stephenjudkins has joined #ruby
<SheikPunk> shevy: but the invalid chars keep on string
<shevy> well
<shevy> this is the Encoding situation for ya
<shevy> welcome to the evolution of ruby
zakwilson_ has joined #ruby
elliot_ has joined #ruby
<shevy> I am still on 1.8.7
<lectrick> Why am I choking already this morning? No coffee yet I guess. How do I define a (lambda|proc|block), assign it to a variable, and then pass that block to a method which takes blocks?
<Mon_Ouie> methhod(&block)
<SheikPunk> shevy: hm… :(
<SheikPunk> shevy: can i try another thing?
brngardner has joined #ruby
<SheikPunk> Iconv not works too.
mrsolo has joined #ruby
<shevy> SheikPunk dunno
<shevy> try to push the xml shit there into some thing that is valid
<SheikPunk> shevy: hm… got confused? like what?
SPYGAME has joined #ruby
voodoofish430 has joined #ruby
williamcotton_ has joined #ruby
Jakee` has joined #ruby
djbkd has joined #ruby
r0bby has joined #ruby
<banseljaj> hey shevy
RegEchse has joined #ruby
Drewch has joined #ruby
<banseljaj> I hate Random
bluenemo has joined #ruby
williamcotton_ has joined #ruby
axl_ has joined #ruby
netogallo has joined #ruby
shruggar has quit [#ruby]
<lectrick> I can't assign a lambda to a constant??
<lectrick> "error: dynamic constant assignment" grrrr
stkowski_ has joined #ruby
rexbutler has joined #ruby
<lectrick> oh i was in an instance method. Is that why?
TheIronWolf has joined #ruby
<eph3meral> what do I use to catch any and all errors/exceptions in a rescue blocK?
<eph3meral> rescue RuntimeError => e ?
<eph3meral> i thought just plain old rescue e would do it but that gives me a syntax error
<withnale> How do I fix this? '`gem_original_require': no such file to load -- spec (LoadError)' when I type ruby -rubygems "require 'spec'"
pdtpatrick has joined #ruby
<rippa> lectrick: yes, that was why
<lectrick> rippa: I bought it. Moved to a class constant where it made more sense. Thanks.
ccapndave3 has joined #ruby
* lectrick loves this fucking language.
<lectrick> i'm still in the honeymoon phase after 5 years.
<lectrick> Now if I could only find a girl like that.
bandu has quit ["Leaving"]
Sailias has joined #ruby
mrsolo has joined #ruby
bubz has joined #ruby
kvirani has joined #ruby
<bubz> I'm using the ipaddress gem and am looking to be able to pass in an address like '10.1.2.3-10'. I'm finding this unsupported. I tried to instantiate with the .3 address alone and then the .10 address alone in order to somehow enumerate the between/difference or something, but I'm coming up short. Anybody have any ideas how to get all hosts with a hyphen range instead of /CIDR?
kirun has joined #ruby
pubis has joined #ruby
chomp has joined #ruby
goldenwest has joined #ruby
<aszurom> if I have an array with 10 elements, and I want to read and remove the first element, is there a "pop" in ruby?
<banseljaj> Success. I can now genreate random statistical data.
mmokrysz has joined #ruby
<rippa> aszurom: pop removes last element
<rippa> shift removes first
<aszurom> banseljaj is ready to work for the government now
<banseljaj> aszurom: I already dooooo.... :P
<aszurom> random statistical data was a giveaway
<lectrick> Anyone know what it means when a YAML.dump writes a value of something like "*id011" for a key?
<lectrick> Is that the object_id of... something?
<aszurom> I wish presidential candidates were like D&D characters, and we could just re-roll low wisdom scores until we get one we like
<ged> bubz: [2] pry(main)> rng = (IPAddr.new('10.1.2.3')..IPAddr.new('10.1.2.10'))
<ged> [3] pry(main)> rng.to_a
<ged> => [#<IPAddr: IPv4:10.1.2.3/255.255.255.255>,#<IPAddr: IPv4:10.1.2.4/255.255.255.255>,...]
<lectrick> aszurom: shift. If you want to do Ruby right, study the Array, Hash and Enumerable classes in detail. :)
<Veejay> aszurom: head, *tail = *your_array
atmosx has joined #ruby
<Veejay> BOOM, head contains the head and tail contains the tail
<banseljaj> aszurom: :D
<ged> bubz: Or you can use any Enumerable method.
goldenwest has joined #ruby
<ged> But that's using the 'ipaddr' library from 1.9.3.
<Veejay> If the array contains only one element, head contains that element, and tail will be []. Now if the original array is empty, head will be nil and tail will be [].
ahmdrefat has joined #ruby
<Veejay> Or shift, as previously mentioned
<davidcelis> car/cdr
<banseljaj> Hmm. What would be the best way to make a CSV file out of instances of a class?
<aszurom> if the head eats the tail == ragnarok?
<banseljaj> I want to make a CSV file output out of my RandomData class
headius has joined #ruby
<davidcelis> aszurom: You mean ouroboros?
<rippa> also Jormungandr
mborromeo has joined #ruby
<bubz> ged: Thanks! I gave up in ipaddr due to its limitation with enumerating hosts in a /cidr range. Looks like I'll need both for this current effort
yoklov has joined #ruby
atmosx has quit [#ruby]
<davidcelis> rippa: good catch
<ged> bubz: what limitation does it have for CIDR ranges?
<ged> bubz: [10] pry(main)> rng = IPAddr.new( '192.168.16.0/24' ).to_range
<ged> => #<IPAddr: IPv4:192.168.16.0/255.255.255.0>..#<IPAddr: IPv4:192.168.16.255/255.255.255.0>
ph34r_ has joined #ruby
<ged> And then the same thing as above from the Range...
stephenjudkins has joined #ruby
burgestrand has joined #ruby
jimeh2 has joined #ruby
<bubz> ged: I was unable to find that functionality in the docs. Thanks for pointing it out. Now I can be dependency-free for the time being. I'm fairly new to ruby so thanks for the guidance
dankest has joined #ruby
<ged> bubz: Yeah, happy to help. :)
Bosma has joined #ruby
shruggar has joined #ruby
DrShoggoth has joined #ruby
banisterfiend has joined #ruby
Russell^^ has joined #ruby
shadoi has joined #ruby
banisterfiend has joined #ruby
__Grabarz__ has joined #ruby
__Grabarz__ has quit [#ruby]
c0rn has joined #ruby
krz has joined #ruby
kenichi has joined #ruby
<shevy> long
<shevy> live
<shevy> ruby
<shevy> !
<davidcelis> mruby*
<davidcelis> FTFY
Vert has joined #ruby
<lectrick> We have a complicated rails app stack with an irreproducible bug and I'm trying to trace any changes to the request headers. (Asking here because #rubyonrails are noobs.) I was considering injecting a trace on the []= method on the request.headers object and filtering by what I'm looking for, is this a ludicrous idea or?
Eldariof-ru has joined #ruby
apok has joined #ruby
macmartine has joined #ruby
<matti> Vote Shevy!
shruggar has joined #ruby
<LiquidInsect> lectrick: you're trying to watch what's getting pushed in to the headers object and when?
<LiquidInsect> sounds reasonable enough
<lectrick> LiquidInsect: Yes. I'm trying to trace the setting (or mutating, unsetting etc.) of specific values (all values would probably be way too much info)
<shevy> matti \o/
<LiquidInsect> using pry or something similar, or just logging a trace each time?
mikeg has joined #ruby
apeiros_ has joined #ruby
<wargasm> yo. anyone familiar with using mechanize and handling cookies? i'm a scrub trying to automate something and on the last step of my script, i'm using POST to pass in some data, but getting redirected to a page that says "Your session has expired. Please go back and resubmit your data"
rexbutler has joined #ruby
Ankhers has joined #ruby
<wargasm> i'm assuming that the session id or whatever is triggering this is stored in the cookies and i need to pass that along with the rest of the form data?
lockweel has joined #ruby
pdtpatrick has joined #ruby
asumu has quit [#ruby]
<LiquidInsect> wargasm: I think all cookies you receive from the server should be sent back with every request
KL-7 has joined #ruby
<wargasm> hm alright, thanks.
yoklov has joined #ruby
elliot_ has joined #ruby
mmokrysz1 has joined #ruby
ales has joined #ruby
mmokrysz has joined #ruby
thams has joined #ruby
chad_ has joined #ruby
SQLStud has joined #ruby
mrmist has joined #ruby
shruggar has joined #ruby
shruggar has joined #ruby
tayy has joined #ruby
<lectrick> LiquidInsect: There are too many requests and this happens too rarely to use Pry. I'd have to log everything and discard uneventful traces. This understandably has a performance impact which I will have to watch carefully
sterNiX has joined #ruby
Aristata1 has joined #ruby
stephenjudkins has joined #ruby
<Aristata1> Can anyone tell me if this active record query syntax is correct? Person.all({:conditions => ["full_name like '%#{@term}%"]})
<daed> no
<Aristata1> drat
<Aristata1> This is ActiveRecord 2.3.12 by the way
<daed> Person.where('full_name LIKE ?', "%#{@term}%")
<daed> something more like that
<daed> oh
<daed> oh man i haven't used 2.3 in so long i can't even remember
<Aristata1> Yeah, no where or anything
<daed> lordy lordy
<Aristata1> You're tellin me :(
<daed> i'm so glad my company makes a huge effort to keep all rails apps up to date
Ethan has joined #ruby
<matti> shevy: :)
<daed> deploying a 3.0 to 3.2 release on monday
<Aristata1> This i a very old customer, and they are back.
<Aristata1> We can't afford to upgrade this project without them paying a LOT of money for it.
sterNiX has joined #ruby
<Aristata1> It would probably be 100k + to upgrade
<daed> where does one go for really old activerecord documentation?
<Aristata1> I tried rubydoc but didn't have much luck
<daed> that's the hidden cost of NOT updating though
<daed> heh
<Mon_Ouie> rubydoc keeps documentation for gems or you generate it yourself when you install the gem
<daed> going to be harder as time goes on to keep it secure/extendable
elliot_ has joined #ruby
chad_ has joined #ruby
<Aristata1> Unfortunantly I install everything with —no-rdoc --no-ri
<Aristata1> :)
<Aristata1> I am so awesome
<Aristata1> I suppose I could unpack the beast
<Mon_Ouie> I wonder why people do that — it makes it so much more inconvenient to browse the documentation
banisterfiend has joined #ruby
bwlang has joined #ruby
johnmilton has joined #ruby
sterNiX has joined #ruby
<eph3meral> Mon_Ouie, unless, like me, you echo "gem: --no-rdoc --no-ri" >> ~/.gemrc
<eph3meral> :)
StevenR121 has joined #ruby
<eph3meral> Mon_Ouie, actually I disagree, i prefer browsing the docs online
<eph3meral> Mon_Ouie, mostly because rdoc/ri cause gems to take like a bazillion times longer to install
Muz has joined #ruby
laen_ has joined #ruby
maesbn has joined #ruby
<Aristata1> Well if any of you were wondering. I KNOW YOU WHERE: this is correct: .all(:conditions => ["full_name LIKE ?", '%somwhtin%'])
<Mon_Ouie> It installs them after the gem, you can start using the gem before it's done if you're in a rush
chad_ has joined #ruby
frogstarr78 has joined #ruby
<Mon_Ouie> The main benefits are getting the documentation from ri and being able to access it even if you don't have an internet access for some reason
adeponte has joined #ruby
thecreators has joined #ruby
rexbutler has joined #ruby
soveran has joined #ruby
symb0l has joined #ruby
bgupta has joined #ruby
<Aristata1> Mon_Ouie: I am overly paranoid of one mp3 not fitting on my hardrive because of some rdoc
<Aristata1> Plus, if I have no internet, I sure as hell am not working that day!
shiroginne has joined #ruby
<Mon_Ouie> Not working ≠ not programming for me ;)
<Aristata1> Not working = Enjoying some camping or hiking or bar time.
<Aristata1> And waiting patiently until my sentence in this god awful chicagoland is over
<heftig> but that means leaving the house :(
<Aristata1> Anyone know why #ror is invite only all of the sudden?
<heftig> it's not
<Aristata1> Keeps telling me it is
mborromeo has joined #ruby
<heftig> try registering with nickserv
k_m has joined #ruby
<Aristata1> Wait
<Aristata1> wtf
<Aristata1> I am Aristata
ringotwo has joined #ruby
<Aristata1> but it says its being used :(
<Aristata1> That's probably why
<Aristata1> Who the hell is using my nick
<heftig> ghost?
<heftig> try /msg nickserv identify nick password
<heftig> then /msg nickserv ghost aristata
<heftig> followed by /nick Aristata
<minijupe> shevy: Found a rails solution: ActiveSupport::Deprecation.silence do end
<Aristata1> Hrm
<Aristata1> Says Aristata is being used.
statix has joined #ruby
<Aristata1> AND Aristata!
<Aristata1> 1
<heftig> you need to ghost it first
<Aristata1> Lame
<Aristata1> How do I do that?
<heftig> i just told you
<matti> Mon_Ouie: O, hai :)
<heftig> ask nickserv to identify, ghost, then nickchange
<Mon_Ouie> matti: 'alut ;)
<Aristata1> notice) You may not ghost Aristata.
<Aristata1> 2:18
<Aristata1> (notice) You may not ghost aristata.
<heftig> did you identify?
<Aristata1> yeah a long long time ago
<heftig> you're not identified right now
<Aristata1> hmm
<heftig> do /msg nickserv identify aristata <password>
n3m has joined #ruby
<Mon_Ouie> You can add the password as another argument to the ghost command
axl_ has joined #ruby
<Aristata1> hmm
tvw has joined #ruby
<Aristata1> Says I am logged in as aristata
<Aristata1> whatever
<Aristata1> maybe I messed something up on my home comp
<Aristata1> If I am logged in there am I unable to log in elsewhere?
zakwilson has joined #ruby
tommyblue has joined #ruby
<freakeasy> hmm
<freakeasy> I like this nick way better anyway
<freakeasy> thanks heftig
<freakeasy> You have to promise never to let anyone know freakeasy and aristata are the same person, or there will be a ww 3
yannis has joined #ruby
goldenwest has joined #ruby
_ramok has quit [#ruby]
workmad3 has joined #ruby
cool_brandon has joined #ruby
monkeyarmada has joined #ruby
davidpardy has joined #ruby
mattyoho has joined #ruby
zakwilson has joined #ruby
jfelchner has joined #ruby
bwlang_ has joined #ruby
dbgster has joined #ruby
barraponto has joined #ruby
<barraponto> 194 is givin me issues with ssl :/
mborromeo has joined #ruby
w1mark has joined #ruby
axl___ has joined #ruby
<barraponto> rubygems redirects me to cloudfront and i get handshake failures :/
banjara has joined #ruby
d3c has joined #ruby
<td123> barraponto: check out the release notes, the biggest changes were related to ssl
<barraponto> yeah.
nif has joined #ruby
<w1mark> how do you run scripts in ruby? Im trying to just make a .txt/.rb file and run it through the interactive ruby cmd prompt.
banjara has quit [#ruby]
<wargasm> ruby nameofscript.rb in shell
<w1mark> thanks, I think it works, but my file just made a function instead of actually executing anything oops.
indigenous has joined #ruby
<w1mark> yay it works... thanks
<w1mark> so, do you need to make a main function in ruby...?
<w1mark> or do you just execute code after your function definitions?
<ozzloy> w1mark, stuff at the top level gets executed
<ozzloy> w1mark, so you don't need a main
<ozzloy> w1mark, for example if you make a file with just "puts 'hello world!'" it print out hello world!
<w1mark> yea, I just noticed that.
<lectrick> Can anyone fix my deep hash traversal method here? https://gist.github.com/2431329 There's a failing test and everything. Thanks in advance. Anyone good at recursion and end conditions would beat it in 2 seconds probably.
bwlang_ has joined #ruby
<w1mark> didn't really understand when you said top level though
<w1mark> but I guess it executes code as long as it's not a in a function definition
<workmad3> w1mark: the top level is code that isn't inside class, module, method definitions, etc
<workmad3> w1mark: e.g. stuff 'at the top' :)
xcvd has joined #ruby
<w1mark> ah ok, that's what I was guessing, but I didn't know the terminolgy
<w1mark> horrible spelling for the win.
davidpardy_ has joined #ruby
looopy has joined #ruby
ChampS666 has joined #ruby
banjara has joined #ruby
ctwiz has joined #ruby
davidpardy_ has joined #ruby
kiwnix has joined #ruby
headius_ has joined #ruby
<gener1c> mysql2 ftw
yoklov has joined #ruby
banjara1 has joined #ruby
<w1mark> hmmm, reading in a file seems simple enough...
banjara1 has quit [#ruby]
zakwilson_ has joined #ruby
nif has joined #ruby
<lectrick> OK I got my tests passing but I don't like my traverse code :/
<lectrick> Updated the gist
Divinite has joined #ruby
fukushima has joined #ruby
mborromeo has joined #ruby
davidw has joined #ruby
SQLStud has joined #ruby
nif has joined #ruby
Indian has joined #ruby
<barraponto> td123: no luck :/
looopy has joined #ruby
dankest has joined #ruby
heldopslippers has joined #ruby
youdonotexist has joined #ruby
agilobable has joined #ruby
<lectrick> I know there is a way to do what I'm trying to do with inject, sigh
<robacarp> lectrick: what are you trynig to do with inject?
d34th4ck3r has joined #ruby
<lectrick> robacarp: https://gist.github.com/2431329 Look at the "traverse" method.
bwlang has joined #ruby
<kalleth> lectrick: there is ALWAYS a way to do it with inject
<kalleth> no matter what the problem
<lectrick> kalleth: And it's always magical
<kalleth> s/magical/a headfuck
<lectrick> HOLY FUCK I DID IT
* kalleth applause
<josefig> lol
<lectrick> Check out the old and new ones: https://gist.github.com/2431329
<robacarp> lectrick: there you go
<lectrick> i have to say i feel like i just finished a half-mental-marathon
akem has joined #ruby
<lectrick> i mean look at the crap i started with
SegFaultAX|work has joined #ruby
<lectrick> and that was even an improvement on the original code someone wrote, which had a fail condition
lewis has joined #ruby
<lectrick> so I covered it with a test and then turned that bitch ass into a 1 liner
bwlang_ has joined #ruby
<w1mark> how would you read in a tab/space seperated list one item at a time?
<w1mark> read in a .txt file*
<robacarp> read in each line, split by /\w/ or something
<burgestrand> w1mark: depends, can any items contain tabs or spaces?
apok_ has joined #ruby
<w1mark> um, lets say spaces.
<w1mark> er
<w1mark> I mean tabs
<burgestrand> w1mark: no, can any *items* contain tabs or spaces, wether they’re separated by either one does not matter too much
TWIXMIX has quit [#ruby]
zakwilson has joined #ruby
<w1mark> I basically have a names text file.
<w1mark> each line has a first name, followed by a tab for the last name.
<w1mark> I basically just want to throw the names.txt file into a parallel array.
<w1mark> two parrallel arrays*
<burgestrand> w1mark: so then that’s a no, first names cannot contain tabs?
<burgestrand> would be fun to legally change your name to include a tab character
<w1mark> first names don't have tabs or spaces.
<w1mark> I would use the readline function, but I need to sort the file by last name.
<w1mark> which is why im trying to create a parallel array.
burgestrand1 has joined #ruby
<w1mark> ah, the second name is followed by a tab too.
<w1mark> last name*
<w1mark> oops.
ctwiz has joined #ruby
twinturbo has joined #ruby
<shadoi> w1mark: some reason not to use a hash instead of paired arrays?
<w1mark> I just thought it would be easier.
<w1mark> Just picked up ruby recently.
<shadoi> hashes are usually easier to work with
Eldariof-ru has joined #ruby
<shadoi> they just take up more memory
<w1mark> Im more experienced with c++ which I use arrays most often.
<w1mark> don't really have any experience with hashes.
eph3meral has joined #ruby
ctwiz_ has joined #ruby
<w1mark> so how would you use a hash then?
bigdc1 has joined #ruby
horofox has joined #ruby
<horofox> how do i add an element to the beginning of an array?
<shadoi> horofox: unshift
Russell^^ has joined #ruby
<shadoi> w1mark: basically you create a "person" hash, with hash keys as attributes of that persion (like first_name, last_name, jerkyness, etc.)
<shadoi> w1mark: associative array basically.
<horofox> shadoi: ty
ChampS666 has joined #ruby
<w1mark> so basically a struct/class?
<shadoi> w1mark: lighter weight than a struct or class
<w1mark> ok
<shadoi> w1mark: w1mark: h = {}; File.read('names.txt').each {|line| h.fetch(line.split)}
<shadoi> oops, autocomplete fail
zakwilson_ has joined #ruby
headius has joined #ruby
<oooPaul> Hash just maps a key to a value. A class may also have methods defined and bound to the object.
wedgeV has joined #ruby
<w1mark> ; is just the line ender character right?
<rippa> yes
cbuxton1 has joined #ruby
davidw has joined #ruby
soveran has quit [#ruby]
ZachBeta has joined #ruby
xcvd has joined #ruby
<w1mark> im getting an error that the "each" method isn't defined.
<shevy> w1mark you make something wrong then
<Hunner> w1mark: are you calling it with . on an object?
<shevy> w1mark, show code that fails for you at pastie.org so that others can look where the error is
<shadoi> w1mark: sorry, probably each_line
falsetto has joined #ruby
<shadoi> or lines
<rexbutler> Is there a web design or ajax or javascript channel on freenode?
<rexbutler> answer: yes
<shadoi> grats...?
<rexbutler> A particular channel about web design... hmm?
wefawa has joined #ruby
BlissOfBeing has joined #ruby
<shevy> lol
DMKE has joined #ruby
Vendethiel has joined #ruby
fbernier has joined #ruby
banjara has joined #ruby
<Spaceghostc2c> #freenode would have a better idea. there's always /list
williamcotton_ has joined #ruby
<eph3meral> rexbutler, #web ?
Cache_Money has joined #ruby
<dbgster> as long as I have a Gemfile, I can call bundle?
matt_yoho has joined #ruby
<dbgster> I' ran bundle but I get this on my server: bundle: command not found
<dbgster> and I have installed bundler
mattyoho has joined #ruby
tatsuya_o has joined #ruby
horofox has joined #ruby
adeponte has joined #ruby
bglusman has joined #ruby
<Spaceghostc2c> dbgster: Using rvm?
horofox has joined #ruby
<dbgster> Spaceghostc2c: no
michael7 has joined #ruby
redgetan has joined #ruby
apok has joined #ruby
kenperkins has joined #ruby
<Spaceghostc2c> Oh.
mengu has joined #ruby
ben225 has joined #ruby
adeponte has joined #ruby
havenn has joined #ruby
michael7 has joined #ruby
mikepack has joined #ruby
heftig has joined #ruby
hackingoff has joined #ruby
ipnosi77 has joined #ruby
<ipnosi77> ciao
<ipnosi77> !list
ipnosi77 has quit [#ruby]
dkissell has joined #ruby
bwlang_ has joined #ruby
davidamcclain has joined #ruby
davidamcclain has joined #ruby
RegEchse has joined #ruby
havenn_ has joined #ruby
mborromeo has joined #ruby
flagg0204 has joined #ruby
ssnt has joined #ruby
zakwilson has joined #ruby
mattyoho has joined #ruby
<w1mark> how would you create a file and add text to it?
<w1mark> create/edit
imsplitbit has joined #ruby
andrewhl has joined #ruby
campanolix has joined #ruby
eph3meral has joined #ruby
lucasefe has joined #ruby
jitesh_shetty has joined #ruby
havenn has joined #ruby
kallisti has joined #ruby
<Spaceghostc2c> With documentation guiding the way.
<kallisti> what's a good tutorial for someone who's already familiar with programming in a variety of languages?
goldenwest has joined #ruby
<matled> kallisti: I personally really enjoyed the "ruby crystallized" chapter from pickaxe
<kallisti> I guess I'm mostly looking for a walkthrough of the standard libraries and maybe some standard idioms, since I'm familiar with the syntax.
<kallisti> I'll check that out.
headius has joined #ruby
PaciFisT has joined #ruby
bwlang_ has joined #ruby
netrealm has joined #ruby
gbluma has joined #ruby
headius has joined #ruby
Sailias has joined #ruby
rellon has joined #ruby
indigenous has quit [#ruby]
jaysern has joined #ruby
n00by has joined #ruby
<n00by> is it possible to convert hash or array to function argument list?
<heftig> n00by: foo(*arr)
<kallisti> is there something like __name__ == "__main__" (from Python) in Ruby?
<n00by> heftig, thanx a lot, I knew it was damn simple!!!
<heftig> kallisti: $0 == __FILE__
<kallisti> ah
<kallisti> __FILE__ is the current module name, $0 is the same as in bash/perl
<heftig> i assume you want to test if the user launched your script directly
tomzx has joined #ruby
<kallisti> yes
<heftig> right.
<kallisti> I can already piece together most of what Ruby code means, the trick is just getting everything down so that I can do it intuitively.
workmad3 has joined #ruby
kish has joined #ruby
nanderoo has quit [#ruby]
d34th4ck3r has joined #ruby
<kallisti> classes in Ruby do a lot of stuff..
<kallisti> well, I'm looking at File right now. there's a lot of different libraries stuck together in one place.
burgestrand has joined #ruby
<kallisti> I'm looking for a "with file" construct, where a finalizer is called at the end of my block of code. Does that exist?
kish has joined #ruby
guns has joined #ruby
yoklov has joined #ruby
pplask has joined #ruby
<pplask> hi guys
<kallisti> hey
<pplask> I am having problems starting unicorn, can I ask questions about it on this channel?
<banisterfiend> kallisti: File.open {}
<kallisti> ah nice.
<lectrick> kalleth: File.read will auto-close a file and read it in one command. File.write, which only exists on the latest release of Ruby, will do the same for writes.
kish has joined #ruby
<kallisti> eh I'd rather use constant memory.
<lectrick> kalleth: For writes on rubies < 1.9.3 you still have to do File.open(filepath, 'w'){|f| f.write(bigstring)}
shadoi has joined #ruby
<lectrick> constant memory?
artm has joined #ruby
Vendethiel has joined #ruby
<pplask> When I run unicorn, I get this error: http://pastebin.com/8XakvayQ
<kallisti> lectrick: yes, reading the file into memory is less efficient than reading one line at a time.
<kallisti> in this case it likely doesn't matter.
<kalleth> lectrick: you mean kallisti
<kalleth> ;p
<kalleth> i thought someone actually wanted to talk to me then ¬_¬
<lectrick> omg can you guys sort out your names lol. too similar
<lectrick> kallisti: ^
<kallisti> nope
<kalleth> i've had it longer
<kalleth> guarantee
barraponto has quit [#ruby]
<kalleth> '96, i think
<kalleth> maybe 98
* kallisti doesn't care. :P
<lectrick> I haven't had to worry about memory usage when reading files with ruby yet so I'd have to see what is actually more efficient. File.open(file).each should do line by line or perhaps each_line
<pplask> do you know how to help me? http://pastebin.com/8XakvayQ
kish has joined #ruby
<kallisti> lectrick: unless it's a lazy string it would have to be less efficient.
<kallisti> yes that would be good.
<kallisti> lectrick: is that not File::open(file) ?
tommyvyo has joined #ruby
<lectrick> kallisti: Well, if you give that file handle a block, it gets the file handle, and then you can read it however you wish. all at once with f.read or in a different fashion
<lectrick> I'd have to check the File object to be sure
tomv has joined #ruby
<kallisti> so File has an each method? I'm not seeing it anywhere in the docs.
<LiquidInsect> is it in IO?
kish has joined #ruby
<LiquidInsect> File < IO so this is it
<kallisti> ah I see. inheritance.
<lectrick> kallisti: File inherits from IO and IO has foreach
mrsolo has joined #ruby
<kallisti> yes
<lectrick> IO's foreach splits by the default separator
Chryson has joined #ruby
<kallisti> "default seperator" what is that?
<lectrick> it's "\n" by default but you can change that
<LiquidInsect> \n I assume
<kallisti> right I mean where do you do that.
<lectrick> oh wait it's nil by default, my bad http://www.tutorialspoint.com/ruby/ruby_predefined_variables.htm
<LiquidInsect> Look at IO's each method
<kallisti> does Ruby inherit Perl's global variables?
<LiquidInsect> take sa separator as it argument
<kallisti> ah
<kallisti> oh and it defaults to $/
<kallisti> okay
<LiquidInsect> and &/ is "\n"
<LiquidInsect> er
<lectrick> maybe it defaults to \n for IO objects, I would imagine at least, because nil doesn't make much sense (unless you want to read each character separately I guess, but then is it reading a byte or..?)
<LiquidInsect> $/
<LiquidInsect> lectrick: it does
<lectrick> kallisti: Ruby took Perl's globals, yes
<lectrick> FYI there are usually more human-friendly/readable equivalents to the Perl globals
<lectrick> like there is $LOAD_PATH instead of/in addition to $:
<kallisti> hm I installed ruby in Debian but there's no rb command.
<lectrick> it's "ruby"
<kallisti> oh
* kallisti should stop asking dumb questions. :P
<lectrick> the command interpreter or whatever is IRB
<shevy> kallisti debian hates ruby
<lectrick> command "irb"
<lectrick> you can always alias it to rb haha
<shevy> I did that :>
kish has joined #ruby
<kallisti> hm foreach doesn't appear to be a method of File
<lectrick> it's on IO
<lectrick> so File gets it
<lectrick> The docs typically don't show inherited methods
<shevy> kallisti foreach is not needed really
<LiquidInsect> actually I think it's in Enumerable
<kallisti> no I mean I'm getting a runtime error.
<shevy> your_array.each
<LiquidInsect> foreach and for use each
<lectrick> hrmm
<shevy> no please ignore anything that has "for" in ruby code
<LiquidInsect> haha
<lectrick> lol
<LiquidInsect> shevy: I started a project with a friend of mine who works at Microsoft
<kallisti> I guess I'm using Ruby anyway. I have no need to be concerned about memory efficiency. :P
<lectrick> OK so what is the canonical way to read a file line by line with a line separator of "\n"?
<LiquidInsect> He just took off and started writing code
<LiquidInsect> so many for loops
<LiquidInsect> I have to teach him idiomatic ruby
* kallisti comes from Haskell, and already knows a little about some of Ruby's higher-order functions.
<lectrick> for loops = old thinking
<shevy> LiquidInsect he writes for loops in ruby?
<LiquidInsect> shevy: he'd never used ruby before
<lectrick> well, ruby will let you
<shevy> lectrick File.readlines('foo.txt')
<LiquidInsect> so yeah, there was a lot of for thing in things do; whatever; end;
<shevy> ewww
<LiquidInsect> (or however the for syntax works, I for get)
<lectrick> ruby's like, hey, if you really want to write procedural code, I'll let you. If you want to write functional code, I'll let you. It's chill, man. Happy 4/20
<shevy> I have some old ruby code from other people who used that a lot
<shevy> for x in z
<shevy> for a in b
<lectrick> shevy: No, if you want to read the file one line at a time without reading the whole thing at once I mean
<shevy> lectrick ah
<shevy> hmm
<kallisti> I guess I'll just load the whole file into memory since it's not large enough for that to really matter. Still I'd like to know how to do it line-by-line.
<shevy> I think you will need to somehow use File.read and tell it to read in at newlines
<lectrick> kallisti: Me too, now.
<kallisti> do I get $_ in Ruby?
kish has joined #ruby
<lectrick> Looks like readfilehandle.gets will do it
<lectrick> kallisti: ^
<lectrick> kallisti: Yes you do, but I wouldn't recommend using it
<shevy> the $ variables are quite ugly
<lectrick> ruby people like to read code
<lectrick> $* are not readable
<LiquidInsect> lectrick: what's wrong with http://pastie.org/3825465
<kallisti> well I'm mostly interested in using it with regex.
<shevy> what is $_ again?
<kallisti> and.. coming from Perl, I find $_ perfectly readable. :P
<banisterfiend> LiquidInsect: btw the new pry can retrieve docs and source for classes/modules now. What do u think?
<kallisti> $_ is "a current value"
<shevy> not sure I understand
<kallisti> that is used as a default in some places in Perl.
<lectrick> LiquidInsect: I'm not sure. It depends on if .each on a file assumes that file already read the entire file into memory.
<shevy> and what rules set it?
<LiquidInsect> banisterfiend: nice. I need to learn pry myself, I keep finding myself using ruby-debug still
<kallisti> shevy: are you asking rhetorical questions or do you actually know how $_ works?
* kallisti can't tell.
andynu has joined #ruby
shaman42 has joined #ruby
Rambozo has joined #ruby
<shevy> kallisti I am asking what $_ does
<banisterfiend> LiquidInsect: well pry is more of an exploration tool/spelunker than a bona fide debugger, but it's slower gaining debugger capabilities too
falican has joined #ruby
Poapfel has joined #ruby
cespare has joined #ruby
visof has joined #ruby
visof has joined #ruby
<shevy> "$_ $LAST_READ_LINE[1] The last input line of string by gets or readline."
<lectrick> $_$LAST_READ_LINE[1]The last input line of string by gets or readline.
<kallisti> shevy: it's just a global placeholder value. In Perl, various operations read from and set it automatically if you don't specify values. I'm guessing it works similarly in Ruby. For example, in Perl, if you specify a regex without using =~ it will automatically match on $_
<lectrick> lol
<kallisti> this is very handy for quick scripts.
<shevy> thanks lectrick
classix has joined #ruby
jimeh2 has joined #ruby
<kallisti> oh found what I'm looking for
<kallisti> IO.lines
<LiquidInsect> kallisti: that's the name method as each
<LiquidInsect> according to the docs
kish has joined #ruby
<kallisti> oh, right.
<LiquidInsect> unless the internal implementation differs
<lectrick> the same method he means
<lectrick> File.each might defer to IO.lines
<LiquidInsect> File.each doesn't exist
<kallisti> hm it actually seems to work differently.
<lectrick> LiquidInsect: OK I mean File#each
<LiquidInsect> they all seem to be the same
<shevy> how do you use $LAST_READ_LINE in ruby with a regex?
<LiquidInsect> lectrick: also doesn't exist
<LiquidInsect> IO#each is what gets called
ddv has joined #ruby
kallisti has joined #ruby
kallisti has joined #ruby
<lectrick> shevy: No idea since you don't have to program in an obfuscated way to write crisp clean ruby code
<kallisti> so IO#each is how you specify an instance method from a class name?
jfelchner has joined #ruby
<lectrick> What's up with all the netsplits
<shevy> lectrick hahaha yeah I wonder right now
<lectrick> kallisti: Yep, Class#instance_method, Class.class_method
visof_ has joined #ruby
<kallisti> got it.
yoklov has joined #ruby
nyuszika7h has joined #ruby
visof has joined #ruby
mephux has joined #ruby
<shevy> seems $LAST_READ_LINE is an alias to whatever is read in by .gets
<shevy> oops, forgot .chomp
* kallisti thinks readability is a meaningless concept.
<kallisti> anyone who knows Perl can read Perl code that makes heavy use of $_
<kallisti> because it's so idiomatic.
<shevy> kallisti completely wrong
yoklov has joined #ruby
<lectrick> As much as I love to study and work with code, I'm convinced that the longer I inhale it, the less humane I become. I can feel it affecting my brain.
<shevy> your brain will adapt to everything anyway given sufficient training, but the worse language is like a small hammer - you are less likely to finish a huge bridge with a small hammer
<lectrick> kallisti: heh here we go with philosophy. I think that you will find ruby extremely readable as well as concise, regardless of obfuscation.
<shevy> I failed to write an IRC bot in PHP. A few months later my IRC bot in ruby worked
<kallisti> yes, expressivity is more important than readability.
kish has joined #ruby
<kallisti> small hammer = non-expressive language
<shevy> I think you are still stuck in the perl mindset
<kallisti> nah. I have no programming specific mindset
<kallisti> if I did it would be Haskell.
k_m has joined #ruby
alindeman has joined #ruby
cespare has joined #ruby
Rambozo has joined #ruby
LiquidInsect has joined #ruby
lkba has joined #ruby
nilg has joined #ruby
telling has joined #ruby
sirdeiu has joined #ruby
antihero has joined #ruby
sjaveed has joined #ruby
iaj has joined #ruby
mtkd has joined #ruby
limed has joined #ruby
ixx has joined #ruby
aetaric has joined #ruby
pingveno has joined #ruby
thorncp has joined #ruby
mahlon has joined #ruby
Prudhvi has joined #ruby
zaiste has joined #ruby
ddv has joined #ruby
<kallisti> do you pass a "self" as the first argument of an instance method called with the # syntax?
* kallisti is just guessing.
<shevy> self is always available so it makes no real sense to pass it to any method
JC_SoCal has joined #ruby
<kallisti> no I mean like
<shevy> objects in ruby are smarter than in python
<kallisti> File#each(instance, ...)
Beoran_ has joined #ruby
<kallisti> I understand you can do instance.each, and within the class just each
<kallisti> er, within a method of the class I should say
<kallisti> but is that also acceptable?
<kallisti> in other words how does # work...
<kallisti> okay
<shevy> it is available to all classes that include it
<shevy> so Hash has it, Array has it ... File ... etc...
<kallisti> that's not what I'm asking. This is a question of how exactly # works
nitram_macair has joined #ruby
frogstarr78 has joined #ruby
mitchty has joined #ruby
<nitram_macair> any one seen this on centos 5 http://pastebin.com/mt9rL55Y
<shevy> class Foo; def bar then later ... x = Foo.new; x.bar <-- you call the method #bar on the object x
<kallisti> oh
kish has joined #ruby
<adamkittelson> i think # is just a shorthand way of saying you're dealing with an instance method as opposed to a class method, it's not actual syntax
<kallisti> so . is /calling/ the method, and # is its name.
khakimov has joined #ruby
jarred has joined #ruby
<kallisti> oh..
<kallisti> okay.
<lectrick> kallisti: You don't use # in actual code. Class#instance_method is a way to talk about instance methods in chat channels.
<kallisti> ah I see.
<lectrick> kallisti: Actual code would do c = Class.new; c.instance_method
<canton7> aye. It's presented in the docs that way
<shevy> you should be able to lookup documentation via ria that way... 'ri Hash#values_at' for instance ... unless I am wrong. Have not used ri in a long time
shadoi has joined #ruby
<lectrick> Yes, I believe so
<shevy> someone try? :)
<lectrick> So if I type #each, everyone knows I'm talking about an instance method,.
<lectrick> in docs and irc.
<lectrick> (is there something like that for class methods?
<shevy> hmm how do you lookup where #each resides?
<lectrick> Hash::each
<shevy> from commandline
<kallisti> File#gets appears to be valid code.
<kallisti> are you guys sure?
<shevy> no, where do you get this information?
<kallisti> irb
<shevy> hmm
<lectrick> kallisti: # makes ruby ignore the rest of the line. It's a comment character LOL
<shevy> nah
<kallisti> oh, right.
<shevy> I think irb ignores that
<lectrick> yep
* kallisti is silly.
<lectrick> hence comment character
<shevy> so you just typed "File" in IRB in actual practice
<lectrick> yep
kish has joined #ruby
ReachingFarr has joined #ruby
nkts has joined #ruby
<ReachingFarr> I would like to remove a class's :new method. Does anyone know how to do that?
<shevy> remove_method :new
<kallisti> can I use regex in case expressions as I would in Perl?
<kallisti> case val when /regex/ ...
<kallisti> the case succeeds if the regex matches val
<ReachingFarr> shevy: I'm getting an error when I try that: `remove_method': method `new' not defined in Bar (NameError)
seanstickle has joined #ruby
<shevy> yeah I think it is somewhere else... in Object perhaps
<shevy> or not hmm
<shevy> kallisti yes but make a newline after "case val"
<kallisti> right
<shevy> ReachingFarr well it is not in Object either
<ReachingFarr> Oh, so you have to remove it from the class it was defined in? That would mean then that I would make it impossible to call :new on any class, right?
<shevy> perhaps new is special? I think I once read that it calls ... #allocate
<shevy> dunno really. but every class in ruby needs #new
sohocoke has joined #ruby
<shevy> ReachingFarr, I am sure Mon_Ouie will know :)
<ReachingFarr> Right, and I don't want to remove it from something that everything inherits from. I just want to prevent new from being called on a specific class.
<shevy> yeah
kish has joined #ruby
<shevy> you want to remove the ability of any given class to get instantiated (or rather that #new is called on it)
<shevy> I dont think I have read that wish before btw
<kallisti> shevy: and case is just calls of === right?
<ReachingFarr> shevy: I'm trying to implement an AbstractClass module.
<shevy> kallisti yeah I think so
<shevy> ReachingFarr will we ever find out? :)
<ReachingFarr> shevy: If I find a better way of doing it I'll post a link to the code if people are interested.
freedrull has joined #ruby
freedrull has quit [#ruby]
Baen has joined #ruby
<kallisti> is it more idiomatic to use the $n capture variables, or to use MatchData (from regular expressions)?
<kallisti> I'm guessing MatchData
<kallisti> since it's not the Perl one. :P
<kallisti> actually I'm assuming global capture variables exist.
<kallisti> they might not.
kish has joined #ruby
<kallisti> hm I don't see them documented so maybe they don't.
dkissell has joined #ruby
<shadoi> they're not global, but they exist in scope
ben225 has joined #ruby
replore has joined #ruby
<kallisti> I assume they don't have the $ then?
<kallisti> or are they magical?
<kallisti> (since $ means global variable)
<shadoi> err, sorry, yes those are global
<shadoi> I was thinking of the \1 \2, etc.
<kallisti> oh, no.
<kallisti> wait how do those work.
<kallisti> oh nevermind
<shadoi> within a regex
<kallisti> you mean in substitutions.
<kallisti> also in the regex itself.
<shadoi> it's just a match group
<kallisti> right
kish has joined #ruby
<shadoi> What is with everyone wanting abstract classes in ruby lately? It's weird.
<khakimov> hey guys, does anybody know how to parse 1_000_000 websites the smart way? http://pastie.org/3825629 doesn't work well. any suggestions?
<banisterfiend> shadoi: they've all been doing objc recently i guess ;)
<shadoi> banisterfiend: there certainly seems to be an influx of that sort of thinking.
<banisterfiend> shadoi: objc is also kind of duck-typed but it has abstract classes (called protocols)
stephenjudkins has joined #ruby
virunga has joined #ruby
<shadoi> khakimov: I'd break it up with a worker pattern like resque.
<shadoi> ReachingFarr: a module doesn't respond to #new and you can implement class methods on it using .extend.
<khakimov> shadoi: like make batches with 1_000 for example and then process with eventmachine?
<shadoi> khakimov: yeah
kish has joined #ruby
<shadoi> khakimov: also look into Celluloid as a more sane alternative to eventmachine.
<khakimov> shadoi: I did batches like this http://pastie.org/3825647 but still not good ;)
phantasm66 has joined #ruby
<shadoi> khakimov: yeah with redis you basically just pop each URL off as your workers process it, so if something fails it just keeps going. Have your works update redis with results and you can feed it any # of sites to crawl.
<shadoi> s/works/workers/
juul has joined #ruby
<khakimov> shadoi: make sense, going to try
<khakimov> shadoi: thanks
cjk101010 has joined #ruby
madcoder_ has joined #ruby
kish has joined #ruby
ssnt has joined #ruby
<lectrick> How do I test if an instance is a kind of parent class where parent class is a few levels up?
<lectrick> I tried is_a? but this seems to not work all the time
<robacarp> lectrick: kind_of?
<ReachingFarr> shevy: This is what I ended up with: https://gist.github.com/2432710
<kallisti> is there anything similar to tuple assignment in Python? (and pattern matching on tuples in Haskell...)
<lectrick> thanks that worked robacarp
<ReachingFarr> kallisti: a, b, c = [1, 2, 3]
* robacarp tips hat
<kallisti> ReachingFarr: does that work with any Enumerator?
<ReachingFarr> You can also do things like `a, b = if foo then [1,2] else [3,4] end`
<ReachingFarr> kallisti: I'm not sure. I've only ever done it with arrays.
<robacarp> kallisti: I don't think so.
kish has joined #ruby
<robacarp> best way to find out is to try it though, because it might work on anything that sports the [] operator
<robacarp> I rather have my doubts, but ruby has surprised me more than once.
<kallisti> > "test" =~ /test/
<kallisti> => 0
<kallisti> hmmm?
<kallisti> am I doing something wrong?
<heftig> a, b, c = *Enumerator.new { |e| e << 4; e << 5; e << 6 }
<heftig> sure works with any enum
<heftig> (the enum will be converted to an array first)
<robacarp> kallisti: uhm...what are you trying to accomplish?
<MarcWeber> Which ruby versions is ruby-debug supposed to work with?
<shevy> kallisti where is the if
<kallisti> there isn't
<kallisti> why does it return 0?
<kallisti> that's not very useful.
<shevy> the position
<gogiel> kallisti: 0 means first (0th) character in string
<heftig> because it matched at position 0
<shevy> "test" =~ /e/ # => 1
<kallisti> ah
<heftig> 0 is not falsey
<kallisti> that's fine
fbernier has joined #ruby
<kallisti> ah I want #match
kish has joined #ruby
<robacarp> kallisti: $~, $1, $2 etc will do what you want too
<kallisti> robacarp: well in Perl for example I can write
<kallisti> my ($a, $b, $c) = str =~ /regex/
<kallisti> and that will grab all the capture groups and put them in those variables.
Dreamer3 has joined #ruby
<kallisti> (Debian comes with Ruby 1.8 so I can't used named captures)
Drewch has joined #ruby
<robacarp> yea, sure, just do: str =~ /regex/; a,b,c = $~
<kallisti> that works I guess.
* kallisti was going for a one-liner. :P
<robacarp> you might need $~.to_a
dv310p3r has joined #ruby
<kallisti> no heftig showed above that any Enumerator will work
<robacarp> kallisti: I think there is a syntax, but with a different operator
<kallisti> (I'm guessing MatchData is an Enumerator. I may be wrong..)
twinturbo has joined #ruby
<kallisti> well with #match it returns the MatchData
<heftig> * will call .to_a on it
<kallisti> oh cool
<kallisti> so that's what unary * does internally
<heftig> well, besides the expansion
<kallisti> yeah #match works
<kallisti> nick, msg = /^\[.+\] <(.+)> (.+)$/.match(line)
<robacarp> yea $~.kind_of? Enumerable => false
replore_ has joined #ruby
<kallisti> hm
<kallisti> maybe the list assignment tries multiple methods?
<kallisti> Enumerable or [] or ...
ashp has joined #ruby
<heftig> no
<heftig> it only treats a single array specially
sohocoke has joined #ruby
kish has joined #ruby
<ashp> I hate to just stumble in and ask a question but: If I have a string "AA:BB:CC" and I wanted to .split(':') - how could I do this as a hash instead. I basically want to make a hash with a=>AA, b=>BB, c=>CC?
Davide has joined #ruby
<ashp> It's probably a dumb question but I couldn't think of a good way to do it
Drewch has joined #ruby
<Davide> !list
<kallisti> heftig: the code I pased above seems to working as is
<kallisti> *pasted
<shevy> ashp well
<heftig> kallisti: it just assigns the MatchData to nick here
<heftig> msg is nil
<kallisti> oh okay.
<kallisti> yeah I only tested nick
<ashp> shevy: Perhaps I could just do: a, b,c = "string".split
<ashp> and then make a hash out of those, it seems less elegant
<kallisti> nick, msg = /^\[.+\] <(.+)> (.+)$/.match(line).captures # this works, and is a bit clearer than using *
<heftig> ashp: how do you determine the keys?
<Davide> #alghero
Davide has quit [#ruby]
<heftig> Hash[["a","b","c"].zip("AA:BB:CC".split(":"))]
<ashp> yeah, they are just hardcoded
<ashp> that looks perfect
<ashp> That makes perfect sense too! thanks
<robacarp> ashp: yea, I was working out that same line of code.
<kallisti> heftig: can you explain how msg becoms nil?
<shevy> ah heftig is better
tommyvyo has joined #ruby
<heftig> kallisti: /foo/.match("foo") returns a MatchData object
<heftig> that object gets assigned to nick, and msg stays nil
kish has joined #ruby
<kallisti> right
<kallisti> I meant: why?
<kallisti> what are the semantics of that style of assignment
<heftig> because you're trying to assign one element to two, the unassigned ones become nil
<kallisti> so that's just "how it works"
<kallisti> got it.
jaysern has joined #ruby
<kallisti> (for example, in Perl evaluating a scalar in list context produces a list of size 1, thus only the first variable is assigned to)
<heftig> the only special cases are: if there's only a single element on the left side, it becomes an array of all the right-side elements
<heftig> if there's only a single element on the right side, and it's an array, it is expanded
<kallisti> so in the one-element case it sort of implicitly treats it as a length-1 array.
<heftig> huh?
<kallisti> a,b = not_an_array
<heftig> a = not_an_array, b = nil
<kallisti> I understand what happens
<kallisti> but not how that's not just some kind of weird special case.
<heftig> nothing gets treated as a length-1 array
<heftig> not a special case at all
<kallisti> a,b = [not_an_array]
<kallisti> same thing, right?
<heftig> yes, but now you're invoking the special case
kish has joined #ruby
<kallisti> whut
<shadoi> a, b = [you_will_be_mad]
<jaysern> I'm error'ing out on this line when I try to do a gem install of libarchive. Has anyone dealt with this before? checking for archive.h... no *** extconf.rb failed ***Could not create Makefile due to some reason, probably lack ofnecessary libraries and/or headers. Check the mkmf.log file for moredetails. You may need configuration options. http://pastie.org/3825735
<kallisti> so the general case is:
<kallisti> a, b, c, ... = some_value
<kallisti> a = some_value
<kallisti> everything else is nil