<RickHull>
sorry I misread, it looks like L6 does *not* define a block
<RickHull>
it's easy to misread when your indentation is all over the place :)
<nginxxx>
okay thanks
<RickHull>
the `end` on L15 -- what block does that close?
<RickHull>
gah!
<RickHull>
L6 does define a block
<RickHull>
i keep misreading your code
d10n-work has quit [Quit: Connection closed for inactivity]
enterprisey has quit [Remote host closed the connection]
<RickHull>
everything between L6 and L15 should be at the same indent level, with 2 spaces of indent
rainbowz has joined #ruby
<weaksauce>
why don't you pass it in on the command line too `addresses = ARGV[0]`
<RickHull>
(unless an expression is split across multiple lines)
<RickHull>
nginxxx: please make (most of) the suggested changes and paste again
<RickHull>
even if it doesn't run or behave as expected
<RickHull>
in a nutshell: address should be local, not global. assign address before printing it or using it in an expression. fix your indenting
<nginxxx>
l6 defines a block it is not wrong... go look on ruby docs.
<RickHull>
nginxxx: I appreciate the suggestion, but try to follow my lead here
<nginxxx>
and ruby is not like python, its not important how many spaces
<RickHull>
nginxxx: it is important if you want people to read your code
<weaksauce>
it's important, full stop
<nginxxx>
why shoud i drop l3
<nginxxx>
for what?
<RickHull>
what is the purpose of L3? what does it accomplish?
<nginxxx>
Theres nothing wrong
<nginxxx>
I want to write in irb the hostname to resolve
<nginxxx>
not in code
<nginxxx>
...
rainbowz has left #ruby ["WeeChat 1.4"]
<RickHull>
ok, fair enough, in irb L3 will display the value of $address
zautomata has quit [Ping timeout: 260 seconds]
<RickHull>
but it would not have a value at that point
<RickHull>
if we are to take your pasted code as written
alveric2 has joined #ruby
rfoust has joined #ruby
<RickHull>
irb is for playing around -- it will evaluate and print each expression -- but you should not share your code in this form
d^sh has quit [Ping timeout: 260 seconds]
<RickHull>
for others to read
nginxxx has quit [Quit: Page closed]
<RickHull>
the code you are sharing is full of "noise" and not much signal
<weaksauce>
anything over a few lines should be run from a file and not irb...
<RickHull>
and it makes it difficult for others to understand
<weaksauce>
(a well indented file at that)
<RickHull>
and you may not get as much help as you would like
alveric1 has quit [Ping timeout: 248 seconds]
<weaksauce>
also, when you run `ruby myscript" it guarantees that you are free from any other variables being set accidentally
<RickHull>
yes -- I like to "play around" in irb to get an understanding of the variable types, methods, how to structure things
<RickHull>
then I will commit that knowledge to a file
sepp2k has quit [Quit: Leaving.]
<RickHull>
and I can execute that file repeatedly without restarting irb and re-pasting code
<RickHull>
or typing it in over-and-over
postmodern has joined #ruby
<RickHull>
make a small edit to the file, then execute again, etc
<RickHull>
If I don't have a good understanding of types, methods, structure, then it is probably too early to commit a lot of code to a file, as later lines will depend on prior lines
<RickHull>
and any misconceptions committed to prior lines will make a lot of the later lines incorrect in both concept and execution
d^sh has joined #ruby
milardovich has joined #ruby
<leitz>
Any experienced Ruby coders want to give a high level "You need to work on ..." review? My goal is to focus learning on "This should be my next couple topics" instead of "you need to learn everything first." My best Ruby code is: https://github.com/LeamHall/CT_Character_Generator
* leitz
just wrapped up this week's MongoDB class in one day.
<RickHull>
leitz: I skimmed it the other day -- I am a minimalist, simplest-thing-that-could-possibly-work type
<RickHull>
it's easy for ruby newbies to try to write every piece of functionality as instance methods making heavy use of ivars
<RickHull>
but this is very hard to test and make sense of
<RickHull>
it's tempting to write methods that are basically just stored procedures that maybe take some args, read some ivar values, update other ivar values, and maybe have a significant return value
<RickHull>
and there's nothing exactly "wrong" with this approach
<RickHull>
with enough study and tracing, you can figure out what's really going on
<weaksauce>
leitz fwiw it looks like muster_out is refactorable to be much shorter
<RickHull>
i prefer a different structure and organization that makes the "dataflow" clear
<RickHull>
args go in, return values come out
workmad3 has joined #ruby
<weaksauce>
also, eloquent ruby is one of the best programming books i have read hands down
<leitz>
weaksauce, I agree. Am reading Booch's "OO Analysis and Design" and getting a better understanding of how to break things down.
JBbanks has quit [Ping timeout: 240 seconds]
<leitz>
"Eloquent Ruby" is about eight inches from my clipboard where I make notes when not typing.
<weaksauce>
leitz is there a specific reason you are using Hash.new(0) instead of just {}... do you need the default value being set for missing keys?
milardov_ has joined #ruby
<leitz>
weaksauce, there was something I hit a while back and the (0) solved the problem. Not sure what. However, I prefer setting defaults.
<leitz>
Came from another book I read. :)
<RickHull>
that hash default is a big pitfall IIRC -- rarely useful imho
* leitz
has lots of books.
<leitz>
Yeah, I'm trying to remember what the issue was that it solved.
<weaksauce>
usually it's for the case where you have a homogenized set of values that all start at 0 say the weights of a graph edge or something like that but yeah I agree that it's something that I don't use very often
<RickHull>
actually, with integers it should be ok
<RickHull>
but any mutable value will probably not do what you want
<weaksauce>
leitz i would say that it was probably something along the lines of my_hash['missingkey'] += 1
<weaksauce>
that's what usually fails me
<RickHull>
>> h = Hash.new('str'); h[:bar] << 'baz'; h[:foo]
<RickHull>
bougyman: I've been burned so many times by that form, I stopped using it. but it does indeed look good for numeric -- and frozen strings too I'd think
<bougyman>
RickHull: how could you get burned by it for counters?
<RickHull>
not with counters, well maybe an array of counters
<RickHull>
i got burned by mutating
<bougyman>
ah, understood.
<bougyman>
Yes, only ints.
<bougyman>
But for ints I do think it fits the use case perfectly.
<RickHull>
almost certainly with arrays, probably hashes, maybe strings
<RickHull>
yep -- that's what I was trying to say
orbyt_ has joined #ruby
orbyt_ has quit [Client Quit]
<RickHull>
i.e. thanks for pointing it out -- I had given up on it :)
jameser has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
zautomata has joined #ruby
tenderlove has joined #ruby
hinbody has quit [Quit: leaving]
isene has quit [Quit: WeeChat 1.9]
elcontrastador has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
drewmcmillan has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
jameser has joined #ruby
kitsunenokenja has quit [Ping timeout: 258 seconds]
rfoust has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Cohedrin has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Cohedrin has joined #ruby
sucks has joined #ruby
sucks has quit [Remote host closed the connection]
Technodrome has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
gizmore|2 has joined #ruby
dhollinger has quit [Read error: Connection reset by peer]
motstgo has joined #ruby
workmad3 has joined #ruby
Guest70176 has joined #ruby
gizmore has quit [Ping timeout: 250 seconds]
cdg has joined #ruby
govg has quit [Ping timeout: 240 seconds]
nofxx__ has joined #ruby
motstgo_ has quit [Ping timeout: 248 seconds]
nofxx_ has quit [Read error: Connection reset by peer]
workmad3 has quit [Ping timeout: 240 seconds]
cdg has quit [Ping timeout: 258 seconds]
oetjenj has quit [Remote host closed the connection]
Guest70176 has quit [Ping timeout: 260 seconds]
oetjenj has joined #ruby
elcontrastador has joined #ruby
enterprisey has joined #ruby
shoogz has joined #ruby
shoogz has quit [Max SendQ exceeded]
shoogz has joined #ruby
shoogz has quit [Max SendQ exceeded]
shoogz has joined #ruby
shoogz has quit [Max SendQ exceeded]
shoogz has joined #ruby
shoogz has quit [Max SendQ exceeded]
shoogz has joined #ruby
shoogz has joined #ruby
oetjenj has quit [Client Quit]
cdg has joined #ruby
oetjenj has joined #ruby
faces has quit [Ping timeout: 248 seconds]
Barrt has quit [Ping timeout: 248 seconds]
oetjenj has quit [Client Quit]
oetjenj has joined #ruby
kryptoz has joined #ruby
oetjenj has quit [Client Quit]
oetjenj has joined #ruby
oetjenj has quit [Client Quit]
oetjenj has joined #ruby
oetjenj has quit [Client Quit]
oetjenj has joined #ruby
oetjenj has quit [Client Quit]
GodFather has quit [Ping timeout: 248 seconds]
Cohedrin has quit [Read error: Connection reset by peer]
enko has joined #ruby
Cohedrin has joined #ruby
elcontrastador has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
dviola has quit [Quit: WeeChat 1.9.1]
mson has quit [Quit: Connection closed for inactivity]
guardianx has joined #ruby
jackjackdripper has joined #ruby
jackjackdripper has quit [Client Quit]
jackjackdripper has joined #ruby
Psybur has joined #ruby
Barrt has joined #ruby
tcopeland has joined #ruby
uZiel has joined #ruby
Psybur has quit [Ping timeout: 248 seconds]
epochwolf has quit [Ping timeout: 240 seconds]
orbyt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
epochwolf has joined #ruby
Guest90_ has joined #ruby
mjolnird has quit [Quit: Leaving]
milardovich has joined #ruby
Cohedrin has quit [Read error: Connection reset by peer]
Cohedrin has joined #ruby
Barrt has quit [Ping timeout: 260 seconds]
fyrril2 has quit [Quit: Leaving]
mim1k has joined #ruby
fyrril has joined #ruby
Barrt has joined #ruby
jtdoncas has joined #ruby
mim1k has quit [Ping timeout: 248 seconds]
jameser has quit [Read error: Connection reset by peer]
kryptoz has quit [Remote host closed the connection]
jameser has joined #ruby
jtdoncas has quit [Ping timeout: 240 seconds]
ASFT has joined #ruby
Barrt has quit [Ping timeout: 248 seconds]
zanoni has quit [Ping timeout: 240 seconds]
deadpoet has joined #ruby
kryptoz has joined #ruby
deadpoet has quit [Quit: leaving]
bwilson has joined #ruby
shortdudey123 has quit [Ping timeout: 248 seconds]
shortdudey123 has joined #ruby
Psybur has joined #ruby
plexigras has quit [Ping timeout: 268 seconds]
Barrt has joined #ruby
ramortegui has joined #ruby
milardov_ has joined #ruby
Psybur has quit [Ping timeout: 240 seconds]
kies has joined #ruby
milardovich has quit [Ping timeout: 248 seconds]
maum has joined #ruby
Guest70176 has joined #ruby
leeice1 has joined #ruby
bmurt has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Guest70176 has quit [Ping timeout: 240 seconds]
mson has joined #ruby
kryptoz has quit [Remote host closed the connection]
leeice1 has left #ruby [#ruby]
ASFT has quit [Ping timeout: 260 seconds]
Rouge has quit [Ping timeout: 248 seconds]
orbyt_ has joined #ruby
dhollinger has joined #ruby
govg has joined #ruby
ramortegui has quit [Quit: This computer has gone to sleep]
gix has joined #ruby
workmad3 has joined #ruby
gix- has quit [Ping timeout: 248 seconds]
kryptoz has joined #ruby
workmad3 has quit [Ping timeout: 248 seconds]
nofxx__ has quit [Quit: Leaving]
nofxx has joined #ruby
Barrt has quit [Ping timeout: 248 seconds]
Barrt has joined #ruby
jackjackdripper has quit [Quit: Leaving.]
milardovich has joined #ruby
jamesaxl has joined #ruby
nicesignal has quit [Remote host closed the connection]
nicesignal has joined #ruby
guardianx has quit [Remote host closed the connection]
milardov_ has quit [Ping timeout: 240 seconds]
Cohedrin has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
ur5us has quit [Remote host closed the connection]
stan has quit [Ping timeout: 248 seconds]
Psybur has joined #ruby
seggy has joined #ruby
seggy has quit [Client Quit]
Barrt has quit [Ping timeout: 248 seconds]
seggy has joined #ruby
Barrt has joined #ruby
Psybur has quit [Ping timeout: 240 seconds]
iamarun has joined #ruby
astrobunny has joined #ruby
k3rn31_ has joined #ruby
helpa has quit [Remote host closed the connection]
helpa-bot has joined #ruby
Guest70176 has joined #ruby
helpa-bot has quit [Remote host closed the connection]
mjolnird has joined #ruby
helpa has joined #ruby
mjolnird has quit [Remote host closed the connection]
cdg has quit [Remote host closed the connection]
milardovich has quit [Remote host closed the connection]
Guest70176 has quit [Ping timeout: 248 seconds]
mjolnird has joined #ruby
exhiled has joined #ruby
rabajaj has joined #ruby
Guest17927 has joined #ruby
hays has joined #ruby
hays has joined #ruby
hays has quit [Changing host]
minimalism has joined #ruby
<hays>
i have ruby on a windows machine (rubyinstaller) and when I did gem update --system and gem update, I got an error with did_you_mean gem, saying it needed 2.4.0
<hays>
is it safe to just uninstall this gem?
<havenwood>
hays: Yes, it's fine to uninstall it. What version are you on?
<hays>
2.3.2 i think it was
mim1k has joined #ruby
<hays>
2.3.1p112
<hays>
its kinda weird, it seems to know that it can't upgrade it.. yet it tries and fails anyway
<hays>
seems like gem update should just leave it at the last version supporting my version of ruby
michael1 has joined #ruby
Barrt has quit [Ping timeout: 248 seconds]
mim1k has quit [Ping timeout: 248 seconds]
<havenwood>
hays: that's typically what happens
Barrt has joined #ruby
<hays>
i guess gem update is a bit risky then
<havenwood>
ERROR: Error installing did_you_mean:
<havenwood>
did_you_mean requires Ruby version >= 2.4.0.
<havenwood>
hays: ^ that's the error you get if you try to update did_you_mean on Ruby 2.3
<hays>
yep
<havenwood>
hays: The version of did_you_mean that you have is the latest version that works with Ruby 2.3.
<havenwood>
You don't need to uninstall it just because it can't be updated, but you're free to if you want.
<hays>
is there a way to freeze the version of that gem so gem update ignores it
enterprisey has quit [Remote host closed the connection]
zautomata has quit [Quit: WeeChat 1.7]
ramfjord has joined #ruby
st4l1n has joined #ruby
<havenwood>
hays: Nope
<havenwood>
hays: FWIW (little) you can silence warnings: gem update 2>/dev/null
<hays>
you done the rubyinstaller 2.4.2 by any chance? I am getting an error on installing MSYS2+MINGW toolchain
<st4l1n>
Hey, I'm newish to ruby and wishing to become an absolute expert over the next few years. I've heard a great way to go about this is to request a mentor. Can anyone suggest places for this or other methodoloiges/books for becoming an expert in ruby
<apeiros_>
st4l1n: please change your nick
apeiros_ is now known as apeiros
<havenwood>
hays: I think it's confusing that did_you_mean gets listed as an updated gem when it doesn't update. And I agree the warning is odd. I'm not sure on the optimal fix but it seems worth looking at.
orbyt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
st4l1n is now known as marcosstanos
<apeiros>
thanks
ramfjord has quit [Ping timeout: 248 seconds]
<marcosstanos>
all good
<marcosstanos>
As for my question..
SeepingN has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<apeiros>
in the topic, there's a book list. there are a couple of free online training places like exercise.io
Guest70176 has joined #ruby
<apeiros>
personally I prefer the way of "just get a project and start working". you can always ask here about advices on your code.
<havenwood>
marcosstanos: RubyConf has an official guides and scholars program. That's a great place to find a mentor. You might consider applying for an opportunity scholarship next year.
cdg has joined #ruby
<havenwood>
marcosstanos: Local meet-ups are a good place to find mentorship. Or if you can find a workplace with mentors that's ideal.
<marcosstanos>
What level should I be at to get the most value out of such a programme?
<havenwood>
marcosstanos: Most of the scholars this year had about a year experience. Some had none. One had four years.
cschneid_ has quit [Remote host closed the connection]
<havenwood>
marcosstanos: Here's a site where you can pay for in-depth mentorship: https://www.bloc.io/mentors
<havenwood>
marcosstanos: You can certainly find an unpaid mentor, it just takes more searching.
Guest70176 has quit [Ping timeout: 248 seconds]
cdg has quit [Ping timeout: 240 seconds]
<havenwood>
And feel free to ask lots of questions here!
<hays>
its weird to be running pacman on a win7 machine. haha
<hays>
someone loves arch
<marcosstanos>
Fantastic, thanks for the resources
<hays>
havenwood: i agree its weird. but i've decided to focus forward and just put 2.4 on here and fix the bugs that happen if any
Psybur has joined #ruby
<hays>
its a lab anyway
<Nilium>
Cue everyone trying to hang hays.
<hays>
lol could happen. but rolling back to 2.3 on a single laptop is also not that bad
<hays>
and im the one that owns this code so im really just hurting myself if anything happens
<baweaver>
Nilium: Now why would we do that?
<Nilium>
Well, I meant the lab users.
Cohedrin has joined #ruby
<Nilium>
#ruby is very friendly.
<baweaver>
Ah
<Nilium>
Which is actually part of the reason I still hang around here, compared to most other language channels.
i8igmac has joined #ruby
SeepingN has joined #ruby
<baweaver>
We try and be at least :)
exhiled has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<hays>
ruby community is great. language is great too. I mean I also like Python because its hard to beat numpy+scipy+pandas+matplotlib
* Nilium
likes Erlang.
Psybur has quit [Ping timeout: 260 seconds]
<Nilium>
Insert cricket sounds here.
<hays>
haha i remember a guy in college liking erlang. way before FP was cool
<baweaver>
The cool kids use Elixir now
<hays>
i got into Scheme myself
<baweaver>
Just ask Radar, he's even writing a book for it
* Nilium
still doesn't really like Elixir's syntax.
<baweaver>
Radar: was it still "a" or "multiple" now?
<hays>
all the real FP seems to be done in EMCAScript these days. who'd have ever thought that would happen
<Nilium>
Let's assume multiple at some point.
<baweaver>
I even make a crack about Scheme in my book: Where'd we get the car? I think from something called LISP, such a little Schemer it is. Jokes aside, car is just an example object for us to play with for now.
<mrig>
Hello :); I am not a regular ruby user but I do use it for jekyll on my static github pages site, I was wondering if any one could help me with a little issue; When I set the site up I found a Gemfile.lock file provided by Github to insure the correct rubygem versions for their servers; I don't seem to be able tofind a more recent version of this file.
<mrig>
kapil___, ah, I have just changed distro and have not looked at the ruby instillation as yet; This is required as I have recieved a complaint from github about one of the pacages linked in the gemfile.lock listing, all that is required is the current list from github I think, was wondering if this is still in use, and as such if I could get a pointer to it from here, could be that it is no longer a thing :)
<mrig>
heh, sorry spell check not working yet on weechat either :/
DoubleMalt has quit [Ping timeout: 240 seconds]
<cek>
ask weechat about tiananmen square , you'll get wonderful results
<cek>
ok, my question: how do you get an intersection of arrays a and b so that you get full b in case a is empty? can't think a solution without a conditional
<Guest90927>
the defined function fails with a no method error because $1 isn't set... however the call to gsub outside the function works just fine
<tobiasvl>
Guest90927: shouldn't the regex be /\[([A-Z]*[ A-Z_0-9]*)\]
Psybur has joined #ruby
<tobiasvl>
note the [A-Z]*
<tobiasvl>
otherwise you'll just match one letter between A-Z followed by any number of groups of space or alphanumerals
<Guest90927>
ah that could be it... but how does the second gsub succeed?
<tobiasvl>
I also don't know if the space should be inside those brackets, but you know what you want to match better than me
cdg has joined #ruby
<Guest90927>
added a comment on the result that I get in IRB
zenspider has joined #ruby
<Guest90927>
it's almost as if I loose the gsub context when calling from within a function
Mortomes|Work has quit [Ping timeout: 260 seconds]
im0nde has joined #ruby
lupine has quit [Ping timeout: 255 seconds]
char_var[buffer] has quit [Ping timeout: 248 seconds]
benjen has joined #ruby
tacoboy has quit [Ping timeout: 240 seconds]
tacoboy has joined #ruby
Psybur has quit [Ping timeout: 248 seconds]
cdg has quit [Ping timeout: 255 seconds]
<Burgestrand>
Guest90927 if you want to have some more fun, try swapping the order of gsub/doit
<matthewd>
Guest90927: $1 looks like a global, but is actually a specially-scoped local.. tbh I'm actually not sure whether that's relevant in this case
<Guest90927>
ya... that gets it to work...
<Guest90927>
I think because gusb stores the global var and doesn't clear it after?
Guest90927 is now known as kyle
<kyle>
I've also tried using the '\1' syntax
<kyle>
same result
kyle is now known as Guest7623
zenspider has quit [Quit: bye]
<matthewd>
Yeah, using different strings should confirm that
<matthewd>
Use s[1]
<Burgestrand>
kyle__ $1 uses $~, and $~ is not really global (it doesn't leak past the current thread if I remember correctly), it's the last match in the current *scope*
mtkd has quit [Read error: Connection reset by peer]
^mtkd has joined #ruby
sentor``` has joined #ruby
BioSpider has quit [Ping timeout: 240 seconds]
deepredsky has joined #ruby
sentor`` has quit [Ping timeout: 248 seconds]
apparition has joined #ruby
im0nde_ has joined #ruby
rfoust has joined #ruby
im0nde__ has joined #ruby
im0nde has quit [Ping timeout: 248 seconds]
im0nde__ is now known as im0nde
Guest7623 has quit [Ping timeout: 248 seconds]
sentor``` has quit [Ping timeout: 248 seconds]
im0nde_ has quit [Ping timeout: 248 seconds]
Burgestrand has joined #ruby
dionysus69 has quit [Ping timeout: 248 seconds]
deepredsky has quit [Ping timeout: 268 seconds]
plexigras has joined #ruby
deepredsky has joined #ruby
Guest7623 has joined #ruby
vondruch has quit [Ping timeout: 240 seconds]
vondruch has joined #ruby
drowze has quit [Ping timeout: 268 seconds]
tomphp has joined #ruby
Guest7623 has quit [Ping timeout: 240 seconds]
vondruch has quit [Client Quit]
vondruch has joined #ruby
iamarun has joined #ruby
silvermine has quit [Ping timeout: 240 seconds]
vee__ has quit [Ping timeout: 240 seconds]
nowhere_man has quit [Remote host closed the connection]
tomphp_ has joined #ruby
tomphp has quit [Ping timeout: 248 seconds]
^mtkd has quit [Read error: Connection reset by peer]
mtkd has joined #ruby
ramortegui has joined #ruby
nowhere_man has joined #ruby
tomphp_ has quit [Client Quit]
fredx has joined #ruby
Psybur has joined #ruby
uZiel has quit [Remote host closed the connection]
Guest70176 has quit [Ping timeout: 255 seconds]
uZiel has joined #ruby
iceden has quit [Ping timeout: 255 seconds]
guille-moe has joined #ruby
iceden has joined #ruby
drowze has joined #ruby
safetypin has joined #ruby
Psybur has quit [Ping timeout: 258 seconds]
vee__ has joined #ruby
shinnya has joined #ruby
InfinityFye has joined #ruby
charliesome has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
plexigras has quit [Quit: WeeChat 1.9.1]
TinkerTyper has quit [Ping timeout: 240 seconds]
vondruch_ has joined #ruby
vee__ has quit [Ping timeout: 260 seconds]
TinkerTyper has joined #ruby
br0d1n has joined #ruby
plexigras has joined #ruby
vondruch has quit [Ping timeout: 248 seconds]
vondruch_ is now known as vondruch
DLSteve has joined #ruby
ta__ has quit [Remote host closed the connection]
fredx has quit [Quit: Leaving]
Technodrome has joined #ruby
InfinityFye has quit [Quit: Leaving]
fredx has joined #ruby
LebedevRI has joined #ruby
Guest70176 has joined #ruby
polishdub has joined #ruby
kryptoz has joined #ruby
vee__ has joined #ruby
Burgestrand has quit [Quit: Closing time!]
larcara has joined #ruby
Technodrome has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Rouge has quit [Ping timeout: 240 seconds]
mcr1 has quit [Ping timeout: 246 seconds]
tomphp has joined #ruby
tomphp has quit [Client Quit]
silvermine has joined #ruby
tomphp has joined #ruby
uZiel has quit [Ping timeout: 248 seconds]
shinnya has quit [Ping timeout: 268 seconds]
tomphp has quit [Client Quit]
tomphp has joined #ruby
safetypin has quit [Quit: ZZZzzz…]
kryptoz has quit [Read error: Connection reset by peer]
kryptoz has joined #ruby
kryptoz has quit [Read error: Connection reset by peer]
uZiel has joined #ruby
mson has joined #ruby
kryptoz has joined #ruby
im0nde has quit [Quit: im0nde]
<Bish>
can a proc reference itself?
<Bish>
no, right?
iceden has quit [Ping timeout: 250 seconds]
<c-c>
is it an object?
<Bish>
i mean, can you in a block, get the reference of a block.
<Bish>
>> [1,2,[3]].map { |a| case a;when Array;???;else a+1;end; }
<ruby[bot]>
Bish: # => /tmp/execpad-317b2134579b/source-317b2134579b:2: syntax error, unexpected ';' ...check link for more (https://eval.in/905446)
<Bish>
kinda like this
<Bish>
or will i have to make a proc
<c-c>
I don't understand
<Bish>
i want to add 1 to every element in there, recusrively
<c-c>
in your example. what you test in the case is some object from array, not a proc
<Bish>
(i do not really want to do that, it's an example)
deepredsky has quit [Ping timeout: 248 seconds]
<Bish>
the proc/block says " add 1"
<Bish>
i want it to to it in every array element, if it's an array i want to go deeper
<c-c>
I get the temptation to say "forget procs"
<Bish>
hows that.. i need procs/methods for that.. if i don't have a reference then what am i calling
<c-c>
Bish: so you want to do something for .each, recursively
<Bish>
well, and conditionally.
<c-c>
you are not calling? .each or .map is calling. Neither is recursive.
milardovich has joined #ruby
larcara has quit [Remote host closed the connection]
tomphp has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<c-c>
Bish: I think what you want is 1) some method that handles_array_item 2) a walker that walks the array and calls handles_array_item when the item at hand is an array
<Bish>
>> myproc = proc{|a| a.each { |x| case x; when Array; x.map(&:myproc); else x+1; end; } };myproc.call [1,2,3]
<dminuoso>
And this is my take in haskell with lambdas.
<dminuoso>
(Realized that this is the better equivalent of the earlier mentioned combinator)
mim1k has quit [Disconnected by services]
mim1k_ has joined #ruby
Rouge has joined #ruby
<dminuoso>
(The typesystem needs slight encouragement)
troys_ is now known as troys
<dminuoso>
But it's fairly close to (\x -> x x)(\x -> x x) wouldnt you say? :)
motstgo has left #ruby ["WeeChat 1.9"]
mcr1 has joined #ruby
apparition has quit [Quit: Bye]
kapil___ has joined #ruby
conta has quit [Quit: conta]
conta has joined #ruby
cdg has joined #ruby
Psybur has joined #ruby
daemonwrangler is now known as derek-away
conta has quit [Ping timeout: 240 seconds]
rfoust has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
derek-away is now known as daemonwrangler
mim1k_ is now known as mim1k
milardov_ has joined #ruby
Psybur has quit [Ping timeout: 240 seconds]
milardovich has quit [Ping timeout: 240 seconds]
milardov_ has quit [Remote host closed the connection]
daemonwrangler is now known as derek-away
mark_66 has quit [Remote host closed the connection]
silvermine has joined #ruby
synthroid has quit [Remote host closed the connection]
thinkpad has quit [Ping timeout: 248 seconds]
mim1k has quit [Ping timeout: 268 seconds]
mim1k has joined #ruby
dionysus69 has joined #ruby
zautomata has quit [Ping timeout: 268 seconds]
drowze has joined #ruby
milardovich has joined #ruby
jackjackdripper has joined #ruby
aufi has quit [Quit: Leaving]
ewoud has joined #ruby
vee__ has quit [Ping timeout: 260 seconds]
mtkd has quit [Ping timeout: 248 seconds]
<ewoud>
if I want to ship static files in a gem to be used by another gem/script, where would I put them and how would I load them later?
derek-away is now known as daemonwrangler
mtkd has joined #ruby
<adaedra>
I think you can put then anywhere in the gem if you reference them in the gem's files attribute
synthroid has joined #ruby
<adaedra>
Then you should be able to find it relatively to __dir__
<ewoud>
the use case is shipping a bunch of yaml files so I'd have mygem/lib/nodesets.rb and use __dir__ in that nodesets.rb?
bronson_ has joined #ruby
bronson has quit [Read error: Connection reset by peer]
<ewoud>
that sounds like it should work
iamarun has quit [Remote host closed the connection]
<dminuoso>
Nice.
<dminuoso>
So I got a heisenbug somewhere in a native extension. When I now attach valgrind, everything explodes wildly.
<craysiii>
hey everyone. trying to implement these data stream endpoints for an api wrapper, but i see that faraday hasn't implemented data streams yet. can anyone recommend an appropriate gem?
synthroid has quit [Ping timeout: 248 seconds]
Dimik has joined #ruby
jaruga has quit [Quit: jaruga]
<ewoud>
adaedra: thanks, looks like that's exactly what I was looking for
cschneid_ has quit [Read error: Connection reset by peer]
cschneid_ has joined #ruby
Technodrome has quit [Read error: Connection reset by peer]
<mikecmpbll>
hmm. it's a shame that 2.4's Enumerable#sum doesn't have any native performance boost for arrays of BigDecimal.
knight33 has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
<mikecmpbll>
about 8* faster for floats
<mikecmpbll>
(than [].reduce :+ )
synthroid has joined #ruby
raynold has quit [Quit: Connection closed for inactivity]
ewoud has left #ruby [#ruby]
Beams has quit [Quit: .]
ShekharReddy has joined #ruby
mim1k has quit [Ping timeout: 258 seconds]
jamiejackson has joined #ruby
exhiled has joined #ruby
rikkipitt has quit [Remote host closed the connection]
rikkipitt has joined #ruby
wolfshappen has quit [Ping timeout: 268 seconds]
exhiled has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
uZiel has quit [Remote host closed the connection]
milardovich has joined #ruby
milardovich has quit [Remote host closed the connection]
exhiled has joined #ruby
Guest70176 has quit [Ping timeout: 240 seconds]
rikkipitt has quit [Ping timeout: 240 seconds]
nobitanobi has quit [Remote host closed the connection]
Emmanuel_Chanel has quit [Quit: Leaving]
milardov_ has quit [Ping timeout: 248 seconds]
synthroi_ has joined #ruby
mtkd has quit [Read error: Connection reset by peer]
mtkd has joined #ruby
Guest70176 has joined #ruby
synthroid has quit [Ping timeout: 240 seconds]
wolfshappen has joined #ruby
Guest70176 has quit [Ping timeout: 255 seconds]
ldepandis has joined #ruby
mtkd has quit [Read error: Connection reset by peer]
mtkd has joined #ruby
ur5us has joined #ruby
Emmanuel_Chanel has joined #ruby
Emmanuel_Chanel has quit [Remote host closed the connection]
ramfjord has joined #ruby
eckhardt has joined #ruby
uZiel has joined #ruby
ur5us has quit [Ping timeout: 264 seconds]
vee__ has quit [Ping timeout: 248 seconds]
mcr1 has joined #ruby
rabajaj has joined #ruby
Emmanuel_Chanel has joined #ruby
kies has quit [Ping timeout: 248 seconds]
Psybur has joined #ruby
cdg has joined #ruby
Scorpion has joined #ruby
nofxx has quit [Read error: Connection reset by peer]
TomyWork has quit [Ping timeout: 240 seconds]
nofxx has joined #ruby
jenrzzz has quit [Ping timeout: 248 seconds]
RickHull has joined #ruby
Ltem has joined #ruby
vee__ has joined #ruby
Psybur has quit [Ping timeout: 258 seconds]
bvcosta has joined #ruby
daemonwrangler is now known as derek-away
kies has joined #ruby
orbyt_ has joined #ruby
bvcosta_ has joined #ruby
kapil___ has quit [Quit: Connection closed for inactivity]
derek-away is now known as daemonwrangler
exhiled has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
tlaxkit has joined #ruby
orbyt_ has quit [Client Quit]
truenito has quit [Ping timeout: 268 seconds]
bvcosta has quit [Ping timeout: 258 seconds]
[Butch] has joined #ruby
exhiled has joined #ruby
uZiel has quit [Ping timeout: 248 seconds]
<weaksauce>
so after updating to high sierra I am trying to use capistrano to deploy but the gemfile is complaining about ruby version not being correct. I use chruby and select the correct version but every time it runs it switches to 2.3.3... all my `which bundler` and `which cap` and `which ruby` all point to the correct 2.1.3
<weaksauce>
any ideas where to start?
<havenwood>
weaksauce: are you using sudo?
cdg has quit [Remote host closed the connection]
<weaksauce>
in what sense havenwood
cdg_ has joined #ruby
<havenwood>
weaksauce: in the command you're running to deploy
<weaksauce>
the command i am using is `chruby 2.1.3 && be cap production deploy` where be is an alias to bundle exec
<havenwood>
weaksauce: ah, I think I misread what you wrote
<weaksauce>
maybe i just blow out the gems and try bundle install?
<weaksauce>
reinstall bundler?
ledestin has joined #ruby
milardov_ has joined #ruby
guille-moe has quit [Ping timeout: 258 seconds]
mfb2 has joined #ruby
muelleme has joined #ruby
Puffball has quit [Remote host closed the connection]
<weaksauce>
i do a `be ruby --version` and it spits out the correct version
<weaksauce>
it's something to do with capistrano as just trying to do a `be cap --version` spits out the error
milardovich has quit [Ping timeout: 240 seconds]
Puffball has joined #ruby
quobo has quit [Quit: Connection closed for inactivity]
wolfshappen has quit [Ping timeout: 255 seconds]
ramfjord has quit [Ping timeout: 255 seconds]
<weaksauce>
though actually bundler fails with the same message if i try to run a `bundle install` so `bundle exec ruby --version` works but `bundle install` fails
ramfjord has joined #ruby
wolfshappen has joined #ruby
urk187 has joined #ruby
daemonwrangler is now known as derek-away
marr has quit [Ping timeout: 248 seconds]
derek-away is now known as daemonwrangler
andikr has quit [Remote host closed the connection]
<cahoots>
hi, i want to use mechanize to log in at https://www.fabric.io/login, but mechanize seems unable to find the form. any ideas how to solve this?
tvw has quit [Remote host closed the connection]
kryptoz has joined #ruby
<Rouge>
here is my code
<RickHull>
mechanize, wow -- it's been a while since I've heard that library
<Rouge>
anyone able to explain why its not running
<RickHull>
cahoots: there is no HTML form on that page
<Rouge>
as in having title as a method and a variable?
<cahoots>
RickHull, when i open up the source code, i see a form with class .sdk-form
<RickHull>
interesting, when I view source -- the only form ctrl-f can find is in "platform"
<cahoots>
perhaps some js is adding it dynamically and mechanize only picks up on the initial html download?
kryptoz has quit [Ping timeout: 248 seconds]
<cahoots>
RickHull, inspect one of the form fields
<cahoots>
then in that source code view, you'll see the form
<RickHull>
i believe mechanize will just look at the page source, which has no form elements -- not sure
griffindy has joined #ruby
exhiled has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
griffindy has quit [Client Quit]
Psybur has joined #ruby
<RickHull>
Rouge: I'm surprised your last line, L30 doesn't have an error
rfoust has joined #ruby
<weaksauce>
anyone know why bundle would use system default ruby over the ruby that I select from chruby? bundle install uses system ruby bundle exec ruby --version uses the correct one selected by chruby
<Rouge>
RickHull, yeah i sort of know thats wrong
<Rouge>
but im getting that memory error
<Rouge>
regardless of that line
<RickHull>
Rouge: I don't see any memory errors
<Rouge>
what do you get when you run code?
eckhardt has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<RickHull>
i haven't tried, because it looks like L30 has a simple error
<RickHull>
the 2nd line there is just an inspect string, it looks like
<Rouge>
gime 2 mins
<Rouge>
sorry got mixed on a window
<Rouge>
em yeah
<Rouge>
so the name = Name.new
<RickHull>
I'm not sure if your -e is working as expected -- I would just put that code in the .rb file and call ruby.exe script.rb
eckhardt has joined #ruby
<Rouge>
my l30 needs arguments
<RickHull>
yes
cahoots has quit [Ping timeout: 268 seconds]
cahoots_ has joined #ruby
<Rouge>
which should be
Psybur has quit [Ping timeout: 240 seconds]
<Rouge>
name = Name.new(title, last_name, middle_name, last_name)
<Rouge>
?
<RickHull>
probably you would just put string literals in there: Name.new('king', 'john', 'q', 'public')
<haylon>
Hey everyone. Has anyone worked with JRuby and Ant tasks? I'm not sure what I would need to do with my Rake task to make it so I can include the Manifest into my JAR file.
<Rouge>
RickHull, yeah im trying to get from user input
rippa has quit [Quit: {#`%${%&`+'${`%&NO CARRIER]
<RickHull>
Rouge: you should decide between: create the object with values provided, or else create an empty object and prompt the user
<hays>
Anyone use ruby-installer? Curious how you upgrade your rubies
hays has quit [Changing host]
hays has joined #ruby
eightlimbed has quit [Ping timeout: 248 seconds]
<hays>
Anyone use ruby-installer? Curious how you upgrade your rubies
exhiled has joined #ruby
goyox86 has joined #ruby
silvermine has quit [Ping timeout: 258 seconds]
<hays>
it seems like it might be a pretty manual process of installing the new one, reinstalling gems, then deleting the old
<haylon>
@hays I usually just run the RubyInstaller for Windows and it took care of the upgrade .
<haylon>
are you on Windows or something else?
<hays>
oh sorry, mac/homebrew
<haylon>
Ah, I use rbenv on MacOS
<haylon>
and my Linux machines.
<hays>
i use it with chruby to keep 2.2, 2.3, 2.4 all on my system
<hays>
ahh rbenv. I'm not experienced with that, since im using chruby
Rapture has quit [Ping timeout: 248 seconds]
exhiled has quit [Client Quit]
ShekharReddy has quit [Quit: Connection closed for inactivity]
milardov_ has quit [Ping timeout: 268 seconds]
lxsameer has quit [Ping timeout: 240 seconds]
nadir has joined #ruby
Winwin has quit [Excess Flood]
kitsunenokenja has joined #ruby
muelleme has quit [Ping timeout: 268 seconds]
cdg_ has quit [Remote host closed the connection]
<RickHull>
hays: do you mean ruby-install ?
Cohedrin has joined #ruby
<hays>
RickHull: yes
<RickHull>
generally ruby-install and chruby are used together, or ruby-build and rbenv
<hays>
yeah, i am curious if there is a way to upgrade the rubies to the latest minor versions or something similar
<RickHull>
to "upgrade" a ruby means to install a newer version. so if you have ruby-2.4.0, you can install ruby-2.4.1
<RickHull>
(etc)
AlexRussia has joined #ruby
<weaksauce>
I use ruby-install and chruby. usually works just fine other than bundler trying to use the system ruby now
goyox86_ has joined #ruby
<haylon>
So you'd have two versions, the old one and newer one
goyox86 has quit [Ping timeout: 268 seconds]
goyox86_ is now known as goyox86
goyox86 has quit [Client Quit]
<hays>
ok so people just manage this manually
<RickHull>
try ruby-install --latest
<hays>
install new ruby, move gems over, delete the old one
<hays>
I have 5 rubies I keep going
<RickHull>
that's right -- it's meant to be an isolated environment tied to the ruby version
<RickHull>
unlike doing say `apt upgrade`
<hays>
jruby, ruby 2.2, 2.3, 2.4,rbx
dionysus69 has quit [Ping timeout: 248 seconds]
<hays>
so its a bit of a maintenance item for me
knight33 has joined #ruby
mtkd has quit [Read error: Connection reset by peer]
<hays>
I wonder i gem install < list.txt works
<RickHull>
there may be a way to move the gems over, or it would be easily scriptable if not
<RickHull>
havenwood: ^
mtkd has joined #ruby
<RickHull>
hays: in general, I would just develop on one or two ruby versions, and use travis (or similar) to test on other rubies
<havenwood>
hays: so the problem with using gems between teeny versions of ruby is actually the gem executable shebangs.
<havenwood>
hays: you can get an env-based shebang with the --env-shebang flag.
<havenwood>
hays: i do set that flag in my gemrc so i'm able to use gems when i upgrade Ruby to an ABI-compatible version with previously installed gems
<havenwood>
hays: gem: "--env-shebang"
<haylon>
btw, figured out my problem with my JRuby stuff. I wasn't undersatnding how it was dealing with the XML "translations". Had a do...end in the wrong spot
<havenwood>
^ that in your ~/.gemrc should do the trick
<RickHull>
havenwood: just to make it clear, say ruby-2.4.0 is installed with 10 gems; if ruby-2.4.1 is then installed, with the ~/.gemrc env-shebang thing, those 10 gems will be available for 2.4.1 ?
<havenwood>
RickHull: yes
<havenwood>
RickHull: the fix so that *just happens* has been PRed to RubyGems but last I recall it was awaiting a breaking version bump to go live.
<hays>
hmm. that works with chruby?
bvcosta_ has quit []
<havenwood>
sec, i'll find the issue
<havenwood>
hays: yes
<hays>
neat
<hays>
modern environments are so complex.. i don't really follow how they are setup anymore. its just a bit of magic
<RickHull>
in this case, it's not too bad. ruby executables live in some bin/ somewhere, and PATH manipulation finds them. likewise, rubygems stuff has its own filesystem layout, and you just need the right config to point to them
ur5us has joined #ruby
ShekharReddy has joined #ruby
<weaksauce>
RickHull you have any idea why bundler would use the system ruby over the chruby that it should?
<RickHull>
a lot of this is hidden from end users by tooling
<RickHull>
weaksauce: it could be that bundler is looking for ruby before executing any chruby hooks
<havenwood>
weaksauce: make sure bundler is installed with the chruby version of ruby you've selected
<havenwood>
weaksauce: gem install bundler
<havenwood>
weaksauce: confirm: which bundle
<havenwood>
weaksauce: and: gem which bundler
<weaksauce>
i get a segfault on the second command gem which bundler havenwood
<weaksauce>
the first command looks correct though
eightlimbed has joined #ruby
FrostCandy has joined #ruby
<weaksauce>
where do gems get installed normally?
<weaksauce>
i want to just blow out everything and start over
<RickHull>
weaksauce: run `gem which` without any chruby hooks
<RickHull>
er, `gem env`
<RickHull>
that means using your system `gem` -- so either don't run chruby hooks on a new bash session, or find the path and execute it directly
Rapture has joined #ruby
ldepandis has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<havenwood>
weaksauce: no use of sudo involved? take a look at your $PATH env var, is it as expected?
<havenwood>
echo $PATH
jackjackdripper has quit [Quit: Leaving.]
<weaksauce>
havenwood no sudo. this is all because i updated to high sierra and everything was working fine before that
hays has quit [Remote host closed the connection]
<weaksauce>
the path does look a bit funky havenwood though I don't see anything inside my .zshenv that would set that other than chruby perhaps?
eightlimbed has quit [Remote host closed the connection]
<weaksauce>
everything points to 2.1.3 and yet it thinks it is running 2.3.3
<havenwood>
weaksauce: gem pristine --all
<weaksauce>
the problem with that is that those gems that it is complaining about are the ones from the system ruby
impermanence has joined #ruby
<weaksauce>
alright. blowing out the ~/.gem folder seems to have fixed something
truenito has joined #ruby
minimalism has quit [Quit: minimalism]
mson has quit [Quit: Connection closed for inactivity]
Rouge has quit [Ping timeout: 248 seconds]
jamesaxl has quit [Quit: WeeChat 1.9.1]
cahoots_ has quit [Ping timeout: 240 seconds]
truenito has quit [Ping timeout: 248 seconds]
tomphp has joined #ruby
vee__ has joined #ruby
zautomata has joined #ruby
eckhardt has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
TinkerTyper has quit [Read error: Connection reset by peer]
TinkerTyper has joined #ruby
troys is now known as troys_
vee__ has quit [Ping timeout: 255 seconds]
safetypin has quit [Ping timeout: 260 seconds]
br0d1n has quit [Quit: Leaving]
impermanence has quit [Remote host closed the connection]
Rapture has quit [Ping timeout: 250 seconds]
Mia has joined #ruby
Mia has quit [Changing host]
Mia has joined #ruby
jaruga has quit [Ping timeout: 240 seconds]
dp has joined #ruby
cahoots has joined #ruby
<dp>
Are there any tools that will take a directory of ruby classes/scripts/etc and build some kind of map showing how everything is intertwined so I can trace down the issue that I'm having? Maybe even something to generate html documentation for them?
milardovich has joined #ruby
<apeiros>
dp: rdoc and yard
Rouge has joined #ruby
<dp>
apeiros: awesome, thanks!
dp has quit [Client Quit]
eckhardt has joined #ruby
ap4y has joined #ruby
shinnya has joined #ruby
vee__ has joined #ruby
milardovich has quit [Ping timeout: 268 seconds]
eightlimbed has quit [Ping timeout: 240 seconds]
leitz has joined #ruby
daemonwrangler is now known as derek-away
rabajaj has quit [Remote host closed the connection]
mjolnird has quit [Remote host closed the connection]
Psybur has joined #ruby
mfb2 has quit [Remote host closed the connection]
knight33 has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
cdg has joined #ruby
vee__ has quit [Ping timeout: 240 seconds]
Ltem has quit [Quit: Leaving]
eightlimbed has joined #ruby
Psybur has quit [Ping timeout: 250 seconds]
Rapture has joined #ruby
drowze has quit [Ping timeout: 268 seconds]
knight33 has joined #ruby
oetjenj has joined #ruby
eightlimbed has quit [Ping timeout: 248 seconds]
Rouge has quit [Ping timeout: 240 seconds]
vee__ has joined #ruby
houhoulis has joined #ruby
cahoots_ has joined #ruby
milardovich has joined #ruby
knight33 has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
reber has quit [Remote host closed the connection]
cahoots has quit [Ping timeout: 240 seconds]
d10n-work has quit [Quit: Connection closed for inactivity]
carnegie has joined #ruby
knight33 has joined #ruby
milardovich has quit [Ping timeout: 240 seconds]
cdg has quit [Ping timeout: 250 seconds]
rainbowz has joined #ruby
mikeiniowa has quit [Remote host closed the connection]
Cohedrin has quit [Read error: Connection reset by peer]
lexruee has quit [Ping timeout: 255 seconds]
megamosaren has joined #ruby
Cohedrin has joined #ruby
mikeiniowa has joined #ruby
<leitz>
Design question. Class Character holds data and a few methods. Mixin CharacterTools has all the stuff to modify CharacterData. Presenter is used to format output. Right now Character requires CharacterTools, is it an issue that a bunch of methods are mixed in even though they only get used on initialization?
mson has joined #ruby
lexruee has joined #ruby
muelleme has joined #ruby
<weaksauce>
not sure what you are asking leitz
synthroi_ has quit []
<weaksauce>
what's your concern about it?
<leitz>
Mostly bloated code. The first version had all the methods directly in Class Character. Wasn't sure if the mixin was as bloated or what.
<leitz>
There will be other mixins, trying to figure out how to prepare for them.
<weaksauce>
i wouldn't worry too much about bloat at this stage... were you able to refactor that long method from earlier?
<leitz>
Wondering if there's a Design Pattern to solve the issue and give me a reason to learn patterns.
<leitz>
Removed 11 lines, added sample. The next round of refactor is what has me on this question.
<weaksauce>
nice. design is a bit nebulous at times and sometimes there are no great ways to do something only less bad ways
<leitz>
hehe...
<weaksauce>
a factory might be the pattern you are looking for
<weaksauce>
if it's only about initialization stuff
<leitz>
Yup, most of the data will be set once and then done.
<leitz>
But the Character doesn't need to carry all the other stuff.
* leitz
found a blog post on factory.
milardovich has joined #ruby
<weaksauce>
internally the mixins don't get added to every object of that class. they get added to the definition of the class and then that's used at runtime.(unless you redefine it on the actual object)
<weaksauce>
the factory pattern is used heavily in java and less so in ruby
tvw has joined #ruby
<leitz>
So the next task should be "trim methods" as opposed to "Figure out factory"?
<weaksauce>
i would say so yeah.
carnegie has quit [Remote host closed the connection]
jaruga has joined #ruby
<leitz>
Okay, let me see what I can do. I have the next few days off.
carnegie has joined #ruby
milardovich has quit [Remote host closed the connection]
milardovich has joined #ruby
urk187 has quit [Remote host closed the connection]
tlaxkit has quit [Quit: ¡Adiós!]
helpa has quit [Remote host closed the connection]
helpa has joined #ruby
jaruga has quit [Client Quit]
carnegie has quit [Remote host closed the connection]
carnegie has joined #ruby
<weaksauce>
leitz design in programming is one of the more contentious issues programmers face off on... in general rubists are for small easily testable methods though. long methods are a code smell.
milardovich has quit [Ping timeout: 248 seconds]
<RickHull>
leitz: FWIW I am not a fan of mixins
<leitz>
RickHull, you would be if you read my original code.
<RickHull>
link to Character class?
larcara has quit [Remote host closed the connection]
<leitz>
RickHull; there's a large group of careers to use for data, depending on the career the person chooses.
tomphp has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Psybur has joined #ruby
<RickHull>
sure, I suspect we can make this work in a straightforward way
<RickHull>
that said, there a couple more aesthetic things that would be worth fixing sooner rather than later
nopolitica has joined #ruby
<leitz>
weaksauce, CharacterTools is a mixin, would it still crete "class methods"?
<leitz>
RickHull, yup. Working on the first round of refactoring. Long list of fixes. :)
<RickHull>
ruby conventions say, for a class like CharacterToolStuffThingie, that the file should be named character_tool_stuff_thingie.rb
<weaksauce>
leitz make it a class instead of a module and then make the methods class methods
megamosaren has quit [Quit: Leaving]
<RickHull>
ruby projects generally never have uppercase letters in filenames
<RickHull>
i'm sure it will be annoying to try to change all of this and lots of stuff will break
<RickHull>
and right now you are itching to figure out conceptual stuff
<RickHull>
but try to consider whether it will be better to fix the aesthetics sooner or later
<leitz>
Okay, help me prioritize. 1) Change CharacterTools to a class with class methods. 2) Refactor methods so they are cleaner first. Which is best to start on?
<leitz>
Or is there a third or forth option?
<leitz>
fourth
<RickHull>
I recommend 1. fix aesthetics (load path, requires, filenames)
<RickHull>
don't make any functional changes
<RickHull>
assuming your tests pass now, you can fix the aesthetics and make sure tests still pass
<RickHull>
some tests will need some editing, presumably, as they will require filenames that have changed
<RickHull>
and you are probably doing other unnecessary load path manipulation in code
<RickHull>
if you execute your tests with a Rake::TestTask -- rake does the load path for you
<RickHull>
otherwise, I just execute a single test file like: `ruby -Ilib test/the_file.rb`
cdg has joined #ruby
<RickHull>
and my test files are written so that they require what they need and execute successfully, barring a test failure
<leitz>
Current tests fail one on one but pass under the testsuite
rikkipitt has joined #ruby
Psybur has quit [Ping timeout: 248 seconds]
<RickHull>
ok, that's kind of a concern
<leitz>
weaksauce, weigh in on priority?
polishdub has quit [Quit: leaving]
<leitz>
RickHull, yup. I think it's back to the load path.
<weaksauce>
first_name_query = db.prepare "SELECT * from humaniti_#{gender}_first ORDER BY RANDOM() LIMIT 1" something like that could be all in one database with a few more columns. like species, and gender that you then limit with a where clause
<RickHull>
leitz: what I would do is rip out the load path stuff, and change the requires so they do lowercase
tomphp has joined #ruby
<RickHull>
then without changing anything else, you can `ruby -Ilib test/tc_Army.rb`
<weaksauce>
leitz i'd probably change the lower hanging fruit like RickHull suggested
<RickHull>
(and it will fail because it can't require 'army')
<RickHull>
then go and rename lib/Army.rb to lib/army.rb
<RickHull>
see what fails, rename, rinse, repeat
<leitz>
Sounds like a good evening. :) New branch "refactor_muster_out", using a broad definition of "refactor".
<RickHull>
hm, where does Army.rb even live?
<leitz>
Careers/Archive. I changed the layout and only put a few in the new format.
<RickHull>
so you would: require 'careers/archive/army'
tomphp has quit [Client Quit]
<RickHull>
and rename Army.rb to army.rb
<RickHull>
now some other stuff in lib/ may not be able to find it
<RickHull>
but you can use test/tc_Army.rb to drive your changes until that file passes tests
<leitz>
Would probably reformat it and move it out of archive. Only the Chargen and Tests need it.
<RickHull>
i wouldn't start reorganizing at the same time
<RickHull>
just change one set of things at a time. lowercase filenames e.g.
AlexRussia has quit [Ping timeout: 240 seconds]
<RickHull>
rip out load path stuff, and move requires to the top, and rename files to lowercase
jackjackdripper has joined #ruby
<RickHull>
all of those can be done at once -- and you are just dealing with requires
tomphp has joined #ruby
troys_ is now known as troys
<leitz>
So tc_navy.rb should require tools/character_tools and careers/navy?
mim1k has joined #ruby
<leitz>
Assuming I use ruby -llib test/tc_navy.rb
<RickHull>
yes, presumably
<RickHull>
it depends on what classes / methods etc are called by test/tc_navy.rb
<RickHull>
at the top of test/tc_navy.rb should be a number of requires according to what test/tc_navy.rb calls
<RickHull>
for my test files, I generally have 2 or 3 requires: require 'minitest/autorun; require 'some_class'; require 'maybe/some/other/module'
<leitz>
Well, let me go blow things up and see what happens.
<RickHull>
sometimes you can have a test_helper.rb or spec_helper.rb
<RickHull>
in that case, it doesn't live in lib/ and so the standard `-I lib` won't help you
<RickHull>
that's where you require_relative `./spec_helper`
<RickHull>
er, `require_relative './spec_helper'`
<RickHull>
e.g. from within test/tc_navy.rb assuming test/spec_helper.rb exists
bilal80 has joined #ruby
<RickHull>
i'm not sure if `require_relative 'spec_helper'` works or if `require_relative './spec_helper'` is needed
milardovich has joined #ruby
mim1k has quit [Ping timeout: 248 seconds]
<RickHull>
you might think that you could `-I lib -I test` but in my projects at least, the filenames in lib/ and test/ would conflict and require would get confused
oetjenj has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
milardovich has quit [Remote host closed the connection]
milardovich has joined #ruby
mfb2 has joined #ruby
<RickHull>
also, it's good to do this work on a branch, if you're comfortable with that
DLSteve has quit [Quit: All rise, the honorable DLSteve has left the channel.]
<leitz>
Okay, so I'm running "ruby -llib test/tc_navy.rb" and getting a LoadError on line 6, tools/character_tools.
<RickHull>
is there a branch or something where I can see the latest code?
ruby[bot] has quit [Remote host closed the connection]
<leitz>
Breaking it up like that let me work on one set of things at a time but still keep testing.
yokel has joined #ruby
ruby[bot] has joined #ruby
<leitz>
Ah, require_relative tc_navy
mfb2 has quit [Ping timeout: 260 seconds]
* leitz
goes to beat up the Nobles.
gone_haywire has quit [Ping timeout: 248 seconds]
mfb2 has joined #ruby
<RickHull>
in general, if your file in test/ has tests, you don't want to require it
<leitz>
How do you do sets of tests?
<RickHull>
you would only want to require a file in test/ if that file contains class/module/method definitions, or possibly some common requires
char_var[buffer] has joined #ruby
<RickHull>
the basic way: `ruby -Ilib test/*.rb` # should work
<RickHull>
or use Rake::TestTask
<RickHull>
inside your Rakefile
<RickHull>
each file that contains tests should just run on its own, and your test suite consists of running each of these files on their own
ta_ has quit [Read error: Connection reset by peer]
<leitz>
That's currently what the ts file does, though it sounds incorrectly.
<RickHull>
when I say run on its own, I mean execute as passed to ruby, e.g. `ruby -Ilib test/tc_navy.rb`
thinkpad has joined #ruby
<RickHull>
you would not try to execute test/tc_navy.rb via require
jackjackdripper1 has joined #ruby
jackjackdripper has quit [Ping timeout: 240 seconds]
mfb2 has quit [Ping timeout: 248 seconds]
<RickHull>
let me say that, what I am describing is the baseline way to run tests -- it may be possible and even desirable to run tests via require or some other structural methodology
rainbowz has quit [Ping timeout: 258 seconds]
ta_ has joined #ruby
<RickHull>
but I think it's better to understand the baseline -- and only go beyond it as necessary. I've never felt a need to
<RickHull>
if you understand how things at a baseline level, you will have much better judgment for deciding do things differently
<weaksauce>
i do like the baseline method because it removes some complications
<weaksauce>
leitz one method is to just do a Dir.each("pathtotestdir") do |testfile| ruby testfile end or something along those lines to not have to have a file full of tests to run
knight33 has joined #ruby
<weaksauce>
use globs to only get the files that start with test etc.
<RickHull>
nah, see Rake::TestTask
<RickHull>
just define a pattern
<weaksauce>
but the method that RickHull uses is easier
<RickHull>
and rake handles the load path stuff for you
<leitz>
RickHull, the rake/testtask file isn't there.
<RickHull>
you may need the rake gem installed
<RickHull>
but I'd expect its available in stdlib with any recent ruby
<leitz>
But line 4 would be t.pattern = 'test/tc_*.rb' ?
<RickHull>
here are some common patterns:
<leitz>
Ah, that references rake, not a directory in your tree.
<RickHull>
test/*.rb
<RickHull>
test/test_*.rb
<RickHull>
test/**/*.rb
larcara has joined #ruby
<RickHull>
test/tc_*.rb is workable, if that's what you want
<RickHull>
you can define several Rake::TestTasks with different names
mjolnird has joined #ruby
kitsunenokenja has quit [Ping timeout: 250 seconds]
lupine has joined #ruby
<RickHull>
that execute different suites, defined by pattern
<weaksauce>
** is a recursive glob if you didn't know so it will expand every directory under test and run every .rb file
<RickHull>
i tend to put all my test files in a flat dir structure in test/
<RickHull>
and i'll put some benchmark stuff in test/bench/
<RickHull>
so i'll have Rake::TestTask.new(:test) and Rake::TestTask.new(:bench)
<RickHull>
with patterns test/*.rb and test/bench/*.rb
<RickHull>
that way, the bench stuff isn't run when I just want tests
<RickHull>
if the pattern were test/**/*.rb then the bench stuff would get run
<weaksauce>
you can also do something like test/tests/integration/*.rb and test/tests/unit/*.rb and whatever else. if you want to run all the tests just do test/tests/**/*.rb... there is a lot of different options here depending on how big your test suite gets and how granular you want to be.
Psybur has joined #ruby
bilal80 has joined #ruby
larcara has quit [Ping timeout: 248 seconds]
Guest70176 has joined #ruby
Rouge has quit [Ping timeout: 268 seconds]
<leitz>
Okay, moved most of the failing tests into test/archive, added RickHull's stuff to the rakefile, and things work. So far.
guardianx has joined #ruby
<RickHull>
hooray \o/
sepp2k has quit [Quit: Leaving.]
<weaksauce>
progress... commit that and keep going
<weaksauce>
you can always rebase later if you want to squash things
orbyt_ has joined #ruby
heinrich5991 has joined #ruby
Guest70176 has quit [Ping timeout: 248 seconds]
Psybur has quit [Ping timeout: 240 seconds]
jamiejackson has quit [Ping timeout: 248 seconds]
* leitz
goes to feed the beasts and stretch his legs for a few minutes.
QualityAddict has quit [Quit: Leaving]
volty has joined #ruby
eckhardt has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
knight33 has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
troys is now known as troys_
Algebr has joined #ruby
troys_ is now known as troys
<Algebr>
I have a OpenSSL::X509 object and when I do .to_s, it gives me the PEM format of the cert, but I want a p12 style format. any quick easy ways?
Rouge has joined #ruby
qu1j0t3 has left #ruby ["WeeChat 0.4.3"]
mtkd has quit [Ping timeout: 248 seconds]
mtkd has joined #ruby
webguynow has quit [Ping timeout: 240 seconds]
hays has joined #ruby
hays has quit [Changing host]
hays has joined #ruby
webguynow has joined #ruby
kitsunenokenja has joined #ruby
Anaasaa has joined #ruby
<Algebr>
oh nvm, figured it out
milardov_ has joined #ruby
eckhardt has joined #ruby
milardov_ has quit [Client Quit]
rwb has joined #ruby
Puffball has quit [Remote host closed the connection]
milardovich has quit [Ping timeout: 240 seconds]
ShekharReddy has quit [Quit: Connection closed for inactivity]