diff --git a/.travis.yml b/.travis.yml index 23741716c..c11e96d6a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,3 +3,7 @@ language: ruby rvm: - 2.0.0 - 1.9.3 +before_install: + - gem install bundler --version '>= 1.2.2' +before_script: 'bundle exec rake appraisal:install' +script: 'bundle exec rake appraisal test' diff --git a/Appraisals b/Appraisals new file mode 100644 index 000000000..3002ea395 --- /dev/null +++ b/Appraisals @@ -0,0 +1,11 @@ +appraise "rails-3.1" do + gem 'rails', '~> 3.1' +end + +appraise "rails-3.2" do + gem 'rails', '~> 3.2' +end + +appraise "rails-4.0" do + gem 'rails', '~> 4.0' +end diff --git a/Rakefile b/Rakefile index f7144251b..8c1d05bae 100644 --- a/Rakefile +++ b/Rakefile @@ -4,9 +4,9 @@ rescue LoadError puts 'You must `gem install bundler` and `bundle install` to run rake tasks' end - Bundler::GemHelper.install_tasks +require 'appraisal' require 'rake/testtask' Rake::TestTask.new(:test) do |t| @@ -16,6 +16,4 @@ Rake::TestTask.new(:test) do |t| t.verbose = false end - task default: :test - diff --git a/gemfiles/rails_3.1.gemfile b/gemfiles/rails_3.1.gemfile new file mode 100644 index 000000000..58db7a878 --- /dev/null +++ b/gemfiles/rails_3.1.gemfile @@ -0,0 +1,7 @@ +# This file was generated by Appraisal + +source "http://rubygems.org" + +gem "rails", "~> 3.1" + +gemspec :path=>"../" \ No newline at end of file diff --git a/gemfiles/rails_3.1.gemfile.lock b/gemfiles/rails_3.1.gemfile.lock new file mode 100644 index 000000000..922569492 --- /dev/null +++ b/gemfiles/rails_3.1.gemfile.lock @@ -0,0 +1,104 @@ +PATH + remote: /home/jakub/code/react-rails + specs: + react-rails (0.4.1.0) + execjs + rails (>= 3.1) + react-source (= 0.4.1) + +GEM + remote: http://rubygems.org/ + specs: + actionmailer (3.2.14) + actionpack (= 3.2.14) + mail (~> 2.5.4) + actionpack (3.2.14) + activemodel (= 3.2.14) + activesupport (= 3.2.14) + builder (~> 3.0.0) + erubis (~> 2.7.0) + journey (~> 1.0.4) + rack (~> 1.4.5) + rack-cache (~> 1.2) + rack-test (~> 0.6.1) + sprockets (~> 2.2.1) + activemodel (3.2.14) + activesupport (= 3.2.14) + builder (~> 3.0.0) + activerecord (3.2.14) + activemodel (= 3.2.14) + activesupport (= 3.2.14) + arel (~> 3.0.2) + tzinfo (~> 0.3.29) + activeresource (3.2.14) + activemodel (= 3.2.14) + activesupport (= 3.2.14) + activesupport (3.2.14) + i18n (~> 0.6, >= 0.6.4) + multi_json (~> 1.0) + appraisal (0.5.2) + bundler + rake + arel (3.0.2) + builder (3.0.4) + erubis (2.7.0) + execjs (1.4.0) + multi_json (~> 1.0) + hike (1.2.3) + i18n (0.6.4) + journey (1.0.4) + json (1.8.0) + mail (2.5.4) + mime-types (~> 1.16) + treetop (~> 1.4.8) + mime-types (1.23) + multi_json (1.7.8) + polyglot (0.3.3) + rack (1.4.5) + rack-cache (1.2) + rack (>= 0.4) + rack-ssl (1.3.3) + rack + rack-test (0.6.2) + rack (>= 1.0) + rails (3.2.14) + actionmailer (= 3.2.14) + actionpack (= 3.2.14) + activerecord (= 3.2.14) + activeresource (= 3.2.14) + activesupport (= 3.2.14) + bundler (~> 1.0) + railties (= 3.2.14) + railties (3.2.14) + actionpack (= 3.2.14) + activesupport (= 3.2.14) + rack-ssl (~> 1.3.2) + rake (>= 0.8.7) + rdoc (~> 3.4) + thor (>= 0.14.6, < 2.0) + rake (10.1.0) + rdoc (3.12.2) + json (~> 1.4) + react-source (0.4.1) + sprockets (2.2.2) + hike (~> 1.2) + multi_json (~> 1.0) + rack (~> 1.0) + tilt (~> 1.1, != 1.3.0) + sqlite3 (1.3.7) + thor (0.18.1) + tilt (1.4.1) + treetop (1.4.14) + polyglot + polyglot (>= 0.3.1) + tzinfo (0.3.37) + +PLATFORMS + ruby + +DEPENDENCIES + appraisal + bundler (>= 1.2.2) + rails (~> 3.1) + react-rails! + sqlite3 diff --git a/gemfiles/rails_3.2.gemfile b/gemfiles/rails_3.2.gemfile new file mode 100644 index 000000000..779ce7c6e --- /dev/null +++ b/gemfiles/rails_3.2.gemfile @@ -0,0 +1,7 @@ +# This file was generated by Appraisal + +source "http://rubygems.org" + +gem "rails", "~> 3.2" + +gemspec :path=>"../" \ No newline at end of file diff --git a/gemfiles/rails_3.2.gemfile.lock b/gemfiles/rails_3.2.gemfile.lock new file mode 100644 index 000000000..502eb9d23 --- /dev/null +++ b/gemfiles/rails_3.2.gemfile.lock @@ -0,0 +1,104 @@ +PATH + remote: /home/jakub/code/react-rails + specs: + react-rails (0.4.1.0) + execjs + rails (>= 3.1) + react-source (= 0.4.1) + +GEM + remote: http://rubygems.org/ + specs: + actionmailer (3.2.14) + actionpack (= 3.2.14) + mail (~> 2.5.4) + actionpack (3.2.14) + activemodel (= 3.2.14) + activesupport (= 3.2.14) + builder (~> 3.0.0) + erubis (~> 2.7.0) + journey (~> 1.0.4) + rack (~> 1.4.5) + rack-cache (~> 1.2) + rack-test (~> 0.6.1) + sprockets (~> 2.2.1) + activemodel (3.2.14) + activesupport (= 3.2.14) + builder (~> 3.0.0) + activerecord (3.2.14) + activemodel (= 3.2.14) + activesupport (= 3.2.14) + arel (~> 3.0.2) + tzinfo (~> 0.3.29) + activeresource (3.2.14) + activemodel (= 3.2.14) + activesupport (= 3.2.14) + activesupport (3.2.14) + i18n (~> 0.6, >= 0.6.4) + multi_json (~> 1.0) + appraisal (0.5.2) + bundler + rake + arel (3.0.2) + builder (3.0.4) + erubis (2.7.0) + execjs (1.4.0) + multi_json (~> 1.0) + hike (1.2.3) + i18n (0.6.4) + journey (1.0.4) + json (1.8.0) + mail (2.5.4) + mime-types (~> 1.16) + treetop (~> 1.4.8) + mime-types (1.23) + multi_json (1.7.8) + polyglot (0.3.3) + rack (1.4.5) + rack-cache (1.2) + rack (>= 0.4) + rack-ssl (1.3.3) + rack + rack-test (0.6.2) + rack (>= 1.0) + rails (3.2.14) + actionmailer (= 3.2.14) + actionpack (= 3.2.14) + activerecord (= 3.2.14) + activeresource (= 3.2.14) + activesupport (= 3.2.14) + bundler (~> 1.0) + railties (= 3.2.14) + railties (3.2.14) + actionpack (= 3.2.14) + activesupport (= 3.2.14) + rack-ssl (~> 1.3.2) + rake (>= 0.8.7) + rdoc (~> 3.4) + thor (>= 0.14.6, < 2.0) + rake (10.1.0) + rdoc (3.12.2) + json (~> 1.4) + react-source (0.4.1) + sprockets (2.2.2) + hike (~> 1.2) + multi_json (~> 1.0) + rack (~> 1.0) + tilt (~> 1.1, != 1.3.0) + sqlite3 (1.3.7) + thor (0.18.1) + tilt (1.4.1) + treetop (1.4.14) + polyglot + polyglot (>= 0.3.1) + tzinfo (0.3.37) + +PLATFORMS + ruby + +DEPENDENCIES + appraisal + bundler (>= 1.2.2) + rails (~> 3.2) + react-rails! + sqlite3 diff --git a/gemfiles/rails_4.0.gemfile b/gemfiles/rails_4.0.gemfile new file mode 100644 index 000000000..d54014891 --- /dev/null +++ b/gemfiles/rails_4.0.gemfile @@ -0,0 +1,7 @@ +# This file was generated by Appraisal + +source "http://rubygems.org" + +gem "rails", "~> 4.0" + +gemspec :path=>"../" \ No newline at end of file diff --git a/gemfiles/rails_4.0.gemfile.lock b/gemfiles/rails_4.0.gemfile.lock new file mode 100644 index 000000000..70fd357cf --- /dev/null +++ b/gemfiles/rails_4.0.gemfile.lock @@ -0,0 +1,99 @@ +PATH + remote: /home/jakub/code/react-rails + specs: + react-rails (0.4.1.0) + execjs + rails (>= 3.1) + react-source (= 0.4.1) + +GEM + remote: http://rubygems.org/ + specs: + actionmailer (4.0.0) + actionpack (= 4.0.0) + mail (~> 2.5.3) + actionpack (4.0.0) + activesupport (= 4.0.0) + builder (~> 3.1.0) + erubis (~> 2.7.0) + rack (~> 1.5.2) + rack-test (~> 0.6.2) + activemodel (4.0.0) + activesupport (= 4.0.0) + builder (~> 3.1.0) + activerecord (4.0.0) + activemodel (= 4.0.0) + activerecord-deprecated_finders (~> 1.0.2) + activesupport (= 4.0.0) + arel (~> 4.0.0) + activerecord-deprecated_finders (1.0.3) + activesupport (4.0.0) + i18n (~> 0.6, >= 0.6.4) + minitest (~> 4.2) + multi_json (~> 1.3) + thread_safe (~> 0.1) + tzinfo (~> 0.3.37) + appraisal (0.5.2) + bundler + rake + arel (4.0.0) + atomic (1.1.12) + builder (3.1.4) + erubis (2.7.0) + execjs (1.4.0) + multi_json (~> 1.0) + hike (1.2.3) + i18n (0.6.4) + mail (2.5.4) + mime-types (~> 1.16) + treetop (~> 1.4.8) + mime-types (1.23) + minitest (4.7.5) + multi_json (1.7.8) + polyglot (0.3.3) + rack (1.5.2) + rack-test (0.6.2) + rack (>= 1.0) + rails (4.0.0) + actionmailer (= 4.0.0) + actionpack (= 4.0.0) + activerecord (= 4.0.0) + activesupport (= 4.0.0) + bundler (>= 1.3.0, < 2.0) + railties (= 4.0.0) + sprockets-rails (~> 2.0.0) + railties (4.0.0) + actionpack (= 4.0.0) + activesupport (= 4.0.0) + rake (>= 0.8.7) + thor (>= 0.18.1, < 2.0) + rake (10.1.0) + react-source (0.4.1) + sprockets (2.10.0) + hike (~> 1.2) + multi_json (~> 1.0) + rack (~> 1.0) + tilt (~> 1.1, != 1.3.0) + sprockets-rails (2.0.0) + actionpack (>= 3.0) + activesupport (>= 3.0) + sprockets (~> 2.8) + sqlite3 (1.3.7) + thor (0.18.1) + thread_safe (0.1.2) + atomic + tilt (1.4.1) + treetop (1.4.14) + polyglot + polyglot (>= 0.3.1) + tzinfo (0.3.37) + +PLATFORMS + ruby + +DEPENDENCIES + appraisal + bundler (>= 1.2.2) + rails (~> 4.0) + react-rails! + sqlite3 diff --git a/lib/react/rails/engine.rb b/lib/react/rails/engine.rb index 8b9c0bb18..c6afcc8f1 100644 --- a/lib/react/rails/engine.rb +++ b/lib/react/rails/engine.rb @@ -1,10 +1,8 @@ module React module Rails class Engine < ::Rails::Engine - config.before_initialize do |app| - # force autoloading? what? - Sprockets::Engines - Sprockets.register_engine '.jsx', React::JSX::Template + initializer "react_rails.setup_engine", :after => "sprockets.environment", :group => :all do |app| + app.assets.register_engine '.jsx', React::JSX::Template end end end diff --git a/lib/react/rails/railstie.rb b/lib/react/rails/railstie.rb index fd28c8068..c008e3e19 100644 --- a/lib/react/rails/railstie.rb +++ b/lib/react/rails/railstie.rb @@ -5,7 +5,7 @@ module Rails class Railtie < ::Rails::Railtie config.react = ActiveSupport::OrderedOptions.new - initializer "react_rails.setup_vendor" do |app| + initializer "react_rails.setup_vendor", :after => "sprockets.environment" do |app| variant = app.config.react.variant # Mimic behavior of ember-rails... @@ -24,6 +24,7 @@ class Railtie < ::Rails::Railtie tmp_path.join('react.js')) FileUtils.cp(::React::Source.bundled_path_for('JSXTransformer.js'), tmp_path.join('JSXTransformer.js')) + # Make sure it can be found app.assets.append_path(tmp_path) end diff --git a/react-rails.gemspec b/react-rails.gemspec index cf964f1df..0856090b7 100644 --- a/react-rails.gemspec +++ b/react-rails.gemspec @@ -14,13 +14,14 @@ Gem::Specification.new do |s| s.author = ['Paul O’Shannessy'] s.email = ['paul@oshannessy.com'] + s.add_development_dependency "bundler", [">= 1.2.2"] + s.add_development_dependency "appraisal" + s.add_development_dependency "sqlite3" # needed for the dummy app + s.add_dependency 'execjs' s.add_dependency 'rails', '>= 3.1' s.add_dependency 'react-source', '0.4.1' - # needed for the dummy app - s.add_development_dependency "sqlite3" - s.files = Dir[ 'lib/**/*', 'README.md', diff --git a/test/dummy/config/application.rb b/test/dummy/config/application.rb index 76a9c3d72..fe83c9c76 100644 --- a/test/dummy/config/application.rb +++ b/test/dummy/config/application.rb @@ -19,6 +19,7 @@ class Application < Rails::Application # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] # config.i18n.default_locale = :de config.react.variant = :production + + config.assets.enabled = true end end - diff --git a/test/dummy/config/initializers/secret_token.rb b/test/dummy/config/initializers/secret_token.rb index 3b121f749..bbb0cf04a 100644 --- a/test/dummy/config/initializers/secret_token.rb +++ b/test/dummy/config/initializers/secret_token.rb @@ -10,3 +10,6 @@ # Make sure your secret_key_base is kept private # if you're sharing your code publicly. Dummy::Application.config.secret_key_base = '43fa5672451bbd0a171668e625edc433eb00eeeb14c2606546e262e499ab853cfb532998d4809abe5019bf13888863e3a2c7d5cf7757de7a2b1fb50826d9874e' + +# for rails 3.1 & 3.2 +Dummy::Application.config.secret_token = Dummy::Application.config.secret_key_base