<oren>
should i avoid hitting my db in my unit tests?
Indian has joined #ruby-lang
nfxgosu has joined #ruby-lang
<petercooper>
ideally, yes
<lianj>
especially in unit tests
<petercooper>
if you're uncle bob, absolutely and you shouldn't even think about your database until the day before shipping (exaggeration for comic effect)
<lianj>
unless you make a db wrapper
<oren>
petercooper: so do u mainly test the interaction between your objects? (with stubs)
Sailias has joined #ruby-lang
<petercooper>
there are a couple of schools of thought on it, but that is one route, yes
<petercooper>
That said, it's common, particularly in the Ruby world, to take the approach of running against the DB (even if it's just an in-memory one).
<oren>
petercooper: what if my db is mongo or mysql? how do i do that in memory?
<oren>
there is a memory-based mongo, i believe
nfxgosu has joined #ruby-lang
skiz has joined #ruby-lang
nfxgosu has joined #ruby-lang
nfxgosu has joined #ruby-lang
Weems has joined #ruby-lang
Weems has joined #ruby-lang
nfxgosu has joined #ruby-lang
nfxgosu has joined #ruby-lang
gokul has joined #ruby-lang
jacktrick has joined #ruby-lang
nfxgosu has joined #ruby-lang
muffintop has joined #ruby-lang
<oren>
i use capybara-webkit for acceptance tests. it looks like capybara doesn't know about a dom element that is injected at document.ready. any ideas?
slimfit has joined #ruby-lang
nfxgosu has joined #ruby-lang
nfxgosu has joined #ruby-lang
lsegal` has joined #ruby-lang
nfxgosu has joined #ruby-lang
mikeric has joined #ruby-lang
nfxgosu has joined #ruby-lang
seanstickle has joined #ruby-lang
nfxgosu has joined #ruby-lang
brushbox has joined #ruby-lang
nfxgosu has joined #ruby-lang
csmrfx has joined #ruby-lang
<csmrfx>
*Any sightings of ruby dsl for writing non-verbose, non-tautological xml?
gokul has joined #ruby-lang
<csmrfx>
I'm going to working with xslt again, and I'll be damned if I have to write 120 characters of code just for a simple if-then-call-subroutine
sideshownz has joined #ruby-lang
Cherrum has joined #ruby-lang
darkf_ has joined #ruby-lang
WillMars_ has joined #ruby-lang
Sailias has joined #ruby-lang
pvh has joined #ruby-lang
solars has joined #ruby-lang
vereteran has joined #ruby-lang
guns has joined #ruby-lang
y3llow has joined #ruby-lang
17SAALGMA has joined #ruby-lang
jaimef has joined #ruby-lang
darkf_ has joined #ruby-lang
CodeBlock has joined #ruby-lang
Slackwise has joined #ruby-lang
mikeric has joined #ruby-lang
alindeman has joined #ruby-lang
codefriar has joined #ruby-lang
<codefriar>
I'm working with a class and trying to dynamically define some methods. For some reason when I invoke define_method I get an undefined method error. What could cause a class to not respond to define_method ?
bglusman has joined #ruby-lang
EvilJStoker has joined #ruby-lang
<drbrain>
codefriar: do you call some_class.define_method ?
<erikh>
look there -- one of them will refer to the files required
<erikh>
that is, which file ruby actually picked up
<erikh>
you can walk it like an array, so etc
<TTilus>
Tref: was it system package, or did you download something?
<Tref>
i downloaded and built it
<Tref>
so it looks like it could be
<Tref>
$: Load path for scripts and binary modules by load or require.
<TTilus>
Tref: simply build it again with every ruby you intend to use it with
<Tref>
or
<Tref>
$" The array contains the module names loaded by require.
<TTilus>
Tref: the latter
<Tref>
getting that install configured right took me like a week
<Tref>
:)
Wardrop has joined #ruby-lang
<TTilus>
Tref: so now you know how to do it and it wont tae another week :)
<Tref>
:)
<Tref>
so $" is giving me two files
<Tref>
"librets_native.bundle", "Librets.rb",
<Tref>
the latter seems to be in /Library/Ruby/Site/1.8/librets.rb
<Tref>
the former in "/Library/Ruby/Site/1.8/universal-darwin11.0/librets_native.bundle"
<TTilus>
Tref: see that 1.8 in the path
<Tref>
yeah
<TTilus>
Tref: now just go build it again
<Tref>
hahaha
<Tref>
shit
<Tref>
So here's just a question for you to help free me of a bit of ignorance
<TTilus>
Tref: and this time copy the commands u use to an installation script of your own :)
<Tref>
why can't I just include that with ruby 1.9?
<TTilus>
Tref: u prolly still find from your command history
<Tref>
somehow put it in the load path and include it in 1.9
<Tref>
I trust from what you're saying that it won't work. I just don't know enough about ruby to know why
<TTilus>
Tref: u cant know if the library wants to behave/install differently depending on the ruby version/platform
<TTilus>
Tref: let the library decide how it wants things
amerine has joined #ruby-lang
<Tref>
so what is that .bundle extension all about?
<TTilus>
Tref: if you dont, believe me, you need to know whole a lot of more ruby to make things work
<TTilus>
Tref: dunno
<oren>
i inject DOM element in document.ready. my capybara's assertion fails if the js code is not inline. any ideas?
<oren>
(capybara-webkit)
<TTilus>
oren: not really, tried different drivers?
<TTilus>
oren: and #cucumber or #capybara even...
<oren>
TTilus: thanks, i didn't know about #capybara
ryanf has joined #ruby-lang
<Tref>
TTilus: does installing this under RVM mean that this library isn't going to work in my system ruby anymore?
<Tref>
Or should it still work?
<rue>
erikh: Why'd you switch?
rivaler has joined #ruby-lang
thone has joined #ruby-lang
<Tref>
TTilus: looks like I'm getting farther than I though
<Tref>
Thought*
<Tref>
but i was getting a extconf.rb:4:in `<main>': uninitialized constant PLATFORM (NameError) when trying to run extconf
<Tref>
and got it to run by changing PLATFORM to RUBY_PLATFORM in my extconf.rb file
<Tref>
but it appears that there's a second problem that The C macros for working with a Ruby Array changed.
gianlucadv has joined #ruby-lang
bojicas has joined #ruby-lang
bojicas has joined #ruby-lang
EvilJStoker has joined #ruby-lang
sideshownz has joined #ruby-lang
rpowell has joined #ruby-lang
JohnBat26 has joined #ruby-lang
sora_h has joined #ruby-lang
gokul has joined #ruby-lang
jxie has joined #ruby-lang
daglees has joined #ruby-lang
yxhuvud has joined #ruby-lang
<csmrfx>
Given strings "foo-bar" and "foo-gib", methods foo, bar and gib, how would one generally map the strings to the functions in ruby? (ignoring string iteration and tokenizing)
nemesit has joined #ruby-lang
<csmrfx>
in other words, I'd like to write my parser using a map, and some functions
<csmrfx>
but not sure what would be a wise "map" to use with ruby
<Mon_Ouie>
Not sure what you're trying to do. Replace foo with the result of a call to foo?
<csmrfx>
well, add the results of foo to the result set
<csmrfx>
but thats almost the same
<csmrfx>
if you like, I can pastie the pseudocode
<Mon_Ouie>
Yeah, with an example of actual input/output
<csmrfx>
ok, gotta work on the output a sec
takaokouji has joined #ruby-lang
brushbox has joined #ruby-lang
h4y4shi_ has joined #ruby-lang
<ryanf>
csmrfx: it sounds like you want send()
<ryanf>
as in obj.send(:method_name)
<ryanf>
alternately, you could make a hash with method objects in it and then .call() them
savage- has joined #ruby-lang
<ryanf>
(you get method objects using obj.method(name) or klass.instance_method(name))
<ryanf>
instance_method returns unbound methods, which you have to bind to an object before calling
corundum has joined #ruby-lang
<csmrfx>
See from line 78 onwards for input, and 91 for output, and under it shorthand for the tokens. http://pastie.org/3365695
<csmrfx>
ryanf: well, hash with methods in it sounds nice... or hashes with hashes (with hashes) with methods in them...
ryez has joined #ruby-lang
rivaler has joined #ruby-lang
<ryanf>
I think you should consider send() instead, it might simplify your architecture quite a bit compared to keeping a hash of methods
<ryanf>
but the hash is fine too
<erikh>
rue: gc issues
<csmrfx>
(I suppose you noticed there are some errors there)
<csmrfx>
ryanf I dont quite follow the send -idea. How would mapping token-keys to library functions work with that?
<csmrfx>
or perhaps some example code that I should see?
sideshownz has joined #ruby-lang
<ryanf>
csmrfx: well, the simplest way would be to just name your methods after the tokens
<ryanf>
if you need a more complicated mapping then you might as well use method objects instead though
<csmrfx>
well I had a bright moment but now it is totally gone
<csmrfx>
I think it went along the lines of not having to "map" tokens to methods first, instead just have a "parse-tree" that input stream traverses... but just cant wrap my head around how that would be in ruby
<csmrfx>
too much ecma
<csmrfx>
do you think that makes sense?
mytrile has joined #ruby-lang
<csmrfx>
hmm, maybe something with method_missing as usual
<shevy>
is that normally enough to subclass? even without super() ?
<shevy>
I dont know activerecord myself
<shevy>
well if I have to make a guess, you probably did not subclass properly
<shevy>
I can't be of help with activerecord though, so someone else probably has to
<futurechimp>
no need for super there
<futurechimp>
Jake232: it looks like you're using a rails engine?
<Jake232>
futurechimp: yea
<futurechimp>
with what version of rails?
<Jake232>
3.2
<futurechimp>
ok, i haven't used an engine with a version that recent
<Jake232>
If I uncomment all the stuff thats in the Engine class
<Jake232>
It works
<Jake232>
But, I need it to stay there, so I can update the gem
<futurechimp>
it used to be the case, back in the old days of engines, that it was necessary to do something like: require_dependency 'foo/bar/blah' in order to get an engine to load certain kinds of subclasses
<futurechimp>
but i would tend to doubt that this is still the case, since engines are now merged into rails since v3.x
<Jake232>
This is my first xperience with an Engine
<Jake232>
and it hasn't been great
<Jake232>
lol
thoradam has joined #ruby-lang
<Jake232>
Wait
<futurechimp>
ah wait a moment, yeah you'll need to unfortunately put all that stuff in the AR class, if engines still work the same way they used to
<Jake232>
I think that if you require something in your models
<Jake232>
it doesn't require them unless you restart the rails app
<futurechimp>
the AR model in your actual application totally overrides the model in the engine
<Jake232>
even though it should
<Jake232>
because it's supposed to reload every file in /app, in dev mode
<Jake232>
It seems it doesn't fire the require calls
JoL1hAHN has joined #ruby-lang
curtism has joined #ruby-lang
<Spooner>
I always have problems with namespacing if I use shorthand in class defs ('class A::B::C' rather than 'module A;module B; class C'). Can anyone explain why these are different, because as far as I know they "should" be the same.
roha has joined #ruby-lang
<Jake232>
Alright, its officially screwing with me
<Jake232>
it worked
<Jake232>
I havent even gone back to the text editor yet
<Jake232>
and now it doesnt
<thoradam>
Hello everyone, I was wondering about the |pipe| in ruby, is there no substitute for in common situations like this: array.map! { |i| i == 0 ? i : i/3 } ?
<rippa>
why do you need a substitute?
<Jake232>
futurechimp: Using require_dependency has actually worked
<Jake232>
I would have never found that, thanks
<futurechimp>
ah, great :)
<thoradam>
It could be more concise like this: array.map! { _ == 0 ? _ : _/3 }
<rippa>
thoradam: array.map! { |i| i/3 }
<thoradam>
But I guess there is nothing like that right?
<rippa>
that's more concise
<Jake232>
futurechimp: Now I just have to implement this to the other 4 models.
virunga has joined #ruby-lang
<thoradam>
rippa: That was just an example really :)
<rippa>
no, blocks don't have parameters in a default var
slyphon has joined #ruby-lang
<futurechimp>
Jake232: engines are great, but there is a bit of folklore associated with using them - happy it worked for you!
<thoradam>
Ok thought so, thanks!
heftig has joined #ruby-lang
skiz has joined #ruby-lang
MistyM has joined #ruby-lang
symptom has joined #ruby-lang
chimkan has joined #ruby-lang
fayimora has joined #ruby-lang
krz has joined #ruby-lang
thoradam has quit [#ruby-lang]
sirfilip has joined #ruby-lang
aki__ has joined #ruby-lang
<csmrfx>
Any idea where to find example source for parse-rules defined as an object (-tree), and for code that then traverses that tree with tokenized strings?
<csmrfx>
or, definitive example, even
nemesit|osx has joined #ruby-lang
<whitequark>
csmrfx: can you elaborate?
any-key has joined #ruby-lang
<csmrfx>
Ok I have a string representing a document. Then I have a set of rules that define what to return for each string-token. Example: "-html -p =hello" would be parsed with the tree rules = { html: { div: do_div(token), p: do_p(token), h1: do_header(token) }, xml: { foo: etcetc() } }
<csmrfx>
At least in my mind that seems the most attractive solution to parsing stuff
<csmrfx>
I guess simple and succinct are aims here
<csmrfx>
Making a shorthad dsl for representing xml in least verbose way possible (templating, kinda)
<shevy>
csmrfx shouldn't succint and terseness always be the aim anyway ;)
<shevy>
*succintness
<andrewhl>
i'm trying to write a prime sifter. The idea is to take a range of numbers (e.g., 2..20), and check for the multiples of each number by incrementing by that number value. All multiples except the first number will be set to nil or something. When the range is exhausted, move on to the next prime number, increment that by its own value, and repeat. What's the best way to do this? Should I use inject?
<andrewhl>
I'm not sure how to modify an array or a range that I am currently looping through
<csmrfx>
shevy: well, sometimes you have complexity to deal with or safety or robustness > simple+powerful (but perhaps miss some edge cases)
<Jake232>
andrewhl: Sounds like Sieve of Eratosthenes?
<andrewhl>
so... [2, 3, 4, 5, 6, 7, 8, 9] would become [2, 3, nil, 5, nil, 7, nil, 9], which would then become [2, 3, nil, 5, nil, 7, nil, nil]
<Jake232>
If my memory serves correctly anyway, maybe thats somethign else
<andrewhl>
jake232: exactly that. I'm just not sure how to approach it
<andrewhl>
like, I'm not sure what method to use to modify an array as you loop through it
<jorgenpt>
"string".to_hash seems to change between interpreter launches - is there a way to get a consistent hash of a string?
<jorgenpt>
String#hash says that it's generated based on the "length and content" of the String, which is obviously not true - there must be something else involved too.
<shevy>
guys
<shevy>
I have a class with about 20 @instance variables
<shevy>
is that too much?
<jorgenpt>
I guess I'll have to use digest.
S2kx has joined #ruby-lang
mephux has joined #ruby-lang
mephux has joined #ruby-lang
postmodern has joined #ruby-lang
<ddfreyne>
shevy: that seems like a lot, but if you think they all belong together, no problem i guess
Dreamer3 has joined #ruby-lang
dejongge has joined #ruby-lang
elitheeli has joined #ruby-lang
looopy has joined #ruby-lang
<shevy>
ddfreyne yeah well ... I dont know :(
<shevy>
what is making it worse is ... that I use that class to tie together many other smaller classes
<elitheeli>
theconartist: here's what I'm working with: https://gist.github.com/b83351ff0e349f49e5a8 -- I want it to print Tick every second regardless of whether or not I'm typing
<cschneid>
csherin: we're gonna have to fight over the cs prefix on our names
<cschneid>
didn't we collide yesterday too?
<theconartist>
oh
<csherin>
yeah ;-)
<theconartist>
more specific i see
<Defusal>
elitheeli, depending on your project, i'd suggest looking into using EventMachine rather than threads
<theconartist>
what's the problem elitheeli
Wardrop has joined #ruby-lang
<elitheeli>
theconartist: I'm writing a wrapper around a really crapper interpreter in another language. I want readline support. I want to print things from the interpreter as they come.
josh9 has joined #ruby-lang
<elitheeli>
Defusal: does EventMachine stop the Readline.readline call from blocking?
<Defusal>
argh i just realized i cant check the images :|
<Defusal>
elitheeli, you use EventMachine to asynchronously read from the keyboard, you never use any blocking methods with EM
<burgestrand>
elitheeli: as you’ve noticed, it blocks the entire ruby VM when waiting for input
<burgestrand>
which is also why other threads won’t run, as they need to acquire the GIL that the thread running Readline.readline is holding
<elitheeli>
Does that mean that I need to implement all the magic of things like Control-A, Control-U, history, etc. myself?
<csherin>
burgestrand: wouldn't it work in Rubinius in that case. it doesn't have a GIL right ?
<burgestrand>
elitheeli: not all systems have this issue, are you on a mac?
<elitheeli>
yessir
<burgestrand>
csherin: upcoming 2.0 does not, but the current 1.x does
<burgestrand>
elitheeli: you can work around the issue in two ways; either you install GNU readline and reinstall the readline extension, or you can use a pure-ruby implementation of readline named rb-readline
<josh9>
what does it mean 'a driver' in the context of capybara?
<burgestrand>
josh9: it’s what runs the web browser, or rack::test
<burgestrand>
josh9: selenium, or capybara-webkit for example
<josh9>
burgestrand: i know about the different drivers, but not sure what a driver is. why do we need 2 codebases? capybara codebase and a driver codebase?
rpowell has joined #ruby-lang
<burgestrand>
josh9: it allows you to write your own driver for capybara without needing to change capybara itself
<burgestrand>
the drivers themselves become plug-and-play
<mrb_bk>
can anyone help me out with a question about rb_define_alloc_func in a c extension?
<burgestrand>
mrb_bk: just ask
<mrb_bk>
burgestrand: thanks, i'll put a gist together
<burgestrand>
mrb_bk: that’s an awful big question then
<mrb_bk>
haha
<mrb_bk>
i'll try to state it simply
<burgestrand>
always the hard part :)
<mrb_bk>
if the c class i'm wrapping needs arguments passed to the method used to initialize the structs, and i want to use rb_define_alloc_func
<josh9>
andrewvos: assert has_content("whatever") is working. it's only the status_code
<mrb_bk>
should i just allocate the memory in rb_define_alloc_func, and pass that pointer to Data_Wrap_Struct?
<burgestrand>
mrb_bk: yes
<mrb_bk>
burgestrand: and then use Data_Get_Struct in the initialize method and pass the args there?
<burgestrand>
mrb_bk: you then use Data_Get_Struct in your initialize function to get the pointer to your struct, which you can then use to fill with data
<mrb_bk>
:) okay
<mrb_bk>
i thought that's what i was doing but i guess i fucked something up because it keeps crashing
<burgestrand>
mrb_bk: remember, if you store any VALUEs in your struct you should supply a marking function in Data_Wrap_Struct
<burgestrand>
mrb_bk: an example of how I’ve used it
<burgestrand>
mrb_bk: oa_allocate is the function I passed to rb_define_alloc_func, and the oa_initialize below that is the initialize method
<burgestrand>
initialize doesn’t take any arguments here, but that should not matter
<mrb_bk>
burgestrand: awesome, thanks!
<Asher>
w/ fork shouldn't child processes die when the parent process is killed?
niklasb has joined #ruby-lang
<burgestrand>
Asher: don’t think so, no
<rue>
Dat not how et work
<Asher>
oh ok
<Asher>
cool
<Asher>
i thought that's what made it a "child"
jefflembeck has joined #ruby-lang
<burgestrand>
It becomes a zombie when the parent dies, so in effect its closer to spawn of sorts, perhaps a vampire
<andrewvos>
How do I make a process happen in the background under thin?
<andrewvos>
Well, some code really
<andrewvos>
Want to execute some code every request
<burgestrand>
but you don’t want it to block the request from returning?
<burgestrand>
or, well, response :)
<burgestrand>
andrewvos: ^
<andrewvos>
hmmm, I'm starting to think this is a stupid idea...
<andrewvos>
Ok so what I really want is
<whitequark>
if you want to do it synchronously, just execute it in a request handler
<whitequark>
if you want it asynchronously, use resque
<whitequark>
if you want it to be synchronous, but don't block the whole thin server for i/o, look at EM/EM::Synchrony
<andrewvos>
My data store is a text file on the web. I don't want it to update on every request so I want to cache it, but then release the cache after like 5 minutes.
<josh9>
does it make sense to use vcr for acceptance testing?
<andrewvos>
So I was thinking on every request launch a background job that updates the item
<andrewvos>
But that means 1 request for every request
<andrewvos>
Which seems silly
<whitequark>
andrewvos: do I understand you right way? you have a document on a same server with thin with some kind of data
<burgestrand>
josh9: why would you use vcr for acceptance testing?
<whitequark>
andrewvos: which sometimes changes because of requests routed to thin
<josh9>
burgestrand: to make them fast?
<andrewvos>
whitequark: I have a document somewhere else. My app requests it every time and parses it for its data.
<burgestrand>
josh9: and only work as long as you don’t change something? :P
<josh9>
but i guess the purpose of acceptance is on the real site
<whitequark>
andrewvos: ok. that doesn't seem a case for a background job
<andrewvos>
whitequark: Indeed.
<whitequark>
andrewvos: if you're not afraid of Redis, I personally would just cache it with an expiration time of 300 sec
<whitequark>
like 1 command of Redis
<andrewvos>
whitequark: I can't cache it
<andrewvos>
It's coming from an external url whitequark
<whitequark>
andrewvos: why not?
<josh9>
burgestrand: also, am i suppose to test for status codes in my acceptance or is it more a controller test?
<andrewvos>
Well, because it's not on my server
<whitequark>
andrewvos: keeping an external piece of data locally to speed up access time is called "caching"
<andrewvos>
whitequark: Oh I thought you meant cache the data file
<burgestrand>
josh9: status codes does not matter to your users unless it’s an API, so I would not test them
<josh9>
burgestrand: ok
mephux has joined #ruby-lang
<whitequark>
andrewvos: the browser cache, the processor cache, the filesystem cache and any other kinds of cache are just the same thing
<whitequark>
may them work on files
<whitequark>
bytes
<whitequark>
whatever
<shevy>
on boobs
<whitequark>
keeping a pair of boobs locally to speed up access?
<andrewvos>
whitequark: Yeah I get you.. So basically I'm looking for an easy way to cache the data for a certain amount of time
<whitequark>
that's called "relations" by some
<whitequark>
andrewvos: sure. should it be in pure ruby? should it be shared/synced between different worker instances?
<andrewvos>
whitequark: Pure ruby would be nice
<andrewvos>
whitequark: Don't really want ot have to install anything locally
<andrewvos>
whitequark: And this project isn't exactly mission critical
<burgestrand>
andrewvos: do you need to share the cache between multiple instances of the application?
<whitequark>
manveru: configuring a terminal via Xresources is... perverted. at least.
<wmarilync9>
are there anybody from Perú????
wmarilync9 has quit [#ruby-lang]
fayimora has joined #ruby-lang
<manveru>
whitequark: yeah, gotta love it
brushbox has joined #ruby-lang
twittard has joined #ruby-lang
alexh_ has joined #ruby-lang
countskm has joined #ruby-lang
gregf has joined #ruby-lang
<alexh_>
hi, it seems that in a class method one can refer to a class instance variable with an @ or without. which is considered better practice?
<manveru>
without @ it's not a class instance variable
<alexh_>
@manveru, that doesn't really help
<manveru>
your question is ambigous
<alexh_>
well thx (not)
<manveru>
can your provide an example of either?
<manveru>
*you
kyrylo_ has joined #ruby-lang
kyrylo_ has joined #ruby-lang
vesan has joined #ruby-lang
ryanf has joined #ruby-lang
<whitequark>
alexh_: you cannot
<countskm>
@ is an object instance variable - one way it is different is that an instance variable can be shared between the superclass and subclass (if defined in superclass)
<whitequark>
if you have an attr_accessor, that's an entirely different story
<whitequark>
or cattr_accessor, or any similar method
<josh9>
whitequark: drbrain thanks. i'll look into it
<drbrain>
josh9: you should use mechanize
<lianj>
why is open-uri so bad for just a short fetch?
<drbrain>
if you're doing web scraping, don't reinvent mechanize
<drbrain>
lianj: no persistent connections
TheInkyVoid has joined #ruby-lang
<drbrain>
lianj: almost nobody does just one HTTP connection
<josh9>
drbrain: mechanize is using nokogiri. i am cofused..
<manveru>
mechanize is not using open-uri
<drbrain>
you're not going to find a better HTML parser than Nokogiri for ruby
<whitequark>
josh9: nokogiri isn't the slow part
<whitequark>
I/O is
<whitequark>
blocking I/O, that is
<drbrain>
unless you know exactly the HTML so you can write a custom regular expression, use nokogiri
<josh9>
whitequark: ok. so open is the issue?
<manveru>
any I/O is blocking if you can't do stuff before it's done :)
<drbrain>
josh9: and ^^ what whitequark says
<whitequark>
josh9: in your testcase, yes, it's open, and #read, which gets indirectly called inside Nokogiri::HTML
<manveru>
no matter how async your code is, you can't parse stuff that hasn't arrived yet
<whitequark>
I've made it explicit, as you see
<whitequark>
manveru: if you're doing web scraping, you gotta do it asynchronously
<manveru>
whitequark: but he's only got one url
<whitequark>
if that's just one script, I doubt the 0.5s delay is that bad
<whitequark>
so I assumed he is doing some scraping
senthil has joined #ruby-lang
<postmodern>
async all the things!
<whitequark>
postmodern: wrong. there is no silver bullet
<manveru>
postmodern: honoring your name, i see :)
<josh9>
whitequark: it's many requests. each one using nokogiri to find the name of the product.
<whitequark>
josh9: then you really should listen to drbrain
<whitequark>
he knows more than me on the topic
<postmodern>
whitequark, if your concerned about web-scraping perf, i would just use a thread pool and mechanize/net-http-persistant
<drbrain>
josh9: with open-uri, most of the I/O time is spent waiting for TCP syn/ack and slow-start
<whitequark>
postmodern: sure. thread pool is a way to do things asynchronously
<josh9>
whitequark: use net-http-persistant and chose mechanize instead of nokogiri?
<postmodern>
whitequark, it's still synchronous technically
<drbrain>
josh9: mechanize uses nokogiri and net-http-persistent, it's exactly what you want
<postmodern>
mechanize combines net-http-persistent and nokogiri
<wilo>
hola a todos buenas noches
<manveru>
wilo: gn8
<josh9>
drbrain: ok. so the connection will stay open for longer time?
<whitequark>
josh9: you're going to rewrite parts of mechanize anyway
<whitequark>
without knowing it
<alexh_>
so I think I have it… one can essentially refer to a class instance variable in a method without the @ if it is an attribute. Doing so is refering to the attribute rather than the actual class instance variable. Sorry for the nooby question.
<wilo>
I am new to ruby and want to work with the OpenGL library to create the rubik's cube
<manveru>
cool, i knew i learned italian for something :)
<lianj>
hehe
<drbrain>
wilo: do you already know OpenGL?
mikeric has joined #ruby-lang
<whitequark>
manveru: I determined that without even knowing italian, heh
<manveru>
whitequark: i was mostly kidding :)
<drbrain>
wilo: ruby-opengl primarily supports the fixed-function pipeline, not the modern shader pipeline
<drbrain>
wilo: there's no OpenGL 3+ support (yet)
havenn has joined #ruby-lang
<manveru>
opengl code looks the same in any language :P
<wilo>
mmm
<simon_d>
I've got a bit of a problem with an application I'm trying to install (gitlabhq). With the install there were syntax issues and now trying to run the program (after fixing the initial issues with my extremely limited ruby). With so many syntax issues I'm thinking the problem might be something else, maybe a ruby gem I might need or something or a different version of ruby
<wilo>
means that it is not very compatible opengl in ruby?
<whitequark>
simon_d: $ ruby -v. Is it 1.8? if it is, install 1.9
<simon_d>
1.8.7?
<whitequark>
wilo: there's nothing in your Rubik cube which cannot be done with opengl currently available. I doubt you really need shaders
<wilo>
I'm working with Ruby 1.9.2
kyrylo has joined #ruby-lang
kyrylo has joined #ruby-lang
<whitequark>
simon_d: 1.8.7 is 1.8, yes.
<whitequark>
either use your package management system, if any, or use rvm
<drbrain>
wilo: there are some shader-pipeline features in opengl 2, so you can either write ancient-style fixed-function or modern-style shader pipeline
<drbrain>
but all the latest features aren't yet mapped.
<simon_d>
the errors are - syntax error, unexpected ':' - this is the line that is causing it, can you see an issue with the syntax, what is the line doing: redirect_to [:admin, @admin_project], notice: 'Project was successfully updated.'
<drbrain>
simon_d: notice: 'Project was …' is a 1.9 hash syntax