diff --git a/README.md b/README.md index 4d99022..235e810 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,9 @@ source :rubygems # ensure git hooks are installed when a gemfile is processed, see below ensure_git_hooks! +# need the bundler UTF-8 fix? ask for it by name! +bundler_encoding_fix! + # deploying to heroku and want 1.9.3 goodness? ruby '1.9.3' diff --git a/features/ruby_gemfile.feature b/features/ruby_gemfile.feature index d63188e..a815f10 100644 --- a/features/ruby_gemfile.feature +++ b/features/ruby_gemfile.feature @@ -263,7 +263,6 @@ Feature: Gemfiles gem "two", {:require=>nil} """ - @wip Scenario: Set the opposite environment in the environment defaults Given I have the file "Gemfile.penchant" with the content: """ @@ -423,3 +422,20 @@ Feature: Gemfiles # generated by penchant, environment: local ruby "1.9.3" """ + + Scenario: Ask for the Gemfile encoding fix + Given I have the file "Gemfile.penchant" with the content: + """ + bundler_encoding_fix! + """ + When I rebuild the Gemfile for "local" mode + Then the file "Gemfile" should have the following content: + """ + # generated by penchant, environment: local + if RUBY_VERSION =~ /1.9/ + Encoding.default_external = Encoding::UTF_8 + Encoding.default_internal = Encoding::UTF_8 + end + + """ + diff --git a/lib/penchant/file_processor.rb b/lib/penchant/file_processor.rb index 0338409..4b091b7 100644 --- a/lib/penchant/file_processor.rb +++ b/lib/penchant/file_processor.rb @@ -185,6 +185,15 @@ module Penchant passthrough :ruby, *args end + def bundler_encoding_fix! + self << (<<-RB) +if RUBY_VERSION =~ /1.9/ + Encoding.default_external = Encoding::UTF_8 + Encoding.default_internal = Encoding::UTF_8 +end + RB + end + def gemspec passthrough :gemspec end diff --git a/lib/penchant/version.rb b/lib/penchant/version.rb index 039d8e7..81e232d 100644 --- a/lib/penchant/version.rb +++ b/lib/penchant/version.rb @@ -1,3 +1,3 @@ module Penchant - VERSION = "0.2.27" + VERSION = "0.2.28" end