diff options
author | Yves Senn <yves.senn@gmail.com> | 2014-05-27 09:21:16 +0200 |
---|---|---|
committer | Yves Senn <yves.senn@gmail.com> | 2014-05-27 09:27:36 +0200 |
commit | 83cb3560932b05121d9830b4d42a0399d014059b (patch) | |
tree | 1a18e71b8a5fc5d10f16eba4e674d588e26bbd5d /railties/lib/rails | |
parent | 9f8ee29e6fdd25c22f87e8e4ebe47ba9a60e5f9e (diff) | |
parent | 6aaf4bff188d498928bc936ef8d47c32bce03e9c (diff) | |
download | rails-83cb3560932b05121d9830b4d42a0399d014059b.tar.gz rails-83cb3560932b05121d9830b4d42a0399d014059b.tar.bz2 rails-83cb3560932b05121d9830b4d42a0399d014059b.zip |
Merge pull request #15327 from alexbel/replace_double_quotes_with_single_quotes
Replace double quotes with single quotes while adding an entry into Gemfile
Diffstat (limited to 'railties/lib/rails')
-rw-r--r-- | railties/lib/rails/generators/actions.rb | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/railties/lib/rails/generators/actions.rb b/railties/lib/rails/generators/actions.rb index 625f031c94..a239874df0 100644 --- a/railties/lib/rails/generators/actions.rb +++ b/railties/lib/rails/generators/actions.rb @@ -20,9 +20,9 @@ module Rails # Set the message to be shown in logs. Uses the git repo if one is given, # otherwise use name (version). - parts, message = [ name.inspect ], name + parts, message = [ quote(name) ], name if version ||= options.delete(:version) - parts << version.inspect + parts << quote(version) message << " (#{version})" end message = options[:git] if options[:git] @@ -30,7 +30,7 @@ module Rails log :gemfile, message options.each do |option, value| - parts << "#{option}: #{value.inspect}" + parts << "#{option}: #{quote(value)}" end in_root do @@ -68,7 +68,7 @@ module Rails log :source, source in_root do - prepend_file "Gemfile", "source #{source.inspect}\n", verbose: false + prepend_file "Gemfile", "source #{quote(source)}\n", verbose: false end end @@ -255,6 +255,15 @@ module Rails end end + # Surround string with single quotes if there is no quotes. + # Otherwise fall back to double quotes + def quote(str) + if str.include?("'") + str.inspect + else + "'#{str}'" + end + end end end end |