« Back to channel list

#ruby - 17 June 2013

« Back 1 day Forward 1 day »
[00:43:40] sam113101: looks like it's working
[00:45:54] sam113101: I like it when I do things and it works as expected
[01:17:17] n_blownapart: hi I have a deck of cards class that gets shuffled and dealt. http://pastie.org/8050339 ; Then I have a testing class: http://pastie.org/8050343 ; finally a 3rd file with a 'cardtest' class. I know the require/require_relative/load business is wrong but can't figure out how to get the files to load. thanks
[01:18:05] n_blownapart: 3rd file is http://pastie.org/8050346 sorry ^^
[01:28:33] taoshi: a lot of plp :)
[01:28:37] n_blownapart: sam113101: test test
[01:29:25] taoshi: plp can help whit this? https://github.com/speedlight/warpdrive.git
[01:30:24] taoshi: just the part of the cases.rb i'm trying to print the $damage01xx values..
[01:30:36] taoshi: but im getting:
[01:30:39] taoshi: #<Reactores:0x00000002353ae8>
[01:37:53] bnagy: taoshi: there's no need to use globals there ( or in fact anywhere tbh )
[01:38:18] bnagy: and you're calling to_s on an instance of a class that doesn't have a specific to_s method, so you just get the default behaviour
[01:38:27] bnagy: which is to give you the class name and the object id
[01:38:50] taoshi: im kind of newbie :)
[01:39:10] bnagy: if you want specific values from the Reactores instances you'll have to get them ( I didn't look at that class )
[01:39:39] taoshi: you mean in the cases.rb.. yea i trying to figureit out how to get just de damage method value
[01:43:04] bnagy: some_instance.damage
[01:45:06] taoshi: but that way i get 'wrong number of arguments'
[01:46:50] n_blownapart: hi I have a deck of cards class that gets shuffled and dealt: http://pastie.org/8050339 ; Then I have a testing class: http://pastie.org/8050343 ; finally a 3rd file with a 'cardtest' class: http://pastie.org/8050346. I know the require/require_relative/load business is wrong but I'm confused on how to get the files to load. what is wrong? thanks.
[01:47:09] bnagy: oh, yeah damage is a bad name. You can read damageA B C though
[01:47:21] bnagy: n_blownapart: srsly, stop doing that
[01:47:32] bnagy: if nobody answers your question do NOT paste it every fricking 30 mins
[01:47:36] bnagy: we're ALL STILL HERE
[01:49:24] taoshi: bnagy: dont getit :( instance.damage calls the method, i dont have method damageA and so on
[01:50:30] taoshi: bnagy: i dont get how to get the asnwer of the method damage with the arguments that i create the instance
[01:50:50] bnagy: taoshi: you have a damageA method - it's declared in shorthand by attr_reader
[01:51:54] n_blownapart: bnagy: sorry I'm frustrated and can't see the problem.
[01:52:06] bnagy: n_blownapart: good for you, princess
[01:52:40] taoshi: oh that was just a test.. i have only the damage method
[01:52:54] bnagy: whether you're frustrated, calm or have antlers doesn't change the fact that it's bad behaviour
[02:01:09] bnagy: taoshi: I can't really see from your code what you even want damage to return, like this is half complete
[02:01:44] bnagy: but you could have apply_damage damage and damage with no args that returns the current damage
[02:04:11] taoshi: bnagy: thkz i know is half complete :( and i tried th eother creating a getDamage that just print @damage
[02:04:28] taoshi: but now im getting nothing
[02:04:42] bnagy: well if damage has not been called @damage will be nil
[02:06:37] bnagy: taoshi: there's so uch to fix that it's not really clear where to start
[02:07:12] bnagy: if you started with some tests it might help
[02:10:31] taoshi: https://github.com/speedlight/warpdrive.git
[02:10:50] taoshi: i commented out some things
[02:11:53] taoshi: i know it can be refactorized a lot but i dot know many things yet
[02:14:19] bnagy: don't print @damage, that will return nil
[02:14:45] bnagy: in fact just have attr_reader :damage tbh
[02:15:05] bnagy: and change damage( dmg ) to apply_damage or something
[02:17:50] taoshi: and then how i get the value of dmg from an instance?
[02:18:06] taoshi: ruby is beatifull btw
[02:18:18] taoshi: beautyfull*
[02:18:32] taoshi: sorry english is not my native lang
[02:19:08] bnagy: reactor1.apply_damage 30; reactor1.damage => 70
[02:19:44] `p: those new to ruby theres a rubynoobs irc channel we collaborate share explain stuff to each other really active channel
[02:19:47] `p: #rubynoobs
[02:20:32] taoshi: thankz `p
[02:20:50] `p: you're welcome, i was specifically directing that to you actually : |
[02:21:00] taoshi: haha i know
[02:25:42] taoshi: bnagy: im trying to pass 2 args in the instance creation, name and damage.. and in the initialize i get the values, then damage is passed to the apply_damage
[02:26:39] bnagy: taoshi: don't you need a starting damage before you can apply damage to it?
[02:27:30] taoshi: yes thats why i have damage01A = Reactor.new 'a' '40'
[02:27:46] bnagy: then set that in initialize, not through the apply_damage method
[02:28:12] taoshi: in th einitlize i have @damage = damage
[02:28:35] taoshi: and the method apply_damage damage
[02:29:02] taoshi: or dmg as the arg to not confuse ;)
[02:31:09] jcromartie: hey, I am looking to cram for a Ruby technical screening tomorrow
[02:31:21] jcromartie: what's good for that?
[02:31:23] jcromartie: I ran through https://github.com/gregstallings/ruby-trivia
[02:31:44] jcromartie: I've done Ruby for a long time, but I'm not super up to date with 1.9 and latest and greatest Rails/gems
[02:31:49] bnagy: http://ruby-doc.org/core-2.0/Enumerable.html
[02:33:03] bnagy: if you're not up to date with 1.9 that's an issue
[02:33:12] bnagy: 1.8 is ancient
[02:33:15] taoshi: oh hell i geit to work!
[02:33:33] taoshi: thankz a lot bnagy
[02:33:49] jcromartie: bnagy: well, let me see exactly how "not up to date" I am
[02:34:04] jcromartie: (BTW OS X still comes stock with 1.8.7)
[02:34:47] bnagy: well yeah, but there's alllll kinds of stuff wrong with OSX's unix side by default
[02:36:33] jcromartie: it's not perfect, but it gets the job done
[02:36:45] jcromartie: I'm not running any production servers on OS X :)
[02:37:45] havenn_: jcromartie: Just an aside, but OS 10.9's system Ruby is 2.0.0-p195. Yay! :)
[02:38:00] jcromartie: dang, ahead of the curve
[02:38:20] jcromartie: I don't have any servers running 2.0
[02:38:26] jcromartie: or I should say apps
[02:39:26] havenwood: jcromartie: Seems the only 2.0 issues I run into are on OS X, works great in production! >.>
[02:40:00] L8D: How should I ago about creating classes within classes?
[02:40:19] L8D: I want to do something like: MyClass.pos.x
[02:43:25] jcromartie: L8D: you mean you want a class variable?
[02:44:35] havenwood: L8D: CamelCaseClassNames::DoubleColonForNamspace.period_for_method
[02:46:03] jcromartie: L8D: (and modules act as namespaces)
[02:47:10] r0bgleeson: you can nest classes too if you want
[02:47:17] r0bgleeson: >> class Foo; class Bar; end; end; Foo::Bar
[02:47:18] eval-in: r0bgleeson => Foo::Bar (https://eval.in/33730)
[02:48:17] jcromartie: although generally in OO design the purpose of an inner/nested class is for internal details relevant to the enclosing class only
[02:48:40] pontiki: ubuntu is still at 1.8.7, too
[02:48:42] r0bgleeson: jcromartie: you can say the same about a module containing other classes.
[02:49:17] jcromartie: r0bgleeson: why?
[02:49:41] jcromartie: modules are intended to be used as namespaces, no?
[02:50:10] r0bgleeson: yeah, sometimes, but classes can act fine as a namespace. pry for example uses 'Pry'(a class) as its namespace.
[02:50:27] pontiki: jcromartie: no, public classes inside other public classes are just as public
[02:50:39] pontiki: a class does not hide internal classes
[02:51:07] r0bgleeson: if there is no need for 'Pry' to be a class, I'd make it a module.
[02:53:03] r0bgleeson: pontiki: not without private_constant :d
[02:53:44] jcromartie: pontiki: I'm not talking about access modifiers, just typical OO design, but I guess if it's conventional to use classes as namespaces then go nuts
[02:54:15] r0bgleeson: it's not conventional
[02:54:22] r0bgleeson: but it's not a bad design choice either
[02:54:29] r0bgleeson: sometimes it makes more sense to use class instead of module
[02:55:31] r0bgleeson: if you don't need a class use a module is my general rule of thumb for that type of stuff
[02:56:02] pontiki: If you can do module Foo; class Bar; end ;end
[02:56:05] havenwood: jcromartie: I think its fine to do so when you want to namespace on a constant that you also need to instantiate. For sure modules for namespacing is the way more common case.
[02:56:19] pontiki: and do Foo::Bar
[02:56:51] pontiki: why do you think you couldn't do module Foo; class Bar; class Baz; end; end; end, and then Foo::Bar::Baz?
[02:57:31] r0bgleeson: pontiki: i understand his point, he is saying (normally) an inner class might be a helper class, you _could_ make it private if you wanted to (at least >= 1.9.3)
[02:57:46] pontiki: sure you could
[02:57:53] pontiki: i could think a few reasons why that may be
[02:57:57] pontiki: but it's not a given
[02:59:56] jcromartie: I'm NOT talking about access modifiers
[03:00:14] jcromartie: I'm just talking about API design
[03:01:06] jcromartie: not really even any reason to make it private
[03:01:06] pontiki: you can design your API to whatever depth you need
[03:01:16] pontiki: you need to fulfill it's contract
[03:01:18] r0bgleeson: (with classes or modules)
[03:01:25] r0bgleeson: and don't forget, a class _is_ a module
[03:01:29] r0bgleeson: it inherits from Module
[03:01:45] havenwood: Made a little PStore wrapper gem for stupid-simple persisting of Ruby objects. Guess I shoulda made it a class not a module and made YAML::Store an option... Curious for any feedback though: http://havenwood.github.io/persist/
[03:03:16] pontiki: actually, havenwood, the way you've done it seems fine.
[03:03:53] pontiki: more complex needs a body can just use PStore itself, really
[03:04:10] pontiki: i think dead simple wrappers are pretty useful
[03:10:37] havenwood: pontiki: Yay, glad you think so! I was worried it was too trivial a difference from PStore to be worth doing. I guess the hope would be to be useful for someone who'd never seen PStore and wasn't doing fancy things.
[03:14:18] havenwood: Did an almost identical syntax one for Ruby objects to Redis: https://github.com/Havenwood/bindi#readme
[03:15:00] havenwood: I need to take a page from r0bgleeson's book and add instructions for MessagePack with Bindi. :)
[03:15:30] havenwood: I wanna actually use MessagePack for something. Seems awesome I just haven't had a chance.
[03:16:49] havenwood: Wrap ALL THE THINGS! \o/
[03:23:31] r0bgleeson: havenwood: bindi looks cool
[03:26:30] havenwood: r0bgleeson: I kinda code spiked it and left it in dire need of some love. I need to write test coverage... >.> and maybe go straight through the redis gem instead of ohm.
[03:27:49] r0bgleeson: havenwood: yeah… i don't know much about ohm
[03:27:57] r0bgleeson: i wouldn't think you'd need anything but the redis library
[03:28:03] r0bgleeson: it's a really good library
[03:28:35] havenwood: r0bgleeson: Yeah, I'm kinda using Ohm for no good reason since I'm not using its ORM stuff at all.
[03:29:51] r0bgleeson: havenwood: i used the redis docs (redis.io) and everything mapped cleanly to the ruby redis library
[03:30:11] havenwood: r0bgleeson: Simple benchmarks of serializing to Redis versus PStore or YAML::Store were crazy favorable to Redis, of course.
[03:30:50] r0bgleeson: what does YAML::Store use?
[03:30:52] r0bgleeson: filesystem as well?
[03:30:55] havenwood: r0bgleeson: Nice, I'll look at that and convert it over.
[03:30:58] havenwood: r0bgleeson: Yup, same.
[03:33:27] Inside: so.. weird question
[03:33:41] Inside: if I have an erm.. static method and then within that method I declare a small helper function
[03:33:50] Inside: why does helper function need to be self.func_name
[03:33:57] Inside: I thought its scope is local to the inside of that class?
[03:34:10] Inside: erm, inside of that static method
[03:36:47] r0bgleeson: Inside: code please?
[03:37:14] Inside: r0bgleeson: http://codepad.org/ndc2kAHb
[03:37:40] Inside: error before the addition of "self" was this: PDFReceiver.rb:112:in `block (2 levels) in mergeBOMs': undefined method `sym_app
[03:37:40] Inside: end' for BOMMaker:Class (NoMethodError)
[03:38:01] r0bgleeson: Inside: use define_method
[03:38:09] r0bgleeson: Inside: 'static' method is 'class method' in ruby
[03:38:12] Inside: huh, first I hear of that
[03:38:16] Inside: ah class method, that's what I thought
[03:47:47] Inside: I don't see why def doesn't work in this case at all :(
[03:48:25] r0bgleeson: Inside: when you want to define a method at runtime you should use define_method, it is a method itself, so you would say define_method(:some_name) { body }
[03:49:02] Inside: I mean I guess this doesn't have to a function created at run-time, I just wanted to place it close to where its gets used.
[03:49:37] r0bgleeson: that works as well
[03:50:00] Inside: ACTION flops.
[03:50:51] treehau55: i have a question about making a cli program
[03:51:13] treehau55: i want to just pass in the name of my program and the options
[03:51:37] r0bgleeson: treehau55: the options are available in ARGV, it is array
[03:51:39] Inside: you want to get the value of the arguments?
[03:51:47] Inside: it's ARGV, as r0bgleeson said
[03:52:03] treehau55: are you guys familiar with the pickaxe book?
[03:53:16] pontiki: treehau55: look at thor, methadone, GLI, even rake
[03:54:22] treehau55: so I have a ruby shebang set up in a file inside of a bin, it only works from the command line by name if I move it to /usr/bin, but how do other ruby programs do it so that it just works from gems installed from say the home directory. do I have to make it a gem myself?
[03:55:45] havenwood: treehau55: /usr/bin is in your PATH, as is your gem directory
[03:55:47] pontiki: treehau55: it should be set executable and placed someone on your PATH
[03:56:08] pontiki: if you have craeted it as a gem, you should be just need to install it
[03:56:41] treehau55: okay so in the future if I want other people to be able to use my program I should probably make it a gem, then if they install it as a gem, they will have it available to their cli, correct?
[03:56:56] treehau55: i wnat to avoid having to have users modify their path
[04:02:54] gearahol_: treehau55: http://www.awesomecommandlineapps.com/gems.html
[04:03:31] gearahol_: treehau55: actually http://robdodson.me/blog/2012/06/14/how-to-write-a-command-line-ruby-gem/ looks better
[04:03:52] treehau55: ive searched and found those as well, thank you
[04:04:00] gearahol_: treehau55: you need to create a executable for your gem
[04:04:09] sevenseacat: pragprog published a whole book on writing command line apps in ruby :p
[04:11:11] pontiki: it's a pretty good book
[04:11:19] pontiki: if a little breathless :)
[04:12:39] pontiki: i've been using methadone a fair bit
[04:13:07] pontiki: (it's by the guy who wrote the pragpog book Awesome Command-Line Applications
[04:46:41] treehau55: do most ruby apps have a "runner"
[04:49:25] pontiki: it would be much of an app if you couldn't run it...
[04:50:58] r0bgleeson: treehau55: if you can't run it then it becomes an API?
[04:54:02] pontiki: by API you mean library?
[04:59:02] r0bgleeson: pontiki: yeah
[05:00:46] treehau55: i mean is it convention to have a file called runner.rb and have that be executed in your bin executable?
[05:01:08] pontiki: not particularly that name, no
[05:01:22] pontiki: and not with an .rb extension, either from what i've seen
[05:01:26] r0bgleeson: it should be unique as possible
[05:01:39] r0bgleeson: your project name would work
[05:02:16] pontiki: like say you start your development doing `bundle gem my_cool_app`
[05:02:33] pontiki: that will create the directory structure
[05:03:06] pontiki: but then you still need the bin, and inside that what makes sense is a #!/usr/bin/env ruby file called just my_cool_app
[05:03:48] treehau55: so I have another problem the classes Date and Time don't seem to be compatible
[05:04:01] treehau55: so I can't do Date.new(Time.now)
[05:04:46] treehau55: is there a way to normalize their file formats to make them both use UTF
[05:04:52] r0bgleeson: treehau55: use Time#to_date.
[05:05:12] r0bgleeson: time? file formats? UTF-8? confused.
[05:06:57] treehau55: r0bgleeson, im confused too, there seems to be a Time referenced by Date, and then a whole nother seperate Time class
[05:09:21] treehau55: trying to figure out where sec_fraction is coming from in the Time source code, that could be just what I need
[05:09:47] r0bgleeson: treehau55: Time & Date are two separate classes, yeah, Date is not concerned about hours & minutes.
[05:13:34] treehau55: man aruba is great for cucumber testing a cli app
[05:14:54] treehau55: although not quite sure why its not picking up my puts statement, its definitely coming out to the terminal
[05:15:51] treehau55: Then /^I should see "(.*?)"$/ do |arg| assert_partial_output(arg, all_output) end
[05:18:13] pontiki: it's coming out to the terminal while you're running cucumber?
[06:17:13] L8D: Um...I'm having a problem...
[06:17:24] L8D: In my class I have a function that goes like:
[06:17:55] L8D: def clone; clone = self; clone.parent_id = self.id;return clone; end
[06:18:27] L8D: And whenever I use it, it causes both the clone and original objects to have the parent_id
[06:19:20] L8D: Actually, Both the clone and the original share the exact same object_id
[06:19:22] hackeron: is there a ruby way to check how full a filesystem is in percentage?
[06:20:03] sevenseacat: because youre just returning self from clone
[06:20:19] sevenseacat: not actually cloning anything
[06:20:21] L8D: `df`.split(" ")[12]
[06:20:29] sevenseacat: do you mean clone = self.clone ?
[06:20:49] L8D: `df`.split(" ")[11]
[06:20:59] L8D: Ooh, haven't seen self.dup
[06:21:13] L8D: ACTION plays checks if he can/should use self.dup
[06:21:24] L8D: checks*
[06:21:34] L8D: :s/plays //g
[06:23:02] L8D: self.dup fixed the sharing-the-same id problem, but I still have 'clone.parent_id = self.id' setting both self and clone
[06:23:08] L8D: 's parent_ids
[06:23:21] L8D: Is that intended behaivour?
[06:23:49] L8D: hackeron: `df`.split(" ")[11]
[06:24:20] L8D: Or better yet: `df`.split(" ")[11].to_i
[06:25:40] L8D: Nevermind, it did fix it
[06:25:49] hackeron: L8D: I meant a ruby way, not running a linux process - preferably something platform independent
[06:26:13] L8D: Okay...
[06:26:24] hackeron: L8D: also that shows me percentage on ubuntu but not on mac osx
[06:26:42] L8D: what do you get on mac? o.O
[06:26:52] hackeron: irb(main):001:0> `df`.split(" ")[11]
[06:26:52] hackeron: => "248390464"
[06:27:04] L8D: Try 12 then...
[06:27:28] hackeron: L8D: I won't it to work on both mac and linux reliably, but also no: irb(main):002:0> `df`.split(" ")[12]
[06:27:32] hackeron: => "222573016"
[06:27:52] L8D: Try 13...
[06:27:59] hackeron: lol, funny man
[06:28:12] L8D: Yes, I understand you need it cross-platform...
[06:29:40] L8D: hackeron: Well, if you want it to work cross platform, you're going to have to end up scanning the entire hard drive and gaining a sum of every file's size.
[06:29:41] hackeron: I can see a gem sys-filesystem which lets me do something like mb_available = stat.block_size * stat.blocks_available / 1024 / 1024 -- to get amount of MB available, but can't see a way to get the total number of MB available to calculate a percentage
[06:30:28] L8D: Whereas using something like sys-filesystem or the system command `df`, which use the systems built-in monitoring system.
[06:31:01] L8D: So either not use a gem, and just regex df to find the %, or use sys-filesystem in an obscure manor.
[06:31:33] hackeron: well, how do I get the total number of MB with sys-filesystem?
[06:32:35] L8D: I'm not sure...
[06:42:37] rrecio: Other day I went to a quora page which subject was why don't google use ruby? They were mostly saying its because of higher cost of infrastructure. What you guys think about that?
[06:43:26] rrecio: (..) and because ruby is slow.
[06:46:06] sevenseacat: i think it's misinformed.
[06:47:57] r0bgleeson: rrecio: there's some truth in it
[06:48:10] r0bgleeson: rrecio: but it isn't really that simple
[06:49:33] r0bgleeson: rrecio: the focus of ruby is developer happiness & productivity, there's some trade offs to pay for that.
[06:55:00] oceanbreeze: Hello guys. I am looking at the source code of an application, and found this expression class_eval <<-RUBY, __FILE__, __LINE__+1 i dont really understand, can you explain to me please
[06:56:17] hackeron: anyone knows how do I get the total number of megabytes on the filesystem with sys-filesystem?
[06:56:57] r0bgleeson: oceanbreeze: are you confused about __FILE__ and __LINE__ stuff or class_eval in general?
[06:58:56] oceanbreeze: whole expression
[06:59:43] r0bgleeson: oceanbreeze: there's a lot of different parts to explain but to give you a short answer it evaluates a string in the context of a class or module.
[06:59:44] jarin: oceanbreeze: It's adding methods to a class, and the __FILE__ and __LINE__+1 let it know what line number and file to output if there are any errors
[07:00:08] jarin: Er r0bgleeson is more correct than me about the first part
[07:01:18] jarin: But yeah you need the __FILE__ and __LINE__+1 because it doesn't know where it's at until you actually put that module into a class
[07:01:28] jarin: So without that you will not get very good error messages
[07:01:48] jarin: At least that is my understanding of it
[07:03:15] jarin: Without it you will get errors like: # (eval):1:in `name': undefined local variable or method `undefined_method' for # (NameError)
[07:03:37] jarin: With it, it will look like: # foo.rb:3:in `name': undefined local variable or method `undefined_method' for # (NameError)
[07:04:40] r0bgleeson: jarin: it sets __FILE__ and __LINE__ in the enclosing string or block as well, i think that is also important (besides the error reporting stuff)
[07:04:45] oceanbreeze: Aha, and _FILE_ is a refference to a file object? And _LINE_ is a refference to line in that _FILE_ object?
[07:04:47] oceanbreeze: So i case error will occure, error will be written in line of file? :)
[07:04:58] r0bgleeson: __FILE__ is just a string
[07:05:01] r0bgleeson: __LINE__ is a fixnum
[07:05:35] r0bgleeson: oceanbreeze: in the backtrace, the file(path) and line number will be used
[07:05:42] jarin: r0bgleeson: Ah ok I didn't know about that part, that is also important :)
[07:06:20] rrecio: What about the -RUBY part?
[07:06:25] rrecio: What is this
[07:06:28] r0bgleeson: that's a doc string
[07:06:48] r0bgleeson: just syntax for a multi-line string
[07:07:58] jarin: I never understood what the advantage of evaluating it as a string was, I guess string interpolation is useful in that case
[07:08:44] jarin: ok yeah never mind I get it now
[07:08:46] r0bgleeson: jarin: it is actually done for performance reasons, string is cheaper than proc
[07:08:52] jarin: Ah ok nice
[07:08:57] r0bgleeson: looks ugly as hell though
[07:09:01] jarin: Always much to learn in metaprogramming haha
[07:10:14] r0bgleeson: metaprogramming can end up confusing
[07:10:34] r0bgleeson: i try to use it sparingly
[07:14:23] Paradox: yo dawg we heard you like programming so we put some ruby in your ruby so you can make programs with your programs
[07:15:44] rrecio: ... and that's how the matrix was created.
[07:27:13] rrecio: Thats all for today folks. Thanks for your attention!
[07:43:35] lessless: how to securely access a potentially nonexistent hash element w/o raising en error?
[07:46:57] havenwood: lessless: by default nil is returned if the key isn't found
[07:47:18] havenwood: lessless: what do you mean by securely?
[07:48:27] lessless: havenwood, I mean nested elements
[07:48:57] lessless: like some['element']['that']['probably']['do_not_exist']
[07:49:05] lessless: NoMethodError: undefined method `[]' for nil:NilClass
[08:59:31] oceanbreeze: Guys, File.expand_path, automaticaly detects the whole path?
[09:00:18] oceanbreeze: I mean how its working?
[09:05:45] L8D: oceanbreeze: It takes the current directory...
[09:06:09] L8D: And prepends it to the path specified
[09:06:30] L8D: And does the special means for things like ../ and ~
[09:06:57] Mon_Ouie: Not really, e.g. File.expand_path("/foo/bar")
[09:07:09] L8D: Well, and /
[09:07:16] Mon_Ouie: It just takes a path (relative or absolute) and gives you an absolute path back
[09:08:05] Mon_Ouie: (for relative directories, it assumes the path is relative to the current directory or the second argument if specified)
[11:02:56] joshu: anyone used helios mobile?
[11:37:25] m00nlight: Hi, when I use rvm to install ruby
[11:37:30] m00nlight: it says : RVM was not able to detect your system type and does not know how to load extra library paths
[11:37:39] m00nlight: I'm using chakra linux
[11:38:01] m00nlight: How can I solve this problem
[11:41:02] ellipse: Have you read `rvm notes`?
[11:41:58] ellipse: That might be a good idea then.
[11:49:22] hackeron: anyone know a way to detect a plugged in hard drive with ruby on ubuntu?
[11:49:56] MrZYX: there's probably some dbus event you can listen to
[11:50:38] hackeron: MrZYX: a hal one but I believe hal was removed some time ago?
[11:50:57] maetthew: hackeron: Not sure if theres a Ruby way but you could execute system command `df` to find out which disks are mounted on your system
[11:51:07] MrZYX: I would be surprised if udev doesn't send one out
[11:51:33] hackeron: maetthew: the drives are not mounted - I can see the drive in dmesg but tailing/parsing that seems like a big hack
[11:52:03] maetthew: yeah it is kind of an ugly hack
[11:52:54] maetthew: is it an internal drive?
[11:53:09] hackeron: some times internal, sometimes USB
[11:53:29] maetthew: so you want to see it wether it's mounted or not, right?
[11:53:59] hackeron: no, I want to detect it, detect it's serial number and if it is in the list to mount it
[11:54:25] wuest: hackeron, what you're describing sounds like a textbook job for udev.
[11:54:32] hackeron: so to mount it when it plugged in and umount it in case someone unplugs it
[11:54:50] hackeron: wuest: hmm, is there an example to get udev to run a ruby script?
[11:55:10] hackeron: or a way for ruby to subscribe to these messages?
[11:55:35] wuest: Check the manpage for udev, look for RUN
[11:55:58] MrZYX: I'd still explore the dbus route
[11:56:12] MrZYX: org.freedesktop.UDisks2 sounds promising
[11:57:00] hackeron: MrZYX: hmm, is there an example how to use dbus with ruby? - I've done it with python before but can't see to find much info with ruby
[11:57:19] wuest: I could be wrong, but isn't dbus not guaranteed to be on a system? Most (all?) modern linuxes are going to have udev.
[11:57:23] MrZYX: a quick search on rubygems brought up https://github.com/mvidner/ruby-dbus
[11:57:43] hackeron: hmm, I'll check it out :)
[11:58:16] hackeron: wuest: I'm using ubuntu server and that seems to come with dbus by default
[11:58:20] wuest: ACTION isn't sure as to dbus's ubiquity. Is a KDE user, so dbus is a given.
[12:02:37] MrZYX: hackeron: https://github.com/shurizzle/em-udev a bit dated but could be interesting too
[12:03:19] hackeron: MrZYX: I saw it, but there's like no docs :/ - not obvious what it does if anything
[12:03:32] hackeron: it's only 60 lines of code in total from what I can see
[12:04:33] MrZYX: yeah, depends on https://github.com/shurizzle/rubdev
[12:05:13] hackeron: MrZYX: yeh, that one's docs aren't much better, lol
[12:05:26] MrZYX: time to read some code :P
[12:06:02] MrZYX: ruby is just not yet there as gui app language, sadly
[12:06:18] MrZYX: I could imagine nice APIs with blocks as callbacks etc
[12:07:06] linusoleander: How is Ruby is handling recursive calls?
[12:07:06] linusoleander: Will I have any problems if I used it over a long period of time?
[12:07:38] MrZYX: there's a stacklimit, yeah, so no tail recursion
[12:09:18] linusoleander: MrZYX: Aha, that's true
[12:11:08] hackeron: MrZYX: this isn't a gui app :)
[12:12:10] MrZYX: well, the true solution to your problem is probably not writing a ruby script but configuring udisks properly, but who am I preventing you from writing ruby? :P
[12:13:09] linusoleander: Is there a way to implement a safe tail recursion script in ruby?
[12:13:24] MrZYX: use a loop
[12:13:43] MrZYX: tail recursion is the functional style to write loops
[12:14:55] linusoleander: MrZYX: The code is async, so a loop won't work
[12:15:20] MrZYX: do you have a minimal example?
[12:15:39] linusoleander: MrZYX: I think I can scale down my current script, hold on
[12:18:36] linusoleander: MrZYX: https://gist.github.com/oleander/171fe603816ddc66ba17
[12:19:38] linusoleander: MrZYX: On line 7 (or if something goes wrong) I want it to wait for a while and start over again
[12:20:35] MrZYX: maybe I'm missing something but that's not recursive
[12:21:00] MrZYX: you call eventmachine, that call returns
[12:21:04] linusoleander: MrZYX: I know, It's what I'm trying to implement on line 7
[12:21:09] Xeago: on line 7 he wants to restart it
[12:21:29] MrZYX: you call the callback function, pass it a block, that saves it somewhere, and returns
[12:21:31] MrZYX: your function returns
[12:21:37] MrZYX: eh, method
[12:21:52] Xeago: linusoleander: there is no reason to use non-blocking methods if you are just waiting for it to finish
[12:22:19] MrZYX: some later point: the stored callback gets executed, outside of the process methods callstack
[12:22:39] MrZYX: but I might be missing something since I never actually used eventmachine
[12:22:41] linusoleander: Xeago: It's just an example code, my real application includes over 900 current requests per minute
[12:22:51] berdario: Hi, I upgraded ubuntu, and now rbenv always crashes, complaining that the old system ruby isn't what it was before
[12:23:26] Xeago: linusoleander: doesn't matter what the real code is, if you are waiting on the result of IO, use blocking IO or interleave it
[12:23:50] berdario: I'm looking into the shell scripts that make rbenv run... but I can't find where has it stored the assumption of the system version of being the old one
[12:24:04] linusoleander: MrZYX: Any idea?
[12:24:26] Xeago: linusoleander: you probably want a task queue
[12:24:46] Xeago: where you can queue up your tasks, and have multiple workers process a task
[12:25:34] linusoleander: That doesn't sound like my original problem
[12:25:37] MrZYX: linusoleander: so the http.callback call blocks until the passed block is executed?
[12:25:54] MrZYX: then it's not recursive
[12:26:09] MrZYX: no matter what you do inside
[12:26:34] berdario: weeeird... changing the global to "system" and then changing it back to a custom ruby, appears to have fixed it
[12:28:31] berdario: no, it still crashes -_-
[12:28:39] linusoleander: MrZYX: I know that it's not recursive atm
[12:28:52] MrZYX: linusoleander: _no matter what you do inside_
[12:30:14] daxim: what's the gem equivalent command-line of `cpan .`? specifically, I want to install a checkout of <https://github.com/ewilhelm/fpm>
[12:30:45] MrZYX: only guessing what cpan . does: gem build fpm.gemspec
[12:31:09] daxim: ok, and then?
[12:31:39] MrZYX: gem install ./fpm*.gem iirc
[12:31:41] linusoleander: MrZYX: https://gist.github.com/oleander/171fe603816ddc66ba17
[12:31:57] berdario: argh, in this repository there was a .rbenv-version
[12:31:59] linusoleander: Opps, a bit much code
[12:32:21] berdario: I think it's absurd to require a certain patchset just to run a piece of code
[12:32:24] daxim: that seems to work, MrZYX++
[12:33:18] wuest: berdario: I imagine that it provides you context regarding what patchset the code is known to work well under, rather than implying a hard requirement.
[12:33:56] berdario: wuest: true, but it would be better to provide context through the README
[12:34:05] berdario: this way, I'm forced to change the file
[12:34:12] wuest: README? What do you think this is, C? ;)
[12:34:23] wuest: I agree with you, to note.
[12:34:55] berdario: (that is under VCS, so if I'll ever want to do a pull request, I'll have keep in mind not to add this change)
[12:35:01] MrZYX: linusoleander: EventMachine::Timer.new(30) doesn't block either so perform returns before the block is executed
[12:35:13] L8D: I have a problem/question
[12:35:20] MrZYX: linusoleander: so still no recursion
[12:35:33] L8D: Let's say I have 4 variables, x, y, a, and d
[12:35:47] L8D: x and y start at 0 and represent a graph
[12:36:01] L8D: a represents a number between 0 and 360
[12:36:10] L8D: and d represents a distance to travel...
[12:36:28] L8D: How can I calculate how much to add to x and y based on the angle and distance?
[12:36:54] L8D: I'm more looking for a functon that takes a and d, and return x and y
[12:38:08] berdario: uhm... the gemfile requires rake 0.9, I have already installed rake 0.9.6 and it installed
[12:38:11] berdario: why is that?
[12:38:33] L8D: is radians what I'm looking for?
[12:39:05] MrZYX: berdario: most likely some other dependency you have restricts the requirement down to .2.2
[12:39:10] ellipse: Googling radians will aid you on your quest, yes.
[12:39:32] MrZYX: berdario: read your Gemfile.lock
[12:39:36] berdario: MrZYX: is there an easy way to see which dependency restri...
[12:39:38] L8D: ACTION is now looking at the wikipedia article
[12:39:50] L8D: this is what I'm looking for...
[12:39:53] L8D: thank you
[12:39:59] linusoleander: MrZYX: I think you should do some reading about EM :)
[12:40:28] berdario: MrZYX: there's only one rake item, and it's under "specs:"
[12:40:55] berdario: to me, it seems to mean that the restriction doesn't come from other packages, isn't it?
[12:41:33] MrZYX: linusoleander: http://eventmachine.rubyforge.org/EventMachine/Timer.html the first sentence demonstrates that you can cancel a timer and that it never executes the block because of that, that means the call returns before the block is executed, that means the block is executed outside the call stack of your current method, that means it's no recursion but a loop somewhere
[12:41:55] MrZYX: berdario: gist your Gemfile and Gemfile.lock then
[12:42:18] L8D: I see how radians are relevant, but I don't see how using will help me solve my problem.
[12:42:26] linusoleander: MrZYX: "Somewhere" as my code or in EM?
[12:42:57] berdario: MrZYX: http://dpaste.com/1247546/
[12:42:58] linusoleander: MrZYX: Yeah, they have an event loop somewhere
[12:43:47] MrZYX: berdario: okay looks like the lock was built when .2.2 was the latest version, if you want to get to .6 run bundle update rake
[12:45:32] berdario: MrZYX: uhhhh... you're right... I checked the git status, and indeed Gemfile.lock was already there (I thought it was created when I ran bundle install)... thanks!
[13:02:47] L8D: Is it possible to define your own methods for standard classes?
[13:05:28] tobiasvl: go right ahead
[13:06:26] zets: L8D: yeah, that's one of the nice things about ruby
[13:07:38] L8D: How can you deinfe your own methods for standard classes?
[13:07:43] L8D: define*
[13:08:10] tobiasvl: the way you define any old method
[13:08:19] tobiasvl: class String; def foo; return; end; end
[13:08:33] L8D: That works? And doesn't break the String class?
[13:08:48] tobiasvl: it works. what do you mean "break"?
[13:09:18] joonty: tobiasvl: I'm guessing L8D isn't used to languages where you can open up existing classes
[13:09:18] L8D: cause the String class to not have it's original methods
[13:09:30] tobiasvl: L8D: it keeps its original methods
[13:09:31] L8D: Ruby is awesome
[13:09:32] zets: it won't override any of String's current functionality
[13:10:09] L8D: 10.times { puts "Ruby is awesoe" }
[13:10:22] MrZYX: in fact you can dynamically define methods on any object, that's how class methods work in ruby
[13:10:24] L8D: .gsub(/awesoe/, "awesome"
[13:10:43] L8D: Is there any way to prevent that then?
[13:11:00] L8D: prevent the overriding of existing class methods
[13:11:06] MrZYX: a = "foo"; b ="bar"; def a.yay; puts "yay"; end; a.yay #=> yay; b.yay #=> NoMethodError
[13:11:32] L8D: Well crap
[13:13:51] tobiasvl: sure there is
[13:14:39] MrZYX: tobiasvl: how?
[13:14:57] tobiasvl: String.freeze
[13:15:21] L8D: Can you do that for specific methods?
[13:37:06] jrhe: Hi. What is the recommended way of storing database queries in the database itself? Point in question is that I have a load of reports that need to be run in an app than themselves are sql snippets / active record relations. Is there some way I can serialise them and deserialise them?
[13:37:19] jrhe: The relation itself rather than the data returned.
[13:39:52] ccooke: jrhe: a Better Solution would be stored procedures, to be honest
[13:40:21] jrhe: ccooke: Why?
[13:40:59] ccooke: because stored procedures were designed to do what you're talking about - be callable, pre-determined blocks of SQL.
[13:41:04] jrhe: ccooke: I still need to be able to tie it to an activerecord model instance
[13:41:18] ccooke: Storing sql *in* sql means you're going to have to take *great* care not to allow SQL injection attacks
[13:41:21] jrhe: Which contains the name of the query and whatnot
[13:45:16] jrhe: ccooke: Surely so long as I use prepare I should be ok?
[13:45:58] ccooke: jrhe: No, that's no defence at all.
[13:46:48] ccooke: the problem is that SQL-in-SQL is more fragile, requires more complex code and requires you to - at some level - accept that you're going to be executing SQL that's not been entirely deemed as "safe"
[13:47:31] ccooke: wheras a stored procedure is built-in to the DB.
[13:48:20] jrhe: ccooke: I will research it. I don't see quite how it will alleviate that problem but I don't think I know enough about stored procedures.
[13:48:24] ccooke: there are compromises, of course. It all depends on what you need. But the general advice is always *not* to store SQL in a DB
[13:48:40] ccooke: jrhe: what sort of SQL do you actually need to store?
[13:49:23] ccooke: is it *really* arbitrary, or could you actually handle it with (effectively) a number of functions and the parameters to them?
[13:49:25] jrhe: ccooke: Its all reporting queries so mainly selecting fields from a bunch of joined tables which meet some condition. No updates, inserts etc.
[13:49:54] ccooke: jrhe: is there commonality in the tables and the way they're joined?
[13:50:45] jrhe: ccooke: Cheers for the help btw, you are helping me ask the right questions! Nope, other than that they are selects it can be pretty arbitrary. Its basically looking over a rails apps database and generating reports from it. They can be from any tables, composed in anyway.
[13:50:47] ccooke: jrhe: Could you handle it by - effectively - having a few functions that spat out generic SQL to do the select, then return only the data the report asked for?
[13:51:08] jrhe: ccooke: Too much data, would be better to do it at a db level for efficiency
[13:51:16] ccooke: jrhe: that's not the point :-)
[13:51:23] ccooke: jrhe: could it be done that way?
[13:51:36] jrhe: but I think it would be very very very very slow
[13:51:57] ccooke: the reason I ask is, if your were to implement the generic select as a stored procedure and then use that in another SQL statement, the DB does all the optimisation
[13:52:20] jrhe: Ahh right I see
[13:52:34] ccooke: you can even have the stored procedure take a list of field names to return and have it generate its code directly
[13:53:12] ccooke: then you could get your report structrue down to the name of a stored procedure to call, plus the parameters to pass to it.
[13:54:10] ccooke: the downside is you'd need a new stored procedure every time a *completely* new report was used, but every report that's on effectively the same data can use the same function
[13:54:32] jrhe: ccooke: It seems that AR adapters implement a select method, maybe this would do the same
[13:54:33] ccooke: (and stored procedures are fully turing complete, so you *can* have them change the structure they generate based on parameters)
[14:00:33] d4x: anyone can help me to convert a file size to human readable string, using number_to_human_size in ActionView::Helpers::NumberHelper :?
[14:12:23] mwlang: does anyone know where 'getopts' comes from or how to figure it out? I installed a gem that apparently doesn't declare all its dependencies correctly.
[14:13:02] mwlang: I found and installed the "getopt" gem, but that wasn't it.
[14:14:00] momomomomo: mwlang: Paste your stack trace to http://gist.github.com
[14:18:37] mwlang: momomomomo: https://gist.github.com/mwlang/5797220
[14:19:11] mwlang: (yes, I'm running Ruby 2.0 on Raspberry Pi) :-)
[14:21:30] momomomomo: I've got to run mwlang but did you run rvm requirements? Here's a similar situation - you're missing libraries: http://stackoverflow.com/questions/15545639/cant-install-rubygems-with-ruby-2-0-0
[14:22:00] mwlang: momomomomo: I did not know about that…will check it out.
[14:23:00] mwlang: momomomomo: it didn't take any further action.
[14:23:07] momomomomo: mwlang: http://rvm.io/rvm/install - The docs are very helpful, especially if you haven't installed dvm before
[14:23:39] mwlang: that's what I followed to install rvm
[14:23:46] momomomomo: Gotta run, if you still have issues, and you've installed all of the correct libraries - and still have issues, come back and ask
[14:23:50] mwlang: might be a problem in that I attempted the multi-user install.
[14:29:48] jrhe: ccooke: I know its turing complete but that doesn't say much to its usefulness!
[14:30:00] jrhe: ccooke: turns out my db doesnt support prepare anyway
[14:30:09] jrhe: jrhe: Investigating stored procs now
[14:33:37] joshu: probably a silly question but I'm using postgres for the first time. If you create new entries and then delete them. Is it normal that the next next entries don't being at id 1? If that makes sense?
[14:40:08] ericwood: that's not really a ruby question...
[14:40:42] d4x: and what is :P
[14:40:51] d4x: ACTION in console
[14:40:52] ericwood: a question about ruby is
[14:44:06] d4x: ericwood it's about using a class
[14:44:30] d4x: in irb start with require 'rubygems' require 'action_view'
[14:44:46] ericwood: you asked a plain SQL question
[14:44:50] ericwood: idk I'm not reading scrollback
[14:44:51] ericwood: so ignore me
[14:45:07] d4x: ah sorry
[14:46:07] d4x: anyone else can help using this method which is always undefined ...till now :)
[14:49:21] r0bgleeson: joshu: that's normal
[14:50:06] joshu: r0bgleeson thanks
[14:51:27] Harzilein: anyone here involved with ruby-vim?
[14:51:33] Harzilein: which template script would you recommend using it with?
[14:51:42] Harzilein: most template scripts assume mapping ft to template, so i can't make e.g. a rakefile template
[14:51:51] Harzilein: (also asked this on #ruby-lang)
[14:51:53] senayar: https://github.com/vim-ruby/vim-ruby
[14:53:58] Harzilein: senayar: uhm, i know where vim-ruby is maintained, so?
[14:54:16] Harzilein: s/ruby-vim/vim-ruby/ that your complaint?
[15:14:07] rh1n0: Hello rubyists. Im trying to create bash scripts using ruby. Is it possible to use a heredoc to create a multiline script or bash (for example) invocation?
[15:14:36] rh1n0: i was previously creating a file and piping the contents to the file then executing the file but that seems wrong
[15:17:17] rh1n0: here is a gist to explain what i mean: https://gist.github.com/rrichards/f6a603004e03e428bcb0
[15:26:16] Spooner: rh1n0, Why on earth you'd want to do that, when you could just run Ruby to do it, is anyone's guess ;)
[15:26:45] rh1n0: Spooner because i couldn't figure out how to do it with bash :)
[15:26:53] rh1n0: just curious
[15:26:56] Spooner: Are you trying to run Ruby from bash or bash from Ruby?
[15:27:02] rh1n0: bash from ruby
[15:27:16] rh1n0: pragmatic bash programming - NOT :)
[15:27:55] Spooner: Yeah, but anything you can do in bash you can do better in Ruby. Isn't it better to ask how to do whatever you think you need bash to do in Ruby?
[15:28:01] rh1n0: i have a bunch of bash scripts I'm using for amazon autoscaling. I want to trigger them from a ruby file being used for user-data when an instance is launched. I could do it in ruby but would need to re-write my bash scripts.
[15:28:15] ccooke: Spooner: there are definitely times when it's better to use shell than bash
[15:28:33] ccooke: I've been writing bash fragments in ruby for the last three weeks for work, actually
[15:28:38] Spooner: Oh right, just running scripts. Thought you meant heredocing the scripts inside the Ruby and then running them in sh.
[15:28:39] joonty: yup, like named pipes
[15:28:48] joonty: in fact, command redirection in general
[15:28:53] ccooke: rh1n0: I can't share the code (atm), but yes, a here doc is fine
[15:29:13] rh1n0: thanks all - at least I know I'm not losing my mind yet
[15:29:18] ccooke: Spooner: my use case is maintenance. When doing maintenance on servers, you're working with files, folders, processes, signals, etc.
[15:29:36] rh1n0: ccooke: right - this is all server stuff I'm doing
[15:29:43] ccooke: Spooner: shell has better tools for dealing with that than anything else, and whats more practically *everyone* can do a bit of shell script.
[15:30:10] ccooke: What shell lacks is the ability to synchronise invocation across multiple locations and ways to pass data back to subsequent scripts
[15:30:15] ccooke: So I have all of that in Ruby
[15:30:18] rh1n0: Storimer's book on ruby processes is very good though - I'm sure you could do everything needed in ruby i just don't have the time to rewrite the scripts yet
[15:30:43] ccooke: rh1n0: even if you *can* do it, that doesn't mean ruby is the right tool for the job. In this case, it simply isn't.
[15:31:00] rh1n0: ccooke: very true
[15:31:54] ccooke: the best part of the code I'm writing is that only I (and anyone who admins the system) need to understand ruby. All the people who create a maintenance need to know is a little shell and some documentation on the shell builtins I'm suppplying.
[15:33:05] Spooner: rh1n0, Anyway, you could use a tempfile thus: https://gist.github.com/Spooner/f4441aa7416da9f37837
[15:33:44] rh1n0: Spooner: thanks - thats actually what i was doing before. It works for sure.
[15:34:13] rh1n0: Spooner: actually no, i was piping each line to the temp file. This solution is even better and good enough.
[15:35:37] Spooner: rh1n0, You can use -e to run arbitrary Ruby in the Bash (I updated the gist).
[15:36:21] rh1n0: Spooner: true - i always forget about the -e switch
[16:23:18] hnordt: Dir.glob('tests/\**/*Test.php') what "\**" means?
[16:23:30] dirk1: it means go into all folder recursively
[16:23:35] joelteon: you can remove the \
[16:24:21] hnordt: this line is written in a book about TDD, I dunno why the author scaped the first *
[16:24:45] joelteon: yeah, that's weird
[16:24:47] joelteon: just take out the \
[16:24:56] joelteon: well hang on, no
[16:24:59] joelteon: that's a literal \ and a *
[16:28:42] hnordt: joelteon: why the literal \ is necessary?
[16:28:51] joelteon: I don't think...
[16:28:58] joelteon: unless he's looking for every directory that starts with a \ character
[16:29:00] joelteon: but nobody does that
[16:31:16] hnordt: thank you joelteon
[16:44:32] BarneyRubble: basic haml q i am stuck on - to make this <div class="foo bar" is ok I can do it in a loop fine - but i need <div class="foo bar0" then bar1,2,3 etc using the iterator i - and i keep rearranging it and nothing is working - i understand the syntax is ruby so can anyone suggest a method for me to try?
[16:44:53] joelteon: .foo{:class => "bar#{i}"}
[16:46:59] joelteon: yeah, you can combine .class and :class => "..."
[16:50:15] BarneyRubble: joelteon, that is new syntax to me but it worked, almost perfect, that gives me - div class='bar0 foo' van i force it to div class='foo bar0' ?
[16:50:26] joelteon: why would you do that?
[16:51:14] BarneyRubble: dont have a reason except it is in the html i need to generate
[16:51:24] MrZYX: it's equivalent
[16:51:31] davidcelis: BarneyRubble: HTML doesn't care how classes are ordered
[16:51:34] davidcelis: it's the same
[16:51:52] BarneyRubble: learn smth new every day
[16:57:06] codezombie: is there a good way in ruby via regex to match a pattern, but don't count duplicates? For example, this pattern: (?=(\w{4})) that works, but returns duplicates. I'd like to do something like... /(?=(\w{4}){1})/ However, this doesn't work. The result from the first regex returns over 100k results. Looping through 100k results to remove duplicates is really, really slow in ruby. I'd like to speed it up.
[16:58:43] apeiros: codezombie: a) how do you remove the duplicates? b) use scan + Set
[17:00:23] codezombie: apeiros: I've tried a few ways to remove the duplicates... 1st, by using a select block, and checkout the count with array.count(str). 2nd, byt using delete_if with and checking the count. 3rd by using a regex to find the duplicate entries, and then looping over just the returned duplicates, and calling delete... All of that was really slow.
[17:00:32] codezombie: apeiros: can you elaborate a bit more on + Set?
[17:01:23] apeiros: codezombie: well, no wonder that's slow. why didn't you simply use Array#uniq?
[17:01:29] codezombie: however, set won't work because I need to remove all instance of the duplicate... so, in the instance of %w[a b c a] I should only return %w[b c]
[17:01:36] apeiros: it's O(n), unlike your O(n^2) or worse custom solutions…
[17:01:56] codezombie: apeiros: because uniq leaves one of the duplicate values... if > 1 exists, remove them all.
[17:02:44] codezombie: yeah, so to my example... %w[a b c a] should result in %w[b c]
[17:02:56] apeiros: I'm not sure whether your explanation still makes sense - might just me being tired, though.
[17:04:57] codezombie: k, let me try this way... take this into account: "a,b,c,a". There's 2 a's in the array. I want to remove them both, and leave only the unique values, resulting in "b,c".
[17:05:35] codezombie: I'm not sure how to break it down other than that. :/
[17:05:50] apeiros: I don't see the connection to your initial question
[17:05:57] apeiros: but for your current question, you'd use a counting hash
[17:06:31] apeiros: h = Hash.new(0); ary.each do |item| h[item] += 1 end; h.select { |k,v| v == 1 }.keys
[17:07:52] codezombie: apeiros: it's a simplified version. basically, "a,b,c,a" is the result of the first regex (?=(\w{4})). 4 being a arbitrary number, just specifiying length to match. Could be 1, could be 100... Anyhow, I'd like to (if possible) modify the regex to not return the duplicates, so no further processing is required.
[17:08:23] codezombie: I think I need more caffeine.
[17:09:19] codezombie: loops, no matter what I do in them are slow, since the number of iterations can be 100k+
[17:10:16] apeiros: codezombie: you need to understand big-O
[17:10:33] apeiros: if you loop inside a loop, that's quite a lot slower than a single loop
[17:10:40] apeiros: 100k iterations don't take that long.
[17:10:46] apeiros: 100k^2 iterations - yes, that hurts.
[17:11:06] apeiros: and that's what array.count(str) in an array.select does.
[17:11:39] codezombie: ah, yeah that makes sense.
[17:11:50] terrellt: Ah, O(n), how I love you.
[17:12:30] apeiros: and no, you can't tell a regex to not match a previous match again in any sane way.
[17:12:46] apeiros: but I'm pretty sure you can go about your real problem differently.
[17:13:20] davidcelis: terrellt: not as much as O(log n)
[17:13:23] codezombie: lies! regex is the answer to all of our problems! ;)
[17:13:28] davidcelis: or, better yet, O(1)
[17:13:31] wuest: codezombie: now you have 2 problems.
[17:14:36] apeiros: [9] pry(main)> pbench 5,1 do c=Hash.new(0); ary.each { |i| c[i]+=1 }; c.select { |k,v| v == 1 }.keys end
[17:14:37] apeiros: ø 166.000000ms (0.0%)
[17:14:47] apeiros: don't know about you, but I think 166ms isn't "slow"
[17:14:55] apeiros: ary.size == 100_000 btw.
[17:16:13] codezombie: yeah, I was speaking in terms of the list I was working with. However, I think I've got an idea based on your example. Thanks.
[17:17:16] Paradox: http://i.imgur.com/2RT1Kn7.gif
[17:24:49] codezombie: apeiros: thanks again, that works perfectly
[17:58:20] MarcWeber: is there a standard way to run compilers using rake, such as ocamlopt?
[18:03:15] Xeago: which patch version of 1.9.3 is recommended
[18:03:57] lectrick: Does anyone have any opinion on exposing simple sequential integer ID's (database ID's) in an API (or not)?
[18:04:13] lectrick: I'm wondering when the time is to consider GUID's
[18:05:02] Xeago: lectrick: usually GUIDs come in to play once you have to generate keys across multiple locations at the same tim
[18:05:39] havenwood: Xeago: Why no p429?
[18:05:43] lectrick: Since API's are partly to facilitate interoperability between systems, I felt that database ID collision suddenly becomes more of a factor
[18:06:35] Xeago: havenwood: more widespread use, seemed to be the most popular one of the 1.9.3 series
[18:06:41] Xeago: but 429 is fine I spose
[18:07:16] Xeago: lectrick: tell your API consumers to treat keys as variable length strings, they won't generate them
[18:07:31] Xeago: Don't get how those would collide?
[18:08:15] Xeago: If I remember correctly the standardized ISO has 56bits more than plenty for most usecases
[18:09:06] lectrick: Xeago: If we expose simple database ID's, and they wanted to import any of that data and it was relational, ID collision becomes an issue mitigated by UUID's
[18:10:52] Xeago: lectrick: still don't see the problem, if you are generating the ID's on atomically (on 1 machine or multiple in communication) there is no problem
[18:16:04] BarneyRubble: another basic question, this time of concepts not syntax, can haml and scss share variables?
[18:16:39] MrZYX: I guess that's more a #RubyOnRails question
[18:18:01] Mon_Ouie: MarcWeber: There's the rule syntax to specify how to use it (like make's rules if you're familiar with them) and inside those rules you'd just use the #sh method to call your compiler with the input file
[18:19:14] BarneyRubble: MrZYX, trying now thx
[18:21:51] Kopukkk: sohbetkedisi.c...o...m YEN SOHBET ADRESMZZZZZZZZZZZZZ ....
[18:22:04] MarcWeber: Mon_Ouie: :-) Thanks. Exactly what I was looking for.
[18:30:58] Havoc_: Anyone know why this isnt working http://pastebin.com/mT70gJ4L
[18:34:08] MrZYX: Havoc_: please include the real exception you're getting and the real code, your examples contain no interpolations
[18:34:34] MrZYX: also have a look at File::read
[18:36:44] Mon_Ouie: Also, you'll want to use CGI.escape rather than substituting manually
[18:40:38] Havoc_: Here is the real code http://pastebin.com/L6XvP5Bc
[18:41:36] Mon_Ouie: Probably because you have a line return at the end of your file or something similar
[18:42:22] MrZYX: Havoc_: also gsub! may return nil if it didn't actually modified anything
[18:42:48] MrZYX: (you want the non bang version)
[18:42:59] AndChat|: Mon_ouie, 'lutte
[18:43:01] Havoc_: I had some puts in there, it appears to be modifying it to 100+Avery+St
[18:43:35] Mon_Ouie: Use 'p', not 'puts', to see what the string really is (there can be non-visible characters in there)
[18:43:58] Mon_Ouie: You should still use the methods that have been mentioned earlier and File.write takes a file name, not a file object
[18:44:21] MrZYX: Havoc_: File.write wants a filename as first argument, no File object
[18:44:37] MrZYX: ah, too slow
[18:44:57] Mon_Ouie: AndChat|: 'alut
[18:46:31] Havoc_: I search the cgi.escape.. didnt find anything in the core 2.0 docs... found regexp.escape
[18:46:52] Mon_Ouie: It's not in core, it's in stdlib. You need require 'cgi' to use it.
[18:48:12] Havoc_: Is it just slower to use a file object for File.write.. cause it seems to work when provided with the file object too?..
[18:50:10] Mon_Ouie: Oh, so it does. Well, it is more "dangerous" because the file won't be closed if File.write raises an exception for some reason
[18:50:33] Mon_Ouie: If you use File.write with a filename it will take core of closing it itself, avoiding any such issues
[18:50:53] Mon_Ouie: (You generally want to use File.open with a block when you can't use File.read/File.write directly)
[18:51:19] Havoc_: Ah you are right.. there is a /r/n in the file
[18:51:43] Mon_Ouie: Use String#chomp to remove it
[18:52:48] MrZYX: If I recall correctly there was some method File::write etc calls on the filename argument, which returns the opened path for IO objects
[18:52:56] MrZYX: so you're opening the file twice this way
[18:53:00] Havoc_: Ah nice, its working now
[19:26:49] brice_: im new to ruby/irc
[19:27:01] brice_: so..what do you guys talk about here? haha
[19:29:45] havenwood: brice_: About the new look of Github repos... what do you think?!
[19:30:12] MrZYX: it's active already for you?
[19:30:29] havenwood: MrZYX: Ya, a banner popped up offering.
[19:30:40] havenwood: MrZYX: I figured it did for everyone? Maybe they're doing a gradual rollout?
[19:30:51] brice_: nothing changed for me yet
[19:30:52] MrZYX: according the the blog post they do
[19:31:05] MrZYX: did get the banner yet
[19:31:09] MrZYX: did you recall the link? :P
[19:32:21] brice_: MrZYX and havenwood: hi guys, i still dont know much about github. i just got into ruby/rails last month.
[19:32:58] havenwood: brice_: Lots of great Ruby to read on the Githubs and open source projects to contribute to.
[19:33:39] brice_: havenwood: what does it mean to contribute? im still a noob...what do i have to contribute? haha
[19:33:56] havenwood: brice_: A great thing to contribute early on is documentation!
[19:34:23] brice_: havenwood: is contributing like offering advice?
[19:34:32] havenwood: brice_: I had fun doing manpages for chruby and ruby-install. Been meaning to write a less-pathetic manpage for gem.
[19:35:15] havenwood: brice_: Contributing is everything from opening an Issue ticket with a feature idea or bug you've noticed, to fixing typos in the README.md, or adding code.
[19:35:33] brice_: havenwood: ohh i see
[19:35:50] brice_: havenwood: i can def do spell check..
[19:36:07] havenwood: brice_: Fixing README typos is a way to contribute if you can't write code at all but you can spell! (I can't.)
[19:36:34] brice_: havenwood: hahah. what would you say are good ways to practice coding in ruby?
[19:36:58] havenwood: brice_: The list of resources on ruby-lang is a good start: http://www.ruby-lang.org/en/documentation/
[19:37:07] brice_: havenwood: i followed hartl's rails tutorial, agile web depot tutorial. i succesffuly deployed it, but dnt really understand the concepts
[19:37:24] havenwood: brice_: Definitely take tryruby.org for a spin, especially if you're new to programming.
[19:37:41] havenwood: brice_: A hint, if you sign up for free CodeSchool account, TryRuby.org will save your place.
[19:37:54] brice_: havenwood: any cool open source projects you know in particular that could use my spellchecking services?
[19:38:08] havenwood: brice_: RubyKoans are great. Bit steeper learning curve, but nice to start on and go further as you're able.
[19:38:59] havenwood: brice_: Anything of mine is probably spelled terribad: https://github.com/havenwood
[19:39:27] brice_: havenwood: i will start there then!
[19:39:43] havenwood: brice_: Would be awesome if you'd want to give chruby README and Wikis a look! https://github.com/postmodern/chruby
[19:39:52] havenwood: brice_: That is used by more and more people. ^
[19:40:17] brice_: havenwood: whats chruby?
[19:40:21] havenwood: brice_: Or ruby-install too. Less to review there: https://github.com/postmodern/ruby-install
[19:40:39] havenwood: brice_: It is a system tool to select your current Ruby.
[19:41:03] havenwood: brice_: So if you have JRuby and Ruby installed, you can choose to use Ruby like `chruby ruby` and JRuby like `chruby jruby`.
[19:41:18] havenwood: brice_: It sets the environment variables correctly to point at the Ruby you've chosen.
[19:41:32] brice_: havenwood: oh ok. so if i see a typo, how do i change it?
[19:41:39] havenwood: brice_: It is an alternative to tools like RVM and rbenv.
[19:42:18] havenwood: brice_: The chruby and ruby-install projects are actually written in Bash, not Ruby. :O
[19:42:45] havenwood: brice_: In the Wiki, just click edit, explain your change, and its changed.
[19:43:17] havenwood: brice_: For the README.md, click on the file in Github and click edit, and you'll be guided through a pull request.
[19:43:58] havenwood: brice_: Wiki and pull requests, etcetera can be done from the command line - but the Github GUI makes it accessible.
[19:44:37] havenwood: brice_: Also, grammar and spelling in comments that are in the code itself often can use some love.
[19:45:16] havenwood: brice_: Like here is an example documentation fix: https://github.com/postmodern/ruby-install/commit/a7850283bb7da9881d8c4529eae96780f67078e3
[19:46:38] brice_: havenwood: oh cool. how do i edit stuff like that? is there an edit button for that too
[19:47:20] havenwood: Yeah, you can browse through the files in a project and click and hit edit.
[19:47:53] brice_: appreciate all your help by the way
[19:47:57] havenwood: Easier to do for quick changes than to fork the repo, branch it, commit the change, pull request.
[19:48:47] havenwood: brice_: No prob. Oh, if you don't already know, #RubyOnRails is the Rails channel if you end up doing more Rails. Here is Ruby.
[19:50:18] PigDude: has anyone seen this? ruby gem reported as missing but it is installed: http://bpaste.net/show/iJAKFpTzIR8Ect3HU9S3/
[19:56:15] havenwood: PigDude: Try running `bundle` to install the gem dependencies in your Gemfile.
[19:56:21] havenwood: PigDude: Ick, 1.8! :P
[19:56:28] havenwood: PigDude: Can you switch to Ruby 2.0?
[19:56:38] havenwood: PigDude: 1.8 is end-of-lifed.
[19:56:43] PigDude: havenwood, it's an old application, but what's weird is that this started happening all of a sudden
[19:56:52] PigDude: havenwood, its a ruby 1.8 rails 2 app
[19:56:57] havenwood: PigDude: ah
[19:57:16] PigDude: is there a way to get some more verbose output out of rake?
[19:57:26] PigDude: really strange for the path to change in the middle, or something
[19:58:28] PigDude: hm, nothing interesting with --trace
[20:00:04] ericwood: --trace will show you real stack traces on failures
[20:00:14] ericwood: it's up to the task to give more/less verbose output
[20:00:18] ericwood: it's not rake's fault
[20:04:02] LucasTT: what is the best place to learn ruby?
[20:07:00] blitz: LucasTT the official ruby site http://www.ruby-lang.org/en/documentation/quickstart/
[21:03:23] mwlang: I have installed a gem that is failing when encountering the following line: "require 'getopts'" This is on Ruby 2.0. Does anyone know what provides getopts?
[21:04:36] thoughtpunch: Have you tried manually installing the 'getopts' gem? http://rubygems.org/gems/getopt
[21:05:10] mwlang: but getopt doesn't seem to be the same as getopts
[21:06:10] MrZYX: looks like getopts was removed in ruby 1.9 already
[21:08:08] mwlang: so it was part of stdlib prior to ruby2?
[21:08:15] MrZYX: prior to ruby 1.9
[21:08:28] mwlang: I skipped 1.9. :p
[21:08:54] mwlang: is there a gem out there to provide a drop-in replacement?
[21:09:14] MrZYX: I'd rather suggest you seek an alternative to a gem that still requires it
[21:09:18] mwlang: to be fair, I'm updating a gem that purported came from ruby 1.4
[21:09:46] MrZYX: ruby 1.8 is EOL, 1.9 is out for many years now, if it wasn't updated yet it'll never be
[21:10:00] MrZYX: and that might be just the first thing it errors out at
[21:10:03] mwlang: I'm trying to find a library that binds to libpcap
[21:10:50] mwlang: actually, I'll try replacing with Trollop and see how far I can get quickly with that approach.
[21:12:12] MrZYX: quick rubygems search: https://github.com/shadowbq/pcaprub https://github.com/sophsec/ffi-pcap https://github.com/ickymettle/ruby-pcap and a dozen others that aren't that recently updated
[21:13:05] mwlang: yeah, I just now saw ffi-pcap myself while hunting again.
[21:13:10] mwlang: I'll try that one out.
[21:15:25] NorxMAL: What does .to_s() do?
[21:15:45] NorxMAL: I'm unfamiliar with ruby, but I'm trying to understand some code
[21:15:48] MrZYX: NorxMAL: get a shell, type irb, try it out
[21:15:56] LucasTT: turns the integer/float to a string
[21:16:10] MrZYX: not only numbers
[21:16:13] NorxMAL: What would 37726 become?
[21:16:22] MrZYX: get a shell, type irb, try it out
[21:16:30] NorxMAL: Thank you :)
[21:16:57] LucasTT: it turn it to a string
[21:17:12] MrZYX: generally speaking #to_s asks the object to return a string representation of itself
[21:17:37] NorxMAL: url = url + "&qteam=" + fah_team.to_s()
[21:17:52] NorxMAL: I forgot where I was going xD
[21:18:03] MrZYX: url += "&qteam#{fah_team}"
[21:18:16] MrZYX: eh, plus the missing =
[21:18:29] NorxMAL: if fah_team is 37726, it would become &qteam=#{fah_team} ?
[21:18:41] NorxMAL: if fah_team is 37726, it would become &qteam=#{37726} ?
[21:18:54] MrZYX: no &qteam=37726
[21:19:02] NorxMAL: okay, thanks a lot :)
[21:19:34] NorxMAL: I don't have readilly access to a shell :)
[21:19:52] MrZYX: why's that?
[21:19:53] NorxMAL: I'm trying to debug a site
[21:20:22] NorxMAL: Or rather, understand how the script does a certain thing
[21:21:01] NorxMAL: Well, it's input is "37726", so it still becomes &qteam=37726 right?
[21:21:30] NorxMAL: You have saved me a ton of time :)
[21:21:40] Spooner: NorxMAL, http://repl.it/ if you don't have a shell (though you could just install Ruby locally and run irb).
[21:22:03] MrZYX: Spooner: :(
[21:22:09] MrZYX: Ruby 1.8.7 (2008-05-31 patchlevel 0) [x86-linux]
[21:23:37] apeiros: kill it? with fire?!?
[21:24:23] MrZYX: I guess even http://joshnuss.github.io/mruby-web-irb/ would be better
[21:24:36] MrZYX: and that doesn't even keep state
[21:24:37] Spooner: MrZYX apeiros, Yeah, well, it beats using us as IRB ;) But yeah, there are probably better repls.
[21:24:41] Spooner: *web repls
[21:58:23] DrIDK: Could someone explain how this is possible http://intridea.github.io/grape/docs/index.html They call keyword directly inside the class.. format :json, helper do etc....
[22:00:48] slash_nick: DrIDK: something like this https://github.com/rthbound/protected_record/blob/master/lib/protected_record/dirty_model.rb ... add "include PR::DirtyModel" to any model to provide the method "protected_keys"
[22:02:50] DrIDK: it's something like attr_reader :name
[22:02:59] DrIDK: I don't understand how it works
[22:03:08] DrIDK: is it possible to create : my_stuff :namer
[22:04:19] pontiki: DrIDK: is the question you're asking "how does a DSL work?"
[22:04:48] pontiki: DSL == Domain Specific Language
[22:05:30] DrIDK: pontiki, I dont know what's a DSL.. so, I will search it as a keyword , thx
[22:06:12] pontiki: you are welcome
[22:06:25] pontiki: martin fowler might be the name to start with in that regard
[22:06:40] slash_nick: It seems like he's wanting to create his own class methods to call inside the class... methods like "attr_reader :blah", "format :json", "helper do;end"
[22:07:45] pontiki: that's how you do it
[22:08:24] pontiki: rspec provides a DSL, capybara provides a DSL, many many areas have had DSLs made; rake and thor have DSLs, and so on
[22:11:16] wuest: Is there an interface in ruby to sigsuspend/equivalent functionality? Not seeing one, but maybe there's something esoteric in stdlib I haven't found...
[22:12:57] pontiki: Process class, maybe? trapping the SIG?
[22:13:10] pontiki: haven't done that, but that's where i'd start
[22:13:47] wuest: Yeah, been digging there. And just trapping the SIG doesn't block, leading to busy waiting, which is what I want to avoid.
[22:19:11] pontiki: crikey, i found something in the debugger
[22:19:17] pontiki: i don't know if this is usable
[22:20:40] pontiki: http://apidock.com/ruby/v1_9_3_392/DEBUGGER__/Context/set_suspend -- this doesn't really look useful
[22:21:30] wuest: Hmmm, worth digging more
[22:21:40] wuest: Thanks! I know it's a weird/uncommon question :)
[22:21:56] pontiki: i haven't even looked at this sort of thing in probably 2 decades
[22:28:15] RubyPanther: wuest: https://github.com/Spakman/syscalls
[22:28:46] RubyPanther: Or, you could write your own C wrapper in a few lines
[22:31:32] pontiki: looks good
[23:07:31] Eiam: in SomeHash.reduce({},:update) whats the :update do?
[23:16:08] Spooner: Eiam, It is equivalent to [hash1, hash2, hash3].reduce({}) {|m, e| m.update e } (Doesn't actually make sense if it is a hash being reduced, not an Array of Hashes).
[23:20:04] Eiam: err, yeah it was array of hashes
[23:20:16] Eiam: okay so update is being called on a hash
[23:21:30] Eiam: (wasn't aware of .update) which is apparently hte same as merge?
[23:21:51] Eiam: http://www.ruby-doc.org/core-2.0/Hash.html#method-i-update they don't even give an example with update
[23:26:49] Eiam: i find myself doing map().reduce({},:update) rather often
[23:26:53] Eiam: maybe i should stop using map =0
[23:27:26] pontiki: but yeah, maybe
[23:27:40] pontiki: i love reduce, but i probably way over use it
[23:28:09] danman: I am using ruby 1.9.3, any idea why I am getting errors for "{ 'name' => 'Rob', 'years' => '28' }.symbolize_keys"
[23:28:10] danman: NoMethodError: undefined method `symbolize_keys' for {"name"=>"Rob", "years"=>"28"}"?
[23:28:34] r0bgleeson: danman: symbolize_keys comes from rails
[23:28:40] havenwood: danman: The is no symbolize_keys method ^
[23:29:22] pontiki: but it is a rad method
[23:30:24] havenwood: danman: You could use tiny hashy gem and hash.map_value &:to_s: https://github.com/havenwood/hashy
[23:30:45] pontiki: look at this too: https://github.com/intridea/hashie
[23:33:36] havenwood: danman: class Hash; def map_pair &block; Hash[map &block] end end; { 'aim' => true }.map_pair { |k, v| [k.to_sym, v] }; #=> { :aim => true }
[23:36:31] pontiki: the way Rails does it seems a lot more straight-forward
[23:36:49] pontiki: granted it extends Hash
[23:42:53] r0bgleeson: >> foo = { "a" => "b", "c" => "d" }; Hash[foo.keys.map(&:to_sym).zip(foo.values)]
[23:42:54] eval-in: r0bgleeson => {:a=>"b", :c=>"d"} (https://eval.in/33820)
[23:42:57] r0bgleeson: that also works
[23:43:01] r0bgleeson: with no monkey patch
[23:43:55] slash_nick: >> foo = { "a-z" => "b", "c" => "d" }; Hash[foo.keys.map(&:to_sym).zip(foo.values)]
[23:43:56] eval-in: slash_nick => {:"a-z"=>"b", :c=>"d"} (https://eval.in/33821)
[23:44:11] slash_nick: just curious
[23:44:56] havenwood: Hash[foo.map { |k, v| [k.to_sym, v] }]
[23:45:34] r0bgleeson: oh yeah even better
[23:45:53] pontiki: as slash_nick points out, may want to emulate symbolize as well?
[23:47:35] mindeavor: if I'm developing a gem, and I have json files inside the gem's directory, how can I load them from code inside the gem's lib/ folder?
[23:48:04] havenwood: mindeavor: require_relative
[23:48:49] pontiki: are you looking how to find the files?
[23:49:07] pontiki: i don't think requiring json files will do much good
[23:49:11] pontiki: as they aren't ruby
[23:49:37] mindeavor: pontiki: yes. For example, in lib/myfile.rb, I'd like to load a json file
[23:49:48] havenwood: pontiki: good point >.>
[23:49:55] pontiki: look at File.expand_path
[23:50:31] pontiki: for instance File.expand_path(__FILE__, '../..')
[23:50:39] havenwood: mindeavor: do you know the names of the json files or are you globbing them?
[23:50:42] havenwood: mindeavor: Ruby 2.0?
[23:50:53] pontiki: for instance File.expand_path(File.dirname(__FILE__), '../..')
[23:51:08] mindeavor: havenwood: I do know the names, and I'm running 1.9
[23:51:26] pontiki: that should give you the root directory of your gem
[23:51:40] mindeavor: pontiki: Would I put that inside the main lib/gem_name.rb file?
[23:51:57] Apane: So, I'm using feedzirra gem (https://github.com/pauldix/feedzirra) for parsing and displaying RSS data. However, I'm having trouble displaying different feeds. The code in my view is displaying FeedEntry.all, albeit, I'd like to display several different feeds under different headers. Here's the gist of it: https://gist.github.com/anonymous/5801535
[23:52:28] pontiki: so: json_files = Dir.glob(#{File.expand_path(File.dirname(__FILE__),'../..')}/*.json)
[23:53:25] mindeavor: thanks pontiki, I will try that now
[23:53:28] pontiki: that's not quite it, but i think you get the idea?
[23:53:40] mindeavor: I think so. we'll see
[23:53:47] pontiki: like that thing in the Dir.glob needs to be in quotes
[23:54:54] pontiki: mindeavor: where you put it may change the depth of the '../..' part
[23:55:14] pontiki: lib/ should be '../..'; lib/gem_name should be '../../..' i think?
[23:55:19] havenwood: mindeavor: In Ruby 2.0 you can use __dir__, when you upgrade: File.join(__dir__, '../whatev.json')
[23:55:40] pontiki: so much nicer that File.dirname(__FILE__) all over!
[23:55:56] mindeavor: havenwood: thanks for the info, though I'd rather my gem not require 2.0
[23:56:17] havenwood: mindeavor: ah, yes - good point
[23:59:05] havenwood: pontiki: Also replaces expand_path too, so __dir__ instead of File.expand_path(File.dirname(__FILE__))
[23:59:34] havenwood: Here, __dir__ for the poor and huddled Rubies of yore: https://gist.github.com/havenwood/5801572