banisterfiend has quit [Remote host closed the connection]
banisterfiend has joined #ruby
igotnolegs has joined #ruby
vectorshelve has quit [Ping timeout: 245 seconds]
banisterfiend has quit [Ping timeout: 246 seconds]
shellox_ has quit [Ping timeout: 245 seconds]
Z_Mass has quit [Quit: Leaving]
blownapart has quit [Remote host closed the connection]
chriskk has quit [Ping timeout: 246 seconds]
Spooner has quit [Ping timeout: 252 seconds]
khakimov has quit [Ping timeout: 252 seconds]
maletor has quit [Quit: Computer has gone to sleep.]
bradhe has quit [Ping timeout: 244 seconds]
khakimov has joined #ruby
banisterfiend has joined #ruby
neku has quit [Read error: Connection reset by peer]
chriskk has joined #ruby
minijupe has joined #ruby
AndChat| has quit [Ping timeout: 250 seconds]
maletor has joined #ruby
nwest has joined #ruby
CodeVision has quit [Ping timeout: 248 seconds]
bricker88 has quit [Quit: Leaving.]
yugui_zzz is now known as yugui
CodeVision has joined #ruby
pk1001100011 has quit [Quit: I've got a feeling there's a fish in the floor; I'd better squish it or he'll swim out the door; Sometimes they take me for a walk in the sun; I see my fish and I have to run]
indian has quit [Read error: Connection reset by peer]
niklasb has quit [Read error: Operation timed out]
owned_ has quit [Read error: Connection reset by peer]
cloud|windoze has joined #ruby
guns has joined #ruby
GarethAdams has quit [Quit: Leaving...]
<guns>
Is there a way to run the syntax checker `ruby -c` from within a running ruby interpreter (ie without shelling out)?
<guns>
My guess is "no" since the syntax checking option is handled directly in process_options() in ruby.c
<guns>
but perhaps someone has a clever trick
yonggu has joined #ruby
cloud|windoze1 has joined #ruby
cloud|windoze has quit [Ping timeout: 246 seconds]
emmanuelux has quit [Ping timeout: 246 seconds]
akem has quit [Quit: Forget progress by proxy. Land on your own moon.]
akem has joined #ruby
justsee has joined #ruby
kah_ has joined #ruby
kah_ has quit [Client Quit]
Stalkr_ has quit [Quit: Leaving...]
seanstickle has joined #ruby
undersc0re has quit [Quit: *poof*]
ryanf has joined #ruby
yugui is now known as yugui_zzz
etank has quit [Quit: WeeChat 0.3.8]
nari has quit [Ping timeout: 252 seconds]
etank has joined #ruby
mockra has joined #ruby
Draco_ has quit [Remote host closed the connection]
yoklov has joined #ruby
bricker88 has joined #ruby
bricker88 has quit [Client Quit]
zodiac1111 has joined #ruby
Draco_ has joined #ruby
alek_b has quit [Ping timeout: 248 seconds]
alek_b has joined #ruby
tommyvyo has joined #ruby
Cooper_ has joined #ruby
Draco_ has quit [Ping timeout: 244 seconds]
perry is now known as perryh_away
sdwrage has joined #ruby
mockra has quit [Remote host closed the connection]
sdwrage has quit [Client Quit]
yoklov has quit [Quit: computer sleeping]
apok has joined #ruby
akem has quit [Ping timeout: 240 seconds]
greasegum has joined #ruby
yoklov has joined #ruby
byronb has quit [Ping timeout: 255 seconds]
kedai has quit [Ping timeout: 246 seconds]
justsee has quit [Quit: Leaving...]
kedai has joined #ruby
yoklov has quit [Client Quit]
baroquebobcat has quit [Quit: baroquebobcat]
jimeh has quit [Ping timeout: 246 seconds]
oscardelben has joined #ruby
Draco_ has joined #ruby
justsee has joined #ruby
elvis4526 has joined #ruby
EPIK has quit []
RORgasm has joined #ruby
Speed has quit [Quit: When two people dream the same dream, it ceases to be an illusion.]
<elvis4526>
Is there something simpler then optparse to use in ruby?
<elvis4526>
Something less pain in the ass
`brendan has quit [Read error: Connection reset by peer]
bglusman_ has joined #ruby
bradhe has joined #ruby
RORgasm has quit [Ping timeout: 246 seconds]
<seanstickle>
elvis4526: Thor, maybe
<seanstickle>
elvis4526: depends on what kind of thing you are making
<elvis4526>
I just want a SIMPLE way to do, when i put this flag, you do this.
bglusman has quit [Ping timeout: 265 seconds]
<elvis4526>
Something like getopts in bash would be nice
<elvis4526>
and I can play with the argument with $optarg
<seanstickle>
Check the ARGV would be the simplest
<elvis4526>
I did not see any doc about it
<seanstickle>
You know what ARGV is?
baroquebobcat has joined #ruby
<elvis4526>
I read that it is like optparse, but less powerful
<seanstickle>
Uh, you might want to read it again.
Hanmac1 has joined #ruby
<elvis4526>
There is no beginner tutorial about this
<seanstickle>
If you don't know ARGV, you'll be in a weird situation writing Ruby apps
<elvis4526>
I know a little bit what it is, but I just don't understand
Hanmac has quit [Ping timeout: 252 seconds]
Cooper_ has quit [Ping timeout: 255 seconds]
yoklov has joined #ruby
mockra has joined #ruby
<elvis4526>
In fact, all the argument are in an array and the arraw is name ARGV?<
ken_barber has joined #ruby
_justin has joined #ruby
<seanstickle>
Yup
<seanstickle>
ARGument Values
<seanstickle>
=> ARGV
<elvis4526>
Hmm... Okay. It is a little bit more clear now. So how do i do to make it print "prout" when he see the -i argument for instance
linoj has quit [Read error: Connection reset by peer]
<elvis4526>
It is this kind of thing I want to do
linoj has joined #ruby
greasegum has quit [Ping timeout: 250 seconds]
L-----D has joined #ruby
Cooper_ has joined #ruby
mpereira has joined #ruby
vlad_starkov has quit [Remote host closed the connection]
bradhe_ has joined #ruby
bradhe has quit [Ping timeout: 244 seconds]
khakimov has quit [Quit: Computer has gone to sleep.]
davidpk has joined #ruby
tewecske has quit [Quit: Leaving.]
cpruitt has quit [Quit: cpruitt]
mxweas_ has joined #ruby
banisterfiend has quit [Remote host closed the connection]
mxweas_ has quit [Client Quit]
mockra has quit [Remote host closed the connection]
seanstickle has quit [Quit: seanstickle]
banisterfiend` has joined #ruby
ryanf has quit [Ping timeout: 265 seconds]
hunglin has joined #ruby
jfelchner has joined #ruby
meskyanichi has joined #ruby
cakehero has quit [Quit: Computer has gone to sleep.]
<rking>
Hrm. Is there a clean idiom to say "if x.nil? or <there was an exception>" ?
<rking>
I'm drawing a bit of a blank trying to make my "rescue" chunk the same as my "else" chunk
<rking>
I could say fail 'adsf' if x.nil? then the rescue would catch it, but that seems silly.
awarner has joined #ruby
patient has quit [Quit: leaving]
zeromodulus has quit [Remote host closed the connection]
Draco___ has joined #ruby
Draco_ has quit [Ping timeout: 248 seconds]
Boondox has quit [Quit: Leaving]
icy` has quit [Quit: .: adios :.]
apok has quit [Quit: apok]
Cooper_ has quit [Ping timeout: 265 seconds]
Cooper_ has joined #ruby
Draco___ has quit [Ping timeout: 240 seconds]
nari has joined #ruby
mockra has joined #ruby
baroquebobcat has quit [Quit: baroquebobcat]
linoj has quit [Quit: linoj]
icy` has joined #ruby
icy` has quit [Changing host]
icy` has joined #ruby
TheHypnotist-lhs has quit [Ping timeout: 265 seconds]
kidoz has quit [Read error: Connection reset by peer]
g_rotbart has quit [Remote host closed the connection]
Sweet-P has quit [Remote host closed the connection]
Sweet-P has joined #ruby
kidoz has joined #ruby
mpereira has quit [Ping timeout: 250 seconds]
* mdszy
feels like he just made the most awesome thing in the world, even though it's just something really simple.
verto is now known as verto|off
<mdszy>
http://hastebin.com/timavuruho.c in case anyone wants to see, an extremely simple C function for counting the digits in an integer using recursion
iamjarvo has joined #ruby
stefanp_ has joined #ruby
wataken44 has quit [Remote host closed the connection]
Draco_ has joined #ruby
Draco_ has quit [Read error: Connection reset by peer]
wataken44 has joined #ruby
Draco_ has joined #ruby
stefanp has quit [Ping timeout: 265 seconds]
vlad_starkov has joined #ruby
greasegum has left #ruby ["Leaving"]
Progster has joined #ruby
awarner has quit [Remote host closed the connection]
vlad_starkov has quit [Ping timeout: 244 seconds]
IceDragon has quit [Ping timeout: 265 seconds]
Draco_ has quit [Ping timeout: 252 seconds]
justsee is now known as justsee|away
g_rotbart has joined #ruby
<dekz>
Anyone had any problems with starting up ruby objects which have a trap call in a multithreaded environment on jruby? I'm getting no such method errors on __jtrap from Ruby Kernel
mockra has quit [Remote host closed the connection]
mmsequeira_ has joined #ruby
nai has joined #ruby
mrdodo has joined #ruby
mahmoudimus has joined #ruby
webusnix has quit [Quit: Ухожу я от вас (xchat 2.4.5 или старше)]
mmsequeira has quit [Ping timeout: 252 seconds]
banisterfiend` has quit [Remote host closed the connection]
cableray has quit [Quit: cableray]
headius has joined #ruby
krz has quit [Quit: krz]
nai has quit [Remote host closed the connection]
tomb has joined #ruby
mxweas_ has joined #ruby
Banistergalaxy has joined #ruby
td123 has quit [Ping timeout: 244 seconds]
vitor-br has quit [Read error: Connection reset by peer]
mdszy has quit [Quit: nini]
tomb has quit [Client Quit]
pedm has quit [Quit: pedm]
mockra has joined #ruby
diegoviola has quit [Quit: leaving]
null- has left #ruby [#ruby]
eph3meral has joined #ruby
mockra has quit [Remote host closed the connection]
baroquebobcat has joined #ruby
mockra has joined #ruby
j01 has quit [Quit: j01]
\13k has quit [Quit: Leaving]
khakimov has joined #ruby
CaptainJet has quit []
headius has quit [Quit: headius]
wargasm has quit [Read error: Connection reset by peer]
cdavaz has quit [Quit: cdavaz]
_justin has quit [Ping timeout: 250 seconds]
cdavaz has joined #ruby
Jackneill has joined #ruby
Jackneill is now known as Guest75326
L-----D has quit [Ping timeout: 246 seconds]
elrond255 has joined #ruby
nai has joined #ruby
iamjarvo has quit [Quit: Computer has gone to sleep.]
RichieEvan has quit [Quit: RichieEvan]
andrewhl has joined #ruby
dhruvasagar has joined #ruby
luckyruby has joined #ruby
banisterfiend has joined #ruby
xpot-station has quit [Ping timeout: 244 seconds]
nai has quit [Remote host closed the connection]
xscc has joined #ruby
emmanuelux has quit [Remote host closed the connection]
<elrond255>
I'm having a syntax problem. in https://gist.github.com/3120460 I've copied the class I'm using (validator.rb), the test driver I wrote (validate_test.rb) and the result of executing the command (validate_test.rb.txt). Can anyone point me to the mistakes that are causing the error?
_justin has joined #ruby
g_rotbart has quit [Remote host closed the connection]
xscc has quit [Client Quit]
nai has joined #ruby
oscardelben has quit [Quit: oscardelben]
guns has quit [Ping timeout: 255 seconds]
RichieEvan has joined #ruby
igotnolegs has quit [Quit: Computer has gone to sleep.]
igotnolegs has joined #ruby
igotnolegs has quit [Client Quit]
savage- has quit [Remote host closed the connection]
Cooper_ has quit [Read error: Connection reset by peer]
Cooper_ has joined #ruby
igotnolegs has joined #ruby
Icoin has quit [Quit: Icoin]
nai has quit [Remote host closed the connection]
AndChat| has joined #ruby
Banistergalaxy has quit [Ping timeout: 248 seconds]
vertroa has quit [Read error: Connection reset by peer]
Ethan has joined #ruby
thecreators has quit [Quit: thecreators]
vertroa has joined #ruby
mockra has quit [Remote host closed the connection]
hemanth has joined #ruby
Cooper_ has quit [Read error: Connection reset by peer]
Cooper_ has joined #ruby
mockra has joined #ruby
andrewhl has quit [Remote host closed the connection]
noyb has joined #ruby
cantonic_ has joined #ruby
lion|wrk has left #ruby ["WeeChat 0.3.8"]
mockra has quit [Ping timeout: 248 seconds]
cantonic has quit [Ping timeout: 255 seconds]
cantonic_ is now known as cantonic
mockra has joined #ruby
crankycoder has quit [Remote host closed the connection]
Draco_ has quit [Ping timeout: 246 seconds]
Progster has quit [Ping timeout: 260 seconds]
thatRD has quit [Read error: Operation timed out]
syamajala has joined #ruby
artOfWar has joined #ruby
artOfWar_ has quit [Read error: Connection reset by peer]
artOfWar_ has joined #ruby
tonini has joined #ruby
csprite has joined #ruby
mxweas_ has quit [Quit: Computer has gone to sleep.]
artOfWar has quit [Ping timeout: 240 seconds]
davidpk has quit [Quit: Computer has gone to sleep.]
mxweas_ has joined #ruby
mockra has quit [Remote host closed the connection]
<elrond255>
<elrond255>
I'm having a syntax problem. in https://gist.github.com/3120460 I've copied the class I'm using (validator.rb), the test driver I wrote (validate_test.rb) and the result of executing the command (validate_test.rb.txt). Can anyone point me to the mistakes that are causing the error?
justsee has joined #ruby
mockra has joined #ruby
mrdodo has quit [Remote host closed the connection]
nai has joined #ruby
elrond255 has quit [Quit: elrond255]
mockra has quit [Remote host closed the connection]
yoklov has quit [Quit: computer sleeping]
RichieEvan has quit [Ping timeout: 244 seconds]
bglusman_ has quit [Remote host closed the connection]
cdavaz is now known as Ontolog
justsee has quit [Quit: Leaving...]
krz has joined #ruby
Draco_ has joined #ruby
baroquebobcat has quit [Quit: baroquebobcat]
baroquebobcat has joined #ruby
dhruvasagar has quit [Ping timeout: 252 seconds]
mahmoudimus has quit [Quit: Computer has gone to sleep.]
thatRD has joined #ruby
oxyxian has quit [Quit: oxyxian]
greyEAX has quit [Read error: Connection reset by peer]
nai has quit [Remote host closed the connection]
baroquebobcat has quit [Quit: baroquebobcat]
syamajala has quit [Remote host closed the connection]
ananthakumaran has quit [Quit: Leaving.]
RORgasm has joined #ruby
yugui_zzz is now known as yugui
a_a_g has joined #ruby
yugui is now known as yugui_zzz
RORgasm has quit [Ping timeout: 246 seconds]
undersc0re has joined #ruby
headius has joined #ruby
Ethan has quit [Read error: Operation timed out]
kylemcgill has quit [Remote host closed the connection]
undersc0re is now known as Ethan
vertroa has quit [Read error: Connection reset by peer]
vertroa has joined #ruby
headius has quit [Ping timeout: 255 seconds]
csprite has quit [Quit: ChatZilla 0.9.88.2 [Firefox 13.0.1/20120614114901]]
mxweas_ has quit [Quit: Computer has gone to sleep.]
grantbdev has quit [Quit: Leaving]
IceDragon has quit [Quit: ~ヾ(^∇^)]
savage- has joined #ruby
alek_b has quit [Remote host closed the connection]
alek_b has joined #ruby
alek_b has quit [Remote host closed the connection]
alek_b has joined #ruby
alek_b has quit [Remote host closed the connection]
<_bart>
Hi I get "`downcase': invalid byte sequence in UTF-8" when I try to downcast a large chunk of data.
Rochefort has quit [Remote host closed the connection]
Cooper has quit [Ping timeout: 240 seconds]
<_bart>
how do I force it to work?
<hoelzro>
_bart: is your data actually UTF-8?
<apeiros_>
you either specify the correct encoding
<apeiros_>
or you remove the offending bytes
<apeiros_>
because either what you have is not utf-8, or the utf-8 you have is broken
<_bart>
#<Encoding:UTF-8>
bluenemo has joined #ruby
<apeiros_>
_bart: yes, that's what *you* tell ruby that your string is
<apeiros_>
ruby does not (and can not) detect the encoding of a string by its own.
<_bart>
no the string I'm down casing might have chinese characters of weird stuff like that, I don't mind if they don't downcase along.
<apeiros_>
that's not the point
<_bart>
it's a Nokogiri node
<_bart>
that I call .to_s upon
danguita has quit [Ping timeout: 248 seconds]
bluenemo_ has joined #ruby
bluenemo_ has quit [Changing host]
bluenemo_ has joined #ruby
<apeiros_>
the point is that your text contains byte sequences that are *not* valid utf-8. so I repeat: either your string does *not* contain utf-8, so you shouldn't tell ruby it was. or your string contains broken utf-8.
<apeiros_>
if it is the latter, you'll have to devise a clean-up strategy.
fermion has joined #ruby
bluenemo has quit [Remote host closed the connection]
mobilegamelabs has joined #ruby
Speed has quit [Remote host closed the connection]
wrapids has quit [Ping timeout: 240 seconds]
<_bart>
apeiros_: isn't there a quick and dirty clean up method?
<apeiros_>
_bart: if you don't know what you want then there is none.
<apeiros_>
since String#downcase will only downcase A-Z, you can force_encode to binary and downcase that.
mdstunthamster has joined #ruby
<apeiros_>
but that doesn't relieve you from having to learn and understand how encodings work.
myth17 has joined #ruby
hemanth has quit [Read error: Connection reset by peer]
hashar has quit [Quit: I am a manual virus, please copy me to your quit message.]
<Spooner>
_justin : JSON doesn't support symbols. You either need to use a serialisation that does support symbols or, after you load, either convert the hash or use a hash that allows you to reference string keys with symbols.
ixti has joined #ruby
<_justin>
Spooner: will try, thnx
<Spooner>
What are you trying to do, exactly?
<Spooner>
Oh, right, interact with Kendo UI
<fowl>
you can use symbols in yaml
<fowl>
:key: value
<Spooner>
fowl: Yes, but the external app requires normal json, so I am not sure why _justin was asking for symbols to be preserved in the .to_json.
<fowl>
o
<_justin>
yea, Spooner maybe i got the concept they stated there wrong, i dont think a product like kendoui can rip-off the concept json
<_justin>
fowl: wen i feed data into the widget it should be key:"value"
seitensei has quit [Remote host closed the connection]
<Spooner>
What widget exactly?
<_justin>
they use the key to populate data
<_justin>
grid
<Spooner>
That isn't too specific. Are you interfacing with KendoUI directly or do you have a Ruby binding?
<_justin>
directly
<_justin>
i dont know about any rb binding for it
<fowl>
you're saying that something that has nothing to do with ruby, requires you to use symbols?
<Spooner>
.to_json produces valid json, so don't worry about it.
reuf has joined #ruby
<_justin>
fowl: just to prevent key to get enclosed in quotes
tuxaddic1ed has quit [Read error: Operation timed out]
<Spooner>
The data there isn't json - that is javascript. It will be converted into json, just like our Ruby hash { x: "y"}.to_json will become '{"x":"y"}'
<ij>
When you create super-self-explanatory methods, do you put articles in their names, e.g. def can_have_a_weasel?
tuxaddicted has quit [Read error: Operation timed out]
trivol_ has joined #ruby
<fowl>
i would go with can_has_weasels? that way you can anger grammar nazis
<shevy>
lol
<shevy>
ij: the problem is that the extra words often don't make the method read better
<Spooner>
You don't usually. So you use have_a_weasel? or awake? rather than is_awake? or can_have_a_weasel?
<shevy>
ij: whenever possible, try to be as short as possible
<shevy>
now in this example
<shevy>
_a is not that long
<shevy>
but I have had examples where the method itself was already way too long, so adding more to it would make it only worse
<_justin>
Spooner: yea, i tried to inject json directly, it is generating trouble
trivol has quit [Ping timeout: 248 seconds]
trivol_ is now known as trivol
<Spooner>
_justin: There are a hundred other things that could be going wrong other than that the json is invalid. No idea how/what you are doing though.
tuxaddicted has joined #ruby
tuxaddic1ed has joined #ruby
jjang_ has joined #ruby
justsee has quit [Ping timeout: 250 seconds]
<_justin>
Spooner: got it r8, the issue was caused coz i tried to inject json data as such
jjang_ has quit [Remote host closed the connection]
Guerrero has joined #ruby
nemesit|osx has joined #ruby
jjang has quit [Ping timeout: 252 seconds]
<JonnieCache>
ij: ignore them, name your methods what you want
<JonnieCache>
especially if theyre going to go in html templates or something
<JonnieCache>
or a dsl
<fowl>
ij, donno, can_has_weasels?
heisenmink has quit [Quit: Leaving]
<fowl>
dont listen to him
nemesit has quit [Ping timeout: 265 seconds]
<fowl>
use can_has_weasels?
<JonnieCache>
maybe not can_has_weasels?
<fowl>
he's a detractor, sent here to discourage you
<ij>
fowl: haha
BiHi has quit [Quit: Computer has gone to sleep]
<ij>
I wanted opinion. I got it. :]
<ij>
Another #ruby's success story.
<JonnieCache>
i like being able to write things like `user.can_edit? post`
<Spooner>
Why you are applying weasels to some things and not to others is another question entirely.
KDr2 has joined #ruby
BiHi has joined #ruby
<JonnieCache>
forget being as short as possible. use a proper editor.
<JonnieCache>
you will be happy when you come back in 12 months and you can actually read the code
<ij>
That makes no sense.
<ij>
Having a auto-completion doesn't make me want to make giant method names.
<ij>
And the long one just sometimes make the code visibly unparsable.
<JonnieCache>
i didnt say "be as long as possible" just dont cut down on method names for the sake of keystrokes, its a false economy
Criztian has joined #ruby
richardStokes has joined #ruby
<JonnieCache>
otherwise you may as well go back to the days of 8.3 filenames
<ij>
ha
<richardStokes>
anyone know a nice clean way of getting the first n digits from a large integer? i.e. get 123 from 1234567
<ij>
I remember that I was five or something and dad told me that I can't make filenames longer than that.
<fowl>
richardStokes, i would be lazy and int.to_s[0,3]
Sweet_P has joined #ruby
<richardStokes>
thanks, that was what I was going to do until I realized that it was actually more appropriate to store the data as a string and not an integer. Thanks anyway
verto is now known as verto|off
Sweet-P has quit [Ping timeout: 250 seconds]
verto|off is now known as verto
grafthez has joined #ruby
Icoin has joined #ruby
<shevy>
hehehe
<shevy>
strings are quite more useful in ruby
<shevy>
"123"+"123" could only mean to append two strings, consistently
<shevy>
"123"+"123".to_i could not work as information would be lost. ruby can't pick a preference here randomly
<shevy>
hmm
<shevy>
perhaps it could make a biased favour towards strings... or integers, optionally, if set via shebang-flag or some other way
<shevy>
I'd love to have such a flag to omit "end"
mengu has quit [Read error: Operation timed out]
freeayu has quit [Ping timeout: 246 seconds]
<Mon_Ouie>
I though you hated indentation-based languages?
<Mon_Ouie>
thought*
mengu has joined #ruby
<JonnieCache>
shevy: write a preprocessor for ruby that converts significant whitespace into do-end
<JonnieCache>
i double dare you
yonggu has quit [Quit: yonggu]
freeayu has joined #ruby
<shevy>
haha
<shevy>
Mon_Ouie: yeah, from a conceptual point of view indeed. I dont think a programming language, or the parser, should care about indentation at all
<shevy>
but from looking at my own code at times, I feel that things could be more elegant when I could omit "end"
<shevy>
JonnieCache: what I never understood why python required both a ':' and also indent. "def foo():, newline,INDENT"
<shevy>
before that I always thought it would need only indentation
<Spooner>
I do sort of feel that end is unnecessary sugar too. I'd consider a preprocessor, but then I'd also need new editor highlighters and no-one else could edit my code without also having them. Shame.
<Spooner>
And yes, the : seems unnecessary too.
<shevy>
yeah, indent isn't the panacea either :( I think guido once said that this would be the main thing he would change if he could redo python completely once or?
akem has quit [Ping timeout: 244 seconds]
<Mon_Ouie>
In this case, yes, I think it wouldn't be hard to write a parser for just def foo() — but usually you'd need a token to know where you could find an indented block
<Mon_Ouie>
(In that case, the closed paren works)
Rochefort has joined #ruby
roychri has joined #ruby
vlad_starkov has joined #ruby
MOTION4 has quit [Quit: Computer has gone to sleep.]
<roychri>
Hello, I am trying to find the answer to the following issue but google keeps showing documentation about optional method parameters, which is not what I want. Is it possible with ruby to add optional values to a has, but inline. Ex: { :one => "1", :two => "2" if condition1, :three => "3" unless condition2 }
<roychri>
I know this does not work (I tried).
<roychri>
so maybe its possible but with a different syntax?
<Mon_Ouie>
But doing everything in one-line is stupid anyway
<roychri>
Mon_Ouie: : Thanks but the context is : <%= method "some param", :one => "1", :two => 2 %>
sapht has quit [Ping timeout: 245 seconds]
<roychri>
and I only want :two to be added based on a condition
<fowl>
thats bad design
<Mon_Ouie>
What prevents you from doing that?
<roychri>
Mon_Ouie: : Not doing EVERYTHING :)
<Spooner>
Well, there is: {a:1}.tap {|h| h[:b] = 3 if c1 }.tap{|h| h[:c] = 5 if c2 }
<Spooner>
Even though it is a little horrible.
<fowl>
do you indend to check the conditions every time you access hash[:two] ?
<roychri>
Spooner: : yeah, looks horrible. thnaks though
<fowl>
intend
hemanth has quit [Read error: Connection reset by peer]
<roychri>
Here is the real picture guys. <%= f.text_area :message, "data-action" => "richtext" if current_user.can_use_richtext?, :style => "width:500px" %>
ZachBeta has quit [Quit: Computer has gone to sleep.]
<_bart>
peterhellberg: thanks!
<peterhellberg>
But you probably just need the full date, right?
<peterhellberg>
And then just parse it into a proper Data/Time object :)
emmanuelux has joined #ruby
flippingbits has quit [Client Quit]
MOTION4 has joined #ruby
<_bart>
peterhellberg: yes using the [0][0]
DrShoggoth has quit [Read error: Connection reset by peer]
<_bart>
peterhellberg: I have multiple regexpes that look for dates, how do I put the results all in the same "dates" variable?
<peterhellberg>
_bart: In that case you won’t even need the extra captures
<fowl>
peterhellberg, why did you add the extra stuff
<peterhellberg>
fowl: It was just an example
jonathanwallace has quit [Remote host closed the connection]
<peterhellberg>
(if you want multiple captures per match)
DrShoggoth has joined #ruby
<peterhellberg>
_bart: Is there a reason why the dates have different formats? (User input?)
<_bart>
peterhellberg: this is a tiny part of my smart scraper, it scrapes/parses html and the code is intelligent to understand the structure.
<peterhellberg>
_bart: Ah, got it.
<_bart>
so I can except any kind of format
<_bart>
expect*
Stalkr_ has joined #ruby
jmeeuwen has quit [Ping timeout: 240 seconds]
JohnBat26 has joined #ruby
<peterhellberg>
I’d write a single regex that accepts all the formats you want to support
prtksxna has joined #ruby
prtksxna has quit [Remote host closed the connection]
totochan has quit [Ping timeout: 265 seconds]
jxf has joined #ruby
<peterhellberg>
I would also use ISO 8601 for output etc
gry has joined #ruby
<jxf>
I have an array of strings. One of the elements in the array might be "foo". I want the value of the element that comes before "foo" if (1) there is a "foo" in the array, and (2) "foo" has an element before it (i.e. it's not the first thing in the array).
<peterhellberg>
_bart: If you want to support wildly different date formats, then it might be a good idea to split it up in multiple parsers/regexen
<jxf>
Is there a Ruby-ish way to pull that off?
akem has joined #ruby
akem has quit [Changing host]
akem has joined #ruby
<jxf>
My solution winds up having a couple of `if`s.
<_bart>
peterhellberg: yes that's what I want to do, but how to do that without turning into messy code?
luckman212 has joined #ruby
vjt has quit [Ping timeout: 272 seconds]
boredomist has quit [Ping timeout: 272 seconds]
Mez has quit [Ping timeout: 272 seconds]
<peterhellberg>
_bart: I’d step through each regex/parser run and aggregate the results in some way (Probably a simple Array, but it could just as well push new dates on top of a redis list, etc)
<_bart>
peterhellberg: alright
<hoelzro>
jxf: what about index = array.index('foo'); previous = index && index != 1 ? array[index - 1] : nil
<peterhellberg>
_bart: Are you also going to parse Time? (A whole can of worms considering how notoriously bad TZ-hints can be :)
croz has quit [Remote host closed the connection]
<_bart>
peterhellberg: only interested in dates haha ;)
jmeeuwen has joined #ruby
<jxf>
hoelzro: That looks wrong. It would return nil if 'foo' was the second thing in the array.
<peterhellberg>
Slow day at the office, pretty much everyone is on vacation :)
ctp has quit [Read error: Operation timed out]
<apeiros_>
jxf: ary.each_cons(2).find { |x,y| y == "foo" }.first
<hoelzro>
jxf: oops, I meant =!= 0
<apeiros_>
oh, hm, needs guarding against find returning nil
<hoelzro>
er, != 0
<JonnieCache>
i need some way of remembering that each_cons actually means sliding_window
<apeiros_>
meh, not as nice anymore:
<apeiros_>
["a","b","c","foox","d"].each_cons(2).find(proc{[nil]}) { |x,y| y == "foo" }.first
<JonnieCache>
considering how many redundant aliases the stdlib has that seems an oversight
zodiac1111 has quit [Ping timeout: 240 seconds]
bruder has joined #ruby
<apeiros_>
peterhellberg: same here. but sadly no slow day.
<peterhellberg>
Such a hard life in a “socialist society” ;)
* apeiros_
is having fun writing a ruby API against exchange's EWS interface
<jxf>
apeiros_: I wonder if that gets expensive with a big array since you wouldn't break early.
verto is now known as verto|off
<apeiros_>
jxf: that one *does* break early
<apeiros_>
that's the point of enumerators and find.
iamjarvo has joined #ruby
krz has quit [Quit: krz]
<jxf>
Oh, I misread. `first` is just getting the first of each pair.
<jxf>
Not the first of all the matches.
<peterhellberg>
apeiros_: In Finland by any chance?
<apeiros_>
jxf: the return value of the find is an array with [before_foo, "foo"]
<apeiros_>
so you have to call .first on it to get before_foo
<apeiros_>
but it does break on the first occurrence of that pattern
<jxf>
Gotcha. Yes, that's what I meant by "first of each pair".
bruder has left #ruby [#ruby]
lxsameer has joined #ruby
lxsameer has quit [Changing host]
lxsameer has joined #ruby
<apeiros_>
peterhellberg: no, switzerland
jonathanwallace has joined #ruby
<peterhellberg>
apeiros_: (I’ve only met one person that enjoys working with Exchange from Ruby… and he was working in Finland)
<peterhellberg>
:)
KDr2 has joined #ruby
<apeiros_>
peterhellberg: I'll rephrase: /me is having "fun" writing…
<apeiros_>
iow, I'm swearing my ass off
gry has joined #ruby
<apeiros_>
at least the docs are only bad, not horrible. and while the existing ruby libs are half-baked, they at least provide enough meat to scavenge and take short-cuts.
_justin has quit [Ping timeout: 240 seconds]
hashar has joined #ruby
lxsameer has quit [Max SendQ exceeded]
<apeiros_>
the functionality stands already. all I'm left to do is come up with an actually enjoyable ruby API wrapper around that ugly EWS turd
rails has quit [Ping timeout: 272 seconds]
vlad_starkov has quit [Remote host closed the connection]
KDr2 has quit [Remote host closed the connection]
<peterhellberg>
I’m leeching data from Google Analytics for internal processing… it’s pretty enjoyable with one of the Gattica forks and then a bunch of Map/Reduce queries in MongoDB :)
DefV has quit [Ping timeout: 272 seconds]
blueOxigen has quit [Read error: Connection reset by peer]
bluOxigen has joined #ruby
DefV has joined #ruby
GarethAdams has joined #ruby
cakehero has joined #ruby
rails has joined #ruby
mahmoudimus has quit [Quit: Computer has gone to sleep.]
verto|off is now known as verto
cloud|windoze has quit [Quit: Leaving.]
tommyvyo has joined #ruby
niklasb has joined #ruby
Foxandxss has joined #ruby
fantazo has quit [Remote host closed the connection]
mdszy has joined #ruby
linoj has joined #ruby
kidoz has quit [Quit: Ухожу я от вас]
fbernier has joined #ruby
obryan has joined #ruby
boredomist has quit [Ping timeout: 272 seconds]
t_j has left #ruby [#ruby]
boredomist has joined #ruby
yoklov has joined #ruby
vjt has quit [Ping timeout: 272 seconds]
oxyxian has joined #ruby
luckman212 has joined #ruby
vjt has joined #ruby
<_bart>
peterhellberg: when I do Date.parse over a large string it returns the last date it found
<_bart>
peterhellberg: or it skipped the very obvious first one, but that is unlikely
baphled has quit [Remote host closed the connection]
Axsuul has quit [Ping timeout: 255 seconds]
<_bart>
peterhellberg: anyway, how to tell Date.parse to look for the first occurance?
statix_ has joined #ruby
hynkle has joined #ruby
Guest32778 has quit [Quit: /quit]
luckman212_ has joined #ruby
alindeman has joined #ruby
<peterhellberg>
_bart: You are only supposed to parse a single date string
verto is now known as verto|off
<_bart>
peterhellberg: well the large string contains more than one
<_bart>
but I just want the first
luckman212 has quit [Ping timeout: 248 seconds]
<peterhellberg>
Steps: find all the dates, step through them, parse each date, insert in list of parsed dates
<peterhellberg>
Never pass "a large string" to Date.parse
nachtwandler has joined #ruby
<peterhellberg>
Just a "string containing a date"
stat1x has quit [Ping timeout: 256 seconds]
Criztian has joined #ruby
yugui_zzz is now known as yugui
nachtwandler has quit [Client Quit]
<peterhellberg>
_bart: You might also want to use the rfc2822, rfc3339 and strptime methods
My_Hearing has joined #ruby
Mon_Ouie has quit [Ping timeout: 265 seconds]
dhruvasagar has quit [Ping timeout: 250 seconds]
dhruvasagar has joined #ruby
zastaph has joined #ruby
Eldariof18-ru has joined #ruby
Eldariof-ru has quit [Ping timeout: 265 seconds]
j01 has joined #ruby
uris has joined #ruby
[Neurotic] has quit [Quit: Leaving]
dv310p3r has joined #ruby
Eldariof57-ru has joined #ruby
tayy has quit [Remote host closed the connection]
tzvi has joined #ruby
meskyanichi has quit [Ping timeout: 244 seconds]
Eldariof18-ru has quit [Ping timeout: 252 seconds]
mohits has quit [Read error: No route to host]
bluOxigen has quit [Read error: Connection reset by peer]
<_bart>
peterhellberg: another question, how do I strip \r\n\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t at the beginning and edges of a string?
<gogiel>
.strip?
<_bart>
I want to remove all spaces, \r and \n and \t
<_bart>
.strip is also for \r\n\t? I thought spaces only
geekbri has joined #ruby
<gogiel>
strip is for whitespace
bluOxigen has quit [Ping timeout: 248 seconds]
<gogiel>
white characters, sry
<cantbecool>
_bart try using a gsub or regex
<_bart>
hmm strip did work somehow!
<_bart>
cool
mneorr has joined #ruby
<apeiros_>
somehow…
udante has joined #ruby
<gogiel>
magic
<apeiros_>
awesome
<peterhellberg>
_bart: Are you surprised that the method does what it is supposed to do? :)
<apeiros_>
careful, maybe next time it will somehow do something else!
Targen has joined #ruby
<apeiros_>
rand-lang
<apeiros_>
does sometimes what you want
<workmad3>
apeiros_: sounds like java2k
joast has joined #ruby
<apeiros_>
that does sometimes what you want? o0
<peterhellberg>
Łukasiewicz logic!
<joma>
After ruby, I don't feel java as programming language. I think it is supposed to write poems
TPFC-SYSTEM has quit [Quit: TPFC-SYSTEM]
niklasb has joined #ruby
<apeiros_>
shakespeare is for that…
TPFC-SYSTEM has joined #ruby
wangr has joined #ruby
<JonnieCache>
java is the opposite of poetry
<apeiros_>
(and that language is awesome and does indeed work just somehow)
nanderoo has joined #ruby
<joma>
why? there is no even normal '==', you should write equals. I wont be surprised if on future versions of java instead of {} will be used begin, end
<Spooner>
_bart: It isn't good enough! we could refactor it down to a 3-character regexp that matched all things in all situations...given enough time.
<peterhellberg>
tl;dr: 0 byte program, sold for £5 per copy
<z1y>
Hello. I try to launch a ssh tunnel in ruby: exec("ssh","remote -fN"). Unfortunately, my ruby script doesn't go in to background as expected. (The option "-fN" of ssh will bring ssh to background.). Please help.
<apeiros_>
z1y: exec replaces the current process
<apeiros_>
you may want to take a look at net/ssh. it's quite good.
<z1y>
apeiros_: thank you. I will take a look
<peterhellberg>
z1y: Yes, I’d also go for net/ssh it’s pretty nice
raluxgaza has quit [Remote host closed the connection]
liluo has joined #ruby
* apeiros_
still wants to replace his capistrano setup with a relatively simple ruby+net/ssh tool
<apeiros_>
rather: ruby+net/ssh+bash
bier has quit [Read error: Operation timed out]
RORgasm has quit [Ping timeout: 246 seconds]
jayne has quit [Read error: Connection timed out]
<peterhellberg>
apeiros_: I’m using Rake + rsync over ssh for one of my projects, it is working quite well :)
jayne has joined #ruby
<apeiros_>
peterhellberg: the simplest setup I have uses git + post-receive hook
<apeiros_>
+ a single user with a single sudo-right (restart the webserver)
<peterhellberg>
apeiros_: Yeah, I’ve done that too… but I don’t like to separate deployment from the application
<peterhellberg>
From the application code that is
<apeiros_>
the post-receive hook invokes a script in the app ;-)
<apeiros_>
it's one or two lines. don't remember.
<apeiros_>
and I think git-push in that setup is mostly comparable to an rsync
robbyoconnor has joined #ruby
<peterhellberg>
Pretty much, except for being able to deploy to any server (even ones without access to the Git repo)
jsime has joined #ruby
<apeiros_>
the server doesn't have access to the git repo. it only contains a clone of it. I push to the server.
<apeiros_>
it's not pull
<apeiros_>
and rsync & git-push both go (or can go) over ssh
hmans has joined #ruby
<peterhellberg>
apeiros_: Yeah, that’s true
<peterhellberg>
We generally use capistrano + capistrano-ext for most of our deployments (both Ruby and Java)
tayy has quit [Remote host closed the connection]
<peterhellberg>
capistrano-ext is used for multiple deploy targets
caveat- has quit [Remote host closed the connection]
bier has joined #ruby
<gogiel>
peterhellberg: looks promising
jumski has joined #ruby
<jumski>
hi guys
yoklov has joined #ruby
jxf has quit [Ping timeout: 248 seconds]
<jumski>
do you have any idea why a fresh rails app consumes ~360mb of memory?
<jumski>
im using 1.9.3-p194, rails 3.2.6
g0bl1n has joined #ruby
bowlowni has joined #ruby
<hmans>
Rails doesn't scale
<jumski>
thought it could be somehow related to rvm, so i imploded it, removed all the gems and installed everything from scratch
<jumski>
without success
<jumski>
im talkin about development environment
sulaiman has joined #ruby
<jumski>
yeah, but my is the only pc in the office that shows so high mem usage
<sulaiman>
Greetings
<apeiros_>
the dev env reloads itself upon every request. that may or may not be the cause.
<peterhellberg>
jumski: You might have better luck in a RoR specific channel
<jumski>
with same app
<apeiros_>
run it in production setting and see if you experience the same resource load
<JonnieCache>
jumski: rails can take a lot
<apeiros_>
jumski: also #rubyonrails
z1y has left #ruby ["ISON zipp0"]
<JonnieCache>
360mb is too much
yoklov has quit [Client Quit]
<jumski>
pererhellberg your right, sorry for bothering you here :)
<apeiros_>
depends
<JonnieCache>
my dev server is running a bloody massive eccommerce app and its at least 100mb less than that
<jumski>
yeah but it is FRESH rails app
<peterhellberg>
jumski: No problem :)
<apeiros_>
while our really big app is considerably less than 360mb, I have a tiny app that consumes 600mb
<apeiros_>
but that's because it keeps an index in memory…
<jumski>
made by "rails new"
<apeiros_>
that sounds unlikely
<apeiros_>
there are memory profilers for ruby, though
<jumski>
yeah
<jumski>
tried gdb.rb
<jumski>
but without luck
<jumski>
got "Cannot access memory at address 0x29"
saaim has joined #ruby
<jumski>
when run "ruby objects"
hunglin has joined #ruby
hunglin has quit [Client Quit]
schwap has quit [Read error: Operation timed out]
hunglin has joined #ruby
awarner has joined #ruby
bowlowni has quit [Ping timeout: 240 seconds]
<JonnieCache>
jumski: what OS are you on? and where are you getting that 360mb figure from?
<JonnieCache>
memory management is a complex issue
<jumski>
ubuntu 12.04, to be more specific it is lubuntu (lxde variation)
<jumski>
ive got it from resource column in htop
<saaim>
hiiiii???????????
<mdszy>
saaim: Calm down.
<mdszy>
Goodness
<hmans>
jumski, how many instances of the app are you running? Just one?
hunglin has left #ruby [#ruby]
<jumski>
just one
<jumski>
it is dev env
<JonnieCache>
i cant remember which memory figure is the important one
<hmans>
A naked Rails app should probably eat less than 50 MB per instance, or at least something roughly in that dimension.
<jumski>
JonnieCache it is the right one
<JonnieCache>
the private dirty set or something? all the memory management terms sound porn related
<hmans>
That said, Rails is a pretty hefty beast.
<JonnieCache>
increasingly so
<jumski>
JonnieCache: lol
<saaim>
what r u spech panjabi
sailias has joined #ruby
<jumski>
but im pretty sure this figure is the right one, when i try with some other "not fresh app" it goes to 700mb, and my pc freezes when got spork, rails server, rake and console up and running (got 4gb of ram)
ephemerian has joined #ruby
Hanmac has quit [Ping timeout: 244 seconds]
<JonnieCache>
shit man thats not right :)
<JonnieCache>
i can do all that on my beatdown laptop at home just fine
<saaim>
euby
<jumski>
any ideas where to look for ore how to get that gdb.rb thing running ?
<saaim>
ruby
tonini has quit [Remote host closed the connection]
<jumski>
JonnieCache: yeah me too, never had a problem like this before
ackz has joined #ruby
<jumski>
i feel like screwing up this ubuntu install and making a new one, feel really hopeless :p
<shevy>
\o/
<JonnieCache>
try it with an earlier version of rails perhaps?
<jumski>
so you guys are my last resort :P
<JonnieCache>
3.1.6 rather than 3.2.6
<jumski>
it is a nice idea
verto|off is now known as verto
bbttxu has joined #ruby
vjacob has joined #ruby
tatsuya_o has quit [Remote host closed the connection]
<JonnieCache>
also try using the thin server rather than the default webrick if youre not already
<JonnieCache>
webrick sucks, but tbh it shouldnt have that effect
<saaim>
kon sa idea
<jumski>
that is not webserver related
panpainter has quit [Quit: leaving]
tayy has quit [Remote host closed the connection]
<jumski>
console or any other rails-enviroment-dependent thing is going to eat 360mnb
<jumski>
mb*
<JonnieCache>
use some profiling tool that logs object allocation. most likely something somewhere is creating a bazillion objects that it doesnt need
saaim has left #ruby [#ruby]
<JonnieCache>
most ruby, especially rails perf issues are due to too many objects
<davidroy>
hey folks, if i have a object that has many sub objects that i wish to output as a table. Am i best to use many each loops or a recursive function to build the table
carlyle has joined #ruby
KevinSjoberg has joined #ruby
oooPaul has joined #ruby
bbttxu has joined #ruby
<peterhellberg>
i0n: I’d probably do something like Hash[Dir.glob('*').map { |f| [f,File.atime(f)] }]
<JonnieCache>
well if its a table you should only need 2 loops
<JonnieCache>
davidroy: one loop inside the other
<fowl>
davidboy, use Enumerable#map
Shrink has joined #ruby
<davidroy>
fowl and JonnieCache cheers
<fowl>
or do some janky joining '<table><tr><td>'+(items.join('</td><td>'))+'</td></tr></table>'
<JonnieCache>
dont do that
<fowl>
do what you want*
<fowl>
and never think about the consequences
<JonnieCache>
yeah do what you want but try to want the right thing
verto is now known as verto|off
Targen has joined #ruby
<davidroy>
well basically i have a object with a sub object, and another sub object
<davidroy>
so i am most interested in the best way to output this
internet_user has joined #ruby
<fowl>
well obviously you have objects, what isnt an object in ruby
<fowl>
._.
<davidroy>
fowl: hmm true
<blazes816>
davidroy: is there a set number of levels? or might you have 10 levels deep of object going on?
niklasb has joined #ruby
<davidroy>
blazes816: set level of 3
<blazes816>
davidroy: as in 1 root object, which has some objects, each of those have some?
<davidroy>
each of these are to be displayed in as one row of a table
<davidroy>
blazes816: 1 root object, that has a children, that has children
<blazes816>
david: cool. yeah, use map. as for the format, idk. maybe use highlighting with css classes to differentiate all the different stuff you have
<i0n>
peterhellberg: i see very nice
wallerdev has joined #ruby
Speed has joined #ruby
Speed has quit [Changing host]
Speed has joined #ruby
shevy has joined #ruby
<shevy>
hi
<shevy>
i0n: Dir.entries is not a lot of fun IMO
<davidroy>
blazes816: cheers, is there a good example of using map ?
<shevy>
i0n: I tend to prefer Dir.glob() or something like that
<i0n>
shevy: yea thats what peterhellberg has been showing me
wallerdev has quit [Client Quit]
<blazes816>
davidroy: are you using a templating engine of somekind?
<shevy>
it is much more flexible than Dir.entries, I use this a lot. usually like: var = '*.rb'; Dir.glob(var)
<shevy>
or if you need the array ... array = Dir.glob(var)
<shevy>
etc..
<shevy>
:)
<davidroy>
blazes816: nope pure html.erb via rails
<blazes816>
davidroy: so erb is you templating engine ;)
<davidroy>
blazes816: ^_^() i guess it is
<blazes816>
davidroy: In that case, probably use collection partials
<davidroy>
blazes816: ah cheers, however partials have proved really inefficient in this case.
<peterhellberg>
I know it’s decided against, but I would really like implicit block parameters in Ruby 2.0.
<blazes816>
davidroy: could be. you may want to try using something a bit faster. let me work up a gist of something.
JustinCampbell has joined #ruby
seatea has quit [Ping timeout: 244 seconds]
<davidroy>
blazes816: that would be great
<fowl>
peterhellberg, implicit how
<shevy>
peterhellberg: how would that look like?
<shevy>
I mean in syntax
niklasb has quit [Ping timeout: 246 seconds]
<peterhellberg>
fowl: Something like [1,2,3].each { puts it }
<fowl>
peterhellberg, ah
<peterhellberg>
fowl: Similar to how it works in Groovy
<shevy>
"it" would become a keyword, only within blocks?
bigoldrock has quit [Quit: Leaving.]
<fowl>
peterhellberg, what about blocks that send multiple vars
<shevy>
it1 it2 it3 ... :)))
<shevy>
or
<shevy>
it,that,this,that_other,that_one
<peterhellberg>
fowl: 1.9 already support the splat operator in block params
<peterhellberg>
fowl: It could just capture the first as it, and then the rest in a separate array
<shevy>
and this array can then be accessed how?
<fowl>
^
<fowl>
it2 ?
<shevy>
hehe
<shevy>
well "it" alone is not so bad
<peterhellberg>
shevy: I’m just speculating here :)
<shevy>
peterhellberg: yeah but you need a complete proposal, even if it is just speculation that core team won't accept
<shevy>
I mean, it is new to me entirely
<shevy>
I never read it before :)
<peterhellberg>
And it wouldn’t be too hard to just specify array.map { |my,list,of,variables| … } :)
<shevy>
well that is explicit though, you give them names in ||
guns has joined #ruby
<peterhellberg>
shevy: It has been proposed before and shut down by core… but that doesn’t change the fact that I _would_ like to see it in Ruby 2.0 :)
pu22l3r has joined #ruby
guns is now known as Guest19953
<fowl>
you're entitled to your opinion no matter how wrong it is
<shevy>
do you have the reason they gave for this?
<rking>
shevy: You're off probation for saying, "shevy │ it,that,this,that_other,that_one"
Guest19953 has quit [Client Quit]
<shevy>
haha
billiam has joined #ruby
<shevy>
but I wanted to know the default name of the array :(
<shevy>
puts it seems is ok
<peterhellberg>
fowl: Yeah :)
<peterhellberg>
shevy: No, It seems like a number of people have been trying to get this implemented. With varying success I might add.
<peterhellberg>
Someone wanted @ and $ to be used for the "anonymous" variable, a little bit like how it works in Perl
Araxia has quit [Quit: Araxia]
rbanffy has joined #ruby
devdazed has quit [Ping timeout: 246 seconds]
PaciFisT has joined #ruby
<fowl>
i wouldnt mind that
<fowl>
as much as a new word
wmoxam_ has joined #ruby
<peterhellberg>
I quite like the implicit scalar variable in Perl
<peterhellberg>
Since you never have to actually type $_
bradhe has quit [Remote host closed the connection]
mdpatrick has joined #ruby
<peterhellberg>
But this is somewhat solved by Symbol#to_proc
liluo has quit [Remote host closed the connection]
mxweas has left #ruby ["Leaving..."]
cloud|windoze has quit [Quit: Leaving.]
eywu has quit [Quit: Leaving.]
uris has quit [Read error: Connection reset by peer]
Spooner has quit [Ping timeout: 246 seconds]
nonotza has joined #ruby
chomp has joined #ruby
nyuszika7h is now known as pingmenextround
pingmenextround is now known as nyuszika7h
ringotwo has quit [Ping timeout: 240 seconds]
mobilegamelabs has joined #ruby
eywu has joined #ruby
wmoxam has quit [Disconnected by services]
maletor has joined #ruby
wmoxam_ is now known as wmoxam
brasten has quit [Quit: brasten]
wmoxam has quit [Changing host]
wmoxam has joined #ruby
flip_digits has joined #ruby
zrail has left #ruby [#ruby]
savage- has joined #ruby
savage- has quit [Remote host closed the connection]
Ontolog has quit [Quit: Ontolog]
verto|off is now known as verto
hmans has quit [Quit: Leaving...]
savage- has joined #ruby
cjlicata has quit [Remote host closed the connection]
cirwin has joined #ruby
fuleo has quit [Ping timeout: 260 seconds]
kvirani has quit [Remote host closed the connection]
Lachryma has quit [Ping timeout: 248 seconds]
EMarklar has joined #ruby
iamjarvo has quit [Quit: Computer has gone to sleep.]
robozahn has quit [Quit: leaving]
<EMarklar>
Hi I'm running an app with Bundle exec ruby app.rb, but from within that I need to call another app which is also started with 'Bundler exec ruby other_app.rb'. The issue is that second bundler setup doesn't get loaded as I'm already locked into the original binders env. Is there a way to do this?
maletor has quit [Ping timeout: 244 seconds]
ananthakumaran has joined #ruby
ryanf has joined #ruby
<mdszy>
Is it just me, or is recursion close to impossible in Ruby?
bluenemo_ has quit [Remote host closed the connection]
mpereira has joined #ruby
maletor has joined #ruby
bowlowni has quit [Read error: Connection reset by peer]
<workmad3>
mdszy: err, no
<workmad3>
mdszy: it's just you
bowlowni has joined #ruby
<workmad3>
mdszy: or at least, on the surface, it's just you... would you care to explain your viewpoint more? :)
mucker has joined #ruby
<mdszy>
workmad3: One moment, turns out my code is broken that I thought would work XD
<workmad3>
mdszy: :D
lorandi has joined #ruby
<mdszy>
okay, got it XD
<Speed>
interesting, according to my lazyman's benchmark, if you have a string "# something", it's slightly faster to do include? "#" than str[0] == "#". Is that true or is my bench wrong?
<apeiros_>
also, take a look at Singleton (ri Singleton, it's part of rubys stdlib)
voodoofish430 has joined #ruby
cj3kim has quit [Client Quit]
<sernin>
Wondering why this gives an error. Should I be creating these arrays elsewhere? http://pastie.org/4267095
tatsuya_o has joined #ruby
yoklov has joined #ruby
gabebug has joined #ruby
Speed has quit [Quit: When two people dream the same dream, it ceases to be an illusion.]
chrxn_ is now known as chrxn[a]
<gabebug>
What's the best way to file a bug report for the std lib csv library? I'm having an issue where CSV.foreach(path, { :encoding => "iso-8859-1:utf-8" }) errors with "invalid byte sequence in UTF-8" in csv.rb:2027:in `init_separators, but setting the :encoding => "iso-8859-1", and then calling .encode('utf-8' on each cell works fine - strikes me as a bug
mahmoudimus has quit [Quit: Computer has gone to sleep.]
tatsuya_o has quit [Ping timeout: 265 seconds]
philips_ has quit [Excess Flood]
Aaton_off is now known as Aaton
hashar has joined #ruby
<fowl>
csv.rb is a terrible mess
<fowl>
i wanted to shoot myself after trying to debug it
bluenemo has quit [Remote host closed the connection]
Lachryma has quit [Read error: Connection reset by peer]
apok has joined #ruby
redgetan has quit [Quit: This computer has gone to sleep]
mohits has joined #ruby
nej has joined #ruby
oooPaul has quit [Quit: Ciao for now!]
ryanf has quit [Quit: leaving]
sdwrage has quit [Quit: geekli.st/programmer]
andoriyu has joined #ruby
etehtsea has joined #ruby
vitoravelino`afk is now known as vitoravelino
jstew has joined #ruby
bricker88 has joined #ruby
andoriyu_ has quit [Ping timeout: 240 seconds]
<bricker88>
is it possible to make an HTTP request to a local URI, such as http://something.dev or http://localhost:3000 ? I am getting a SocketError when trying to send a request to a local pow URI
sdwrage has joined #ruby
bbttxu has joined #ruby
Eldariof-ru has joined #ruby
mpereira has joined #ruby
d3vic3 has quit [Ping timeout: 248 seconds]
lorandi has quit [Quit: Leaving]
<shevy>
sernin: what are labels and values
lorandi has joined #ruby
d3vic3 has joined #ruby
<Mon_Ouie>
bricker88: What does the error message say?
Gurpartap has quit [Quit: Page closed]
<bricker88>
Mon_Ouie: "getaddrinfo: nodename nor servname provided, or not known"
odigity has joined #ruby
reuf has joined #ruby
<bricker88>
I assume that means it doesn't know the ".dev" domain
<odigity>
I have a method B which makes a few objects and returns them. In method A, I want to create an array, and call B a bunch of times to append those objects to my array. What's the best way? I can have B return an array, but will the << operator flatten it back out into multiple objects before appending?
NorrinRadd has joined #ruby
fermion has quit [Quit: P]
<odigity>
I could use array addition (my_array += methodB()), but that seems inefficient, since it will be constantly creating new copies
<Mon_Ouie>
odigity: Use Array#concat
<odigity>
is there a flattening operator?
<shevy>
yeah
<blazes816>
odigity: Array#flatten ?
<shevy>
[[1,2,3]].flatten # => [1, 2, 3]
greasegum has joined #ruby
<odigity>
so, in method A, I need "myarray.concat methodB()", and in methodB, I can just return an array of objects "return mysubarray"
<Mon_Ouie>
Yes
<odigity>
is that the most idiomatic way, or should be I using flattening somehow?
<Mon_Ouie>
I wouldn't use flatten in that case. It just sounds more natural to directly append the elements to the right array
GeekOnCoffee_ has joined #ruby
GeekOnCoffee_ is now known as GeekOnCoffee
<odigity>
ok, thanks
kvirani has joined #ruby
jrajav has joined #ruby
<fowl>
flatten operator would be cool
<fowl>
it could be ___
<fowl>
:>
mohits has quit [Read error: Connection reset by peer]
<blazes816>
apeiros_: explicit is better than implicit
<shevy>
I hate explicit self in python
<fowl>
shevy, only because its not resolving Array and the new method
<blazes816>
shevy: and how!
<blazes816>
I forgive perl
<shevy>
:)
bbttxu has quit [Quit: bbttxu]
<shevy>
yeah fowl no idea really... I think I read it once in the old pickaxe. my brain remembers only 5% of what I read
<fowl>
yea
<fowl>
i tested that once..for some reason
<sernin>
I recall I ran into some subtle differences between {} and Hash.new
<fowl>
only diff is Hash.new lets you specify a default value, which you could do after you create the hash if you wanted
axl_ has quit [Read error: Connection reset by peer]
<apeiros_>
blazes816: [] is explicit
axl_ has joined #ruby
emmanuelux has quit [Quit: emmanuelux]
TPFC-SYSTEM has quit [Quit: TPFC-SYSTEM]
<blazes816>
apeiros_: I was just joking
cirwin has quit [Ping timeout: 252 seconds]
<shevy>
sernin: I think Hash.new gives you a {} additionally
<shevy>
with {}, I dont think you can give a block to it
emmanuelux has joined #ruby
<shevy>
{}{}
<shevy>
what a weird syntax
<shevy>
hmm Hash.new() {}
nilg has joined #ruby
<fowl>
x = Hash.new do |y, key| y[key] = key ** 2 end <- might as well use Hash#default_proc tho
<fowl>
why would you send an empty block
<fowl>
crazy austrian
kenichi has quit [Remote host closed the connection]
<shevy>
I dunno
<shevy>
I just wondered about the syntax
skryking has quit [Quit: Konversation terminated!]
<shevy>
I also have to admit, I have not seen default_proc before
<shevy>
I am still a noob :(
d3vic3 has quit [Ping timeout: 246 seconds]
jayne has joined #ruby
king313 has quit [Quit: .]
mohits has quit [Read error: Connection reset by peer]
zastaph has quit []
luckyruby has joined #ruby
<fowl>
o Hash.new(&block) sets block to default_proc that makes sense
d3vic3 has joined #ruby
oxyxian has joined #ruby
eph3meral has joined #ruby
<eph3meral>
has anyone had success getting spec to properly log in using omniauth with rspec under a modular sinatra/rack application? I googled and tried stuff for like 4 hours yesterday, nothing seemed to work - specificallly I feel like if I could set a sinatra session variable from within the test, that everything would be all good - I've got omniauth configured to use test mode in the test environment, so I think all I need to do is make sure
<eph3meral>
session['user_id'] exists and is sane inside the controller action, when said action is called from a test
<eph3meral>
the only way I've gotten my app to work is if I add a check for the test environment, and then simply bypass my authentication code (sorry for xposts btw, if anyone cares, not sure where this question belongs since so many systems/subsystems are involved)
<fowl>
your problems scares, i wish you the best of luck
<eph3meral>
shevy, uh... rspec, rack, omniauth, capybara, sinatra <- all of the above are involved in this issue
trivol has joined #ruby
<eph3meral>
well, actually I suppose maybe not so much capybara - but it's definitely a "multi thing" issue, I'm still not 100% sure which parts are required, and there's zero comprehensive docs on this
<NorrinRadd>
trying to figure out what this does: (@events[event] ||= []) << [Regexp.new(match), block]
<NorrinRadd>
currently noob status
<NorrinRadd>
can't find a ||= operator in the hash class.
<skyjumper>
var ||= expressoin
mneorr has quit [Quit: Leaving.]
<skyjumper>
is the same as
<skyjumper>
var = var || expression
<NorrinRadd>
gotcha
<Mon_Ouie>
Actually it's not really that
<Mon_Ouie>
It's expression || (var = expression)
DrForr has joined #ruby
<Mon_Ouie>
i.e. when var is a method call and doesn't return nil or false, #var= won't be called at all
hemanth has quit [Read error: Connection reset by peer]
<skyjumper>
aha
<Mon_Ouie>
Erm, I meant var || (var = expression)
punkrawkR has joined #ruby
pk1001100011 has quit [Remote host closed the connection]
elliottcable is now known as erparse
headius_ has joined #ruby
hemanth has joined #ruby
grekkos has joined #ruby
<NorrinRadd>
same as var? var : var=expression
<NorrinRadd>
this ^ ?
grekkos is now known as Guest1056
<NorrinRadd>
if (!var) var = expression
ryannielson has left #ruby [#ruby]
<NorrinRadd>
because using || like in your examples, it might be contruued that var ends up being 0 or 1
pk1001100011 has joined #ruby
<Mon_Ouie>
Why would it end up being 0 or 1?
user__ has joined #ruby
ozy_work has joined #ruby
<NorrinRadd>
because || returns 0 or 1
Targen has quit [Ping timeout: 240 seconds]
<Mon_Ouie>
You mean in C?
Axsuul has joined #ruby
<NorrinRadd>
yeah
<Mon_Ouie>
But we're talking about Ruby, not C
<NorrinRadd>
ah. so || is differently too....
<Mon_Ouie>
And your former example isn't the same either, because var gets evaluated twice
<ozy_work>
I'm trying to write a custom function for puppet, and I keep getting the error "Function 'lookup_instance_password' does not return a value" -- no one in the puppet channel seems to have any suggestions. Can anyone here help me?
<Mon_Ouie>
(not that a getter *should* have side effects)
headius has quit [Ping timeout: 255 seconds]
headius_ is now known as headius
sanitypassing has left #ruby ["WeeChat 0.3.8"]
erparse is now known as alexgordon
<ozy_work>
I am calling 'return 'foo'' at the end of my short code, so it should be returning something, right?
<ozy_work>
i've also tried 'puts' instead of return
<ozy_work>
no difference
otters is now known as eboy
blacktulip has quit [Remote host closed the connection]
eboy is now known as otters
<Mon_Ouie>
return won't work in that context
<Mon_Ouie>
You'd need break to return early from the block, but you can just make sure the last expression evaluates to what you want here
g0bl1n has quit [Ping timeout: 240 seconds]
<Mon_Ouie>
And if nothing gets printed, that's most likely because your block is never run
s0ber has quit [Read error: Connection reset by peer]
<ozy_work>
it's throwing an error that it is not returning anything, so it looks like it is trying to run it
<ozy_work>
so I should be abel to use 'puts'?
<ozy_work>
or even a hash reference?
s0ber has joined #ruby
headius has quit [Read error: Connection reset by peer]
hemanth has quit [Read error: Connection reset by peer]
<Mon_Ouie>
That may be related to the way you're using that library, check for examples
<Mon_Ouie>
and the docs
hemanth has joined #ruby
ackz has quit [Read error: Connection reset by peer]
<ozy_work>
the docs appear to be pretty.... spotty, unfortunately
tayy has joined #ruby
robert45- has joined #ruby
<robert45->
hi guys Im geting this error "/usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require': no such file to load -- new_relic/recipes (LoadError)"
<robert45->
does anyone know how to fix this?
<Mon_Ouie>
Change your load path or install whatever you need to get that new_relic/recipes file
Maher4Ever has joined #ruby
<robert45->
Mon_Ouie thanks, how do I need which gems does provides new_relic/recipes?
<robert45->
I know*
<Mon_Ouie>
What are you trying to run?
webusnix has quit [Quit: Ухожу я от вас (xchat 2.4.5 или старше)]
<Mon_Ouie>
Usually, gem names match require names, so it would be new_relic
Criztian has joined #ruby
trivol has joined #ruby
<robert45->
Mon_Ouie newscloud
<robert45->
alright, let me check
<Maher4Ever>
Hey, Is there a way in the ruby C API to stop the GC from freeing a particuler ruby object?
<Mon_Ouie>
And newscloud doesn't have anything to handle dependencies? A gemspec? A readme? Bundler?
<Maher4Ever>
I need to store a pointer to a block in my application. When it's run for a long time, the GC frees the block and I end up with a dead pointer!
<Mon_Ouie>
Maher4Ever: Make sure to set ivars so that a reference to it is still visible when appropriate. Alternatively, use rb_gc_(un)register_address
<Mon_Ouie>
If I wanted to keep a value object like that, I'd probably use an ivar on my module
sdwrage has joined #ruby
carloslopes has quit [Quit: Leaving.]
<shadoi>
Norrin: it is a method to register an event callback
Zolrath has joined #ruby
<Maher4Ever>
Mon_Ouie: Thans for the response, I'll look into those functions. I can't use ivars because each method call comes with it's own block
<shadoi>
Norrin: the event is the name, match is a pattern for something in the block to use I guess, and the block is the code to call when the event is encountered.
<Norrin>
shadoi, thank you. i'm glad you understand it
QaDeS has joined #ruby
bglusman_ has joined #ruby
<Mon_Ouie>
I think match is another condition for the block to be run
<Maher4Ever>
fowl: LOL, I wish I was that much good-looking :P
<Mon_Ouie>
The block is only run when the event type is some value, and its argument (whatever it is, a string it seems) matches the "match" argument
<shadoi>
Norrin: it's a common pattern for event driven code.
<Norrin>
i'm still trying to decipher it. can't figure out line 3
seatea has quit [Ping timeout: 240 seconds]
<Norrin>
if event is not find out @events, it sets the value of that key to an empty array?
jsime has quit [Read error: Connection reset by peer]
<Mon_Ouie>
Only if it's nil or false (so it's a default value)
<Norrin>
and not guess what happens after that. can't imagine why a left shift is there
bglusman has quit [Ping timeout: 245 seconds]
<Mon_Ouie>
It's not a left shit, it calls Array#<<, which appends a new element
jsime has joined #ruby
<Norrin>
on. i tihnk @events is a hash
c0rn_ has joined #ruby
<Mon_Ouie>
It most likely is
<Norrin>
so it's adding key=regex and value=block ?
ozy_work has quit [Ping timeout: 244 seconds]
<Mon_Ouie>
No, the key is event
<Mon_Ouie>
and the value is an array, to which it adds a new element
<Norrin>
I see!
<Mon_Ouie>
Which itself is another array, containing two elements: the regexp and the block
hemanth has quit [Read error: Connection reset by peer]
<shevy>
hmm I need help with a regex
<shevy>
I have two words: SDL_tty-0.0.1 and acl_2.2.47-1
tayy has quit [Ping timeout: 248 seconds]
<shevy>
for the first word, I need to split at the "-". for the second word, I actually need to split at the "_"
the_jeebster has quit [Quit: Leaving.]
<shevy>
my idea was to split on the first number found hmm
minijupe has quit [Quit: minijupe]
<fowl>
shevy, look for groups of numbers instead
<shadoi>
shevy: you need to normalize the data first. Your work boundaries delimiter is changing.
<fowl>
or trailing numbers
<shevy>
oh, that is a good idea
<shadoi>
s/work/word/
<fowl>
shevy, i remember gobo always had problems with this especially when it was like LibXML2-version
hemanth has joined #ruby
ibash has joined #ruby
<Mon_Ouie>
If there are only two elements, there's no real reason to actually split — you can match using two capture groups, one for the name and another for the version
<shevy>
yeah shadoi ... trying to split up "program name" and "program version". this one is another difficult one WebKit-r116716
tayy has joined #ruby
<shevy>
ok
<fowl>
shevy, their solution was to name packages Libname--version--md5hash
<shadoi>
There are package name normalization scripts in the debian packaging tools, but … yeah, it requires some manual massaging.
<Maher4Ever>
Mon_Ouie: if I call 'rb_gc_register_address' on the block, when should I call 'rb_gc_unregister_address'? Can I assume it would be the same place rb_gc_mark was being called?
<Mon_Ouie>
You call it when you won't use the reference anymore
<Mon_Ouie>
Preferably as soon as you're done
<Maher4Ever>
Got it, thanks
choffste_ has joined #ruby
minijupe has joined #ruby
choffstein has quit [Read error: Connection reset by peer]
andoriyu has quit [Quit: This computer has gone to sleep]
greasegum has quit [Ping timeout: 240 seconds]
snearch has joined #ruby
hemanth has quit [Read error: Connection reset by peer]
geekbri has quit [Remote host closed the connection]
itnomad has joined #ruby
tayy has joined #ruby
Norrin has quit [Quit: Zzz]
alindeman has quit [Ping timeout: 240 seconds]
hynkle has quit []
pushp0p is now known as dawtcawm
andoriyu has joined #ruby
minijupe has quit [Quit: minijupe]
<Maher4Ever>
Mon_Ouie: The functions you pointed out work like a charm, thank you. I struggled with it for quite a while :)
vertroa has quit [Ping timeout: 252 seconds]
nateberkopec has joined #ruby
mdpatrick has quit [Quit: mdpatrick]
<Maher4Ever>
I have another question: Does ruby have some kind of a memory pool exposed for developers of extentions? I know about ALLOC and xfree, but these don't cache memory AFAIK
Cooper_ has joined #ruby
apok has joined #ruby
<Maher4Ever>
Something like nedmalloc ?
<Foxandxss>
excuse me: What's the new form :blah => "Bleh" or blah: "bleh"?
<shevy>
Foxandxss: second
<shevy>
the shorter
<Maher4Ever>
Foxandxss: blah: "blah"
<shevy>
foo: "bla"
<Foxandxss>
thanks
<shevy>
old form was the longer
<shevy>
:)
<shevy>
easy to remember
<Foxandxss>
I used the first one and rails guides uses first one, but I remembered that somewhere said that second was newer, but I got confused, thanks
maahes has quit [Ping timeout: 244 seconds]
lorandi has quit [Quit: Leaving]
<Maher4Ever>
I actually like the old form, I mean look at this 'method(opt: :sym, :opt2: :sym2)' doesn't look right to me :S
<ged>
iset highlight
<ged>
Heh, oops.
headius has joined #ruby
<shevy>
hah
<shevy>
after so many years of IRC!
<shevy>
Maher4Ever: I like the old form too
<shevy>
I am not that opposed to the new one though
<shevy>
what I dont like at all is ->
<johnernaut>
lambdaz
<fowl>
Maher4Ever, in that case the options hash is more like a hash of enums (set symbol values)
techhelp has quit [Quit: Leaving]
<johnernaut>
->(arg)
<fowl>
Maher4Ever, and i would say thats unruby
Rubinista has joined #ruby
jamesaxl has quit [Ping timeout: 240 seconds]
<Maher4Ever>
shevy: yeah, I hate the new ->
kvirani has quit [Remote host closed the connection]
stewart_ has joined #ruby
<Rubinista>
Does anyone know how to make an error during a test-case's self.startup method block the individual test cases? Test-Unit just tries running them anyways and they all fail for a lack of proper fixtures.
hemanth has quit [Read error: Connection reset by peer]
<Maher4Ever>
fowl: I understand what you mean, I like providing options by yielding a config object in a block method {|c| c.opt = :something }
fbernier has quit [Ping timeout: 246 seconds]
DrForr has quit [Ping timeout: 246 seconds]
hemanth has joined #ruby
jakemask has joined #ruby
jstew has quit [Quit: leaving]
<jakemask>
quick question, can you do #{ substitutions in a regex string?
<Maher4Ever>
So does anyone knows anything about a memory pool in ruby? I have an extention that allocates a lot of memory and when it's run very fast, ruby errors on me with "[FATAL] failed to allocate memory"
<GarethAdams>
jakemask: inside a /regex literal?/ yes
<Maher4Ever>
jakemast: yes
nopolitica has joined #ruby
rqutab has joined #ruby
tommyvyo has quit [Ping timeout: 248 seconds]
reuf has joined #ruby
cmaujean has quit [Quit: cmaujean]
bbttxu has quit [Ping timeout: 248 seconds]
alek_b_ has joined #ruby
rowanu has quit [Remote host closed the connection]
jakemask has quit [Quit: Page closed]
nopolitica has quit [Client Quit]
alek_b has quit [Ping timeout: 240 seconds]
nopolitica has joined #ruby
Spooner has joined #ruby
jamesaxl has joined #ruby
syamajala has quit [Read error: Connection reset by peer]
linoj has quit [Ping timeout: 246 seconds]
syamajala has joined #ruby
jwg2s has joined #ruby
robert_ has joined #ruby
sailias has quit [Quit: Leaving.]
twock has quit [Quit: leaving]
wmoxam has quit [Ping timeout: 244 seconds]
robert45- has quit [Quit: • IRcap • 8.6 •]
twock has joined #ruby
jamesaxl has quit [Ping timeout: 246 seconds]
Speed has joined #ruby
Speed has quit [Changing host]
Speed has joined #ruby
jamesaxl has joined #ruby
RORgasm has quit [Remote host closed the connection]
luckyrub_ has joined #ruby
twinturbo has quit [Quit: twinturbo]
Berglund has joined #ruby
tommyvyo has joined #ruby
andrew has joined #ruby
andrew is now known as Guest37843
<Mon_Ouie>
Maher4Ever: That's not the new hash form
<Mon_Ouie>
Oh, unless it was just a typo
<Mon_Ouie>
It's opt2: :sym2
IceDragon has joined #ruby
<jwg2s>
I'd like to convert days 1 out of 365 to month and day, is this possible?
workmad3 has quit [Ping timeout: 244 seconds]
<Maher4Ever>
Mon_Ouie: Yeah, it was a typo there
<jwg2s>
I mean I know its possible, but is there a built in way with Date or Time?
<Mon_Ouie>
Create a Time object for the day you're looking for, and use #mday and #month
luckyruby has quit [Ping timeout: 265 seconds]
luckyrub_ is now known as luckyruby
cantonic has quit [Quit: cantonic]
<Mon_Ouie>
(You need to know the year to do this, or at least whether or not it's a leap year)
<jwg2s>
i'm trying to convert a really old format from CCYYDDD to mysql
Ontolog_ has joined #ruby
<jwg2s>
mysql friendly *
minijupe has joined #ruby
<Maher4Ever>
Mon_Ouie: You are the guy behind coolline right? Great job man :). We just added support for it in Guard :)
<Mon_Ouie>
Maher4Ever: Yep ;)
fridim_ has quit [Ping timeout: 246 seconds]
banseljaj is now known as imami|afk
oscardelben has quit [Read error: Connection reset by peer]
wvms has joined #ruby
hemanth has quit [Read error: Connection reset by peer]
hemanth has quit [Read error: Connection reset by peer]
nicoulaj has quit [Remote host closed the connection]
chrxn[a] has quit [Ping timeout: 255 seconds]
hemanth has joined #ruby
tayy has quit [Ping timeout: 265 seconds]
axl_ has quit [Quit: axl_]
tommyvyo has joined #ruby
babinho has quit [Remote host closed the connection]
vertroa has joined #ruby
chrxn[a] has joined #ruby
babinho has joined #ruby
internet_user has quit [Remote host closed the connection]
amacgregor_osx has joined #ruby
odigity has quit [Quit: Leaving]
twock has quit [Quit: Lost terminal]
hemanth has quit [Read error: Connection reset by peer]
hemanth has joined #ruby
headius has quit [Quit: headius]
peterhellberg has joined #ruby
jrajav has quit [Quit: The best darkness is strange and surprising]
greasegum has joined #ruby
hemanth has quit [Read error: Connection reset by peer]
`brendan has quit [Quit: - nbs-irc 2.39 - www.nbs-irc.net -]
hemanth has joined #ruby
c0rn_ has quit [Quit: Computer has gone to sleep.]
SQLStud has quit [Quit: Leaving]
axl_ has joined #ruby
trivol has joined #ruby
AlbireoX_ has quit [Read error: Connection reset by peer]
syamajala has quit [Read error: Connection reset by peer]
bbttxu has joined #ruby
zemanel has joined #ruby
alanp has quit [Read error: Operation timed out]
rqutab has quit [Quit: rqutab]
balki_ has joined #ruby
alanp has joined #ruby
GoGoGarrett has quit [Remote host closed the connection]
balki has quit [Ping timeout: 255 seconds]
reuf has quit [Quit: Leaving]
panpaint1r has joined #ruby
panpainter has quit [Ping timeout: 248 seconds]
williamcotton has joined #ruby
rqutab has joined #ruby
LalTopi has quit [Ping timeout: 250 seconds]
minijupe has quit [Quit: minijupe]
williamcotton_ has quit [Ping timeout: 246 seconds]
PaciFisT has quit [Quit: Leaving.]
LalTopi has joined #ruby
[Neurotic] has joined #ruby
stat1x has quit [Remote host closed the connection]
stat1x has joined #ruby
<shevy>
Mon_Ouie is the secret ruby master
<shevy>
he even has some GUI thingy... I keep on forgetting the name :\
<shevy>
I am going to call it Mon-GUI
stkowski has quit [Quit: stkowski]
sebicas has joined #ruby
wallerdev has quit [Quit: wallerdev]
jsime has quit [Quit: Leaving]
yoklov has quit [Quit: computer sleeping]
snearch has quit [Quit: Verlassend]
jwg2s has quit [Quit: jwg2s]
<Mon_Ouie>
The 2D graphics library? Ray
oxyxian has quit [Ping timeout: 244 seconds]
<shevy>
oh
<shevy>
yeah
<Rubinista>
Does anyone use self.startup/shutdown methods with TestUnit? I'm trying to figure out how to make a failure in startup prevent the methods from running (and all dying, because their fixtures aren't initialized.)
Cooper_ has quit [Ping timeout: 248 seconds]
joshman_ has quit [Quit: Computer has gone to sleep.]
<robert_>
shevy :D
wvms has quit [Quit: wvms]
billiam has quit [Quit: Leaving]
wvms has joined #ruby
mengu has joined #ruby
<shevy>
heya robert_
<shevy>
you doing anything fun in ruby lately?
ryan0x2 has quit [Remote host closed the connection]
vitoravelino is now known as vitoravelino`afk
rbanffy has quit [Ping timeout: 246 seconds]
<robert_>
yeah
<robert_>
working on a padrino project. :D
<robert_>
that responds to domains lol
awarner has quit [Remote host closed the connection]
wvms has quit [Remote host closed the connection]
obryan has quit [Quit: Konversation terminated!]
<shevy>
hmm
wvms has joined #ruby
<shevy>
is it fun?
rasbonics has joined #ruby
bradhe has quit [Remote host closed the connection]
<peterhellberg>
Rubinista: I’d probably exit straight from the spec_helper.rb (or similar)
Cooper_ has quit [Client Quit]
AlbireoX_ has joined #ruby
mucker has quit [Ping timeout: 240 seconds]
<peterhellberg>
Rubinista: MiniTest::Unit::TestCase#setup and the equivalent before in MiniTest::Spec is run for each test, and you want to run the check once at test suite startup?
<hakunin>
i'm trying to figure out why does it block
<davidw>
it simply "does not work" in that something is not picking up on the fact that I have rvm
<bperry>
hakunin: because that is how threads work, if you don't want it to block make a new thread or proc
<hakunin>
bperry: i thought that #system is supposed to fire a command and return a boolean based on its exit status. my command gets backgrounded, so it "exists" immediately, no?
<bperry>
nope
GoGoGarrett has joined #ruby
<bperry>
because it hasn't returned anything
mmokrysz has joined #ruby
<hakunin>
ah
mmokrysz has left #ruby [#ruby]
<hakunin>
bperry: so in my case i need more of a "fire and forget", which i'd like to work in 1.8.7,1.9.3
IcyDragon has joined #ruby
Athetiusdroid has joined #ruby
ixti has quit [Quit: So Long, and Thanks for All the Fish!]
hemanth has quit [Read error: Connection reset by peer]
nemesit has quit [Quit: Leaving...]
<Rubinista>
peterhellberg: self.startup/shutdown are similar to before/after(:all) in rspec. I want to not try (silently fail) all tests in that TestSuite when they fail.
<Athetiusdroid>
Hello all, I was wondering about creating a "connect" MySQL file like with PHP in ruby. If I just connect with con = Mysql.new and require_relative on the other file to call con.query it tells me that con is undefined.
<hakunin>
bperry: do you know if system behavior changed from 1.8.7 to 1.9.3?
hemanth has joined #ruby
<hakunin>
bperry: it used to work
mneorr has joined #ruby
<bperry>
no idea
<Rubinista>
peterhellberg: I can do this by having the setup (equivalent to before(:each)) check if the resources are initialized: "raise SetupError unless @resource", but I'd need to remember that for each suite...
<peterhellberg>
Rubinista: There is something similar to after(:all) in minitest, but it seems like the general consensus is to do before checks in the test helper
IceDragon has quit [Ping timeout: 248 seconds]
<peterhellberg>
Oh, are you using 1.8 or 1.9 btw?
bowlowni has quit [Remote host closed the connection]
bowlowni has joined #ruby
<Rubinista>
peterhellberg: I guess the basic question is, "Is suite.startup raising an error but then continuing to run the individual tests, a bug?" Should I report this with a patch, or is it desired behavior?
<Rubinista>
peterhellberg: 1.9, with test-unit gem 2.5.0
<peterhellberg>
Rubinista: Ah, I thought you meant Minitest with the Test::Unit wrapper instead of the actual Test::Unit
<peterhellberg>
Rubinista: I’ve never used Test::Unit with 1.9 so I’m not the best person to ask :)
<Rubinista>
peterhellberg: No, but I am curious what it'd do - it'd help to know if this is right or not.
<Rubinista>
peterhellberg: Thanks anyways!
<peterhellberg>
Rubinista: np
htroyack has joined #ruby
hemanth has quit [Read error: Connection reset by peer]
bowlowni has quit [Ping timeout: 252 seconds]
<peterhellberg>
Rubinista: But I imagine that you could do something similar as you would in Minitest. That is, raising an exception/exiting from the test suite run in the test helper (before the entire suite is run)
<peterhellberg>
Rubinista: startup seems to do the same job as before(:each) in RSpec and before in Minitest
hemanth has joined #ruby
yoklov has joined #ruby
pk1001100011 has quit [Ping timeout: 255 seconds]
pk1001100011 has joined #ruby
<Rubinista>
peterhellberg: No, the runner silently quashes most errors. There are a few (Interrupt, SignalException, etc) it lets through, so I could throw one of those but a syntax error or div-by-zero would be hidden.
<peterhellberg>
Rubinista: Ah, tricky :/
Draco_ has joined #ruby
mneorr has quit [Quit: Leaving.]
panpainter has joined #ruby
<peterhellberg>
How about: exit unless fixtures_present?
jmccune has left #ruby [#ruby]
strife25 has joined #ruby
Aaton is now known as Aaton_off
<peterhellberg>
Rubinista: fixtures_present? would obviously need to be written :)
sebicas has quit [Quit: sebicas]
oxyxian has joined #ruby
hemanth has quit [Read error: Connection reset by peer]
hunglin has quit [Ping timeout: 244 seconds]
hemanth has joined #ruby
Draco_ has quit [Read error: Connection reset by peer]
<Rubinista>
peterhellberg: It's essentially what I do now. I require a dashboard object which is created in the startup so I just raise unless dashboard, but this is just yet another thing to forget...
Draco_ has joined #ruby
Draco___ has joined #ruby
<chiel>
in ruby, is there some kinda norm on how to do TDD?
<chiel>
i'm writing a rest api, and would like to take a TDD approach, but don't really know where to begin
g0bl1n has joined #ruby
hemanth has quit [Read error: Connection reset by peer]
<Rubinista>
chiel: Check out rspec or cucumber. Or do you mean something else?
<benson>
chiel: read the rspec book
<peterhellberg>
chiel: The norm is to do TDD/BDD in some capacity, the choice of framework to do it in, is up to each developer :)
<peterhellberg>
chiel: There isn’t really a single right way to do testing, and a lot of people would definitely suggest RSpec
<peterhellberg>
s/testing/testing in Ruby/
hemanth has quit [Read error: Connection reset by peer]
hemanth has joined #ruby
<chiel>
peterhellberg: fair enough, I'm just after something pretty minimal really. I'll mostly be doing a bunch of curl calls with various nouns to the api
<peterhellberg>
chiel: Why? You should probably use rack-test and/or capybara for testing your api
rbanffy has joined #ruby
rbanffy has quit [Client Quit]
<chiel>
peterhellberg: yeah that's why I was looking for suggestions, not 100% sure on how to approach it. :D
<peterhellberg>
chiel: Fair enough
Z_Mass has joined #ruby
Z_Mass has quit [Read error: Connection reset by peer]
<peterhellberg>
chiel: Most of my work is centered about building tested REST and Hypermedia APIs in Ruby… so you are welcome to ask questions :)
<peterhellberg>
s/about/around/
<chiel>
peterhellberg: oh yes, that's exactly what I am doing. trying to design a proper api for https://tinker.io
<chiel>
which is basically a playground for making little snippets from html/css/js
<chiel>
peterhellberg: so when you write tests for the apis you work on, what is your framework of choice?
<peterhellberg>
chiel: Tend to go as minimal as possible (low number of dependencies) so I usually work with Sinatra and Minitest
baroquebobcat has quit [Quit: baroquebobcat]
<peterhellberg>
chiel: http://pastie.org/4268780 <- Very trivial example of how it can look when you test an API using minitest/spec + rack-test
<chiel>
peterhellberg: cool, I am writing the api in sinatra
<chiel>
so all the better if I can use that to write the tests as well
uris has quit [Quit: leaving]
<peterhellberg>
chiel: I generally write the business logic in PORO's (Plain old Ruby Objects) and test them separately
ringotwo has quit [Read error: Connection reset by peer]
<chiel>
peterhellberg: the approach i was taking so far is basically one file, api.rb (a sinatra app) which handles all the various urls
ringotwo has joined #ruby
<chiel>
and then just connects that to regular ruby classes
<chiel>
and that request is just returning `request.body.read`
randomautomator has quit [Remote host closed the connection]
<shadoi>
looks like JSON to me?
<chiel>
since I can't even handle this, maybe it's time to go to bed..
subbyyy has joined #ruby
<chiel>
shadoi: yes, but it treats it as a key/value pair
<shadoi>
ah
<shadoi>
yes
luckyruby has quit [Remote host closed the connection]
hemanth has joined #ruby
<chiel>
maybe that's how it always is, no idea, but that's what threw me off initially
<shadoi>
nah, that looks fishy
<shadoi>
make sure JSON.parse(request.body.read) works as expected.
pk1001100011_ has joined #ruby
cakehero has quit [Quit: Computer has gone to sleep.]
davidboy|alive is now known as davidboy|living
<chiel>
shadoi: seems to return exactly the same response... really weird
davidboy|living is now known as davidboy
<peterhellberg>
chiel: And your user.json only contains {"id":1,"username":"chiel"}?
<chiel>
peterhellberg: yep
<chiel>
just trying to run a quick test
<chiel>
but.. failing :D
krz has joined #ruby
pk1001100011 has quit [Ping timeout: 244 seconds]
raz has joined #ruby
<peterhellberg>
I’ve got JSON.parse(request.body.read).inspect in a post "/" here, and it works just fine
<raz>
anyone know how to prevent rubygems from creating a wrapper for certain files in bin/ (when creating a gem)?
<chiel>
probab;y just something fishy going on I guess
<shadoi>
raz: don't list them as executables
<raz>
i'm trying to bundle a real binary, but the wrapper tries to 'load', which obviously fails
<raz>
shadoi: ah, then they will just go plain into the bin-dir?
<raz>
gonna try that
hemanth has quit [Read error: Connection reset by peer]
<shadoi>
raz: if you use bundler it likes to list all files in bin/ as executables by default
<shadoi>
you have to change it
hemanth has joined #ruby
<raz>
shadoi: yes, i'm gonna remove my binary from that now and see if that unwraps it
<shadoi>
The only problem is, it won't create a symlink or anything, so it'll be in your gem path
<shadoi>
kinda inconvenient.
<chiel>
aha, now it works, I was being a retard
<chiel>
that means, it's time to go to sleep, probably :p
<chiel>
thanks for the help guys
<peterhellberg>
chiel: Well, I’m heading to bed now. But you are welcome to ask me more questions about building APIs with Sinatra ( My contact info is on http://c7.se/ )
<peterhellberg>
chiel: np
<chiel>
ah, a swede!
<peterhellberg>
chiel: yep
<chiel>
I hung out there for 1 year and 8 months before moving to london
hemanth has quit [Read error: Connection reset by peer]
pk1001100011_ is now known as pk1001100011
<chiel>
peterhellberg: anyway, sleep well, see you later
<peterhellberg>
I see, it is a pretty nice country to live in. But I tend to escape to Asia in the darkest part of the winter :)
<peterhellberg>
chiel: The same to you
sailias has joined #ruby
<chiel>
peterhellberg: sweden is a bit too quiet for me
yxhuvud has quit [Ping timeout: 252 seconds]
<chiel>
peterhellberg: london is more up my alley, was a nice experience though, stockholm
<chiel>
i worked at spotify there
ryan0x2 has joined #ruby
hemanth has joined #ruby
axl_ has joined #ruby
<peterhellberg>
Ah, I’ve some friends who have/will work there.
<chiel>
peterhellberg: cool, it's a pretty popular location i guess, for tech-people in Stockholm
<GeekOnCoffee>
Woo spotify
<chiel>
lot of kth people roaming the halls
<peterhellberg>
There are a small startup scene here, but most of the action in Europe seems to be happening in Berlin now
<peterhellberg>
It used to be London, but Berlin is where its at now :)
<chiel>
yeah, berlin is pretty popular now
<chiel>
but... german
<chiel>
i like london cause i speak the language! :D
<raz>
shadoi: indeed. any idea how to locate the path where my gem was installed from inside ruby? :/