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

twerkin' on j-rails

twerkin' on j-rails

Austin on Rails talk about tools and patterns for use with jruby/rails/java

Michael May

April 23, 2013
Tweet

More Decks by Michael May

Other Decks in Technology

Transcript

  1. twerkin’ (n) 1. to do your sh*t like a mutha

    fu*kin professional Today at my J-O-B I was twerkin’ it like a pro...all day, ery day source: “Lenny” on urbandictionary.com Wednesday, April 24, 13
  2. 1) Use big font 2) Use color 3) Use jokes/memes

    so people stay happy Wednesday, April 24, 13
  3. mmay ~/jruby-talk $ ls - jruby - tool chain for

    mvn/ruby/java - jruby/rails dev patterns - social connection service Wednesday, April 24, 13
  4. mmay ~/dev/.../rails [master] $ rails s Booted rails in 1.108

    Included bundled gems in 6.132 Loading java environment from /../../pom.xml Built effective-pom.xml in 0.0s Built build-classpath.txt in 0.0s Added java paths to $CLASSPATH in 0.056 Parsed effective-pom.xml in 0.863s JRuby Spring Services / is_rake=false Starting Spring with full context Spring started in 14.254 Loaded site settings in 0.208s Wednesday, April 24, 13
  5. use spork and guard to help mitigate startup time https://github.com/sporkrb/spork

    https://github.com/guard/guard Wednesday, April 24, 13
  6. MRI gets the love MRI == Matz Matz == Ruby

    God Wednesday, April 24, 13
  7. mmay ~/jruby-talk $ ls - jruby - tool chain for

    mvn/ruby/java - jruby/rails dev patterns - social connection service Wednesday, April 24, 13
  8. NameError: missing class or uppercase package name (`com.homeaway.reviews.mod el.Day') get_proxy_or_package_under_package

    at org/jruby/javasupport/JavaUtilities.java:54 method_missing at file:.../ jruby-1.7.3/lib/jruby.jar!/jruby/java/ java_package_module_template.rb:14 load at org/jruby/ RubyKernel.java:1046 Wednesday, April 24, 13
  9. mmay ~/jruby-talk $ ls - jruby - tool chain for

    mvn/ruby/java - jruby/rails dev patterns - social connection service Wednesday, April 24, 13
  10. module Foo java_import java.util.Date ... def bar date = Date.parse(date_string)

    Date.new(date.year, date.month, date.day) end end Wednesday, April 24, 13
  11. Model.create { name: “John”, coffee: “yes pls” } model.validate model.save

    model.save! Model.where(name: “John”) Wednesday, April 24, 13
  12. ReviewsClientImpl = Java::ReviewsClient::ReviewClientImpl review = Java::ReviewsApi::Review.new.tap do |r| r.setBody(params[:review][:body]) r.setRating(params[:review][:rating].to_i)

    r.setReviewer(params[:review][:reviewer]) end ReviewsClientImpl.write_review(property_id, unit_id, site, review) Wednesday, April 24, 13
  13. class Review include ActiveModel::Conversion include ActiveModel::Validations include ActiveModel::MassAssignmentSecurity extend ActiveModel::Naming

    # implement ActiveRecord-like interfaces # save, save!, create, create!, find, etc. end Wednesday, April 24, 13
  14. Review = Java::ReviewsApi::Review Review = double('Review') unless defined? Review Review.should_receive(:new).and_return(Review)

    Review.should_receive(:setBody) Review.should_receive(:setCountry) ... client.write_review(review) Wednesday, April 24, 13
  15. mmay ~/jruby-talk $ ls - jruby - tool chain for

    mvn/ruby/java - jruby/rails dev patterns - social connection service Wednesday, April 24, 13
  16. { id: 1234, from_uuid: xxx-yyy-zzz, connector_uuid: zzz-yyy-xxx, to_id: listing-xyz-123, connection_type:

    property, site: vrbo, connection_data: { rating: 5} } Wednesday, April 24, 13
  17. > JS POSTS to an endpoint > query solr >

    build up connection > send response > backbone throws the response into a template Wednesday, April 24, 13