• Save
twerkin' apps with j-rails
Upcoming SlideShare
Loading in...5
×
 

twerkin' apps with j-rails

on

  • 332 views

 

Statistics

Views

Total Views
332
Views on SlideShare
332
Embed Views
0

Actions

Likes
0
Downloads
0
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

twerkin' apps with j-rails twerkin' apps with j-rails Presentation Transcript

  • twerkin apps with j-rails building stuff with jruby, rails, and javaWednesday, April 24, 13
  • 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.comWednesday, April 24, 13
  • Michael May @ehm_mayWednesday, April 24, 13 View slide
  • No Be w ta in !Wednesday, April 24, 13 View slide
  • Wednesday, April 24, 13
  • Wednesday, April 24, 13
  • social profiles // local-templateWednesday, April 24, 13
  • 1) Use big font 2) Use color 3) Use jokes/memes so people stay happyWednesday, April 24, 13
  • Wednesday, April 24, 13
  • mmay ~/jruby-talk $ ls - jruby - tool chain for mvn/ruby/java - jruby/rails dev patterns - social connection serviceWednesday, April 24, 13
  • jrubyWednesday, April 24, 13
  • jruby NATIVE THREADSWednesday, April 24, 13
  • Native threads are scheduled by the OSWednesday, April 24, 13
  • Green threads are scheduled by the Ruby VMWednesday, April 24, 13
  • Why do I care?Wednesday, April 24, 13
  • simultaneous thread executionWednesday, April 24, 13
  • Wednesday, April 24, 13
  • C extensionsWednesday, April 24, 13
  • C extensionsWednesday, April 24, 13
  • Nokogiri diedWednesday, April 24, 13
  • Java extensionsWednesday, April 24, 13
  • Use native java xml parsers e.g. StAXWednesday, April 24, 13
  • Apache libraries!! Google Collections Log4J Jetty ANTLR - lexer/parserWednesday, April 24, 13
  • jruby startup time = no buenoWednesday, April 24, 13
  • 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.208sWednesday, April 24, 13
  • Wednesday, April 24, 13
  • Wednesday, April 24, 13
  • Wednesday, April 24, 13
  • use spork and guard to help mitigate startup time https://github.com/sporkrb/spork https://github.com/guard/guardWednesday, April 24, 13
  • anti-jruby biasWednesday, April 24, 13
  • Wednesday, April 24, 13
  • MRI gets the love MRI == Matz Matz == Ruby GodWednesday, April 24, 13
  • rubyspec.orgWednesday, April 24, 13
  • mmay ~/jruby-talk $ ls - jruby - tool chain for mvn/ruby/java - jruby/rails dev patterns - social connection serviceWednesday, April 24, 13
  • Toolin’Wednesday, April 24, 13
  • Wednesday, April 24, 13
  • maven mvnWednesday, April 24, 13
  • maven : java :: bundler : rubyWednesday, April 24, 13
  • “targets” compile test deployWednesday, April 24, 13
  • $ mvn clean compileWednesday, April 24, 13
  • pom.xml <dependencies> <dependency> <groupId>org.jruby</groupId> <artifactId>jruby</artifactId> <version>1.7.3</version> </dependency> </dependencies>Wednesday, April 24, 13
  • XML non-believer? ruby DSL for pom.xml ruby-maven github.com/mkristian/ruby-mavenWednesday, April 24, 13
  • pom-loaderWednesday, April 24, 13
  • pom-loader loads your java dependencies into your jruby envWednesday, April 24, 13
  • classpathWednesday, April 24, 13
  • classpath no moreWednesday, April 24, 13
  • require ‘pom-loader’pom_dir = File.join Rails.root, “..”PomLoader.load {pom_dir: pom_dir}Wednesday, April 24, 13
  • def day date = Date.parse(self.arrival_date) com.homeaway.reviews.model.Day.new(date) endWednesday, April 24, 13
  • 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:1046Wednesday, April 24, 13
  • mmay ~/jruby-talk $ ls - jruby - tool chain for mvn/ruby/java - jruby/rails dev patterns - social connection serviceWednesday, April 24, 13
  • PatternsWednesday, April 24, 13
  • Namespace java classesWednesday, April 24, 13
  • module Java module ReviewsApi java_import com.homeaway.reviews.model.Day .... java_import com.homeaway.reviews.model.Review end endWednesday, April 24, 13
  • def day date = Date.parse(self.arrival_date) com.homeaway.reviews.model.Day.new(date) endWednesday, April 24, 13
  • def day date = Date.parse(self.arrival_date) Java::ReviewsApi::Day.new(date) endWednesday, April 24, 13
  • WARNING!!!Wednesday, April 24, 13
  • You can clobber your ruby namespaceWednesday, April 24, 13
  • module Foo java_import java.util.Date ... def bar date = Date.parse(date_string) Date.new(date.year, date.month, date.day) end endWednesday, April 24, 13
  • ActiveModel is greatWednesday, April 24, 13
  • Rails ActiveRecord is awesomeWednesday, April 24, 13
  • Model.create { name: “John”, coffee: “yes pls” } model.validate model.save model.save! Model.where(name: “John”)Wednesday, April 24, 13
  • Java::ReviewsClient::Reviews ClientImpl.write_review(uuid, unit_id, site, review)Wednesday, April 24, 13
  • 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
  • mehWednesday, April 24, 13
  • Review.create(review: params[:review])Wednesday, April 24, 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. endWednesday, April 24, 13
  • def save if self.valid? Reviews.client(@site).write_review(@system_id, @property_id, @unit_id, self.to_java) else false end endWednesday, April 24, 13
  • def to_java Java::ReviewsApi::Review.new.tap do |r| r.setArrivalDate(@day) r.setBody(@body) r.setCountry(@country) r.setLanguage(@language) r.setHeadline(@headline) r.setRating(@rating.to_i) r.setReviewer(build_reviewer) end endWednesday, April 24, 13
  • Testin’Wednesday, April 24, 13
  • You can test jruby/java code with MRIWednesday, April 24, 13
  • running specs with jruby sucksWednesday, April 24, 13
  • 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
  • be aware of javaWednesday, April 24, 13
  • Wednesday, April 24, 13
  • mmay ~/jruby-talk $ ls - jruby - tool chain for mvn/ruby/java - jruby/rails dev patterns - social connection serviceWednesday, April 24, 13
  • Building a connection search serviceWednesday, April 24, 13
  • lolwut?Wednesday, April 24, 13
  • PropertiesWednesday, April 24, 13
  • PeopleWednesday, April 24, 13
  • Wednesday, April 24, 13
  • { 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
  • solrWednesday, April 24, 13
  • > 6 Million first-order connectionsWednesday, April 24, 13
  • > 100 Million second-order connectionsWednesday, April 24, 13
  • > JS POSTS to an endpoint > query solr > build up connection > send response > backbone throws the response into a templateWednesday, April 24, 13
  • Wednesday, April 24, 13
  • Wednesday, April 24, 13
  • jruby is your friend embrace it, don’t hate itWednesday, April 24, 13
  • To the bar! @ehm_may @CDNSumoWednesday, April 24, 13