aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Gemfile6
-rw-r--r--railties/lib/rails/generators/app_base.rb9
-rw-r--r--railties/test/generators/app_generator_test.rb13
3 files changed, 28 insertions, 0 deletions
diff --git a/Gemfile b/Gemfile
index 60c4b31e5b..49a68c7d9d 100644
--- a/Gemfile
+++ b/Gemfile
@@ -87,6 +87,12 @@ platforms :jruby do
end
end
+platforms :rbx do
+ # The rubysl-yaml gem doesn't ship with Psych by default
+ # as it needs libyaml that isn't always available.
+ gem 'psych', '~> 2.0'
+end
+
# gems that are necessary for ActiveRecord tests with Oracle database
if ENV['ORACLE_ENHANCED']
platforms :ruby do
diff --git a/railties/lib/rails/generators/app_base.rb b/railties/lib/rails/generators/app_base.rb
index 20e512a7ff..c93ed10d6a 100644
--- a/railties/lib/rails/generators/app_base.rb
+++ b/railties/lib/rails/generators/app_base.rb
@@ -114,6 +114,7 @@ module Rails
jbuilder_gemfile_entry,
sdoc_gemfile_entry,
spring_gemfile_entry,
+ psych_gemfile_entry,
@extra_entries].flatten.find_all(&@gem_filter)
end
@@ -313,6 +314,14 @@ module Rails
GemfileEntry.new('spring', nil, comment, group: :development)
end
+ def psych_gemfile_entry
+ return [] unless defined?(Rubinius)
+
+ comment = 'Use Psych as the YAML engine, instead of Syck, so serialized ' \
+ 'data can be read safely from different rubies (see http://git.io/uuLVag)'
+ GemfileEntry.new('psych', '~> 2.0', comment, platforms: :rbx)
+ end
+
def bundle_command(command)
say_status :run, "bundle #{command}"
diff --git a/railties/test/generators/app_generator_test.rb b/railties/test/generators/app_generator_test.rb
index 409616d0d2..aff484f3eb 100644
--- a/railties/test/generators/app_generator_test.rb
+++ b/railties/test/generators/app_generator_test.rb
@@ -488,6 +488,19 @@ class AppGeneratorTest < Rails::Generators::TestCase
end
end
+ def test_psych_gem
+ run_generator
+ gem_regex = /gem 'psych',\s+'~> 2.0', \s+platforms: :rbx/
+
+ assert_file "Gemfile" do |content|
+ if defined?(Rubinius)
+ assert_match(gem_regex, content)
+ else
+ assert_no_match(gem_regex, content)
+ end
+ end
+ end
+
protected
def action(*args, &block)