From db5e54631014e91a9e8aea78c63a615d5b91cd95 Mon Sep 17 00:00:00 2001 From: Ivan Hinojal Date: Sat, 6 Jun 2015 00:14:23 +0200 Subject: [PATCH] Added jRuby support To be used this gem in jRuby we will be using activerecord-jdbcpostgresql-adapter or maybe another adapter like activerecord-postgis-adapter. They all both support hstore because they run over postgres anyway. --- .travis.yml | 2 + Gemfile | 8 ++- Gemfile.lock | 62 +++++++++++++--------- lib/multilang-hstore/translation_keeper.rb | 2 +- multilang-hstore.gemspec | 7 ++- 5 files changed, 53 insertions(+), 28 deletions(-) diff --git a/.travis.yml b/.travis.yml index e4366c5..2b1fd50 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,3 +2,5 @@ language: ruby rvm: - 1.9.3 - ruby-head + - jruby-1.7 + - jruby-9.0.4.0 diff --git a/Gemfile b/Gemfile index 73f852e..928640b 100644 --- a/Gemfile +++ b/Gemfile @@ -1,8 +1,12 @@ source "http://rubygems.org" -gem 'pg', '>= 0.0.1' -gem 'activerecord', '>= 4.0.0' +gem 'pg', '>= 0.0.1', platform: :ruby +# Use jdbcpostgresql as the database for Active Record in jruby +gem 'activerecord-jdbcpostgresql-adapter', platform: :jruby +gem 'activesupport' +gem 'activerecord' +gem 'logger' gem 'rake' group :test, :development do diff --git a/Gemfile.lock b/Gemfile.lock index 543aa71..920fed2 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,48 +1,62 @@ GEM remote: http://rubygems.org/ specs: - activemodel (4.2.0) - activesupport (= 4.2.0) + activemodel (4.2.5.1) + activesupport (= 4.2.5.1) builder (~> 3.1) - activerecord (4.2.0) - activemodel (= 4.2.0) - activesupport (= 4.2.0) + activerecord (4.2.5.1) + activemodel (= 4.2.5.1) + activesupport (= 4.2.5.1) arel (~> 6.0) - activesupport (4.2.0) + activerecord-jdbc-adapter (1.3.19) + activerecord (>= 2.2) + activerecord-jdbcpostgresql-adapter (1.3.19) + activerecord-jdbc-adapter (~> 1.3.19) + jdbc-postgres (>= 9.1) + activesupport (4.2.5.1) i18n (~> 0.7) json (~> 1.7, >= 1.7.7) minitest (~> 5.1) thread_safe (~> 0.3, >= 0.3.4) tzinfo (~> 1.1) - arel (6.0.0) + arel (6.0.3) builder (3.2.2) diff-lcs (1.2.5) i18n (0.7.0) - json (1.8.2) - minitest (5.5.1) - pg (0.18.1) - rake (10.4.2) - rspec (3.1.0) - rspec-core (~> 3.1.0) - rspec-expectations (~> 3.1.0) - rspec-mocks (~> 3.1.0) - rspec-core (3.1.7) - rspec-support (~> 3.1.0) - rspec-expectations (3.1.2) + jdbc-postgres (9.4.1206) + json (1.8.3) + json (1.8.3-java) + logger (1.2.8) + minitest (5.8.4) + pg (0.18.4) + rake (10.5.0) + rspec (3.4.0) + rspec-core (~> 3.4.0) + rspec-expectations (~> 3.4.0) + rspec-mocks (~> 3.4.0) + rspec-core (3.4.2) + rspec-support (~> 3.4.0) + rspec-expectations (3.4.0) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.1.0) - rspec-mocks (3.1.3) - rspec-support (~> 3.1.0) - rspec-support (3.1.2) - thread_safe (0.3.4) + rspec-support (~> 3.4.0) + rspec-mocks (3.4.1) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.4.0) + rspec-support (3.4.1) + thread_safe (0.3.5) + thread_safe (0.3.5-java) tzinfo (1.2.2) thread_safe (~> 0.1) PLATFORMS + java ruby DEPENDENCIES - activerecord (>= 4.0.0) + activerecord + activerecord-jdbcpostgresql-adapter + activesupport + logger pg (>= 0.0.1) rake rspec diff --git a/lib/multilang-hstore/translation_keeper.rb b/lib/multilang-hstore/translation_keeper.rb index 0076749..42c24d3 100644 --- a/lib/multilang-hstore/translation_keeper.rb +++ b/lib/multilang-hstore/translation_keeper.rb @@ -124,8 +124,8 @@ def actual_locale end def flush! - @model.send("#{@attribute}_will_change!") @model[@attribute] = @translations + @model.send("#{@attribute}_will_change!") end end diff --git a/multilang-hstore.gemspec b/multilang-hstore.gemspec index 25b0679..34c91eb 100644 --- a/multilang-hstore.gemspec +++ b/multilang-hstore.gemspec @@ -19,7 +19,12 @@ Gem::Specification.new do |s| "spec/schema.rb", "spec/spec_helper.rb" ] - s.add_dependency 'pg', '~> 0.0' s.add_dependency 'activerecord', '~> 4.0' + if (RUBY_PLATFORM == 'java') + s.add_dependency 'activerecord-jdbcpostgresql-adapter' + else + s.add_dependency 'pg', '~> 0.0' + end + end