<RickHull>
notice it's defined on the Character class, in character.rb
<RickHull>
it's a "class method" rather than an "instance method" as it does not touch the Character object's ivars
<RickHull>
`class Foo; `def self.bar` defines a class method that can be called like `Foo.bar`
<RickHull>
without instantiating an object
<RickHull>
i left an extra backtick in there, oops
jackjackdripper has joined #ruby
<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.
<RickHull>
sure, I mean in general OOP terminology, not ruby's weird twisted mirror of mirrors clownhouse
jackjackdripper1 has quit [Ping timeout: 248 seconds]
<dminuoso>
>> a = "RickHull"; def a.hi; puts "hi, I am: #{self}"; a.hi
<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)
<dminuoso>
>> a = "RickHull"; def a.hi; puts "hi, I am: #{self}"; end; a.hi
<ruby[bot]>
dminuoso: # => hi, I am: RickHull ...check link for more (https://eval.in/905706)
<dminuoso>
Sucks so muchy to type in irssi without an editor completing your `end` all the time.
<leitz>
Hang on a sec, the chargen is broken.
<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
<RickHull>
which explained things in conventional terms -- and I locked into that understanding
<dminuoso>
RickHull: Dont even have to talk about all that stuff. You can think of it as defining methods on objects rather than classes.
<RickHull>
classes are objects
<RickHull>
so uh, boosh
<dminuoso>
Yup.
<RickHull>
it makes things terribly annoying to discuss
<dminuoso>
RickHull: My point is, they are not "special to classes". You can tie a method to anything by just using def foo.bar :)
<dminuoso>
The fact that there's classes involved, that is probably the secret bit we dont have to talk about.
Psybur has joined #ruby
<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?"
<dminuoso>
>> class << "funny business"; def fun; end; end
<dminuoso>
Its great if you understand that it just opens up an objects singleton class. ;-)
bmurt has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<RickHull>
I've worked with folks that love doing that, just so they can omit the `self` part of `def self.foo`
<dminuoso>
class << a; end; is basically equivalent to a.singleton_class.instance_eval do; end
<RickHull>
that's a horrendous use of coding judgment IMHO
<dminuoso>
RickHull: I sometimes do it out of convenience.
<dminuoso>
But its rare and usually justified.
exhiled has joined #ruby
<RickHull>
omitting a tiny part of a major signifier of what the method is intended for
<RickHull>
WHY!?!?!?
<RickHull>
and using goofball syntax to do it
<dminuoso>
RickHull: Since my time with Haskell Ive started to appreciate concise syntax.
<RickHull>
like, it's a big deal in my world whether a method is a "class method" or an "instance method"
<RickHull>
how much does typing `self` hurt? I love looking at it -- it means something
<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.
cschneid_ has quit [Remote host closed the connection]
<RickHull>
i'd prefer your instance_eval version
Psybur has quit [Ping timeout: 248 seconds]
<RickHull>
but why even go there? you're adding a whole layer of indentation and masking the method signature
<RickHull>
WHY?!
<dminuoso>
RickHull: Note there's probably some subtly difference in semantics.
cschneid_ has joined #ruby
<weaksauce>
tomfoolery is why
<RickHull>
why should I even have to consider a semantic difficulty?
<RickHull>
WHY?!
<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.
<RickHull>
there are methods that have no access to ivars
<dminuoso>
RickHull: Maybe you should start writing in SKI calculus.
<dminuoso>
Only three things to consider.
<RickHull>
and can be called without instantiating anything
<RickHull>
and are globally available with `require`
<RickHull>
"class methods" kick ass
<RickHull>
what do you call them?
<dminuoso>
methods.
<RickHull>
do you distinguish between methods that mess with ivars and require an instantiated object to call?
<dminuoso>
the only difference between some method and another, is their name and/or the class/module they are defined in.
<RickHull>
and those that don't?
<dminuoso>
huh?
<dminuoso>
what makes you think methods on singleton classes cant have instance variables?
<dminuoso>
and what makes you think you dont require an instantiated object to call them?
<dminuoso>
Array.class << Array is an instantiated object, is it not?
knight33 has joined #ruby
<RickHull>
i don't quite follow. I mean where a user calls .new
<leitz>
It's not. This is the tricky part I mentioend a while ago. "career" is from line 72, a variable.
troys is now known as troys_
<RickHull>
weaksauce: the career being required -- that's a variable, not 'career'
<weaksauce>
oh right. my bad
<leitz>
So it refers to noble, other, etc.
<RickHull>
require career -- vs -- require 'career'
<leitz>
weaksauce, I wrote it and I still barely get it...
<leitz>
Of course, I wrote it with #ruby help. :)
<weaksauce>
you'd want to use the full path to that file.
<leitz>
The issue is, I think, once LOAD_PATH is not modified, it can't find it.
mim1k has quit [Ping timeout: 248 seconds]
<leitz>
I tried to add the path but it didn't work "careers/#{career}"
<RickHull>
i think you need require File.join('careers', career)
<RickHull>
yes, you need to provide the subdir path within lib/
<weaksauce>
so if your key is noble. the filename is noble.rb and then the require should be something like require "lib/careers/#{career}"
<RickHull>
not with lib though
<weaksauce>
er yeah, since you add the loadpath to ruby
<RickHull>
presuming you called `ruby -Ilib bin/chargen`
<weaksauce>
so then, require "careers/#{career}" if you want to do it dynamically like that
<RickHull>
dminuoso: my point is that yes, ruby is mad flexible and you can do crazy postmodern stuff with it, like in Perl
<RickHull>
but there are also well established conventions and best practices that is similar to python methodology
kapil___ has joined #ruby
<RickHull>
where the term "class method" is meaningful
<al2o3-cr>
RickHull: class methods are merely instance methods on the singleton class
<RickHull>
yes, and we can make the singleton class behave like a class instance with ivars
<RickHull>
but rarely is that a good idea
<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?
<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.
<dminuoso>
weaksauce: ^- this is why.
<dminuoso>
weaksauce: It has to do with basic type theory.
<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"
reu_ has quit [Quit: こんなにも、世界はレプリスで満ちあふれていたのか? もし、今自分の手を傷つけてみたら、同じように泡を立てて消えていくのか?]
<RickHull>
what are the types in ruby? can we enumerate them?
<dminuoso>
RickHull: classes and you can.
<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.
<leitz>
Ruby has all types...
<leitz>
FIxed the require. Do the dishes, fix teamgen, and then it'll be nappy time.
cahoots_ has quit [Ping timeout: 260 seconds]
<RickHull>
is Array a ruby type?
<dminuoso>
ObjectSpace.each_object(Class)
charliesome has joined #ruby
larcara has joined #ruby
<dminuoso>
weaksauce: the singleton pattern name has the same origin :p
<weaksauce>
:D yeah
jameser has joined #ruby
<RickHull>
so Array is properly a type, a class, and an object - wonderful
<dminuoso>
RickHull: well for the purpose of this discussion class and type are synonymous.
<dminuoso>
Ruby created it for you when it started.
<dminuoso>
(Or rather when the VM is initialized)]
larcara has quit [Ping timeout: 260 seconds]
<garyserj>
and does anybody here use sinatra?
<weaksauce>
!ask
<RickHull>
?ask
<ruby[bot]>
Don't ask to ask. Just ask your question, and if anybody can help, they will likely try to do so.
<weaksauce>
perhaps that bot isn't around anymore
<weaksauce>
ah
<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"
<dminuoso>
Only thing Im missing is dependent types.
Lyubo1 has quit [Ping timeout: 255 seconds]
<RickHull>
yes, I suppose I learned a much simpler programming model, with more limitations, that imposes dataflow structure
reu has joined #ruby
<RickHull>
it's like structured programming without GOTO
<dminuoso>
Ruby has goto.
<dminuoso>
Like, actual goto.
<RickHull>
it's an analogy
<weaksauce>
i learned on basic years ago... that was basically goto programming
<RickHull>
you can do all kinds of wacky stuff with GOTO
<dminuoso>
No I mean like really.
<RickHull>
(I know)
<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
drewmcmillan has joined #ruby
<RickHull>
it's much better to limit yourself and impose structure
Technodrome has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<dminuoso>
You can declare __label__(:foo) and __goto__(:foo) just fine!
<garyserj>
How do you tell Sinatra to look at a haml file outside of the views directory?
drewmcmillan has quit [Client Quit]
Lyubo1 has joined #ruby
<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
<RickHull>
not everyone has to be like me :)
<RickHull>
but wearing that straitjacket yields simple and easy to understand code, in my experience
<RickHull>
and it is in accordance with the larger OOP world beyond ruby's specific impl
<RickHull>
AFAIK
charliesome has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<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
<RickHull>
it matters whether the methods are defined on the singleton class
<RickHull>
why hide that signature?
<RickHull>
anyways...
<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
<weaksauce>
as the saying goes, there are only two hard problems in computer science: cache invalidation, naming things and off by one errors
<RickHull>
that's 11
oetjenj has joined #ruby
stevie has joined #ruby
<stevie>
does ruby play nice with uwsgi?
<RickHull>
stevie: are you familiar with rack?
mim1k has joined #ruby
<stevie>
no
<leitz>
Well, dang, it almost all worked.
charliesome has joined #ruby
jackjackdripper has quit [Quit: Leaving.]
<RickHull>
stevie: rack is ruby's standard web middleware, modeled off WSGI as i understand https://rack.github.io/
<RickHull>
I'm not sure about uwsgi
<dminuoso>
RickHull | dminuoso: I program as though global variables and GOTO are not available.
<dminuoso>
You use if right?
<dminuoso>
That's a conditional goto.
<RickHull>
yes, as in structured programming
<RickHull>
the Dijkstra "goto considered harmful" sense
<RickHull>
the pedantic stuff about "peel back the covers and there's a jmp" isn't really helpful
tomphp has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
mim1k has quit [Ping timeout: 240 seconds]
<dminuoso>
The irrational fear of goto is just a subconscious fear of imperative programming.
<dminuoso>
People just know that "telling" the program to suddenly do weird things is bad.
<RickHull>
nope, structured programming is objectively better
<RickHull>
dijkstra wasn't being irrational
Algebr has quit [Remote host closed the connection]
Algebr has joined #ruby
<RickHull>
and for sure, ceteris paribus, declarative programming is better than imperative
<RickHull>
it's just that ceteris usually isn't paribus
<RickHull>
but we'll get there one day ;)
<dminuoso>
RickHull: Considering how "structured programming" introduces exceptions later, which are even worse than gotos in a particular way.
dinfuehr has quit [Ping timeout: 255 seconds]
<dminuoso>
Namely that they are commonly implemented using non-local gotos.
<RickHull>
i do like early returns, breaks, and exceptions
Psybur has joined #ruby
ramfjord has quit [Ping timeout: 248 seconds]
<garyserj>
for a small project, is sinatra advantageous over rails?
<RickHull>
there's a difference between an abstraction that uses goto in a structured way and littering your code with gotos
<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.
<RickHull>
garyserj: I like starting with sinatra -- it's very quick and easy to get going
<RickHull>
dminuoso: i'd make an analogy between declaring a rectangle vs driving a paintbrush
dinfuehr has joined #ruby
<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.
<RickHull>
driving a paintbrush can go wrong in many more varied ways
<RickHull>
leitz: I might poke around -- til next time :)
<dminuoso>
RickHull: Well at any rate, it is a religion war.
<dminuoso>
And I finally found mine.
<dminuoso>
Just admit that you are wrong.
<dminuoso>
;o
<RickHull>
I have declared a fatwa on "x is merely a y on a z"
exhiled has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<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.
<leitz>
Be sure you go back to the master branch.
<RickHull>
what does upp mean?
webguynow has quit [Ping timeout: 255 seconds]
<leitz>
Universal Personality Profile. The characters stats: strength, endurance, education, etc.
webguynow has joined #ruby
<RickHull>
S P E C I A L
<leitz>
Normally 6 Hex characters but there are two outliers that need to be handled.
<leitz>
Modifying a key'd hash seems a lot easier.
<leitz>
Feel free to open an issue if you like, I do. :)
Psybur has quit [Ping timeout: 248 seconds]
leitz has quit [Quit: Nappy time]
cahoots has quit [Ping timeout: 260 seconds]
<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.
<dminuoso>
garyserj: No.
<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.
cahoots has joined #ruby
cdg has joined #ruby
cahoots has quit [Client Quit]
ap4y has quit [Quit: WeeChat 1.9.1]
<RickHull>
i think the problem with bypassing a rendering engine is you have to maintain a stack yourself
cdg has quit [Ping timeout: 258 seconds]
<RickHull>
someone has to maintain the tag stack
Guest70176 has joined #ruby
<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?
ap4y has joined #ruby
<RickHull>
but I haven't messed with this stuff in a while, maybe I'm misunderstanding
<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
pilne has joined #ruby
mtkd has quit [Ping timeout: 268 seconds]
<garyserj>
I am totally new to the concept of something like haml
<garyserj>
so i've no idea. i'm just going to be playing with it a bit.
<RickHull>
I would stick with it for now
mtkd has joined #ruby
<RickHull>
it's pretty standard and it is useful
<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?
<RickHull>
if you decide you hate it later, at least it will be based on experience that can apply to your next decision
QualityAddict has joined #ruby
<RickHull>
my understanding is it's a way to call e.g. #form with some args that will define an html form for you
<RickHull>
i think it touches on both templating and rendering
houhoulis has quit [Remote host closed the connection]
eightlimbed has joined #ruby
ensyde has quit [Quit: Leaving]
helpa has quit [Remote host closed the connection]
k3rn31_ has joined #ruby
helpa has joined #ruby
JBbanks_ has joined #ruby
Eletious_ has joined #ruby
MrSparkle has quit [Ping timeout: 240 seconds]
k3rn31 has quit [Ping timeout: 260 seconds]
Eletious has quit [Ping timeout: 260 seconds]
harfangk has joined #ruby
JBbanks has quit [Ping timeout: 240 seconds]
mson has quit [Quit: Connection closed for inactivity]
<Bish>
dminuoso: who would expect a pure funcitonal language to have a good way to express ycombinator :D
<Bish>
haskell can have utf8 names?
PhoenixMage has joined #ruby
biberu has quit []
<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...
<Bish>
usually gems do not have makefiles, am i mistaking?
mim1k has joined #ruby
mikecmpbll has joined #ruby
<Bish>
PhoenixMage: do you have a github? you could put it up there, and give it as a source in the gemfile
<Bish>
otherwise you could do the same thing with filesystem, pretty sure
hurricanehrndz has quit [Quit: Goodbye]
hurricanehrndz has joined #ruby
cschneid_ has joined #ruby
<PhoenixMage>
Bish: I have the source code with the modified Makefile and its compiled but no idea have to package it to a gem
<Bish>
PhoenixMage: well, you might never know, since the dude who wrote the gem makes all kind of stuff
_aeris_ has quit [Remote host closed the connection]
<Bish>
PhoenixMage: that's why yo should make it a github/repository
<Bish>
and give it as source in your gemfile
<Bish>
that way, your changes are ONLY about -Werror
_aeris_ has joined #ruby
maum has quit [Read error: Connection reset by peer]
cschneid_ has quit [Ping timeout: 255 seconds]
Burgestrand has joined #ruby
gregf_ has quit [Ping timeout: 260 seconds]
<Bish>
so you can just take out what makes this gem not build, and leave the rest as is
<PhoenixMage>
:/ Nothing is ever easy
<Bish>
welcome to cs-hell
<PhoenixMage>
If I am going to do that I might as well try to find the bug and fix it
<Bish>
what gem is it?
<PhoenixMage>
gRPC compiling on arm
<Bish>
oh poor you, native gem on arm
<PhoenixMage>
I am trying to make a gitlab package
<PhoenixMage>
For archlinux
<Bish>
had do google gRPC
<Bish>
looks cool
<Bish>
what do people need it for
<Bish>
can you talk to gitlab with it?
jenrzzz has joined #ruby
jenrzzz has quit [Changing host]
jenrzzz has joined #ruby
<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
Cohedrin has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
iamarun has quit [Read error: Connection reset by peer]
guille-moe has joined #ruby
iamarun has joined #ruby
Psybur has quit [Ping timeout: 240 seconds]
<Bish>
it crashes while compiling tests
<Bish>
that's funny
mim1k has quit [Disconnected by services]
mim1k_ has joined #ruby
<Bish>
gcc7?
Guest70176 has joined #ruby
Azure has quit [Read error: Connection reset by peer]
<PhoenixMage>
Yeah
conta has joined #ruby
qba73 has joined #ruby
<Bish>
well, i would say you're asking for it :D
<Bish>
with gcc7
silvermine has quit [Ping timeout: 255 seconds]
<PhoenixMage>
And --with-cppflags=-Wno-error doesnt work :(
harfangk has quit [Ping timeout: 240 seconds]
<Bish>
if you want everything to be easy
<Bish>
you should stick to stable versions
<Bish>
dont you think
<adaedra>
gcc7 seems to be a stable version though
<Bish>
not if you ask gentoo package management, which is the one i trust
<adaedra>
It's even a .2
<Bish>
well, you're right, didn't check that up
<Bish>
holy shit, in august already
<Bish>
i remember people calling me crazy when installing 6.0
Azure has joined #ruby
<PhoenixMage>
I am just using the default build package archlinux-arm
Beams has joined #ruby
tomphp has joined #ruby
<PhoenixMage>
Looks like I will need to work out how to do the github thing
<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
marr has joined #ruby
enterprisey has quit [Ping timeout: 258 seconds]
DoubleMalt has quit [Ping timeout: 248 seconds]
<Bish>
docker is your friend
howdoi has joined #ruby
DoubleMalt has joined #ruby
<PhoenixMage>
What does docker have to do with it?
drewmcmillan has joined #ruby
<Bish>
if you have a run gem install <some_gem> line in a docker file
<Bish>
it certainly won't repull it
Azure has quit [Read error: Connection reset by peer]
<PhoenixMage>
ah
<Bish>
i was ultrasceptic when using containers at first, but it's sooo good, i use it for everything
<PhoenixMage>
I am just cloning the repo will make the change and use the local repo
<PhoenixMage>
I am a docker fan myself
<PhoenixMage>
I use it for game servers most of the time though
<PhoenixMage>
My Ark server is a docker container
jaruga has joined #ruby
<Bish>
it solves so many problems that you shouldn't have in first place.. like non-compiling gems
<PhoenixMage>
Agreed
<PhoenixMage>
I think there is even a published docker container for gitlab on arm
qba73 has quit []
<adaedra>
Wait, if I'm reading correctly, you are just trying to install Gitlab?
<adaedra>
How do you get from this to manually compiling a gem from a Makefile?
<jokke>
hi
<jokke>
i have something in my codebase which causes my tests to block indefinately
<PhoenixMage>
adaedra: grpc is a requirement for gitlab
<PhoenixMage>
There is no gitlab package for archlinux-arm
<jokke>
it's before the actual test is run and after the test setup
<jokke>
is there a easy way to find the actual code responsible for the blocking?
<adaedra>
Ah, but it's not a gem right?
tomphp has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
mtkd has quit [Ping timeout: 260 seconds]
mson has quit [Quit: Connection closed for inactivity]
dhollin3 has joined #ruby
<PhoenixMage>
Its trying to install the gem when I install a gitlab bundle from the source
jaruga has quit [Ping timeout: 240 seconds]
<PhoenixMage>
Its only cos the damn Makefile has -Werror in it
mtkd has joined #ruby
<adaedra>
Ah, I see, it'd be the gem bridge
Azure has joined #ruby
<adaedra>
Everyone should use -Werror
<adaedra>
grpc itself is built correctly?
dhollinger has quit [Ping timeout: 255 seconds]
<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
<adaedra>
ha, the AUR package for grpc does filter the -Werror out
jenrzzz has quit [Ping timeout: 260 seconds]
deepredsky has joined #ruby
<adaedra>
so, in order: did grpc itself (so not the gem) built correctly, or is it the one throwing the error?
<PhoenixMage>
Its the one throwing the error
ams__ has joined #ruby
<adaedra>
Okay
<adaedra>
So you can try building using the technique seen in the AUR I guess
<Burgestrand>
It'd recommend compling ruby with debug symbols enabled though, otherwise it's a mess trying to figure out what's what
Psybur has joined #ruby
<adaedra>
Bish: I think there's a part that gets required in the executed script, which allows the external control
<adaedra>
But that's long ago
leitz has joined #ruby
<adaedra>
Now I write bug-free code, much less hassle :p
<Bish>
gdb with ruby :D
<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
<Bish>
that's a good one
<jokke>
couldn't i just trap interrupt?
silvermine has joined #ruby
<adaedra>
Not sure the backtrace you get in trap would reveal the problem
lexruee has joined #ruby
<adaedra>
But yeah, look at a htop or a ps to see what is launched by your script
minimalism has quit [Ping timeout: 240 seconds]
Azure has joined #ruby
<Bish>
maybe strace helps
<Bish>
rescued me in many hopeless situations
<Bish>
jokke: strace -fp <pidof ruby>
<Bish>
you might see the reason for the block
<Bish>
or even invoke the bad script with strace -f -o output <bad_script>
<jokke>
it just launches the test apparently
<jokke>
from rake
<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
<Bish>
try to invoke it with strace
<jokke>
ok
<Bish>
you will se a lot of shit, but there is a slight chance you can read the exact error
Psybur has quit [Ping timeout: 255 seconds]
apparition has quit [Quit: My iMac has gone to sleep. ZZZzzz…]
<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
<Bish>
this is the exact reason why strace > debugging in some cases
<Bish>
particulary the hard ones
<Bish>
jokke: where is the error in that dump?
mim1k_ has quit [Ping timeout: 252 seconds]
<Bish>
just so i learn something
jenrzzz has joined #ruby
SirOliver has joined #ruby
lxsameer has joined #ruby
minimalism has joined #ruby
jameser_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
RoneDreamer has joined #ruby
Serpent7776 has joined #ruby
RoneDreamer has quit [Remote host closed the connection]
Guest70176 has quit [Ping timeout: 255 seconds]
bigkevmcd has joined #ruby
<jokke>
well i guess it's just that the mongodb connection is blocking
<jokke>
or retrying indefinetly
cdg has joined #ruby
ldnunes has joined #ruby
cdg has quit [Ping timeout: 246 seconds]
esObe has quit [Ping timeout: 252 seconds]
deepredsky has quit [Ping timeout: 240 seconds]
Sina has quit [Quit: Connection closed for inactivity]
ldepandis has joined #ruby
<Bish>
that's cool
<jokke>
yeah i don't know about that. :P now it's even harder to find the error
deepredsky has joined #ruby
[spoiler] has quit [Quit: Cheers!]
<Bish>
im sorry, then
[spoiler] has joined #ruby
char_var[buffer] has quit [Ping timeout: 268 seconds]
[spoiler] has joined #ruby
[spoiler] has quit [Client Quit]
deepredsky has quit [Ping timeout: 240 seconds]
[spoiler] has quit [Client Quit]
RoneDreamer has joined #ruby
[spoiler] has joined #ruby
RoneDreamer has quit [Remote host closed the connection]
RoneDreamer has joined #ruby
deepredsky has joined #ruby
mim1k has joined #ruby
<leitz>
Is there a Ruby equivalent to Pythons "my_hash.get('key', <default_value>}" ?
<ta_>
`{}.fetch(:key, "value"}`
<ta_>
`{}.fetch(:key, "value")` even
<leitz>
hehe...thanks!
* leitz
goes off to refactor
roshanavand has quit [Read error: Connection reset by peer]
deepredsky has quit [Ping timeout: 248 seconds]
mim1k has quit [Ping timeout: 240 seconds]
tvw has joined #ruby
Psybur has joined #ruby
esObe has joined #ruby
SirOliver has quit [Quit: ZZZzzz…]
roshanavand has joined #ruby
deepredsky has joined #ruby
Psybur has quit [Ping timeout: 240 seconds]
minimalism has quit [Ping timeout: 240 seconds]
SirOliver has joined #ruby
SirOliver has quit [Client Quit]
RoneDreamer has quit [Remote host closed the connection]
RoneDreamer has joined #ruby
iamarun has quit [Remote host closed the connection]
vtx has joined #ruby
SirOliver has joined #ruby
ldepandis has quit [Ping timeout: 268 seconds]
mim1k has joined #ruby
<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
<vtx>
using :set solve this my ensuring only one connection is made and reused?
SirOliver has quit [Client Quit]
Immune has joined #ruby
MrBismuth has joined #ruby
<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
jenrzzz has quit [Ping timeout: 248 seconds]
biberu has joined #ruby
MrBusiness has quit [Ping timeout: 255 seconds]
<vtx>
oh, as an aside to that, maybe my code needs to do `@db ||= mongo[database].database`?
<vtx>
tbuehlmann: is set part of sinatra DSL or is it a ruby thing?
<tbuehlmann>
that's from sinatra
SirOliver has joined #ruby
Defenestrate has joined #ruby
snickers has joined #ruby
<vtx>
okay thank you, i really appreciate it!
SirOliver has quit [Client Quit]
silvermine has quit [Quit: WeeChat 2.0-dev]
silvermine has joined #ruby
kryptoz has quit []
jenrzzz has joined #ruby
SirOliver has joined #ruby
SirOliver has quit [Remote host closed the connection]
jaruga has joined #ruby
jenrzzz has quit [Ping timeout: 268 seconds]
cdg has joined #ruby
deepredsky has quit [Remote host closed the connection]
larcara has quit [Remote host closed the connection]
<ule>
its not actually a merge, its a combine
larcara has joined #ruby
<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
<tobiasvl>
but I haven't used erb in years
<ule>
tobiasvl: already told him how to fix it
<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
DoubleMalt has quit [Ping timeout: 268 seconds]
<tobiasvl>
I assume erb is replacing <%= foo -%> with (foo).to_s
<ule>
oh yeah
<ule>
my bad
<RevanOne>
hmm, so what is the actually solution then ? I cannot use 2 lines in my DO ?
mostlybadfly has joined #ruby
<tobiasvl>
RevanOne: I don't remember how erb works, but can't you just change <%= to <% in line 2?
<tobiasvl>
you just want that line to be evaluated, not printed
<RevanOne>
i can
raynold has quit [Quit: Connection closed for inactivity]
larcara has quit [Ping timeout: 260 seconds]
guille-moe has quit [Ping timeout: 250 seconds]
<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| -%>
<RevanOne>
?
<dminuoso>
You sir, need to learn about variables.
<dminuoso>
There's nothing scary about stuff = factvalueslb['results'].map{ |h| h[1]['fqdn'] }; /* and then in some other place */ <% stuff.each do |val | %>
<pavelz>
hi, just wondering if there is a RESTy file storage service in ruby a simple one ?
<pavelz>
preferably with filesystem and least amount cruft needed to get going. need to customize and emu some corporate service for devs.
Ambassador has joined #ruby
electrostat has quit [Quit: uwotm8]
drowze has joined #ruby
Psybur has joined #ruby
electrostat has joined #ruby
<leitz>
Ah...may have it.
BioSpider has quit [Quit: Going offline, see ya! (www.adiirc.com)]
Psybur has quit [Ping timeout: 248 seconds]
kitsunenokenja has joined #ruby
cdg has joined #ruby
vtx has joined #ruby
SirOlive_ has joined #ruby
DK2 has quit [Ping timeout: 246 seconds]
<pavelz>
prolly sinatra it till it works
<c-c>
pavelz: maybe you can make fog use filesystem
SirOliver has quit [Ping timeout: 240 seconds]
<pavelz>
nah looks too complicated )
cdg has quit [Remote host closed the connection]
cdg has joined #ruby
Defenestrate has quit [Quit: Leaving]
jottr has joined #ruby
<Bish>
pavelz: how do you combine rest with files?
<Bish>
i mean... rest usually means you're modifying the entries
<Bish>
with update/patch whatever
<Bish>
with files.. i would just imagning create, replace, delete
<Bish>
pavelz: i had sucess using a combination of roda/shrine/sequel
<Bish>
where i append files to database entries, really easily
<pavelz>
post to a service a file get json back
<Bish>
simple as model.file = post[:uploaded_file]
<Bish>
and whats the content of said json?
<pavelz>
application specific uuid and filename and such things
<Bish>
yeah not really restful what u describe
<Bish>
it would be.. if what you sends is exactly what u get back
<Bish>
but what you describe is upload a file, and get a minimal json back
<Bish>
but as i said, sequel/shrine make it really easy and you generalize it with roda
<c-c>
its not rest or its not restful :D
<Bish>
code snippet out of my current project:
<Bish>
r.post { model.file = r.POST['file'] }
quobo has joined #ruby
<Bish>
and this gets uploaded to s3 and simulates "syscalls" like read, seek, etc
guille-moe has joined #ruby
<Bish>
CRUD would describe it better, wouldn't it?
tuelz has quit [Ping timeout: 255 seconds]
tuelz has joined #ruby
mikecmpbll has quit [Read error: Connection reset by peer]
vee__ has quit [Ping timeout: 268 seconds]
mikecmpbll has joined #ruby
drowze has quit [Ping timeout: 255 seconds]
ledestin has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Rouge has joined #ruby
zautomata has quit [Quit: WeeChat 1.7]
govg has quit [Ping timeout: 248 seconds]
zautomata has joined #ruby
zautomata has quit [Client Quit]
zautomata has joined #ruby
<leitz>
Bish, CRUD would describe a lot of my code.
<leitz>
Oh, you mean "Create..." :D
<Bish>
i am no native speaker, i don't get it in case crud means something awful
<leitz>
Crud is "junky, trashy" "He has a lot of crud in his background." or "His code is full of crud."
<Bish>
eheh
<leitz>
I have lived in a few countries and understand how odd the English language can be.
<leitz>
Not to mention the English themselves...
zautomata has quit [Client Quit]
* leitz
hopes the blokes are all busy at work and ignoring IRC.
<Bish>
i've been to scotland, nice people
zautomata has joined #ruby
vee__ has joined #ruby
<Bish>
but didn't understand a word, i'm bad with accents
<leitz>
No one understands Scots, they just drink more.
<Bish>
very stereotypical being you are
<Bish>
literally everyhwere i went to buy something
<leitz>
Yup.
<Bish>
multiple people stopped whatever they were doing
<Bish>
to help me to decide to buy the best thing
<Bish>
not kidding: i was buying cigarettes and they didn't have my brand
<Bish>
3 people got out of line, to explain each tabbaco flavor to me
<Bish>
that happened everytime i couldn't decide what to order/buy
<leitz>
Americans like me and people from the UK make friendly fun of each other.
<leitz>
I can believe that; I lived in England for a while. People there were the same.
webguynow has quit [Ping timeout: 260 seconds]
<leitz>
Italy too.
<leitz>
Err...and Germany, though I wasn't there as long. Just visiting.
webguynow has joined #ruby
<leitz>
They were still shooting at us Gringos in Panama so I didn't get out much.
<Bish>
lol, i've had a business meeting some weeks ago, and in the region where i live people aren't very friendly
<leitz>
Sorry to hear. What region are you in?
Psybur has joined #ruby
<Bish>
northrhine westfalia i think thats how it's written in english
<Bish>
OWL more precicely
<Bish>
highest compliment you can get here is no critism
<Bish>
that's how people outside of the region describe us
<leitz>
North-Rhine Westphalia
<leitz>
If you want real abuse, ask for help with Ruby 1.8.7. It will make OWL seem very nice. :P
<Bish>
that's before my ruby times
<Bish>
well, don't use it?
<leitz>
1.8.7 is comes on Red Hat 6.
<leitz>
Like my CentOS desktop.
<Bish>
or am i being naive?
<adaedra>
Good thing you can install more recent rubies :D
cdg has quit [Remote host closed the connection]
Psybur has quit [Ping timeout: 240 seconds]
<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.
apparition has quit [Quit: Bye]
<Bish>
are there big incompabalities? i thought ruby rarely does that
uZiel has quit [Ping timeout: 248 seconds]
SirOlive_ has quit [Quit: ZZZzzz…]
<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.
<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.
<Bish>
2.5 is out?
<Bish>
man, im slow
snickers has quit [Ping timeout: 248 seconds]
<leitz>
In preview.
<leitz>
2.5.0-preview1
<leitz>
By the time I get good with Ruby 2.5 will be the 1.8.7. :)
roshanavand has quit [Read error: Connection reset by peer]
roshanavand has joined #ruby
oleo has joined #ruby
cdg has joined #ruby
nadir has quit [Quit: Connection closed for inactivity]
cdg has quit [Ping timeout: 258 seconds]
dviola has joined #ruby
marr has quit [Ping timeout: 248 seconds]
urk187 has joined #ruby
<darix>
leitz: use the snapshot tarballs tbh.
<darix>
that preview1 is really old
<darix>
leitz: for opensuse I could even get you 2.5 packages.
<darix>
leitz: but be warned 1-2 extensions are broken with 2.5 right now. (mostly profiling and debug tools though)
<leitz>
darix, the git repo for 2.5 needs an extra step, I found that out the fun way.
<darix>
leitz: yeah that's why i sticked to the snapshot tarballs :P
<leitz>
Now I can't recall if I'm running from git repo or tar files from ruby-lang. Dang.
charliesome has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
knight33 has joined #ruby
x77686d has joined #ruby
aufi has quit [Quit: Leaving]
<leitz>
Time for a break. Back in a while, lots of refactoring left.
DLSteve has joined #ruby
deepredsky has quit [Ping timeout: 240 seconds]
deepredsky has joined #ruby
zautomata has quit [Ping timeout: 248 seconds]
InfinityFye has quit [Quit: Leaving]
zautomata has joined #ruby
nofxx_ has quit [Remote host closed the connection]
nofxx_ has joined #ruby
kitsunenokenja has quit [Ping timeout: 258 seconds]
tvw has quit [Remote host closed the connection]
deepredsky has quit [Ping timeout: 240 seconds]
zautomata1 has joined #ruby
plexigras has joined #ruby
zautomata has quit [Ping timeout: 240 seconds]
Psybur has joined #ruby
larcara has quit [Remote host closed the connection]
larcara has joined #ruby
marr has joined #ruby
knight33 has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
<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.
Guest70176 has quit [Ping timeout: 248 seconds]
<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.
<leitz>
In this case class Noble is in "noble.rb".
Revan007 has quit [Ping timeout: 240 seconds]
<leitz>
I am trying to figure out how to call the class's method on the character instance.
zautomata1 has quit [Ping timeout: 260 seconds]
zautomata1 has joined #ruby
Guest70176 has joined #ruby
Technodrome has joined #ruby
Revan007 has joined #ruby
<dminuoso>
character.method _
<dminuoso>
?
<leitz>
dminuoso, I don't understand the question.
guille-moe has quit [Ping timeout: 248 seconds]
<dminuoso>
leitz: I dont understand yours.
larcara has joined #ruby
guille-moe has joined #ruby
howdoi has joined #ruby
<leitz>
Understood, this is one of the places I get confused. It is making a string from a file name into a class call.
Burgestrand has quit [Quit: Closing time!]
milardov_ has joined #ruby
rippa has joined #ruby
guille-moe has quit [Ping timeout: 248 seconds]
milardovich has quit [Ping timeout: 258 seconds]
drewmcmillan has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
gizmore|2 is now known as gizmore
ana_ has quit [Ping timeout: 248 seconds]
drowze has joined #ruby
troys_ is now known as troys
drewmcmillan has joined #ruby
ledestin has joined #ruby
zautomata1 has quit [Ping timeout: 248 seconds]
x77686d has quit [Ping timeout: 240 seconds]
deepredsky has joined #ruby
thinkpad has quit [Ping timeout: 248 seconds]
quobo has quit [Quit: Connection closed for inactivity]
zautomata1 has joined #ruby
deepredsky has quit [Ping timeout: 258 seconds]
tvw has joined #ruby
conta has quit [Ping timeout: 248 seconds]
bmurt has joined #ruby
John__ has joined #ruby
tvw has quit []
tvw has joined #ruby
Guest70176 has quit [Ping timeout: 248 seconds]
<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".
<adaedra>
If you do not override the method, the parent's one is called, yes.
<dminuoso>
leitz: Keep in mind that, that modules of a class are also considered ancestors.
FahmeF has joined #ruby
<dminuoso>
The order is: `Prepended modules, the class itself, included modules`, repeat with parent.
x77686d has joined #ruby
nopolitica has quit [Ping timeout: 240 seconds]
nofxx_ has quit [Remote host closed the connection]
<leitz>
I'm just past the edge of my understanding. Not sure I can explain it well and was hoping the code was enough.
nofxx_ has joined #ruby
<leitz>
Let me post the code and then what I think is happening.
<leitz>
Hmm...I'm trying to learn Class methods, I think. There's no real instance of Career, it just modifies character.
cschneid_ has joined #ruby
<havenwood>
leitz: Then change Career from a Class to a Module and add `module_function` at the top of the module.
blackmesa has joined #ruby
<havenwood>
leitz: Then you can call: Career.update_character(character, career, terms)
deadpoet_ has quit [Client Quit]
<havenwood>
leitz: Or `include Career` in another class, and call: update_character(character, career, terms)
<leitz>
Can you have parent and child modules?
<leitz>
Where the child extends or modifies parent methods?
<havenwood>
leitz: A module can mixin another module. They don't have offspring.
deepredsky has joined #ruby
x77686d has quit [Quit: x77686d]
SirOliver has quit [Quit: ZZZzzz…]
cschneid_ has quit [Ping timeout: 246 seconds]
Guest70176 has joined #ruby
andikr has quit [Read error: Connection reset by peer]
aef has quit [Ping timeout: 240 seconds]
deepredsky has quit [Ping timeout: 268 seconds]
Beams has quit [Quit: .]
Guest70176 has quit [Ping timeout: 240 seconds]
Serpent7776 has quit [Quit: Leaving]
mim1k has quit [Disconnected by services]
mim1k_ has joined #ruby
<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".
milardovich has quit [Remote host closed the connection]
milardovich has joined #ruby
milardovich has quit [Remote host closed the connection]
<leitz>
Still getting a NoMethodError for class Noble.
Cohedrin has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
vondruch has quit [Ping timeout: 268 seconds]
John__ has quit [Ping timeout: 240 seconds]
<leitz>
Latest code pushed up.
mson has joined #ruby
cdg has joined #ruby
cdg has quit [Ping timeout: 255 seconds]
raynold has joined #ruby
rmhonji has joined #ruby
gregf_ has joined #ruby
mark_66 has quit [Remote host closed the connection]
ShekharReddy has quit [Quit: Connection closed for inactivity]
Ambassador has quit [Ping timeout: 252 seconds]
<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
<havenwood>
leitz: you can get rid of `module_function` if you want to use it the way you've shown
<leitz>
The goal is to be able to call <career_name>.update_character. Which was why I had it as a class, for inheritance.
char_var[buffer] has joined #ruby
danielpclark has joined #ruby
herbmillerjr has quit [Remote host closed the connection]
Rouge has joined #ruby
deadpoet has joined #ruby
<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 []"
mim1k_ has quit [Ping timeout: 248 seconds]
<apeiros>
uh, where did you put the public?
<leitz>
Different errors is progress. :)
nopolitica has joined #ruby
<apeiros>
if you keep your gist up to date, it'd be easier
<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.
Rouge has quit [Read error: Connection reset by peer]
bmurt has joined #ruby
<apeiros>
leitz: if you want it public, you almost certainly don't want it to be a module_function
<apeiros>
and in that case, you can just save yourself those two calls (module_function and public)
eightlimbed has joined #ruby
<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.
nopolitica has quit [Ping timeout: 240 seconds]
Rouge has joined #ruby
<apeiros>
a public module_function usually isn't decent
milardovich has joined #ruby
claudiuinberlin has joined #ruby
<leitz>
Working code with a public module_function is more decent than non-working code. :)
<apeiros>
I'm not quite sure what part you don't understand
<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.
<apeiros>
you can have more decent, AND working, AND less code, all for the price of ONE: removing both public and module_function
Ambassador has joined #ruby
<apeiros>
(the "working" part of course depends on "private" being the only reason it didn't work)
milardovich has quit [Ping timeout: 268 seconds]
QualityAddict has joined #ruby
<leitz>
private wasn't the only reason. :)
<apeiros>
then putting "public" in front of it won't fix it anyway.
<leitz>
Since Career became a module, and not a parent class, the @character stuff fails.
<apeiros>
which implies skill_options is nil
<leitz>
Yup.
<leitz>
That's the NilClass in the gist.
vtx has quit [Quit: vtx]
<apeiros>
skill_options = … assigns a local variable
<apeiros>
you don't do anything with it except printing it
<apeiros>
it'll be gone right after build_skill_options. I suspect that's not what you intend it to do.
mikecmpbll has quit [Ping timeout: 240 seconds]
<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.
<leitz>
Well, down in like 66 it's supposed to be set from calling build_skill_options.
char_var[buffer] has joined #ruby
<apeiros>
yeah, ^
<leitz>
Right, but it was failing before the puts.
<apeiros>
pretty sure not with the same exception.
<leitz>
Hate to dissappoint you, but yup.
<apeiros>
or then again, maybe it did
<apeiros>
since your puts says "NilClass" :D
larcara has quit [Remote host closed the connection]
<apeiros>
so your stuff goes wrong before that already.
<leitz>
The @skill_optiions seems the issue.
<leitz>
They worked when Career was a class.
larcara has joined #ruby
<leitz>
Now it is a module included by Noble. Don't seem to work as they are not being set.
<RickHull>
leitz: the aesthetics look much better now, at least. follows ruby conventions :)
<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.
<leitz>
RickHull, you should look at muster_out. Much shorter. :)
<apeiros>
iow, you probably want to initialize @skill_options in the Noble class
<RickHull>
are you working on the career_call_character branch now?
<apeiros>
also, you should not access foreign instance variables. use methods for that.
<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
<apeiros>
>> module Foo; end; class Bar; include Foo; end; Bar.new.is_a?(Foo)
<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.
<RickHull>
what are the main parts of a career?
<apeiros>
(instance_of? checks whether it is an instance of the given class, is_a?/kind_of? test ancestry)
<RickHull>
let's pick a good career example Knight?
<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.
<leitz>
Career Noble.
<RickHull>
ok, so Character Jim has class Bard and career Noble?
<RickHull>
something like that?
<leitz>
You guys should play Traveller some time. :)
<apeiros>
if I had spare time…
troys is now known as troys_
<leitz>
Character Jim has a career of Noble.
<apeiros>
I assume traveller is some D&D style game?
<leitz>
Character Jane has a career of Citizen.
kickr has joined #ruby
<RickHull>
the design that pops into my head is to use composition. literally character has-a career
<apeiros>
+1
deepredsky has joined #ruby
<leitz>
apeiros, yes, but SciFi. One of the original Role-playing games and it lends itself very well to coding. Assuming I could code...
jaruga has quit [Quit: jaruga]
<RickHull>
@career = Noble # perhaps -- a module reference
<apeiros>
jim = Character.new(career: :citizen); jim.career # => Careers::Citizen
<RickHull>
and each career has some methods -- a common interface
<apeiros>
well, #<Careers::Citizen …> really
dionysus69 has joined #ruby
larcara has quit [Ping timeout: 240 seconds]
<RickHull>
and when you call jim.foo -- the result is based on jim's attributes modified by the career
<leitz>
RickHull, sounds good. I know very little about design and patterns. Keep typing, I'm taking notes.
moei has quit [Quit: Leaving...]
<RickHull>
foo would do stuff based on jim's ivars, and also modify them based on calling module methods
bmurt has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<RickHull>
do it all on-the-fly, worry about optimizing performance later
<leitz>
Hang on a sec, I'll add to the gist to show the output when things work.
<RickHull>
if you want to cache the results of career modifications
<apeiros>
leitz: though it seems to me like careers are more like providing initial values for characters + how they'll level up?
<apeiros>
btw., are you still restricted to ruby 1.8? (your project's README says so)
<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
<leitz>
Class Character provides the initial values, Career levels them up.
<RickHull>
so Jim-the-Noble, what are some good examples of inherent attributes that the career then modifies?
<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
deepredsky has quit [Ping timeout: 248 seconds]
<RickHull>
and do it with expressions, not assignment
<leitz>
apeiros, I'm now using 2.5.0. The readme is old.
<apeiros>
great
<RickHull>
def skill; @career.modify(@skill); end
<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 :)
<apeiros>
you store Character instances in the databse, did I get that right?
<leitz>
RickHull, the data will go into various output formats, like SQL, Monggo, json.
FahmeF has quit [Remote host closed the connection]
<RickHull>
now, i may be barking up the wrong tree -- i'm certainly oversimplifying
TomyWork has quit [Ping timeout: 240 seconds]
<RickHull>
what's a basic example of how a career modifies e.g. a cash attribute?
<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.
<RickHull>
I would express this -- probably -- as making most of the class definition having to do with an existing character
<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.
eightlimbed has joined #ruby
<RickHull>
and then a class method on character named generate -- Character.generate(*args)
<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
<RickHull>
and Character.generate to roll a new Jane
<RickHull>
Character.generate would do a bunch of dice rolls and come with the args to then call Character.new
<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.
<RickHull>
has to do with leveling up -- and?
larcara has joined #ruby
<leitz>
I had a Character.run_career method but thought it might be better as something like "Noble(Character)"
jottr has quit [Ping timeout: 260 seconds]
tacoboy has quit [Remote host closed the connection]
<apeiros>
though given the complexity, I'd probably create a full Character::Generator class and wrap that in Character.generate
<RickHull>
sure -- though I would just leave that as an escape valve
<RickHull>
my usual approach is to stuff everything into a giant bag, make it basically work
<RickHull>
and then refactor to something nicer
<RickHull>
rather than imagine a big hierarchy up front
ramfjord has joined #ruby
<apeiros>
I usually do put a few minutes into considering an architecture. but a couple of stuff usually changes while writing.
<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.
guille-moe has joined #ruby
<RickHull>
leitz: i would keep that as a milestone
<RickHull>
keep it in mind. but maybe limit the scope initially
milardovich has joined #ruby
<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. ;)
<RickHull>
for example, maybe later you can transform careers into yaml definitions later
<leitz>
Already works.
guacamole has joined #ruby
<leitz>
In the master branch, anyway. :)
<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
<RickHull>
so I like to make the cake rock-solid, and then ice it
<RickHull>
(so to speak)
<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
<gizmore>
leitz: rename the method to "apply/change"Foo?
<gizmore>
modify / adjust... :P
<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.
<apeiros>
leitz: generally in OO, you want to only mutate the receiver of a method
<gizmore>
leitz: why should changing an instance being a bad habit?
<gizmore>
thx apeiros
blackmesa has quit [Ping timeout: 240 seconds]
<leitz>
gizmore, the way I'm changing it.
<leitz>
So, if you run a character instance through a career, the character is modified. Skills, etc.
danielpclark has quit [Ping timeout: 240 seconds]
<apeiros>
yeah, sounds fine
<leitz>
apeiros, in that line is character the reciever?
<RickHull>
leitz: forget the code for a sec -- what's a concrete example of how a career affects a character?
<gizmore>
yeah--- i have the same. the skill type change the char
<apeiros>
leitz: yes. the thing to the left of the dot.
<apeiros>
receiver.method(argument) { block }
tomphp has joined #ruby
<RickHull>
leitz: is there a time component? does the career or char know that 10 years has passed?
<apeiros>
and if you just do `method(argument) { block }` (where arguments and block are optional of course), then `self` is the receiver.
<RickHull>
or is it more "tick" based -- character.yearly_update
<RickHull>
character.level_up
guacamole has quit [Quit: My face has gone to sleep. ZZZzzz…]
<apeiros>
ok, so a char doesn't have a career, you apply one to it, and that modifies their stats + skills + advanced skills?
<leitz>
RIckHull, ivar is instance varialbe? Or something else?
<apeiros>
and skills are replaced, not added if I got that right
nopolitica has joined #ruby
<RickHull>
yes, as in `attr_reader :strength`
milardovich has quit [Ping timeout: 248 seconds]
ldepandis has joined #ruby
<leitz>
apeiros, a character has served in a career, like we do. But a career is not a thing.
<RickHull>
or def initialize(str, dex, end); @strength = str ...
<leitz>
Skills are added. If a person has a high Edu then they can learn Advanced Skills.
<apeiros>
ok
<leitz>
That's the skill_options array.
<leitz>
And it is an array, not a set, as some skills are more likely than others, based on career.
<leitz>
Army people shoot more. :)
<apeiros>
but the added skill is random, or can be random
<leitz>
Is random.
<RickHull>
i would add a hash key for every added skill
<leitz>
Educated people can get skills from either list.
<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
<leitz>
RickHull, already done. :)
x77686d has joined #ruby
<leitz>
apeiros, number of skills is based loosely on terms served.
<apeiros>
e.g. {Skill1: 1, Skill2: 2, Skill3: 1}, where Skill2 is twice as likely to happen compared to Skill1 and Skill3
<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.
tlaxkit has quit [Remote host closed the connection]
tlaxkit has joined #ruby
tlaxkit has quit [Max SendQ exceeded]
nopolitica has quit [Ping timeout: 268 seconds]
<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.
<leitz>
And I can bask in the glory of a heavily reduced "muster_out" method.
danielpclark has joined #ruby
lupine has quit [Remote host closed the connection]
ramortegui has quit [Quit: This computer has gone to sleep]
Rouge has quit [Remote host closed the connection]
<apeiros>
hm, I should cleanup my backup-inception. I have a weighted sample lying around somewhere
Rouge has joined #ruby
<apeiros>
though I guess I can just rewrite it…
ams__ has quit [Quit: Connection closed for inactivity]
mikecmpbll has joined #ruby
vtx has joined #ruby
<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
<pecan>
Don't eat me please leitz :o
<leitz>
*burp*
Guest70176 has joined #ruby
mcr1 has quit [Ping timeout: 252 seconds]
Dimik has joined #ruby
muelleme has joined #ruby
<leitz>
You guys really should try Traveller. Pretty easy and lots of things to code about.
larcara has quit [Remote host closed the connection]
exhiled has joined #ruby
<wmoxam>
leitz: what's that?
<leitz>
wmoxam, one of the earliest pen and paper role playing games.
larcara has joined #ruby
<leitz>
And the source of most of my coding efforts.
<RickHull>
and only Character.generate will create a new character with generated values
<leitz>
The initialize takes the exisitng data provided.
<RickHull>
in your version, where is @upp initialized?
<leitz>
Line 14 in generate.
<RickHull>
oh duh, sorry
<leitz>
Currenly as a string, will move to hash after the after big meal nap.
<RickHull>
sorry, what I meant was: your version allows to initialize a character without an :upp
exhiled has joined #ruby
<RickHull>
and when you call character.generate, it will be generated conditionally
David_H_Smith has quit [Remote host closed the connection]
<RickHull>
so you are mixing the concepts of a fully realized character vs generating a new one
<RickHull>
my version separates them completely
<RickHull>
you can only call Character.new with fully realized values
<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.
blackmesa has joined #ruby
<RickHull>
it's cleaner to just generate a fully realized character when a new one comes up
<RickHull>
if all you need is a name, then just represent the fake char with their name string
<leitz>
Actaully, you can call Character.new with nothing, and then generate en masse or add bit by bit.
dionysus69 has quit [Quit: dionysus69]
<RickHull>
I think this mixing of concerns causes complications in the code built on top
<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
<leitz>
That's why I want to keep Careers separate. So a Character can be used by itself.
<RickHull>
I would make a different class for NPCs
<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?
<RickHull>
perhaps both derive from the same base class
cschneid_ has joined #ruby
<RickHull>
NPC concerns are quite distinct from P concerns
<RickHull>
er, PC concerns :)
larcara has joined #ruby
<leitz>
vtx, are you actually trying to connect?
<RickHull>
the app wants to connect -- the test wants the app not to connect
<leitz>
RickHull, I have a really bad habit of promoting minor charcters to full blown heroes.
<RickHull>
leitz: sure, you can accomodate that -- just create a PC from NPC attributes
<vtx>
leitz: i don’t want the database connection to happen during my tests
<leitz>
Like, dozens. Easier to treat everyone the same.
<vtx>
i want to mock out the responses
jaruga has joined #ruby
<RickHull>
but trying to have do-all wonder-class that accomodates all concerns -- I'm skeptical
<leitz>
vtx, ah. Gotcha. I'm not that good with Rspec.
<vtx>
neither am i haha
<leitz>
RickHull, that's why I'm going to use a MongoDB backend. I can add fields as needed as characters develop.
<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
milardovich has quit [Ping timeout: 260 seconds]
<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
<leitz>
RickHull, Both PC and NPC grow backstories as I go along. No real differentiation.
<RickHull>
and if all NPCs *should* be fully realized -- then don't try to generate stuff on the fly
<RickHull>
you will have bugs
<leitz>
vtx, I would, at least at first. I code poorly and that would be expensive but test me often.
<RickHull>
for example, you pass around hashes and forget to include a field. you will want an error here
<RickHull>
but instead it will get silently autogenerated
x77686d has quit [Quit: x77686d]
<leitz>
RickHull, that's why Character.generate must be called separately.
<leitz>
No autogeneration unless I tell it to.
larcara has quit [Ping timeout: 260 seconds]
<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?
Tim_F_Croso has joined #ruby
<RickHull>
well @upp only gets assigned in #generate
<RickHull>
it sure looks like you have to call #generate to get an @upp
<leitz>
RickHull, unless the call to Character.new includes a data set with the upp.
<RickHull>
where does @upp get assigned in that case?
<leitz>
It will get pulled from the database as soon as I get that far. DId you look at the python/bottle stuff?
<leitz>
Same idea.
<RickHull>
hang on, i call Character.new(upp: stuff)
<RickHull>
@upp will not exist at that point
<RickHull>
it only comes into being with Character.new(upp: stuff).generate
<RickHull>
you've written #generate to be the place where the hash becomes ivars
<leitz>
Being called to the table. I'll test and answer that in a bit.
<RickHull>
yep, i gotta run
<RickHull>
cheers!
conta1 has quit [Remote host closed the connection]
milardovich has joined #ruby
larcara has joined #ruby
zautomata1 has quit [Ping timeout: 248 seconds]
milardovich has quit [Ping timeout: 268 seconds]
zautomata1 has joined #ruby
ensyde has joined #ruby
alan_w has joined #ruby
Guest59285 has joined #ruby
<havenwood>
an easter egg if you have the computing power:
kapil___ has quit [Quit: Connection closed for inactivity]
nopolitica has quit [Ping timeout: 255 seconds]
troulouliou_div2 has joined #ruby
x77686d has joined #ruby
<c-c>
Would the key be a string or a symbol?
Xeago has quit [Ping timeout: 248 seconds]
Guest70176 has joined #ruby
blackmesa1 has joined #ruby
muelleme has quit [Ping timeout: 246 seconds]
blackmesa has quit [Read error: Connection reset by peer]
Xeago has joined #ruby
ramortegui has quit [Quit: This computer has gone to sleep]
<apeiros>
leitz: there's instance_variable_set, which is used like: instance_variable_set(:"@foo", value)
John___ has quit [Read error: Connection reset by peer]
Guest70176 has quit [Ping timeout: 248 seconds]
<apeiros>
though often when you do that you should probably either use a Struct or a Hash directly.
sunrunner20 has joined #ruby
tomphp has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
danielpclark has joined #ruby
tomphp has joined #ruby
tomphp has quit [Client Quit]
tomphp has joined #ruby
tomphp has quit [Client Quit]
tomphp has joined #ruby
tomphp has quit [Client Quit]
deepredsky has joined #ruby
tomphp has joined #ruby
eightlimbed has quit [Ping timeout: 240 seconds]
ur5us_ has joined #ruby
eightlimbed has joined #ruby
Cohedrin has joined #ruby
lexruee has joined #ruby
deepredsky has quit [Ping timeout: 248 seconds]
ur5us has quit [Ping timeout: 268 seconds]
FahmeF has joined #ruby
ramortegui has joined #ruby
milardovich has joined #ruby
jenrzzz has joined #ruby
FahmeF has quit [Ping timeout: 268 seconds]
Cohedrin has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
jamesaxl has quit [Read error: Connection reset by peer]
milardovich has quit [Remote host closed the connection]
jamesaxl has joined #ruby
LocaMocha has joined #ruby
jaruga has quit [Quit: jaruga]
<RickHull>
leitz: yep -- if it seems like my code is doing much of what yours is/was, but slightly differently, that's on purpose :)
<RickHull>
i definitely think there is a win in separating character generation from having a realized character
<RickHull>
you don't want missing attributes to be silently generated instead of causing an error
<RickHull>
i love errors :)
<RickHull>
(I hate hiding them)
ramortegui has quit [Quit: This computer has gone to sleep]
mim1k has joined #ruby
<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
x77686d has quit [Quit: x77686d]
<RickHull>
let's reduce the scope and make something rock solid first
drowze has joined #ruby
<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
<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"
<RickHull>
if there even is a spec or schema
<RickHull>
in the security world, there is the concept of rings. ring 1's functionality is based on having a rock-solid ring 0
<RickHull>
you could always make an uber-ring that combines the concerns of rings 1-4
sunrunner20_ has joined #ruby
<RickHull>
and there could be some small wins there. but likely huge losses
mim1k has quit [Ping timeout: 248 seconds]
<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
milardovich has joined #ruby
sunrunner20 has quit [Ping timeout: 260 seconds]
sunrunner20_ is now known as sunrunner20
<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
<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
nopolitica has joined #ruby
<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
<RickHull>
Character.generate is flexible. Character.new is not
<RickHull>
likewise, Character.new does not do any dice rolling. it assumes the character data has already been generated
<RickHull>
Character.generate enforces the dice rolls for upp generation
<RickHull>
but allows user-set values for plot, appearance, etc
ramortegui has joined #ruby
milardovich has quit [Ping timeout: 260 seconds]
muelleme has joined #ruby
sunrunner20 has quit [Quit: So Long and Thanks for All the fish]
nopolitica has quit [Ping timeout: 248 seconds]
quobo has joined #ruby
sunrunner20 has joined #ruby
Guest70176 has joined #ruby
muelleme has quit [Ping timeout: 260 seconds]
jenrzzz has quit [Ping timeout: 240 seconds]
Guest70176 has quit [Ping timeout: 240 seconds]
thinkpad has joined #ruby
MrSparkle has quit [Ping timeout: 260 seconds]
LocaMocha is now known as MochaLoca
cschneid_ has joined #ruby
MrSparkle has joined #ruby
miskatonic has quit [Remote host closed the connection]
danielpclark has quit [Ping timeout: 268 seconds]
milardovich has joined #ruby
Nicmavr has quit [Read error: Connection reset by peer]
cschneid_ has quit [Ping timeout: 248 seconds]
ShekharReddy has quit [Quit: Connection closed for inactivity]
enterprisey has joined #ruby
nowhere_man has joined #ruby
milardovich has quit [Ping timeout: 248 seconds]
biberu has quit []
rivalomega has quit [Remote host closed the connection]
eightlimbed has quit [Ping timeout: 240 seconds]
rivalomega has joined #ruby
John___ has joined #ruby
jenrzzz has joined #ruby
danielpclark has joined #ruby
vee__ has quit [Ping timeout: 258 seconds]
_sfiguser has quit [Quit: Leaving]
jenrzzz has quit [Ping timeout: 248 seconds]
Guest59285 has quit [Remote host closed the connection]
Dimik has joined #ruby
zapata has joined #ruby
jenrzzz has joined #ruby
jottr has quit [Quit: WeeChat 1.9.1]
vee__ has joined #ruby
<leitz>
apeiros, RickHull found a flaw in my logic. I'm working on it.
<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. :)
<weaksauce>
leitz there are no flaws in logic just unexpected features
<RickHull>
oh for sure
<RickHull>
leitz: i'm hooked on redoing your core -- stay tuned to my fork
<RickHull>
it's maybe worth playing around with already
<leitz>
Keep in mind I'm an "early to bed, early to rise" sort. :)
axsuul has quit [Ping timeout: 250 seconds]
<RickHull>
leitz: want to try it out?
<leitz>
yup.
<RickHull>
ok, go to a new dir, so you can clone my fork
<leitz>
Same repo?
<RickHull>
or if you're good with git, then you can add my fork as a remote
<RickHull>
but for simplicity, just e.g. mkdir ~/tmp; cd ~/tmp