solnic changed the topic of #rom-rb to: Ruby Object Mapper | Mailing List: https://groups.google.com/forum/?fromgroups#!forum/rom-rb | Logs: http://irclog.whitequark.org/rom-rb
<snusnu> the key thing here, is that an axiom schema knows *nothing* about databases, database names, drivers .. *nothing* .. it only knows (base)relations .. the knowledge, which base relations belong to which physical database, is handled elsewhere, axiom-schema basically only supports functional update, allowing you to use #connect to get a "RA compatible" schema instance back, but this time with physically backed relations
lfox has joined #rom-rb
<snusnu> so you describe your app's schema, and for tests, you might just connect every relation in it to the memory adapter, and in production you might connect some to postgres, some to mysql and some to mongo, whatever
<snusnu> such an app would define 3 database instances, one for each of the above mentioned databases .. it'd initialize those instances with the respective adapters, and those instances would know a mapping of logical (schema) names, to actual backend base relation names .. when production boots up, it'd transform the (logical) schema into a physical one, with gateway relations for all the 3 databases
<snusnu> when tests boot up, it'd transform the logical schema into a physical one, with all relations being gateways for the memory adapter
<snusnu> when it's deployed to a different database, it wouldn't need to change, it'd only need a new database class in your app, that'd know how to "install" the schema on that new backend
<dkubb> btw, I wouldn't use the logical/physical distinction too much in this context
<snusnu> yeah, i know, i'm sloppy here
<snusnu> but i think you know what i mean?
<dkubb> physical schema, in terms of databases, means the actual filesystem layout
<dkubb> yeah
<snusnu> yup, i'm aware of that
<snusnu> maybe we can use axiom schema and backend schema
<snusnu> as names i mean
<snusnu> when talking about it
<snusnu> or even, relation schema, and database schema
<snusnu> btw, we can of course easily provide an Axiom::Database class along with subclasses for the supported databases .. you'd instantiate such an instance in your app, and tell it which axiom schema relation (names) it should handle
<snusnu> and then you use that instance, to retrieve a new schema instance, with the respective relations backed by that database
cored has quit [Read error: Connection reset by peer]
<snusnu> dkubb: an initial client code spike: http://pastie.org/8524204
<dkubb> snusnu: I've got an alternative for that, but I can't share it now
<dkubb> I mean I can't share the code
<snusnu> dkubb: here's an alternative using instances: http://pastie.org/8524218
<snusnu> dkubb: meh, it should've included the schema, here: http://pastie.org/8524221
<snusnu> of course, all method/class names subject to change
<snusnu> dkubb: can't share, as in no time, or can't share because it's private?
<dkubb> no time
<snusnu> good ;)
<snusnu> fwiw, this updated http://pastie.org/8524235 does away with passing the schema to the database instance as that's not needed/desired at all
cored has joined #rom-rb
cored has joined #rom-rb
<snusnu> dkubb: another DSL, same idea: http://pastie.org/8524266
<dkubb> it's probably bikeshedding, but I'd probably use schema[:people] instead of schema.get(:people)
<dkubb> this will be consistent with the adapter interface
<dkubb> one approach I was going to take is have the adapter#[] return any base relations it knows about, which will probably be reflected from the underlying database
<snusnu> dkubb: yeah of course, #[] instead of #get .. no idea why i used #get, probably because we were talking about *get* on skype, because *[]* is hard to pronounce :p
<dkubb> heh
<dkubb> "element reference" is hard to say
<snusnu> hah, i didn't think about this one even, you know, on skype, we actually talk german ;)
<snusnu> while in irc (private also) we talk english .. it's funny
<snusnu> dkubb: when discussing code, english feels more natural, but that only works in a written medium .. when we're actually talking, it's too awkward to not use our mothertongue ;)
<snusnu> even then tho, we oftentimes have to drop "down to" english ;)
<cored> hello
<snusnu> hey cored
<cored> snusnu: hi
<cored> I'm also experimenting using [] for instantiation of my collection wrappers
<cored> found that very pleasent for the eyes
<dkubb> I like using it for "lookup"
<dkubb> I use Hash[] sometimes, but I don't find it particularly pleasing
<snusnu> yeah me too, i even find it weird when used to #call lambdas
<dkubb> I think of #call and #[] as the same thing when they accept an argument
<snusnu> i haven't made it that far yet, i'm happy to always call #call by its name :)
<dkubb> #call is a function that maps some input to some output based on the state of the object you're calling it on
<snusnu> dkubb: anyways, do you dig the core idea behind that schema api?
<cored> what do you mean by lookup
<cored> ?
<cored> like #fetch ?
<snusnu> cored: array indexing or hash key lookup
<snusnu> yeah
<cored> oh
<cored> maybe it could be confusing having that method to be a factory method
<snusnu> altho i guess dkubb would extend that definition a bit
<cored> but I thought that having something like Collection[%w|a b c d|]
<cored> looks good
<cored> to instantiation
<dkubb> snusnu: yeah, I think so. I'll think about it a bit more tonight
<snusnu> cored: tbh, i'd leave the realm of instantiation to its "natural" habitants .. the likes of new,build,coerce and so on .. but really, it's a matter of taste i guess, not saying one or the other is the right thing to do .. altho it might surprise a few readers of the code, given that instantiation typically doesn't use #[] .. apart from that awkward Hash[]
<snusnu> dkubb: cool, fair enough
<dkubb> yeah, I would use .new as the general constructor usually
<snusnu> dkubb: btw, i locally have functional AST evaluators that construct a complete axiom-schema from an ast already
<dkubb> I try to keep an interface as natural as I can. you want someone who has not read the docs to be able to read the code and get the gist of what it's trying to do based on the class and method names used
<snusnu> dkubb: i'll do some *minor* refactorings for it to be inline with that recent idea, and then push it up
<cored> snusnu: did not think that much, but you are correct on the reading part
jordanyee has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
lgierth has quit [Quit: Ex-Chat]
cored has quit [Ping timeout: 272 seconds]
cored has joined #rom-rb
lfox has quit [Quit: ZZZzzz…]
cored has quit [Ping timeout: 264 seconds]
Guest___ has joined #rom-rb
Guest___ is now known as jordanyee
snusnu has quit [Quit: Leaving.]
snusnu1 has joined #rom-rb
jgaskins has quit [Quit: This computer has gone to sleep]
dkubb|away has joined #rom-rb
dkubb has quit [Ping timeout: 260 seconds]
snusnu1 has quit [Quit: Leaving.]
jordanyee has quit [Quit: Textual IRC Client: www.textualapp.com]
dkubb|away has quit [Quit: Linkinus - http://linkinus.com]
lfox has joined #rom-rb
dkubb has joined #rom-rb
lfox has quit [Quit: ZZZzzz…]
kalleth_ has quit [Read error: Connection reset by peer]
kalleth has joined #rom-rb
zekefast has joined #rom-rb
mbj has joined #rom-rb
zekefast has quit [Quit: Leaving.]
mbj has quit [Ping timeout: 264 seconds]
mbj has joined #rom-rb
skade has joined #rom-rb
zekefast has joined #rom-rb
snusnu1 has joined #rom-rb
jfredett-w1 has joined #rom-rb
jfredett-w has quit [Ping timeout: 265 seconds]
zekefast has quit [Quit: Leaving.]
snusnu1 has quit [Quit: Leaving.]
kleech has joined #rom-rb
snusnu1 has joined #rom-rb
snusnu1 has quit [Client Quit]
postmodern has quit [Quit: Leaving]
snusnu has joined #rom-rb
cored has joined #rom-rb
snusnu has quit [Quit: Leaving.]
snusnu has joined #rom-rb
zekefast has joined #rom-rb
<snusnu> yo mbj
zekefast has quit [Quit: Leaving.]
kleech has quit [Remote host closed the connection]
<mbj> snusnu: yo and busy ;)
<mbj> snusnu: gonna close IRC to make sure I finish commercial stuff
mbj has quit [Quit: leaving]
kleech has joined #rom-rb
kleech has quit [Remote host closed the connection]
kleech has joined #rom-rb
travis-ci has joined #rom-rb
travis-ci has left #rom-rb [#rom-rb]
<travis-ci> [travis-ci] rom-rb/rom-session#89 (master - 2b2a308 : snusnu): The build has errored.
<travis-ci> [travis-ci] Build details : http://travis-ci.org/rom-rb/rom-session/builds/14864329
breakingthings has joined #rom-rb
kleech has quit [Remote host closed the connection]
CraigBuchek has joined #rom-rb
jgaskins has joined #rom-rb
zekefast has joined #rom-rb
mkristian has joined #rom-rb
snusnu has quit [Quit: Leaving.]
lfox has joined #rom-rb
snusnu has joined #rom-rb
cored has quit [Ping timeout: 264 seconds]
cored has joined #rom-rb
jordanyee has joined #rom-rb
zekefast has quit [Quit: Leaving.]
zekefast has joined #rom-rb
skade has quit [Quit: Computer has gone to sleep.]
dkubb has quit [Quit: Linkinus - http://linkinus.com]
zekefast has quit [Quit: Leaving.]
zekefast has joined #rom-rb
zekefast has quit [Client Quit]
CraigBuchek has quit [Quit: Leaving.]
cbuxton_ has quit [Ping timeout: 240 seconds]
jordanyee has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
cbuxton_ has joined #rom-rb
snusnu has quit [Quit: Leaving.]
snusnu has joined #rom-rb
CraigBuchek has joined #rom-rb
mbj has joined #rom-rb
mbj has quit [Read error: Operation timed out]
mbj has joined #rom-rb
<mbj> snusnu: hi
<snusnu> yo mbj
<snusnu> mbj: does this "sum up" our discussion re axiom-schema? http://pastie.org/8526244
mkristian has quit [Quit: bye]
postmodern has joined #rom-rb
<mbj> snusnu: later
<mbj> snusnu: cannot access current teams jabber server
<mbj> snusnu: For some reason
<mbj> snusnu: We had a netsplit and I'm the only one who cannot reconnect.
<mbj> very very very strange.
dkubb has joined #rom-rb
<mbj> snusnu: cannot find it.
<mbj> snusnu: Super strange!
<mbj> snusnu: persists reboot, network location changes, etc.
<mbj> snusnu: need to check against an "open" jabber server.
skade has joined #rom-rb
jgaskins has quit [Ping timeout: 272 seconds]
breakingthings has quit []
jgaskins has joined #rom-rb
snusnu has quit [Quit: Leaving.]
mbj has quit [Ping timeout: 260 seconds]
skade has quit [Quit: Textual IRC Client: www.textualapp.com]
mbj has joined #rom-rb
zekefast has joined #rom-rb
breakingthings has joined #rom-rb
lfox has quit [Quit: ZZZzzz…]
lfox has joined #rom-rb
jgaskins has quit [Quit: This computer has gone to sleep]
lfox has quit [Quit: ZZZzzz…]
<mbj> postmodern: This use case in gitorious does NOT need /bin/sh (Kernel#`)
<mbj> postmodern: Kernel.exec(*args) uses execve directly without having to defend with shellwords.
<mbj> postmodern: Okay you'd need to setup a pipe in a fork for yourself and create a string for it. But there are good libs for this.
<mbj> postmodern: I hate it when people use Kerne#` when its not needed. Creating a problem to solve it :(
<postmodern> mbj, yeah they should use popen
<postmodern> mbj, or just use one of the Git libraries instead of shelling out
<mbj> postmodern: args = %W(#{Gitorious.git_binary} --git-dir=#{git_dir} log --graph --pretty=#{pretty_format}).concat(options) << branch
<mbj> postmodern: Kernel.exec(*args) is 100% guaranteed to be injection free.....
<postmodern> mbj, yep, well you still have to use separate args, otherwise you'll get option injection
<mbj> postmodern: nope
<mbj> postmodern: irb(main):003:0> bar = "injectio; foo"; %W(--foo#{bar})
<mbj> => ["--fooinjectio; foo"]
<mbj> postmodern: With %W its the literal whitespace in the outside expression. Whitespace from interpolation goes to the corresponding element.
<mbj> postmodern: *its the literal whitespace in the %W expression that delimits members, not the value of the interpolated expressions.
<postmodern> mbj, i mean option injection
<postmodern> mbj, *['command', '--option', user_input]
<mbj> postmodern: got it.
<mbj> postmodern: that one. thout only about the flag value.
<mbj> postmodern: %W(command --flag --other-flag -- #{user_value}" ?
<mbj> postmodern: so "--" should help IMHO.
<postmodern> mbj, that should work
<mbj> postmodern: But still Kernel.exec should be prefered over Kernel#´ because you "only" have to deal with option injection.
<mbj> postmodern: With Kernel#` you also have to fight shell.
<mbj> postmodern: You created a lib for wrapping cli tools into ruby api?
<mbj> postmodern: Does it use Kernel.exec(*args) internally? And allows to capture output via pipe as a string?
<postmodern> mbj, yeah
<mbj> preferably stderr and stdout.
<postmodern> mbj, rprogram, been meaning to rewrite it using virtus
<mbj> nice
<mbj> postmodern: Dont forget to tweet once ready.
<mbj> postmodern: Why virtus, for coercions?
<postmodern> mbj, that way virtus would enforce type coercion for the inputs
breakingthings has quit []
<postmodern> mbj, preventing someone from submitting a String for a Float value
<mbj> postmodern: virtus is not really good in "enforcing" type coercions.
<mbj> postmodern: Still better than nothing but IMHO allos to much coercion vektors.
<mbj> *allows
<postmodern> mbj, by enforce i guess i mean just coercion inputs
<postmodern> mbj, "hello".to_f => 0.0
<mbj> class Foo; include Virtus; attribute Integer, :bar; end; Foo.new(:bar => '10e10').bar # => 100000000000
<mbj> Such very "wide" range of coercions, for example accepting sci notation, is to much IMHO.
<mbj> postmodern: Why do you plan to coerce stuff people submit, at all?
<mbj> postmodern: Just raise if the type does not fit. It should be the API users reponsibility to coerce.
<postmodern> mbj, it's handy for certain types of options that allow repetition
<postmodern> mbj, or certain options that are always Hashes
<mbj> postmodern: Why shouldnt the user provide hashes?
<postmodern> mbj, previously I had to write all my own coercion code by hand
<mbj> map = MyCLIWrapper.build { executable 'foo'; flag '--bar', :type => :integer }
<mbj> map.call(:bar => 1) # works
<mbj> map.call(:bar => "1") # raises
<postmodern> mbj, i prefer to coerce so it "just works" tm
<postmodern> mbj, but really everything get's converted down to Strings before being executed
<mbj> postmodern: I dislike this kind of bugs that occur with implicit coercions.
<mbj> postmodern: the caller should provide type compatible values. If not raise.
<mbj> postmodern: Checking types can easily be dslified.
<mbj> my 2¢
<mbj> Will happily play around with your new wrapper once ready ;)
<mbj> postmodern: Is you wrapper able to capture both, stderr and stdout?
<postmodern> well i never got around to finishing the complex logic that converts all the attributes to [option, *values] lists, but also could run them through Shellwords.shelljoin
<mbj> postmodern: you need a structured type mapper like ducktrap for this ;)
<postmodern> so it's kind of moot to debate about the design of the code
<mbj> heh, np lets stop and focus on stderr and stdout
<mbj> what if stderr and stdout are in "sync" mode. Means they need to be consumed before writer can write again.
<mbj> How do you "read from both" at the same time without blocking / running into a deadlock.
snusnu has joined #rom-rb
<mbj> I have some code in a simillar wrapper that usese select.
<mbj> *uses select
<mbj> To make sure I dont do a blocking read on stderr, while there is only data on stdout (and vice versa).
<mbj> snusnu, going to sleep, sorry will read that pastie tomorrow
<mbj> postmodern: cu
mbj has quit [Quit: leaving]
<postmodern> too many people talking at once :)