Skip to content

Commit

Permalink
Set the default internal and external encoding to UTF-8
Browse files Browse the repository at this point in the history
Solves an issue where external files contain UTF-8 characters [SS-194]
  • Loading branch information
shaiguitar authored and martinemde committed Jul 11, 2013
1 parent 54a8482 commit 98b5f07
Show file tree
Hide file tree
Showing 11 changed files with 125 additions and 4 deletions.
1 change: 1 addition & 0 deletions bin/engineyard-serverside
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ rescue LoadError
end

$LOAD_PATH.push(File.expand_path("../lib", File.dirname(__FILE__)))

require 'engineyard-serverside'

EY::Serverside::CLI.start
5 changes: 5 additions & 0 deletions lib/engineyard-serverside.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
$string_encodings = false
end

if defined?(Encoding) && Encoding.respond_to?(:default_internal=) # String.instance_methods.include?(:force_encoding)
Encoding.default_internal = Encoding::UTF_8
Encoding.default_external = Encoding::UTF_8
end

$LOAD_PATH.unshift File.expand_path('vendor/thor/lib', File.dirname(__FILE__))
$LOAD_PATH.unshift File.expand_path('vendor/systemu/lib', File.dirname(__FILE__))
$LOAD_PATH.unshift File.expand_path('vendor/escape/lib', File.dirname(__FILE__))
Expand Down
3 changes: 2 additions & 1 deletion script/ci
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#!/usr/bin/env bash
set -x
set -e
export LANG=en_US.UTF-8
export LC_CTYPE=
export LANG=

source use_ruby.sh
use_ruby resin
Expand Down
5 changes: 5 additions & 0 deletions spec/fixtures/repos/assets_disabled_utf8/Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
source 'https://rubygems.org'

gem 'rake'
gem 'ey_config'
gem 'rails'
88 changes: 88 additions & 0 deletions spec/fixtures/repos/assets_disabled_utf8/Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
GEM
remote: https://rubygems.org/
specs:
actionmailer (3.2.3)
actionpack (= 3.2.3)
mail (~> 2.4.4)
actionpack (3.2.3)
activemodel (= 3.2.3)
activesupport (= 3.2.3)
builder (~> 3.0.0)
erubis (~> 2.7.0)
journey (~> 1.0.1)
rack (~> 1.4.0)
rack-cache (~> 1.2)
rack-test (~> 0.6.1)
sprockets (~> 2.1.2)
activemodel (3.2.3)
activesupport (= 3.2.3)
builder (~> 3.0.0)
activerecord (3.2.3)
activemodel (= 3.2.3)
activesupport (= 3.2.3)
arel (~> 3.0.2)
tzinfo (~> 0.3.29)
activeresource (3.2.3)
activemodel (= 3.2.3)
activesupport (= 3.2.3)
activesupport (3.2.3)
i18n (~> 0.6)
multi_json (~> 1.0)
arel (3.0.2)
builder (3.0.0)
erubis (2.7.0)
ey_config (0.0.5)
hike (1.2.1)
i18n (0.6.0)
journey (1.0.3)
json (1.6.6)
mail (2.4.4)
i18n (>= 0.4.0)
mime-types (~> 1.16)
treetop (~> 1.4.8)
mime-types (1.18)
multi_json (1.3.2)
polyglot (0.3.3)
rack (1.4.1)
rack-cache (1.2)
rack (>= 0.4)
rack-ssl (1.3.2)
rack
rack-test (0.6.1)
rack (>= 1.0)
rails (3.2.3)
actionmailer (= 3.2.3)
actionpack (= 3.2.3)
activerecord (= 3.2.3)
activeresource (= 3.2.3)
activesupport (= 3.2.3)
bundler (~> 1.0)
railties (= 3.2.3)
railties (3.2.3)
actionpack (= 3.2.3)
activesupport (= 3.2.3)
rack-ssl (~> 1.3.2)
rake (>= 0.8.7)
rdoc (~> 3.4)
thor (~> 0.14.6)
rake (0.9.2.2)
rdoc (3.12)
json (~> 1.4)
sprockets (2.1.2)
hike (~> 1.2)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
thor (0.14.6)
tilt (1.3.3)
treetop (1.4.10)
polyglot
polyglot (>= 0.3.1)
tzinfo (0.3.33)

PLATFORMS
ruby

DEPENDENCIES
ey_config
rails
rake
3 changes: 3 additions & 0 deletions spec/fixtures/repos/assets_disabled_utf8/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Assets disabled in application.rb, but the application.rb file has characters we don't expect.

Previous versions of serverside would crash if the file encoding was loaded incorrectly.
5 changes: 5 additions & 0 deletions spec/fixtures/repos/assets_disabled_utf8/Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
desc 'Precompile yar assetz'
task 'assets:precompile' do
sh "touch #{File.expand_path('../public/assets/compiled_asset', __FILE__)}"
sh "touch precompiled"
end
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# encoding: utf-8
module Rails31
class Application < Rails::Application
config.assets.enabled = false
# ☃ 漢字仮名交じり文
end
end
3 changes: 3 additions & 0 deletions spec/fixtures/repos/assets_disabled_utf8/config/ey.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
environments:
env:
ignore_database_adapter_warning: true
9 changes: 6 additions & 3 deletions spec/rails31_deploy_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,15 @@
end

context "with asset support disabled in config/application.rb" do
before(:all) do
it "does not precompile assets" do
deploy_test_application('assets_disabled')
deploy_dir.join('current', 'precompiled').should_not exist
read_output.should include("Skipping asset precompilation. ('config/application.rb' disables assets.)")
end

it "does not precompile assets" do
deploy_dir.join('current', 'precompiled').should_not exist
it "deploys successfully when application.rb has utf-8 encoding" do
deploy_test_application('assets_disabled_utf8')
deploy_dir.join('current', 'precompiled').should exist
read_output.should include("Skipping asset precompilation. ('config/application.rb' disables assets.)")
end
end
Expand Down

1 comment on commit 98b5f07

@ukitazume
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Please sign in to comment.