« Back to channel list

#ruby - 23 November 2017

« Back 1 day Forward 1 day »
[00:01:44] Technodrome: has joined #ruby
[00:03:26] Algebr: has joined #ruby
[00:04:21] RickHull: leitz: move the require above the class
[00:04:31] RickHull: and it looks like you're no longer `include`ing your mixin
[00:04:51] nofxx: has joined #ruby
[00:04:59] RickHull: remember: require takes a filename and makes the definitions within available
[00:05:19] RickHull: include takes a module object and injects the module into the current context
[00:06:04] alveric3: has joined #ruby
[00:07:34] RickHull: leitz: though we can start doing some restructuring
[00:07:35] leitz: That worked. Once I checked how to re-include. Still have a Noble hiding somewhere. Off to kill her.
[00:08:16] RickHull: most of the #generate methods don't need to be instance methods
[00:08:21] RickHull: most, if not all
[00:09:42] RickHull: do you have the latest committed?
[00:10:55] leitz: Something can't find the career files. Trying to fix that. It isn't saying where the issue is.
[00:11:09] kryptoz: has joined #ruby
[00:11:20] mikecmpb_: has joined #ruby
[00:12:38] RickHull: here's how I would write generate_upp https://gist.github.com/rickhull/d7e0c2845c3b7587aaf370569c5df6d3
[00:12:51] RickHull: notice it's defined on the Character class, in character.rb
[00:13:18] RickHull: it's a "class method" rather than an "instance method" as it does not touch the Character object's ivars
[00:14:12] RickHull: `class Foo; `def self.bar` defines a class method that can be called like `Foo.bar`
[00:14:23] RickHull: without instantiating an object
[00:14:43] RickHull: i left an extra backtick in there, oops
[00:14:48] jackjackdripper: has joined #ruby
[00:15:45] dminuoso: A keen reader might notice that strictly speaking it is an instance method, but its tied to "self" (which in the context is the class object itself) -> which is why Character.generate_upp works. You call methods on instances.
[00:16:09] RickHull: sure, I mean in general OOP terminology, not ruby's weird twisted mirror of mirrors clownhouse
[00:16:46] dminuoso: >> a = "RickHull"; def a.hi; puts "hi, I am: #{self}"; a.hi
[00:16:47] ruby[bot]: dminuoso: # => /tmp/execpad-4f771f7cf4d1/source-4f771f7cf4d1:7: syntax error, unexpected end-of-input, expecting ke ...check link for more (https://eval.in/905705)
[00:16:51] dminuoso: >> a = "RickHull"; def a.hi; puts "hi, I am: #{self}"; end; a.hi
[00:16:52] ruby[bot]: dminuoso: # => hi, I am: RickHull ...check link for more (https://eval.in/905706)
[00:17:07] dminuoso: Sucks so muchy to type in irssi without an editor completing your `end` all the time.
[00:17:17] leitz: Hang on a sec, the chargen is broken.
[00:17:25] RickHull: i think a lot of my lack of grokking ruby's metaclass stuff has to do with devouring one of the earliest versions of Pickaxe
[00:17:46] RickHull: which explained things in conventional terms -- and I locked into that understanding
[00:17:51] dminuoso: RickHull: Dont even have to talk about all that stuff. You can think of it as defining methods on objects rather than classes.
[00:18:01] RickHull: classes are objects
[00:18:06] RickHull: so uh, boosh
[00:18:25] RickHull: it makes things terribly annoying to discuss
[00:18:48] dminuoso: RickHull: My point is, they are not "special to classes". You can tie a method to anything by just using def foo.bar :)
[00:19:11] dminuoso: The fact that there's classes involved, that is probably the secret bit we dont have to talk about.
[00:19:49] Psybur: has joined #ruby
[00:22:05] dminuoso: RickHull: This is also a good reason to not talk about `class << a` (notice how I intentionally did not use `self` there?) because the entire syntax should make you question "what is going on here. what is the keyword class doing here?"
[00:22:34] dminuoso: >> class << "funny business"; def fun; end; end
[00:22:36] ruby[bot]: dminuoso: # => :fun (https://eval.in/905707)
[00:22:55] RickHull: yeah that syntax is inscrutable
[00:23:09] dminuoso: Its great if you understand that it just opens up an objects singleton class. ;-)
[00:23:27] RickHull: I've worked with folks that love doing that, just so they can omit the `self` part of `def self.foo`
[00:23:37] dminuoso: class << a; end; is basically equivalent to a.singleton_class.instance_eval do; end
[00:23:39] RickHull: that's a horrendous use of coding judgment IMHO
[00:23:55] dminuoso: RickHull: I sometimes do it out of convenience.
[00:24:03] dminuoso: But its rare and usually justified.
[00:24:16] Exhiled: has joined #ruby
[00:24:25] RickHull: omitting a tiny part of a major signifier of what the method is intended for
[00:24:37] RickHull: and using goofball syntax to do it
[00:24:52] dminuoso: RickHull: Since my time with Haskell Ive started to appreciate concise syntax.
[00:24:56] RickHull: like, it's a big deal in my world whether a method is a "class method" or an "instance method"
[00:25:18] RickHull: how much does typing `self` hurt? I love looking at it -- it means something
[00:25:22] dminuoso: The frustration you are talking about, I had it too. I ended up realizing, it was mostly due to a lack of exact understanding.
[00:26:01] RickHull: i'd prefer your instance_eval version
[00:26:17] RickHull: but why even go there? you're adding a whole layer of indentation and masking the method signature
[00:26:30] dminuoso: RickHull: Note there's probably some subtly difference in semantics.
[00:26:34] cschneid_: has joined #ruby
[00:26:35] weaksauce: tomfoolery is why
[00:26:46] RickHull: why should I even have to consider a semantic difficulty?
[00:27:28] dminuoso: RickHull: At any rate. The day I learned that ruby had no class methods, was when ruby was finally demystified. I wished that articles and guides had mentioned this everywhere.
[00:27:51] RickHull: there are methods that have no access to ivars
[00:27:57] dminuoso: RickHull: Maybe you should start writing in SKI calculus.
[00:28:05] dminuoso: Only three things to consider.
[00:28:06] RickHull: and can be called without instantiating anything
[00:28:16] RickHull: and are globally available with `require`
[00:28:23] RickHull: "class methods" kick ass
[00:28:30] RickHull: what do you call them?
[00:28:58] RickHull: do you distinguish between methods that mess with ivars and require an instantiated object to call?
[00:29:01] dminuoso: the only difference between some method and another, is their name and/or the class/module they are defined in.
[00:29:04] RickHull: and those that don't?
[00:29:22] dminuoso: what makes you think methods on singleton classes cant have instance variables?
[00:29:38] dminuoso: and what makes you think you dont require an instantiated object to call them?
[00:29:54] dminuoso: Array.class << Array is an instantiated object, is it not?
[00:30:06] knight33: has joined #ruby
[00:30:49] RickHull: i don't quite follow. I mean where a user calls .new
[00:31:04] RickHull: File.open(fn) vs File.new(fn).open
[00:31:11] leitz: Different question. This line is failing. https://github.com/LeamHall/CT_Character_Generator/blob/refactor_muster_out/bin/chargen#L74
[00:31:16] weaksauce: i don't know if that distinction is worth making dminuoso
[00:31:17] RickHull: clearly one versions doesn't require instatiating a file
[00:31:26] weaksauce: Array is a special object
[00:31:41] dminuoso: >> def Class.store(a); @storage = a; end; def Class.print; puts @storage; end; Class.store(1); Class.print
[00:31:43] ruby[bot]: dminuoso: # => 1 ...check link for more (https://eval.in/905715)
[00:31:52] leitz: The intent is that chargen pulls in all possible careers from the lib/careers directoyr.
[00:32:14] leitz: It worked before I starting blowing things up.
[00:32:15] dminuoso: RickHull: Like I said. There is no such thing as class methods. There is only methods. ;-)
[00:33:55] RickHull: dminuoso: that's beautifully nonresponsive :|
[00:33:58] hays_: has joined #ruby
[00:34:10] dminuoso: RickHull: The example is a bit ill-conceived.
[00:34:14] dminuoso: You are creating objects eithe rway.
[00:34:22] dminuoso: It's just two different approaches.
[00:34:24] mim1k: has joined #ruby
[00:34:33] RickHull: sure, and one is goofballs
[00:34:35] RickHull: guess which
[00:34:37] weaksauce: leitz where is that file?
[00:34:57] dminuoso: RickHull: Im unsure what your point is.
[00:35:54] weaksauce: if you want to do something like that you would need to add an umbrella file that contains requires to all the other career files.
[00:35:58] leitz: weaksauce, which file?
[00:36:19] al2o3-cr: >> class X def self.x() :x end end; X.singleton_class.instance_methods(false)
[00:36:20] ruby[bot]: al2o3-cr: # => [:x] (https://eval.in/905718)
[00:36:38] weaksauce: sorry, career.rb
[00:37:04] leitz: It's not. This is the tricky part I mentioend a while ago. "career" is from line 72, a variable.
[00:37:11] RickHull: weaksauce: the career being required -- that's a variable, not 'career'
[00:37:18] weaksauce: oh right. my bad
[00:37:20] leitz: So it refers to noble, other, etc.
[00:37:20] RickHull: require career -- vs -- require 'career'
[00:37:40] leitz: weaksauce, I wrote it and I still barely get it...
[00:37:53] leitz: Of course, I wrote it with #ruby help. :)
[00:38:10] weaksauce: you'd want to use the full path to that file.
[00:38:29] leitz: The issue is, I think, once LOAD_PATH is not modified, it can't find it.
[00:39:03] leitz: I tried to add the path but it didn't work "careers/#{career}"
[00:39:08] RickHull: i think you need require File.join('careers', career)
[00:39:22] RickHull: yes, you need to provide the subdir path within lib/
[00:39:32] weaksauce: so if your key is noble. the filename is noble.rb and then the require should be something like require "lib/careers/#{career}"
[00:39:40] RickHull: not with lib though
[00:39:57] weaksauce: er yeah, since you add the loadpath to ruby
[00:39:59] RickHull: presuming you called `ruby -Ilib bin/chargen`
[00:40:32] weaksauce: so then, require "careers/#{career}" if you want to do it dynamically like that
[00:40:37] RickHull: dminuoso: my point is that yes, ruby is mad flexible and you can do crazy postmodern stuff with it, like in Perl
[00:40:56] RickHull: but there are also well established conventions and best practices that is similar to python methodology
[00:41:06] kapil___: has joined #ruby
[00:41:07] RickHull: where the term "class method" is meaningful
[00:42:01] al2o3-cr: RickHull: class methods are merely instance methods on the singleton class
[00:42:34] RickHull: yes, and we can make the singleton class behave like a class instance with ivars
[00:42:49] RickHull: but rarely is that a good idea
[00:43:22] weaksauce: why did ruby call the anonymous classes that get created when you add methods to an instantiated object singleton classes instead of something with less baggage?
[00:43:37] dminuoso: RickHull: The only difference between a singleton clas and a non-singleton class, is that the type of that singleton class is inhabited by only one object. Non-singleton classes are (usually) inhabited by an infinite number of possible objects.
[00:43:52] dminuoso: weaksauce: ^- this is why.
[00:43:57] dminuoso: weaksauce: It has to do with basic type theory.
[00:44:18] dminuoso: weaksauce: When you consider a type as a set of possible values, singleton classes represent sets of just one object. Those sets are called "singleton sets"
[00:45:03] RickHull: what are the types in ruby? can we enumerate them?
[00:45:14] dminuoso: RickHull: classes and you can.
[00:45:16] weaksauce: i get that that is the case but in general the singleton pattern is more prevalent it would seem and it muddies the people just getting into ruby from say java.
[00:45:19] leitz: Ruby has all types...
[00:45:40] leitz: FIxed the require. Do the dishes, fix teamgen, and then it'll be nappy time.
[00:45:42] RickHull: is Array a ruby type?
[00:45:59] dminuoso: ObjectSpace.each_object(Class)
[00:46:07] charliesome: has joined #ruby
[00:46:38] larcara: has joined #ruby
[00:46:44] dminuoso: weaksauce: the singleton pattern name has the same origin :p
[00:47:10] Jameser: has joined #ruby
[00:48:58] RickHull: so Array is properly a type, a class, and an object - wonderful
[00:49:23] dminuoso: RickHull: well for the purpose of this discussion class and type are synonymous.
[00:49:31] cahoots: has joined #ruby
[00:50:03] ruby[bot]: RickHull: # => Array (https://eval.in/905734)
[00:50:08] RickHull: did I just instantiate an object?
[00:50:14] dminuoso: It already was.
[00:50:18] garyserj: has joined #ruby
[00:50:22] dminuoso: Array itself is of type Class.
[00:50:23] garyserj: does anybody here use haml?
[00:50:29] dminuoso: Ruby created it for you when it started.
[00:50:37] dminuoso: (Or rather when the VM is initialized)]
[00:51:11] garyserj: and does anybody here use sinatra?
[00:51:30] ruby[bot]: Don't ask to ask. Just ask your question, and if anybody can help, they will likely try to do so.
[00:51:32] weaksauce: perhaps that bot isn't around anymore
[00:52:10] dminuoso: RickHull: For what its worth, the clean separation of types and values in Haskell is much preferrable to this "everything is an object, including classes"
[00:52:51] dminuoso: Only thing Im missing is dependent types.
[00:53:53] RickHull: yes, I suppose I learned a much simpler programming model, with more limitations, that imposes dataflow structure
[00:53:58] reu: has joined #ruby
[00:54:10] RickHull: it's like structured programming without GOTO
[00:54:17] dminuoso: Ruby has goto.
[00:54:22] dminuoso: Like, actual goto.
[00:54:26] RickHull: it's an analogy
[00:54:34] weaksauce: i learned on basic years ago... that was basically goto programming
[00:54:36] RickHull: you can do all kinds of wacky stuff with GOTO
[00:54:39] dminuoso: No I mean like really.
[00:55:07] RickHull: it's good that it's there, but it doesn't mean you should roll with the pigs in the mud at every opportunity
[00:55:09] drewmcmillan: has joined #ruby
[00:55:22] RickHull: it's much better to limit yourself and impose structure
[00:55:41] dminuoso: You can declare __label__(:foo) and __goto__(:foo) just fine!
[00:55:45] garyserj: How do you tell Sinatra to look at a haml file outside of the views directory?
[00:57:34] Lyubo1: has joined #ruby
[00:58:26] RickHull: dminuoso: I program as though global variables and GOTO are not available. if I need to reach for them, so be it. likewise, I program as if "class methods" do not access ivars and behave much like functions
[00:58:48] RickHull: not everyone has to be like me :)
[00:59:22] RickHull: but wearing that straitjacket yields simple and easy to understand code, in my experience
[01:00:15] RickHull: and it is in accordance with the larger OOP world beyond ruby's specific impl
[01:02:37] RickHull: doing class << self just to avoid typing `self` on a few method signatures -- this adds indentation, LOC, inscrutability, and screws up the method signature
[01:03:14] RickHull: it matters whether the methods are defined on the singleton class
[01:03:29] RickHull: why hide that signature?
[01:04:11] RickHull: when we look at rdoc, we see "class methods" and "instance methods" this is a sensible and common way of looking at ruby functionality
[01:04:57] weaksauce: as the saying goes, there are only two hard problems in computer science: cache invalidation, naming things and off by one errors
[01:06:37] oetjenj: has joined #ruby
[01:08:29] stevie: has joined #ruby
[01:08:39] stevie: does ruby play nice with uwsgi?
[01:10:17] RickHull: stevie: are you familiar with rack?
[01:10:32] mim1k: has joined #ruby
[01:10:59] leitz: Well, dang, it almost all worked.
[01:11:13] charliesome: has joined #ruby
[01:12:00] RickHull: stevie: rack is ruby's standard web middleware, modeled off WSGI as i understand https://rack.github.io/
[01:12:17] RickHull: I'm not sure about uwsgi
[01:12:33] dminuoso: RickHull | dminuoso: I program as though global variables and GOTO are not available.
[01:12:36] dminuoso: You use if right?
[01:12:45] dminuoso: That's a conditional goto.
[01:12:49] RickHull: yes, as in structured programming
[01:13:23] RickHull: the Dijkstra "goto considered harmful" sense
[01:13:37] RickHull: the pedantic stuff about "peel back the covers and there's a jmp" isn't really helpful
[01:15:26] dminuoso: The irrational fear of goto is just a subconscious fear of imperative programming.
[01:15:38] dminuoso: People just know that "telling" the program to suddenly do weird things is bad.
[01:15:51] RickHull: nope, structured programming is objectively better
[01:16:04] RickHull: dijkstra wasn't being irrational
[01:17:42] Algebr: has joined #ruby
[01:18:05] RickHull: and for sure, ceteris paribus, declarative programming is better than imperative
[01:18:12] RickHull: it's just that ceteris usually isn't paribus
[01:18:30] RickHull: but we'll get there one day ;)
[01:19:11] dminuoso: RickHull: Considering how "structured programming" introduces exceptions later, which are even worse than gotos in a particular way.
[01:19:23] dminuoso: Namely that they are commonly implemented using non-local gotos.
[01:19:24] RickHull: i do like early returns, breaks, and exceptions
[01:19:48] Psybur: has joined #ruby
[01:20:08] garyserj: for a small project, is sinatra advantageous over rails?
[01:20:10] RickHull: there's a difference between an abstraction that uses goto in a structured way and littering your code with gotos
[01:20:27] dminuoso: RickHull: I still do believe, that all these things "dont abuse exceptions", "dont use goto the wrong way", "dont use global variables", are just symptoms of imperative programming. That isn't to say the paradigm is inherently bad, decades of successful projects show that this is not the case.
[01:20:30] RickHull: garyserj: I like starting with sinatra -- it's very quick and easy to get going
[01:21:09] RickHull: dminuoso: i'd make an analogy between declaring a rectangle vs driving a paintbrush
[01:21:12] dinfuehr: has joined #ruby
[01:21:25] leitz: For those awake who care, tonights changes to CT_Character_Generator have been merged into the master branch. I've been up for a while and it's nappy time. More fun in the morning.
[01:21:31] RickHull: driving a paintbrush can go wrong in many more varied ways
[01:21:58] RickHull: leitz: I might poke around -- til next time :)
[01:22:11] dminuoso: RickHull: Well at any rate, it is a religion war.
[01:22:19] dminuoso: And I finally found mine.
[01:22:28] dminuoso: Just admit that you are wrong.
[01:22:50] RickHull: I have declared a fatwa on "x is merely a y on a z"
[01:23:20] leitz: RickHull, there's a big issue coming up; UPP might much better be a hash, but it's currently a string that gets split and reformed. It will affect a lot of code. Should make some cleaner though.
[01:23:29] leitz: Be sure you go back to the master branch.
[01:23:40] RickHull: what does upp mean?
[01:24:09] leitz: Universal Personality Profile. The characters stats: strength, endurance, education, etc.
[01:24:20] webguynow: has joined #ruby
[01:24:26] RickHull: S P E C I A L
[01:24:41] leitz: Normally 6 Hex characters but there are two outliers that need to be handled.
[01:24:55] leitz: Modifying a key'd hash seems a lot easier.
[01:25:15] leitz: Feel free to open an issue if you like, I do. :)
[01:29:00] garyserj: Do you think Haml is helpful? I am using sinatra and haml, though i'm not sure how to point to aa haml file in the root, outside of the views directory.
[01:31:01] dminuoso: garyserj: No.
[01:31:36] dminuoso: At this point Im so close to going back to HTML again. The price tag of rendering engines is just too high. Any "boilerplate" issues are editor issues, not language issues.
[01:31:41] cahoots: has joined #ruby
[01:31:54] cdg: has joined #ruby
[01:36:18] RickHull: i think the problem with bypassing a rendering engine is you have to maintain a stack yourself
[01:36:30] RickHull: someone has to maintain the tag stack
[01:36:39] Guest70176: has joined #ruby
[01:37:19] RickHull: and do you want to be doing stack manipulation in your views? or just call methods that do the stack manipulation behind the scenes?
[01:37:31] ap4y: has joined #ruby
[01:37:54] RickHull: but I haven't messed with this stuff in a while, maybe I'm misunderstanding
[01:41:26] Guest90_: has joined #ruby
[01:41:54] RickHull: and then what should be responsible for e.g. double quotes for attributes and doing all the angle brackets, and tag styles for elements without inner text
[01:42:35] pilne: has joined #ruby
[01:44:50] garyserj: I am totally new to the concept of something like haml
[01:44:57] garyserj: so i've no idea. i'm just going to be playing with it a bit.
[01:45:05] RickHull: I would stick with it for now
[01:45:21] mtkd: has joined #ruby
[01:45:33] RickHull: it's pretty standard and it is useful
[01:46:00] garyserj: at the moment I know it more as a quick way of writing html.. but is it not really, is it really for a template of html with variables and you inject data into the variables?
[01:46:03] RickHull: if you decide you hate it later, at least it will be based on experience that can apply to your next decision
[01:46:43] QualityAddict: has joined #ruby
[01:46:45] RickHull: my understanding is it's a way to call e.g. #form with some args that will define an html form for you
[01:47:03] RickHull: i think it touches on both templating and rendering
[01:50:25] eightlimbed: has joined #ruby
[01:52:21] helpa: has joined #ruby
[01:53:29] JBbankss: has joined #ruby
[01:54:01] Eletious_: has joined #ruby
[01:55:44] harfangk: has joined #ruby
[02:01:54] MrSparkle: has joined #ruby
[02:04:44] bdnelson: has joined #ruby
[02:04:50] oetjenj: has joined #ruby
[02:08:03] uZiel: has joined #ruby
[02:08:20] d^sh: has joined #ruby
[02:09:07] FastJack: has joined #ruby
[02:09:18] tuelz: has joined #ruby
[02:09:39] bdnelson: has joined #ruby
[02:10:52] silvermine: has joined #ruby
[02:12:01] bdnelson: has joined #ruby
[02:14:10] Technodrome: has joined #ruby
[02:18:09] brian_penguin: has joined #ruby
[02:18:55] uZiel: has joined #ruby
[02:19:49] Psybur: has joined #ruby
[02:21:43] cschneid_: has joined #ruby
[02:27:21] d^sh: has joined #ruby
[02:27:54] jackjackdripper: has joined #ruby
[02:44:15] charliesome: has joined #ruby
[02:47:47] rouge: has joined #ruby
[02:49:20] gizmore|2: has joined #ruby
[02:51:56] cryocaustik: has joined #ruby
[02:51:57] Bin4ry: has joined #ruby
[02:51:59] Guest70176: has joined #ruby
[02:56:03] weaksauce: garyserj i like rails more because it's easier to get going for me
[02:56:22] weaksauce: it quite a bit more productive to me but sinatra is not bad
[02:58:11] weaksauce: i like haml a lot for forcing consistency and making overly complex stuff in views harder
[02:58:21] weaksauce: but everyone has an opinion
[02:59:00] ule: Lets say I have something like: ["en", #<User id: 1, name: "foo">, "en", #<User id: 2, name: "bar">]]
[02:59:06] ule: How can I make this become this:
[02:59:32] nofxx1: has joined #ruby
[02:59:44] weaksauce: yourarray.each_slice(2).map do |x,y| y end
[02:59:47] ule: { en: { #<User id: 1, name: "foo">, #<User id: 2, name: "bar"> } }
[03:00:19] Radar: ule: that syntax is valid. Do you want perhaps: { en: [user1, user2] } ?
[03:00:24] Radar: is invalid*
[03:00:47] ule: Radar: yeah, but I need to combine the two users under "en"
[03:01:11] ule: I'm actually going to have probably "en" and "fr". Im doing this to split in groups
[03:01:13] Radar: ule: use each_slice as weaksauce suggests, and then group_by.
[03:01:20] ule: let me try
[03:02:49] stevie: does ruby have an equivalent to virtual environments?
[03:05:06] sspreitz: has joined #ruby
[03:05:33] weaksauce: stevie bundler is the closest that i know of
[03:05:35] guardianx: has joined #ruby
[03:05:50] weaksauce: different approach but similar outcomes
[03:06:16] weaksauce: it is actually better in my mind having played with both
[03:13:09] cdg: has joined #ruby
[03:14:22] Bin4ry: has joined #ruby
[03:18:10] mson: has joined #ruby
[03:19:51] Psybur: has joined #ruby
[03:20:41] ule: let me understand..
[03:20:48] ule: each_slice(2).map do |x,y| y end
[03:21:00] ule: this makes a new array only with Users
[03:21:13] ule: "en" is actually gone
[03:22:56] baweaver: array.each_slice(2).each_with_object(Hash.new { |h,k| h[k] [] }) { |(lang, user), h| h[lang] << user }
[03:23:24] baweaver: ACTION throws sparkles in air
[03:23:39] ule: you guys are masters
[03:24:04] baweaver: Give that a read to understand what that hash was - https://medium.com/@baweaver/abusing-hash-constructors-65d59c0a5b27
[03:24:17] baweaver: Just be careful around the black magic section, I get a tinge carried away there
[03:26:09] mim1k: has joined #ruby
[03:26:23] ule: oh man.. thats awesome
[03:26:52] baweaver: https://baweaver.gitbooks.io/an-illustrated-guide-to-ruby/content/assets/lemur_horror.png
[03:27:02] baweaver: ACTION is enjoying having a horde of lemur reactions to use
[03:27:30] Radar: ule: You can simplify this problem like this: : ["en", "]]
[03:27:35] Radar: ule: You can simplify this problem like this: : ["en", "user1", "en", "user2"]]
[03:28:02] Radar: >> ["en", "user1", "en", "user2"].each_slice(2).to_a
[03:28:04] ruby[bot]: Radar: # => [["en", "user1"], ["en", "user2"]] (https://eval.in/905759)
[03:28:18] baweaver: Note they want a hash
[03:28:37] Radar: Yeah. Got that. I am breaking it down into smaller easier to parse chunks.
[03:28:38] ule: but I want { en: { "user1", "user2" } }
[03:28:40] Radar: Chaining in Ruby can be confusing sometimes.
[03:28:58] Radar: What each_slice gives you is the pairing up of the user and their locale.
[03:29:02] s2013: has joined #ruby
[03:29:10] Radar: From that, you then need to group the users by the locale
[03:29:23] baweaver: ACTION sits down and listens to Master Radar
[03:29:31] ule: users.map { |u| [u.language_code, u] }.flatten.each_slice(2).each_with_object(Hash.new { |h,k| h[k] [] }) { |(lang, user), h| h[lang] << user }
[03:29:53] baweaver: wait wait wait
[03:30:01] Radar: >> ["en", "user1", "en", "user2"].each_slice(2).each_with_object({}) { |(locale, user), group| group[locale] ||= []; group[locale] << user }
[03:30:02] ruby[bot]: Radar: # => {"en"=>["user1", "user2"]} (https://eval.in/905762)
[03:30:03] baweaver: you had that before it was like that?
[03:30:18] baweaver: then just do this instead: users.group_by(&:language_code)
[03:30:34] ule: c'mon.. can't be that simple
[03:30:38] Radar: Could be.
[03:30:44] ule: facepalm :/
[03:30:48] ule: let me try
[03:30:54] baweaver: And realize Ruby is magic https://baweaver.gitbooks.io/an-illustrated-guide-to-ruby/content/assets/wizard_lemur.png
[03:31:41] c0ncealed: has joined #ruby
[03:31:50] ule: worked like a charm
[03:32:08] ule: yeeeeeeeaaaahh
[03:32:15] baweaver: Giving the original code earlier helps ;)
[03:32:29] baweaver: keeps you from having to do some odd hacks
[03:32:45] Radar: >> User = Struct.new(:language_code); users = [User.new("en"), User.new("en")]; users.group _by(&:language_code)
[03:32:46] ruby[bot]: Radar: # => undefined method `_by' for main:Object (NoMethodError) ...check link for more (https://eval.in/905764)
[03:32:50] Radar: >> User = Struct.new(:language_code); users = [User.new("en"), User.new("en")]; users.group_by(&:language_code)
[03:32:51] ruby[bot]: Radar: # => {"en"=>[#<struct User language_code="en">, #<struct User language_code="en">]} (https://eval.in/905765)
[03:32:57] baweaver: ACTION snickers
[03:33:07] baweaver: pesky spaces
[03:33:26] Radar: Switched from flat apple keyboard to mechanical keyboard about 15 mins ago and still adjusting
[03:33:45] baweaver: Sounds like an interesting type of change
[03:34:48] ule: Radar: exactly
[03:34:59] ule: dammit.. it was so simple
[03:35:19] baweaver: ule Takes time to get used to it
[03:36:26] drewmcmillan: has joined #ruby
[03:36:59] knight33: has joined #ruby
[03:40:33] Jameser`: has joined #ruby
[03:42:25] ule: thank you very much guys
[03:46:50] root3: has joined #ruby
[03:47:21] larcara: has joined #ruby
[03:47:37] kryptoz: has joined #ruby
[03:48:26] root3: why need this irc channel?
[03:49:01] havenwood: root3: This is a Ruby channel. Please feel free to ask Ruby questions here or share Ruby code.
[03:49:39] ule: root3: this is where ruby friends can talk about ruby
[03:50:18] Bin4ry: has joined #ruby
[03:51:23] root3: havenwood: Thank
[03:52:22] root3: has joined #ruby
[03:56:51] dtzuzu: has joined #ruby
[04:02:42] _lyte_: has joined #ruby
[04:03:26] Xiti`: has joined #ruby
[04:06:34] veeti: has joined #ruby
[04:10:55] bmurt: has joined #ruby
[04:12:10] Xiti: has joined #ruby
[04:19:04] harfangk: has joined #ruby
[04:19:46] Psybur: has joined #ruby
[04:21:41] mfb2: has joined #ruby
[04:25:07] uZiel: has joined #ruby
[04:27:39] rainbowz: has joined #ruby
[04:28:06] Bin4ry: has joined #ruby
[04:38:09] veeti: has joined #ruby
[04:44:28] Cohedrin: has joined #ruby
[04:48:39] larcara: has joined #ruby
[04:51:50] gix-: has joined #ruby
[04:55:19] orbyt_: has joined #ruby
[05:05:39] Technodrome: has joined #ruby
[05:07:33] Guest70176: has joined #ruby
[05:08:45] apparition: has joined #ruby
[05:15:04] ShekharReddy: has joined #ruby
[05:17:27] ur5us: has joined #ruby
[05:19:28] govg: has joined #ruby
[05:19:48] Psybur: has joined #ruby
[05:23:43] mjolnird: has joined #ruby
[05:26:43] mim1k: has joined #ruby
[05:27:47] MrBusiness: has joined #ruby
[05:28:49] iamarun: has joined #ruby
[05:33:51] mim1k: has joined #ruby
[05:49:03] larcara: has joined #ruby
[05:50:19] enterprisey: has joined #ruby
[06:04:21] reber: has joined #ruby
[06:08:27] ur5us: has joined #ruby
[06:09:44] kryptoz: has joined #ruby
[06:09:52] mtkd: has joined #ruby
[06:11:39] minimalism: has joined #ruby
[06:15:59] charliesome: has joined #ruby
[06:18:30] LocaMocha: has joined #ruby
[06:19:46] Psybur: has joined #ruby
[06:21:54] tacoboy: has joined #ruby
[06:21:59] harfangk: has joined #ruby
[06:27:26] mikecmpbll: has joined #ruby
[06:32:26] qba73: has joined #ruby
[06:33:50] conta: has joined #ruby
[06:40:40] ur5us: has joined #ruby
[06:45:00] DoubleMalt: has joined #ruby
[06:48:20] ramfjord: has joined #ruby
[06:50:19] larcara: has joined #ruby
[06:55:54] larcara: has joined #ruby
[06:56:42] rabajaj: has joined #ruby
[06:59:46] BTRE: has joined #ruby
[07:02:19] ur5us: has joined #ruby
[07:03:58] apparition: has joined #ruby
[07:08:16] Technodrome: has joined #ruby
[07:16:21] InfinityFye: has joined #ruby
[07:17:09] konsolebox: has joined #ruby
[07:17:25] oetjenj: has joined #ruby
[07:19:50] Psybur: has joined #ruby
[07:20:31] mark_66: has joined #ruby
[07:27:46] oetjenj: has joined #ruby
[07:28:59] Exhiled: has joined #ruby
[07:31:20] conta: has joined #ruby
[07:32:08] konsolebox: has joined #ruby
[07:40:13] konsolebox: has joined #ruby
[07:44:52] roshanavand: has joined #ruby
[07:48:01] lele: has joined #ruby
[07:49:29] maum: has joined #ruby
[07:49:32] andikr: has joined #ruby
[07:51:49] BioSpider: has joined #ruby
[07:54:14] cdg: has joined #ruby
[07:57:16] aufi: has joined #ruby
[07:58:58] larcara: has joined #ruby
[08:00:36] uZiel: has joined #ruby
[08:00:42] anas: has joined #ruby
[08:04:11] biberu: has joined #ruby
[08:05:53] larcara: has joined #ruby
[08:08:38] ur5us: has joined #ruby
[08:14:59] mark_66: has joined #ruby
[08:17:30] sonne: has left #ruby: ()
[08:18:55] deepredsky: has joined #ruby
[08:19:15] iamarun: has joined #ruby
[08:19:50] Psybur: has joined #ruby
[08:22:09] mfb2: has joined #ruby
[08:25:38] claudiuinberlin: has joined #ruby
[08:25:48] guille-moe: has joined #ruby
[08:31:06] TomyWork: has joined #ruby
[08:36:49] apparition: has joined #ruby
[08:38:17] minimalism: has joined #ruby
[08:41:33] DoubleMalt: has joined #ruby
[08:42:50] tAn: has joined #ruby
[08:45:57] mikecmpbll: has joined #ruby
[08:51:19] Bish: dminuoso: who would expect a pure funcitonal language to have a good way to express ycombinator :D
[08:51:56] Bish: haskell can have utf8 names?
[08:55:14] PhoenixMage: has joined #ruby
[08:57:42] PhoenixMage: Hi All, how can I compile a gem from a Makefile? I have an issue with -Werror in the Makefile and it finishes compiling if I remove it and accept the warnings but have no idea what to do next...
[08:58:25] Bish: usually gems do not have makefiles, am i mistaking?
[08:58:28] mim1k: has joined #ruby
[08:58:45] mikecmpbll: has joined #ruby
[08:59:14] Bish: PhoenixMage: do you have a github? you could put it up there, and give it as a source in the gemfile
[08:59:37] Bish: otherwise you could do the same thing with filesystem, pretty sure
[09:00:51] hurricanehrndz: has joined #ruby
[09:00:56] cschneid_: has joined #ruby
[09:01:18] PhoenixMage: Bish: I have the source code with the modified Makefile and its compiled but no idea have to package it to a gem
[09:01:39] Bish: PhoenixMage: well, you might never know, since the dude who wrote the gem makes all kind of stuff
[09:01:50] Bish: PhoenixMage: that's why yo should make it a github/repository
[09:01:56] Bish: and give it as source in your gemfile
[09:02:10] Bish: that way, your changes are ONLY about -Werror
[09:02:17] _aeris_: has joined #ruby
[09:08:49] burgestrand: has joined #ruby
[09:11:33] Bish: so you can just take out what makes this gem not build, and leave the rest as is
[09:11:48] PhoenixMage: :/ Nothing is ever easy
[09:12:19] Bish: welcome to cs-hell
[09:12:27] PhoenixMage: If I am going to do that I might as well try to find the bug and fix it
[09:12:33] Bish: what gem is it?
[09:12:45] PhoenixMage: gRPC compiling on arm
[09:13:01] Bish: oh poor you, native gem on arm
[09:13:14] PhoenixMage: I am trying to make a gitlab package
[09:13:21] PhoenixMage: For archlinux
[09:14:07] Bish: had do google gRPC
[09:14:09] Bish: looks cool
[09:14:22] Bish: what do people need it for
[09:14:27] Bish: can you talk to gitlab with it?
[09:14:32] jenrzzz: has joined #ruby
[09:14:32] jenrzzz: has joined #ruby
[09:15:46] PhoenixMage: I have no idea what gitlab uses it for, I am just following the compile from source instructions and gRPC is needed for a bundle
[09:16:01] RevanOne: has joined #ruby
[09:17:28] PhoenixMage: Running into this bug https://github.com/grpc/grpc/issues/11765 but for zlib
[09:19:50] Psybur: has joined #ruby
[09:21:34] guille-moe: has joined #ruby
[09:22:22] iamarun: has joined #ruby
[09:27:02] Bish: it crashes while compiling tests
[09:27:04] Bish: that's funny
[09:27:40] mim1k_: has joined #ruby
[09:28:23] Guest70176: has joined #ruby
[09:36:22] conta: has joined #ruby
[09:36:43] qba73: has joined #ruby
[09:37:15] Bish: well, i would say you're asking for it :D
[09:37:21] Bish: with gcc7
[09:38:18] PhoenixMage: And --with-cppflags=-Wno-error doesnt work :(
[09:39:57] Bish: if you want everything to be easy
[09:40:01] Bish: you should stick to stable versions
[09:40:03] Bish: dont you think
[09:40:34] adaedra: gcc7 seems to be a stable version though
[09:40:59] Bish: not if you ask gentoo package management, which is the one i trust
[09:41:14] adaedra: It's even a .2
[09:41:42] Bish: well, you're right, didn't check that up
[09:41:47] Bish: holy shit, in august already
[09:41:57] Bish: i remember people calling me crazy when installing 6.0
[09:42:40] Azure: has joined #ruby
[09:42:46] PhoenixMage: I am just using the default build package archlinux-arm
[09:43:07] Beams: has joined #ruby
[09:43:27] tomphp: has joined #ruby
[09:43:29] PhoenixMage: Looks like I will need to work out how to do the github thing
[09:44:04] PhoenixMage: The irony that it is gitlab I am trying to compile is not lost on me, I just wish it wouldnt redownload the source every time I do gem install
[09:44:32] marr: has joined #ruby
[09:50:23] Bish: docker is your friend
[09:50:39] howdoi: has joined #ruby
[09:52:36] DoubleMalt: has joined #ruby
[09:52:59] PhoenixMage: What does docker have to do with it?
[09:53:14] drewmcmillan: has joined #ruby
[09:53:19] Bish: if you have a run gem install <some_gem> line in a docker file
[09:53:23] Bish: it certainly won't repull it
[09:53:57] Bish: i was ultrasceptic when using containers at first, but it's sooo good, i use it for everything
[09:54:12] PhoenixMage: I am just cloning the repo will make the change and use the local repo
[09:54:23] PhoenixMage: I am a docker fan myself
[09:54:36] PhoenixMage: I use it for game servers most of the time though
[09:54:53] PhoenixMage: My Ark server is a docker container
[09:54:57] jaruga: has joined #ruby
[09:55:04] Bish: it solves so many problems that you shouldn't have in first place.. like non-compiling gems
[09:55:58] PhoenixMage: I think there is even a published docker container for gitlab on arm
[09:56:49] adaedra: Wait, if I'm reading correctly, you are just trying to install Gitlab?
[09:57:05] adaedra: How do you get from this to manually compiling a gem from a Makefile?
[09:58:17] jokke: i have something in my codebase which causes my tests to block indefinately
[09:58:20] PhoenixMage: adaedra: grpc is a requirement for gitlab
[09:58:40] PhoenixMage: There is no gitlab package for archlinux-arm
[09:59:01] jokke: it's before the actual test is run and after the test setup
[09:59:25] jokke: is there a easy way to find the actual code responsible for the blocking?
[10:00:00] adaedra: Ah, but it's not a gem right?
[10:01:18] dhollin3: has joined #ruby
[10:01:20] PhoenixMage: Its trying to install the gem when I install a gitlab bundle from the source
[10:01:55] PhoenixMage: Its only cos the damn Makefile has -Werror in it
[10:02:23] mtkd: has joined #ruby
[10:02:25] adaedra: Ah, I see, it'd be the gem bridge
[10:02:39] Azure: has joined #ruby
[10:02:47] adaedra: Everyone should use -Werror
[10:03:35] adaedra: grpc itself is built correctly?
[10:04:00] PhoenixMage: I dont disagree as long as you test with it first, the zlib code in grpc still hasnt been updated to fix the fallthrough warnings
[10:04:54] adaedra: ha, the AUR package for grpc does filter the -Werror out
[10:06:21] deepredsky: has joined #ruby
[10:06:24] adaedra: so, in order: did grpc itself (so not the gem) built correctly, or is it the one throwing the error?
[10:06:47] PhoenixMage: Its the one throwing the error
[10:07:01] ams__: has joined #ruby
[10:07:23] adaedra: So you can try building using the technique seen in the AUR I guess
[10:07:32] adaedra: https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=grpc
[10:07:56] PhoenixMage: Yeah reading that no
[10:08:20] PhoenixMage: I essentially did the same thing manually
[10:09:23] PhoenixMage: If the grpc libraries are installed system wide will it not actually recompile for the gem?
[10:09:36] PhoenixMage: I assumed that the gem would be like a bubble
[10:09:50] adaedra: However, the gem may still try to compile for itself a tiny bit of code to link to grpc
[10:10:22] RevanOne: Can I get a help with this please ? https://gist.github.com/dragosrosculete/a1f3a03c634cd2ab545bd0b88632fae6
[10:12:14] adaedra: Wait PhoenixMage, I may be wrong
[10:12:21] jokke: anyone? :/
[10:12:27] adaedra: This lib is built weirdly
[10:13:20] adaedra: You could try to attach a debugger, jokke
[10:13:30] jokke: yes i did that
[10:13:37] jokke: but as soon as it's blocking it's too late
[10:14:20] adaedra: With a debugger, you should be able to interrupt the process once it's blocked and inspect the stacktrace
[10:15:28] blackmesa: has joined #ruby
[10:15:33] jokke: you mean pry?
[10:16:31] Bish: "attach" a debugger
[10:16:36] Bish: does ruby have a function like this now?
[10:16:56] adaedra: I must admit I let RubyMine handle that for me last time I needed it
[10:17:09] Bish: pry is cool for stuff liek that, yah
[10:17:42] adaedra: But no, I mean a real debugger, which is usually an external process overseeing your program
[10:17:55] Bish: last time i checked ruby was not able to do such a thing?
[10:18:11] jokke: hmm it's only vendor code: https://gist.github.com/3f6ba2314330686496890fbbcbcf2624
[10:18:57] adaedra: It's running a process apparently
[10:19:05] burgestrand: You can use gdb with ruby
[10:19:09] iceden: has joined #ruby
[10:19:24] burgestrand: It'd recommend compling ruby with debug symbols enabled though, otherwise it's a mess trying to figure out what's what
[10:19:50] Psybur: has joined #ruby
[10:19:59] adaedra: Bish: I think there's a part that gets required in the executed script, which allows the external control
[10:20:06] adaedra: But that's long ago
[10:20:14] leitz: has joined #ruby
[10:20:18] adaedra: Now I write bug-free code, much less hassle :p
[10:20:23] Bish: gdb with ruby :D
[10:20:25] burgestrand: jokke looks like it's waiting for a system call though, you should be able to see what command it executed by looking at the process tree
[10:20:26] Bish: that's a good one
[10:20:31] jokke: couldn't i just trap interrupt?
[10:20:48] silvermine: has joined #ruby
[10:20:49] adaedra: Not sure the backtrace you get in trap would reveal the problem
[10:21:17] lexruee: has joined #ruby
[10:21:18] adaedra: But yeah, look at a htop or a ps to see what is launched by your script
[10:22:48] Azure: has joined #ruby
[10:22:54] Bish: maybe strace helps
[10:23:02] Bish: rescued me in many hopeless situations
[10:23:19] Bish: jokke: strace -fp <pidof ruby>
[10:23:27] Bish: you might see the reason for the block
[10:25:02] Bish: or even invoke the bad script with strace -f -o output <bad_script>
[10:25:04] jokke: it just launches the test apparently
[10:25:05] jokke: from rake
[10:25:27] jokke: this is the command line: /home/jokke/.anyenv/envs/rbenv/versions/2.4.2/bin/ruby -Ilib:test -I/home/jokke/code/meso/energybox/bridge/vendor/bundle/gems/rake-12.1.0/lib /home/jokke/code/meso/energybox/bridge/vendor/bundle/gems/rake-12.1.0/lib/rake/rake_test_loader.rb test/acceptance/protocols/databox/stream_data_message/request_forwarding_2_test.rb
[10:25:43] Bish: try to invoke it with strace
[10:26:04] Bish: you will se a lot of shit, but there is a slight chance you can read the exact error
[10:26:46] burgestrand: I think the process of running _that_, waiting until it hangs and then killing it with an interrupt to check the backtrace will give you better signal/noise ratio than the bazooka
[10:27:05] Bish: bazooka > all
[10:27:14] apparition: has joined #ruby
[10:28:26] charliesome: has joined #ruby
[10:30:22] jokke: Bish: awesome!
[10:30:24] jokke: https://gist.github.com/ba532f80888a550de424e020a24a004a
[10:30:56] Bish: so it's not blocking, it's retrying?
[10:31:07] Bish: this is the exact reason why strace > debugging in some cases
[10:31:11] Bish: particulary the hard ones
[10:32:51] Bish: jokke: where is the error in that dump?
[10:33:26] Bish: just so i learn something
[10:34:07] jenrzzz: has joined #ruby
[10:34:11] SirOliver: has joined #ruby
[10:35:13] lxsameer: has joined #ruby
[10:35:26] minimalism: has joined #ruby
[10:38:03] RoneDreamer: has joined #ruby
[10:45:39] Serpent7776: has joined #ruby
[10:52:08] bigkevmcd: has joined #ruby
[10:52:15] jokke: well i guess it's just that the mongodb connection is blocking
[10:52:31] jokke: or retrying indefinetly
[10:54:46] cdg: has joined #ruby
[10:56:35] ldnunes: has joined #ruby
[11:03:09] ldepandis: has joined #ruby
[11:03:11] Bish: that's cool
[11:06:29] jokke: yeah i don't know about that. :P now it's even harder to find the error
[11:06:55] deepredsky: has joined #ruby
[11:07:07] Bish: im sorry, then
[11:07:29] [spoiler]: has joined #ruby
[11:10:45] [spoiler]: has joined #ruby
[11:11:50] RoneDreamer: has joined #ruby
[11:11:53] [spoiler]: has joined #ruby
[11:12:13] RoneDreamer: has joined #ruby
[11:12:44] deepredsky: has joined #ruby
[11:13:56] mim1k: has joined #ruby
[11:14:44] leitz: Is there a Ruby equivalent to Pythons "my_hash.get('key', <default_value>}" ?
[11:15:33] tAn: `{}.fetch(:key, "value"}`
[11:15:46] tAn: `{}.fetch(:key, "value")` even
[11:15:58] leitz: hehe...thanks!
[11:16:06] leitz: ACTION goes off to refactor
[11:18:52] tvw: has joined #ruby
[11:19:48] Psybur: has joined #ruby
[11:21:30] esObe: has joined #ruby
[11:24:07] roshanavand: has joined #ruby
[11:25:45] deepredsky: has joined #ruby
[11:28:31] SirOliver: has joined #ruby
[11:30:57] RoneDreamer: has joined #ruby
[11:33:23] vtx: has joined #ruby
[11:34:47] SirOliver: has joined #ruby
[11:36:20] mim1k: has joined #ruby
[11:36:40] vtx: hi guys, does anyone here use sinatra? i’m trying to connect to a mongodb, and although i can connect, i think my client is cerating new connections for every request. looking at this recipe: http://recipes.sinatrarb.com/p/databases/mongo what does `:set` do? is it part of sinatra, or ruby in general? i currently assign my db connection as follows: `@db = mongo[database].database`, rather than using :set - is this why new connections are created for every request? w
[11:36:41] vtx: using :set solve this my ensuring only one connection is made and reused?
[11:37:30] Immune: has joined #ruby
[11:38:52] MrBismuth: has joined #ruby
[11:39:32] tbuehlmann: vtx: .set will really just only set it once. if mongo[database].database creates a new connection on each call, that might be it
[11:40:14] biberu: has joined #ruby
[11:43:21] vtx: oh, as an aside to that, maybe my code needs to do `@db ||= mongo[database].database`?
[11:43:41] vtx: tbuehlmann: is set part of sinatra DSL or is it a ruby thing?
[11:44:16] tbuehlmann: that's from sinatra
[11:44:50] SirOliver: has joined #ruby
[11:45:59] Defenestrate: has joined #ruby
[11:47:29] snickers: has joined #ruby
[11:47:58] vtx: okay thank you, i really appreciate it!
[11:50:32] silvermine: has joined #ruby
[11:56:25] jenrzzz: has joined #ruby
[11:56:25] jenrzzz: has joined #ruby
[11:57:57] SirOliver: has joined #ruby
[11:58:24] jaruga: has joined #ruby
[12:03:45] cdg: has joined #ruby
[12:04:21] deepredsky: has joined #ruby
[12:05:24] ule: Hey guys
[12:05:28] ule: https://ghostbin.com/paste/btydh
[12:06:06] RevanOne: https://gist.github.com/dragosrosculete/efd803706302387810e90e3bf838210f
[12:06:28] RevanOne: error in my ruby code, what am I missing ?
[12:06:29] ule: ops just edit
[12:07:27] ule: RevanOne: replace ).to_s to: end.to_s
[12:07:44] ule: so guys.. I need to merge two hashes like this:
[12:07:45] ule: https://ghostbin.com/paste/btydh
[12:07:56] ule: not sure if you know some magic ruby trick
[12:08:34] ule: its not actually a merge, its a combine
[12:08:43] larcara: has joined #ruby
[12:08:54] tobiasvl: RevanOne: I don't think you can use <%= on line 2 there? it seems to try to make the result of that line into a string, but it ends with an open block
[12:09:08] tobiasvl: but I haven't used erb in years
[12:09:16] ule: tobiasvl: already told him how to fix it
[12:09:49] tobiasvl: ule: no, actually you didn't :) if you look at line 2 in his gist, there's no ) in the actual ruby code. erb is inserting it
[12:11:14] tobiasvl: I assume erb is replacing <%= foo -%> with (foo).to_s
[12:11:15] ule: oh yeah
[12:11:45] RevanOne: hmm, so what is the actually solution then ? I cannot use 2 lines in my DO ?
[12:12:25] mostlybadfly: has joined #ruby
[12:12:37] tobiasvl: RevanOne: I don't remember how erb works, but can't you just change <%= to <% in line 2?
[12:12:49] tobiasvl: you just want that line to be evaluated, not printed
[12:13:51] RevanOne: so only this line: <%= factvalueslb['results'].map{|h|h[1]['fqdn']}.each do |val| -%> to <% factvalueslb['results'].map{|h|h[1]['fqdn']}.each do |val| -%>
[12:14:01] dminuoso: You sir, need to learn about variables.
[12:14:54] dminuoso: There's nothing scary about stuff = factvalueslb['results'].map{ |h| h[1]['fqdn'] }; /* and then in some other place */ <% stuff.each do |val | %>
[12:15:26] ule: https://ghostbin.com/paste/btydh
[12:15:40] ule: im stuck on this for at least 2h
[12:16:17] dminuoso: ule: Are you sure you dont have the hash the wrong way?
[12:16:26] ule: what do you mean?
[12:16:55] dminuoso: ule: Let me show you
[12:17:52] dminuoso: ule: What if two users happen to share this? ['en', 'android', 'sub_message']
[12:18:50] ule: pls refresh that
[12:19:02] ShekharReddy: has joined #ruby
[12:19:05] dminuoso: ule: How are you constructing one/two?
[12:19:28] ule: Im using group_by
[12:19:50] Psybur: has joined #ruby
[12:19:52] dminuoso: ule: Can you show the input data format?
[12:20:33] ule: all_messages.map(&:user).group_by { |u| [u.language, u.platform] }
[12:20:53] dminuoso: ule: I meant the data, not the code
[12:22:12] ule: data is like that.. the only difference is that instead of 'user_1' is actually a Rails User object
[12:22:25] guille-moe: has joined #ruby
[12:23:43] dminuoso: ule: can you show me the attribute shape?
[12:24:03] dminuoso: The reason Im trying to go back a bit further, is because I believe the way you are approaching this is twisted.
[12:24:20] RevanOne: Thank you guys, without "=" it worked
[12:25:09] Defenestrate: has joined #ruby
[12:25:58] apparition: has joined #ruby
[12:28:06] dminuoso: ule: Would I be correct in assuming its something along the lines of messages = [ { type: 'message', user: { language: 'fr', platform: 'ios', id: 1 } }, { type: 'sub_message': user: { language: 'en, platform: 'android', id: 2 }} ]
[12:29:30] ule: yeah, the only difference is that my type is: nil or ID
[12:29:50] ule: if I have a id, that means I have a parent, so its a sub_message
[12:30:19] ule: if the type is nil, that means its a parent message or first message in the thread
[12:31:42] Guest70176: has joined #ruby
[12:34:10] cadillac_: has joined #ruby
[12:35:16] VladGh: has joined #ruby
[12:36:19] truenito: has joined #ruby
[12:36:31] Exagone313: has joined #ruby
[12:38:45] ule: tried using a group_by with 3 elements inside an array
[12:38:56] ule: let me grab some coffee then I'll test with some real data
[12:39:05] ule: thanks though
[12:43:40] sepp2k: has joined #ruby
[12:44:58] larcara: has joined #ruby
[12:45:57] leitz: Logic failure somewhere. On a travis-ci run this failed on character['cash'] <= max_cash https://github.com/LeamHall/CT_Character_Generator/blob/master/test/tc_navy.rb#L31-L37
[12:46:31] zanoni: has joined #ruby
[12:47:24] leitz: It is testing this, which seems odd that cash could be > max_cash. What am I missing? https://github.com/LeamHall/CT_Character_Generator/blob/master/lib/tools/career.rb#L11-L20
[12:47:51] leitz: The next task is to refactor that muster_out method.
[12:48:27] leitz: Re-running the tests gives a pass, so there's some chance the math goes wrong.
[12:50:37] SirOliver: has joined #ruby
[12:56:40] deepredsky: has joined #ruby
[13:00:06] cdg: has joined #ruby
[13:02:57] cschneid_: has joined #ruby
[13:06:56] naquad: has joined #ruby
[13:08:55] tlaxkit: has joined #ruby
[13:09:09] pavelz: has joined #ruby
[13:09:40] pavelz: hi, just wondering if there is a RESTy file storage service in ruby a simple one ?
[13:10:51] pavelz: preferably with filesystem and least amount cruft needed to get going. need to customize and emu some corporate service for devs.
[13:16:29] Ambassador: has joined #ruby
[13:19:17] drowze: has joined #ruby
[13:19:48] Psybur: has joined #ruby
[13:19:51] electrostat: has joined #ruby
[13:21:45] leitz: Ah...may have it.
[13:29:50] kitsunenokenja: has joined #ruby
[13:33:38] cdg: has joined #ruby
[13:34:50] vtx: has joined #ruby
[13:35:22] SirOliver: has joined #ruby
[13:36:31] pavelz: prolly sinatra it till it works
[13:37:11] c-c: pavelz: maybe you can make fog use filesystem
[13:39:55] pavelz: nah looks too complicated )
[13:43:25] cdg: has joined #ruby
[13:45:05] jottr: has joined #ruby
[13:46:54] Bish: pavelz: how do you combine rest with files?
[13:47:15] Bish: i mean... rest usually means you're modifying the entries
[13:47:21] Bish: with update/patch whatever
[13:47:36] Bish: with files.. i would just imagning create, replace, delete
[13:48:03] Bish: pavelz: i had sucess using a combination of roda/shrine/sequel
[13:48:17] Bish: where i append files to database entries, really easily
[13:48:30] pavelz: post to a service a file get json back
[13:48:36] Bish: simple as model.file = post[:uploaded_file]
[13:48:44] Bish: and whats the content of said json?
[13:50:58] pavelz: application specific uuid and filename and such things
[13:51:16] Bish: yeah not really restful what u describe
[13:51:25] Bish: it would be.. if what you sends is exactly what u get back
[13:51:35] Bish: but what you describe is upload a file, and get a minimal json back
[13:52:10] Bish: but as i said, sequel/shrine make it really easy and you generalize it with roda
[13:52:18] c-c: its not rest or its not restful :D
[13:53:07] Bish: code snippet out of my current project:
[13:53:23] Bish: r.post { model.file = r.POST['file'] }
[13:53:35] quobo: has joined #ruby
[13:53:46] Bish: and this gets uploaded to s3 and simulates "syscalls" like read, seek, etc
[13:54:09] guille-moe: has joined #ruby
[13:56:19] Bish: CRUD would describe it better, wouldn't it?
[14:00:29] tuelz: has joined #ruby
[14:03:46] mikecmpbll: has joined #ruby
[14:09:09] rouge: has joined #ruby
[14:11:24] zautomata: has joined #ruby
[14:12:04] zautomata: has joined #ruby
[14:12:59] leitz: Bish, CRUD would describe a lot of my code.
[14:13:10] leitz: Oh, you mean "Create..." :D
[14:13:32] Bish: i am no native speaker, i don't get it in case crud means something awful
[14:14:17] leitz: Crud is "junky, trashy" "He has a lot of crud in his background." or "His code is full of crud."
[14:14:52] leitz: I have lived in a few countries and understand how odd the English language can be.
[14:15:00] leitz: Not to mention the English themselves...
[14:15:17] leitz: ACTION hopes the blokes are all busy at work and ignoring IRC.
[14:15:36] Bish: i've been to scotland, nice people
[14:15:38] zautomata: has joined #ruby
[14:15:45] veeti: has joined #ruby
[14:15:51] Bish: but didn't understand a word, i'm bad with accents
[14:16:12] leitz: No one understands Scots, they just drink more.
[14:16:35] Bish: very stereotypical being you are
[14:16:47] Bish: literally everyhwere i went to buy something
[14:16:53] Bish: multiple people stopped whatever they were doing
[14:17:05] Bish: to help me to decide to buy the best thing
[14:17:24] Bish: not kidding: i was buying cigarettes and they didn't have my brand
[14:17:37] Bish: 3 people got out of line, to explain each tabbaco flavor to me
[14:17:48] Bish: that happened everytime i couldn't decide what to order/buy
[14:17:49] leitz: Americans like me and people from the UK make friendly fun of each other.
[14:18:10] leitz: I can believe that; I lived in England for a while. People there were the same.
[14:18:17] leitz: Italy too.
[14:18:37] leitz: Err...and Germany, though I wasn't there as long. Just visiting.
[14:18:37] webguynow: has joined #ruby
[14:19:08] leitz: They were still shooting at us Gringos in Panama so I didn't get out much.
[14:19:12] Bish: lol, i've had a business meeting some weeks ago, and in the region where i live people aren't very friendly
[14:19:40] leitz: Sorry to hear. What region are you in?
[14:19:50] Psybur: has joined #ruby
[14:19:57] Bish: northrhine westfalia i think thats how it's written in english
[14:20:08] Bish: OWL more precicely
[14:20:36] Bish: highest compliment you can get here is no critism
[14:20:43] Bish: that's how people outside of the region describe us
[14:20:46] leitz: North-Rhine Westphalia
[14:22:54] leitz: If you want real abuse, ask for help with Ruby 1.8.7. It will make OWL seem very nice. :P
[14:23:38] Bish: that's before my ruby times
[14:25:13] leitz: 1.8.7 is comes on Red Hat 6.
[14:25:25] leitz: Like my CentOS desktop.
[14:25:44] Bish: well, don't use it?
[14:25:50] Bish: or am i being naive?
[14:25:59] adaedra: Good thing you can install more recent rubies :D
[14:27:38] leitz: Bish, if I wanted to use Ruby at work I would have to use 1.8.7. Since that is a lot of work, I just use Ruby for myself at home.
[14:28:17] Bish: are there big incompabalities? i thought ruby rarely does that
[14:29:15] leitz: Interesitng rake test bug. Methods return their last "thing". If you don't use a variable set in the method but use it upon return, rake thinks the variable is unused.
[14:30:02] leitz: Bish, most of my old code works under 2.5. As I refactor I expect advice given here will break backwards compatibility. Ruby introduces stuff with new versions.
[14:31:55] Bish: 2.5 is out?
[14:31:58] Bish: man, im slow
[14:32:37] leitz: In preview.
[14:32:50] leitz: 2.5.0-preview1
[14:33:14] leitz: By the time I get good with Ruby 2.5 will be the 1.8.7. :)
[14:35:35] roshanavand: has joined #ruby
[14:37:24] oleo: has joined #ruby
[14:39:13] cdg: has joined #ruby
[14:48:18] dviola: has joined #ruby
[14:52:56] urk187: has joined #ruby
[14:52:57] darix: leitz: use the snapshot tarballs tbh.
[14:53:01] darix: that preview1 is really old
[14:53:10] darix: leitz: for opensuse I could even get you 2.5 packages.
[14:53:32] darix: leitz: but be warned 1-2 extensions are broken with 2.5 right now. (mostly profiling and debug tools though)
[14:54:20] leitz: darix, the git repo for 2.5 needs an extra step, I found that out the fun way.
[14:54:40] darix: leitz: yeah that's why i sticked to the snapshot tarballs :P
[14:54:59] leitz: Now I can't recall if I'm running from git repo or tar files from ruby-lang. Dang.
[14:57:46] knight33: has joined #ruby
[14:59:33] x77686d: has joined #ruby
[15:03:59] leitz: Time for a break. Back in a while, lots of refactoring left.
[15:04:24] DLSteve: has joined #ruby
[15:05:27] deepredsky: has joined #ruby
[15:10:00] zautomata: has joined #ruby
[15:10:31] nofxx1: has joined #ruby
[15:16:31] zautomata1: has joined #ruby
[15:16:55] plexigras: has joined #ruby
[15:19:50] Psybur: has joined #ruby
[15:21:44] larcara: has joined #ruby
[15:25:47] marr: has joined #ruby
[15:33:22] SirOliver: has joined #ruby
[15:34:40] ananthakumaran: has joined #ruby
[15:35:54] milardovich: has joined #ruby
[15:36:12] ananthakumaran: has left #ruby: ()
[15:38:29] Revan007: has joined #ruby
[15:43:34] milardovich: has joined #ruby
[15:43:48] veeti: has joined #ruby
[15:44:51] tuelz: has joined #ruby
[15:45:51] leitz: Okay, my brain is melting. Starting to go in loops and need some help. Here's the error: https://gist.github.com/LeamHall/2e870bfaa62d7637e12b23f05986906c
[15:46:03] leitz: Here's the code in question: https://github.com/LeamHall/CT_Character_Generator/blob/career_call_character/bin/chargen#L70-L76
[15:47:19] leitz: The options["careers"] array is a list of files from a particular directory. Each one has a class that is a subclass of Career. The intent is that the character goes through a career.
[15:47:50] leitz: the code intent is that the career can be called from the command line without having to manually opdate the possible list of careers by hand.
[15:48:29] leitz: In this case class Noble is in "noble.rb".
[15:49:18] leitz: I am trying to figure out how to call the class's method on the character instance.
[15:51:55] zautomata1: has joined #ruby
[15:52:42] Guest70176: has joined #ruby
[15:54:00] Technodrome: has joined #ruby
[15:54:45] Revan007: has joined #ruby
[15:56:18] dminuoso: character.method _
[15:57:49] leitz: dminuoso, I don't understand the question.
[15:58:08] dminuoso: leitz: I dont understand yours.
[15:58:27] larcara: has joined #ruby
[15:58:36] guille-moe: has joined #ruby
[15:58:41] howdoi: has joined #ruby
[15:59:03] leitz: Understood, this is one of the places I get confused. It is making a string from a file name into a class call.
[16:06:38] milardov_: has joined #ruby
[16:07:10] rippa: has joined #ruby
[16:12:25] drowze: has joined #ruby
[16:16:50] drewmcmillan: has joined #ruby
[16:23:31] ledestin: has joined #ruby
[16:29:41] deepredsky: has joined #ruby
[16:34:43] zautomata1: has joined #ruby
[16:37:00] tvw: has joined #ruby
[16:39:41] bmurt: has joined #ruby
[16:41:54] john__: has joined #ruby
[16:42:33] tvw: has joined #ruby
[16:46:07] leitz: Do class method calls to sub-classes go to the parent class if the child does not have that method? Or do you have to specify "super".
[16:47:04] adaedra: If you do not override the method, the parent's one is called, yes.
[16:47:29] dminuoso: leitz: Keep in mind that, that modules of a class are also considered ancestors.
[16:47:43] FahmeF: has joined #ruby
[16:47:50] dminuoso: The order is: `Prepended modules, the class itself, included modules`, repeat with parent.
[16:47:59] x77686d: has joined #ruby
[16:49:36] leitz: I'm just past the edge of my understanding. Not sure I can explain it well and was hoping the code was enough.
[16:49:50] nofxx1: has joined #ruby
[16:50:25] leitz: Let me post the code and then what I think is happening.
[16:53:33] milardovich: has joined #ruby
[16:53:40] leitz: I'm calling bin/chargen.rb: ruby -Ilib bin/chargen.rb -c noble
[16:55:44] leitz: Which should set "options["careers"] to a single element array for "noble".
[16:56:16] Cohedrin: has joined #ruby
[16:56:35] leitz: In the puts section this is confirmed by the output. https://github.com/LeamHall/CT_Character_Generator/blob/career_call_character/bin/chargen#L72-L74
[16:57:34] havenwood: leitz: typically you'd add a shebang to the first line fo that file: #!/usr/bin/env ruby
[16:59:44] leitz: But I'm getting a "update_character" "NoMethodError" on this line: https://github.com/LeamHall/CT_Character_Generator/blob/career_call_character/bin/chargen#L79
[17:00:29] leitz: havenwood, I had one but was using more than one ruby. Also, calling it with the -Ilib lets it find the libraries.
[17:00:48] havenwood: leitz: then use a .rb extension
[17:01:25] deadpoet_: has joined #ruby
[17:01:42] leitz: So, what I am trying to do is have Class Noble, a subclass of Class Career, use Career#update_character. It seems to not want to.
[17:02:28] havenwood: leitz: #update_character looks like an instance method, so you'd need to call it on an instance of `#<Career:...>` not on `Career` itself.
[17:03:06] havenwood: Career.update_character #!> NoMethodError...
[17:03:25] leitz: Hmm...I'm trying to learn Class methods, I think. There's no real instance of Career, it just modifies character.
[17:04:27] cschneid_: has joined #ruby
[17:05:02] havenwood: leitz: Then change Career from a Class to a Module and add `module_function` at the top of the module.
[17:05:03] blackmesa: has joined #ruby
[17:05:27] havenwood: leitz: Then you can call: Career.update_character(character, career, terms)
[17:05:55] havenwood: leitz: Or `include Career` in another class, and call: update_character(character, career, terms)
[17:06:48] leitz: Can you have parent and child modules?
[17:07:07] leitz: Where the child extends or modifies parent methods?
[17:07:18] havenwood: leitz: A module can mixin another module. They don't have offspring.
[17:08:00] deepredsky: has joined #ruby
[17:11:07] Guest70176: has joined #ruby
[17:20:10] mim1k_: has joined #ruby
[17:20:30] leitz: Hmmm...Career is now a module, with module_function as the first line under "module Career". "Noble" is a class that has "include Career".
[17:20:55] milardovich: has joined #ruby
[17:23:11] leitz: Still getting a NoMethodError for class Noble.
[17:25:03] leitz: Latest code pushed up.
[17:25:18] mson: has joined #ruby
[17:25:46] cdg: has joined #ruby
[17:30:08] raynold: has joined #ruby
[17:30:28] rmhonji: has joined #ruby
[17:31:39] gregf_: has joined #ruby
[17:33:26] havenwood: leitz: if you use module_function and include Career, the #update_character function will be private - so it can't be called externally on Noble, just from within Noble
[17:33:42] havenwood: leitz: you can get rid of `module_function` if you want to use it the way you've shown
[17:34:18] havenwood: &ri Module#module_function
[17:34:18] `derpy: http://ruby-doc.org/core-2.4.1/Module.html#method-i-module_function
[17:35:16] leitz: The goal is to be able to call <career_name>.update_character. Which was why I had it as a class, for inheritance.
[17:36:05] char_var[buffer]: has joined #ruby
[17:36:32] danielpclark: has joined #ruby
[17:40:16] rouge: has joined #ruby
[17:40:57] deadpoet: has joined #ruby
[17:41:10] leitz: Hmm...Calling similar to that ruby-doc bit says I can't call it because it's a private method. Putting "public" before update_character fails with "undefiend method []"
[17:44:46] apeiros: uh, where did you put the public?
[17:44:47] leitz: Different errors is progress. :)
[17:44:50] nopolitica: has joined #ruby
[17:45:17] apeiros: if you keep your gist up to date, it'd be easier
[17:46:11] leitz: apeiros, before the def update_character. And given the async nature of IRC I'm plugging along on different paths to see if I can figure it out.
[17:47:05] bmurt: has joined #ruby
[17:47:30] apeiros: leitz: if you want it public, you almost certainly don't want it to be a module_function
[17:47:46] apeiros: and in that case, you can just save yourself those two calls (module_function and public)
[17:48:24] eightlimbed: has joined #ruby
[17:48:50] leitz: apeiros, I want it to work. And be decent code. Doesn't fit either of those yet. I was trying havenwood's suggestion and then my own ideas when things still didn't work.
[17:49:07] rouge: has joined #ruby
[17:49:14] apeiros: a public module_function usually isn't decent
[17:49:51] milardovich: has joined #ruby
[17:51:19] claudiuinberlin: has joined #ruby
[17:52:42] leitz: Working code with a public module_function is more decent than non-working code. :)
[17:53:35] apeiros: I'm not quite sure what part you don't understand
[17:53:37] leitz: In this case I have a path to follow, I think. When Noble and Career were both classes the instance variables for skills cuold be used in both. As a module within a class it seems not to work the same.
[17:53:58] apeiros: you can have more decent, AND working, AND less code, all for the price of ONE: removing both public and module_function
[17:54:23] Ambassador: has joined #ruby
[17:54:38] apeiros: (the "working" part of course depends on "private" being the only reason it didn't work)
[17:54:54] QualityAddict: has joined #ruby
[17:54:58] leitz: private wasn't the only reason. :)
[17:55:11] apeiros: then putting "public" in front of it won't fix it anyway.
[17:55:34] Guest70176: has joined #ruby
[17:56:44] leitz: Updated gist: https://gist.github.com/LeamHall/2e870bfaa62d7637e12b23f05986906c
[17:58:01] leitz: The current issue is here: https://github.com/LeamHall/CT_Character_Generator/blob/career_call_character/lib/tools/career.rb#L50-L57
[17:58:26] apeiros: the exception says it's line 76
[17:58:34] leitz: Since Career became a module, and not a parent class, the @character stuff fails.
[17:58:34] apeiros: which implies skill_options is nil
[17:58:56] leitz: That's the NilClass in the gist.
[17:59:07] apeiros: skill_options = … assigns a local variable
[17:59:15] apeiros: you don't do anything with it except printing it
[17:59:32] apeiros: it'll be gone right after build_skill_options. I suspect that's not what you intend it to do.
[18:00:06] apeiros: oh, you want to use the *return value* of build_skill_options. well, that'll be nil, since puts is your last statement. and puts returns nil.
[18:00:09] leitz: Well, down in like 66 it's supposed to be set from calling build_skill_options.
[18:00:17] char_var[buffer]: has joined #ruby
[18:00:27] leitz: Right, but it was failing before the puts.
[18:00:42] apeiros: pretty sure not with the same exception.
[18:01:00] leitz: Hate to dissappoint you, but yup.
[18:01:00] apeiros: or then again, maybe it did
[18:01:07] apeiros: since your puts says "NilClass" :D
[18:01:19] apeiros: so your stuff goes wrong before that already.
[18:01:21] leitz: The @skill_optiions seems the issue.
[18:01:36] leitz: They worked when Career was a class.
[18:01:54] larcara: has joined #ruby
[18:02:03] leitz: Now it is a module included by Noble. Don't seem to work as they are not being set.
[18:02:27] RickHull: leitz: the aesthetics look much better now, at least. follows ruby conventions :)
[18:02:39] apeiros: well, I don't see class Noble. so no idea. but yeah, the object you call update_character on must have @skill_options set.
[18:02:55] leitz: RickHull, you should look at muster_out. Much shorter. :)
[18:03:14] apeiros: iow, you probably want to initialize @skill_options in the Noble class
[18:03:18] RickHull: are you working on the career_call_character branch now?
[18:03:25] apeiros: also, you should not access foreign instance variables. use methods for that.
[18:03:37] leitz: apeiros: https://github.com/LeamHall/CT_Character_Generator/blob/career_call_character/lib/careers/noble.rb
[18:03:45] leitz: RickHull, yes.
[18:03:59] apeiros: leitz: line 12 sets an instance variable for the *class object*
[18:04:11] apeiros: those are not shared/passed on to instances of that class
[18:04:20] apeiros: you need an initialize method
[18:04:48] RickHull: yes, it is odd to have class without `def initialize`
[18:04:58] RickHull: I suspect we can make the overall structure of this project much simpler
[18:05:06] leitz: apeiros, even if there's no instance of Career? In effect, it is supposed to modify a Character instance, not exist on its own.
[18:05:07] RickHull: perhaps 3-5 classes
[18:05:28] apeiros: leitz: if you create an instance of Noble, there's an instance of Career.
[18:05:51] apeiros: >> module Foo; end; class Bar; include Foo; end; Bar.new.instance_of?(Foo)
[18:05:53] ruby[bot]: apeiros: # => false (https://eval.in/906474)
[18:05:58] RickHull: what is the problem domain? you have a character, and it can roll for attributes, get assigned a character class, which does additional character attribute stuff
[18:06:04] apeiros: >> module Foo; end; class Bar; include Foo; end; Bar.new.is_a?(Foo)
[18:06:05] ruby[bot]: apeiros: # => true (https://eval.in/906475)
[18:06:17] leitz: RickHull, the original idea is a Character class, a SuperClass Career for most career stuff, and then a bunch of Career Child classes for various types of career.
[18:06:32] RickHull: what are the main parts of a career?
[18:06:35] apeiros: (instance_of? checks whether it is an instance of the given class, is_a?/kind_of? test ancestry)
[18:06:55] RickHull: let's pick a good career example Knight?
[18:07:12] leitz: So chargen.rb creates a character with stats, descriptions, and empty skills and stuff. Careers add to skills and stuff and can modify stats.
[18:07:21] leitz: Career Noble.
[18:07:37] RickHull: ok, so Character Jim has class Bard and career Noble?
[18:07:43] RickHull: something like that?
[18:07:46] leitz: You guys should play Traveller some time. :)
[18:07:56] apeiros: if I had spare time…
[18:08:16] leitz: Character Jim has a career of Noble.
[18:08:27] apeiros: I assume traveller is some D&D style game?
[18:08:36] leitz: Character Jane has a career of Citizen.
[18:08:38] kickr: has joined #ruby
[18:08:59] RickHull: the design that pops into my head is to use composition. literally character has-a career
[18:09:10] deepredsky: has joined #ruby
[18:09:11] leitz: apeiros, yes, but SciFi. One of the original Role-playing games and it lends itself very well to coding. Assuming I could code...
[18:09:33] RickHull: @career = Noble # perhaps -- a module reference
[18:09:45] apeiros: jim = Character.new(career: :citizen); jim.career # => Careers::Citizen
[18:09:50] RickHull: and each career has some methods -- a common interface
[18:09:57] apeiros: well, #<Careers::Citizen …> really
[18:09:57] dionysus69: has joined #ruby
[18:10:23] RickHull: and when you call jim.foo -- the result is based on jim's attributes modified by the career
[18:10:24] leitz: RickHull, sounds good. I know very little about design and patterns. Keep typing, I'm taking notes.
[18:10:52] RickHull: foo would do stuff based on jim's ivars, and also modify them based on calling module methods
[18:11:01] RickHull: do it all on-the-fly, worry about optimizing performance later
[18:11:04] leitz: Hang on a sec, I'll add to the gist to show the output when things work.
[18:11:07] RickHull: if you want to cache the results of career modifications
[18:11:29] apeiros: leitz: though it seems to me like careers are more like providing initial values for characters + how they'll level up?
[18:12:23] apeiros: btw., are you still restricted to ruby 1.8? (your project's README says so)
[18:12:39] RickHull: one headache with the current approach, ISTM at a glance, is that you are trying to commit all the behavior to concrete values -- whereas I would try to express the behavior as return values -- calculated on the fly
[18:12:42] leitz: Class Character provides the initial values, Career levels them up.
[18:13:25] RickHull: so Jim-the-Noble, what are some good examples of inherent attributes that the career then modifies?
[18:13:25] leitz: The comment has the normal output. https://gist.github.com/LeamHall/2e870bfaa62d7637e12b23f05986906c
[18:13:42] leitz: Skills, Stats, Cash, Stuff.
[18:14:21] RickHull: i would commit jim's baseline skill attribute to an ivar -- rolled at the beginning I expect -- and then have a skill() method that is modified by his career
[18:14:29] RickHull: and do it with expressions, not assignment
[18:14:39] leitz: apeiros, I'm now using 2.5.0. The readme is old.
[18:15:00] RickHull: def skill; @career.modify(@skill); end
[18:15:16] apeiros: I'm trying to do an outline, though it'll probably deviate a lot from what you intend to do since your tool seems to do a lot. but it might give you ideas :)
[18:15:26] apeiros: you store Character instances in the databse, did I get that right?
[18:15:40] leitz: RickHull, the data will go into various output formats, like SQL, Monggo, json.
[18:15:59] leitz: apeiros, when I get it to work, yes.
[18:16:28] RickHull: def sqldump; [self.skill, self.stats, self.cash, self.stuff].map { ... }; end
[18:17:11] RickHull: now, i may be barking up the wrong tree -- i'm certainly oversimplifying
[18:18:25] RickHull: what's a basic example of how a career modifies e.g. a cash attribute?
[18:19:01] leitz: An issue is that Class character has two uses: a framework for pulling in existing data and a "generate" method to write someone new up.
[18:20:29] RickHull: I would express this -- probably -- as making most of the class definition having to do with an existing character
[18:20:31] leitz: RickHull, each career is run in 1 or more 4 year terms. For (terms/2) +1 times a character gets a cash allocation and a "thing" benefit. That was the complexity of muster_out. Things could be skills, stuff.
[18:20:36] eightlimbed: has joined #ruby
[18:20:45] RickHull: and then a class method on character named generate -- Character.generate(*args)
[18:21:12] RickHull: so Character.new can be initialized with existing attributes -- to bring a fully formed Jim into the world as he was committed to the db last week
[18:21:21] RickHull: and Character.generate to roll a new Jane
[18:24:03] RickHull: Character.generate would do a bunch of dice rolls and come with the args to then call Character.new
[18:24:10] leitz: RickHull, one question on that. Character.new and Character.generate fit well with what I've done. The bit that I'm working on now is running a character through a career.
[18:24:59] RickHull: has to do with leveling up -- and?
[18:25:12] larcara: has joined #ruby
[18:25:35] leitz: I had a Character.run_career method but thought it might be better as something like "Noble(Character)"
[18:26:22] apeiros: leitz: only an outline (hence lots of "…") https://gist.github.com/apeiros/a0e3c6725cbb9a10db0a9ee8f87df894
[18:26:47] leitz: This was before the latest mangling. https://github.com/LeamHall/CT_Character_Generator/blob/master/lib/tools/character.rb#L46-L48
[18:26:53] leitz: ACTION goes to read.
[18:27:36] apeiros: though given the complexity, I'd probably create a full Character::Generator class and wrap that in Character.generate
[18:27:54] RickHull: sure -- though I would just leave that as an escape valve
[18:28:10] RickHull: my usual approach is to stuff everything into a giant bag, make it basically work
[18:28:16] RickHull: and then refactor to something nicer
[18:28:25] RickHull: rather than imagine a big hierarchy up front
[18:29:49] ramfjord: has joined #ruby
[18:29:51] apeiros: I usually do put a few minutes into considering an architecture. but a couple of stuff usually changes while writing.
[18:30:03] leitz: One design goal is to let other people add Careers easily. Really the career is mostly skill and benefits lists, with an occasional method override.
[18:30:08] guille-moe: has joined #ruby
[18:30:25] RickHull: leitz: i would keep that as a milestone
[18:30:41] RickHull: keep it in mind. but maybe limit the scope initially
[18:30:41] milardovich: has joined #ruby
[18:31:01] leitz: As is someone can drop a new career into lib/careers and call it with -c <new_career> and it just works. This is Ruby, you know. ;)
[18:31:06] RickHull: for example, maybe later you can transform careers into yaml definitions later
[18:31:12] leitz: Already works.
[18:31:23] guacamole: has joined #ruby
[18:31:24] leitz: In the master branch, anyway. :)
[18:31:47] RickHull: one problem is if you make the icing work before the cake is fleshed out, the icing limits your ability to make the cake work
[18:31:58] RickHull: so I like to make the cake rock-solid, and then ice it
[18:32:11] RickHull: (so to speak)
[18:33:50] RickHull: with a tight solid cake, with good tests, you can either ice it freely, or you can reconfigure it (thanks to the tests) to make it icing friendly
[18:34:26] leitz: Let's back up for a second. Is this a bad way to modifiy an instance? https://github.com/LeamHall/CT_Character_Generator/blob/master/bin/chargen#L74
[18:35:50] gizmore: leitz: rename the method to "apply/change"Foo?
[18:36:19] gizmore: modify / adjust... :P
[18:36:21] leitz: The *theory* is that there's a better way, but that's just my assumption. The original operation is fairly modular and extensible. And testable. At this point I'm wondering if I'm trying to solve a non-problem.
[18:36:46] apeiros: leitz: generally in OO, you want to only mutate the receiver of a method
[18:36:49] gizmore: leitz: why should changing an instance being a bad habit?
[18:37:04] gizmore: thx apeiros
[18:37:10] leitz: gizmore, the way I'm changing it.
[18:37:40] leitz: So, if you run a character instance through a career, the character is modified. Skills, etc.
[18:38:01] apeiros: yeah, sounds fine
[18:38:02] leitz: apeiros, in that line is character the reciever?
[18:38:05] RickHull: leitz: forget the code for a sec -- what's a concrete example of how a career affects a character?
[18:38:09] gizmore: yeah--- i have the same. the skill type change the char
[18:38:12] apeiros: leitz: yes. the thing to the left of the dot.
[18:38:21] apeiros: receiver.method(argument) { block }
[18:38:56] tomphp: has joined #ruby
[18:38:57] RickHull: leitz: is there a time component? does the career or char know that 10 years has passed?
[18:39:01] apeiros: and if you just do `method(argument) { block }` (where arguments and block are optional of course), then `self` is the receiver.
[18:39:14] RickHull: or is it more "tick" based -- character.yearly_update
[18:39:20] RickHull: character.level_up
[18:40:21] David_H_Smith: has joined #ruby
[18:40:24] leitz: RickHull, in the updated comment the bold stuff is modified by a career. https://gist.github.com/LeamHall/2e870bfaa62d7637e12b23f05986906c
[18:40:32] apeiros: so it's officially a terrible idea to eat raclette cheese and not wash your hands before using keyboard & mouse again 😅
[18:40:42] milardovich: has joined #ruby
[18:40:46] leitz: The UPP (67B84B) usially is.
[18:40:47] guacamole: has joined #ruby
[18:41:01] conta1: has joined #ruby
[18:41:01] apeiros: what's UPP? some kind of descriptive string for your char?
[18:41:08] leitz: apeiros, or eat pecan pie with the same hand on the trackball...
[18:41:09] RickHull: universal personality profile
[18:41:15] RickHull: the initial char roll
[18:41:33] apeiros: that roll defines some baselines of the stats?
[18:41:35] leitz: ^ Initial, as possibly modified by career.
[18:41:53] leitz: That roll is the stats. In Hex format.
[18:41:56] RickHull: leitz: there are 3 components to that string, right?
[18:42:09] RickHull: you are right that a string is not the best choice to store this data
[18:42:15] kapil___: has joined #ruby
[18:42:16] RickHull: i would do an array of ints
[18:42:20] leitz: RIckHull, 6 components
[18:42:22] RickHull: or possibly a hash, like you mentioned last night
[18:42:37] leitz: And I'm thinking hash since each Stat would serve as a unique key.
[18:42:38] RickHull: oh, i thought it was 0x67 0xb8 0x4b
[18:42:54] RickHull: yes, if there are names for each stat, use a hash
[18:43:11] RickHull: or possibly struct/openstruct -- but i would start with a hash
[18:43:42] RickHull: or possibly ivars. @stat_this = 0x67 @stat_that = 0x4b
[18:43:45] leitz: Average is 7, so Strenght 6, Dexterity 7, Endurance 11, Intelligence 8, Education 4, Social Status 11.
[18:44:06] leitz: Or Str Dex End Int Edu Soc for keys.
[18:44:18] RickHull: i would use ivars probably, and maybe have a stats_hsh() method if you pass them around as a group
[18:44:43] leitz: Since I'm guessing on how to spell intelligence.
[18:44:47] RickHull: >> { strength: 0x45, dexterity: 0x4b, }
[18:44:48] ruby[bot]: RickHull: # => {:strength=>69, :dexterity=>75} (https://eval.in/906519)
[18:44:56] apeiros: ok, so a char doesn't have a career, you apply one to it, and that modifies their stats + skills + advanced skills?
[18:44:57] leitz: RIckHull, ivar is instance varialbe? Or something else?
[18:45:04] apeiros: and skills are replaced, not added if I got that right
[18:45:18] nopolitica: has joined #ruby
[18:45:20] RickHull: yes, as in `attr_reader :strength`
[18:45:23] ldepandis: has joined #ruby
[18:45:37] leitz: apeiros, a character has served in a career, like we do. But a career is not a thing.
[18:45:47] RickHull: or def initialize(str, dex, end); @strength = str ...
[18:45:59] leitz: Skills are added. If a person has a high Edu then they can learn Advanced Skills.
[18:46:28] leitz: That's the skill_options array.
[18:46:46] leitz: And it is an array, not a set, as some skills are more likely than others, based on career.
[18:46:59] leitz: Army people shoot more. :)
[18:47:00] apeiros: but the added skill is random, or can be random
[18:47:07] leitz: Is random.
[18:47:19] RickHull: i would add a hash key for every added skill
[18:47:30] leitz: Educated people can get skills from either list.
[18:47:36] apeiros: uh, I'd not do that by repeating, I'd do that by using a hash with skill as key and relative probability as value
[18:47:48] leitz: RickHull, already done. :)
[18:47:49] x77686d: has joined #ruby
[18:48:05] leitz: apeiros, number of skills is based loosely on terms served.
[18:48:06] apeiros: e.g. {Skill1: 1, Skill2: 2, Skill3: 1}, where Skill2 is twice as likely to happen compared to Skill1 and Skill3
[18:49:16] leitz: apeiros, at the moment I just "yy p" the skill in vim if i need it more often. I'm not a math wiz.
[18:50:05] tlaxkit: has joined #ruby
[18:50:35] leitz: So, at this point I think the branch is a learning exercise but not the way to go. The original works properly where the reciever of the method is modified.
[18:51:03] leitz: And I can bask in the glory of a heavily reduced "muster_out" method.
[18:51:47] danielpclark: has joined #ruby
[18:53:23] lupine: has joined #ruby
[18:54:33] leitz: apeiros, this is the other way I get random stuff in easily. Just pull from a "single phrase per line" text file. Though your "sample" comment is going to get used heavily. https://github.com/LeamHall/CT_Character_Generator/blob/master/lib/tools/character_tools.rb#L46-L57
[18:55:01] blackmesa: has joined #ruby
[18:55:22] apeiros: "Straight medium brown short" # hah
[18:55:49] apeiros: hm, I should cleanup my backup-inception. I have a weighted sample lying around somewhere
[18:56:07] rouge: has joined #ruby
[18:56:20] apeiros: though I guess I can just rewrite it…
[18:56:35] mikecmpbll: has joined #ruby
[18:58:36] vtx: has joined #ruby
[18:58:50] leitz: If you don't mind looking at Python/Bottle, this is where I'm going with some of this. There will be a web page where people can view characters. I'm using the database to track characters in my stories, I keep forgetting things like hair color, etc. https://github.com/makhidkarun/py_npc_web_db/blob/master/bottle_dragon.py
[18:59:12] pecan: Don't eat me please leitz :o
[18:59:59] Guest70176: has joined #ruby
[19:01:03] Dimik: has joined #ruby
[19:01:23] muelleme: has joined #ruby
[19:02:19] leitz: You guys really should try Traveller. Pretty easy and lots of things to code about.
[19:02:43] Exhiled: has joined #ruby
[19:02:51] wmoxam: leitz: what's that?
[19:03:16] leitz: wmoxam, one of the earliest pen and paper role playing games.
[19:03:28] larcara: has joined #ruby
[19:03:34] leitz: And the source of most of my coding efforts.
[19:10:26] leitz: Well, if i could document C code well there are 5,320 opportunities to excel. :)
[19:11:34] RickHull: leitz: I forked your repo, stubbed out what seems to me like a more sensible base: https://github.com/rickhull/CT_Character_Generator/blob/rickfactor/lib/traveller_char/character.rb
[19:12:12] chmurifree: has joined #ruby
[19:12:50] leitz: RickHull, thanks! Let me go study that.
[19:13:24] conta: has joined #ruby
[19:13:26] RickHull: obviously fill in the legit generator procedures
[19:13:44] RickHull: as apeiros suggested, you definitely want a module for the generator stuff
[19:14:07] RickHull: maybe within Character -- e.g. Character::Generator (exactly as apeiros suggested)
[19:15:29] RickHull: this allows to call Character.generate(basic: { name: 'Jane', gender: 'F' })
[19:15:57] RickHull: er, let me update. should be Character.generate(name: 'Jane', gender: 'F')
[19:16:21] RickHull: and any of the other basic stats will be generated. or provide nothing and name and gender will be generated as well
[19:17:18] RickHull: what this means is that Character.new will require concrete values for everything
[19:17:25] RickHull: i.e. load from yesterday's dump
[19:17:35] leitz: That's what generate already does. What am I missing? https://github.com/LeamHall/CT_Character_Generator/blob/master/lib/tools/character.rb#L14-L27
[19:17:37] RickHull: and only Character.generate will create a new character with generated values
[19:18:03] leitz: The initialize takes the exisitng data provided.
[19:18:14] RickHull: in your version, where is @upp initialized?
[19:18:40] leitz: Line 14 in generate.
[19:18:50] RickHull: oh duh, sorry
[19:19:06] leitz: Currenly as a string, will move to hash after the after big meal nap.
[19:19:20] RickHull: sorry, what I meant was: your version allows to initialize a character without an :upp
[19:19:30] Exhiled: has joined #ruby
[19:19:42] RickHull: and when you call character.generate, it will be generated conditionally
[19:19:54] RickHull: so you are mixing the concepts of a fully realized character vs generating a new one
[19:19:59] RickHull: my version separates them completely
[19:20:07] RickHull: you can only call Character.new with fully realized values
[19:20:21] leitz: Yes. For example, in a story a person comes up just by name. Later, UPP and everything else is needed, so the known data gets put in and the rest generated.
[19:20:44] blackmesa: has joined #ruby
[19:20:47] RickHull: it's cleaner to just generate a fully realized character when a new one comes up
[19:21:00] RickHull: if all you need is a name, then just represent the fake char with their name string
[19:21:12] leitz: Actaully, you can call Character.new with nothing, and then generate en masse or add bit by bit.
[19:21:56] RickHull: I think this mixing of concerns causes complications in the code built on top
[19:22:12] leitz: https://github.com/LeamHall/CT_Character_Generator/blob/master/bin/chargen#L51-L52
[19:22:30] milardovich: has joined #ruby
[19:22:48] vtx: guys in my rspec tests, i have `allow(Mongo::Client).to receive(:new).with(any_args).and_return(mock_database_map)`, however, when i run my tests, MongoDB still attempts to connect to local host, failing repeatedly, and none of my specs are ran
[19:23:30] leitz: That's why I want to keep Careers separate. So a Character can be used by itself.
[19:23:40] RickHull: I would make a different class for NPCs
[19:23:46] vtx: the line in my application that connects to mongo is `mongo = Mongo::Client.new(["#{host}:#{port}"], :database => database)` - how can i stop this from connecting? or rather, how can i tell my tests that the connection was always successful?
[19:23:51] RickHull: perhaps both derive from the same base class
[19:24:22] cschneid_: has joined #ruby
[19:24:23] RickHull: NPC concerns are quite distinct from P concerns
[19:24:34] RickHull: er, PC concerns :)
[19:25:01] larcara: has joined #ruby
[19:25:02] leitz: vtx, are you actually trying to connect?
[19:25:31] RickHull: the app wants to connect -- the test wants the app not to connect
[19:25:32] leitz: RickHull, I have a really bad habit of promoting minor charcters to full blown heroes.
[19:25:54] RickHull: leitz: sure, you can accomodate that -- just create a PC from NPC attributes
[19:26:03] vtx: leitz: i don’t want the database connection to happen during my tests
[19:26:10] leitz: Like, dozens. Easier to treat everyone the same.
[19:26:10] vtx: i want to mock out the responses
[19:26:22] jaruga: has joined #ruby
[19:26:23] RickHull: but trying to have do-all wonder-class that accomodates all concerns -- I'm skeptical
[19:26:37] leitz: vtx, ah. Gotcha. I'm not that good with Rspec.
[19:26:49] vtx: neither am i haha
[19:27:10] leitz: RickHull, that's why I'm going to use a MongoDB backend. I can add fields as needed as characters develop.
[19:27:20] RickHull: leitz: if NPC and PC both inherit from BasicChar -- then you can have stuff that doesn't care about NPC distinction operate on BasicChar
[19:27:38] vtx: i guess it would be a nice to see what connection is actually taking place, i.e. to see if i’m missing something in my mock
[19:28:04] leitz: RickHull, Both PC and NPC grow backstories as I go along. No real differentiation.
[19:28:17] RickHull: and if all NPCs *should* be fully realized -- then don't try to generate stuff on the fly
[19:28:21] RickHull: you will have bugs
[19:28:31] leitz: vtx, I would, at least at first. I code poorly and that would be expensive but test me often.
[19:28:46] RickHull: for example, you pass around hashes and forget to include a field. you will want an error here
[19:28:51] RickHull: but instead it will get silently autogenerated
[19:29:35] leitz: RickHull, that's why Character.generate must be called separately.
[19:29:47] leitz: No autogeneration unless I tell it to.
[19:29:48] vtx: is there a way to have ruby print out all the calls that are happening? so i can see why my mock isnt working? or rather are there any tools that you can pass a line of ruby to, and they tell you how to mock that line?
[19:29:49] Tim_F_Croso: has joined #ruby
[19:29:55] RickHull: well @upp only gets assigned in #generate
[19:30:09] RickHull: it sure looks like you have to call #generate to get an @upp
[19:30:29] leitz: RickHull, unless the call to Character.new includes a data set with the upp.
[19:30:41] RickHull: where does @upp get assigned in that case?
[19:31:10] leitz: It will get pulled from the database as soon as I get that far. DId you look at the python/bottle stuff?
[19:31:19] leitz: Same idea.
[19:31:27] RickHull: hang on, i call Character.new(upp: stuff)
[19:31:34] RickHull: @upp will not exist at that point
[19:31:43] RickHull: it only comes into being with Character.new(upp: stuff).generate
[19:32:02] RickHull: you've written #generate to be the place where the hash becomes ivars
[19:32:08] leitz: Being called to the table. I'll test and answer that in a bit.
[19:32:15] RickHull: yep, i gotta run
[19:38:08] milardovich: has joined #ruby
[19:40:09] larcara: has joined #ruby
[19:43:22] zautomata1: has joined #ruby
[19:44:05] ensyde: has joined #ruby
[19:44:34] alan_w: has joined #ruby
[19:44:47] Guest59285: has joined #ruby
[19:44:49] havenwood: an easter egg if you have the computing power:
[19:44:50] havenwood: require 'prime'; [0.step.lazy.select { |n| (67 ** n - 66 ** n).prime? }.take(3).reduce(1, :*) * 3 * 3 * 3].pack('U')
[19:45:41] nadir: has joined #ruby
[19:46:00] nopolitica: has joined #ruby
[19:51:00] mcr1: has joined #ruby
[19:52:33] leitz: Did someone say bundler doesn't work with 2.5.0Dev?
[19:52:42] RickHull: i was having a problem with it on travis
[19:53:11] RickHull: oh, that was with -preview1
[19:53:13] leitz: I'm getting UnsatisfiableDependencyError for 1.16.0.
[19:53:34] leitz: I just pulled from git, same issue.
[20:01:08] knight33: has joined #ruby
[20:02:36] Guest70176: has joined #ruby
[20:02:46] tacoboy: has joined #ruby
[20:03:16] danielpclark: has joined #ruby
[20:03:20] havenwood: oops, messed up my easter egg >.>, shoulda been:
[20:03:21] havenwood: require 'prime'; [Prime.take(2.step.lazy.select { |n| (67 ** n - 66 ** n).prime? }.take(3).reduce(1, :*)).last * 3 * 3 * 3].pack('U')
[20:04:01] dminuoso: havenwood: Its amazing how bad Ruby is at this.
[20:04:12] dionysus69: has joined #ruby
[20:04:36] havenwood: dminuoso: not fast!
[20:04:48] dminuoso: Speed is just a QoI issue.
[20:05:08] dminuoso: havenwood: You should run this on truffle.
[20:05:19] havenwood: here's a "solution":
[20:05:20] havenwood: https://gist.github.com/havenwood/82275d0f330feb28ee69c2d170faacf1
[20:06:03] s2013: has joined #ruby
[20:06:53] leitz: RickHull, humorously, the earlier version of Character#initilize set the values to certain types. I cleaned it out not too long ago.
[20:07:24] havenwood: dminuoso: it's fast but seemingly not the same result, hrmmm
[20:07:38] havenwood: jt ruby -e "require 'prime' ;puts [Prime.take(2.step.lazy.select { |n| (67 ** n - 66 ** n).prime? }.take(3).reduce(1, :*)).last * 3 * 3 * 3].pack('U') * 3"
[20:09:16] armyriad: has joined #ruby
[20:09:19] havenwood: well, i gotta turkey - curious to look into that later though!
[20:09:25] Exhiled: has joined #ruby
[20:09:45] deepredsky: has joined #ruby
[20:10:52] x77686d: has joined #ruby
[20:11:26] milardovich: has joined #ruby
[20:20:20] moei: has joined #ruby
[20:21:27] johno84: has joined #ruby
[20:24:46] selim: has joined #ruby
[20:25:31] miskatonic: has joined #ruby
[20:27:49] rivalomega: has joined #ruby
[20:28:06] jamesaxl: has joined #ruby
[20:28:16] jenrzzz: has joined #ruby
[20:28:16] jenrzzz: has joined #ruby
[20:31:29] cadillac_: has joined #ruby
[20:37:32] vtx: guys at what point does a configure block run?
[20:39:36] milardovich: has joined #ruby
[20:42:40] knight33: has joined #ruby
[20:45:43] ahrs: has joined #ruby
[20:45:47] danielpclark: has joined #ruby
[20:46:49] nopolitica: has joined #ruby
[20:46:57] lexruee: has joined #ruby
[20:49:44] eightlimbed: has joined #ruby
[20:50:18] vtx: has joined #ruby
[20:50:51] c-c: vtx: which configure block?
[20:51:10] vtx: c-c: so, the configure block in a sinatra application?
[20:51:55] vtx: i.e. if my class extends Sinatra::Application, and that class contains `configure do…end`, at what point does that block actually run?
[20:56:30] ur5us: has joined #ruby
[20:59:02] mcr1: has joined #ruby
[21:03:01] cdg: has joined #ruby
[21:04:07] Guest70176: has joined #ruby
[21:06:10] blackmesa: has joined #ruby
[21:08:05] ShekharReddy: has joined #ruby
[21:09:36] milardovich: has joined #ruby
[21:17:21] ramortegui: has joined #ruby
[21:24:02] leitz: is there a way, in a class, to iterate through hash.each do |key,value| to set instance variables to the key?
[21:35:06] dminuoso: "set instance variables to _the_ key" ?
[21:35:12] dminuoso: What does that even?]
[21:37:54] _sfiguser: has joined #ruby
[21:43:26] jottr: has joined #ruby
[21:47:37] nopolitica: has joined #ruby
[21:48:05] lele: has joined #ruby
[21:52:50] troulouliou_div2: has joined #ruby
[21:53:53] x77686d: has joined #ruby
[21:54:02] c-c: Would the key be a string or a symbol?
[21:54:12] Guest70176: has joined #ruby
[21:55:01] blackmesa1: has joined #ruby
[21:56:50] Xeago: has joined #ruby
[21:59:52] apeiros: leitz: there's instance_variable_set, which is used like: instance_variable_set(:"@foo", value)
[22:00:23] apeiros: though often when you do that you should probably either use a Struct or a Hash directly.
[22:00:37] sunrunner20: has joined #ruby
[22:03:18] danielpclark: has joined #ruby
[22:03:50] tomphp: has joined #ruby
[22:04:50] tomphp: has joined #ruby
[22:06:12] tomphp: has joined #ruby
[22:10:32] deepredsky: has joined #ruby
[22:11:06] tomphp: has joined #ruby
[22:12:02] ur5us_: has joined #ruby
[22:12:22] eightlimbed: has joined #ruby
[22:12:33] Cohedrin: has joined #ruby
[22:13:43] lexruee: has joined #ruby
[22:16:22] FahmeF: has joined #ruby
[22:17:42] ramortegui: has joined #ruby
[22:19:08] milardovich: has joined #ruby
[22:19:22] jenrzzz: has joined #ruby
[22:27:45] jamesaxl: has joined #ruby
[22:29:52] LocaMocha: has joined #ruby
[22:38:14] RickHull: leitz: yep -- if it seems like my code is doing much of what yours is/was, but slightly differently, that's on purpose :)
[22:38:58] RickHull: i definitely think there is a win in separating character generation from having a realized character
[22:39:20] RickHull: you don't want missing attributes to be silently generated instead of causing an error
[22:39:27] RickHull: i love errors :)
[22:39:32] RickHull: (I hate hiding them)
[22:40:19] mim1k: has joined #ruby
[22:40:33] RickHull: likewise, i would make sure there is a solid core before trying to layer on user-defined generation schemes or NPCs that can morph into full chars
[22:40:58] RickHull: let's reduce the scope and make something rock solid first
[22:41:13] drowze: has joined #ruby
[22:41:32] RickHull: that said, it's good to keep in mind how the core will be extended -- but don't put on the extension handcuffs sooner than necessary
[22:42:15] RickHull: one common problem with deep, complex, nested hash data structures is that there are often missing fields, or field values that are slightly "out of spec"
[22:42:20] RickHull: if there even is a spec or schema
[22:43:45] RickHull: in the security world, there is the concept of rings. ring 1's functionality is based on having a rock-solid ring 0
[22:44:05] RickHull: you could always make an uber-ring that combines the concerns of rings 1-4
[22:44:11] sunrunner202: has joined #ruby
[22:44:19] RickHull: and there could be some small wins there. but likely huge losses
[22:45:51] RickHull: my approach is not to try to anticipate how to design rings 1-4 at the start. instead, nail down ring 0, and then see what is possible for ring 1
[22:46:03] milardovich: has joined #ruby
[22:46:36] RickHull: if you are already a domain expert and you have the entire design in your head and somewhat "validated" then sure -- commit a big design up front for all rings, or make an uber-ring
[22:48:06] RickHull: so in my fork, in order to call Character.new, you have to have all the data, and the data will be validated or else Character.new will error out
[22:48:23] nopolitica: has joined #ruby
[22:48:41] RickHull: if you have no data and want full generation, call Character.generate. if you have partial data like name and gender, but want everything else generated, call Character.generate
[22:48:49] RickHull: Character.generate is flexible. Character.new is not
[22:49:53] RickHull: likewise, Character.new does not do any dice rolling. it assumes the character data has already been generated
[22:50:12] RickHull: Character.generate enforces the dice rolls for upp generation
[22:50:29] RickHull: but allows user-set values for plot, appearance, etc
[22:50:32] ramortegui: has joined #ruby
[22:52:33] muelleme: has joined #ruby
[22:52:51] quobo: has joined #ruby
[22:53:21] sunrunner20: has joined #ruby
[22:56:45] Guest70176: has joined #ruby
[23:05:27] thinkpad: has joined #ruby
[23:11:07] cschneid_: has joined #ruby
[23:13:24] MrSparkle: has joined #ruby
[23:15:02] milardovich: has joined #ruby
[23:17:32] enterprisey: has joined #ruby
[23:17:39] nowhere_man: has joined #ruby
[23:23:31] rivalomega: has joined #ruby
[23:23:49] johno84: has joined #ruby
[23:26:14] jenrzzz: has joined #ruby
[23:26:30] danielpclark: has joined #ruby
[23:32:13] Dimik: has joined #ruby
[23:34:11] zapata: has joined #ruby
[23:37:08] jenrzzz: has joined #ruby
[23:41:10] veeti: has joined #ruby
[23:42:36] leitz: apeiros, RickHull found a flaw in my logic. I'm working on it.
[23:43:24] leitz: RickHull, yeah, the core interface is mostly done. I was playing around with using the class differently but that didn't work. It was a learning experience though. :)
[23:43:29] weaksauce: leitz there are no flaws in logic just unexpected features
[23:43:30] RickHull: oh for sure
[23:43:47] RickHull: leitz: i'm hooked on redoing your core -- stay tuned to my fork
[23:44:00] RickHull: it's maybe worth playing around with already
[23:44:30] leitz: Keep in mind I'm an "early to bed, early to rise" sort. :)
[23:47:36] RickHull: leitz: want to try it out?
[23:48:15] RickHull: ok, go to a new dir, so you can clone my fork
[23:48:18] leitz: Same repo?
[23:48:24] RickHull: or if you're good with git, then you can add my fork as a remote
[23:48:43] RickHull: but for simplicity, just e.g. mkdir ~/tmp; cd ~/tmp
[23:48:55] RickHull: git clone https://github.com/rickhull/CT_Character_Generator.git
[23:49:05] nopolitica: has joined #ruby
[23:49:24] Axsuul: has joined #ruby
[23:50:09] RickHull: once you're in the project dir, git checkout rickfactor
[23:50:22] RickHull: then: irb -Ilib -rtraveller_char/generator
[23:50:32] RickHull: Character.generate
[23:50:44] RickHull: er, TravellerChar::Character.generate
[23:51:54] RickHull: @appearance="medium straight brown neck hair with black skin" LOL
[23:52:10] RickHull: neck hair, sweet
[23:52:42] RickHull: we need a cheeto-dusted neckbeard
[23:54:06] rouge: has joined #ruby
[23:56:28] leitz: RickHull, nice!
[23:56:41] leitz: Can't say I understand all of it yet though. :)
[23:57:01] RickHull: I added dice rolling to the generator module
[23:57:12] RickHull: if dice rolling is needed at playtime -- probably extract that back out again
[23:57:28] RickHull: but we're writing things to be flexible and composable so this will be easy later
[23:58:05] leitz: Using random is fine, or even sample from a range. Mostly just 2 six sided dice equivalent to give a curve in the middle.
[23:58:09] RickHull: the roll1 and rolln stuff was me just playing with lambdas -- not necessarily a good way to do it
[23:58:11] tomphp: has joined #ruby
[23:58:14] Guest70176: has joined #ruby
[23:58:38] RickHull: in general, I prefer to express the calculation rather than step through it
[23:58:43] RickHull: declarative vs imperative