<za1b1tsu>
havenwood: I was just reading about optionparser, but how did you integrate optionparser in ARGV, I don't get it
<havenwood>
za1b1tsu: It just does that when you require it.
<havenwood>
za1b1tsu: Or you can use: OptionParser.new do |x|
<havenwood>
za1b1tsu: Same result.
Inline has quit [Quit: Leaving]
<za1b1tsu>
havenwood: it's very clean like this, thank you
<havenwood>
za1b1tsu: you're welcome
snickers has joined #ruby
<evdubs>
havenwood, i am looking at currency exposure for cryptocurrency positions - when looking at the exposure, i want the currencies to be sorted so that i can compare to other positions more easily. i can get away with {}.sort.to_h, but it just feels strange not having a sorted map in ruby. i am coming from java where we have built in rb trees and skip lists
<evdubs>
basically, any time i want to look at data or present data, i generally want a sorted data structure
clemens3 has quit [Ping timeout: 245 seconds]
<evdubs>
or, say i have a list of trades and the trade list grows over time. i could keep the list stored as an array and then call .sort on it every time a new trade is added, or i can just keep it in a sorted data structure
<havenwood>
evdubs: For the latter, SortedSet sounds like a fit.
<evdubs>
also, for the people curious about skip lists, they're useful as concurrent data structures because the locking used to make sure writes don't interfere with reads is much more easily done than with a balancing binary tree
<evdubs>
it is true that they will generally occupy more space than a binary tree, but balancing binary trees are notorious for poor performance when many threads are reading from/writing to it
aufi has joined #ruby
<evdubs>
that's my understanding of why java provides a ConcurrentSkipListMap and not a ConcurrentTreeMap
<evdubs>
i've used the ConcurrentSkipListMap as a data structure to manage an order book (a collection of orders sorted by price) - wouldn't want a hash for that
<evdubs>
of course, if your code is running in an interpreter with a global lock, thread contention is not much of a concern (from what i hear)
tristanp has joined #ruby
ramfjord has joined #ruby
tristanp has quit [Ping timeout: 264 seconds]
<apeiros>
08:23 evdubs: and i suppose the SortedSet of tuples is considered to be a sorted map?
<apeiros>
not really, since you can't do a key based lookup
<apeiros>
evdubs: but interesting re reasoning for ConcurrentSkipListMap vs ConcurrentTreeMap
<apeiros>
that does at the very least sound sensible
graphene has quit [Remote host closed the connection]
graphene has joined #ruby
ramfjord has quit [Ping timeout: 252 seconds]
ascarter has joined #ruby
madhatter has quit [Quit: leaving]
yohji has joined #ruby
clemens3 has joined #ruby
<marz_d`ghostman>
How do I require everything inside a module? I have module1:module2:Error:error_classes
ascarter has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
ascarter has joined #ruby
madhatter has joined #ruby
mike11 has joined #ruby
ascarter has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
duderonomy has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
jmcgnh has quit [Read error: Connection reset by peer]
jmcgnh has joined #ruby
akem has quit [Remote host closed the connection]
akem has joined #ruby
tdy1 has joined #ruby
lightstalker has quit [Ping timeout: 244 seconds]
tdy has quit [Ping timeout: 260 seconds]
lightstalker has joined #ruby
prestorium has joined #ruby
mikecmpbll has joined #ruby
discopatrick has joined #ruby
lxsameer has joined #ruby
venmx has joined #ruby
prometheus_falli has joined #ruby
<apeiros>
marz_d`ghostman: require and modules serve entirely different purposes
<marz_d`ghostman>
I have a bunc of custom error classes inside an Error module, and I don't want to require them one by one though
<apeiros>
require is "just" a glorified eval. require "path" is mostly eval(File.read(find_file_in_$LOAD_PATH("path")))
<apeiros>
you can use glob + __dir__ + require
<apeiros>
but honestly, just require them one by one. it's not. that. bad.
<apeiros>
after all, you'll usually do `require 'yourgem'`, which in turn handles all requires. so usually you'll only ever write those explicit requires once.
<marz_d`ghostman>
apeiros: Also I'm trying to rescue %x error. How do I extract the Errno::ENOENT part when doing SystemCallError => e?
<apeiros>
e.class will be Errno::ENOENT
<marz_d`ghostman>
apeiros: Also, tried visiting ruby docs, can't seem to find where it is explicitly defined what errors %x would through
t0adst00l has quit [Ping timeout: 256 seconds]
<marz_d`ghostman>
I'm pretty sure I just don't know how to navigate through it htough
<apeiros>
but you can also always be more specific first: rescue Errno::ENOENT …handle…; rescue SystemCallError …handle…
<apeiros>
can't parse that sentence: "where it is explicitly defined what errors %x would through"
<marz_d`ghostman>
apeiros: Oh I meant, when passing commands via %x. I want to know what possible errors it would throw so I could rescue it.
<marz_d`ghostman>
Or everything listed in Errno.constants?
<apeiros>
*raise
<apeiros>
throw is something different
<apeiros>
sadly ruby is rather lacking in documentation regarding potentially raised exceptions
<marz_d`ghostman>
Oh, I see
<apeiros>
you'd have to check the code, and the code of every method invoked within, and that recursively
<marz_d`ghostman>
I guess I'll have to deal with ENOENT first
<apeiros>
but, and this is important: you should not rescue exceptions if you can't handle them anyway.
mike11 has quit [Ping timeout: 250 seconds]
mike11 has joined #ruby
<marz_d`ghostman>
apeiros: Yeah, I have a custom log file that I want that exception message to be logged, hence, I'm handling it. :)
tdy1 has quit [Ping timeout: 260 seconds]
amelliaa has joined #ruby
tristanp has joined #ruby
<marz_d`ghostman>
I'm getting an error: NameError: undefined local variable or method `messsage' for #<Rise::MirrorManager::Error::CmdError:0x000000000235aa28> Did you mean? message for my custom error class http://termbin.com/1svchttp://termbin.com/dydy6
<marz_d`ghostman>
I'm not sure what I"m doing wrong though
ansraliant has quit [Quit: My planet needs me]
d^sh has quit [Ping timeout: 252 seconds]
tristanp has quit [Ping timeout: 245 seconds]
d^sh has joined #ruby
Nicmavr has quit [Read error: Connection reset by peer]
Nicmavr has joined #ruby
damasceno has joined #ruby
<damasceno>
Hello, I'm using nokogiri to retrieve a XML document and read it. I have three elements: id, date, description. I'm able to get all the <description> elements but I want to filter it, I would like to get the ones where the <date> element is TODAY. Is it possible to do that? Thanks
ua has quit [Ping timeout: 246 seconds]
Beams has joined #ruby
<apeiros>
marz_d`ghostman: well, for logging, you don't need to know which exception it is
<apeiros>
just rescue all, log, then reraise
<apeiros>
marz_d`ghostman: `messsage` read the word very very closely :-p
<apeiros>
especially the number of characters
<havenwood>
damasceno: Could you interpolate the date with XPath or CSS selectors? Or it might take less thought to #select today's. Have an example of the XML and the result you're looking for?
<havenwood>
#=> ["Amazon Elastic Compute Cloud (Ireland) Service Status"]
Tuor has joined #ruby
<damasceno>
thanks havenwood
<havenwood>
damasceno: you're welcome
nowhereman_ has quit [Remote host closed the connection]
nowhereman_ has joined #ruby
mehdi-farsi has joined #ruby
<mehdi-farsi>
Hi everyone ! I'm new to the channel. My name is Mehdi and I'm a developer from Paris ! Glad to be part of this community.
<havenwood>
mehdi-farsi: Welcome!
yohji has quit [Ping timeout: 246 seconds]
yohji has joined #ruby
apeiros has quit []
mehdi-farsi has quit [Quit: Page closed]
damasceno has quit [Quit: Page closed]
TheBloke has quit [Quit: My Mac has gone to sleep.]
TheBloke has joined #ruby
<marz_d`ghostman>
Using rspec, how do you test private methods?
<havenwood>
marz_d`ghostman: You can always get at private methods with #send, but meh.
<havenwood>
marz_d`ghostman: Avoid testing private methods since it's testing implementation instead of behavior.
<marz_d`ghostman>
havenwood: Cause I have this method which accepts commands then runs it %x, I'm testing it that it is receiving the correct argument. Also, testing it that it won't raise any error
<marz_d`ghostman>
havenwood: Okay, given you have a private method that runs cmd, how do you test it?
<havenwood>
marz_d`ghostman: Test the expected behavior via public methods.
<havenwood>
marz_d`ghostman: The private method is an implementation detail.
<marz_d`ghostman>
Hmmm, seems like I have to restructure my code
<havenwood>
"I personally avoid testing private functions because usually you end up testing implementation instead of behaviour and those tests fail as soon as you need to change the code. Instead, I test the expected behaviour via the public functions, breaking them in small, consistent chunks." ~José Valim
<marz_d`ghostman>
havenwood: regarding the pattern pertaining a class with a method self.run { self new().run } . . . everything will be private right?
<havenwood>
marz_d`ghostman: You're just exposing ::run, right. ::new is also public.
<havenwood>
marz_d`ghostman: I'm falling asleep, but hopefully someone else can help. Or I'd be happy to give suggestions when i wake.
<havenwood>
marz_d`ghostman: PS - You can: $?.success?
<havenwood>
marz_d`ghostman: Consider Open3.
<marz_d`ghostman>
havenwood: given the sample code, I need to test whether the cmd for pre_cmd and post_cmd is executed
<marz_d`ghostman>
havenwood: Okay thanks man. Have a good sleep :)
<havenwood>
g'night!
graphene has quit [Remote host closed the connection]
graphene has joined #ruby
phenom has joined #ruby
GodFather has joined #ruby
Tuor has quit [Ping timeout: 252 seconds]
lomex has joined #ruby
gregf_ has joined #ruby
apparition has joined #ruby
lomex has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
aufi has quit [Ping timeout: 252 seconds]
apeiros_ has joined #ruby
RedNifre has joined #ruby
<marz_d`ghostman>
Why does having two expects invoke the method twice?
<universa1>
TvL2386: did you try oc.stdout.string ?
<TvL2386>
universa1: nope :)
<TvL2386>
not printing anything
<TvL2386>
I was trying to put in `require 'pry'` and adding `binding.pry` at the bottom, but the program just exits
madhatter has joined #ruby
<universa1>
TvL2386: it "works", just the resetting does not work for some reason
<universa1>
TvL2386: i used your code and did not change stderr, and then printed to stderr... because a simple puts "42" did not print anything as well in the end
<beefjoe>
universa1 one more question
<beefjoe>
I'm not able to encode the result to json
<jhass>
for checking whether STDOUT is used at all you can set $stdout to something that logs all calls (BasicObject + method_missing are your friends)
Cthulu201 has quit [Ping timeout: 272 seconds]
arekushi is now known as Guest15520
Guest15520 is now known as arekushi
quazimodo has quit [Ping timeout: 240 seconds]
jcarl43 has joined #ruby
Puffball has quit [Remote host closed the connection]
Puffball has joined #ruby
alimiracle has joined #ruby
s2013 has joined #ruby
longshi has joined #ruby
longshi has left #ruby [#ruby]
<alimiracle>
hi I trying to install fabricio I useing gem install fabricio its installed but I cant use it
jcarl43 has quit [Quit: WeeChat 2.2]
Creatornator has joined #ruby
alimiracle has quit [Quit: Page closed]
beowuff has joined #ruby
Creatornator has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
snickers has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
beowuff has joined #ruby
oborot has joined #ruby
<oborot>
Does anybody have any idea what might cause a record to wrongly return values from the database? E.g., `Model.find(56)` yields different results from what's actually in the database for it's `completed_at` field during runtime.
<oborot>
No cachings is enabled.
ellcs has joined #ruby
savolla has joined #ruby
<apeiros_>
?ar oborot
<ruby[bot]>
oborot: For activerecord/arel questions, please join #RubyOnRails, since they're maintained as a part of it. Note: you need to be identified with NickServ, see /msg NickServ HELP
Inline has joined #ruby
apeiros_ is now known as apeiros
Inline has quit [Read error: Connection reset by peer]
xfbs has quit [Quit: afk]
Inline has joined #ruby
lxsameer has quit [Ping timeout: 240 seconds]
savolla has quit [Ping timeout: 244 seconds]
duderonomy has joined #ruby
tdy1 has joined #ruby
kpoman has quit [Ping timeout: 240 seconds]
ellcs has quit [Ping timeout: 260 seconds]
ivanskie has joined #ruby
Creatornator has joined #ruby
desperek has joined #ruby
madhatter has quit [Quit: bbl]
yohji has quit [Remote host closed the connection]
clemens3 has quit [Ping timeout: 240 seconds]
kpoman has joined #ruby
aufi has quit [Ping timeout: 240 seconds]
prestorium has quit [Quit: prestorium]
s2013 has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
Sembei has quit [Ping timeout: 252 seconds]
s2013 has joined #ruby
MyMind has joined #ruby
DTZUZO has joined #ruby
mikecmpbll has quit [Quit: inabit. zz.]
s2013 has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
s2013 has joined #ruby
orbyt_ has joined #ruby
akem has quit [Remote host closed the connection]
Creatornator has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
DTZUZO has quit [Ping timeout: 252 seconds]
Beams has quit [Quit: .]
impermanence has quit [Remote host closed the connection]
xfbs has joined #ruby
clemens3 has joined #ruby
c0ncealed3 has quit [Remote host closed the connection]
c0ncealed3 has joined #ruby
nowhereman_ has quit [Ping timeout: 260 seconds]
Creatornator has joined #ruby
<za1b1tsu>
Regarding shell scripting what's a good way to get current user?
ascarter has joined #ruby
savolla has joined #ruby
conta1 has joined #ruby
Creatornator has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
ascarter has quit [Client Quit]
akem has joined #ruby
sameerynho has joined #ruby
RedNifre has quit [Remote host closed the connection]
<hays_>
is there a way to see from the commandline what executables are associated with a gem
<hays_>
given a .gem file
<hays_>
or an installed gem
za1b1tsu has quit [Ping timeout: 240 seconds]
jcalla has quit [Quit: Leaving]
duderonomy has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
energizer has joined #ruby
<energizer>
Hello I'm trying to run `gem install travis -v 1.8.9 --no-rdoc --no-ri` and it says `You don't have write permissions for the /var/lib/gems/2.5.0 directory.` I'm following https://github.com/travis-ci/travis.rb#installation
MoritaShinobu has quit [Quit: Leaving]
<havenwood>
hays_: For just those provided by a gem, and not also its deps, you can just find the spec and check the executables.