<freemo>
Hello everyone! Is this a good spot to ask dumb noob questions?
justinmcp_ has quit [Quit: No Ping reply in 180 seconds.]
justinmcp has joined #ruby
schneider has quit [Ping timeout: 246 seconds]
Xiti has quit [Quit: Xiti]
freemo has quit [Remote host closed the connection]
freemo_ has joined #ruby
justinmcp has quit [Client Quit]
<freemo_>
sorry was disconnected
<freemo_>
not sure why... anyway my question..
c0ncealed3 has quit [Ping timeout: 245 seconds]
Xiti has joined #ruby
Cyrus is now known as Guest26490
axsuul has quit [Ping timeout: 252 seconds]
justinmcp has joined #ruby
schneider has joined #ruby
Creatornator has joined #ruby
<freemo_>
Im a noob to ruby (sorta) but expiernced coder so i know the concepts. I have some code im working on with a complex class / module hierarchy. All the classes need to be serialized to json and back to be saved and restored regularly. I recently included a module into my class from a third-party library that allows me to do events (subscribing to events on a class). Problem is the internal data it uses to do this cant be serialized (and i
<freemo_>
dont want it to be). So when my objects try to serialize the built-in marshalling method throws an error
cpallares has quit [Ping timeout: 252 seconds]
uplime has joined #ruby
ur5us has quit [Read error: Connection reset by peer]
Guest26490 has quit [Ping timeout: 252 seconds]
<freemo_>
I am trying to find some simple way to make it so the default marshalling method is still invoked but it ignored the included module but still marshals everything else automatically as usual
octomancer has quit [Ping timeout: 264 seconds]
<freemo_>
In other languages like java this means adding a @transient annotation or similar. But I cant find anything like that in ruby. Any ideas?
<havenwood>
freemo_: What does @transient put in place of the serialized class? A null? (I don't quite understand.)
<havenwood>
freemo_: So you're serializing an instance of your class, and the included module is borking it?
<havenwood>
freemo_: Can you define #dump and ::load yourself, explicitly?
<freemo_>
havenwood: correct, the included module is breaking the serialization
schneider has joined #ruby
<havenwood>
freemo_: I'd suggest defining ::load and #dump on the class, so you can omit whatever the included module is trying to serialize.
<freemo_>
havenwood: in java the @transient is just a marker. It marks the variable as transient, when the serialization process sees this it ignores the field and doesnt serialize it, when it deserializes it it will be null by default, yea.
<freemo_>
havenwood: yea i can implement the mashaling methods (i think its called marshal_dump and marshal_load).. problem is that will break the marshalling of superclasses too, which all marshall their own variables in special ways potentially.
<havenwood>
freemo_: _dump and _load are aliases, iir
<havenwood>
freemo_: aha
<freemo_>
havenwood: by the way it is all opensource so i can share the repo or the code if it helps
<freemo_>
havenwood: based on the code I take it you actually ran the program and reproduced the error yourself?
<freemo_>
If so im impressed you figured out how to run and reproduce the code so quickly without my help
schneider has quit [Ping timeout: 252 seconds]
<freemo_>
*reproduce the bug
<freemo_>
havenwood: to use that code i suppose I just include safeSerialize anywhere i include wisper?
<havenwood>
freemo_: yup
bmurt has joined #ruby
<freemo_>
havenwood: since you actually ran the program and all, if you feel like it id be curious to hear your thoughts on the game in general. Though may be off topic here
cagomez has joined #ruby
schneider has joined #ruby
<freemo_>
havenwood: what im going to do (tell me if this isnt going to work) is just include wisper directly into SafeSerialize (and name it something else). Then ill include that module instead of wisper itself. That way i just need to do one include
<havenwood>
freemo_: Yes, that sounds to me like it'd work. I have to relocate, but I'll think more on this.
<freemo_>
havenwood: alright, ill be around until my connection drops for some reason. I appreciate the help
schneider has quit [Ping timeout: 268 seconds]
dviola has joined #ruby
schneider has joined #ruby
dviola has quit [Client Quit]
bkxd has joined #ruby
gheegh has joined #ruby
schneider has quit [Ping timeout: 276 seconds]
asphyxia has joined #ruby
schneider has joined #ruby
elcontrastador has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
vqrs has quit [Ping timeout: 252 seconds]
vqrs has joined #ruby
schneider has quit [Ping timeout: 250 seconds]
hays_ is now known as hays
Creatornator has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<freemo_>
havenwood: that ooks similar to the direction i was going to go originally. Issue would be that it completely overrides marshalling methods on the base classes
gheegh has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<freemo_>
havenwood: so if a base class does something special when marshalling this would break it
schneider has quit [Ping timeout: 250 seconds]
Tempesta has quit [Ping timeout: 252 seconds]
<freemo_>
havenwood: side note: I had no idea a class could be extended from Module or what that class << self bit does... but like i said im a noob
schneider has joined #ruby
asphyxia has quit [Ping timeout: 276 seconds]
ansraliant has joined #ruby
schneider has quit [Ping timeout: 268 seconds]
schneider has joined #ruby
duderonomy has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<freemo_>
havenwood: still there? I'm a little confused how to use your mod...
<freemo_>
nvm
<havenwood>
freemo_: Hey, yup - just got back. Let me look at this again and see if I'm thinking clearer now.
schneider has quit [Ping timeout: 250 seconds]
bmurt has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
nadir has joined #ruby
<havenwood>
freemo_: That more recent, convoluted gist was my attempt to let you list the ivars to not dump from the outside.
<havenwood>
include DoNotDump[:@bad, :@another, :@etc]
ivanskie has joined #ruby
dbz has joined #ruby
asphyxia has quit [Quit: Lost terminal]
<freemo_>
havenwood: yea i noticed that a second later.. it is still giving me problems but im looking into why now...
<havenwood>
freemo_: I'm tempted to want to try super for the case you mention above, where the class already has custom marshalling - but it seems like a pain to get working for various reasons.
<havenwood>
freemo_: I just tried it with my example code.
<freemo_>
havenwood: line 25 in publisher at the link i just pasted you is the line that recursively gets called over and over till it crashes...
<freemo_>
so must be something i edited.
schneider has quit [Ping timeout: 250 seconds]
<havenwood>
freemo_: Ah, your problem is the edit, yeah: include Marshaller[]
bkxd has quit [Ping timeout: 268 seconds]
<havenwood>
freemo_: What's the name of the instance variable you don't want to marshal? Do you know?
<havenwood>
include Marshaller[:@instance_variable_name_here]
<freemo_>
havenwood: no i dont know yet, i was going to run it and try to determine that from the error it would produce
<freemo_>
havenwood: i figured id run it and when it complained about not being able to marshal the variable then id add it, as i dont recall what the variable was
pabs has quit [Ping timeout: 264 seconds]
<freemo_>
havenwood: i just tried creating a dummy variable called "foobar" and ignored that (just so i passed some instance variable in).. same problem
<havenwood>
freemo_: Yeah, it should actually work empty - so that's odd.
schneider has joined #ruby
<freemo_>
havenwood: i think marshal.dump is just an alias for marshal_dump
<freemo_>
which is why
<havenwood>
freemo_: What's the error you're getting?
<freemo_>
havenwood: its a really long stack trace witht he same two lines repeated over and over again (line 25 in publisher).. indicating its just infinitely recursive. I can paste it though on a paste bin, one sec
<ruby[bot]>
freemo_: we in #ruby do not like pastebin.com, it loads slowly for most, has ads which are distracting and has terrible formatting. Please use https://gist.github.com
kujira has joined #ruby
<freemo_>
havenwood: i suspect that there is some magic somewhere in my project (i didnt write it all myself, i took from an old opensource project) that made it an alias somewhere maybe
<havenwood>
freemo_: Are you inheriting from Array or something?
<havenwood>
Hrmm, how odd...
<freemo_>
havenwood: no but the array class was modified by some code somewhere
<havenwood>
freemo_: How odd, so you're right about what it appears to be. `Marshal.dump` would call `data`'s #marshal_dump, but `data` is an instance of Array, and you've presumably not mixed this into Array.
<freemo_>
yea i dont fully understand it mysef. But that could just be my noobiness
cagomez has quit [Remote host closed the connection]
asphyxia has joined #ruby
schneider has quit [Ping timeout: 244 seconds]
<havenwood>
freemo_: I can easily reproduce a stack level too deep with: class Array; include DoNotDump[] end
<havenwood>
freemo_: But I have no idea why it's happening in your code.
<havenwood>
freemo_: Sec
<freemo_>
maybe it is trying to marshal an array somehow i dunno let me poke around more
jetchisel has quit [Quit: Unfortunately time is always against us -- [Morpheus]]
<havenwood>
Or am I just missing the Producer code?
<freemo_>
havenwood: i didnt try the example itself
schneider has joined #ruby
<havenwood>
freemo_: Maybe try that, because it works for me.
<freemo_>
havenwood: producer? you mean publisher?
erratic has joined #ruby
<havenwood>
freemo_: yes
<freemo_>
havenwood: not sure if it would happen if publisher were empty and i tried to serialize it...hmm need to figure out an easy way to test that
za1b1tsu has quit [Ping timeout: 252 seconds]
<freemo_>
let me try your example first
<havenwood>
freemo_: If Publisher is empty, and it happens, I then wonder why it's only in the context of the project that an empty class errors. I'd say sanity check the example even works for you (assuming it does).
<freemo_>
thats easy
<lunaphyte>
i'm hoping someone can help me understand a section of a ruby program i'm trying to use
<lunaphyte>
i think i understand that part, just from testing - it won't go into the conditional unless ssl_host_verification is present in the config file
<baweaver>
bingo
<lunaphyte>
line 2 though i don't understand
MoritaShinobu has joined #ruby
<baweaver>
!! ?
<baweaver>
which part?
<havenwood>
baweaver: Getting a boolean from truthiness
<baweaver>
It means "not not"
<baweaver>
havenwood: Oh I know
<baweaver>
I assume that the config shouldn't be quoted either
<lunaphyte>
i can get it to go into the conditional - i've done that with testing, but it never prints "Disabling ssl host verification"
<havenwood>
baweaver: hah, wrong nick - hi though!
<baweaver>
alo
<havenwood>
baweaver: you're the same color blue in my irc as lunaphyte at the moment
<baweaver>
interesting
<baweaver>
ah well
<baweaver>
It might be that platform logger isn't logging to console
* havenwood
rerolls irc colors
<freemo_>
havenwood: the code you just pasted gives me the same error as the last pastebin i shared
<baweaver>
duplicate that line and change it to puts instead
<lunaphyte>
baweaver: i believe it is - i see other logging from it
<baweaver>
is different from: `ssl_host_verification: "false"`
<baweaver>
Strings in Ruby are always truthy lunaphyte
<lunaphyte>
ah - of course
<freemo_>
havenwood: yea that worked
<baweaver>
derp on me for not noticing it earlier :P
<lunaphyte>
well, it's probably mostly because it's such an inane question :)
asphyxia has quit [Ping timeout: 252 seconds]
<havenwood>
freemo_: welp, works in isolation - and doesn't take Wisper to break - so it's gotta be something else - hrmm - this isn't easy to track down
* havenwood
peruses the code
<lunaphyte>
baweaver: when you said strings are always truthy, that is to say that if there is a string, it evaluates to true, even if the string is, for example, "false"?
asphyxia has joined #ruby
schneider has quit [Ping timeout: 246 seconds]
<baweaver>
In Ruby there are two things which are false
<baweaver>
falsy rather
<baweaver>
false and nil
<baweaver>
everything else? Truthy
<freemo_>
havenwood: as much as i love ruby my main complaint is that it is always harder to debug
<lunaphyte>
so one could make a boolean true with either true or "true", but one can only make a boolean false with false, but not "false"?
<lunaphyte>
oh or nil?
<lunaphyte>
ok
<havenwood>
lunaphyte: Nothing at all, ever is ever falsey other than `nil` and `false`. You can't even make a thing that is. Almost nothing is falsey.
<baweaver>
"true" is truthy
<lunaphyte>
got it - thanks
<baweaver>
havenwood: Well....
nowhere_man has quit [Remote host closed the connection]
<baweaver>
There are ways to screw with prefix and equality to do fun things :D
<baweaver>
but there be dark magics
nowhere_man has joined #ruby
<havenwood>
baweaver: i don't even know how to use Fiddle to make a thing actually falsey
<lunaphyte>
so now i'm on to the next issue. i've set ssl_host_verification: false, and the output reflects this ["Disabling ssl host verification
<lunaphyte>
"], but the http request still complains "certificate verify failed": https://dpaste.de/Spf2
<lunaphyte>
oops, sorry about the feral line feed
schneider has joined #ruby
<lunaphyte>
i suppose that's not quite topical for this channel though :)
<havenwood>
freemo_: Ah, found it - Gary!
<freemo_>
havenwood: hmmm
<havenwood>
freemo_: err, or maybe not. at least it's suspicious - Gary mixes in Enumerable, then Inventory inherits from Gary and defined marshal_dump.
<freemo_>
havenwood: because it includes Enumerable?
<freemo_>
ahh
<freemo_>
yea gary does behave like an array
<freemo_>
Gary is used a lot in the app
<havenwood>
but this wouldn't actually define these for all Enumerable - and you confirmed Array and Hash both exhibit the error...
schneider has quit [Ping timeout: 268 seconds]
<lunaphyte>
baweaver, havenwood: thanks for the help and the friendly cluebat - much appreciated
<havenwood>
freemo_: Maybe this would show if the issue is really a redefining of #marshal_dump on Array and Hash - unsure!
<havenwood>
baweaver: I think I need to stop coding for the day ^ ... It's getting ugly...
<havenwood>
class variables? what's happening to me?!?
<freemo_>
havenwood: same error
<freemo_>
havenwood: lol :)
<havenwood>
freemo_: wow, I don't get it!
<freemo_>
class variables have their place, but ill admit there arent may good uses for them
<freemo_>
havenwood: im useless for debugging this one :(
<freemo_>
my only solution is to try a similar approach but rewritten to do it in a less clean way
<havenwood>
freemo_: Could you throw a binding.pry in there and check: [].methods.grep(/dump/)
<havenwood>
Or: binding.irb
<freemo_>
id rather not go that route but i may have to if you dont know what to do
schneider has quit [Ping timeout: 268 seconds]
<freemo_>
havenwood: i have no clue how to do that, im a noob
<havenwood>
freemo_: do you use IRB or Pry?
asphyxia has quit [Read error: Connection reset by peer]
<havenwood>
freemo_: If you're not using Pry, IRB ships with Ruby so that works.
<havenwood>
freemo_: You just put an `binding.irb` in the code where you want to jump to debug - then run it.
<freemo_>
havenwood: i think irb, thats that command line thing that lets youwrite ruby interactively right? I almost never use it though i mostly run ruby from files
<havenwood>
freemo_: I usually debug Ruby from Pry. It makes debugging much more fun.
<havenwood>
freemo_: Pry is a gem, you just: gem install pry
orbyt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<havenwood>
freemo_: But yeah - really handy.
<havenwood>
?pry
<ruby[bot]>
Pry, the better IRB, provides easy object inspection `ls`, `history`, viewing docs `?`, viewing source `$`, syntax highlighting and other features (see `help` for more). Put `binding.pry` in your source code for easy debugging. Install Pry (https://pryrepl.org/): gem install pry pry-doc
<freemo_>
havenwood: i should learn how to debug ruby properly, until now i just hack it out
<havenwood>
freemo_: It's a great way to introspect and find out what's actually happening.
<freemo_>
havenwood: although is you want me to debug this code as you asked youll have to step me through exactly what you want me to do, unfortunately im pretty lost here. so just add the text "binding.irb" to some line in my code? what line? then run irb? run it how? ike what command?
<havenwood>
freemo_: However you usually reproduce your error.
<havenwood>
freemo_: Put a `binding.irb` on line 24 since it's failing on line 25.
<freemo_>
ok.. do i add it with the quotes or without?
<havenwood>
just using backticks to show it's code
<havenwood>
binding.irb
<freemo_>
done
<havenwood>
Or add pry to your Gemfile, bundle, add `require 'pry'` and: binding.pry
asphyxia has joined #ruby
<havenwood>
freemo_: Now reproduce the error, and instead of it happening it'l jump you to the REPL at line 24.
<havenwood>
freemo_: So you can check: [].methods.grep(/dump/)
<freemo_>
havenwood: just reproduce it by running it the way i usually do? just call bundler exec ruby ....
<havenwood>
freemo_: yup
schneider has quit [Ping timeout: 252 seconds]
<freemo_>
ok
<havenwood>
[].methods.grep(/dump/) #?> []
<freemo_>
havenwood: ohhh this is cool! ok im at the prompt with it stalled at the expected place
<havenwood>
freemo_: Yup! And with Pry you can do stuff like: ls []
<havenwood>
freemo_: Or even: cd []; ls
apeiros has quit [Remote host closed the connection]
<havenwood>
freemo_: With pry-byebug you can also step through the stack.
<freemo_>
havenwood: irb(Room(GarbageRoom|439a0844-0085-2a1a-a02b-51fc03617ead)):001:0> [].methods.grep(/dump/) #?> [] .... this gives me the following result... => []
<havenwood>
freemo_: Hrmm, so no dump methods defined on an Array instance...
<havenwood>
freemo_: So where's that method loop coming from?!
<havenwood>
freemo_: Try?: Marshal.dump []
<havenwood>
freemo_: Does that ^ reproduce the error?
<freemo_>
havenwood: nope when i do that it returns this: => "\x04\b[\x00"
<havenwood>
freemo_: Oooh, maybe one of the instance variables is a Producer itself!
<havenwood>
freemo_: Great, so marshaling arrays actually works, it's this particular array.
<havenwood>
freemo_: Check?: data
<freemo_>
havenwood: ohh yes it would be
<havenwood>
freemo_: ahhhh, depth
<freemo_>
virtually every object in the game needs to be a publisher
schneider has joined #ruby
<havenwood>
freemo_: haha, that just didn't occur to me
<freemo_>
so an inventory is itself a publisher and all the objects it contains are publishers
<freemo_>
:)
<havenwood>
freemo_: But we can't limit the depth, because you actually need those all to be serialized - right/
<havenwood>
freemo_: Try?: Marshal.dump data, 1
<havenwood>
-1 (no depth check) is the default second argument to Marshal::dump
<freemo_>
yea
<freemo_>
i need everything serialized to infinite depth
<havenwood>
freemo_: Hrmmmmmmm
<havenwood>
freemo_: I have to run tonight but this is an interesting problem. I'd be happy to look with fresh eyes. I'd probably be more help.
<havenwood>
freemo_: Or someone else might be waking up here shortly. :)
<freemo_>
havenwood: the last command i tried does produce an exception
<freemo_>
havenwood: i should sleep myself, 1am here. if youd like to continue this tomorrow is there a good time to catch you?
<havenwood>
freemo_: G'night and good luck! I'm usually around here.
<freemo_>
havenwood: alright ill try to look for you tomorrow then
<freemo_>
i appreciate all the help
<havenwood>
no prob, you're welcome - g'night!
schneider has quit [Ping timeout: 252 seconds]
schneider has joined #ruby
schneider has quit [Ping timeout: 250 seconds]
freemo_ has quit [Ping timeout: 268 seconds]
schneider has joined #ruby
dviola has quit [Quit: WeeChat 2.2]
SuperL4g_ is now known as SuperLag
schneider has quit [Ping timeout: 246 seconds]
ivanskie has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
karapetyan has joined #ruby
karapetyan has quit [Remote host closed the connection]
schneider has joined #ruby
schneider has quit [Ping timeout: 244 seconds]
za1b1tsu has joined #ruby
schneider has joined #ruby
dellavg_ has joined #ruby
schneider has quit [Ping timeout: 250 seconds]
schneider has joined #ruby
bkxd has quit [Ping timeout: 268 seconds]
schneider has quit [Ping timeout: 272 seconds]
karapetyan has joined #ruby
dbz has joined #ruby
schneider has joined #ruby
dbz has quit [Remote host closed the connection]
schneider has quit [Ping timeout: 272 seconds]
savolla has joined #ruby
dbz has joined #ruby
aupadhye has joined #ruby
skwurl has joined #ruby
<skwurl>
how can a share variables between methods
<skwurl>
?
<havenwood>
skwurl: Instance variables are a common way.
schneider has joined #ruby
<skwurl>
would you mind meeting me here if you have a few moments for a small demo please? https://codeshare.io/aywLZe
dbz_ has joined #ruby
dbz has quit [Remote host closed the connection]
<baweaver>
skwurl: what's the use case?
<baweaver>
What are you trying to do with the code?
schneider has quit [Quit: WeeChat 2.0.1]
<havenwood>
skwurl: I responded to your codeshare.
<skwurl>
heres a better example of what im actually trying to do.
<skwurl>
sorry thank you
<skwurl>
i want to use variables outside of the method
<baweaver>
you can't
<havenwood>
skwurl: Local variables are local to the method.
<havenwood>
skwurl: Show us the real code you're working with?
<baweaver>
Now, what are you trying to do
<baweaver>
Not in the code, but with the code
<baweaver>
The more vague you are about the actual code the less help we can really be
<baweaver>
Aha, DND
<skwurl>
simple character generator. but it doesnt feel quite right
<baweaver>
You're conflating a lot of ideas
<baweaver>
Functions should be pure, one input and one output
<baweaver>
Are you trying to roll dice?
<baweaver>
Also global variables are now off limits to you
<skwurl>
no this is an rpg called dungeon squad. my kids really like it. No dice rolling. trying to randomly assign a string to a variable to be put in a database.
<skwurl>
lol.
<baweaver>
What do the text files look like?
<skwurl>
it works? X )
<baweaver>
you end up reading the entire file in for one value
<baweaver>
Random names
<skwurl>
thats the names.
<baweaver>
So all those text files are basically just lists you want to generate a random set of input from?
<skwurl>
random waepons at the bottom etc.
<baweaver>
So does stuffgen do roughly the same?
<baweaver>
or are those dice rolls?
<skwurl>
yes. a random string essentially
<baweaver>
Considering the D10?
<baweaver>
10 characters long or how are they defined?
<baweaver>
Might be able to do it inline
savolla has quit [Remote host closed the connection]
<baweaver>
Mind I only ask because it'll help us help you a bit better.
<skwurl>
this is in the ctypegen method
<baweaver>
you should name them better
<baweaver>
ctype doesn't reveal the intent
<skwurl>
certianly, i really appreciate it.
bkxd has joined #ruby
arescorpio has joined #ruby
<skwurl>
$d4 is a variable defined by randomly slecting a string from the array
<skwurl>
it then removes that string from the array to prep for the next.
arescorpio has quit [Remote host closed the connection]
<baweaver>
Shuffle is fun.
<skwurl>
ctype is character type. d4 d10 d12 are assigned either warrior wizard or explorer to which skill checks are performed in game depending on the nature of the challenge.
<skwurl>
it is! shuffle? is that another method?
schleppel has joined #ruby
<baweaver>
yep
<baweaver>
So assuming things can only be used once, you can instantiate lists of those and shuffle them
<baweaver>
or rather: File.readlines(x).shuffle
<skwurl>
oh cool!
<baweaver>
Now then, code.
<baweaver>
one moment, hopping over there
<skwurl>
so i want to re-write this from scratch but without gloabl variables.
jetchisel has quit [Ping timeout: 245 seconds]
jetchisel has joined #ruby
ozzloy has joined #ruby
stoffus has joined #ruby
snickers has joined #ruby
arescorpio has joined #ruby
LiftLeft2 has quit [Ping timeout: 252 seconds]
printercu has joined #ruby
<skwurl>
so i can pass @@avaraible anywhere in a class right
<baweaver>
don't
<baweaver>
good habits, not bad ones.
andikr has joined #ruby
<skwurl>
i thinnk i have the order backwards in my head.
<baweaver>
FIle IO should be as far outside of a class as possible
<baweaver>
IO is state mutation, and you want to keep that to the outside as much as possible
<baweaver>
It makes code far easier to test, reason about, and build upon later.
<skwurl>
right instead of passing stuff out of a method pas it into it
<baweaver>
Not necessarily
<baweaver>
A function or rather a method should have an input and an output
<baweaver>
File IO and things like puts are an additional vector
<baweaver>
So you want to avoid them where possible
aufi has joined #ruby
printerc_ has joined #ruby
<baweaver>
There are reasons for this
printercu has quit [Read error: Connection reset by peer]
<baweaver>
Mostly around dependency injection later on
Fusl has quit [Excess Flood]
printercu has joined #ruby
<skwurl>
i alwasy see the initialize method at the start of the class. is the name of this method important?
<baweaver>
yes.
<baweaver>
Initialize is how you create an instance of a class
<baweaver>
Though this may be advanced for you at this point
<skwurl>
i think this is what i am missing
Fusl has joined #ruby
<baweaver>
Read Practical Object Oriented Programming in Ruby
<skwurl>
omw now.
LiftLeft2 has joined #ruby
printerc_ has quit [Ping timeout: 244 seconds]
aufi has quit [Ping timeout: 250 seconds]
DTZUZO_ has quit [Ping timeout: 244 seconds]
aufi has joined #ruby
za1b1tsu has quit [Ping timeout: 252 seconds]
aufi has quit [Read error: Connection reset by peer]
za1b1tsu has joined #ruby
<printercu>
Hi there! Does anybody know if net/http client is thread-safe? I mean if I have single client = Net::HTTP.new(...) is it safe to call client.request(...) multiple times concurrently?
skwurl has quit [Quit: WeeChat 2.2]
alem0lars has joined #ruby
clemens3_ has joined #ruby
arescorpio has quit [Remote host closed the connection]
sariyar has joined #ruby
duderonomy has joined #ruby
za1b1tsu has quit [Ping timeout: 244 seconds]
duderono_ has joined #ruby
duderonomy has quit [Read error: Connection reset by peer]
duderono_ has quit [Client Quit]
duderonomy has joined #ruby
duderonomy has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
ivanskie has joined #ruby
nadir has quit [Quit: Connection closed for inactivity]
bzf- has joined #ruby
za1b1tsu has joined #ruby
dbz_ has quit [Remote host closed the connection]
Ag3nt has joined #ruby
ivanskie has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
za1b1tsu has quit [Ping timeout: 244 seconds]
bga57 has quit [Ping timeout: 272 seconds]
roshanavand has joined #ruby
teclator has joined #ruby
schleppel has quit [Quit: Konversation terminated!]
tj_ has joined #ruby
<tj_>
Hi folks, anyone using VS Code with ruby ? I have problems while passing arguments to Vscode (there are program arguments and interpreter arguments)
lxsameer has joined #ruby
<tj_>
I want to use a debugger for debugging my ruby code
johnny56 has joined #ruby
<tj_>
order of passing arguments --> ruby.exe [ interpreter arguments like -v -w -I ] [ programfile.rb ] [ program arguments ... ]
<ruby[bot]>
tj_: we in #ruby do not like pastebin.com, it loads slowly for most, has ads which are distracting and has terrible formatting. Please use https://gist.github.com
bga57 has joined #ruby
<tj_>
VS Code gives an args[] array to pass the arguments. I have pasted my launch.json here https://pastebin.com/CCJs0vXs
<tj_>
But please consider the given pastebin link for this one time.
za1b1tsu has joined #ruby
<tj_>
in args[] section in given json file. I have passed the arguments. but it doesn't follow the order of passing arguments
<tj_>
it violets the order of passing args order of passing arguments --> ruby.exe [ interpreter arguments like -v -w -I ] [ programfile.rb ] [ program arguments ... ]
marz_d`ghostman has joined #ruby
<marz_d`ghostman>
I forgot what it is called in Java, but there's a mechanism where they use constants as a value that they pass anywhere. Is there a similar mechanism in ruby? Like Database::Status::SUCCESSFUL?
karapetyan has quit [Remote host closed the connection]
<tj_>
I am not sure. I get "require" error that it cannot find required files
c0ncealed3 has quit [Remote host closed the connection]
mikecmpbll has joined #ruby
c0ncealed3 has joined #ruby
xfbs has joined #ruby
_whitelogger has joined #ruby
jetchisel has quit [Ping timeout: 252 seconds]
xfbs has quit [Quit: afk]
ansraliant has quit [Quit: My planet needs me]
apeiros has joined #ruby
vutral has joined #ruby
<marz_d`ghostman>
I have a class method that invokes multiple private methods. When testing it in rspec, cop telss me that my describe block has too many lines.
<marz_d`ghostman>
Should I test every method instead of the one class method with multiple context?
bkxd has joined #ruby
<phaul>
I found a way, ... sequel has so many gotchas.
xfbs has joined #ruby
bkxd has quit [Ping timeout: 252 seconds]
apeiros has quit [Ping timeout: 250 seconds]
bkxd has joined #ruby
gell5 has joined #ruby
MaiconVieira has quit [Remote host closed the connection]
tj_ has quit [Remote host closed the connection]
n13z has quit [Ping timeout: 252 seconds]
apeiros has joined #ruby
troulouliou_div2 has joined #ruby
<apeiros>
phaul: personally I've stopped doing anything remotely complex in ORMs (or even just "query mappers"). I'll resort to db views rather quickly so I can keep the code side simple.
<apeiros>
the moment I have joins or aliases f.ex. -> db view
n13z has joined #ruby
<phaul>
apeiros: fair enough
silviu has joined #ruby
<phaul>
tbh I have 0 experience with sequel but slowly getting the hang of it
<rapha>
is there anything for ruby that will allow you to do what's suggested in that answer, i.e. "fitting data to a distribution"?
<apeiros>
that's a statistical problem first, and once you've found which statistical tool you want to use, it's a programmatic/algorithmic problem second.
<apeiros>
in core ruby, there are no statistical tools, no.
<apeiros>
but there are almost certainly gems which provide you with methods to perform analytic queries on data series.
<phaul>
Bish: weird, I checked with alis, and it doesn't seem to know about it. /msg alis list sequel
<marz_d`ghostman>
If the code under test calls `exit`, the rest of the tests are not run in rspec. How do I get around that?
<apeiros>
stub it
<apeiros>
also don't call exit in your code :-p
<marz_d`ghostman>
apeiros: But I'm testing a case where my code fails and not continue, hence I have exit in my code :)
<Bish>
phaul: tf is alis
<apeiros>
code failing is no reason to call exit
<Bish>
oh u explain it right there :D
<marz_d`ghostman>
apeiros: Okay how about this, I have a pre_process() method that needs to run before main_process(). If the pre_process() isn't successful, it logs/updates db status and should not continue with running main_process()
<apeiros>
almost exclusively the only place to call exit is in the scope of the executable. and the executable itself should be minimal. like: shebang line, require main library, call into main library, exit.
bkxd has quit [Ping timeout: 276 seconds]
<apeiros>
marz_d`ghostman: you can do all of that without a single exit.
bkxd has joined #ruby
<apeiros>
you make reasoning about code a lot easier if you have single entry & exit points. calling exit in the middle is like calling return in the middle. it's spaghetti and makes reading & reasoning about your code harder. usually without any gain.
* apeiros
afk, back in ~30min
tj_ has joined #ruby
<marz_d`ghostman>
apeiros: so If I have a method run() { pre_process(); main_process() } how do I terminate if pre_process does not succeed?
lxsameer has quit [Ping timeout: 252 seconds]
esrse has quit [Ping timeout: 244 seconds]
<rapha>
apeiros: looking at my data, it seems the OPTICS algorithm might be a good choice. And luckily, as you predicted, ta-daaa: https://github.com/ebakan/clustering
<rapha>
(well, not a Gem, but good enough!)
tdy has quit [Ping timeout: 252 seconds]
bkxd has quit [Ping timeout: 250 seconds]
apeiros has quit [Ping timeout: 252 seconds]
EnderMB has joined #ruby
EnderMB has left #ruby [#ruby]
lxsameer has joined #ruby
kurko_ has joined #ruby
jetchisel has joined #ruby
Francisco has joined #ruby
lxsameer has quit [Ping timeout: 276 seconds]
Fr4n has quit [Read error: Connection reset by peer]
gheegh has joined #ruby
KeyJoo has joined #ruby
prillian5 has joined #ruby
apeiros has joined #ruby
<apeiros>
rapha: cool!
<apeiros>
marz_d`ghostman: well, how do you usually let ruby *not* execute a piece of code you don't want to execute because something is or something happened?
<apeiros>
or rather, your framing "how do I *terminate*" is wrong.
karapetyan has quit [Remote host closed the connection]
bkxd has joined #ruby
karapetyan has joined #ruby
<marz_d`ghostman>
apeiros: I'm having problems testing my private methods, hence, I've made all of them public. But I don't think this is good practice though
<prillian5>
Hi, I'm a ruby noob. I have to adjust now a short script, which search and replace something in a given file. http://dpaste.com/3YBXQVG
<apeiros>
I'm not sure - was that supposed to be an answer to my question? o0
schleppel has joined #ruby
<apeiros>
hi prillian5
<prillian5>
This works nice, but now I have to replace the Version-Code of "version": "0.2.1" and I try to figure out how.
<prillian5>
@apeiros hi
paraxial has joined #ruby
<apeiros>
prillian5: somehow I don't think that this works at all… I'd bet that line 3 raises an exception.
<prillian5>
Ah yes, sorry this line was only a try I forget to remove.
bkxd has quit [Ping timeout: 252 seconds]
<apeiros>
prillian5: try to phrase in words how a valid version number you'd want to match can look
<prillian5>
I wonder how to search for "version" ... must I escape " like this: re = /\"version\"\:\s+(\d\.\d\.\d)/
<apeiros>
right now your expression says "a version number is one or more digits"
<apeiros>
marz_d`ghostman: sooo… skipping my question entirely?
tdy has joined #ruby
bkxd has joined #ruby
<apeiros>
prillian5: yes, that will match e.g. "\"version\": 1.2.3"
<apeiros>
it won't match "version: 1.2.3", it won't match "version: 1.15.2", and it won't match "version: 1.2"
<marz_d`ghostman>
apeiros: oh sorry wasn't able to notice that. Hmmm, so what I did was I have a method like pre_cmd() where I run cmd and rescue Errno::ENOENT, then log and update db. I just transferred the rescue block to the main method
<prillian5>
@apeiros : thats no problem, the version here is all the time exactly the same schema.
<prillian5>
1.3.5 or 1.12.2 and so on
<apeiros>
prillian5: 1.12.2 is in my list of non-matches, though
<apeiros>
\d <-- exactly one digit
<apeiros>
\d+ <-- one or more digits
<prillian5>
ok, have to go for half an our, Will be back later. Thank you so far
<apeiros>
kk, cya
bmurt has joined #ruby
za1b1tsu_ has quit [Ping timeout: 276 seconds]
bmurt has quit [Client Quit]
prillian5 has quit [Ping timeout: 252 seconds]
tj_ has quit [Ping timeout: 252 seconds]
Nicmavr has quit [Read error: Connection reset by peer]
Nicmavr has joined #ruby
lxsameer has joined #ruby
ldnunes has joined #ruby
bkxd has quit [Ping timeout: 252 seconds]
lxsameer has quit [Ping timeout: 276 seconds]
KeyJoo has quit [Read error: Connection reset by peer]
dionysus69 has quit [Ping timeout: 268 seconds]
KeyJoo has joined #ruby
dionysus69 has joined #ruby
za1b1tsu_ has joined #ruby
dionysus69_ has joined #ruby
tdy has quit [Ping timeout: 276 seconds]
dionysus69 has quit [Ping timeout: 250 seconds]
dionysus69_ is now known as dionysus69
mn3m has joined #ruby
prillian5 has joined #ruby
mn3m has quit [Max SendQ exceeded]
jcalla has joined #ruby
Chetic has joined #ruby
dionysus69_ has joined #ruby
<Chetic>
my .rb file has a line with require "P4.so" and calls self.run(). Is there a possibility that self.run() calls a run function in P4.so?
KeyJoo has quit [Remote host closed the connection]
prillian5 has quit [Quit: Konversation terminated!]
dionysus69_ is now known as dionysus69
dionysus69 has quit [Ping timeout: 244 seconds]
<Chetic>
stack trace ends at "P4.rb:131:in `run'" even though P4.rb does not have a run function
ta_ has joined #ruby
bkxd has joined #ruby
lxsameer has joined #ruby
Chetic is now known as alarm1
alarm1 is now known as Chetic
lxsameer has quit [Ping timeout: 250 seconds]
lxsameer has joined #ruby
GodFather has joined #ruby
karapetyan has quit [Remote host closed the connection]
ta_ has quit [Remote host closed the connection]
karapetyan has joined #ruby
kurko_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
GodFather has quit [Ping timeout: 260 seconds]
suukim has quit [Quit: Konversation terminated!]
asphyxia is now known as kogumanomisha
GodFather has joined #ruby
kogumanomisha is now known as asphyxia
InfinityFye has joined #ruby
cow[moo] has joined #ruby
bmurt has joined #ruby
Ag3nt has quit [Quit: leaving]
GodFather has quit [Ping timeout: 252 seconds]
DTZUZO_ has joined #ruby
Asher has joined #ruby
donofrio has quit [Remote host closed the connection]
madsj has joined #ruby
vondruch has quit [Ping timeout: 244 seconds]
MaiconVieira has joined #ruby
<apeiros>
Chetic: yes
kurko_ has joined #ruby
Asher has quit [Ping timeout: 276 seconds]
<Chetic>
any tips on how to figure out what's wrong?
GodFather has joined #ruby
<apeiros>
.so is a native extension. most often written in C, and it can define methods callable from ruby
<apeiros>
with the given information? all I can tell you "read the exception and go from there".
<Chetic>
there is no run function declared in the .so-file though
<Chetic>
but maybe there's some mapping in-between?
<apeiros>
if you don't have access to the source, your options are limited to docs, though.
<Chetic>
the exception just says "[P4#run] Errors during command execution( "p4 users" )"
<apeiros>
how do you figure that there's no run-function in the .so file?
<Chetic>
objdump -Ct P4.so | grep run
<apeiros>
ok, I don't know how objdump's output maps with how methods are linked with the C code. so can't help with that.
<apeiros>
if you have the source, it'll read something along rb_define_method
<Chetic>
it lists and demangles all symbols
<Chetic>
ok
<apeiros>
the C symbol afaik doesn't have to have the same name as the method exposed in ruby
<Chetic>
where is the mapping stored then?
snickers has quit [Ping timeout: 244 seconds]
<apeiros>
as you can do e.g. rb_define_module_function(cP4, "run", your_c_function, argc)
GodFather has quit [Ping timeout: 276 seconds]
<apeiros>
I don't know where that information will end up in the .so
<Chetic>
wouldn't that end up in the .so-file though
<apeiros>
in some way sure. but I think only your_c_function ends up as a symbol
<apeiros>
I don't know where/how cP4 + "run" ends up
<Chetic>
hrm yeah maybe the mapping is mangled somehow
<apeiros>
(assumes cP4 = rb_define_class(…))
<apeiros>
or rb_define_module if it's a module
<Chetic>
I'm looking at the source
<Chetic>
with mappings
<apeiros>
the "run" certaily ends up in ruby's symbol table (Symbol.all_symbols), but where/how that's stored in the .so - as said, no idea.
<apeiros>
with the source as said, search for rb_define_module_function
<apeiros>
unless P4 is neither a class nor a module.
<apeiros>
then it'd just be rb_define_method iirc
<apeiros>
oh, could also be rb_define_singleton_method
<apeiros>
aaaah, I think rb_module_function is effectively what `module_function def foo` in ruby code does. so that one is less likely than singleton_method.
* apeiros
afk for a bit
apeiros has quit []
uplime has quit [Ping timeout: 252 seconds]
dmitch has joined #ruby
mhb has joined #ruby
GodFather has joined #ruby
elcontrastador has joined #ruby
tdy has joined #ruby
fluxAeon has joined #ruby
GodFather has quit [Ping timeout: 250 seconds]
Asher has joined #ruby
Rapture has joined #ruby
aupadhye has quit [Quit: Leaving]
Asher has quit [Ping timeout: 252 seconds]
tj_ has joined #ruby
apeiros_ has joined #ruby
madsj has quit [Quit: Lost terminal]
stoffus has quit [Ping timeout: 245 seconds]
noodle has quit [Ping timeout: 264 seconds]
stoffus has joined #ruby
za1b1tsu_ has quit [Ping timeout: 252 seconds]
nadir has joined #ruby
tj_ has quit [Remote host closed the connection]
justicefries has joined #ruby
stoffus has quit [Quit: leaving]
ivanskie has joined #ruby
noodle has joined #ruby
cow[moo] has quit [Ping timeout: 246 seconds]
orbyt_ has joined #ruby
justicefries has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
justicefries has joined #ruby
ruby462 has joined #ruby
tdy has quit [Ping timeout: 252 seconds]
reber has joined #ruby
sgen has joined #ruby
clemens3_ has quit [Remote host closed the connection]
sgen has quit [Max SendQ exceeded]
sgen has joined #ruby
Mia has joined #ruby
Mia has quit [Changing host]
Mia has joined #ruby
freemo_ has joined #ruby
kujira has quit []
clemens3_ has joined #ruby
uplime has joined #ruby
za1b1tsu_ has joined #ruby
alem0lars has quit [Ping timeout: 272 seconds]
freemo_ has quit [Changing host]
freemo_ has joined #ruby
ivanskie has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<freemo_>
hello everyone. I had a problem last night that havenwood was trying to work me through. He offered a solution, but it had a bug, we figured out why the bug was there but he had to go to sleep and we couldnt do a fix. Im a bit of a noob so im having trouble undersanding the issue myself or how to fix it. One sec I'll post the code itself and try to explain...
<freemo_>
What we are trying to do is get serialization to work such that certain instance variables are ignored (since they cant serialize)
<freemo_>
the issue is that objects being serialized also contain other objects that also need to be serialized.. this recursive nature is the reason it breaks it seems (the error is a very long stack trace of the same line over and over)
<freemo_>
So with that said, anyone have any ideas what to do?
<apeiros_>
oh wow, havenwood used class variables?
Francisco has quit [Quit: Francisco]
<apeiros_>
not sure why you use included hook instead of defining the methods and use extend…
<apeiros_>
well… got to run in ~5min, so I'm probably not able to help.
apeiros_ has quit []
Asher has joined #ruby
kurko_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
polishdub has joined #ruby
Asher has quit [Ping timeout: 245 seconds]
chouhoulis has joined #ruby
chouhoulis has quit [Remote host closed the connection]
chouhoulis has joined #ruby
jackson has joined #ruby
jackson is now known as Guest90026
troulouliou_div2 has quit [Read error: Connection reset by peer]
DTZUZO_ has quit [Ping timeout: 276 seconds]
za1b1tsu_ has joined #ruby
clemens3_ has quit [Ping timeout: 244 seconds]
gheegh has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
za1b1tsu_ has quit [Ping timeout: 246 seconds]
desperek has joined #ruby
samort7 has joined #ruby
<samort7>
I know it is a bit overkill, but anyone ever use Rails for just a basic personal website?
snickers has joined #ruby
jcarl43 has joined #ruby
apeiros_ has joined #ruby
<apeiros_>
samort7: sure. why not.
<samort7>
apeiros_, alright neat :)
apeiros_ is now known as apeiros
<Eiam>
samort7: take a look at Sinatra?
<Eiam>
way less magic and overhead than Rails
<Eiam>
not that rails cannot do it, just cognitive load for me. I used to use Rails, these days I try to keep it simple with sinatra
<samort7>
Eiam: It's just that I am now finishing Hartle's Rails tutorial and wanted something to work on while I brainstorm bigger and better project ideas.
<Eiam>
well, good reason to use Rails then =)
<samort7>
Eiam: :)
andikr has quit [Remote host closed the connection]
gheegh has joined #ruby
nahra has joined #ruby
swoorup has joined #ruby
<freemo_>
apeiros: yea havenwood is the one who wrote that, i only partially understand what is going on
<freemo_>
So anyone have any ideas on how to address my problem
<apeiros>
freemo_: I'd need a reproducible example. but I'm only here for a moment, that's why I said before I'll likely not be very helpful :-|
<freemo_>
apeiros: well you can run the code to reproduce the error, but it probably isnt too hard to write a minamilist example (I can try). it would just need a member variable to contain a serializable object
rippa has joined #ruby
<apeiros>
freemo_: eh, no, I can't run that code. I don't have Whisper.
Dbugger has joined #ruby
<havenwood>
apeiros: Seriously, what was I thinking? Yesterday was a long day, but I didn't realize I was so far gone that I'd start using class variables... ¯\_(ツ)_/¯
<apeiros>
*Wisper
<apeiros>
havenwood: 17:40 apeiros: he must have had a good reason :)
<apeiros>
see, I trust you! :D
<havenwood>
haha
<freemo_>
havenwood: you gotta admit that while class variables should be a very rare occurance there are some scenarios where it makes sense. Most of which are cases where the class variables are static (like this one)
<apeiros>
anyway, got to get some extreeeemely slow query to run now and then run myself some ~5 miles
<apeiros>
why did I use miles? fuck miles. km ftw.
<havenwood>
freemo_: So the issue we left off with was the Producers themselves have Producers (is that the right word, I remember it starts with "P")
<havenwood>
freemo_: And it's serializing to too deep a depth and overflowing the stack, right?
<freemo_>
havenwood: I think you mean "Publisher" not "Producer" .. unless producer has a technical meaning here im unaware of
<havenwood>
Yes, Publisher.
<apeiros>
freemo_: you realize tho that class variables are shared across the ancestry, yes?
<havenwood>
freemo_: No, I just can't remember words. Starts with "P" and ends with "r" are all the same word to my brain. >.>
<apeiros>
and in a rather funky way with regards to where they are cut off (first seen first cut-off)
DTZUZO_ has joined #ruby
<freemo_>
apeiros: well i havent used them much in ruby yet, but it would seem that in this case that is exactly what youd want, since a child of a class would still ignore the same stuff as the parent. So you'd want the hierarchy to have it
<havenwood>
freemo_: If each Publisher has Publishers, how deep does it go?
<freemo_>
havenwood: but im not sure the issue is "too deep".. because with my code while it would be recursive the depth would only be a few dozen levels at most.. but the call looks like it is recursive down hundreds of levels, and i doubt thats the case here
<apeiros>
freemo_: but the parents might not want to ignore the stuff children added…
<apeiros>
and they will. because it doesn't matter where in the ancestry you modify it. it'll be shared across all, all the same.
<havenwood>
freemo_: It needs to serialize the publishers of the publishers too though, right?
<freemo_>
havenwood: there is no set limit to how deep it would go. In practice usually just a few levels down. though in reality nothing is stopping it from going deeper
karapetyan has quit [Remote host closed the connection]
<freemo_>
havenwood: yes it needs to serialize as deep as it goes
<havenwood>
freemo_: How many publishers of publishers are there? Is that the hundreds?
elcontrastador has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<freemo_>
So everything in the game are either objects that cant contain things or objects that can. For example an area contains rooms, rooms contain people, people contain inventory, inventory contains bags, bags can contain other bags, and those bags can have objects
<havenwood>
freemo_: Serializing nested things that themselves have nested things that themselves have nested things and so on can get pretty deep.
<freemo_>
so just depends on who placed what in what and how many levels deep it goes
karapetyan has joined #ruby
<havenwood>
freemo_: hmm.
<freemo_>
right now it shouldnt be more than a few levels deep though cause its a starter world im testing on (one room in one area with one guy in it and one sword).. so probably the error we are seeing is after about 6 levels of recursion or so
<freemo_>
but once the game goes live there could be dozens of levels of recursion
<freemo_>
but not at the depth we are seeing (which looks like hundreds)
ivanskie has joined #ruby
<havenwood>
freemo_: I don't have time to look at Wisper at the moment, but I'm curious what's going on.
elcontrastador has joined #ruby
<freemo_>
havenwood: it isnt wisper related, if you recall even if we remove wisper the issue still occured
<havenwood>
freemo_: What's your Publisher code left after removing the Wisper mixin?
<havenwood>
freemo_: Where's that class defined? There's got to be more than an empty class right, or it'd work like the example.
<havenwood>
freemo_: I forgot you reproduced it after removing Wisper, but that doesn't make sense!
<freemo_>
havenwood: well the publisher itself is empty (other than the include of your class) once i remove wisper. But that in turn was included by game_object and manager... and every object in the game extends from game_object
<freemo_>
so quite a bit
<freemo_>
in this case its the inventory class that is offending
<freemo_>
which has its own marshal calls
<freemo_>
which i suspect is where the problem is
<havenwood>
freemo_: Can you link us to that class? Sounds like a culprit.
<freemo_>
inventory has its own marshal call, and inventory includes Publisher, which itseld redefined marshal
<freemo_>
sure
orbyt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<freemo_>
damnit ruby bot I was resharing the same link upon request ::scowls::
suukim has joined #ruby
DTZUZO has joined #ruby
DTZUZO_ has quit [Ping timeout: 268 seconds]
duderonomy has joined #ruby
<havenwood>
freemo_: binding.irb in and try?: Marshal.dump data.first
teej has joined #ruby
lxsameer has quit [Ping timeout: 250 seconds]
ivanskie has joined #ruby
MaiconVieira has quit [Remote host closed the connection]
darkhanb has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<freemo_>
havenwood: same spot we had it before right? ok...
<havenwood>
freemo_: Yeah, just trying to get some insights into which ivars are causing this.
<freemo_>
havenwood: that appears to have worked, the output was as follows: => "\x04\b[\a:\n@infoU:\tInfo{\a:\nflags{\x00:\fterrainU;\x06{\b:\findoors0:\rswimming0:\ttype0"
<havenwood>
freemo_: see if you can find which part of data fails?
<havenwood>
freemo_: Marshal.dump data[1]
<freemo_>
havenwood: just do the dump command and use different indexes till it fails?
swoorup has joined #ruby
jrafanie has joined #ruby
<havenwood>
freemo_: Yeah, you could do it programmatically if there are many indexes. I think visibility on what exactly is causing this loop will help.
<freemo_>
havenwood: yup, im up to index 17 still not failure... ill keep trying...
<freemo_>
havenwood: i dont think any of the indexes failed...
<havenwood>
freemo_: But it does fail if you?: Marshal.dump data
<freemo_>
havenwood: i could maybe just not create the object that is succeeding... then the first one it hits may be the failing one (since there are only two rooms and the first one it tries to serialize is the empty one)
<freemo_>
let me try that.
<freemo_>
havenwood: oh wait i figured it out
<freemo_>
havenwood: if you do "quit" then instead of quiting it just goes to the next binding
sarmiena_ has joined #ruby
<freemo_>
havenwood: ok i think i found the offending object (though the behavior is kinda weird
<freemo_>
havenwood: so once i get to this object if i try to dump the data then it just puts me back at a new binding. Which is the behavior i think id expect if this thing was infinitely recursive: https://gist.github.com/freemo/e3de4e6ad796118f68cbf4123c2c3686
KrzaQ has quit [Ping timeout: 268 seconds]
mikecmpbll has quit [Quit: inabit. zz.]
funnel_ has joined #ruby
swoorup has quit [Remote host closed the connection]
MoritaShinobu has quit [Quit: Leaving]
duderonomy has joined #ruby
darkhanb has joined #ruby
clemens3 has joined #ruby
swoorup has joined #ruby
clemens3_ has quit [Ping timeout: 245 seconds]
funnel has quit [Remote host closed the connection]
funnel_ is now known as funnel
KrzaQ has joined #ruby
swoorup has quit [Remote host closed the connection]
venmx has quit [Ping timeout: 252 seconds]
swoorup has joined #ruby
swoorup has quit [Remote host closed the connection]
yqt has quit [Ping timeout: 268 seconds]
Guest90026 has quit [Quit: Lost terminal]
swoorup has joined #ruby
nowhereman_ has joined #ruby
nowhere_man has quit [Read error: Connection reset by peer]
duderonomy has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
swoorup has quit [Remote host closed the connection]
swoorup has joined #ruby
Boboo has joined #ruby
Boboo has quit [K-Lined]
nowhereman_ has quit [Ping timeout: 252 seconds]
<freemo_>
hmm still kinda confused on how to fix this even though i found the offending object... hmmm
za1b1tsu_ has joined #ruby
<havenwood>
freemo_: What was the offending object?
<freemo_>
havenwood: its the mobile object (i can link it)
<freemo_>
havenwood: interestingly i dont think the mobile should actually have anything in its inventory
sauvin has quit [Read error: Connection reset by peer]
bmurt has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<freemo_>
havenwood: i think i found the issue, though im not clear why your code produces the bug whereas the old way of serializing did not
<freemo_>
havenwood: maybe the built0in serialization method is smart enough to not go recursive
<freemo_>
havenwood: but yea pretty sure i see what the problem is at least, just not how to fix it
kurko_ has joined #ruby
bmurt has joined #ruby
alem0lars has joined #ruby
akaiiro has quit [Ping timeout: 252 seconds]
dmitch has quit [Ping timeout: 260 seconds]
vondruch has joined #ruby
vondruch has quit [Remote host closed the connection]
Boboo has joined #ruby
Boboo has quit [Client Quit]
gell5 has quit [Read error: Connection reset by peer]
vondruch has joined #ruby
gell5 has joined #ruby
swoorup has quit [Read error: Connection reset by peer]
<freemo_>
havenwood: I fixed it! (well sorta/mostly)
<freemo_>
just gotta fix some unrelated stuff that was effected
<freemo_>
but yea its fixed :)
chouhoul_ has joined #ruby
bmurt has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
dviola has joined #ruby
<havenwood>
freemo_: nice!
chouhoulis has quit [Ping timeout: 245 seconds]
<freemo_>
havenwood: i still think ill need to redesign a lot of this approach though. But it is a good start, thanks so much
<freemo_>
havenwood: the issue was that a mobile contained a reactor and the reactor contained a reference back to the mobile.
MaiconVieira has joined #ruby
dous has quit [Ping timeout: 264 seconds]
<havenwood>
freemo_: oooh
<havenwood>
that explain the looping
surrounder has quit [Ping timeout: 264 seconds]
dous has joined #ruby
<havenwood>
explains*
surrounder has joined #ruby
bmurt has joined #ruby
<freemo_>
yup
<freemo_>
havenwood: i think the default marshaller is smart enough to handle that gracefully.. just need to figure out how to implement that ntelligence in our own method
<havenwood>
freemo_: Without including the marshaling module, can you actually marshal the offending object directly with?: Marshal.dump
<freemo_>
havenwood: yup
claudiuinberlin has joined #ruby
Asher has joined #ruby
jrafanie has joined #ruby
eckhardt has joined #ruby
duderonomy has joined #ruby
claudiuinberlin has quit [Ping timeout: 252 seconds]
justache has joined #ruby
bmurt has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
sameerynho has joined #ruby
za1b1tsu_ has joined #ruby
duderonomy has quit [Read error: Connection reset by peer]
duderonomy has joined #ruby
za1b1tsu_ has quit [Ping timeout: 252 seconds]
postmodern has joined #ruby
teej has quit [Quit: Connection closed for inactivity]
MoritaShinobu has joined #ruby
akem has quit [Ping timeout: 252 seconds]
bmurt has joined #ruby
akem has joined #ruby
suukim has quit [Quit: Konversation terminated!]
InfinityFye has quit [Quit: Leaving]
jrafanie_ has joined #ruby
bmurt has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
tj_ has joined #ruby
SCHAPiE has quit [Ping timeout: 272 seconds]
jrafanie has quit [Ping timeout: 252 seconds]
code_zombie has joined #ruby
bmurt has joined #ruby
ivanskie has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
SCHAPiE has joined #ruby
connor_goodwolf has joined #ruby
chouhoul_ has quit [Remote host closed the connection]
chouhoulis has joined #ruby
GodFather has joined #ruby
<sgen>
Where can I view the source for a ruby gem online (specifically zlib)
kurko_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
kurko_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
GodFather has joined #ruby
akaiiro has joined #ruby
throwntall has quit [Remote host closed the connection]
throwntall has joined #ruby
kurko_ has joined #ruby
nowhereman_ has joined #ruby
schneider has joined #ruby
sgen has quit [Ping timeout: 252 seconds]
jamesaxl has joined #ruby
tj_ has quit [Quit: Leaving]
envex has joined #ruby
hugo_dc has joined #ruby
tdy has quit [Ping timeout: 252 seconds]
hugo_dc has quit [Quit: Leaving]
bmurt has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
MaiconVieira has quit [Remote host closed the connection]
sgen has joined #ruby
nowhereman_ has quit [Ping timeout: 268 seconds]
teej has joined #ruby
oncall-pokemon has quit [Quit: Connection closed for inactivity]
mostlybadfly has quit [Quit: Connection closed for inactivity]
Dbugger has quit [Remote host closed the connection]
jamesaxl has quit [Quit: WeeChat 2.2]
jetchisel has quit [Ping timeout: 252 seconds]
SeepingN has joined #ruby
jetchisel has joined #ruby
<freemo_>
havenwood: any idea where i could get my hands on the actual code in the defauly marshall method. im thinking of copying and modifying that so it handles our use case
bmurt has joined #ruby
alem0lars has quit [Remote host closed the connection]
<freemo_>
it isnt a gem so im guessing its somewhere in the core ruby code....
schneider has quit [Quit: WeeChat 2.0.1]
<freemo_>
oh damn i think its in C :(
alem0lars has joined #ruby
<freemo_>
Ok how about this question: Are there any good alternatives to the default ruby marshaling. Perhaps a more feature-rich gem ?
ur5us has joined #ruby
<apeiros>
depends. what do you want from serialization?
<freemo_>
apeiros: well mostly just something where custom serialization of classes is easy, but automatic when there is no need for custom
rippa has quit [Quit: {#`%${%&`+'${`%&NO CARRIER]
<freemo_>
apeiros: with the default marshal module it seems it works great when automatic, but if you have specific fields you dont want serialized then you have to write your own and can not extend from the base method (since it serializes everything). As such it makes it very hard to create customized serialization on just part of the hiararchy and keep it automatic for the rest.
<apeiros>
freemo_: well, you can make any serialization easy by implementing your own serialization protocol. as in: add Object#my_serializable which returns primitive values, override that in cases where you want to customize. then do WhichEverSerializer.dump(your_obj.my_serializable)
<apeiros>
s/easy/easily customizable/
<freemo_>
apeiros: id have to see an example as i may not be understanding you correctly, but im not sure how that makes things any easier.
<apeiros>
it frees you from depending on a specific serializer's mechanism of implementing a custom serialization.
bmurt has quit [Ping timeout: 245 seconds]
<freemo_>
apeiros: then i think i may not be understanding what your suggesting
<freemo_>
apeiros: the whole point is that I WANT to rely on the automatic mechanism, just selectively
<apeiros>
yeah, then you'll have to read up on the docs of whichever serializer you use and follow their pattern. there are plenty of serializations:
<apeiros>
json, yaml, msgpack, protobuf to name a few
<freemo_>
apeiros: in short. I want to have the default serializer serialize my whole class structure (all the variables int he parent class and children class) but only customize the serialization for one local variable (in this case make sure it is just serialized to nil)
reber has quit [Remote host closed the connection]
<apeiros>
^
<freemo_>
apeiros: is there one you recommend i look at first that has good support for the use case I just described? I'm not above learning the module, just need some advice as to which one might suite my needs as I described them.
<apeiros>
not really. due to external circumstances I had to use json and yaml exclusively in the past.
<apeiros>
well, and sometimes xml.
<freemo_>
apeiros: do either of those seem to have mechanisms that would fit my needs?
<freemo_>
apeiros: even if i can just rule out some in that list as not likely to be a good fit then I know where to start looking
<apeiros>
I know yaml can, I don't remember how easy it was. IIRC it was rather complex there.
<freemo_>
protobuf sounds cool, also it sounds like i heard of it before....
<freemo_>
maybe ill look at that
<apeiros>
with JSON it depends on the specific gem/framework you use. since I use json within rails, you satisfy rails' protocol for serialization.
<freemo_>
ohhh protobuf.. protocol buffers.. i used this in java before!
<apeiros>
I think protobuf's origin is with google/go
<freemo_>
that would go beyond just serialization though (in this case for storage on the hard drive)
<freemo_>
yes its google
<freemo_>
but its a standard IIRC
<freemo_>
so maybe msgpack...
<freemo_>
man this is the first time in my expiernce with Ruby that they made something needlessly difficult that should be an everyday task
<apeiros>
yes. as are all the others I mentioned ;-)
<apeiros>
(standard)
<marz_d`ghostman>
Is it possible to instantiate an object before each context?
Nicmavr has quit [Read error: Connection reset by peer]
mikecmpbll has quit [Quit: inabit. zz.]
Nicmavr has joined #ruby
code_zombie has quit [Quit: Leaving]
kurko_ has joined #ruby
pulgolino has quit [Remote host closed the connection]
phaul has quit [Quit: bye]
supergeek has joined #ruby
supergeek has quit [Client Quit]
polishdub has quit [Quit: leaving]
MaiconVieira has quit [Ping timeout: 252 seconds]
sameerynho has quit [Ping timeout: 252 seconds]
duderonomy has joined #ruby
<cthulchu>
folks, how is it called again?
<cthulchu>
when I use arguments like a:b in def?
<cthulchu>
I think this is the bestest thing about Ruby
<cthulchu>
well, to me
<cthulchu>
cuz I never used it before
<SeepingN>
defaults?
fluxAeon has joined #ruby
<cthulchu>
no, not a=b
<cthulchu>
like def error_reporting(screen_name:"", category:"", action:"", label:"")
<cthulchu>
and then you can do error_reporting(category:"pew-pew")
duderonomy has quit [Ping timeout: 250 seconds]
<cthulchu>
so the order and quantity doesn't matter
<cthulchu>
it makes my life sooooo much easier
<cthulchu>
also makes my code sloppier
<cthulchu>
what is it called
<cthulchu>
there was a term for it
<cthulchu>
keyed arguments?
<cthulchu>
I think apeiros told me about this back when I was starting it
<freemo_>
zenspider: marshal is easy to understand, just not written in a way that is very easy for the user to work with.
DTZUZO has quit [Ping timeout: 252 seconds]
ivanskie has joined #ruby
DTZUZO has joined #ruby
<zenspider>
freemo_: compared to protobuf?!? disagree
cd has quit [Quit: cd]
cd has joined #ruby
supergeek has joined #ruby
<freemo_>
zenspider: I already ruled out protobuf and am instead looking at other gems
asphyxia has joined #ruby
<zenspider>
well... I'll put my vote down for sticking with marshal. it works well. very fast. and actually quite easy when you need to customize when the default behavior doesn't work for you.
MaiconVieira has joined #ruby
<freemo_>
zenspider: Well thats what we tried to do for 2 days now and couldnt get it working right, so how do you suggest I do it? Cause switching to something else was a last resort anyway for me
supergeek has quit [Quit: Goodbye cruel world...]
<zenspider>
"couldn't get it working right" is too vague to work with. What'd you try and what happened instead?