<josh9>
i have a product object with a method that scrap a webpage. in my tests i want to stub this method.
towski [towski!~towski@host-70-45-23-142.onelinkpr.net] has joined #ruby-lang
<Asher>
josh9 - just open the object you're testing (i usually use separate mock modules/class including/extending the module i'm testing for each spec) and re-define the method
<josh9>
Asher: sweet. i didn't think about opening the class. i'll give it a try
<apeiros>
nobody got a take on my idea?
<Asher>
josh9 - ya ruby lets you re-open anything so you can just replace your method with a mock stub
<josh9>
Asher: i know that but rarly had do that. do u think that's the reason minitest don't have stubs? since you can open your class instead?
<Asher>
yup
<josh9>
Asher: i also feel that tdd forces me to design my system in a way that will be easy to deconstruct. i always think 'how will i test this?', and think of stuff like passing objects to a method, so i'll be able to mock this object in my test.
jmontross [jmontross!~Adium@75-35-173-1.lightspeed.dllstx.sbcglobal.net] has joined #ruby-lang
infid [infid!~infid@99-95-168-48.lightspeed.sndgca.sbcglobal.net] has joined #ruby-lang
<apeiros>
:(
<chris2>
hm?
<samuelkadolph>
apeiros: I still love you.
<apeiros>
chris2: I'm looking for feedback on my rubygems idea… but none so far :(
<chris2>
i had a path-caching library loader in 2008 or something :P
<apeiros>
chris2: so why didn't make that into rubygems?
<chris2>
i didnt build it on rubygems
<chris2>
and keeping the stuff updated was Too Much Work
<apeiros>
did you suggest the underlying idea for rubygems?
<chris2>
i dont think so
<apeiros>
hm, ok
<apeiros>
but you think the idea itself is sound?
<chris2>
you approach is nicer
<chris2>
a kind of stow-approach
<apeiros>
thanks
<chris2>
makes lot of sense actually
datanoise [datanoise!~datanoise@24-145-66-018-dhcp.mia.fl.atlanticbb.net] has joined #ruby-lang
<apeiros>
woah, do I read that correctly, that require will perform the whole path search again even if the lib has already been loaded? (I started reading the source after noticing that require 'foo' took ~1000x as long as $LOAD_PATH.include?('foo'), and that even though $LOAD_PATH is *still* an array…)
corn_man|2 [corn_man|2!kvirc@2001:470:a:5c1::3] has joined #ruby-lang
<apeiros>
err, $LOADED_FEATURES.include? of course…
<apeiros>
even 10'000x slower than loaded_features_hash.include? (which is just Hash[$".zip($")])
tla [tla!~tla@toelboell-lund.dk] has joined #ruby-lang
andrewhl [andrewhl!~andrew@CPE687f7402a2d8-CM00195ed25a2a.cpe.net.cable.rogers.com] has joined #ruby-lang
robgleeson [robgleeson!~rob@subtle/contributor/robgleeson] has joined #ruby-lang
QaDeS_ [QaDeS_!~mklaus@frbg-5f731bd8.pool.mediaWays.net] has joined #ruby-lang
voker57 [voker57!~voker57@128.70.38.70] has joined #ruby-lang
voker57 [voker57!~voker57@kvirc/developer/Voker57] has joined #ruby-lang
postmodern [postmodern!~postmoder@c-71-237-178-98.hsd1.or.comcast.net] has joined #ruby-lang
Banistergalaxy [Banistergalaxy!~AndChat@222.153.223.43] has joined #ruby-lang
srbaker [srbaker!~srbaker@184.66.82.213] has joined #ruby-lang
burgestrand [burgestrand!~burgestra@81-229-85-235-no66.tbcn.telia.com] has joined #ruby-lang
<josh9>
so i am opening my product class and stubbing a method just for my test. it's working great. the question is where would i do that. right now it's inside the it "bla bla bla" do block.
gnufied [gnufied!~gnufied@122.167.91.153] has joined #ruby-lang
gnufied1 [gnufied1!~gnufied@122.167.91.153] has joined #ruby-lang
<josh9>
maybe there is a common place to put all the classes that are open for testing purposes?
vesan [vesan!vesan@maailmanlopun.modeemi.net] has joined #ruby-lang
apeiros_ [apeiros_!~apeiros@77-58-115-24.dclient.hispeed.ch] has joined #ruby-lang
hexo [hexo!hexo@hackerspace.base48.tk] has joined #ruby-lang
Swimming_Bird [Swimming_Bird!~textual@cpe-68-173-86-46.nyc.res.rr.com] has joined #ruby-lang
ttilley [ttilley!~ttilley@unaffiliated/lv] has joined #ruby-lang
RomyEatsDrupal [RomyEatsDrupal!~stickycak@cpe-74-64-122-182.nyc.res.rr.com] has joined #ruby-lang
knu [knu!chuck@v055125.ppp.asahi-net.or.jp] has joined #ruby-lang
freedrull [freedrull!~freedrull@freedrull.xen.prgmr.com] has joined #ruby-lang
<freedrull>
okay well
<freedrull>
how many different SDL ruby bindings are there :\
gnufied [gnufied!~gnufied@122.167.91.153] has joined #ruby-lang
<josh9>
freedrull: what's that?
knu [knu!chuck@v055125.ppp.asahi-net.or.jp] has joined #ruby-lang
towski [towski!~towski@host-70-45-23-142.onelinkpr.net] has joined #ruby-lang
arthurlockhart [arthurlockhart!~cinch@60-242-128-8.static.tpgi.com.au] has joined #ruby-lang
adgar [adgar!~adgar@carbonica.xen.prgmr.com] has joined #ruby-lang
srbaker [srbaker!~srbaker@184.66.82.213] has joined #ruby-lang
jmontross [jmontross!~Adium@75-35-173-1.lightspeed.dllstx.sbcglobal.net] has joined #ruby-lang
jonpierce [jonpierce!~jonpierce@c-174-54-73-238.hsd1.pa.comcast.net] has joined #ruby-lang
vesan_ [vesan_!vesan@maailmanlopun.modeemi.net] has joined #ruby-lang
hexo [hexo!hexo@hackerspace.base48.tk] has joined #ruby-lang
nuclearsandwich [nuclearsandwich!~nuclearsa@74-93-3-241-SFBA.hfc.comcastbusiness.net] has joined #ruby-lang
<shevy>
freedrull rubygame
<shevy>
and the older ruby-sdl
nuclearsandwich [nuclearsandwich!~nuclearsa@74-93-3-241-SFBA.hfc.comcastbusiness.net] has joined #ruby-lang
dr0id [dr0id!~andy@unaffiliated/dr0id] has joined #ruby-lang
x0F_ [x0F_!~x0F@unaffiliated/x0f] has joined #ruby-lang
igotnolegs [igotnolegs!~igotnoleg@75-162-83-166.slkc.qwest.net] has joined #ruby-lang
wmoxam [wmoxam!~wmoxam@pdpc/supporter/active/wmoxam] has joined #ruby-lang
yfeldblum [yfeldblum!~Jay@pool-173-68-228-166.nycmny.east.verizon.net] has joined #ruby-lang
tdmackey [tdmackey!~tdmackey@booleanhaiku.com] has joined #ruby-lang
blowmage [blowmage!~blowmage@humanecode.new.xen.prgmr.com] has joined #ruby-lang
benwoody [benwoody!~ben@ln.benwoodall.com] has joined #ruby-lang
jaimef [jaimef!jaimef@dns.mauthesis.com] has joined #ruby-lang
corn_man|2 [corn_man|2!kvirc@2001:470:a:5c1::3] has joined #ruby-lang
ltd [ltd!~z@zx.io] has joined #ruby-lang
flip_digits [flip_digits!~textual@c-71-199-243-97.hsd1.fl.comcast.net] has joined #ruby-lang
wmoxam [wmoxam!~wmoxam@69-196-160-102.dsl.teksavvy.com] has joined #ruby-lang
wmoxam [wmoxam!~wmoxam@pdpc/supporter/active/wmoxam] has joined #ruby-lang
vesan_ [vesan_!vesan@maailmanlopun.modeemi.net] has joined #ruby-lang
jd [jd!~useless@modemcable003.116-202-24.mc.videotron.ca] has joined #ruby-lang
jd [jd!~useless@unaffiliated/jade] has joined #ruby-lang
hexo [hexo!hexo@hackerspace.base48.tk] has joined #ruby-lang
vmatiyko [vmatiyko!~vmatiyko@178.121.177.46] has joined #ruby-lang
vmatiyko [vmatiyko!~vmatiyko@178.121.177.46] has quit [#ruby-lang]
JosephRuby [JosephRuby!~joseph@46.33.34.17] has joined #ruby-lang
looopy [looopy!~looopy@c-68-34-92-100.hsd1.md.comcast.net] has joined #ruby-lang
srbaker [srbaker!~srbaker@184.66.82.213] has joined #ruby-lang
<josh9>
i get a div with nokogiri - "\r\n\t\t\t\t\t\t\t$9.98\r\n\t\t\t\t\t\t" is there an easy way to get the number out of it (regex?)
<yfeldblum>
my_string.gsub(/[^\d.]/m, "").to_f
Pip [Pip!~Pip@unaffiliated/pip] has joined #ruby-lang
<josh9>
yfeldblum: wow, thanks
perryh [perryh!~perryh@76-230-52-253.lightspeed.sntcca.sbcglobal.net] has joined #ruby-lang
<yfeldblum>
np
corundum [corundum!~rbot@drbrain-2-pt.tunnel.tserv8.dal1.ipv6.he.net] has joined #ruby-lang
<josh9>
[ ] any single character of set
<josh9>
what does it mean?
<josh9>
i try to wrap my head around this but can't figure it out
hexo [hexo!hexo@hackerspace.base48.tk] has joined #ruby-lang
vesan_ [vesan_!~vesan@maailmanlopun.modeemi.net] has joined #ruby-lang
<yfeldblum>
/[abc]/ will match all of the following: "a", "b", "c", "xxxxxxyyyyyyakkkkkkk"
<josh9>
ok. so it will match any a b or c regardless of their order
<yfeldblum>
it will match a single character of the input string, so long as the character in the input string is one of the characters in the list given inside the []
looopy [looopy!~looopy@pool-151-200-235-184.washdc.btas.verizon.net] has joined #ruby-lang
<josh9>
so gsub goes char after char and evaluate against or regex
<josh9>
if it matches the regex it replace it
duper [duper!~super@c-98-192-216-171.hsd1.de.comcast.net] has joined #ruby-lang
<duper>
When invoking instance methods on a class, which syntax executes faster? AClass::amethod() or AClass.amethod() # they both work
<duper>
instead of typing out all the hash references every time
<yfeldblum>
of course
<yfeldblum>
it's called DRY
<duper>
but the thing is i need a lot of these alias variables
<yfeldblum>
then your code is too complex
andrewhl [andrewhl!~andrew@CPE687f7402a2d8-CM00195ed25a2a.cpe.net.cable.rogers.com] has joined #ruby-lang
<yfeldblum>
split it up into sub-methods
<duper>
and i dont want them taking up too much space for too long
<duper>
GC will get them when control flow proceeds out of the block it was declared in?
<yfeldblum>
yes, but you're not making any new objects, so GC doesn't factor in
<duper>
u prolly right, there's just a lot of data im handling.. hostnames, ipv4+ipv6 addrs (numeric and hostnames), integer versions of those for comparison, comments, what the servers with those IPs do etc.
<duper>
yfeldblum: ah okay so it'll just disappear off the stack then?
<duper>
can you declare arbitrary blocks in ruby without defining a function? like how u can put curly braces anywhere in C
<yfeldblum>
a copy of the pointer to the actual object will disappear off the stack
<duper>
so i can regulate stack visibility
<duper>
like i wanna have a small block so that hash alias will disappear
Pip [Pip!~Pip@unaffiliated/pip] has joined #ruby-lang
<duper>
should i just use a begin-do-end construct, or is there something easier/shorter/better?
<duper>
ah, so even if i assign a literal value like an integer to a normal variable it's still a pointer?
<duper>
the other question i had is if there's short-hand for String.new() cuz i need like a copy constructor, if i do `str1=str2' if i change one they both get modified
<duper>
also would like to know the diff between `h={}' and `h=Hash.new()'
<yfeldblum>
locals in ruby are not scoped to begin/end; they are scoped at class/module, method-definition, and block levels
<duper>
will just have to investigate that YARV u were talking about i guess lol
<yfeldblum>
{} is syntax sugar for Hash.new
<yfeldblum>
YARV is the VM in ruby-1.9
<duper>
i'm usin latest stable
<yfeldblum>
ruby-1.8 is interpreted with a top-down interpreter; ruby-1.9 is compiled (in memory only) and executed on a ruby VM originally named YARV before it was merged into ruby
<yfeldblum>
str1 = str2.dup
<duper>
recursive descent parser?
<duper>
oic String#dup thx
<yfeldblum>
no, the parser is a crazy ass nightmare; a top-down interpreter which interprets an AST built by the parser
<yfeldblum>
the ruby language with all its syntax does not lend itself to easy parsing
<duper>
is there a built-in way to do `not(obj.nil? or obj.empty?)' yet?
<duper>
kinda like M$ .NET System.String.IsNullOrEmpty
<rue>
There's no need for a builtin, since you can just write a method for it, like Rails did
<duper>
ya i've seen that
<duper>
Object#blank? or whatever
<yfeldblum>
class String ; def not_nil_or_empty? ; !nil? && self =~ /\S/ end end
<yfeldblum>
and no, because the meaning of empty for a string is contextual
<yfeldblum>
rails does it in a way that makes sense for string values that come from user input (text-box html controls)
<duper>
wouldn't the regexp in that String extension be slower than using String#empty?
wyhaines [wyhaines!~wyhaines@65.39.118.15] has joined #ruby-lang
<duper>
btw, do you know of any free online resources concerning Ruby optimization?
<duper>
didn't see much on the net at first glance (aside from well-known stuff i was already aware of)
uniqanomaly [uniqanomaly!~ua@dynamic-87-105-21-246.ssp.dialog.net.pl] has joined #ruby-lang
<rue>
yfeldblum: There's nothing contextual about an empty string: "". A non-empty string with only whitespace is different
<rue>
duper: There isn't much. Profile, fix problems.
<duper>
thinking about buying this Writing Efficient Ruby Code book.. but i dunno if it has the attention to detail i'm looking for
<rue>
It seems to cover the most common cases, from ToC
<rue>
Broadly, the types of problems Ruby isn't suited for, it *really* isn't suited for.
takaokouji [takaokouji!~takaokouj@nat35.mable.ne.jp] has joined #ruby-lang
Weems [Weems!~frodo@unaffiliated/weems] has joined #ruby-lang
<rue>
Thinking in terms of optimization, as you're forced to do in many system languages, tends to get in the way of expressing the problem clearly
<any-key>
I agree, it causes cruft and premature optimization usually ends up with you shooting yourself in the foot
srbaker [srbaker!~srbaker@184.66.82.213] has joined #ruby-lang
janissary [janissary!~user@adsl-98-70-95-30.mco.bellsouth.net] has quit ["ERC Version 5.3 (IRC client for Emacs)"]
<duper>
well, overdoing optimization lacks benefit in any programming language
<duper>
but last time i checked ruby was slower than everything else i use
<any-key>
it's a scripting language
<any-key>
scripting languages trade speed for rapid development and ease of maintainence
<any-key>
as well as other things
<duper>
true, but Python and Perl crawl faster ;)
<any-key>
1.9.3 is a bit faster
<duper>
the only language i've written that runs slower than Ruby is Scheme
<any-key>
and everyone keeps saying JRuby is the shit
<duper>
any-key, JRuby is certainly one of the fastest (once it loads up)
<duper>
maybe because of the just-in-time compilation, i'm not sure *shrug*
<any-key>
JIT will do that
<duper>
last time i looked rubinius was lacking support for some key features
<rue>
1.9.3 is faster than Python in most cases
<rue>
Apparently
<duper>
i try to use MRI anyway since it's the main one
<duper>
rue, what changed?
<duper>
that's hard for me to believe..
<rue>
Incremental improvements. All of 1.9 series has been pretty close
<rue>
If you currently see differences in either direction, it's likely mostly to do with the libraries being used.
<any-key>
iirc require was changed significantly (implementation-wise)
<duper>
any-key, IronRuby enjoys the optimizations of the CLI DLR from .NET but again its lagging behind on features
<rue>
Yeah, a loading bug was fixed
<rue>
IronRuby isn't a player currently. Maglev is, for a certain class of problems
<duper>
never heard of that one
<duper>
i've seen ironruby apps on windows phone
<duper>
and as an adapter between Java RMI and .NET Remoting
<duper>
looks promising, but certainly not ready for prime time
looopy_ [looopy_!~looopy@c-68-34-92-100.hsd1.md.comcast.net] has joined #ruby-lang
<duper>
lollers.. a SmallTalk VM? :) they have Cardinal for Parrot as well
<rue>
Gemstone is a Serious Platform™
wyhaines [wyhaines!~wyhaines@65.39.118.15] has joined #ruby-lang
io_syl [io_syl!~io_syl@unaffiliated/steph021] has joined #ruby-lang
ryanf [ryanf!~revfitz@76.197.6.24] has joined #ruby-lang
hagabaka [hagabaka!~hagabaka@unaffiliated/hagabaka] has joined #ruby-lang
Pip [Pip!~Pip@unaffiliated/pip] has joined #ruby-lang
jxie [jxie!~jxie@115.197.91.174] has joined #ruby-lang
heftig [heftig!jan@archlinux/developer/heftig] has joined #ruby-lang
postmodern [postmodern!~postmoder@c-71-237-178-98.hsd1.or.comcast.net] has joined #ruby-lang
RomyEatsDrupal [RomyEatsDrupal!~stickycak@cpe-74-64-122-182.nyc.res.rr.com] has joined #ruby-lang
solars [solars!~solars@194.208.132.118] has joined #ruby-lang
robgleeson [robgleeson!~rob@subtle/contributor/robgleeson] has joined #ruby-lang
skinnymuch [skinnymuch!~skinnymuc@c-68-36-123-133.hsd1.nj.comcast.net] has joined #ruby-lang
shevy [shevy!~shevy@93-82-84-78.adsl.highway.telekom.at] has joined #ruby-lang
Dreamer3 [Dreamer3!~Dreamer3@74-134-34-116.dhcp.insightbb.com] has joined #ruby-lang
Heimidal [Heimidal!~heimidal@c-67-165-197-126.hsd1.co.comcast.net] has joined #ruby-lang
mytrile [mytrile!~mmm@77.70.29.148] has joined #ruby-lang
rippa [rippa!~rippa@109-161-123-174.pppoe.yaroslavl.ru] has joined #ruby-lang
duper [duper!~super@c-98-192-216-171.hsd1.de.comcast.net] has joined #ruby-lang
rippa [rippa!~rippa@109-161-123-174.pppoe.yaroslavl.ru] has joined #ruby-lang
nuclearsandwich [nuclearsandwich!~nuclearsa@74-93-3-241-SFBA.hfc.comcastbusiness.net] has joined #ruby-lang
workmad3 [workmad3!~workmad3@cpc1-bagu10-2-0-cust81.1-3.cable.virginmedia.com] has joined #ruby-lang
kyrylo [kyrylo!~kyrylo@46.118.239.219] has joined #ruby-lang
<jammi>
it doesn't really matter, whether ruby is slow or not. it's very expressive, which is a benefit in programmer efficiency (writing code). when the software is ready to be tested, it can be benchmarked and profiled; the slowest parts can be easily identified and optimized, if/when neccessary.
uniqanomaly [uniqanomaly!~ua@dynamic-87-105-21-246.ssp.dialog.net.pl] has joined #ruby-lang
<rue>
It does matter, if it's too slow.
<rue>
It isn't, generally
<jammi>
and being easily extensible in C (or other languages, depending on the implementation) makes that relatively easy
<jammi>
rue: when it matters, it's usually "90% slow 10% of the time". fixing that 10% is easier to identify and quicker to write than prematurely optimizing the app by writing it in a low level language in the first place
<jammi>
and one will usually try to fix the algorithms themselves in ruby before resorting to C
<jammi>
an app won't be magically quicker just because it's written in a low level language, if its bottlenecks aren't easily identifiable. it requires developer skill too
<jammi>
it's easy to write an inefficient algorithm in C and never be aware of its inefficiency (and a better algorithm in something high-level and "slow" like ruby could easily be the quicker piece of software)
<jammi>
one of the reasons a skilled ruby developer's apps runs circles around the commonly inefficent java app
blowmage [blowmage!~blowmage@humanecode.new.xen.prgmr.com] has joined #ruby-lang
imperator [imperator!~Daniel@63-225-247-192.hlrn.qwest.net] has joined #ruby-lang
<imperator>
merry christmas!
dejongge [dejongge!~jonke@pD9E0C3D2.dip0.t-ipconnect.de] has joined #ruby-lang
antonsk [antonsk!~Adium@94.179.212.255.pool.3g.utel.ua] has joined #ruby-lang
thrcka [thrcka!~thrcka@dial-95-105-177-62-orange.orange.sk] has joined #ruby-lang
<josh9>
jammi: or write in cruby and deploy with jruby
<jammi>
josh9: sure
<josh9>
jammi: never tried it but heard people here talking about it
<jammi>
in places where java is still the major limitation, oracle, otoh is pretty good at getting rid of it
<jammi>
josh9: I've tried it, but not been interested in it because so many C extensions won't work with it
<jammi>
some C extensions do work in jruby, however
<jammi>
but not even remotely close to "all" or "most"
skiaec04 [skiaec04!~textual@96.18.234.205] has joined #ruby-lang
skiaec04 [skiaec04!~textual@96.18.234.205] has joined #ruby-lang
robgleeson [robgleeson!~rob@subtle/contributor/robgleeson] has joined #ruby-lang
Defusal_ [Defusal_!DeFi@unaffiliated/ecnerifed] has joined #ruby-lang
Jade [Jade!~jade@unaffiliated/jade] has joined #ruby-lang
apeiros_ [apeiros_!~apeiros@77-58-115-24.dclient.hispeed.ch] has joined #ruby-lang
Jade [Jade!~jade@unaffiliated/jade] has joined #ruby-lang
jxie [jxie!~jxie@115.197.91.174] has joined #ruby-lang
Jake232 [Jake232!~textual@5e025306.bb.sky.com] has joined #ruby-lang
cyri__ [cyri__!~cyri_@jem75-1-87-88-118-80.dsl.sta.abo.bbox.fr] has joined #ruby-lang
drd2 [drd2!53a0482e@gateway/web/freenode/ip.83.160.72.46] has joined #ruby-lang
Pip [Pip!~Pip@unaffiliated/pip] has quit ["It's not your problem."]
S1kx [S1kx!~S1kx@pdpc/supporter/monthlybyte/s1kx] has joined #ruby-lang
robgleeson [robgleeson!~rob@subtle/contributor/robgleeson] has joined #ruby-lang
benanne [benanne!~rijdier@218.188-241-81.adsl-dyn.isp.belgacom.be] has joined #ruby-lang
yorickpeterse [yorickpeterse!~yorickpet@pdpc/supporter/professional/yorickpeterse] has joined #ruby-lang
saLOUt [saLOUt!~rriemann@pool-40-79-199-89.dbd-ipconnect.net] has joined #ruby-lang
nuclearsandwich [nuclearsandwich!~nuclearsa@74-93-3-241-SFBA.hfc.comcastbusiness.net] has joined #ruby-lang
workmad3 [workmad3!~workmad3@cpc1-bagu10-2-0-cust81.1-3.cable.virginmedia.com] has joined #ruby-lang
ramonmaruko [ramonmaruko!~marco@122.52.126.66] has joined #ruby-lang
ramonmaruko1 [ramonmaruko1!~marco@122.52.126.66] has joined #ruby-lang
ramonmaruko1 [ramonmaruko1!~marco@122.52.126.66] has joined #ruby-lang
ramonmaruko1 [ramonmaruko1!~marco@122.52.126.66] has joined #ruby-lang
ramonmaruko [ramonmaruko!~marco@122.52.126.66] has joined #ruby-lang
Jake232 [Jake232!~textual@5e025306.bb.sky.com] has joined #ruby-lang
jensn [jensn!~Jens@90-229-211-15-no150.tbcn.telia.com] has joined #ruby-lang
workmad3 [workmad3!~workmad3@cpc1-bagu10-2-0-cust81.1-3.cable.virginmedia.com] has joined #ruby-lang
towski [towski!~towski@host-70-45-23-142.onelinkpr.net] has joined #ruby-lang
comboy [comboy!~quassel@static.7.66.9.176.clients.your-server.de] has joined #ruby-lang
mindgame [mindgame!~nfxgosu@c-24-6-170-1.hsd1.ca.comcast.net] has joined #ruby-lang
jbx028 [jbx028!~jbx028@maa78-1-212-194-146-225.dsl.sta.abo.bbox.fr] has joined #ruby-lang
shapeshed [shapeshed!~shapeshed@5e02d68c.bb.sky.com] has joined #ruby-lang
<jbx028>
hi. I have a problem with my ruby installation working on Ubuntu. To keep it short, i have the following error message showing "cannot load such file openssl" when i try to declare librairies like httparty for example. I have googlised the problem but in most of the case, i see that the way to fix the issue is to come to the ruby installation folder + "ext/openssl" and run ruby extconf.rb. Unfortunately this folder doesn't e
<jbx028>
xist. FYI i have installed openssl, libopenssl, etc.. via gem. Any idea on how to fix this error ? (my apologies in advance for my poor english but my mother language is french....)
retro|cz [retro|cz!~retro@106.142.broadband6.iol.cz] has joined #ruby-lang
<shevy>
see! they even have documentation about it :D
<jbx028>
i am a bit newbie with ruby
<jbx028>
echo $rvm_path
<jbx028>
sorry
<shevy>
hey manveru do you use RVM?
QaDeS [QaDeS!~mklaus@frbg-5f731bd8.pool.mediaWays.net] has joined #ruby-lang
<manveru>
yeah
<jbx028>
rvm pkg install openssl is running....i will then remove 1.9.3 with rvm and reinstall ruby by indicating the openssl directory as insticated to the link you gave me
corn_man [corn_man!kvirc@unaffiliated/cornman] has joined #ruby-lang
burgestrand [burgestrand!~burgestra@81-229-85-235-no66.tbcn.telia.com] has joined #ruby-lang
<jbx028>
this is strange because openssl is recognised with irb : require 'openssl' --> true
<jbx028>
but if i types require 'httparty' i got an error message saying that openssl is not found
<jbx028>
anyway, i will finish the de installation re installation
<shevy>
well
<shevy>
you know
<shevy>
if require 'openssl' works in irb
<shevy>
then it may be that httparty reports a faulty error
_avyy [_avyy!~Sage@79.164.150.164] has joined #ruby-lang
wyhaines [wyhaines!~wyhaines@65.39.118.15] has joined #ruby-lang
<_avyy>
Hi guys. Sorry for my english. I have question. Why amp(&) before proc-object does not work in irb-session? Only after methods. This is not a valid operation? How it works? Also, how i can see realisation of amp in MRI sources (which file)? Thanks!
<Asher>
_avyy - share some code? & says: "treat this variable as the method's block"
<imperator>
_avyy, works for me
<imperator>
a = %w[alpha beta gamma]; a.map(&:upcase) => worked fine in irb
<_avyy>
No-no, 1 sec
<_avyy>
pr = proc {puts "proc"}; &pr
<_avyy>
syntax error
<_avyy>
if amp works such as to_proc - valid operation
<_avyy>
Or amp works only for cases where for method need block?
<_avyy>
(sorry for english)
<Asher>
& says to a method: treat this parameter as the block parameter
<Asher>
if the parameter specified by & is not a proc already it will call .to_proc
<Asher>
but that only applies in method parameter context
<_avyy>
OH JESUS
<_avyy>
Thanks!
datanoise [datanoise!~datanoise@24-145-66-018-dhcp.mia.fl.atlanticbb.net] has joined #ruby-lang
<_avyy>
Also, how i can see realisation of amp in MRI sources?
<Asher>
look in the parser definitions
<_avyy>
Okay, many thanks!
<Asher>
parse.y
fahadsadah [fahadsadah!fahad@unaffiliated/fahadsadah] has joined #ruby-lang
<Asher>
you're asking the eigenclass if it responds to the method you just defined in it
<Asher>
the class will respond to it, the eigenclass does not
corn_man [corn_man!kvirc@unaffiliated/cornman] has joined #ruby-lang
<imperator>
blarg
<imperator>
i figured that might be it, but it creates issues for me :(
<imperator>
the issue is with an ffi method
<imperator>
basically i need to alias an ffi function, but that function may not exist, depending on the platform
<imperator>
wait, i know...
* imperator
should have talked to the wall first
looopy [looopy!~looopy@c-68-34-92-100.hsd1.md.comcast.net] has joined #ruby-lang
<Asher>
not sure what all that meant but the example you just showed will work if you put an end after oyu defne your method before you ask respond_to?
<burgestrand>
imperator: method_defined?
andrewhl [andrewhl!~andrew@CPE687f7402a2d8-CM00195ed25a2a.cpe.net.cable.rogers.com] has joined #ruby-lang
<imperator>
Asher, i just did an outer conditional
<imperator>
if respond_to?(:some_singleton_method); class << self; ...
<Asher>
i don't understand what you're trying to achieve, but if you do - great :)
<burgestrand>
Pretty much define a method conditionally
<burgestrand>
Well, alias it rather
<imperator>
yep, at the singleton level
<burgestrand>
Did the same for FFI::Pointer#read_size_t :p
<Asher>
ah yea… looks like you got it then… and if not burgestrand gave you the other option
<imperator>
yes, thanks burgestrand, hadn't thought of that
wyhaines [wyhaines!~wyhaines@65.39.118.15] has joined #ruby-lang
_avyy [_avyy!~Sage@79.164.150.164] has quit [#ruby-lang]
robgleeson [robgleeson!~rob@subtle/contributor/robgleeson] has joined #ruby-lang
skammer [skammer!~skammer@ppp95-165-179-17.pppoe.spdop.ru] has joined #ruby-lang
S2kx [S2kx!~S1kx@ip-95-223-80-198.unitymediagroup.de] has joined #ruby-lang
Pip [Pip!~Pip@unaffiliated/pip] has joined #ruby-lang
<shevy>
hmm
<shevy>
is :p a smiley or a symbol
<Asher>
dilemmas
<shevy>
:(
<shevy>
I wonder how ruby would look like if matz would have tried to only compete in the range of lua
<lianj>
whats your idea of luas range?
janissary [janissary!~user@adsl-98-70-95-30.mco.bellsouth.net] has joined #ruby-lang
benanne [benanne!~rijdier@218.188-241-81.adsl-dyn.isp.belgacom.be] has joined #ruby-lang
corn_man [corn_man!kvirc@unaffiliated/cornman] has joined #ruby-lang
corn_man [corn_man!kvirc@unaffiliated/cornman] has joined #ruby-lang
<rue>
Here to about here
yfeldblum [yfeldblum!~Jay@pool-173-68-228-166.nycmny.east.verizon.net] has joined #ruby-lang
* manveru
wants xpath2 in nokogiri
<rue>
Isn't it?
<bougyman>
nope
<rue>
Maybe libxml only implements parts
<bougyman>
manveru: does the pg have xpath2?
<manveru>
pg uses libxml too afaik
heppy [heppy!~heppy@75-101-31-55.dsl.dynamic.sonic.net] has joined #ruby-lang
<manveru>
yeah
<manveru>
libxml2 doesn't have xpath2 because it's still only a spec draft or something
vmatiyko [vmatiyko!~vmatiyko@178.121.177.46] has joined #ruby-lang
<manveru>
i haven't really read all of it
<burgestrand>
andrewhl: because on one hand you’re using String#* but on the other you’re using Fixnum#*
<rue>
andrewhl: I.e. "w".*(2) vs. 2.*("w")
<manveru>
all i want is ends-with... xpath1 only has starts-with
<rue>
Heh
<rue>
manveru: Reverse the document!
<andrewhl>
ah, ok
<rue>
andrewhl: And Fixnum#* just does actual multiplication
corn_man [corn_man!kvirc@unaffiliated/cornman] has joined #ruby-lang
cyri_ [cyri_!~cyri_@nor75-27-88-178-186-47.fbx.proxad.net] has joined #ruby-lang
saLOUt [saLOUt!~rriemann@2.208.178.155] has joined #ruby-lang
DEac- [DEac-!~deac@81.16.104.86] has joined #ruby-lang
<necromancer>
is {'Content-Type': 'text/plain'} valid in ruby 1.9?
<necromancer>
or do i still have to use hashrockets?
<necromancer>
btw merry christmas guyz!
<yfeldblum>
necromancer, the `key: "value"` notation should only be used for named arguments to messages, not for general Hashes
<mindgame>
how do i end a ruby program in cmd(windows)
<shevy>
mindgame exit
<shevy>
or control-C if it hangs
<shevy>
or -Z
<shevy>
I uses MSYS on windows, I can't stand plain cmd.exe
<yfeldblum>
ctrl-alt-del
<shevy>
lol
<shevy>
oh
<necromancer>
yfeldblum: technically these are named arguments to messages
<shevy>
task manager is also an option mindgame
<mindgame>
contol-c worked
<mindgame>
what do you mean by hanging
<shevy>
if it does not respond or something like that
<yfeldblum>
necromancer, that's a header in a MIME-like message, not a named argument to an OO-like message
<necromancer>
yfeldblum: oh i see what you mean now
wyhaines [wyhaines!~wyhaines@24.143.25.13] has joined #ruby-lang
<necromancer>
yfeldblum: i was just going to remark on how disgustingly easy it would be to parse JSON into a Ruby object if it was valid to just build hash objects like that
<necromancer>
yfeldblum: with an understanding that `key: "value"` notation "should" only be used for named arguments to messages, does Ruby actually maintain a distinction between hashes with the new syntax and hashes with the old syntax, or are they both the same kind of object? although best practices might dictate against it, would using that notation all the time cause errors or just be more difficult to u
<necromancer>
nderstand what's going on?
<yfeldblum>
necromancer, there's no internal distinction
<necromancer>
oh ok
wyhaines [wyhaines!~wyhaines@24.143.25.13] has joined #ruby-lang
dejongge [dejongge!~jonke@pD9E0C3D2.dip0.t-ipconnect.de] has joined #ruby-lang
<yfeldblum>
necromancer, however, symbols should only be used in very specific cases, and in all other cases, strings; one of those cases where one should use symbols is in named arguments to messages, following the positional arguments to the messages (not passing a Hash of data as an argument, but passing a named argument)
workmad3 [workmad3!~workmad3@cpc1-bagu10-2-0-cust81.1-3.cable.virginmedia.com] has joined #ruby-lang
<mindgame>
oh fuck
<mindgame>
is there a way to stop the program if its spewing
<yfeldblum>
necromancer, the best use of this smaller syntax is to facilitate this good use case of symbols: passing named arguments to messages
<necromancer>
ok
<necromancer>
yfeldblum: the reason for using strings by default and symbols only in specific cases, i assume, is flexibility?
<necromancer>
because you can do "#{key_param}_#{key_id}" => key_value
<necromancer>
or something
<yfeldblum>
necromancer, sure, you can use interpolation with strings, but also Hashes can have any objects as keys, not just strings
<necromancer>
wait really?
<yfeldblum>
{ Object.new => Object.new }
<necromancer>
so i can do like { User => @some_user }?
<necromancer>
that's fucked up man
<yorickpeterse>
Out of curiosity, when would one use Date, DateTime or Time? I know some of them have certain parsing methods (e.g. Date.strptime) that others don't, but other than that they're a bit confusing
<rue>
mindgame: ^C probably?
<yorickpeterse>
Since for example Time also sets dates, and not just times
<yfeldblum>
yorickpeterse, i don't really know the rules or best practices there, sorry
<yorickpeterse>
Hm
<manveru>
yorickpeterse: Time is basically an int, Date is a rational, and DateTime is insane
<yorickpeterse>
Heh
<yorickpeterse>
Oh look at that, Time actually has .strptime()
<manveru>
anw, Date is easier to do day/week/year calculations and manipulations with
<necromancer>
i've been happy just using Time honestly
<manveru>
while Time is more seconds-oriented
<necromancer>
yeah it's stored as UTC seconds since the epoch
<yorickpeterse>
Cool, thanks :)
io_syl [io_syl!~io_syl@adsl-69-105-118-125.dsl.pltn13.pacbell.net] has joined #ruby-lang
io_syl [io_syl!~io_syl@unaffiliated/steph021] has joined #ruby-lang
<rue>
Also, can't go back very far with Time
<rue>
Or forward :/
<yfeldblum>
necromancer, why is it odd that you can use anything as a Hash key?
<manveru>
rue: on 64bit?
<rue>
On Portable System ™
<necromancer>
i don't know i guess it's because you can't do it with php or perl, and i've never seen it done in ruby before, so i just never knew you could do it
<manveru>
hm
<yorickpeterse>
I really like it that you can set any type as the key
<matled>
necromancer: one problem with symbols is that they cannot be garbage collected. there is one object per symbol but once a symbol has been used the mapping of the symbols name to its object id has to be saved until ruby terminates. therefore you should only use a limited number of symbols (and not convert everything entered by a user into a symbol).
<manveru>
not sure, but i consider that quite far in the future...
<rue>
See above
<manveru>
probably longer than ruby will be around
<lianj>
:)
<jaska>
probably longer than the universe will be around
<manveru>
they say programming languages never die
<yfeldblum>
matled, in addition, if you convert user-entered strings into symbols, that opens the doorway to your interpreter being DoS'd by legitimate users (and even more so by malicious users)
<manveru>
anyway, it looks like Time now handles Bignum as well, even if it's way slower
<matled>
yfeldblum: exactly
<rue>
yfeldblum: Logically speaking, it might not even need a write lock on the symbol table
<rue>
matled: The short and long of it is that if you A) read (from I/O), B) write or C) modify the content, you should use a String
tomzx [tomzx!~tomzx@dsl-132-26.aei.ca] has joined #ruby-lang
<yfeldblum>
rue, i assume MRI just uses the GIL?
<rue>
I'm pretty sure it does, yeah
<yorickpeterse>
manveru: heh, numbers aren't an issue in this case
<yorickpeterse>
I'm parsing dates to verify them, never doing anything with timestamps or other large numbers
<yfeldblum>
rue, so this issue just happens to be masked by a worse issue ... for now
<yfeldblum>
rue, i suppose it could be implemented with an atomic CAS
hagabaka [hagabaka!~hagabaka@unaffiliated/hagabaka] has joined #ruby-lang
flip_digits [flip_digits!~textual@c-71-199-243-97.hsd1.fl.comcast.net] has joined #ruby-lang
looopy [looopy!~looopy@c-68-34-92-100.hsd1.md.comcast.net] has joined #ruby-lang
<necromancer>
yfeldblum: should i use symbols when denoting array keys from a YAML::load_file?
<necromancer>
like CONFIG[:consumer_id]
<yfeldblum>
necromancer, no, you should use strings, unless for some retarded reason the YAML file has symbol keys
<necromancer>
nah it just looks prettier
<yfeldblum>
necromancer, you should always use strings unless, in some specific circumstance, you have a specific, concrete reason to use symbols
<necromancer>
done
<necromancer>
cool i think i will use symbols less
thone [thone!~thone@f052159008.adsl.alicedsl.de] has joined #ruby-lang
<yorickpeterse>
Symbols are useful when the same keys are referenced many times
<yorickpeterse>
e.g. You have a large collection of hashes each with the same keys
Pip_ [Pip_!~Pip@unaffiliated/pip] has joined #ruby-lang
<yfeldblum>
yorickpeterse, why are they more useful?
<yfeldblum>
yorickpeterse, just use a constant referencing a frozen string
<yorickpeterse>
If they're re-used often it could save memory usage
<yorickpeterse>
For example, in one of my use cases I use symbols to retrieve themes. These theme names may be referenced so many times that using strings would most likely have an impact on the memory usage
<yfeldblum>
reusing a constant referencing a frozen string saves equally on memory usage
<burgestrand>
comparison is faster for symbols than strings
<burgestrand>
actually, for symbols comparison is constant, but for strings it grows with size
<yorickpeterse>
yfeldblum: except that would require developers to first store it somewhere
<yorickpeterse>
Rather than themes[:gray_theme]
<yorickpeterse>
I'd rather not do MY_THEME = 'foobar'.freeze; themes[MY_THEME] ...... themes[MY_THEME].public .. etc
<yfeldblum>
yorickpeterse, that's what private methods are for
<yfeldblum>
burgestrand, isn't there first a comparison by object identity (e.g. by same object_id), subsequently by object equivalence?
<whitequark>
yfeldblum: there is
<yorickpeterse>
Other question, does Time offer anything to set the amount of hours, minutes, etc to a custom value? (after .parse(), .new() or others are called)
<yorickpeterse>
Something like t = Time.new; t.hours = 23;
<yfeldblum>
that's true, the sources for 1.8.7 and 1.9.3 for String#eql? differ in this regard
<whitequark>
burgestrand: interesting, it has only appeared in 1.9.3
<burgestrand>
whitequark: yet another reason to use 1.9.3 :p
<whitequark>
I do... use Rubinius!
<mindgame>
how do I use loop do to do this
<whitequark>
and 1.9.3 for production, yes
<burgestrand>
I was excited for full 1.9 support by 2012
<yfeldblum>
anyway, what i'm objecting to is "let's just use symbols for everything"; i'm ok with "symbols are faster in this situation, symbols use less memory in that situation, etc"
<whitequark>
burgestrand: I use it for, erm, other things--particularly introspection capabilities, sane bytecode, etc.
<whitequark>
yfeldblum: note that Symbols aren't GC'ed
<burgestrand>
Ah yes :)
<burgestrand>
neither are string assigned to a constant ^^
<yfeldblum>
whitequark, yes, that is one of my reasons
<whitequark>
burgestrand: Ruby "constants" are mutable
<burgestrand>
… or, well, nor I guess
<whitequark>
they're more like just global variables in that sense
<burgestrand>
aye, but reassigning constants just for the sake of it is kind of silly :p
<whitequark>
I wonder what's actually better in this case: Python's strings which are always immutable, but are also heap-allocated and GC'ed
<whitequark>
or Ruby's symbols which are extremely light, but never GC'ed (not a big concern unless you're doing something hairy) and explicit
joke_day [joke_day!~joke_day@cpc3-live6-0-0-cust1799.know.cable.virginmedia.com] has joined #ruby-lang
<whitequark>
I prefer Ruby way because the Symbols have additional semantic meaning
<yfeldblum>
ruby's strings are byte-arrays, not real strings
<yfeldblum>
:P
<whitequark>
yfeldblum: define "real string"?
<yfeldblum>
python3's, java's, and .net's versions, which are immutable and unicode
<jaska>
utf16 ... ick
<jaska>
worst of both worlds
<yfeldblum>
jaska, why?
<whitequark>
jaska: +1
<jaska>
yfeldblum: java and net that is... wide but still not fixed-width
<jensn>
yfeldblum: Because it is bad at storing enlgish, but not fixed-width.
<jensn>
*english
<jaska>
python can do utf32 tho
<whitequark>
even worse
<jaska>
well, utf16 is worse imo
<jensn>
UTF32 is probably the worst of all worlds, almost no script is smaller in UTF32 than in UTF8
<jaska>
atleast indexing is (cache-ignorant) constant-time
<whitequark>
yfeldblum: (unicode) 1.9 has unicode, and it has it the universal way
<whitequark>
and I don't see what's wrong with mutable strings.
<whitequark>
at least that allows one to operate with megabyte-sized buffers without resorting to some external insanity
slaytanic [slaytanic!~slaytanic@200-55-74-190.dsl.prima.net.ar] has joined #ruby-lang
<jensn>
jasiek: Except you almost always want to index by character, not code-point. Which isn't constant-time in UTF32 either.
<whitequark>
I think I'd like the implementation of strings as ropes more, but never seen that
<jaska>
jensn: normalize to a combined form :)
<whitequark>
jaska: not possible for most combination characters
<whitequark>
in a generic case, that is
<jaska>
id probably store utf32.. truncated to 1 byte :D
<jensn>
Or just use UTF8/16… like a boss.
nuclearsandwich [nuclearsandwich!~nuclearsa@74-93-3-241-SFBA.hfc.comcastbusiness.net] has joined #ruby-lang
Marco_ [Marco_!~marco@c-98-254-52-240.hsd1.fl.comcast.net] has joined #ruby-lang
darkf [darkf!~darkf_dix@unaffiliated/darkf] has joined #ruby-lang
<jaska>
well, not utf16, as stated before
<yfeldblum>
whitequark, 1.9 allows you to attach an encoding to a byte-array and also offers transcoding when you ask for it
<jensn>
jaska: For non-ascii, UTF16 can be significantly smaller. So there is a point in using it.
<jaska>
non-ascii is rarity in most cases
<whitequark>
yfeldblum: exactly
<whitequark>
jaska: O
<whitequark>
jaska: I'm Russian. Now say that to me :)
<jensn>
^
diegovio1a [diegovio1a!~viola@host-1-211.b15.cvc.com.py] has joined #ruby-lang
skinnymuch [skinnymuch!~skinnymuc@c-68-36-123-133.hsd1.nj.comcast.net] has joined #ruby-lang
<jensn>
Well, I am not russian, but non-ascii isn't rare.
<whitequark>
then, to members of ruby-core.
<burgestrand>
And me! D:
<mindgame>
are parenthesis after gets.chomp() redundant?
<burgestrand>
mindgame: yep
<jensn>
mindgame: Yes
<mindgame>
ty
<jensn>
whitequark: On the other hand, Cryllic is special since it only requires two bytes for characters in both encodings.
<jensn>
Same with Greek, Arabic and Hebrew iirc.
<whitequark>
jensn: but different two. And everything I have on disk or receive from the net is UTF8
<whitequark>
why the hell should I transcode it to utf16
<whitequark>
then from utf16
<whitequark>
goto 1
<jensn>
Almost everything I receive is in weird encodings… :(
<whitequark>
like cp437?
<jensn>
Thankfully, no.
<whitequark>
and there are still websites in Russian coded in KOI8.
corn_man [corn_man!kvirc@unaffiliated/cornman] has joined #ruby-lang
<whitequark>
it has an unique property that if 8th bit is chopped off, it auto-transliterates.
<whitequark>
in uppercase.
<jensn>
Thankfully EUC-xx seems to be dying.
srbaker [srbaker!~srbaker@184.66.82.213] has joined #ruby-lang
<Faris>
oh right that's faster than linked lists :)
solars [solars!~solars@194.208.132.118] has joined #ruby-lang
<samuelkadolph>
What would be the best way to parse a gem file in Objective C? Use macruby's rubygems 1.4.2 or use libarchive to extract the zlib and gz manually.
<jensn>
Just call tar
<andrewhl>
what's the easiest way to sort an array alphabetically?
<whitequark>
can anyone suggest sane reasons to redefine constants except for class reloading?
<jensn>
whitequark: To make someone else insane.
<whitequark>
no, seriously
<whitequark>
I'm deciding if my implementation should ever allow one to redefine constant or not
<jensn>
whitequark: No, there are no sane reasons, constants are constants.
<tobiasvl>
andrewhl: Array#sort
<whitequark>
I think not.
<whitequark>
yeah
TheMoonMaster [TheMoonMaster!~TMM@reddit/operator/themoonmaster] has joined #ruby-lang
<tobiasvl>
andrewhl: the default string comparison used by sort IS alphabetical :)
bawKz [bawKz!~bawKz@user-1120pv0.dsl.mindspring.com] has joined #ruby-lang
<andrewhl>
ok perfect, thanks
<tobiasvl>
btw, sort is functional, sort! is in place
Codif [Codif!~codif@84.120.204.160.dyn.user.ono.com] has joined #ruby-lang
thrcka [thrcka!~thrcka@dial-95-105-177-62-orange.orange.sk] has joined #ruby-lang
<samuelkadolph>
jensn: That's a horrible solution.
<jensn>
samuelkadolph: Why? It extracts the required contents, and tar is available on every platform.
<samuelkadolph>
For the same reason executing any external process when there are libraries to do it.
<jensn>
I think you just attacked every script out there ever.
<samuelkadolph>
Then you don't understand much
workmad3 [workmad3!~workmad3@cpc1-bagu10-2-0-cust81.1-3.cable.virginmedia.com] has joined #ruby-lang
Banistergalaxy [Banistergalaxy!~AndChat@222.153.223.47] has joined #ruby-lang
<yfeldblum>
whitequark, e.g. in a local monkey-patch to fix a bug with an existing constant in a separate gem
<yfeldblum>
whitequark, your implementation of what?
TheMoonMaster [TheMoonMaster!~TMM@reddit/operator/themoonmaster] has joined #ruby-lang