Skip to content

Commit

Permalink
Merge pull request #1414 from padrino/19mode
Browse files Browse the repository at this point in the history
drop ruby 18mode, liberate ActiveSupport
  • Loading branch information
ujifgc committed Nov 15, 2013
2 parents 193235b + 4bbfa14 commit 6a1acc6
Show file tree
Hide file tree
Showing 12 changed files with 13 additions and 51 deletions.
5 changes: 2 additions & 3 deletions .travis.yml
Expand Up @@ -4,10 +4,9 @@ install:
- gem update --system
- bundle update
rvm:
- 1.8.7
- 1.9.3
- 2.0.0
- rbx-18mode
- rbx-19mode
- jruby-19mode
notifications:
irc: 'irc.freenode.org#padrino'
Expand All @@ -32,4 +31,4 @@ matrix:
allow_failures:
- rvm: 1.9.3
env: SINATRA_EDGE=true
- rvm: rbx-18mode
- rvm: rbx-19mode
5 changes: 0 additions & 5 deletions Gemfile
Expand Up @@ -33,11 +33,6 @@ group :development do
gem "uuid", ">= 2.3.1"
gem "builder", ">= 2.1.2"
gem "bcrypt-ruby", :require => "bcrypt"
platforms :mri_18 do
# gem "rcov", "~> 0.9.8"
# gem "ruby-prof", ">= 0.9.1"
gem "system_timer", ">= 1.0"
end
platforms :jruby do
gem "jruby-openssl"
end
Expand Down
Expand Up @@ -31,7 +31,7 @@ class <%= @model_name %> < ActiveRecord::Base

def encrypt_password
value = ::BCrypt::Password.create(password)
value = value.force_encoding(Encoding::UTF_8) if value.respond_to?(:encoding) && value.encoding == Encoding::ASCII_8BIT
value = value.force_encoding(Encoding::UTF_8) if value.encoding == Encoding::ASCII_8BIT
self.crypted_password = value
end

Expand Down
Expand Up @@ -34,7 +34,7 @@ class <%= @model_name %> < ActiveRecord::Base

def encrypt_password
value = ::BCrypt::Password.create(password)
value = value.force_encoding(Encoding::UTF_8) if value.respond_to?(:encoding) && value.encoding == Encoding::ASCII_8BIT
value = value.force_encoding(Encoding::UTF_8) if value.encoding == Encoding::ASCII_8BIT
self.crypted_password = value
end

Expand Down
8 changes: 2 additions & 6 deletions padrino-core/lib/padrino-core.rb
Expand Up @@ -105,12 +105,8 @@ def global_configurations
# @return [NilClass]
#
def set_encoding
if RUBY_VERSION < '1.9'
$KCODE='u'
else
Encoding.default_external = Encoding::UTF_8
Encoding.default_internal = Encoding::UTF_8
end
Encoding.default_external = Encoding::UTF_8
Encoding.default_internal = Encoding::UTF_8
nil
end

Expand Down
2 changes: 1 addition & 1 deletion padrino-core/padrino-core.gemspec
Expand Up @@ -39,6 +39,6 @@ Gem::Specification.new do |s|
end
s.add_dependency("http_router", "~> 0.11.0")
s.add_dependency("thor", "~> 0.17.0")
s.add_dependency("activesupport", ">= 3.1", "< 4.0")
s.add_dependency("activesupport", "~> 4.0")
s.add_dependency("rack-protection", ">= 1.5.0")
end
8 changes: 2 additions & 6 deletions padrino-core/test/test_core.rb
Expand Up @@ -27,12 +27,8 @@ def setup

should 'set correct utf-8 encoding' do
Padrino.set_encoding
if RUBY_VERSION <'1.9'
assert_equal 'UTF8', $KCODE
else
assert_equal Encoding.default_external, Encoding::UTF_8
assert_equal Encoding.default_internal, Encoding::UTF_8
end
assert_equal Encoding.default_external, Encoding::UTF_8
assert_equal Encoding.default_internal, Encoding::UTF_8
end

should 'have load paths' do
Expand Down
2 changes: 0 additions & 2 deletions padrino-core/test/test_routing.rb
Expand Up @@ -146,8 +146,6 @@ class FooError < RuntimeError; end
end

should 'encode params using UTF-8' do
skip unless ''.respond_to?(:encoding) # for 1.8.7

mock_app do
get('/:foo') { params[:foo].encoding.name }
end
Expand Down
Expand Up @@ -29,13 +29,6 @@
# Setup our logger
ActiveRecord::Base.logger = logger
# Raise exception on mass assignment protection for Active Record models.
ActiveRecord::Base.mass_assignment_sanitizer = :strict
# Log the query plan for queries taking more than this (works
# with SQLite, MySQL, and PostgreSQL).
ActiveRecord::Base.auto_explain_threshold_in_seconds = 0.5
# Include Active Record class name as root for JSON serialized output.
ActiveRecord::Base.include_root_in_json = false
Expand Down
13 changes: 2 additions & 11 deletions padrino-gen/lib/padrino-gen/generators/components/orms/mongoid.rb
Expand Up @@ -74,17 +74,8 @@
MONGO

def setup_orm
require_dependencies 'mongoid', :version => (RUBY_VERSION >= '1.9' ? '~>3.0.0' : '~>2.0')

if RUBY_VERSION =~ /1\.8/ && (!defined?(RUBY_ENGINE) || RUBY_ENGINE == 'ruby')
require_dependencies('SystemTimer', :require => 'system_timer')
end

if RUBY_VERSION >= '1.9'
create_file('config/database.rb', MONGOID3.gsub(/!NAME!/, @project_name.underscore))
else
create_file('config/database.rb', MONGOID.gsub(/!NAME!/, @project_name.underscore))
end
require_dependencies 'mongoid', :version => '~>3.0.0'
create_file('config/database.rb', MONGOID3.gsub(/!NAME!/, @project_name.underscore))
end

MONGOID_MODEL = (<<-MODEL) unless defined?(MONGOID_MODEL)
Expand Down
Expand Up @@ -11,7 +11,6 @@
def setup_orm
require_dependencies 'mongo_mapper'
require_dependencies 'bson_ext', :require => 'mongo'
require_dependencies('SystemTimer', :require => 'system_timer') if RUBY_VERSION =~ /1\.8/ && (!defined?(RUBY_ENGINE) || RUBY_ENGINE == 'ruby')
create_file("config/database.rb", MONGO.gsub(/!NAME!/, @project_name.underscore))
end

Expand Down
9 changes: 2 additions & 7 deletions padrino-gen/test/test_project_generator.rb
Expand Up @@ -377,13 +377,8 @@ def teardown
should "properly generate for mongoid" do
out, err = capture_io { generate(:project, 'project.com', "--root=#{@apptmp}", '--orm=mongoid', '--script=none') }
assert_match(/applying.*?mongoid.*?orm/, out)
if RUBY_VERSION >= '1.9'
assert_match_in_file(/gem 'mongoid', '~>3.0.0'/, "#{@apptmp}/project.com/Gemfile")
assert_match_in_file(/Mongoid::Config.sessions =/, "#{@apptmp}/project.com/config/database.rb")
else
assert_match_in_file(/gem 'mongoid', '~>2.0'/, "#{@apptmp}/project.com/Gemfile")
assert_match_in_file(/Mongoid.database/, "#{@apptmp}/project.com/config/database.rb")
end
assert_match_in_file(/gem 'mongoid', '~>3.0.0'/, "#{@apptmp}/project.com/Gemfile")
assert_match_in_file(/Mongoid::Config.sessions =/, "#{@apptmp}/project.com/config/database.rb")
end


Expand Down

0 comments on commit 6a1acc6

Please sign in to comment.