Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Gempact Ruby FTW

Avatar for troy troy
October 29, 2014

Gempact Ruby FTW

Avatar for troy

troy

October 29, 2014

Other Decks in Programming

Transcript

  1. • First held in 2007 • 1-4 Developers • 48

    hours • Ruby based Rack framework http://railsrumble.com
  2. • Heroku app provided for deployment • GitHub Repo provided

    for optional use • Free access to some paid Heroku add-ons http://railsrumble.com
  3. • Judged by competitors • Must have submitted an app

    to judge • Favorite and rank up to ten apps • General public can also “favorite” an app • Judging period is 7 days following end of competition http://blog.railsrumble.com/rules/
  4. • Ten Overall Winners • computed from competitors’ favorite lists

    • Best Solo Award • Public Favorite http://blog.railsrumble.com/rules/
  5. And other gems depend on those gems And yet more

    gems depend on the gems that depend on gems, and still other gems depend on those gems…
  6. But I’m not sure I could write the SQL to

    reverse all the dependencies.
  7. SELECT gems.dependencies FROM gems WHERE gems.name = 'activesupport' AND INCLUDE

    TRANSITIVE DEPENDENCIES PLEASE; This is just not a question you can easily ask a RDBMS
  8. *This is a speculative complaint, of course. We don’t know

    how long it would take because it sounded too painful to even write the query. We’re not saying RDBMSes are slow in general, but the part about transitive dependencies would definitely be a problem. How long would the query take*?
  9. But first we have to get the raw data. We

    can get a list of all the gems from rubygems.
  10. RubyGems Index • http://rubygems.org/specs.4.8.gz • Gzipped and Marshalled ruby object

    • ["activerecord", #<Gem::Version "4.1.2">, "ruby"] https://blog.engineyard.com/2014/new-rubygems-index-format
  11. Next we need the Gem Specs for each gem. We

    have to get them one by one from the rubygems API. There are about 90k gems in rubygems.
  12. Our data is a bunch of interconnected nodes. Graph databases

    store data as a bunch of interconnected nodes.
  13. No “impedance mismatch*” *I have no idea what impedance actually

    is The way our data actually looks: The way our data is stored in the database:
  14. Works like activerecord • Ruby object represents a node in

    the database. • The object’s class represents the node’s “label” (e.g. User, RubyGem, Pickle) • Relationships between nodes (aka edges) work like AR relationships, but they also have a name and direction
  15. Pattern-matching “Using patterns, you describe the shape of the data

    you’re looking for.” // find first 5 dependents of the rails gem ! MATCH (rails:RubyGem { name: 'rails' }) MATCH rails<-[:depends_on]-(deps:RubyGem) RETURN rails, deps LIMIT 5;