Skip to content
This repository has been archived by the owner on Apr 22, 2021. It is now read-only.

Update rails 2.3 lts to run on ruby 2+ #1

Open
wants to merge 9 commits into
base: 2-3-lts
Choose a base branch
from
1 change: 1 addition & 0 deletions .ruby-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2.1.9
3 changes: 2 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ gem 'mysql', '=2.8.1'
gem 'rack', '< 1.5'
gem 'pg', '=0.9.0'
gem 'nokogiri', '1.3.3'
gem 'libxml-ruby', '=1.1.4'
gem 'libxml-ruby', '2.9.0'
gem 'iconv', '1.0.4'

gem 'railslts-version', :path => 'railslts-version'
21 changes: 18 additions & 3 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,35 @@ GEM
remote: https://rubygems.org/
specs:
RedCloth (4.2.3)
libxml-ruby (1.1.4)
hoe (3.15.2)
rake (>= 0.8, < 12.0)
iconv (1.0.4)
libxml-ruby (2.9.0)
mocha (0.9.7)
rake
mysql (2.8.1)
nokogiri (1.3.3)
hoe (>= 2.3.2)
racc
rake-compiler
rexical
pg (0.9.0)
rack (1.4.6)
racc (1.4.14)
rack (1.4.7)
rake (0.8.7)
rake-compiler (1.0.1)
rake
rdoc (2.5.11)
rexical (1.0.5)
sqlite3 (1.3.7)

PLATFORMS
ruby

DEPENDENCIES
RedCloth (= 4.2.3)
libxml-ruby (= 1.1.4)
iconv (= 1.0.4)
libxml-ruby (= 2.9.0)
mocha (= 0.9.7)
mysql (= 2.8.1)
nokogiri (= 1.3.3)
Expand All @@ -33,3 +45,6 @@ DEPENDENCIES
rake (= 0.8.7)
rdoc (= 2.5.11)
sqlite3 (= 1.3.7)

BUNDLED WITH
1.13.6
1 change: 1 addition & 0 deletions actionpack/lib/action_controller/request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,7 @@ def normalize_parameters(value)
when Array
value.map { |e| normalize_parameters(e) }
else
value.force_encoding(Encoding.default_external) if value.respond_to?(:force_encoding)
value
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def inspect
end

def send(method, *args)
if proxy_respond_to?(method)
if proxy_respond_to?(method, true)
super
else
load_target
Expand Down
2 changes: 1 addition & 1 deletion activerecord/lib/active_record/autosave_association.rb
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ def save_collection_association(reflection)
end

# reconstruct the SQL queries now that we know the owner's id
association.send(:construct_sql) if association.respond_to?(:construct_sql)
association.send(:construct_sql) if association.respond_to?(:construct_sql, true)
end
end

Expand Down
2 changes: 1 addition & 1 deletion activerecord/lib/active_record/callbacks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ def destroy_with_callbacks #:nodoc:
def callback(method)
result = run_callbacks(method) { |result, object| false == result }

if result != false && respond_to_without_attributes?(method)
if result != false && respond_to_without_attributes?(method, true)
result = send(method)
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ class MysqlAdapter < AbstractAdapter
QUOTED_TRUE, QUOTED_FALSE = '1'.freeze, '0'.freeze

NATIVE_DATABASE_TYPES = {
:primary_key => "int(11) DEFAULT NULL auto_increment PRIMARY KEY".freeze,
:primary_key => "int(11) auto_increment PRIMARY KEY".freeze,
:string => { :name => "varchar", :limit => 255 },
:text => { :name => "text" },
:integer => { :name => "int", :limit => 4 },
Expand Down
51 changes: 36 additions & 15 deletions activesupport/lib/active_support/core_ext/string/output_safety.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,42 @@ module Util
HTML_ESCAPE = { '&' => '&amp;', '>' => '&gt;', '<' => '&lt;', '"' => '&quot;', "'" => '&#39;' }
JSON_ESCAPE = { '&' => '\u0026', '>' => '\u003E', '<' => '\u003C' }

# A utility method for escaping HTML tag characters.
# This method is also aliased as <tt>h</tt>.
#
# In your ERB templates, use this method to escape any unsafe content. For example:
# <%=h @person.name %>
#
# ==== Example:
# puts html_escape("is a > 0 & a < 10?")
# # => is a &gt; 0 &amp; a &lt; 10?
def html_escape(s)
s = s.to_s
if s.html_safe?
s
else
s.gsub(/[&"'><]/n) { |special| HTML_ESCAPE[special] }.html_safe
# Detect whether 1.9 can transcode with XML escaping.
if '"&gt;&lt;&amp;&quot;"' == ('><&"'.encode('utf-8', :xml => :attr) rescue false)

Choose a reason for hiding this comment

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

wtf

# A utility method for escaping HTML tag characters.
# This method is also aliased as <tt>h</tt>.
#
# In your ERB templates, use this method to escape any unsafe content. For example:
# <%=h @person.name %>
#
# ==== Example:
# puts html_escape("is a > 0 & a < 10?")
# # => is a &gt; 0 &amp; a &lt; 10?
def html_escape(s)
s = s.to_s
if s.html_safe?
s
else
s.encode(s.encoding, :xml => :attr)[1...-1].html_safe
end
end
else
# A utility method for escaping HTML tag characters.
# This method is also aliased as <tt>h</tt>.
#
# In your ERB templates, use this method to escape any unsafe content. For example:
# <%=h @person.name %>
#
# ==== Example:
# puts html_escape("is a > 0 & a < 10?")
# # => is a &gt; 0 &amp; a &lt; 10?
def html_escape(s)
s = s.to_s
if s.html_safe?
s
else
s.gsub(/[&"><]/n) { |special| HTML_ESCAPE[special] }.html_safe
end
end
end

Expand Down
26 changes: 14 additions & 12 deletions activesupport/lib/active_support/testing/declarative.rb
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
module ActiveSupport
module Testing
module Declarative
# test "verify something" do
# ...
# end
def test(name, &block)
test_name = "test_#{name.gsub(/\s+/,'_')}".to_sym
defined = instance_method(test_name) rescue false
raise "#{test_name} is already defined in #{self}" if defined
if block_given?
define_method(test_name, &block)
else
define_method(test_name) do
flunk "No implementation provided for #{name}"
unless defined?(Spec)
# test "verify something" do
# ...
# end
def test(name, &block)
test_name = "test_#{name.gsub(/\s+/,'_')}".to_sym
defined = method_defined? test_name
raise "#{test_name} is already defined in #{self}" if defined
if block_given?
define_method(test_name, &block)
else
define_method(test_name) do
flunk "No implementation provided for #{name}"
end
end
end
end
Expand Down
20 changes: 3 additions & 17 deletions railties/lib/rails/gem_dependency.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
require 'rails/vendor_gem_source_index'

module Gem
def self.source_index=(index)
@@source_index = index
end
end

module Rails
class GemDependency < Gem::Dependency
attr_accessor :lib, :source, :dep
Expand All @@ -18,10 +12,6 @@ def self.unpacked_path

def self.add_frozen_gem_path
@@paths_loaded ||= begin
source_index = Rails::VendorGemSourceIndex.new(Gem.source_index)
Gem.clear_paths
Gem.source_index = source_index
# loaded before us - we can't change them, so mark them
Gem.loaded_specs.each do |name, spec|
@@framework_gems[name] = spec
end
Expand Down Expand Up @@ -74,8 +64,7 @@ def add_load_paths
end

begin
dep = Gem::Dependency.new(name, requirement)
spec = Gem.source_index.find { |_,s| s.satisfies_requirement?(dep) }.last
spec = Gem::Specification.find_all_by_name(name, requirement).last
spec.activate # a way that exists
rescue
gem self.name, self.requirement # < 1.8 unhappy way
Expand All @@ -101,7 +90,7 @@ def specification
# code repeated from Gem.activate. Find a matching spec, or the currently loaded version.
# error out if loaded version and requested version are incompatible.
@spec ||= begin
matches = Gem.source_index.search(self)
matches = Gem::Specification.find_all_by_name(self.name)
matches << @@framework_gems[name] if framework_gem?
if Gem.loaded_specs[name] then
# This gem is already loaded. If the currently loaded gem is not in the
Expand Down Expand Up @@ -218,10 +207,7 @@ def load
end

def refresh
Rails::VendorGemSourceIndex.silence_spec_warnings = true
real_gems = Gem.source_index.installed_source_index
exact_dep = Gem::Dependency.new(name, "= #{specification.version}")
matches = real_gems.search(exact_dep)
matches = Gem::Specification.find_all_by_name(name, "= #{specification.version}")
installed_spec = matches.first
if frozen?
if installed_spec
Expand Down
2 changes: 1 addition & 1 deletion railties/lib/rails_generator/commands.rb
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ def template(relative_source, relative_destination, template_options = {})
# Evaluate any assignments in a temporary, throwaway binding.
vars = template_options[:assigns] || {}
b = template_options[:binding] || binding
vars.each { |k,v| eval "#{k} = vars[:#{k}] || vars['#{k}']", b }
vars.each { |k, v| b.local_variable_set(:"#{k}", v) }

# Render the source file with the temporary binding.
ERB.new(file.read, nil, '-').result(b)
Expand Down
4 changes: 2 additions & 2 deletions railties/lib/tasks/framework.rake
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ namespace :rails do
require 'rubygems/gem_runner'

rails = (version = ENV['VERSION']) ?
Gem.cache.find_name('rails', "= #{version}").first :
Gem.cache.find_name('rails').sort_by { |g| g.version }.last
Gem::Specification.find_by_name('rails', "= #{version}") :
Gem::Specification.find_all_by_name('rails').sort_by { |g| g.version }.last

version ||= rails.version

Expand Down