Skip to content
This repository

Making Machinist run on jruby, too #117

Open
wants to merge 1 commit into from

3 participants

αλεx π vanyak Attila Györffy
αλεx π

Hi, here's a rather small pull request that adds jruby support.

Tests are passing :) on both platforms

jruby-1.6.5 :010 > RUBY_PLATFORM
 => "java"
➜  machinist git:(master) ✗ bundle install
Using rake (0.9.2) 
Using activesupport (3.0.9) 
Using builder (2.1.2) 
Using i18n (0.5.0) 
Using activemodel (3.0.9) 
Using arel (2.0.10) 
Using tzinfo (0.3.28) 
Using activerecord (3.0.9) 
Using activerecord-jdbc-adapter (1.2.2) 
Using jdbc-mysql (5.1.13) 
Using activerecord-jdbcmysql-adapter (1.2.2) 
Using diff-lcs (1.1.2) 
Using machinist (2.0) from source at . 
Using rcov (0.9.9) 
Using rdoc (3.6.1) 
Using rspec-core (2.6.4) 
Using rspec-expectations (2.6.0) 
Using rspec-mocks (2.6.0) 
Using rspec (2.6.0) 
Using bundler (1.2.0.pre.1) 
Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.
➜  machinist git:(master) ✗ bundle exec rspec spec     
-- create_table(:users, {:force=>true})
   -> 0.6490s
   -> 0 rows
-- create_table(:posts, {:force=>true})
   -> 0.0180s
   -> 0 rows
-- create_table(:comments, {:force=>true})
   -> 0.0190s
   -> 0 rows
-- create_table(:tags, {:force=>true})
   -> 0.0170s
   -> 0 rows
-- create_table(:posts_tags, {:id=>false, :force=>true})
   -> 0.0180s
   -> 0 rows
-- initialize_schema_migrations_table()
   -> 0.0020s
-- assume_migrated_upto_version(0, "db/migrate")
   -> 0.0020s
..............................

Finished in 0.656 seconds
30 examples, 0 failures

If you don't mind/want to, I could add .travis.yml with all supported rubies. What do you think?

vanyak
vanyak commented July 06, 2012

There is a bug in JRuby 1.6 which makes Machinist2 fail occasionally. https://jira.codehaus.org/browse/JRUBY-6035
This bug has been fixed in 1.7 only

Attila Györffy

I'm very sorry but I don't think this is a good way to handle this. The .gemspec is read at the time you build and release your gem, so any conditional logic in that file will be evaluated once when the gem is built and released on your machine.

What you need instead is to evaluate the platform at runtime. You can do this in your Gemfile instead as none of the ActiveRecord adapters is an actual dependency of Machinist:

platforms :ruby do
  gem "sqlite3"
end

platforms :jruby do
  gem "activerecord-jdbcsqlite3-adapter"
end

I've got a fork of Machinist that does exactly this: https://github.com/liquid/machinist/blob/master/Gemfile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Jul 05, 2012
αλεx π Making Machinist run on jRuby, too 2d5a741
This page is out of date. Refresh to see the latest.

Showing 1 changed file with 8 additions and 1 deletion. Show diff stats Hide diff stats

  1. 9  machinist.gemspec
9  machinist.gemspec
@@ -19,7 +19,14 @@ Gem::Specification.new do |s|
19 19
   s.require_paths = ["lib"]
20 20
 
21 21
   s.add_development_dependency "activerecord"
22  
-  s.add_development_dependency "mysql"
  22
+
  23
+  if RUBY_PLATFORM == "java"
  24
+    s.add_development_dependency "activerecord-jdbc-adapter"
  25
+    s.add_development_dependency "activerecord-jdbcmysql-adapter"
  26
+  else
  27
+    s.add_development_dependency "mysql"
  28
+  end
  29
+
23 30
   s.add_development_dependency "rake"
24 31
   s.add_development_dependency "rcov"
25 32
   s.add_development_dependency "rspec"
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.