LoneHermit has quit [Remote host closed the connection]
fullofcaffeine has quit [Remote host closed the connection]
riskish has quit [Read error: Connection reset by peer]
millerti has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
fullofcaffeine has joined #ruby
x0f has quit [Ping timeout: 260 seconds]
fullofcaffeine has quit [Ping timeout: 245 seconds]
kriskropd has quit [Quit: WeeChat 0.4.2]
ddffg has quit [Ping timeout: 244 seconds]
CloCkWeRX has quit [Quit: Leaving.]
djbkd has joined #ruby
kriskropd has joined #ruby
kriskropd has quit [Client Quit]
mikecmpbll has quit [Quit: inabit. zz.]
x0f has joined #ruby
CamonZ has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
kriskropd has joined #ruby
careta has quit [Ping timeout: 265 seconds]
frozengeek___ has quit [Quit: frozengeek___]
uxp_ has joined #ruby
tuxaddicted_back has joined #ruby
djbkd has quit [Remote host closed the connection]
sid_fules has joined #ruby
roamingdog has joined #ruby
zenguy_pc has quit [Ping timeout: 256 seconds]
defhlt has quit [Ping timeout: 256 seconds]
trajing has quit [Ping timeout: 260 seconds]
trajing has joined #ruby
uxp has quit [Ping timeout: 256 seconds]
zenguy_pc has joined #ruby
icedp has joined #ruby
GBrawl has quit [Quit: (null)]
<hightower2>
Yo, what's an elegant way to get epoch seconds of the time the current process was started?
<matthewd>
hightower2: I suspect the elegant way is to store the time, when the process starts. Looks like getting it later from the kernel is not so fun.
trake has joined #ruby
ledestin has joined #ruby
millerti has joined #ruby
<hightower2>
matthewd, right, it doesn't seem very nice doing it through kernel-related functions. But it appears there's a way -- the directory /proc/PID's creation time, which can be gotten with stat(), is the start time.
tuxaddicted_back is now known as tuxaddicted
millerti has quit [Max SendQ exceeded]
sid_fules has quit [Read error: Connection reset by peer]
lel has quit [Ping timeout: 265 seconds]
brent__ has joined #ruby
lel has joined #ruby
nettoweb has quit [Ping timeout: 248 seconds]
<brent__>
i'm trying to write some rspec tests, and getting "no such file or directory @rb_sysopen - sample.json'. My initialize method of the class i'm testing takes a file path. Is ther something i'm missing for passing a file to a test subject?
nettoweb has joined #ruby
nicokavts has quit [Ping timeout: 260 seconds]
<matthewd>
hightower2: Ah, cool. Probably not super portable, but that's less often a real concern these days, at least for individual apps.
<matthewd>
brent__: Obvious guess would be that the current directory isn't what you think it is
<brent__>
so my spec file is under /spec/test_spec.rb
j416 has quit [Ping timeout: 268 seconds]
<brent__>
i put the json in /spec/sample.json
<brent__>
and did let(:test) {Test.new('sample.json')}
ledestin has quit [Ping timeout: 260 seconds]
libastral has quit [Ping timeout: 256 seconds]
<matthewd>
So, yes.
s2013 has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
jeanlinux has joined #ruby
<matthewd>
It's looking for the file relative to your process's current working directory, not relative to the source file that happened to contain the string
j416 has joined #ruby
enterprisey has joined #ruby
sepp2k has quit [Read error: Connection reset by peer]
<matthewd>
brent__: File.join(__dir__, 'sample.json') will give you what you want
whathappens has joined #ruby
c0mrad3 has quit [Quit: Connection closed for inactivity]
libastral has joined #ruby
jgt has joined #ruby
<brent__>
matthewd: thank you, that worked
aupadhye has joined #ruby
whathappens has quit [Ping timeout: 245 seconds]
guacamole has quit [Quit: Lost terminal]
roamingdog has quit [Remote host closed the connection]
tau has quit [Remote host closed the connection]
guacamole has joined #ruby
jgt has quit [Ping timeout: 260 seconds]
nettoweb has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
djellemah has quit [Ping timeout: 256 seconds]
Jackneill has quit [Read error: Connection reset by peer]
tau has joined #ruby
tau has quit [Remote host closed the connection]
djellemah has joined #ruby
tau has joined #ruby
kermit_ has joined #ruby
MrBusiness2 has quit [Read error: Connection reset by peer]
harai has quit [Ping timeout: 260 seconds]
LoneHerm_ has joined #ruby
Azure has quit [Read error: Connection reset by peer]
nettoweb has joined #ruby
lel has quit [Read error: Connection reset by peer]
LoneHerm_ has quit [Ping timeout: 250 seconds]
Azure has joined #ruby
pawnbox has joined #ruby
djbkd has joined #ruby
aryaching has quit [Ping timeout: 250 seconds]
lel has joined #ruby
marr has quit [Ping timeout: 246 seconds]
pawnbox has quit [Remote host closed the connection]
djbkd has quit [Ping timeout: 256 seconds]
douglascorrea has joined #ruby
harai has joined #ruby
Madplatypus has joined #ruby
kermit_ has quit [Ping timeout: 250 seconds]
aryaching has joined #ruby
galeido has quit [Ping timeout: 256 seconds]
LoneHerm_ has joined #ruby
mikeiniowa has quit [Remote host closed the connection]
galeido has joined #ruby
nettoweb has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
jenrzzz has joined #ruby
jenrzzz has quit [Changing host]
jenrzzz has joined #ruby
harfangk has joined #ruby
mikeiniowa has joined #ruby
charliesome has joined #ruby
roamingdog has joined #ruby
Littlemyu has joined #ruby
dviola has quit [Quit: WeeChat 1.6]
kermit_ has joined #ruby
brendan- has joined #ruby
jgnagy has joined #ruby
jgt has joined #ruby
ur5us has quit [Read error: Connection reset by peer]
<hays>
i have used rubyinstaller an chruby. any easy way to upgrade from 2.3.1 to 2.3.2 or just do complete reinstall and redo gems
jgnagy has quit [Ping timeout: 256 seconds]
<Radar>
ruby-install ruby 2.3.2
<Radar>
then change your ~/.ruby-version to ruby-2.3.2
ur5us has joined #ruby
jgt has quit [Ping timeout: 246 seconds]
<postmodern>
hays, install the new version. You could rename the ~/.gem/ruby/2.3.1 directory and run `gem pristin --all`
ur5us has quit [Read error: Connection reset by peer]
<hays>
ok ill give that a try
jgt has joined #ruby
<hays>
is there anything even close to comparable to chruby on a windows platform?
ur5us has joined #ruby
<hays>
right now ive got soem laptops that i just run rubyinstaller on, and if they need jruby or something i just remember to do jruby -S
<postmodern>
hays, i think there's pik, which was a windows version of RVM
<postmodern>
hays, but Windows now has a very solid Linux compatibility layer. You can run a Ubuntu base OS with bash on windows without virtualization
<hays>
ive heard of this--haven't tried it recently
brendan- has quit [Quit: My iMac has gone to sleep. ZZZzzz…]
ur5us_ has quit [Ping timeout: 240 seconds]
Jameser has joined #ruby
c355e3b has quit [Quit: Connection closed for inactivity]
cdg has quit [Ping timeout: 258 seconds]
enterprisey has joined #ruby
Channel6 has joined #ruby
lupine has quit [Ping timeout: 245 seconds]
roamingdog has quit [Remote host closed the connection]
roamingdog has joined #ruby
ledestin has joined #ruby
d^sh has quit [Ping timeout: 250 seconds]
d^sh has joined #ruby
trake has quit [Ping timeout: 248 seconds]
lupine has joined #ruby
Krython has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
roamingdog has quit [Remote host closed the connection]
ramfjord has joined #ruby
kermit_ has quit [Ping timeout: 260 seconds]
kermit_ has joined #ruby
kermit_ has quit [Client Quit]
enterprisey has quit [Quit: Leaving]
ur5us has quit [Read error: Connection reset by peer]
iateadonut has joined #ruby
ur5us has joined #ruby
roamingdog has joined #ruby
charliesome has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
Littlemyu has quit [Ping timeout: 248 seconds]
tvw has quit [Ping timeout: 246 seconds]
enterprisey has joined #ruby
jgt has joined #ruby
skweek has joined #ruby
iMadper has quit [Remote host closed the connection]
ur5us has quit [Remote host closed the connection]
jenrzzz has quit [Ping timeout: 245 seconds]
natevick has joined #ruby
nsturgess has joined #ruby
<nsturgess>
Can I ask some code questions about nested hashes in ruby?
roamingdog has quit [Remote host closed the connection]
c_nick has joined #ruby
s2013 has joined #ruby
ur5us has joined #ruby
<c_nick>
I launch 1000 jobs and am using Incredibuild to do the multithreading .. is there any better way to achieve it in ruby itself.
<c_nick>
or any other open source tool for the same?
natevick has quit [Client Quit]
<nofxx>
nsturgess, just ask
<nofxx>
c_nick, sidekiq
<nsturgess>
ok
solocshaw has joined #ruby
<nsturgess>
I have this line: raw_hash = {"nodes" => Hash.new { Hash.new {} }, "links" => Hash.new { Hash.new {} }}
<nsturgess>
I get this: 2.3.0 :116 > raw_hash["nodes"]["one"]["two"] = 1
<nsturgess>
=> 1
<nofxx>
c_nick, well, it uses redis...
<nsturgess>
But then this raw_hash["nodes"]["one"]["two"] returns nil? Haven’t used runy in a while and can’t figure out why
jenrzzz has joined #ruby
jenrzzz has joined #ruby
jenrzzz has quit [Changing host]
<nsturgess>
*ruby
<nofxx>
nsturgess, that's too confuse.... Hash.new is the same as {}, so try using only {}
<nsturgess>
ok
TPug has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
enterprisey has quit [Remote host closed the connection]
<c_nick>
nofxx, is there any disadvantage of using Redis ?
<nofxx>
nsturgess, and I guess you're one level short... raw = { 'nodes' => { 'one' => {} }, ..... maybe
<nsturgess>
yeah i think so too by the look of it
<nofxx>
c_nick, nope. you said 'in ruby' so not sure if you meant 'only in ruby' heh
<nofxx>
my bad
<matthewd>
nsturgess: Hash.new {|h,k| h[k] = {} }
solocshaw has quit [Ping timeout: 258 seconds]
<c_nick>
nofxx, ok not necessarily the main application is in ruby and i need something to handle the multithreading part - like incredibuild not necessarily in ruby ..
tau has quit [Remote host closed the connection]
<c_nick>
sidekiq is more of a paid stuff
<nofxx>
matthewd, that's cool
<nsturgess>
matthewd what is going on there?
<nofxx>
c_nick, it's not.. only things you don't need...
<nofxx>
c_nick, and it's better than threading, it forks the process, clean state.. those niceries
<c_nick>
hmm ok cool i will read their official wiki to understand it more :) thanks nofxx
<matthewd>
nsturgess: What you seem to intend; when that hash is accessed with an unknown key, it creates a new child hash and stores it in that key
shortdudey123 has quit [Remote host closed the connection]
TPug has joined #ruby
TPug has quit [Client Quit]
djbkd has joined #ruby
Tempesta has quit [Quit: See ya!]
Tempesta has joined #ruby
hanmac has quit [Ping timeout: 240 seconds]
s2013 has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
tmtwd has joined #ruby
tuxaddicted has quit [Quit: Leaving]
<nsturgess>
re: nofxx: nsturgess, that's too confuse.... Hash.new is the same as {}, so try using only {} just having {} doesn’t work
chrisja has quit [Quit: leaving]
ur5us has quit [Read error: Connection reset by peer]
ur5us has joined #ruby
djbkd has quit [Ping timeout: 258 seconds]
harai has quit [Ping timeout: 252 seconds]
fullofcaffeine has joined #ruby
jgt has quit [Ping timeout: 250 seconds]
User458764 has joined #ruby
GodFather has quit [Ping timeout: 265 seconds]
enterprisey has joined #ruby
jcao219 has quit [Ping timeout: 250 seconds]
noodle has quit [Ping timeout: 250 seconds]
[spoiler] has quit [Ping timeout: 268 seconds]
s2013 has joined #ruby
Puffball has quit [Ping timeout: 250 seconds]
SJr has quit [Ping timeout: 250 seconds]
[spoiler] has joined #ruby
Puffball has joined #ruby
hahuang65 has joined #ruby
optiz0r has quit [Ping timeout: 250 seconds]
SJr has joined #ruby
Apocalypse has quit [Quit: Input/Output Error]
libastral has quit [Ping timeout: 240 seconds]
hahuang65 has quit [Ping timeout: 256 seconds]
chopin has joined #ruby
noodle has joined #ruby
libastral has joined #ruby
hanmac has joined #ruby
User458764 has quit [Quit: My iMac has gone to sleep. ZZZzzz…]
tmtwd has quit [Quit: Leaving]
jgt has joined #ruby
redpants has quit [Read error: Connection reset by peer]
Apocalypse has joined #ruby
Felipe__ has joined #ruby
redpants has joined #ruby
dreinull has quit [Ping timeout: 268 seconds]
shortdudey123 has joined #ruby
d^sh has quit [Ping timeout: 248 seconds]
JoshL has quit [Ping timeout: 250 seconds]
mattp__ has joined #ruby
mattp_ has quit [Ping timeout: 250 seconds]
majoh has quit [Ping timeout: 256 seconds]
kriskropd has quit [Ping timeout: 250 seconds]
blackbombay has quit [Ping timeout: 258 seconds]
jgt has quit [Ping timeout: 256 seconds]
astrobunny has joined #ruby
JesseH has quit [Ping timeout: 250 seconds]
blackbombay has joined #ruby
sdothum has quit [Ping timeout: 250 seconds]
majoh has joined #ruby
kriskropd has joined #ruby
JesseH has joined #ruby
JoshL has joined #ruby
d^sh has joined #ruby
sdothum has joined #ruby
allcentu1 has quit [Ping timeout: 240 seconds]
nofxxx has joined #ruby
Felipe__ has quit [Remote host closed the connection]
Mia has joined #ruby
Mia has quit [Changing host]
Mia has joined #ruby
Axy has quit [Ping timeout: 244 seconds]
nofxx has quit [Ping timeout: 260 seconds]
User458764 has joined #ruby
optiz0r has joined #ruby
jackjackdripper1 has joined #ruby
brent__ has quit [Quit: Connection closed for inactivity]
exadeci has joined #ruby
jackjackdripper has quit [Ping timeout: 250 seconds]
ledestin has quit [Ping timeout: 260 seconds]
SeepingN has joined #ruby
lee__ has joined #ruby
<lee__>
Hi all, I'm trying to profile a simple ruby script that connects to google api. All I need is memory usage. Tried valgrind massif, doing /proc dumps. rbtrace --gc, even tried JRuby but that wornt work due to openSSL issues.
sphex has quit [Read error: Connection reset by peer]
ace05 has joined #ruby
sphex has joined #ruby
<mvxlr>
say i have 2 hash's hash1 and hash2 i want to compare several fields from these 2 to decide if they are equal or not, what's the right syntax to write something like compare(hash1, hash2).by([:id, :home_address, :has_drugs, :had_parties_before)
<mvxlr>
both hashes are Hashie::Dash based
lee__ has left #ruby ["Leaving"]
ace05 has quit [Remote host closed the connection]
firstdayonthejob has quit [Ping timeout: 268 seconds]
<iamse7en>
no need to be patronizing... ive spent like 30 minutes on it and can't find the answer.... all the work ive done is in the console with tons of syntax errors
blaxter has joined #ruby
<dminuoso>
iamse7en: Look, I'm not trying to be patronizing.
bayed has joined #ruby
<iamse7en>
was just hoping someone could point me in the right direction and not try to verify that i'm trying hard enough
<iamse7en>
really just looking for the answer at this point as i'm tired and frustrated :)
<dminuoso>
iamse7en: What's the issue then? Converting the BigDecimal? Getting to there?
<iamse7en>
getting to there.
ace05 has quit [Ping timeout: 245 seconds]
<iamse7en>
the arrays are messing me up i think
<iamse7en>
hash to array to hash.
<iamse7en>
hurting my head
<dminuoso>
iamse7en: Simple trick: Don't try to do it all in one line. Do it bit by bit.
x0f has quit [Ping timeout: 265 seconds]
x0f has joined #ruby
<dminuoso>
iamse7en: I just don't see what exact problem you have, so I cant be any more specific than that. Or show us what you have tried so far.
xrlk has joined #ruby
CloCkWeRX has joined #ruby
skweek has joined #ruby
vondruch has quit [Ping timeout: 248 seconds]
ledestin has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Roa has quit [Ping timeout: 248 seconds]
<mvxlr>
dminuoso: that you very much. appreciate it.
<mvxlr>
*thank
allcentu1 has joined #ruby
pandaant has quit [Remote host closed the connection]
SesMan has joined #ruby
harai has joined #ruby
ta_ has joined #ruby
<mvxlr>
regarding the predicate, i'm trying to understand how it works.
<dminuoso>
mvxlr: ->(k,v) {} is just short for lambda { |k, v| }
<gr33n7007h>
why is the latter two different memory address
M-shine has joined #ruby
davix[matrix] has joined #ruby
tobyn[m] has joined #ruby
kineticrootkit[m has joined #ruby
riotgsmport[m] has joined #ruby
Luca[m] has joined #ruby
meaggan[m] has joined #ruby
laithshadeed[m] has joined #ruby
bascht has joined #ruby
TheGillies has joined #ruby
cpfeilschifter[m has joined #ruby
M-mistake has joined #ruby
eliotk[m] has joined #ruby
M-manveru has joined #ruby
velu_aon[m] has joined #ruby
fladson[m] has joined #ruby
serah[m] has joined #ruby
User458764 has quit [Quit: My iMac has gone to sleep. ZZZzzz…]
biberu has joined #ruby
jeanlinux has quit [Remote host closed the connection]
jeanlinux has joined #ruby
jeanlinux has quit [Remote host closed the connection]
jeanlinux has joined #ruby
<gr33n7007h>
always 16 bytes difference
<gr33n7007h>
or 8 on 32bits
jeanlinux has quit [Ping timeout: 258 seconds]
<gr33n7007h>
oh, i see, the former two start directly where x is stored in memory
hightower2 has quit [Ping timeout: 250 seconds]
mim1k|wo1k has joined #ruby
jeanlinux has joined #ruby
jaruga___ has joined #ruby
<gr33n7007h>
or pointed to :p
mim1k|work has quit [Ping timeout: 250 seconds]
mim1k|wo1k has quit [Ping timeout: 252 seconds]
mim1k|work has joined #ruby
User458764 has joined #ruby
hightower2 has joined #ruby
blackwind_123 has quit [Ping timeout: 240 seconds]
bhavya has joined #ruby
<terens>
hello.I have a project with many models 30+. I want these models to be exported to several custom format. Currently each model has to_my_format method
<terens>
and a service class calls this method for each model. is there a way is there a way to organize it better?
<terens>
move that logic out of model?
<apeiros>
terens: rails?
blackwind_123 has joined #ruby
bhavya has left #ruby ["Leaving"]
<terens>
yes
<terens>
but has ruby only parts
<apeiros>
rails has a concept for serializers. take a look at that.
<apeiros>
?rails terens
<ruby[bot]>
terens: Please join #RubyOnRails for Rails questions. You need to be identified with NickServ, see /msg NickServ HELP
<apeiros>
and ^
<terens>
activemodels serializers?
<apeiros>
can't remember from the top of my head. but sounds like it could be in AM, yes.
<terens>
ok
Definity has joined #ruby
<terens>
i asked at ror
Rickmasta has joined #ruby
Rickmasta has quit [Client Quit]
<dminuoso>
apeiros: So our IT admin guy told me "Why would you want the scanner to send the documents via e-mail to your system? It would be far easier to just write a fat client and access the scanner with TWAIN".
<dminuoso>
Good to have these IT admins.
<apeiros>
dminuoso: ot? :)
<dminuoso>
Oh maybe I dont know.
<dminuoso>
Unless you can tell me about a neat ruby TWAIN library
<workmad3>
terens: you could also consider writing your own serializers that take a model as an argument and produce an output format using `serializable_hash` (which is a standard method added to ActiveRecord-based models and feeds things like JSON and XML serialization)
<apeiros>
I'd have to consult the toolbox
vondruch has left #ruby [#ruby]
<terens>
my problem is to write it clean
atmosx has joined #ruby
<terens>
currently i have a method to all models to_my_format
<workmad3>
terens: that's pretty clean... it means for a new format you write one serializer, and for a new model you just add the model
Burgestrand has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<workmad3>
and you encapsulate the details about the format away from the model
<terens>
yes but soon it becomes fat model
<workmad3>
terens: I mean using a serializer class that works on something like serializable_hash is pretty clean
doublemalt__ has joined #ruby
User458764 has quit [Quit: My iMac has gone to sleep. ZZZzzz…]
<terens>
but that model would have to be serialized in different formats for other services
<workmad3>
terens: right... one serializer per format
<terens>
i see
<terens>
makes sense
douglascorrea has joined #ruby
elaptics has joined #ruby
douglasc_ has joined #ruby
TomyWork has joined #ruby
rikkipitt has joined #ruby
|RicharD| has joined #ruby
douglascorrea has quit [Ping timeout: 258 seconds]
triangles has joined #ruby
charliesome has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
Madplatypus has quit [Quit: Connection closed for inactivity]
manjaro-kde5 has joined #ruby
charliesome has joined #ruby
lenwood has quit [Ping timeout: 250 seconds]
ocbtec has quit [Quit: leaving]
<gr33n7007h>
when you create an array, do the values get stored in reverse order in memory?
vondruch has joined #ruby
cassianoleal has joined #ruby
spicerack has joined #ruby
Ishido has joined #ruby
andrzejku has joined #ruby
GodFather has joined #ruby
<yorickpeterse>
gr33n7007h: ..no?
<yorickpeterse>
why would they?
<yorickpeterse>
They would be stored in-order, but they don't have to be placed directly next to each other
<gr33n7007h>
yorickpeterse: let me show you what i mean, one sec
tens0r has joined #ruby
xall has joined #ruby
allcentu1 has joined #ruby
tensor-dev has joined #ruby
jmignault has joined #ruby
emilkarl has joined #ruby
<dminuoso>
gr33n7007h: Why would you possibly care about the order in memory?
<yorickpeterse>
gr33n7007h: now in normal English please
vondruch has joined #ruby
<yorickpeterse>
as in, _describe_ what you're trying to do
<dminuoso>
gr33n7007h: Those two are how elements are stored. They are either embedded in a statically sized array, or moved into a dynamically (which gets realloc'ed as needed) contiguous array.
Burgestrand has joined #ruby
<gr33n7007h>
dminuoso: thanks
tk__ has joined #ruby
<jokke>
i'm trying to write a custom matcher that checks if a method was called on a double
<xrlk>
regex is dum
<gr33n7007h>
yorickpeterse: use fiddle to write a method to see if it's faster than [].reverse.values_at
<sts>
hello folks. anyone knows how to override PassengerBaseUri in apache? I'd like to serve a specific location not from mod_passenger.
nettoweb has quit [Ping timeout: 250 seconds]
iMadper has quit [Read error: Connection reset by peer]
<apeiros>
catphish: they should have put optional/custom rack env keys into a toplevel key named "nonportable"
<dminuoso>
catphish, haven't I see you around somewhere Aren't you a networking person?
<catphish>
dminuoso: yes
chouhoulis has quit [Remote host closed the connection]
monji has joined #ruby
<catphish>
i am chief networking, but i'm also a ruby developer :)
chouhoulis has joined #ruby
|RicharD| has quit [Ping timeout: 260 seconds]
<dminuoso>
Thought I recognized your name.
<apeiros>
so the cat is unrelated to animals but to cabling? :)
CloCkWeRX has quit [Ping timeout: 250 seconds]
redpants has joined #ruby
mim1k|wo1k has joined #ruby
handicraftsman has joined #ruby
handicraftsman has joined #ruby
handicraftsman has quit [Changing host]
mim1k|work has quit [Ping timeout: 256 seconds]
GodFather has quit [Ping timeout: 244 seconds]
terlar has joined #ruby
mvxlr has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
ben_____ has joined #ruby
nadir has joined #ruby
allcentu1 has quit [Ping timeout: 260 seconds]
ben__ has quit [Ping timeout: 256 seconds]
ben_____ has quit [Ping timeout: 258 seconds]
Snowy has quit [Read error: Connection reset by peer]
Snowy has joined #ruby
rikkipit_ has quit [Remote host closed the connection]
joonty1 has joined #ruby
rikkipitt has joined #ruby
GodFather has joined #ruby
charliesome has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
tuelz has quit [Quit: WeeChat 1.4]
tau has quit [Ping timeout: 265 seconds]
emilkarl has quit [Read error: Connection reset by peer]
rikkipit_ has joined #ruby
emilkarl has joined #ruby
rikkipitt has quit [Ping timeout: 268 seconds]
tvw has joined #ruby
emilkarl has quit [Read error: Connection reset by peer]
radic has quit [Ping timeout: 268 seconds]
jeanlinux has quit [Read error: Connection reset by peer]
<rob_>
hi, if i have a Log class i want to share between objects how should i best provide access to that class?
<catphish>
do you mean you have an instance of a logger?
<rob_>
ideally i just want each of my classes to be able to use a 'log' method so i was thinking i should include a module that has those methods
eggshke has quit []
radic has joined #ruby
<catphish>
the simplest way is with a class method somewhere, for example Rails provides the class method "Rails.logger" which can be called from anywhere
<catphish>
and that class method would always return the same instance of your logger class
<catphish>
class MyApplication; def self.logger; @logger||=MyLogger.new;end;end
nettoweb1 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<catphish>
that's the simplest approach i'm aware of, then you can always access the same instance of your logger class using MyApplication.logger
<catphish>
people prefer this to the even simpler (but frowned upon) aproach of creating a global variable: $logger = Logger.new
hutch34 has joined #ruby
<rob_>
catphish: ahh so if i store the logger in a class variable then i can include it into a load of modules and just use the 'logger' method to access the log?
<catphish>
i don't know why ruby has global variables, you key kicked in the face if yo use them :)
<catphish>
rob_: i believe so, i suppose this is much the same as creating a module with a constant, like:
<apeiros>
but your line 23 does not call that method.
<apeiros>
`foo =` never calls a method. it always sets a local variable.
harfangk has joined #ruby
JeanCarloMachado has quit [Ping timeout: 260 seconds]
ben__ has quit [Remote host closed the connection]
CrazyEddy has quit [Ping timeout: 240 seconds]
ben__ has joined #ruby
chouhoul_ has joined #ruby
hebroon has joined #ruby
<rob_>
thanks for the tips, i'll have a play and paste the code in a bit :)
allcentu1 has joined #ruby
ace05 has joined #ruby
cassianoleal has quit [Quit: Off to the other side!]
chouhoulis has quit [Ping timeout: 268 seconds]
aegis3121 has joined #ruby
Rodya_ has joined #ruby
Rodya_ has quit [Remote host closed the connection]
ace05 has quit [Ping timeout: 260 seconds]
nankyokusei has quit [Remote host closed the connection]
skweek has joined #ruby
Rodya_ has joined #ruby
nankyokusei has joined #ruby
alan_w_ has quit [Quit: WeeChat 1.4]
xall has quit [Ping timeout: 256 seconds]
alexherbo2 has joined #ruby
serard has joined #ruby
<serard>
Hello
eljimmy has quit [Ping timeout: 265 seconds]
rfoust has joined #ruby
xall has joined #ruby
<serard>
When I do something like "my_config.machines.each do |machine_config|", modifying machine_config.property will be done at the end of the block ?
<serard>
outside the block, I mean
Rodya_ has quit [Ping timeout: 258 seconds]
gingray has joined #ruby
pandaant has joined #ruby
<workmad3>
serard: not particularly likely... unless you've custom-coded a lot of tricky things, any modifications you make to an object will be reflected at the moment the operation is executed
<Cymew>
I'm looking at the API docs for File.open and I'm confused. If perm is 'wb' what on earth does that mean? Writable something?
<serard>
that's weird, I can modify strings in the block, but I cannot add a property to an OpenStruct object
<dminuoso>
serard: testcase.
chris2 has quit [Ping timeout: 250 seconds]
rikkipit_ has quit [Ping timeout: 252 seconds]
redpants has quit [Ping timeout: 256 seconds]
tk__ has quit [Quit: ばいばい]
rikkipitt has joined #ruby
chris2 has joined #ruby
allcentu1 has quit [Quit: WeeChat 1.2]
allcentury has joined #ruby
serard has quit [Ping timeout: 258 seconds]
gnufied has joined #ruby
hightower2 has quit [Ping timeout: 260 seconds]
anuxivm has joined #ruby
polysics has joined #ruby
etehtsea has joined #ruby
nobitanobi has joined #ruby
centrx has joined #ruby
<Cymew>
Not much works for me right now. "NoMethodError: undefined method `mktmpdir' for Dir:Class" what does that mean? I have 'Dir.mktmpdir("/tmp/apa")' in my code and I see no problem with that. huh?
tomphp has joined #ruby
<dminuoso>
Cymew: What Ruby version, flavour (CRuby, JRuby, Rubinius) and operating system are you on?
<dminuoso>
Cymew: The documentation should probably include a hint there.
<dminuoso>
Cymew: well indirectly it does if you look at the page closely (and realize that you're not inside the "Dir" class from core, but inside the tmpdir from the stdlib.
<dminuoso>
But I didnt notice either at first glance. :)
ben__ has joined #ruby
failshell has joined #ruby
jhack has joined #ruby
<Cymew>
dminuoso: Yeah, that worked. I did not notice that fact. It looked very much like the docs for Dir from core.
igniting has quit [Ping timeout: 245 seconds]
<Cymew>
That's kind of scary, though, as it means there must be some kind of require higher upp in the call chain of my code including 'tmpdir' that I've missed.
<dminuoso>
Cymew: It may have been indirect (through something else that requires 'tmpdir')
<dminuoso>
There's some way of figuring out how though.
<dminuoso>
Don't ask me how.
tens0r has quit [Ping timeout: 265 seconds]
<Cymew>
Better, but still scary as those implicit depenencies are a recipie for loosing some time in the future.
<Cymew>
s/depenencies/dependencies/
cdg has joined #ruby
<dminuoso>
Cymew: (Reason is if you look at stack traces, you see exact lines of where code is required from)
<dminuoso>
So Ruby has the information somewhere.
<Cymew>
I guess so.
<Cymew>
Thanks for the eagle eyes/
hightower2 has joined #ruby
nopolitica has quit [Quit: leaving]
dionysus69 has quit [Ping timeout: 260 seconds]
eclm has joined #ruby
ben_____ has joined #ruby
ben__ has quit [Ping timeout: 268 seconds]
skweek has quit [Ping timeout: 240 seconds]
vondruch_ has joined #ruby
last_staff has quit [Quit: last_staff]
failshell has quit []
skweek has joined #ruby
Definity has quit [Ping timeout: 245 seconds]
vondruch has quit [Ping timeout: 252 seconds]
nettoweb has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
ddffg has quit [Quit: Leaving]
rippa has joined #ruby
jhack has quit [Quit: jhack]
s2013 has joined #ruby
`tim` has joined #ruby
s2013 has quit [Client Quit]
terens has quit [Remote host closed the connection]
djbkd has joined #ruby
rikkipitt has quit [Remote host closed the connection]
Chair has joined #ruby
rikkipitt has joined #ruby
s2013 has joined #ruby
rikkipitt has quit [Remote host closed the connection]
rikkipitt has joined #ruby
rikkipitt has quit [Remote host closed the connection]
rikkipitt has joined #ruby
rikkipitt has quit [Remote host closed the connection]
jcao219 has joined #ruby
rikkipitt has joined #ruby
User458764 has joined #ruby
User458764 has quit [Max SendQ exceeded]
rikkipitt has quit [Remote host closed the connection]
User458764 has joined #ruby
rikkipitt has joined #ruby
rikkipitt has quit [Remote host closed the connection]
djbkd has quit [Ping timeout: 260 seconds]
saneax is now known as saneax-_-|AFK
rikkipitt has joined #ruby
rikkipitt has quit [Remote host closed the connection]
rikkipitt has joined #ruby
rikkipitt has quit [Remote host closed the connection]
Beams has quit [Quit: .]
rikkipitt has joined #ruby
eljimmy has joined #ruby
centrx has quit [Remote host closed the connection]
ace05 has joined #ruby
jhack has joined #ruby
Beams has joined #ruby
rikkipitt has quit [Ping timeout: 250 seconds]
ace05 has quit [Ping timeout: 250 seconds]
Rodya_ has joined #ruby
<xall>
i know the difference between a stub and a mock but what about double? is double comparable or does it just refer to a pretend object?
Snickers has quit [Ping timeout: 246 seconds]
dionysus69 has joined #ruby
palms has joined #ruby
<dminuoso>
xall: a double turns a regular object into a mock that you can shape.
<dminuoso>
it basically creates "a double of the object"
tercenya has quit [Remote host closed the connection]
tercenya has joined #ruby
Rodya_ has quit [Remote host closed the connection]
<gr33n7007h>
catphish: $stdin.sync = true ?
<catphish>
i have a tcp socket, i need to read a variable length line from it, then pass the socket to openssl, if i use gets, it reads too much data from the socket, and puts it somewhere that openssl no longer has access to
<Sindriava>
catphish: e.g. are you at a point, where curses could solve your problem more elegantly?
<jgnagy>
if message doesn't match /\n/, then it will be an Array of 1 String, so .each will still work
marxarelli has quit [Read error: Connection reset by peer]
skweek has quit [Ping timeout: 240 seconds]
Rodya_ has quit [Ping timeout: 245 seconds]
Macaveli has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<rob_>
jgnagy: thanks
stupidystupid has joined #ruby
`tim` has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
drzel has joined #ruby
blackbom1 has joined #ruby
serard has quit [Ping timeout: 244 seconds]
<jgnagy>
also, looking at it again, be careful with a method named #initialize on a Module... what is the purpose of this? Are you planning on including Log in a class?
kbdkode has quit [Quit: * ~ see ya ~ *]
gregf_ has quit [Ping timeout: 260 seconds]
blackbombay has quit [Ping timeout: 256 seconds]
lxsameer has joined #ruby
<rob_>
jgnagy: yeah
<jgnagy>
I didn't catch that this was a Module before, which makes your method scope (instance level rather than class / module) confusing
<jgnagy>
ah, are you doing different logging things per instance of a class?
nikivi has joined #ruby
<rob_>
its confusing for me too, but it just seems to work, i was basically asking how to do this kind of thing "properly"..
claudiuinberlin has quit []
<rob_>
i want to include Log into multiple classes and use the same logging instance
<jgnagy>
Using a module like this is fine, but for logging, it is more typical to use a Singleton (so Module methods, for instance)
fullofcaffeine has joined #ruby
<jgnagy>
meaning just rename #initialize to something else (like .setup), and make everything class / module level methods
<jgnagy>
then, anywhere in your classes that include Log, don't include it
<rob_>
jgnagy: so all my method calls would look like: Log.info?
<jgnagy>
and rename info() to Log.info()
<jgnagy>
yes
<rob_>
i was trying to avoid doing that
<jgnagy>
hmmmm may I ask why?
jhack has quit [Quit: jhack]
psychicist__ has joined #ruby
careta has joined #ruby
<rob_>
is it bad?
<jgnagy>
you can avoid it in your class definition(s) by making an instance method that further wraps it
jhack has joined #ruby
aufi has quit [Quit: Leaving]
nankyokusei has quit [Remote host closed the connection]
jackjackdripper has joined #ruby
andikr has quit [Remote host closed the connection]
<jgnagy>
in your class, #info(message) could just be a wrapper for Log.info(message)
Sindriava has quit [Quit: _]
<jgnagy>
but using a singleton for logging is pretty typical
<rob_>
jgnagy: im trying to understand why the way ive done it is bad?
plugine has joined #ruby
<jgnagy>
"bad" is subjective
troulouliou_div2 has quit [Ping timeout: 252 seconds]
<jgnagy>
this is not typical because you'll have loggers defined on each instance of whatever class you include Log in
<jgnagy>
that is a lot of redundancy
<jgnagy>
each instance of your classes will independently open STDOUT, for instance
<dminuoso>
Listen to rudolf.
<dminuoso>
He knows.
<rob_>
jgnagy: but since im using a class variable to store the logger i thought it wouldnt..
<rob_>
loggers, rather
fullofcaffeine has quit [Ping timeout: 258 seconds]
<rob_>
i.e: it shares the state between all the classes which include Log.. i tested this by writing out the object_id of the included object from multiple classes..
nicoulaj has quit [Remote host closed the connection]
plugine_ has joined #ruby
bmurt has joined #ruby
nobitanobi has quit [Remote host closed the connection]
<jgnagy>
well, that is true, @@loggers is a class variable, but even then you've defined this on every class you create (obviously not as many, sure, but still redundant if you're logging for more than one class)
<jgnagy>
by using a dedicated class or module for logging, you separate concerns and make your code more modular
ramfjord has quit [Ping timeout: 258 seconds]
Silthias has quit [Ping timeout: 265 seconds]
plugine has quit [Ping timeout: 240 seconds]
tercenya has quit [Remote host closed the connection]
nikivi has quit [Quit: irc]
nicoulaj has joined #ruby
<rob_>
initially i tried creating a singleton but didnt really understand how to mix it in properly to my classes to share the single instance between all of them but still be able to call short methods like 'info()'.. im guessing i would need to create a class to hold the state then include a module to pull in instance methods to wrap the class methods?
frozengeek___ has joined #ruby
tercenya has joined #ruby
<rob_>
toretore: thanks, thats interesting
<jgnagy>
do you have a base class or something where you're including Log?
<toretore>
it's still pretty shitty because it conflates data with representation
solocshaw has quit [Quit: solocshaw]
mark_66 has quit [Remote host closed the connection]
solocshaw has joined #ruby
<rob_>
jgnagy: ive been including it into all my classes individually
jhack has quit [Quit: jhack]
<jgnagy>
ok, if you have several similar classes, a common design pattern is to make a "Base" class to subclass or module to mix-in
jhack has joined #ruby
Dimik has joined #ruby
hahuang65 has joined #ruby
<jgnagy>
which would make this a bit easier
<jgnagy>
let me make a Gist with a contrived example
<rob_>
jgnagy: appreciate the help
TPug has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
whathappens has joined #ruby
<toretore>
base classes sometimes trap you in a straight jacket of inheritance though, so beware
nofxxx has joined #ruby
edwinvdgraaf has joined #ruby
threh has joined #ruby
tau has joined #ruby
Humdai has quit [Quit: Leaving]
marxarelli has joined #ruby
centrx has quit []
TPug has joined #ruby
terlar has joined #ruby
marxarelli has quit [Read error: Connection reset by peer]
<jgnagy>
anyway, with that, Log.log() or Log.info(), etc, can be used from anywhere in the app
muelleme has joined #ruby
marxarelli has joined #ruby
d10n-work has joined #ruby
<jgnagy>
now I only did ResourceBase#info() because rob_ didn't like Log.info() calls
<rob_>
jgnagy: ok, thanks.. i'll have a play around with it
<rob_>
id rather avoid inheritance too though
<jgnagy>
personally I would have just used Log.info "Did action!" in Thing#action()
<jgnagy>
you seem very picky about your scenario... you ask for "better" ways but don't want to use any of the typical design patterns associated with them
<rob_>
jgnagy: because im trying to make something similar to what my co-workers are used to using
<rob_>
i do appreciate your help :)
<jgnagy>
I hope it does help
<jgnagy>
also, encourage your coworkers to embrace reusable code, they'll thank you later
<jgnagy>
:)
GBrawl has joined #ruby
ace05 has joined #ruby
jhack has quit [Quit: jhack]
byte512 has quit [Ping timeout: 260 seconds]
jhack has joined #ruby
howdoi has quit [Quit: Connection closed for inactivity]
<talntid>
you can search for any company in that list and get the info from that namesearch page
<talntid>
for example if you search for "SAHAJGLOBAL LLC", in that list I showed, you can get all the info from that list from DE's website
<talntid>
and I work for myself
nankyokusei has quit [Ping timeout: 240 seconds]
nobitanobi has joined #ruby
Snowy has joined #ruby
roamingdog has quit [Remote host closed the connection]
JeanCarloMachado has joined #ruby
d0nn1e has quit [Ping timeout: 258 seconds]
cdg has joined #ruby
zeroDi has joined #ruby
roamingdog has joined #ruby
andrzejku_ has joined #ruby
<andrzejku_>
hey guys
dnicole_ has quit [Remote host closed the connection]
<andrzejku_>
I start learn Ruby
<andrzejku_>
:D
<tobiasvl>
great going!
<andrzejku_>
ye but
<andrzejku_>
there are a whispers that ruby is dying
<andrzejku_>
:P
<andrzejku_>
on Tiobe
<andrzejku_>
is it true?
dviola has quit [Quit: WeeChat 1.6]
d0nn1e has joined #ruby
diego3 has joined #ruby
nobitanobi has quit [Ping timeout: 248 seconds]
<xall>
well
<xall>
we're all dying
<xall>
*whisper*
<tobiasvl>
the numbers don't lie, I guess, but "dying" is an exagerration. the margins are so small below the major languages
<tobiasvl>
I mean... -0.06%
anisha has joined #ruby
<tobiasvl>
but yes ruby peaked in the last half of the aughts, ruby on rails' heyday
<tobiasvl>
it is not dying though
<frankiee_>
andrzejku_: ruby is the continuation or natural evolution of all past programming languages
diego3 has quit [Changing host]
diego3 has joined #ruby
diego3 is now known as dviola
<frankiee_>
in 100 years when we colonize the stars we will do so using ruby
<andrzejku_>
haha ;D
dviola has quit [Client Quit]
<andrzejku_>
that's funny
diego3 has joined #ruby
<andrzejku_>
I am C++ expert but learn a bit Perl and then I tried Ruby as it is pretty similar
diego3 has quit [Changing host]
diego3 has joined #ruby
<andrzejku_>
so it looks much better
diego3 is now known as dviola
<andrzejku_>
going to do koans =)
ta_ has quit [Remote host closed the connection]
symm- has quit [Ping timeout: 240 seconds]
<andrzejku_>
do you know if after I make koans I can start learning RoR and do some app
<andrzejku_>
or should I read a book?:P
<nofxxx>
frankiee_, true... suppose to be in 50, but they will try python first. And crash and kill everybody cuz someone wrote for python Y and the shuttle runs X
anisha has quit [Quit: This computer has gone to sleep]
<xall>
andrzejku_: you could probably jump into the hartl rails tutorial after. reading Eloquent Ruby would be good too
Snowy_ has joined #ruby
<nofxxx>
andrzejku, yeah, more you learn ruby less you'll need explanations about rails
<andrzejku_>
thanks :)
<nofxxx>
because it's just ruby ;) what you learn is actually convetions and method names
<andrzejku_>
the good about ruby it is better perl
blackjid has quit [Ping timeout: 260 seconds]
_sfiguser has joined #ruby
TPug has joined #ruby
GinoMan2440Wrx has joined #ruby
_sfiguser has quit [Max SendQ exceeded]
douglascorrea has quit [Remote host closed the connection]
_sfiguser has joined #ruby
frozengeek___ has quit [Quit: frozengeek___]
GinoMan2440Wrx has quit [Read error: Connection reset by peer]
GinoMan2440Wrx has joined #ruby
douglascorrea has joined #ruby
GinoMan2440Wrx has quit [Read error: Connection reset by peer]
ramfjord has quit [Ping timeout: 265 seconds]
GinoMan2440Wrx has joined #ruby
<nofxx>
andrzejku, check out chris pine learn to program too, great crashcourse
GinoManWrx has quit [Ping timeout: 260 seconds]
be_______ has joined #ruby
ben_____ has quit [Read error: Connection reset by peer]
be_______ has quit [Remote host closed the connection]
whathappens has quit [Remote host closed the connection]
douglascorrea has quit [Ping timeout: 245 seconds]
jhack has quit [Ping timeout: 245 seconds]
jhack has joined #ruby
ramfjord has joined #ruby
ldnunes has quit [Quit: Leaving]
ta_ has joined #ruby
ben_____ has joined #ruby
redpants has joined #ruby
whathappens has joined #ruby
whathappens has quit [Remote host closed the connection]
rfoust has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
GodFather has joined #ruby
rfoust has joined #ruby
tpendragon has joined #ruby
jhack has quit [Quit: jhack]
agent_white has quit [Quit: leaving]
blackjid has joined #ruby
ben_____ has quit [Remote host closed the connection]
ben_____ has joined #ruby
ereslibre has quit [Remote host closed the connection]
aalmenar has quit [Remote host closed the connection]
agent_white has joined #ruby
ledestin has joined #ruby
jaruga___ has quit [Quit: jaruga___]
raul782 has quit [Read error: Connection reset by peer]
raul782 has joined #ruby
talntid has left #ruby [#ruby]
pragmaticus has quit [Ping timeout: 250 seconds]
Asher has quit [Quit: Leaving.]
elifoster has joined #ruby
maloik has quit [Remote host closed the connection]
rikkipitt has quit [Remote host closed the connection]
maloik has joined #ruby
rikkipitt has joined #ruby
JeanCarloMachado has quit [Remote host closed the connection]
conta has quit [Ping timeout: 250 seconds]
rippa has quit [Quit: {#`%${%&`+'${`%&NO CARRIER]
lizard2010 has joined #ruby
Salih has quit [Quit: Leaving]
marxarelli|afk is now known as marxarelli
djbkd has joined #ruby
roamingdog has quit [Remote host closed the connection]
lizard2010 has quit [Client Quit]
stupidystupid has quit [Ping timeout: 244 seconds]
rikkipitt has quit [Ping timeout: 245 seconds]
Snowy_ has quit [Remote host closed the connection]
hutch34 has quit [Ping timeout: 245 seconds]
raul782 has quit [Remote host closed the connection]
SteenJobs has quit [Quit: SteenJobs]
frankiee_ has quit [Quit: Lost terminal]
skweek has joined #ruby
enterprisey has joined #ruby
XV8 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
vuoto has joined #ruby
<blackbom1>
rails is full of magic.
mati_urunda has quit [Ping timeout: 265 seconds]
Jackneill_ has joined #ruby
<blackbom1>
knowing ruby well definitely helps, but not required, you can use magic without understanding how it works.
_sfiguser has quit [Ping timeout: 260 seconds]
djbkd has quit [Remote host closed the connection]
lxsameer has quit [Quit: WeeChat 1.6]
psychicist__ has quit [Ping timeout: 250 seconds]
djbkd has joined #ruby
muelleme has quit [Ping timeout: 252 seconds]
psychicist__ has joined #ruby
SteenJobs has joined #ruby
rfoust has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
djbkd has quit [Ping timeout: 240 seconds]
hutch34 has joined #ruby
ledestin has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
rfoust has joined #ruby
dnicole has joined #ruby
zeroDi has quit [Quit: WeeChat 1.6]
_sfiguser has joined #ruby
bmurt has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
jhack has joined #ruby
bartek has joined #ruby
Alina-malina has quit [Ping timeout: 250 seconds]
bartek has left #ruby [#ruby]
jackjackdripper has joined #ruby
sepp2k has joined #ruby
enterprisey has quit [Ping timeout: 256 seconds]
Alina-malina has joined #ruby
jackjackdripper has quit [Client Quit]
jackjackdripper has joined #ruby
Rodya_ has joined #ruby
raul782 has joined #ruby
jgt has joined #ruby
fmcgeough has quit [Quit: fmcgeough]
raul782 has quit [Remote host closed the connection]
l33n has joined #ruby
raul782 has joined #ruby
enterprisey has joined #ruby
bocaneri has quit [Read error: Connection reset by peer]
ryan_notabot has quit [Quit: Leaving]
whathappens has joined #ruby
robouk has joined #ruby
gingray has quit [Ping timeout: 268 seconds]
<zacts>
I wonder how different it is to learn Ruby after knowing C++
andrzejku_ has quit [Quit: Leaving]
whathappens has quit [Ping timeout: 240 seconds]
bocaneri has joined #ruby
<xall>
if you aren't familiar with picking up languages, especially if you haven't encountered dynamic, it will be a bit strange
<dminuoso>
zacts: Completely different.
cevett has quit [Read error: Connection reset by peer]
<zacts>
interesting
<dminuoso>
zacts: Ruby is almost, but not quite, entirely unlike C++.
<dminuoso>
zacts: Though recently I started implementing common C++ patterns in Ruby with some degree of success.
<gener1c>
lol
<gener1c>
what gave you that crazy idea
<zacts>
oh cool dminuoso
<xall>
c++ is like a pt cruiser and ruby is like a miata
<xall>
that's how different
<zacts>
I wonder how different Ruby would be to learn from a Java programmer
<dminuoso>
gener1c: I started hating the fact that Ruby advocated all the shitty habits that Rubyists seem to pick up.
<zacts>
(and I promise to stop asking about X -> Ruby after Java)
<dminuoso>
Duck typing is about the worst of it.
<gener1c>
i know java and ruby
<gener1c>
learned ruby first then java
<gener1c>
both have very simillar ideas of how oop should look like if you neglect the fact that java is statically typed
<zacts>
oh cool
<dminuoso>
No they dont. They are very very different.
<zacts>
gener1c: have you tried groovy?
<zacts>
Java syntax is a bit too much for me
ace05 has quit [Read error: Connection reset by peer]
<gener1c>
dminuoso: yeah well its really hard to OOD with ruby , since it solved a lot of stuff for you like dep injection and polymorphism in a lot of cases
ace05 has joined #ruby
<gener1c>
zacts: cpp has a lot more boilerplate than java
<dminuoso>
gener1c: It's great in Ruby because it lets you treat Ruby more like Smalltalk than Java.
<zacts>
gener1c: oh interesting
<dminuoso>
gener1c: In that sense Ruby has actually a unique interesting feature.
<zacts>
gener1c: of C++, Java, and Ruby which do you prefer language designwise?
<gener1c>
dminuoso: in what sense? is ruby like smalltalk?
<gener1c>
metaprogramming and duck typing?
<dminuoso>
gener1c: Every single method invocation is actually just a send(:message)
<dminuoso>
Every.
psychicist__ has quit [Ping timeout: 258 seconds]
skweek has quit [Ping timeout: 268 seconds]
<gener1c>
oh my , do you use that fact?
<dminuoso>
asm>> obj.call_method # gener1c
<ruby[bot]>
dminuoso: I have disassembled your code, the result is at https://eval.in/682188
<dminuoso>
gener1c: Look at the Ruby bytecode. :)
<dminuoso>
This is what Ruby actually executes internally for "obj.call_method"
<dminuoso>
asm>> obj = 1; obj.call_method {} # gener1c a bit more obvious there
<ruby[bot]>
dminuoso: I have disassembled your code, the result is at https://eval.in/682190
blackjid has quit [Ping timeout: 258 seconds]
stupidystupid has joined #ruby
<gener1c>
send(block in <compiled>)
banisterfiend has quit [Ping timeout: 258 seconds]
tyang has quit [Ping timeout: 244 seconds]
<dminuoso>
gener1c: It just means that it sends a message "call_method" with 0 arguments and a compiled block
<gener1c>
funny it doesnt treat the block as just another argument
<dminuoso>
gener1c: It's treated specially for a multitude of reasons. One of the main reasons is that it lets Ruby avoid making an object for it.
doublemalt_ has joined #ruby
<dminuoso>
gener1c: And if you look at this, this magic "block_given?" might make more sense. Any method invocation may have one or no block attached to it, but the only way to figure out how is "block_given?"
<gener1c>
does that effect speed as well as memory consumtion in a positive way?
<dminuoso>
Yes.
<gener1c>
well in this disasm i dont see an invocation of this method
<dminuoso>
This is why binding a block to a proc object e.g. def foo(&predicate); end is usually detrimental for performance (unless you get really low level this usually does not matter at all) - you will not see this anywhere in any stdlib.
<dminuoso>
gener1c: I anmed the method poorly. Let me redo
<dminuoso>
asm>> quux = 1; quux.foobar {} # gener1c a bit more obvious there
<ruby[bot]>
dminuoso: I have disassembled your code, the result is at https://eval.in/682191
<gener1c>
block_given i mean
tenderlove has joined #ruby
<gener1c>
oh nice
nankyokusei has joined #ruby
<gener1c>
send <callinfo!mid:foobar, argc:0>, <callcache>, block in <compiled>
<gener1c>
send(:foobar) #with block and argc 0
<dminuoso>
gener1c: Exactly.
jgt has quit [Ping timeout: 260 seconds]
<gener1c>
is the block_given? method called when parsing the code to make this bytecode?
rfoust has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
doublemalt__ has quit [Ping timeout: 258 seconds]
<dminuoso>
gener1c: It was just a random example. My point is that because there is no corresponding object to a block there are only 3 builtin ways to interact with a block.
<gener1c>
proc
<gener1c>
yield
<gener1c>
and {}
<gener1c>
wait im wrong
<dminuoso>
Nope. Interrogate through Kernel#block_given? whether one was passed in the current method invocation, yield (i.e. execute) the block and bind the block to a proc.
<dminuoso>
(or lambda)
isan32 has joined #ruby
<dminuoso>
Well, and indirectly using "super" (passing it to super)
<gener1c>
interesting
<dminuoso>
This super bit is kind of important and the reason that we have two different super and super()
<dminuoso>
(Yes, they are really different)
<dminuoso>
And shit like this is what I dislike about Ruby.
claudiuinberlin has quit [Remote host closed the connection]
<gener1c>
well do you contribute to ruby core?
fnord_ has joined #ruby
<dminuoso>
I have done a few minor patches
fnord_ has quit [Changing host]
fnord_ has joined #ruby
Sindriava has joined #ruby
<gener1c>
i have done one in pure ruby, but they ignore my PR im afraid
isan32 has left #ruby [#ruby]
<dminuoso>
gener1c: Make a feature request on the bug tracker. PRs have a tendencies to be ignored if they are non-trivial.
Sindriava has left #ruby [#ruby]
`tim` has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
fnord_ has quit [Remote host closed the connection]
claudiuinberlin has joined #ruby
nankyokusei has quit [Remote host closed the connection]
synthroid has quit []
<jolamb>
is there some way I can force the version on a gem dependency when running "gem install"?
<jolamb>
e.g. gem a requires gem
<jolamb>
er
Rodya_ has quit [Remote host closed the connection]
olspookishmagus has quit [Quit: All for nothing]
<jolamb>
e.g. gem a requires gem b >= 1.5.0, but gem b 1.6.0 doesn't support ruby 2.0.0 any longer
<dminuoso>
jolamb: I want you to type "gem --help"
<dminuoso>
jolamb: then proceed with the appropriate gem help command that you are being told.
whathappens has joined #ruby
<dminuoso>
That help page will list all the options for what you are looking for.
<dminuoso>
jolamb: You want to install gems and control their versions and you call bundler a bad fit? You got me really excited now.
careta has joined #ruby
<jolamb>
dminuoso: this isn't for a project, it's for a command-line tool
<dminuoso>
jolamb: so?
<havenwood>
jolamb: Is it a gem?
<jolamb>
yeah
<dminuoso>
jolamb: You can load bundler from within Ruby you know that, right?
kirun has quit [Quit: Konversation terminated!]
<jolamb>
dminuoso: yup. I'll have to pursue this later though, gtg now
<dminuoso>
jolamb: Rails does this under the hood for example. Every time you would type "rails console" it would effectively be the same as "bundle exec rails console"
enterprisey has quit [Remote host closed the connection]
<dminuoso>
(assuming you are in the rails projects directory with a bundle)
blackwind_123 has quit [Ping timeout: 256 seconds]
FernandoBasso has quit [Quit: WeeChat 1.6]
psychicist__ has quit [Ping timeout: 258 seconds]
dnicole has quit [Remote host closed the connection]