aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.travis.yml2
-rw-r--r--RAILS_VERSION2
-rw-r--r--actionmailer/lib/action_mailer/version.rb4
-rw-r--r--actionpack/actionpack.gemspec1
-rw-r--r--actionpack/lib/abstract_controller/layouts.rb72
-rw-r--r--actionpack/lib/abstract_controller/logger.rb1
-rw-r--r--actionpack/lib/action_dispatch/middleware/show_exceptions.rb26
-rw-r--r--actionpack/lib/action_dispatch/routing/redirection.rb9
-rw-r--r--actionpack/lib/action_pack/version.rb4
-rw-r--r--actionpack/lib/action_view/helpers/asset_paths.rb7
-rw-r--r--actionpack/lib/action_view/lookup_context.rb12
-rw-r--r--actionpack/lib/action_view/renderer/abstract_renderer.rb12
-rw-r--r--actionpack/lib/action_view/renderer/partial_renderer.rb9
-rw-r--r--actionpack/lib/action_view/renderer/template_renderer.rb1
-rw-r--r--actionpack/lib/action_view/template.rb94
-rw-r--r--actionpack/lib/action_view/template/error.rb6
-rw-r--r--actionpack/test/abstract/layouts_test.rb15
-rw-r--r--actionpack/test/controller/render_test.rb17
-rw-r--r--actionpack/test/controller/routing_test.rb51
-rw-r--r--actionpack/test/dispatch/mount_test.rb2
-rw-r--r--actionpack/test/template/render_test.rb32
-rw-r--r--activemodel/activemodel.gemspec1
-rw-r--r--activemodel/lib/active_model/version.rb4
-rw-r--r--activerecord/lib/active_record/fixtures.rb1
-rw-r--r--activerecord/lib/active_record/railties/databases.rake31
-rw-r--r--activerecord/lib/active_record/scoping/default.rb14
-rw-r--r--activerecord/lib/active_record/version.rb4
-rw-r--r--activerecord/test/cases/base_test.rb6
-rw-r--r--activerecord/test/cases/helper.rb6
-rw-r--r--activerecord/test/cases/log_subscriber_test.rb2
-rw-r--r--activeresource/lib/active_resource/version.rb4
-rw-r--r--activesupport/CHANGELOG.md5
-rw-r--r--activesupport/lib/active_support.rb3
-rw-r--r--activesupport/lib/active_support/buffered_logger.rb121
-rw-r--r--activesupport/lib/active_support/concern.rb5
-rw-r--r--activesupport/lib/active_support/core_ext.rb1
-rw-r--r--activesupport/lib/active_support/core_ext/date/calculations.rb18
-rw-r--r--activesupport/lib/active_support/core_ext/date/conversions.rb23
-rw-r--r--activesupport/lib/active_support/core_ext/date_time/calculations.rb2
-rw-r--r--activesupport/lib/active_support/core_ext/date_time/conversions.rb2
-rw-r--r--activesupport/lib/active_support/core_ext/enumerable.rb37
-rw-r--r--activesupport/lib/active_support/core_ext/exception.rb2
-rw-r--r--activesupport/lib/active_support/core_ext/logger.rb3
-rw-r--r--activesupport/lib/active_support/core_ext/module/introspection.rb23
-rw-r--r--activesupport/lib/active_support/core_ext/object/instance_variables.rb8
-rw-r--r--activesupport/lib/active_support/core_ext/range.rb1
-rw-r--r--activesupport/lib/active_support/core_ext/range/cover.rb3
-rw-r--r--activesupport/lib/active_support/core_ext/string/encoding.rb10
-rw-r--r--activesupport/lib/active_support/core_ext/string/multibyte.rb110
-rw-r--r--activesupport/lib/active_support/core_ext/uri.rb28
-rw-r--r--activesupport/lib/active_support/log_subscriber/test_helper.rb4
-rw-r--r--activesupport/lib/active_support/logger.rb18
-rw-r--r--activesupport/lib/active_support/memoizable.rb116
-rw-r--r--activesupport/lib/active_support/message_encryptor.rb17
-rw-r--r--activesupport/lib/active_support/message_verifier.rb5
-rw-r--r--activesupport/lib/active_support/multibyte/chars.rb161
-rw-r--r--activesupport/lib/active_support/ordered_hash.rb167
-rw-r--r--activesupport/lib/active_support/testing/assertions.rb2
-rw-r--r--activesupport/lib/active_support/testing/performance/ruby.rb2
-rw-r--r--activesupport/lib/active_support/testing/performance/ruby/mri.rb57
-rw-r--r--activesupport/lib/active_support/version.rb4
-rw-r--r--activesupport/test/abstract_unit.rb34
-rw-r--r--activesupport/test/benchmarkable_test.rb8
-rw-r--r--activesupport/test/buffered_logger_test.rb13
-rw-r--r--activesupport/test/clean_logger_test.rb37
-rw-r--r--activesupport/test/core_ext/date_ext_test.rb10
-rw-r--r--activesupport/test/core_ext/hash_ext_test.rb6
-rw-r--r--activesupport/test/core_ext/range_ext_test.rb13
-rw-r--r--activesupport/test/core_ext/string_ext_test.rb50
-rw-r--r--activesupport/test/core_ext/time_with_zone_test.rb3
-rw-r--r--activesupport/test/flush_cache_on_private_memoization_test.rb45
-rw-r--r--activesupport/test/json/encoding_test.rb30
-rw-r--r--activesupport/test/memoizable_test.rb290
-rw-r--r--activesupport/test/message_encryptor_test.rb6
-rw-r--r--activesupport/test/message_verifier_test.rb6
-rw-r--r--activesupport/test/multibyte_chars_test.rb11
-rw-r--r--activesupport/test/multibyte_utils_test.rb54
-rw-r--r--activesupport/test/ordered_hash_test.rb13
-rw-r--r--activesupport/test/tagged_logging_test.rb4
-rw-r--r--railties/guides/rails_guides/levenshtein.rb2
-rw-r--r--railties/guides/source/getting_started.textile3
-rw-r--r--railties/guides/source/migrations.textile2
-rw-r--r--railties/lib/rails.rb16
-rw-r--r--railties/lib/rails/application/bootstrap.rb8
-rw-r--r--railties/lib/rails/commands/plugin.rb2
-rw-r--r--railties/lib/rails/generators/app_base.rb18
-rw-r--r--railties/lib/rails/generators/named_base.rb12
-rw-r--r--railties/lib/rails/generators/rails/app/templates/Gemfile4
-rw-r--r--railties/lib/rails/generators/rails/app/templates/gitignore1
-rw-r--r--railties/lib/rails/generators/rails/plugin_new/templates/gitignore1
-rw-r--r--railties/lib/rails/performance_test_help.rb2
-rw-r--r--railties/lib/rails/ruby_version_check.rb14
-rw-r--r--railties/lib/rails/version.rb4
-rw-r--r--railties/test/abstract_unit.rb1
-rw-r--r--railties/test/application/configuration_test.rb8
-rw-r--r--railties/test/application/initializers/check_ruby_version_test.rb39
-rw-r--r--railties/test/application/middleware/exceptions_test.rb3
-rw-r--r--railties/test/generators/app_generator_test.rb24
-rw-r--r--railties/test/generators/mailer_generator_test.rb29
-rw-r--r--railties/test/generators/namespaced_generators_test.rb6
-rw-r--r--railties/test/generators/scaffold_controller_generator_test.rb13
-rw-r--r--railties/test/railties/generators_test.rb4
-rw-r--r--version.rb4
103 files changed, 397 insertions, 1866 deletions
diff --git a/.travis.yml b/.travis.yml
index 88999fe831..68d5c594ae 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,7 +1,5 @@
script: 'ci/travis.rb'
rvm:
- - 1.8.7
- - 1.9.2
- 1.9.3
env:
- "GEM=railties"
diff --git a/RAILS_VERSION b/RAILS_VERSION
index dd8b7cd23b..e1e048d8f0 100644
--- a/RAILS_VERSION
+++ b/RAILS_VERSION
@@ -1 +1 @@
-3.2.0.beta
+4.0.0.beta
diff --git a/actionmailer/lib/action_mailer/version.rb b/actionmailer/lib/action_mailer/version.rb
index b74ba3cb0d..0cb5dc6d64 100644
--- a/actionmailer/lib/action_mailer/version.rb
+++ b/actionmailer/lib/action_mailer/version.rb
@@ -1,7 +1,7 @@
module ActionMailer
module VERSION #:nodoc:
- MAJOR = 3
- MINOR = 2
+ MAJOR = 4
+ MINOR = 0
TINY = 0
PRE = "beta"
diff --git a/actionpack/actionpack.gemspec b/actionpack/actionpack.gemspec
index 1aa346929e..fe5bed70a9 100644
--- a/actionpack/actionpack.gemspec
+++ b/actionpack/actionpack.gemspec
@@ -20,7 +20,6 @@ Gem::Specification.new do |s|
s.add_dependency('activemodel', version)
s.add_dependency('rack-cache', '~> 1.1')
s.add_dependency('builder', '~> 3.0.0')
- s.add_dependency('i18n', '~> 0.6')
s.add_dependency('rack', '~> 1.3.5')
s.add_dependency('rack-test', '~> 0.6.1')
s.add_dependency('journey', '~> 1.0.0.rc1')
diff --git a/actionpack/lib/abstract_controller/layouts.rb b/actionpack/lib/abstract_controller/layouts.rb
index 8b6136d6ba..6a6387632c 100644
--- a/actionpack/lib/abstract_controller/layouts.rb
+++ b/actionpack/lib/abstract_controller/layouts.rb
@@ -195,8 +195,9 @@ module AbstractController
include Rendering
included do
- class_attribute :_layout_conditions
- remove_possible_method :_layout_conditions
+ class_attribute :_layout, :_layout_conditions,
+ :instance_reader => false, :instance_writer => false
+ self._layout = nil
self._layout_conditions = {}
_write_layout_method
end
@@ -254,7 +255,7 @@ module AbstractController
conditions.each {|k, v| conditions[k] = Array(v).map {|a| a.to_s} }
self._layout_conditions = conditions
- @_layout = layout || false # Converts nil to false
+ self._layout = layout
_write_layout_method
end
@@ -281,52 +282,27 @@ module AbstractController
RUBY
end
- if defined?(@_layout)
- layout_definition = case @_layout
- when String
- @_layout.inspect
- when Symbol
- <<-RUBY
- #{@_layout}.tap do |layout|
- unless layout.is_a?(String) || !layout
- raise ArgumentError, "Your layout method :#{@_layout} returned \#{layout}. It " \
- "should have returned a String, false, or nil"
- end
+ layout_definition = case _layout
+ when String
+ _layout.inspect
+ when Symbol
+ <<-RUBY
+ #{_layout}.tap do |layout|
+ unless layout.is_a?(String) || !layout
+ raise ArgumentError, "Your layout method :#{_layout} returned \#{layout}. It " \
+ "should have returned a String, false, or nil"
end
- RUBY
- when Proc
- define_method :_layout_from_proc, &@_layout
- "_layout_from_proc(self)"
- when false
- nil
- when true
- raise ArgumentError, "Layouts must be specified as a String, Symbol, false, or nil"
- when nil
- name_clause
- end
- else
- # Add a deprecation if the parent layout was explicitly set and the child
- # still does a dynamic lookup. In next Rails release, we should @_layout
- # to be inheritable so we can skip the child lookup if the parent explicitly
- # set the layout.
- parent = self.superclass.instance_variable_get(:@_layout)
- @_layout = nil
- inspect = parent.is_a?(Proc) ? parent.inspect : parent
-
- layout_definition = if parent.nil?
- name_clause
- elsif name
- <<-RUBY
- if template = lookup_context.find_all("#{_implied_layout_name}", #{prefixes.inspect}).first
- ActiveSupport::Deprecation.warn 'Layout found at "#{_implied_layout_name}" for #{name} but parent controller ' \
- 'set layout to #{inspect.inspect}. Please explicitly set your layout to "#{_implied_layout_name}" ' \
- 'or set it to nil to force a dynamic lookup.'
- template
- else
- super
- end
- RUBY
- end
+ end
+ RUBY
+ when Proc
+ define_method :_layout_from_proc, &_layout
+ "_layout_from_proc(self)"
+ when false
+ nil
+ when true
+ raise ArgumentError, "Layouts must be specified as a String, Symbol, false, or nil"
+ when nil
+ name_clause
end
self.class_eval <<-RUBY, __FILE__, __LINE__ + 1
diff --git a/actionpack/lib/abstract_controller/logger.rb b/actionpack/lib/abstract_controller/logger.rb
index 8b36230397..a4e31cd2e5 100644
--- a/actionpack/lib/abstract_controller/logger.rb
+++ b/actionpack/lib/abstract_controller/logger.rb
@@ -1,4 +1,3 @@
-require "active_support/core_ext/logger"
require "active_support/benchmarkable"
module AbstractController
diff --git a/actionpack/lib/action_dispatch/middleware/show_exceptions.rb b/actionpack/lib/action_dispatch/middleware/show_exceptions.rb
index 5eceeece1f..3d06214bf1 100644
--- a/actionpack/lib/action_dispatch/middleware/show_exceptions.rb
+++ b/actionpack/lib/action_dispatch/middleware/show_exceptions.rb
@@ -22,31 +22,7 @@ module ActionDispatch
"application's log file and/or the web server's log file to find out what " <<
"went wrong.</body></html>"]]
- class << self
- def rescue_responses
- ActiveSupport::Deprecation.warn "ActionDispatch::ShowExceptions.rescue_responses is deprecated. " \
- "Please configure your exceptions using a railtie or in your application config instead."
- ExceptionWrapper.rescue_responses
- end
-
- def rescue_templates
- ActiveSupport::Deprecation.warn "ActionDispatch::ShowExceptions.rescue_templates is deprecated. " \
- "Please configure your exceptions using a railtie or in your application config instead."
- ExceptionWrapper.rescue_templates
- end
- end
-
- def initialize(app, exceptions_app = nil)
- if [true, false].include?(exceptions_app)
- ActiveSupport::Deprecation.warn "Passing consider_all_requests_local option to ActionDispatch::ShowExceptions middleware no longer works"
- exceptions_app = nil
- end
-
- if exceptions_app.nil?
- raise ArgumentError, "You need to pass an exceptions_app when initializing ActionDispatch::ShowExceptions. " \
- "In case you want to render pages from a public path, you can use ActionDispatch::PublicExceptions.new('path/to/public')"
- end
-
+ def initialize(app, exceptions_app)
@app = app
@exceptions_app = exceptions_app
end
diff --git a/actionpack/lib/action_dispatch/routing/redirection.rb b/actionpack/lib/action_dispatch/routing/redirection.rb
index 330400e139..617b24b46a 100644
--- a/actionpack/lib/action_dispatch/routing/redirection.rb
+++ b/actionpack/lib/action_dispatch/routing/redirection.rb
@@ -97,16 +97,7 @@ module ActionDispatch
} if String === path
block = path if path.respond_to? :call
-
- # :FIXME: remove in Rails 4.0
- if block && block.respond_to?(:arity) && block.arity < 2
- msg = "redirect blocks with arity of #{block.arity} are deprecated. Your block must take 2 parameters: the environment, and a request object"
- ActiveSupport::Deprecation.warn msg
- block = lambda { |params, _| block.call(params) }
- end
-
raise ArgumentError, "redirection argument not supported" unless block
-
Redirect.new status, block
end
end
diff --git a/actionpack/lib/action_pack/version.rb b/actionpack/lib/action_pack/version.rb
index add6b56425..94cbc8e478 100644
--- a/actionpack/lib/action_pack/version.rb
+++ b/actionpack/lib/action_pack/version.rb
@@ -1,7 +1,7 @@
module ActionPack
module VERSION #:nodoc:
- MAJOR = 3
- MINOR = 2
+ MAJOR = 4
+ MINOR = 0
TINY = 0
PRE = "beta"
diff --git a/actionpack/lib/action_view/helpers/asset_paths.rb b/actionpack/lib/action_view/helpers/asset_paths.rb
deleted file mode 100644
index fae2e4fc1c..0000000000
--- a/actionpack/lib/action_view/helpers/asset_paths.rb
+++ /dev/null
@@ -1,7 +0,0 @@
-ActiveSupport::Deprecation.warn "ActionView::Helpers::AssetPaths is deprecated. Please use ActionView::AssetPaths instead."
-
-module ActionView
- module Helpers
- AssetPaths = ::ActionView::AssetPaths
- end
-end \ No newline at end of file
diff --git a/actionpack/lib/action_view/lookup_context.rb b/actionpack/lib/action_view/lookup_context.rb
index 3bb2b98e48..3f07314dda 100644
--- a/actionpack/lib/action_view/lookup_context.rb
+++ b/actionpack/lib/action_view/lookup_context.rb
@@ -151,14 +151,8 @@ module ActionView
# as well as incorrectly putting part of the path in the template
# name instead of the prefix.
def normalize_name(name, prefixes) #:nodoc:
- name = name.to_s.sub(handlers_regexp) do |match|
- ActiveSupport::Deprecation.warn "Passing a template handler in the template name is deprecated. " \
- "You can simply remove the handler name or pass render :handlers => [:#{match[1..-1]}] instead.", caller
- ""
- end
-
prefixes = nil if prefixes.blank?
- parts = name.split('/')
+ parts = name.to_s.split('/')
name = parts.pop
return name, prefixes || [""] if parts.empty?
@@ -168,10 +162,6 @@ module ActionView
return name, prefixes
end
-
- def handlers_regexp #:nodoc:
- @@handlers_regexp ||= /\.(?:#{default_handlers.join('|')})$/
- end
end
include Accessors
diff --git a/actionpack/lib/action_view/renderer/abstract_renderer.rb b/actionpack/lib/action_view/renderer/abstract_renderer.rb
index c0936441ac..5a611e9f63 100644
--- a/actionpack/lib/action_view/renderer/abstract_renderer.rb
+++ b/actionpack/lib/action_view/renderer/abstract_renderer.rb
@@ -22,18 +22,6 @@ module ActionView
details
end
- def extract_format(value, details)
- if value.is_a?(String) && value.sub!(formats_regexp, "")
- ActiveSupport::Deprecation.warn "Passing the format in the template name is deprecated. " \
- "Please pass render with :formats => [:#{$1}] instead.", caller
- details[:formats] ||= [$1.to_sym]
- end
- end
-
- def formats_regexp
- @@formats_regexp ||= /\.(#{Mime::SET.symbols.join('|')})$/
- end
-
def instrument(name, options={})
ActiveSupport::Notifications.instrument("render_#{name}.action_view", options){ yield }
end
diff --git a/actionpack/lib/action_view/renderer/partial_renderer.rb b/actionpack/lib/action_view/renderer/partial_renderer.rb
index 374bdb62f5..e231aade01 100644
--- a/actionpack/lib/action_view/renderer/partial_renderer.rb
+++ b/actionpack/lib/action_view/renderer/partial_renderer.rb
@@ -300,7 +300,6 @@ module ActionView
"and is followed by any combinations of letters, numbers, or underscores.")
end
- extract_format(@path, @details)
self
end
@@ -369,13 +368,7 @@ module ActionView
path = if object.respond_to?(:to_partial_path)
object.to_partial_path
else
- klass = object.class
- if klass.respond_to?(:model_name)
- ActiveSupport::Deprecation.warn "ActiveModel-compatible objects whose classes return a #model_name that responds to #partial_path are deprecated. Please respond to #to_partial_path directly instead."
- klass.model_name.partial_path
- else
- raise ArgumentError.new("'#{object.inspect}' is not an ActiveModel-compatible object that returns a valid partial path.")
- end
+ raise ArgumentError.new("'#{object.inspect}' is not an ActiveModel-compatible object. It must implement :to_partial_path.")
end
@partial_names[path] ||= merge_prefix_into_object_path(@context_prefix, path.dup)
diff --git a/actionpack/lib/action_view/renderer/template_renderer.rb b/actionpack/lib/action_view/renderer/template_renderer.rb
index e131afa279..3e3a44b432 100644
--- a/actionpack/lib/action_view/renderer/template_renderer.rb
+++ b/actionpack/lib/action_view/renderer/template_renderer.rb
@@ -6,7 +6,6 @@ module ActionView
def render(context, options)
@view = context
@details = extract_details(options)
- extract_format(options[:file] || options[:template], @details)
template = determine_template(options)
freeze_formats(template.formats, true)
render_template(template, options[:layout], options[:locals])
diff --git a/actionpack/lib/action_view/template.rb b/actionpack/lib/action_view/template.rb
index 10797c010f..eac6287b0b 100644
--- a/actionpack/lib/action_view/template.rb
+++ b/actionpack/lib/action_view/template.rb
@@ -173,6 +173,50 @@ module ActionView
@inspect ||= defined?(Rails.root) ? identifier.sub("#{Rails.root}/", '') : identifier
end
+ # This method is responsible for properly setting the encoding of the
+ # source. Until this point, we assume that the source is BINARY data.
+ # If no additional information is supplied, we assume the encoding is
+ # the same as <tt>Encoding.default_external</tt>.
+ #
+ # The user can also specify the encoding via a comment on the first
+ # line of the template (# encoding: NAME-OF-ENCODING). This will work
+ # with any template engine, as we process out the encoding comment
+ # before passing the source on to the template engine, leaving a
+ # blank line in its stead.
+ def encode!
+ return unless source.encoding_aware? && source.encoding == Encoding::BINARY
+
+ # Look for # encoding: *. If we find one, we'll encode the
+ # String in that encoding, otherwise, we'll use the
+ # default external encoding.
+ if source.sub!(/\A#{ENCODING_FLAG}/, '')
+ encoding = magic_encoding = $1
+ else
+ encoding = Encoding.default_external
+ end
+
+ # Tag the source with the default external encoding
+ # or the encoding specified in the file
+ source.force_encoding(encoding)
+
+ # If the user didn't specify an encoding, and the handler
+ # handles encodings, we simply pass the String as is to
+ # the handler (with the default_external tag)
+ if !magic_encoding && @handler.respond_to?(:handles_encoding?) && @handler.handles_encoding?
+ source
+ # Otherwise, if the String is valid in the encoding,
+ # encode immediately to default_internal. This means
+ # that if a handler doesn't handle encodings, it will
+ # always get Strings in the default_internal
+ elsif source.valid_encoding?
+ source.encode!
+ # Otherwise, since the String is invalid in the encoding
+ # specified, raise an exception
+ else
+ raise WrongEncodingError.new(source, encoding)
+ end
+ end
+
protected
# Compile a template. This method ensures a template is compiled
@@ -195,15 +239,7 @@ module ActionView
end
# Among other things, this method is responsible for properly setting
- # the encoding of the source. Until this point, we assume that the
- # source is BINARY data. If no additional information is supplied,
- # we assume the encoding is the same as <tt>Encoding.default_external</tt>.
- #
- # The user can also specify the encoding via a comment on the first
- # line of the template (# encoding: NAME-OF-ENCODING). This will work
- # with any template engine, as we process out the encoding comment
- # before passing the source on to the template engine, leaving a
- # blank line in its stead.
+ # the encoding of the compiled template.
#
# If the template engine handles encodings, we send the encoded
# String to the engine without further processing. This allows
@@ -215,40 +251,8 @@ module ActionView
# In general, this means that templates will be UTF-8 inside of Rails,
# regardless of the original source encoding.
def compile(view, mod) #:nodoc:
+ encode!
method_name = self.method_name
-
- if source.encoding_aware?
- # Look for # encoding: *. If we find one, we'll encode the
- # String in that encoding, otherwise, we'll use the
- # default external encoding.
- if source.sub!(/\A#{ENCODING_FLAG}/, '')
- encoding = magic_encoding = $1
- else
- encoding = Encoding.default_external
- end
-
- # Tag the source with the default external encoding
- # or the encoding specified in the file
- source.force_encoding(encoding)
-
- # If the user didn't specify an encoding, and the handler
- # handles encodings, we simply pass the String as is to
- # the handler (with the default_external tag)
- if !magic_encoding && @handler.respond_to?(:handles_encoding?) && @handler.handles_encoding?
- source
- # Otherwise, if the String is valid in the encoding,
- # encode immediately to default_internal. This means
- # that if a handler doesn't handle encodings, it will
- # always get Strings in the default_internal
- elsif source.valid_encoding?
- source.encode!
- # Otherwise, since the String is invalid in the encoding
- # specified, raise an exception
- else
- raise WrongEncodingError.new(source, encoding)
- end
- end
-
code = @handler.call(self)
# Make sure that the resulting String to be evalled is in the
@@ -297,7 +301,11 @@ module ActionView
raise e
else
assigns = view.respond_to?(:assigns) ? view.assigns : {}
- template = @virtual_path ? refresh(view) : self
+ template = self
+ unless template.source
+ template = refresh(view)
+ template.encode!
+ end
raise Template::Error.new(template, assigns, e)
end
end
diff --git a/actionpack/lib/action_view/template/error.rb b/actionpack/lib/action_view/template/error.rb
index fe27e54037..587e37a84f 100644
--- a/actionpack/lib/action_view/template/error.rb
+++ b/actionpack/lib/action_view/template/error.rb
@@ -89,14 +89,10 @@ module ActionView
line_counter = start_on_line
return unless source_code = source_code[start_on_line..end_on_line]
- extract = source_code.sum do |line|
+ source_code.sum do |line|
line_counter += 1
"#{indent}#{line_counter}: #{line}\n"
end
-
- extract.encode! if extract.respond_to?(:encode!)
-
- extract
end
def sub_template_of(template_path)
diff --git a/actionpack/test/abstract/layouts_test.rb b/actionpack/test/abstract/layouts_test.rb
index de6f42d826..fc25718d9e 100644
--- a/actionpack/test/abstract/layouts_test.rb
+++ b/actionpack/test/abstract/layouts_test.rb
@@ -57,11 +57,8 @@ module AbstractControllerTests
layout "hello_override"
end
- class WithNilChild < WithString
- layout nil
- end
-
class WithStringImpliedChild < WithString
+ layout nil
end
class WithChildOfImplied < WithStringImpliedChild
@@ -258,20 +255,14 @@ module AbstractControllerTests
test "when a child controller has an implied layout, use that layout and not the parent controller layout" do
controller = WithStringImpliedChild.new
- assert_deprecated { controller.process(:index) }
- assert_equal "With Implied Hello string!", controller.response_body
- end
-
- test "when a child controller specifies layout nil, do not use the parent layout" do
- controller = WithNilChild.new
controller.process(:index)
- assert_equal "Hello string!", controller.response_body
+ assert_equal "With Implied Hello string!", controller.response_body
end
test "when a grandchild has no layout specified, the child has an implied layout, and the " \
"parent has specified a layout, use the child controller layout" do
controller = WithChildOfImplied.new
- assert_deprecated { controller.process(:index) }
+ controller.process(:index)
assert_equal "With Implied Hello string!", controller.response_body
end
diff --git a/actionpack/test/controller/render_test.rb b/actionpack/test/controller/render_test.rb
index 243bad8749..768cfb34ac 100644
--- a/actionpack/test/controller/render_test.rb
+++ b/actionpack/test/controller/render_test.rb
@@ -25,6 +25,8 @@ end
class TestController < ActionController::Base
protect_from_forgery
+ before_filter :set_variable_for_layout
+
class LabellingFormBuilder < ActionView::Helpers::FormBuilder
end
@@ -41,7 +43,7 @@ class TestController < ActionController::Base
end
def hello_world_file
- render :file => File.expand_path("../../fixtures/hello.html", __FILE__)
+ render :file => File.expand_path("../../fixtures/hello", __FILE__), :formats => [:html]
end
def conditional_hello
@@ -364,17 +366,14 @@ class TestController < ActionController::Base
end
def layout_test_with_different_layout
- @variable_for_layout = nil
render :action => "hello_world", :layout => "standard"
end
def layout_test_with_different_layout_and_string_action
- @variable_for_layout = nil
render "hello_world", :layout => "standard"
end
def layout_test_with_different_layout_and_symbol_action
- @variable_for_layout = nil
render :hello_world, :layout => "standard"
end
@@ -383,7 +382,6 @@ class TestController < ActionController::Base
end
def layout_overriding_layout
- @variable_for_layout = nil
render :action => "hello_world", :layout => "standard"
end
@@ -666,8 +664,11 @@ class TestController < ActionController::Base
private
+ def set_variable_for_layout
+ @variable_for_layout = nil
+ end
+
def determine_layout
- @variable_for_layout ||= nil
case action_name
when "hello_world", "layout_test", "rendering_without_layout",
"rendering_nothing_on_layout", "render_text_hello_world",
@@ -809,9 +810,7 @@ class RenderTest < ActionController::TestCase
end
def test_render_file
- assert_deprecated do
- get :hello_world_file
- end
+ get :hello_world_file
assert_equal "Hello world!", @response.body
end
diff --git a/actionpack/test/controller/routing_test.rb b/actionpack/test/controller/routing_test.rb
index 062fc1f94e..f40d663ae8 100644
--- a/actionpack/test/controller/routing_test.rb
+++ b/actionpack/test/controller/routing_test.rb
@@ -85,6 +85,57 @@ class LegacyRouteSetTests < Test::Unit::TestCase
@rs.clear!
end
+ def test_class_and_lambda_constraints
+ subdomain = Class.new {
+ def matches? request
+ request.subdomain.present? and request.subdomain != 'clients'
+ end
+ }
+
+ @rs.draw do
+ match '/', :constraints => subdomain.new,
+ :to => lambda { |env| [200, {}, 'default'] }
+ match '/', :constraints => { :subdomain => 'clients' },
+ :to => lambda { |env| [200, {}, 'clients'] }
+ end
+
+ body = @rs.call({'PATH_INFO' => '/',
+ 'REQUEST_METHOD' => 'GET',
+ 'HTTP_HOST' => 'www.example.org'})[2]
+
+ assert_equal 'default', body
+
+ body = @rs.call({'PATH_INFO' => '/',
+ 'REQUEST_METHOD' => 'GET',
+ 'HTTP_HOST' => 'clients.example.org'})[2]
+
+ assert_equal 'clients', body
+ end
+
+ def test_lambda_constraints
+ @rs.draw do
+ match '/', :constraints => lambda { |req|
+ req.subdomain.present? and req.subdomain != "clients" },
+ :to => lambda { |env| [200, {}, 'default'] }
+
+ match '/', :constraints => lambda { |req|
+ req.subdomain.present? && req.subdomain == "clients" },
+ :to => lambda { |env| [200, {}, 'clients'] }
+ end
+
+ body = @rs.call({'PATH_INFO' => '/',
+ 'REQUEST_METHOD' => 'GET',
+ 'HTTP_HOST' => 'www.example.org'})[2]
+
+ assert_equal 'default', body
+
+ body = @rs.call({'PATH_INFO' => '/',
+ 'REQUEST_METHOD' => 'GET',
+ 'HTTP_HOST' => 'clients.example.org'})[2]
+
+ assert_equal 'clients', body
+ end
+
def test_draw_with_block_arity_one_raises
assert_raise(RuntimeError) do
@rs.draw { |map| map.match '/:controller(/:action(/:id))' }
diff --git a/actionpack/test/dispatch/mount_test.rb b/actionpack/test/dispatch/mount_test.rb
index 1a032539b9..f7a746120e 100644
--- a/actionpack/test/dispatch/mount_test.rb
+++ b/actionpack/test/dispatch/mount_test.rb
@@ -51,4 +51,4 @@ class TestRoutingMount < ActionDispatch::IntegrationTest
get "/fakeengine"
assert_equal "OK", response.body
end
-end \ No newline at end of file
+end
diff --git a/actionpack/test/template/render_test.rb b/actionpack/test/template/render_test.rb
index c29519276d..2ba86306f4 100644
--- a/actionpack/test/template/render_test.rb
+++ b/actionpack/test/template/render_test.rb
@@ -146,7 +146,7 @@ module RenderTestCases
@view.render(:partial => nil)
flunk "Render did not raise ArgumentError"
rescue ArgumentError => e
- assert_equal "'#{nil.inspect}' is not an ActiveModel-compatible object that returns a valid partial path.", e.message
+ assert_equal "'#{nil.inspect}' is not an ActiveModel-compatible object. It must implement :to_partial_path.", e.message
end
def test_render_partial_with_errors
@@ -243,36 +243,6 @@ module RenderTestCases
@controller_view.render(customers, :greeting => "Hello")
end
- class CustomerWithDeprecatedPartialPath
- attr_reader :name
-
- def self.model_name
- Struct.new(:partial_path).new("customers/customer")
- end
-
- def initialize(name)
- @name = name
- end
- end
-
- def test_render_partial_using_object_with_deprecated_partial_path
- assert_deprecated(/#model_name.*#partial_path.*#to_partial_path/) do
- assert_equal "Hello: nertzy",
- @controller_view.render(CustomerWithDeprecatedPartialPath.new("nertzy"), :greeting => "Hello")
- end
- end
-
- def test_render_partial_using_collection_with_deprecated_partial_path
- assert_deprecated(/#model_name.*#partial_path.*#to_partial_path/) do
- customers = [
- CustomerWithDeprecatedPartialPath.new("nertzy"),
- CustomerWithDeprecatedPartialPath.new("peeja")
- ]
- assert_equal "Hello: nertzyHello: peeja",
- @controller_view.render(customers, :greeting => "Hello")
- end
- end
-
# TODO: The reason for this test is unclear, improve documentation
def test_render_partial_and_fallback_to_layout
assert_equal "Before (Josh)\n\nAfter", @view.render(:partial => "test/layout_for_partial", :locals => { :name => "Josh" })
diff --git a/activemodel/activemodel.gemspec b/activemodel/activemodel.gemspec
index 49f664bf89..283c3ee324 100644
--- a/activemodel/activemodel.gemspec
+++ b/activemodel/activemodel.gemspec
@@ -18,5 +18,4 @@ Gem::Specification.new do |s|
s.add_dependency('activesupport', version)
s.add_dependency('builder', '~> 3.0.0')
- s.add_dependency('i18n', '~> 0.6')
end
diff --git a/activemodel/lib/active_model/version.rb b/activemodel/lib/active_model/version.rb
index dbda55ca7c..e195c12a4d 100644
--- a/activemodel/lib/active_model/version.rb
+++ b/activemodel/lib/active_model/version.rb
@@ -1,7 +1,7 @@
module ActiveModel
module VERSION #:nodoc:
- MAJOR = 3
- MINOR = 2
+ MAJOR = 4
+ MINOR = 0
TINY = 0
PRE = "beta"
diff --git a/activerecord/lib/active_record/fixtures.rb b/activerecord/lib/active_record/fixtures.rb
index d8340bf1c9..da72d1718e 100644
--- a/activerecord/lib/active_record/fixtures.rb
+++ b/activerecord/lib/active_record/fixtures.rb
@@ -10,7 +10,6 @@ require 'zlib'
require 'active_support/dependencies'
require 'active_support/core_ext/array/wrap'
require 'active_support/core_ext/object/blank'
-require 'active_support/core_ext/logger'
require 'active_support/ordered_hash'
require 'active_record/fixtures/file'
diff --git a/activerecord/lib/active_record/railties/databases.rake b/activerecord/lib/active_record/railties/databases.rake
index 0d1d9845ae..199eee4359 100644
--- a/activerecord/lib/active_record/railties/databases.rake
+++ b/activerecord/lib/active_record/railties/databases.rake
@@ -446,26 +446,39 @@ db_namespace = namespace :db do
end
namespace :test do
- # desc "Recreate the test database from the current schema.rb"
+
+ # desc "Recreate the test database from the current schema"
task :load => 'db:test:purge' do
- ActiveRecord::Base.establish_connection(ActiveRecord::Base.configurations['test'])
- ActiveRecord::Schema.verbose = false
- db_namespace["schema:load"].invoke if ActiveRecord::Base.schema_format == :ruby
+ case ActiveRecord::Base.schema_format
+ when :ruby
+ db_namespace["test:load_schema"].invoke
+ when :sql
+ db_namespace["test:load_structure"].invoke
+ end
+ end
+ # desc "Recreate the test database from an existent structure.sql file"
+ task :load_structure => 'db:test:purge' do
begin
old_env, ENV['RAILS_ENV'] = ENV['RAILS_ENV'], 'test'
- db_namespace["structure:load"].invoke if ActiveRecord::Base.schema_format == :sql
+ db_namespace["structure:load"].invoke
ensure
ENV['RAILS_ENV'] = old_env
end
+ end
+ # desc "Recreate the test database from an existent schema.rb file"
+ task :load_schema => 'db:test:purge' do
+ ActiveRecord::Base.establish_connection(ActiveRecord::Base.configurations['test'])
+ ActiveRecord::Schema.verbose = false
+ db_namespace["schema:load"].invoke
end
- # desc "Recreate the test database from the current environment's database schema"
- task :clone => %w(db:schema:dump db:test:load)
+ # desc "Recreate the test database from a fresh schema.rb file"
+ task :clone => %w(db:schema:dump db:test:load_schema)
- # desc "Recreate the test databases from the structure.sql file"
- task :clone_structure => [ "db:structure:dump", "db:test:load" ]
+ # desc "Recreate the test database from a fresh structure.sql file"
+ task :clone_structure => [ "db:structure:dump", "db:test:load_structure" ]
# desc "Empty the test database"
task :purge => :environment do
diff --git a/activerecord/lib/active_record/scoping/default.rb b/activerecord/lib/active_record/scoping/default.rb
index 9840cbccae..6b5070808a 100644
--- a/activerecord/lib/active_record/scoping/default.rb
+++ b/activerecord/lib/active_record/scoping/default.rb
@@ -12,7 +12,7 @@ module ActiveRecord
end
module ClassMethods
- # Returns a scope for this class without taking into account the default_scope.
+ # Returns a scope for the model without the default_scope.
#
# class Post < ActiveRecord::Base
# def self.default_scope
@@ -23,18 +23,20 @@ module ActiveRecord
# Post.all # Fires "SELECT * FROM posts WHERE published = true"
# Post.unscoped.all # Fires "SELECT * FROM posts"
#
- # This method also accepts a block meaning that all queries inside the block will
+ # This method also accepts a block. All queries inside the block will
# not use the default_scope:
#
# Post.unscoped {
# Post.limit(10) # Fires "SELECT * FROM posts LIMIT 10"
# }
#
- # It is recommended to use block form of unscoped because chaining unscoped with <tt>scope</tt>
- # does not work. Assuming that <tt>published</tt> is a <tt>scope</tt> following two statements are same.
+ # It is recommended to use the block form of unscoped because chaining
+ # unscoped with <tt>scope</tt> does not work. Assuming that
+ # <tt>published</tt> is a <tt>scope</tt>, the following two statements
+ # are equal: the default_scope is applied on both.
#
- # Post.unscoped.published
- # Post.published
+ # Post.unscoped.published
+ # Post.published
def unscoped #:nodoc:
block_given? ? relation.scoping { yield } : relation
end
diff --git a/activerecord/lib/active_record/version.rb b/activerecord/lib/active_record/version.rb
index 838aa8fb1e..0c35adc11d 100644
--- a/activerecord/lib/active_record/version.rb
+++ b/activerecord/lib/active_record/version.rb
@@ -1,7 +1,7 @@
module ActiveRecord
module VERSION #:nodoc:
- MAJOR = 3
- MINOR = 2
+ MAJOR = 4
+ MINOR = 0
TINY = 0
PRE = "beta"
diff --git a/activerecord/test/cases/base_test.rb b/activerecord/test/cases/base_test.rb
index dd0aeada51..1012bfbd94 100644
--- a/activerecord/test/cases/base_test.rb
+++ b/activerecord/test/cases/base_test.rb
@@ -1888,7 +1888,7 @@ class BasicsTest < ActiveRecord::TestCase
def test_silence_sets_log_level_to_error_in_block
original_logger = ActiveRecord::Base.logger
log = StringIO.new
- ActiveRecord::Base.logger = Logger.new(log)
+ ActiveRecord::Base.logger = ActiveSupport::Logger.new(log)
ActiveRecord::Base.logger.level = Logger::DEBUG
ActiveRecord::Base.silence do
ActiveRecord::Base.logger.warn "warn"
@@ -1902,7 +1902,7 @@ class BasicsTest < ActiveRecord::TestCase
def test_silence_sets_log_level_back_to_level_before_yield
original_logger = ActiveRecord::Base.logger
log = StringIO.new
- ActiveRecord::Base.logger = Logger.new(log)
+ ActiveRecord::Base.logger = ActiveSupport::Logger.new(log)
ActiveRecord::Base.logger.level = Logger::WARN
ActiveRecord::Base.silence do
end
@@ -1930,9 +1930,7 @@ class BasicsTest < ActiveRecord::TestCase
original_logger = ActiveRecord::Base.logger
log = StringIO.new
ActiveRecord::Base.logger = Logger.new(log)
- ActiveRecord::Base.benchmark("Logging", :level => :debug, :silence => true) { ActiveRecord::Base.logger.debug "Loud" }
ActiveRecord::Base.benchmark("Logging", :level => :debug, :silence => false) { ActiveRecord::Base.logger.debug "Quiet" }
- assert_no_match(/Loud/, log.string)
assert_match(/Quiet/, log.string)
ensure
ActiveRecord::Base.logger = original_logger
diff --git a/activerecord/test/cases/helper.rb b/activerecord/test/cases/helper.rb
index ae2c230d15..859c3d1947 100644
--- a/activerecord/test/cases/helper.rb
+++ b/activerecord/test/cases/helper.rb
@@ -8,6 +8,7 @@ require 'mocha'
require 'active_record'
require 'active_support/dependencies'
+require 'active_support/logger'
require 'support/config'
require 'support/connection'
@@ -90,7 +91,10 @@ end
unless ENV['FIXTURE_DEBUG']
module ActiveRecord::TestFixtures::ClassMethods
def try_to_load_dependency_with_silence(*args)
- ActiveRecord::Base.logger.silence { try_to_load_dependency_without_silence(*args)}
+ old = ActiveRecord::Base.logger.level
+ ActiveRecord::Base.logger.level = ActiveSupport::Logger::ERROR
+ try_to_load_dependency_without_silence(*args)
+ ActiveRecord::Base.logger.level = old
end
alias_method_chain :try_to_load_dependency, :silence
diff --git a/activerecord/test/cases/log_subscriber_test.rb b/activerecord/test/cases/log_subscriber_test.rb
index e24a5ca5aa..d1f0ace184 100644
--- a/activerecord/test/cases/log_subscriber_test.rb
+++ b/activerecord/test/cases/log_subscriber_test.rb
@@ -5,7 +5,7 @@ require "active_support/log_subscriber/test_helper"
class LogSubscriberTest < ActiveRecord::TestCase
include ActiveSupport::LogSubscriber::TestHelper
- include ActiveSupport::BufferedLogger::Severity
+ include ActiveSupport::Logger::Severity
fixtures :posts
diff --git a/activeresource/lib/active_resource/version.rb b/activeresource/lib/active_resource/version.rb
index d53374b261..d02784bd5d 100644
--- a/activeresource/lib/active_resource/version.rb
+++ b/activeresource/lib/active_resource/version.rb
@@ -1,7 +1,7 @@
module ActiveResource
module VERSION #:nodoc:
- MAJOR = 3
- MINOR = 2
+ MAJOR = 4
+ MINOR = 0
TINY = 0
PRE = "beta"
diff --git a/activesupport/CHANGELOG.md b/activesupport/CHANGELOG.md
index 1516472fed..8299a3fc45 100644
--- a/activesupport/CHANGELOG.md
+++ b/activesupport/CHANGELOG.md
@@ -1,3 +1,8 @@
+## Rails 4.0.0 (unreleased) ##
+
+* BufferedLogger is deprecated. Use ActiveSupport::Logger, or the logger
+ from Ruby stdlib.
+
## Rails 3.2.0 (unreleased) ##
* Added Enumerable#pluck to wrap the common pattern of collect(&:method) *DHH*
diff --git a/activesupport/lib/active_support.rb b/activesupport/lib/active_support.rb
index ff78e718f2..896d0e5f65 100644
--- a/activesupport/lib/active_support.rb
+++ b/activesupport/lib/active_support.rb
@@ -38,6 +38,7 @@ end
require "active_support/dependencies/autoload"
require "active_support/version"
+require "active_support/logger"
module ActiveSupport
extend ActiveSupport::Autoload
@@ -53,7 +54,6 @@ module ActiveSupport
autoload :Base64
autoload :BasicObject
autoload :Benchmarkable
- autoload :BufferedLogger
autoload :Cache
autoload :Callbacks
autoload :Concern
@@ -62,7 +62,6 @@ module ActiveSupport
autoload :Gzip
autoload :Inflector
autoload :JSON
- autoload :Memoizable
autoload :MessageEncryptor
autoload :MessageVerifier
autoload :Multibyte
diff --git a/activesupport/lib/active_support/buffered_logger.rb b/activesupport/lib/active_support/buffered_logger.rb
index 775f9928e6..36e29644c6 100644
--- a/activesupport/lib/active_support/buffered_logger.rb
+++ b/activesupport/lib/active_support/buffered_logger.rb
@@ -1,125 +1,10 @@
require 'thread'
-require 'logger'
-require 'active_support/core_ext/logger'
require 'active_support/core_ext/class/attribute_accessors'
require 'active_support/deprecation'
+require 'active_support/logger'
require 'fileutils'
module ActiveSupport
- # Inspired by the buffered logger idea by Ezra
- class BufferedLogger
- module Severity
- DEBUG = 0
- INFO = 1
- WARN = 2
- ERROR = 3
- FATAL = 4
- UNKNOWN = 5
- end
- include Severity
-
- MAX_BUFFER_SIZE = 1000
-
- ##
- # :singleton-method:
- # Set to false to disable the silencer
- cattr_accessor :silencer
- self.silencer = true
-
- # Silences the logger for the duration of the block.
- def silence(temporary_level = ERROR)
- if silencer
- begin
- logger = self.class.new @log_dest, temporary_level
- yield logger
- ensure
- logger.close
- end
- else
- yield self
- end
- end
- deprecate :silence
-
- attr_reader :auto_flushing
- deprecate :auto_flushing
-
- def initialize(log, level = DEBUG)
- @level = level
- @log_dest = log
-
- unless log.respond_to?(:write)
- unless File.exist?(File.dirname(log))
- ActiveSupport::Deprecation.warn(<<-eowarn)
-Automatic directory creation for '#{log}' is deprecated. Please make sure the directory for your log file exists before creating the logger.
- eowarn
- FileUtils.mkdir_p(File.dirname(log))
- end
- end
-
- @log = open_logfile log
- end
-
- def open_log(log, mode)
- open(log, mode).tap do |open_log|
- open_log.set_encoding(Encoding::BINARY) if open_log.respond_to?(:set_encoding)
- open_log.sync = true
- end
- end
- deprecate :open_log
-
- def level
- @log.level
- end
-
- def level=(l)
- @log.level = l
- end
-
- def add(severity, message = nil, progname = nil, &block)
- @log.add(severity, message, progname, &block)
- end
-
- # Dynamically add methods such as:
- # def info
- # def warn
- # def debug
- Severity.constants.each do |severity|
- class_eval <<-EOT, __FILE__, __LINE__ + 1
- def #{severity.downcase}(message = nil, progname = nil, &block) # def debug(message = nil, progname = nil, &block)
- add(#{severity}, message, progname, &block) # add(DEBUG, message, progname, &block)
- end # end
-
- def #{severity.downcase}? # def debug?
- #{severity} >= level # DEBUG >= @level
- end # end
- EOT
- end
-
- # Set the auto-flush period. Set to true to flush after every log message,
- # to an integer to flush every N messages, or to false, nil, or zero to
- # never auto-flush. If you turn auto-flushing off, be sure to regularly
- # flush the log yourself -- it will eat up memory until you do.
- def auto_flushing=(period)
- end
- deprecate :auto_flushing=
-
- def flush
- end
- deprecate :flush
-
- def respond_to?(method, include_private = false)
- return false if method.to_s == "flush"
- super
- end
-
- def close
- @log.close
- end
-
- private
- def open_logfile(log)
- Logger.new log
- end
- end
+ BufferedLogger = ActiveSupport::Deprecation::DeprecatedConstantProxy.new(
+ 'BufferedLogger', '::ActiveSupport::Logger')
end
diff --git a/activesupport/lib/active_support/concern.rb b/activesupport/lib/active_support/concern.rb
index af3da937c7..c94a8d99f4 100644
--- a/activesupport/lib/active_support/concern.rb
+++ b/activesupport/lib/active_support/concern.rb
@@ -109,11 +109,6 @@ module ActiveSupport
@_dependencies.each { |dep| base.send(:include, dep) }
super
base.extend const_get("ClassMethods") if const_defined?("ClassMethods")
- if const_defined?("InstanceMethods")
- base.send :include, const_get("InstanceMethods")
- ActiveSupport::Deprecation.warn "The InstanceMethods module inside ActiveSupport::Concern will be " \
- "no longer included automatically. Please define instance methods directly in #{base} instead.", caller
- end
base.class_eval(&@_included_block) if instance_variable_defined?("@_included_block")
end
end
diff --git a/activesupport/lib/active_support/core_ext.rb b/activesupport/lib/active_support/core_ext.rb
index 46a8609dd7..b48bdf08e8 100644
--- a/activesupport/lib/active_support/core_ext.rb
+++ b/activesupport/lib/active_support/core_ext.rb
@@ -1,3 +1,4 @@
Dir["#{File.dirname(__FILE__)}/core_ext/*.rb"].sort.each do |path|
+ next if File.basename(path, '.rb') == 'logger'
require "active_support/core_ext/#{File.basename(path, '.rb')}"
end
diff --git a/activesupport/lib/active_support/core_ext/date/calculations.rb b/activesupport/lib/active_support/core_ext/date/calculations.rb
index f0f67765c6..2212e0b3ca 100644
--- a/activesupport/lib/active_support/core_ext/date/calculations.rb
+++ b/activesupport/lib/active_support/core_ext/date/calculations.rb
@@ -7,24 +7,6 @@ require 'active_support/core_ext/time/zones'
class Date
DAYS_INTO_WEEK = { :monday => 0, :tuesday => 1, :wednesday => 2, :thursday => 3, :friday => 4, :saturday => 5, :sunday => 6 }
- if RUBY_VERSION < '1.9'
- undef :>>
-
- # Backported from 1.9. The one in 1.8 leads to incorrect next_month and
- # friends for dates where the calendar reform is involved. It additionally
- # prevents an infinite loop fixed in r27013.
- def >>(n)
- y, m = (year * 12 + (mon - 1) + n).divmod(12)
- m, = (m + 1) .divmod(1)
- d = mday
- until jd2 = self.class.valid_civil?(y, m, d, start)
- d -= 1
- raise ArgumentError, 'invalid date' unless d > 0
- end
- self + (jd2 - jd)
- end
- end
-
class << self
# Returns a new Date representing the date 1 day ago (i.e. yesterday's date).
def yesterday
diff --git a/activesupport/lib/active_support/core_ext/date/conversions.rb b/activesupport/lib/active_support/core_ext/date/conversions.rb
index 338104fd05..3262c254f7 100644
--- a/activesupport/lib/active_support/core_ext/date/conversions.rb
+++ b/activesupport/lib/active_support/core_ext/date/conversions.rb
@@ -63,12 +63,6 @@ class Date
alias_method :default_inspect, :inspect
alias_method :inspect, :readable_inspect
- # A method to keep Time, Date and DateTime instances interchangeable on conversions.
- # In this case, it simply returns +self+.
- def to_date
- self
- end if RUBY_VERSION < '1.9'
-
# Converts a Date instance to a Time, where the time is set to the beginning of the day.
# The timezone can be either :local or :utc (default :local).
#
@@ -83,23 +77,6 @@ class Date
::Time.send("#{form}_time", year, month, day)
end
- # Converts a Date instance to a DateTime, where the time is set to the beginning of the day
- # and UTC offset is set to 0.
- #
- # ==== Examples
- # date = Date.new(2007, 11, 10) # => Sat, 10 Nov 2007
- #
- # date.to_datetime # => Sat, 10 Nov 2007 00:00:00 0000
- def to_datetime
- ::DateTime.civil(year, month, day, 0, 0, 0, 0)
- end if RUBY_VERSION < '1.9'
-
- def iso8601
- strftime('%F')
- end if RUBY_VERSION < '1.9'
-
- alias_method :rfc3339, :iso8601 if RUBY_VERSION < '1.9'
-
def xmlschema
to_time_in_current_zone.xmlschema
end
diff --git a/activesupport/lib/active_support/core_ext/date_time/calculations.rb b/activesupport/lib/active_support/core_ext/date_time/calculations.rb
index 48cf1a435d..1a3cf66a1b 100644
--- a/activesupport/lib/active_support/core_ext/date_time/calculations.rb
+++ b/activesupport/lib/active_support/core_ext/date_time/calculations.rb
@@ -1,5 +1,3 @@
-require 'rational' unless RUBY_VERSION >= '1.9.2'
-
class DateTime
class << self
# DateTimes aren't aware of DST rules, so use a consistent non-DST offset when creating a DateTime with an offset in the local zone
diff --git a/activesupport/lib/active_support/core_ext/date_time/conversions.rb b/activesupport/lib/active_support/core_ext/date_time/conversions.rb
index ca899c714c..851012e3bf 100644
--- a/activesupport/lib/active_support/core_ext/date_time/conversions.rb
+++ b/activesupport/lib/active_support/core_ext/date_time/conversions.rb
@@ -66,7 +66,7 @@ class DateTime
# Attempts to convert self to a Ruby Time object; returns self if out of range of Ruby Time class.
# If self has an offset other than 0, self will just be returned unaltered, since there's no clean way to map it to a Time.
def to_time
- self.offset == 0 ? ::Time.utc_time(year, month, day, hour, min, sec, sec_fraction * (RUBY_VERSION < '1.9' ? 86400000000 : 1000000)) : self
+ self.offset == 0 ? ::Time.utc_time(year, month, day, hour, min, sec, sec_fraction * 1000000) : self
end
# To be able to keep Times, Dates and DateTimes interchangeable on conversions.
diff --git a/activesupport/lib/active_support/core_ext/enumerable.rb b/activesupport/lib/active_support/core_ext/enumerable.rb
index d9856f2e84..ccd0e9692d 100644
--- a/activesupport/lib/active_support/core_ext/enumerable.rb
+++ b/activesupport/lib/active_support/core_ext/enumerable.rb
@@ -1,41 +1,4 @@
-require 'active_support/ordered_hash'
-
module Enumerable
- # Ruby 1.8.7 introduces group_by, but the result isn't ordered. Override it.
- remove_method(:group_by) if [].respond_to?(:group_by) && RUBY_VERSION < '1.9'
-
- # Collect an enumerable into sets, grouped by the result of a block. Useful,
- # for example, for grouping records by date.
- #
- # Example:
- #
- # latest_transcripts.group_by(&:day).each do |day, transcripts|
- # p "#{day} -> #{transcripts.map(&:class).join(', ')}"
- # end
- # "2006-03-01 -> Transcript"
- # "2006-02-28 -> Transcript"
- # "2006-02-27 -> Transcript, Transcript"
- # "2006-02-26 -> Transcript, Transcript"
- # "2006-02-25 -> Transcript"
- # "2006-02-24 -> Transcript, Transcript"
- # "2006-02-23 -> Transcript"
- def group_by
- return to_enum :group_by unless block_given?
- assoc = ActiveSupport::OrderedHash.new
-
- each do |element|
- key = yield(element)
-
- if assoc.has_key?(key)
- assoc[key] << element
- else
- assoc[key] = [element]
- end
- end
-
- assoc
- end unless [].respond_to?(:group_by)
-
# Calculates a sum from the elements. Examples:
#
# payments.sum { |p| p.price * p.tax_rate }
diff --git a/activesupport/lib/active_support/core_ext/exception.rb b/activesupport/lib/active_support/core_ext/exception.rb
index ef801e713d..ba7757ea07 100644
--- a/activesupport/lib/active_support/core_ext/exception.rb
+++ b/activesupport/lib/active_support/core_ext/exception.rb
@@ -1,3 +1,3 @@
module ActiveSupport
- FrozenObjectError = RUBY_VERSION < '1.9' ? TypeError : RuntimeError
+ FrozenObjectError = RuntimeError
end
diff --git a/activesupport/lib/active_support/core_ext/logger.rb b/activesupport/lib/active_support/core_ext/logger.rb
index e63a0a9ed9..a51818d2b2 100644
--- a/activesupport/lib/active_support/core_ext/logger.rb
+++ b/activesupport/lib/active_support/core_ext/logger.rb
@@ -1,4 +1,7 @@
require 'active_support/core_ext/class/attribute_accessors'
+require 'active_support/deprecation'
+
+ActiveSupport::Deprecation.warn 'this file is deprecated and will be removed'
# Adds the 'around_level' method to Logger.
class Logger #:nodoc:
diff --git a/activesupport/lib/active_support/core_ext/module/introspection.rb b/activesupport/lib/active_support/core_ext/module/introspection.rb
index c08ad251dd..1893a9cfa6 100644
--- a/activesupport/lib/active_support/core_ext/module/introspection.rb
+++ b/activesupport/lib/active_support/core_ext/module/introspection.rb
@@ -57,27 +57,8 @@ class Module
parents
end
- if RUBY_VERSION < '1.9'
- # Returns the constants that have been defined locally by this object and
- # not in an ancestor. This method is exact if running under Ruby 1.9. In
- # previous versions it may miss some constants if their definition in some
- # ancestor is identical to their definition in the receiver.
- def local_constants
- inherited = {}
-
- ancestors.each do |anc|
- next if anc == self
- anc.constants.each { |const| inherited[const] = anc.const_get(const) }
- end
-
- constants.select do |const|
- !inherited.key?(const) || inherited[const].object_id != const_get(const).object_id
- end
- end
- else
- def local_constants #:nodoc:
- constants(false)
- end
+ def local_constants #:nodoc:
+ constants(false)
end
# Returns the names of the constants defined locally rather than the
diff --git a/activesupport/lib/active_support/core_ext/object/instance_variables.rb b/activesupport/lib/active_support/core_ext/object/instance_variables.rb
index eda9694614..66caf9bec8 100644
--- a/activesupport/lib/active_support/core_ext/object/instance_variables.rb
+++ b/activesupport/lib/active_support/core_ext/object/instance_variables.rb
@@ -23,11 +23,7 @@ class Object
# end
#
# C.new(0, 1).instance_variable_names # => ["@y", "@x"]
- if RUBY_VERSION >= '1.9'
- def instance_variable_names
- instance_variables.map { |var| var.to_s }
- end
- else
- alias_method :instance_variable_names, :instance_variables
+ def instance_variable_names
+ instance_variables.map { |var| var.to_s }
end
end
diff --git a/activesupport/lib/active_support/core_ext/range.rb b/activesupport/lib/active_support/core_ext/range.rb
index 2428a02242..c0736f3a44 100644
--- a/activesupport/lib/active_support/core_ext/range.rb
+++ b/activesupport/lib/active_support/core_ext/range.rb
@@ -2,4 +2,3 @@ require 'active_support/core_ext/range/blockless_step'
require 'active_support/core_ext/range/conversions'
require 'active_support/core_ext/range/include_range'
require 'active_support/core_ext/range/overlaps'
-require 'active_support/core_ext/range/cover'
diff --git a/activesupport/lib/active_support/core_ext/range/cover.rb b/activesupport/lib/active_support/core_ext/range/cover.rb
deleted file mode 100644
index 3a182cddd2..0000000000
--- a/activesupport/lib/active_support/core_ext/range/cover.rb
+++ /dev/null
@@ -1,3 +0,0 @@
-class Range
- alias_method(:cover?, :include?) unless instance_methods.include?(:cover?)
-end
diff --git a/activesupport/lib/active_support/core_ext/string/encoding.rb b/activesupport/lib/active_support/core_ext/string/encoding.rb
index d4781bfe0c..236f72e933 100644
--- a/activesupport/lib/active_support/core_ext/string/encoding.rb
+++ b/activesupport/lib/active_support/core_ext/string/encoding.rb
@@ -1,11 +1,5 @@
class String
- if defined?(Encoding) && "".respond_to?(:encode)
- def encoding_aware?
- true
- end
- else
- def encoding_aware?
- false
- end
+ def encoding_aware?
+ true
end
end \ No newline at end of file
diff --git a/activesupport/lib/active_support/core_ext/string/multibyte.rb b/activesupport/lib/active_support/core_ext/string/multibyte.rb
index 400db2ce39..4e7824ad74 100644
--- a/activesupport/lib/active_support/core_ext/string/multibyte.rb
+++ b/activesupport/lib/active_support/core_ext/string/multibyte.rb
@@ -2,71 +2,55 @@
require 'active_support/multibyte'
class String
- if RUBY_VERSION >= "1.9"
- # == Multibyte proxy
- #
- # +mb_chars+ is a multibyte safe proxy for string methods.
- #
- # In Ruby 1.8 and older it creates and returns an instance of the ActiveSupport::Multibyte::Chars class which
- # encapsulates the original string. A Unicode safe version of all the String methods are defined on this proxy
- # class. If the proxy class doesn't respond to a certain method, it's forwarded to the encapsulated string.
- #
- # name = 'Claus Müller'
- # name.reverse # => "rell??M sualC"
- # name.length # => 13
- #
- # name.mb_chars.reverse.to_s # => "rellüM sualC"
- # name.mb_chars.length # => 12
- #
- # In Ruby 1.9 and newer +mb_chars+ returns +self+ because String is (mostly) encoding aware. This means that
- # it becomes easy to run one version of your code on multiple Ruby versions.
- #
- # == Method chaining
- #
- # All the methods on the Chars proxy which normally return a string will return a Chars object. This allows
- # method chaining on the result of any of these methods.
- #
- # name.mb_chars.reverse.length # => 12
- #
- # == Interoperability and configuration
- #
- # The Chars object tries to be as interchangeable with String objects as possible: sorting and comparing between
- # String and Char work like expected. The bang! methods change the internal string representation in the Chars
- # object. Interoperability problems can be resolved easily with a +to_s+ call.
- #
- # For more information about the methods defined on the Chars proxy see ActiveSupport::Multibyte::Chars. For
- # information about how to change the default Multibyte behavior see ActiveSupport::Multibyte.
- def mb_chars
- if ActiveSupport::Multibyte.proxy_class.consumes?(self)
- ActiveSupport::Multibyte.proxy_class.new(self)
- else
- self
- end
- end
-
- def is_utf8?
- case encoding
- when Encoding::UTF_8
- valid_encoding?
- when Encoding::ASCII_8BIT, Encoding::US_ASCII
- dup.force_encoding(Encoding::UTF_8).valid_encoding?
- else
- false
- end
- end
- else
- def mb_chars
- if ActiveSupport::Multibyte.proxy_class.wants?(self)
- ActiveSupport::Multibyte.proxy_class.new(self)
- else
- self
- end
+ # == Multibyte proxy
+ #
+ # +mb_chars+ is a multibyte safe proxy for string methods.
+ #
+ # In Ruby 1.8 and older it creates and returns an instance of the ActiveSupport::Multibyte::Chars class which
+ # encapsulates the original string. A Unicode safe version of all the String methods are defined on this proxy
+ # class. If the proxy class doesn't respond to a certain method, it's forwarded to the encapsulated string.
+ #
+ # name = 'Claus Müller'
+ # name.reverse # => "rell??M sualC"
+ # name.length # => 13
+ #
+ # name.mb_chars.reverse.to_s # => "rellüM sualC"
+ # name.mb_chars.length # => 12
+ #
+ # In Ruby 1.9 and newer +mb_chars+ returns +self+ because String is (mostly) encoding aware. This means that
+ # it becomes easy to run one version of your code on multiple Ruby versions.
+ #
+ # == Method chaining
+ #
+ # All the methods on the Chars proxy which normally return a string will return a Chars object. This allows
+ # method chaining on the result of any of these methods.
+ #
+ # name.mb_chars.reverse.length # => 12
+ #
+ # == Interoperability and configuration
+ #
+ # The Chars object tries to be as interchangeable with String objects as possible: sorting and comparing between
+ # String and Char work like expected. The bang! methods change the internal string representation in the Chars
+ # object. Interoperability problems can be resolved easily with a +to_s+ call.
+ #
+ # For more information about the methods defined on the Chars proxy see ActiveSupport::Multibyte::Chars. For
+ # information about how to change the default Multibyte behavior see ActiveSupport::Multibyte.
+ def mb_chars
+ if ActiveSupport::Multibyte.proxy_class.consumes?(self)
+ ActiveSupport::Multibyte.proxy_class.new(self)
+ else
+ self
end
+ end
- # Returns true if the string has UTF-8 semantics (a String used for purely byte resources is unlikely to have
- # them), returns false otherwise.
- def is_utf8?
- ActiveSupport::Multibyte::Chars.consumes?(self)
+ def is_utf8?
+ case encoding
+ when Encoding::UTF_8
+ valid_encoding?
+ when Encoding::ASCII_8BIT, Encoding::US_ASCII
+ dup.force_encoding(Encoding::UTF_8).valid_encoding?
+ else
+ false
end
end
end
diff --git a/activesupport/lib/active_support/core_ext/uri.rb b/activesupport/lib/active_support/core_ext/uri.rb
index ee991e3439..0b219ce44a 100644
--- a/activesupport/lib/active_support/core_ext/uri.rb
+++ b/activesupport/lib/active_support/core_ext/uri.rb
@@ -1,22 +1,18 @@
# encoding: utf-8
-if RUBY_VERSION >= '1.9'
- require 'uri'
+require 'uri'
+str = "\xE6\x97\xA5\xE6\x9C\xAC\xE8\xAA\x9E" # Ni-ho-nn-go in UTF-8, means Japanese.
+parser = URI::Parser.new
- str = "\xE6\x97\xA5\xE6\x9C\xAC\xE8\xAA\x9E" # Ni-ho-nn-go in UTF-8, means Japanese.
-
- parser = URI::Parser.new
-
- unless str == parser.unescape(parser.escape(str))
- URI::Parser.class_eval do
- remove_method :unescape
- def unescape(str, escaped = /%[a-fA-F\d]{2}/)
- # TODO: Are we actually sure that ASCII == UTF-8?
- # YK: My initial experiments say yes, but let's be sure please
- enc = str.encoding
- enc = Encoding::UTF_8 if enc == Encoding::US_ASCII
- str.gsub(escaped) { [$&[1, 2].hex].pack('C') }.force_encoding(enc)
- end
+unless str == parser.unescape(parser.escape(str))
+ URI::Parser.class_eval do
+ remove_method :unescape
+ def unescape(str, escaped = /%[a-fA-F\d]{2}/)
+ # TODO: Are we actually sure that ASCII == UTF-8?
+ # YK: My initial experiments say yes, but let's be sure please
+ enc = str.encoding
+ enc = Encoding::UTF_8 if enc == Encoding::US_ASCII
+ str.gsub(escaped) { [$&[1, 2].hex].pack('C') }.force_encoding(enc)
end
end
end
diff --git a/activesupport/lib/active_support/log_subscriber/test_helper.rb b/activesupport/lib/active_support/log_subscriber/test_helper.rb
index dcfcf0b63c..7b7fc81e6c 100644
--- a/activesupport/lib/active_support/log_subscriber/test_helper.rb
+++ b/activesupport/lib/active_support/log_subscriber/test_helper.rb
@@ -50,7 +50,7 @@ module ActiveSupport
end
class MockLogger
- include ActiveSupport::BufferedLogger::Severity
+ include ActiveSupport::Logger::Severity
attr_reader :flush_count
attr_accessor :level
@@ -73,7 +73,7 @@ module ActiveSupport
@flush_count += 1
end
- ActiveSupport::BufferedLogger::Severity.constants.each do |severity|
+ ActiveSupport::Logger::Severity.constants.each do |severity|
class_eval <<-EOT, __FILE__, __LINE__ + 1
def #{severity.downcase}?
#{severity} >= @level
diff --git a/activesupport/lib/active_support/logger.rb b/activesupport/lib/active_support/logger.rb
new file mode 100644
index 0000000000..66e8fcadb4
--- /dev/null
+++ b/activesupport/lib/active_support/logger.rb
@@ -0,0 +1,18 @@
+require 'logger'
+
+module ActiveSupport
+ class Logger < ::Logger
+ def initialize(*args)
+ super
+ @formatter = SimpleFormatter.new
+ end
+
+ # Simple formatter which only displays the message.
+ class SimpleFormatter < ::Logger::Formatter
+ # This method is invoked when a log event occurs
+ def call(severity, timestamp, progname, msg)
+ "#{String === msg ? msg : msg.inspect}\n"
+ end
+ end
+ end
+end
diff --git a/activesupport/lib/active_support/memoizable.rb b/activesupport/lib/active_support/memoizable.rb
deleted file mode 100644
index 4c67676ad5..0000000000
--- a/activesupport/lib/active_support/memoizable.rb
+++ /dev/null
@@ -1,116 +0,0 @@
-require 'active_support/core_ext/kernel/singleton_class'
-require 'active_support/core_ext/module/aliasing'
-require 'active_support/deprecation'
-
-module ActiveSupport
- module Memoizable
- def self.extended(base)
- ActiveSupport::Deprecation.warn "ActiveSupport::Memoizable is deprecated and will be removed in future releases," \
- "simply use Ruby memoization pattern instead.", caller
- super
- end
-
- def self.memoized_ivar_for(symbol)
- "@_memoized_#{symbol.to_s.sub(/\?\Z/, '_query').sub(/!\Z/, '_bang')}".to_sym
- end
-
- module InstanceMethods
- def self.included(base)
- base.class_eval do
- unless base.method_defined?(:freeze_without_memoizable)
- alias_method_chain :freeze, :memoizable
- end
- end
- end
-
- def freeze_with_memoizable
- memoize_all unless frozen?
- freeze_without_memoizable
- end
-
- def memoize_all
- prime_cache ".*"
- end
-
- def unmemoize_all
- flush_cache ".*"
- end
-
- def prime_cache(*syms)
- syms.each do |sym|
- methods.each do |m|
- if m.to_s =~ /^_unmemoized_(#{sym})/
- if method(m).arity == 0
- __send__($1)
- else
- ivar = ActiveSupport::Memoizable.memoized_ivar_for($1)
- instance_variable_set(ivar, {})
- end
- end
- end
- end
- end
-
- def flush_cache(*syms)
- syms.each do |sym|
- (methods + private_methods + protected_methods).each do |m|
- if m.to_s =~ /^_unmemoized_(#{sym.to_s.gsub(/\?\Z/, '\?')})/
- ivar = ActiveSupport::Memoizable.memoized_ivar_for($1)
- instance_variable_get(ivar).clear if instance_variable_defined?(ivar)
- end
- end
- end
- end
- end
-
- def memoize(*symbols)
- symbols.each do |symbol|
- original_method = :"_unmemoized_#{symbol}"
- memoized_ivar = ActiveSupport::Memoizable.memoized_ivar_for(symbol)
-
- class_eval <<-EOS, __FILE__, __LINE__ + 1
- include InstanceMethods # include InstanceMethods
- #
- if method_defined?(:#{original_method}) # if method_defined?(:_unmemoized_mime_type)
- raise "Already memoized #{symbol}" # raise "Already memoized mime_type"
- end # end
- alias #{original_method} #{symbol} # alias _unmemoized_mime_type mime_type
- #
- if instance_method(:#{symbol}).arity == 0 # if instance_method(:mime_type).arity == 0
- def #{symbol}(reload = false) # def mime_type(reload = false)
- if reload || !defined?(#{memoized_ivar}) || #{memoized_ivar}.empty? # if reload || !defined?(@_memoized_mime_type) || @_memoized_mime_type.empty?
- #{memoized_ivar} = [#{original_method}] # @_memoized_mime_type = [_unmemoized_mime_type]
- end # end
- #{memoized_ivar}[0] # @_memoized_mime_type[0]
- end # end
- else # else
- def #{symbol}(*args) # def mime_type(*args)
- #{memoized_ivar} ||= {} unless frozen? # @_memoized_mime_type ||= {} unless frozen?
- args_length = method(:#{original_method}).arity # args_length = method(:_unmemoized_mime_type).arity
- if args.length == args_length + 1 && # if args.length == args_length + 1 &&
- (args.last == true || args.last == :reload) # (args.last == true || args.last == :reload)
- reload = args.pop # reload = args.pop
- end # end
- #
- if defined?(#{memoized_ivar}) && #{memoized_ivar} # if defined?(@_memoized_mime_type) && @_memoized_mime_type
- if !reload && #{memoized_ivar}.has_key?(args) # if !reload && @_memoized_mime_type.has_key?(args)
- #{memoized_ivar}[args] # @_memoized_mime_type[args]
- elsif #{memoized_ivar} # elsif @_memoized_mime_type
- #{memoized_ivar}[args] = #{original_method}(*args) # @_memoized_mime_type[args] = _unmemoized_mime_type(*args)
- end # end
- else # else
- #{original_method}(*args) # _unmemoized_mime_type(*args)
- end # end
- end # end
- end # end
- #
- if private_method_defined?(#{original_method.inspect}) # if private_method_defined?(:_unmemoized_mime_type)
- private #{symbol.inspect} # private :mime_type
- elsif protected_method_defined?(#{original_method.inspect}) # elsif protected_method_defined?(:_unmemoized_mime_type)
- protected #{symbol.inspect} # protected :mime_type
- end # end
- EOS
- end
- end
- end
-end
diff --git a/activesupport/lib/active_support/message_encryptor.rb b/activesupport/lib/active_support/message_encryptor.rb
index 9ef2b29580..7d8a7fb687 100644
--- a/activesupport/lib/active_support/message_encryptor.rb
+++ b/activesupport/lib/active_support/message_encryptor.rb
@@ -24,29 +24,12 @@ module ActiveSupport
OpenSSLCipherError = OpenSSL::Cipher.const_defined?(:CipherError) ? OpenSSL::Cipher::CipherError : OpenSSL::CipherError
def initialize(secret, options = {})
- unless options.is_a?(Hash)
- ActiveSupport::Deprecation.warn "The second parameter should be an options hash. Use :cipher => 'algorithm' to specify the cipher algorithm."
- options = { :cipher => options }
- end
-
@secret = secret
@cipher = options[:cipher] || 'aes-256-cbc'
@verifier = MessageVerifier.new(@secret, :serializer => NullSerializer)
@serializer = options[:serializer] || Marshal
end
- def encrypt(value)
- ActiveSupport::Deprecation.warn "MessageEncryptor#encrypt is deprecated as it is not safe without a signature. " \
- "Please use MessageEncryptor#encrypt_and_sign instead."
- _encrypt(value)
- end
-
- def decrypt(value)
- ActiveSupport::Deprecation.warn "MessageEncryptor#decrypt is deprecated as it is not safe without a signature. " \
- "Please use MessageEncryptor#decrypt_and_verify instead."
- _decrypt(value)
- end
-
# Encrypt and sign a message. We need to sign the message in order to avoid padding attacks.
# Reference: http://www.limited-entropy.com/padding-oracle-attacks
def encrypt_and_sign(value)
diff --git a/activesupport/lib/active_support/message_verifier.rb b/activesupport/lib/active_support/message_verifier.rb
index 9d7c81142a..30ac44f6fa 100644
--- a/activesupport/lib/active_support/message_verifier.rb
+++ b/activesupport/lib/active_support/message_verifier.rb
@@ -27,11 +27,6 @@ module ActiveSupport
class InvalidSignature < StandardError; end
def initialize(secret, options = {})
- unless options.is_a?(Hash)
- ActiveSupport::Deprecation.warn "The second parameter should be an options hash. Use :digest => 'algorithm' to specify the digest algorithm."
- options = { :digest => options }
- end
-
@secret = secret
@digest = options[:digest] || 'SHA1'
@serializer = options[:serializer] || Marshal
diff --git a/activesupport/lib/active_support/multibyte/chars.rb b/activesupport/lib/active_support/multibyte/chars.rb
index b78d92f599..ba35b515f2 100644
--- a/activesupport/lib/active_support/multibyte/chars.rb
+++ b/activesupport/lib/active_support/multibyte/chars.rb
@@ -38,16 +38,10 @@ module ActiveSupport #:nodoc:
alias to_s wrapped_string
alias to_str wrapped_string
- if RUBY_VERSION >= "1.9"
- # Creates a new Chars instance by wrapping _string_.
- def initialize(string)
- @wrapped_string = string
- @wrapped_string.force_encoding(Encoding::UTF_8) unless @wrapped_string.frozen?
- end
- else
- def initialize(string) #:nodoc:
- @wrapped_string = string
- end
+ # Creates a new Chars instance by wrapping _string_.
+ def initialize(string)
+ @wrapped_string = string
+ @wrapped_string.force_encoding(Encoding::UTF_8) unless @wrapped_string.frozen?
end
# Forward all undefined methods to the wrapped string.
@@ -94,151 +88,8 @@ module ActiveSupport #:nodoc:
@wrapped_string <=> other.to_s
end
- if RUBY_VERSION < "1.9"
- # Returns +true+ if the Chars class can and should act as a proxy for the string _string_. Returns
- # +false+ otherwise.
- def self.wants?(string)
- $KCODE == 'UTF8' && consumes?(string)
- end
-
- # Returns a new Chars object containing the _other_ object concatenated to the string.
- #
- # Example:
- # ('Café'.mb_chars + ' périferôl').to_s # => "Café périferôl"
- def +(other)
- chars(@wrapped_string + other)
- end
-
- # Like <tt>String#=~</tt> only it returns the character offset (in codepoints) instead of the byte offset.
- #
- # Example:
- # 'Café périferôl'.mb_chars =~ /ô/ # => 12
- def =~(other)
- translate_offset(@wrapped_string =~ other)
- end
-
- # Inserts the passed string at specified codepoint offsets.
- #
- # Example:
- # 'Café'.mb_chars.insert(4, ' périferôl').to_s # => "Café périferôl"
- def insert(offset, fragment)
- unpacked = Unicode.u_unpack(@wrapped_string)
- unless offset > unpacked.length
- @wrapped_string.replace(
- Unicode.u_unpack(@wrapped_string).insert(offset, *Unicode.u_unpack(fragment)).pack('U*')
- )
- else
- raise IndexError, "index #{offset} out of string"
- end
- self
- end
-
- # Returns +true+ if contained string contains _other_. Returns +false+ otherwise.
- #
- # Example:
- # 'Café'.mb_chars.include?('é') # => true
- def include?(other)
- # We have to redefine this method because Enumerable defines it.
- @wrapped_string.include?(other)
- end
-
- # Returns the position _needle_ in the string, counting in codepoints. Returns +nil+ if _needle_ isn't found.
- #
- # Example:
- # 'Café périferôl'.mb_chars.index('ô') # => 12
- # 'Café périferôl'.mb_chars.index(/\w/u) # => 0
- def index(needle, offset=0)
- wrapped_offset = first(offset).wrapped_string.length
- index = @wrapped_string.index(needle, wrapped_offset)
- index ? (Unicode.u_unpack(@wrapped_string.slice(0...index)).size) : nil
- end
-
- # Returns the position _needle_ in the string, counting in
- # codepoints, searching backward from _offset_ or the end of the
- # string. Returns +nil+ if _needle_ isn't found.
- #
- # Example:
- # 'Café périferôl'.mb_chars.rindex('é') # => 6
- # 'Café périferôl'.mb_chars.rindex(/\w/u) # => 13
- def rindex(needle, offset=nil)
- offset ||= length
- wrapped_offset = first(offset).wrapped_string.length
- index = @wrapped_string.rindex(needle, wrapped_offset)
- index ? (Unicode.u_unpack(@wrapped_string.slice(0...index)).size) : nil
- end
-
- # Returns the number of codepoints in the string
- def size
- Unicode.u_unpack(@wrapped_string).size
- end
- alias_method :length, :size
-
- # Strips entire range of Unicode whitespace from the right of the string.
- def rstrip
- chars(@wrapped_string.gsub(Unicode::TRAILERS_PAT, ''))
- end
-
- # Strips entire range of Unicode whitespace from the left of the string.
- def lstrip
- chars(@wrapped_string.gsub(Unicode::LEADERS_PAT, ''))
- end
-
- # Strips entire range of Unicode whitespace from the right and left of the string.
- def strip
- rstrip.lstrip
- end
-
- # Returns the codepoint of the first character in the string.
- #
- # Example:
- # 'こんにちは'.mb_chars.ord # => 12371
- def ord
- Unicode.u_unpack(@wrapped_string)[0]
- end
-
- # Works just like <tt>String#rjust</tt>, only integer specifies characters instead of bytes.
- #
- # Example:
- #
- # "¾ cup".mb_chars.rjust(8).to_s
- # # => " ¾ cup"
- #
- # "¾ cup".mb_chars.rjust(8, " ").to_s # Use non-breaking whitespace
- # # => "   ¾ cup"
- def rjust(integer, padstr=' ')
- justify(integer, :right, padstr)
- end
-
- # Works just like <tt>String#ljust</tt>, only integer specifies characters instead of bytes.
- #
- # Example:
- #
- # "¾ cup".mb_chars.rjust(8).to_s
- # # => "¾ cup "
- #
- # "¾ cup".mb_chars.rjust(8, " ").to_s # Use non-breaking whitespace
- # # => "¾ cup   "
- def ljust(integer, padstr=' ')
- justify(integer, :left, padstr)
- end
-
- # Works just like <tt>String#center</tt>, only integer specifies characters instead of bytes.
- #
- # Example:
- #
- # "¾ cup".mb_chars.center(8).to_s
- # # => " ¾ cup "
- #
- # "¾ cup".mb_chars.center(8, " ").to_s # Use non-breaking whitespace
- # # => " ¾ cup  "
- def center(integer, padstr=' ')
- justify(integer, :center, padstr)
- end
-
- else
- def =~(other)
- @wrapped_string =~ other
- end
+ def =~(other)
+ @wrapped_string =~ other
end
# Works just like <tt>String#split</tt>, with the exception that the items in the resulting list are Chars
diff --git a/activesupport/lib/active_support/ordered_hash.rb b/activesupport/lib/active_support/ordered_hash.rb
index b0d4f2bd86..d4f309fbd7 100644
--- a/activesupport/lib/active_support/ordered_hash.rb
+++ b/activesupport/lib/active_support/ordered_hash.rb
@@ -51,172 +51,5 @@ module ActiveSupport
def extractable_options?
true
end
-
- # Hash is ordered in Ruby 1.9!
- if RUBY_VERSION < '1.9'
-
- # In MRI the Hash class is core and written in C. In particular, methods are
- # programmed with explicit C function calls and polymorphism is not honored.
- #
- # For example, []= is crucial in this implementation to maintain the @keys
- # array but hash.c invokes rb_hash_aset() originally. This prevents method
- # reuse through inheritance and forces us to reimplement stuff.
- #
- # For instance, we cannot use the inherited #merge! because albeit the algorithm
- # itself would work, our []= is not being called at all by the C code.
-
- def initialize(*args, &block)
- super
- @keys = []
- end
-
- def self.[](*args)
- ordered_hash = new
-
- if (args.length == 1 && args.first.is_a?(Array))
- args.first.each do |key_value_pair|
- next unless (key_value_pair.is_a?(Array))
- ordered_hash[key_value_pair[0]] = key_value_pair[1]
- end
-
- return ordered_hash
- end
-
- unless (args.size % 2 == 0)
- raise ArgumentError.new("odd number of arguments for Hash")
- end
-
- args.each_with_index do |val, ind|
- next if (ind % 2 != 0)
- ordered_hash[val] = args[ind + 1]
- end
-
- ordered_hash
- end
-
- def initialize_copy(other)
- super
- # make a deep copy of keys
- @keys = other.keys
- end
-
- def []=(key, value)
- @keys << key unless has_key?(key)
- super
- end
-
- def delete(key)
- if has_key? key
- index = @keys.index(key)
- @keys.delete_at index
- end
- super
- end
-
- def delete_if
- super
- sync_keys!
- self
- end
-
- def reject!
- super
- sync_keys!
- self
- end
-
- def reject(&block)
- dup.reject!(&block)
- end
-
- def keys
- @keys.dup
- end
-
- def values
- @keys.collect { |key| self[key] }
- end
-
- def to_hash
- self
- end
-
- def to_a
- @keys.map { |key| [ key, self[key] ] }
- end
-
- def each_key
- return to_enum(:each_key) unless block_given?
- @keys.each { |key| yield key }
- self
- end
-
- def each_value
- return to_enum(:each_value) unless block_given?
- @keys.each { |key| yield self[key]}
- self
- end
-
- def each
- return to_enum(:each) unless block_given?
- @keys.each {|key| yield [key, self[key]]}
- self
- end
-
- def each_pair
- return to_enum(:each_pair) unless block_given?
- @keys.each {|key| yield key, self[key]}
- self
- end
-
- alias_method :select, :find_all
-
- def clear
- super
- @keys.clear
- self
- end
-
- def shift
- k = @keys.first
- v = delete(k)
- [k, v]
- end
-
- def merge!(other_hash)
- if block_given?
- other_hash.each { |k, v| self[k] = key?(k) ? yield(k, self[k], v) : v }
- else
- other_hash.each { |k, v| self[k] = v }
- end
- self
- end
-
- alias_method :update, :merge!
-
- def merge(other_hash, &block)
- dup.merge!(other_hash, &block)
- end
-
- # When replacing with another hash, the initial order of our keys must come from the other hash -ordered or not.
- def replace(other)
- super
- @keys = other.keys
- self
- end
-
- def invert
- OrderedHash[self.to_a.map!{|key_value_pair| key_value_pair.reverse}]
- end
-
- def inspect
- "#<OrderedHash #{super}>"
- end
-
- private
- def sync_keys!
- @keys.delete_if {|k| !has_key?(k)}
- end
- end
end
end
diff --git a/activesupport/lib/active_support/testing/assertions.rb b/activesupport/lib/active_support/testing/assertions.rb
index f3629ada5b..4e1a58a801 100644
--- a/activesupport/lib/active_support/testing/assertions.rb
+++ b/activesupport/lib/active_support/testing/assertions.rb
@@ -87,7 +87,7 @@ module ActiveSupport
# Test if an expression is not blank. Passes if object.present? is true.
#
- # assert_present {:data => 'x' } # => true
+ # assert_present({:data => 'x' }) # => true
def assert_present(object, message=nil)
message ||= "#{object.inspect} is blank"
assert object.present?, message
diff --git a/activesupport/lib/active_support/testing/performance/ruby.rb b/activesupport/lib/active_support/testing/performance/ruby.rb
index 7d6d047ef6..26731c6bd7 100644
--- a/activesupport/lib/active_support/testing/performance/ruby.rb
+++ b/activesupport/lib/active_support/testing/performance/ruby.rb
@@ -144,8 +144,6 @@ end
if RUBY_VERSION.between?('1.9.2', '2.0')
require 'active_support/testing/performance/ruby/yarv'
-elsif RUBY_VERSION.between?('1.8.6', '1.9')
- require 'active_support/testing/performance/ruby/mri'
else
$stderr.puts 'Update your ruby interpreter to be able to run benchmarks.'
exit
diff --git a/activesupport/lib/active_support/testing/performance/ruby/mri.rb b/activesupport/lib/active_support/testing/performance/ruby/mri.rb
deleted file mode 100644
index 142279dd6e..0000000000
--- a/activesupport/lib/active_support/testing/performance/ruby/mri.rb
+++ /dev/null
@@ -1,57 +0,0 @@
-module ActiveSupport
- module Testing
- module Performance
- module Metrics
- class Base
- protected
- # Ruby 1.8 + ruby-prof wrapper (enable/disable stats for Benchmarker)
- if GC.respond_to?(:enable_stats)
- def with_gc_stats
- GC.enable_stats
- GC.start
- yield
- ensure
- GC.disable_stats
- end
- end
- end
-
- class Memory < DigitalInformationUnit
- # Ruby 1.8 + ruby-prof wrapper
- if RubyProf.respond_to?(:measure_memory)
- def measure
- RubyProf.measure_memory
- end
- end
- end
-
- class Objects < Amount
- # Ruby 1.8 + ruby-prof wrapper
- if RubyProf.respond_to?(:measure_allocations)
- def measure
- RubyProf.measure_allocations
- end
- end
- end
-
- class GcRuns < Amount
- # Ruby 1.8 + ruby-prof wrapper
- if RubyProf.respond_to?(:measure_gc_runs)
- def measure
- RubyProf.measure_gc_runs
- end
- end
- end
-
- class GcTime < Time
- # Ruby 1.8 + ruby-prof wrapper
- if RubyProf.respond_to?(:measure_gc_time)
- def measure
- RubyProf.measure_gc_time / 1000.0 / 1000.0
- end
- end
- end
- end
- end
- end
-end
diff --git a/activesupport/lib/active_support/version.rb b/activesupport/lib/active_support/version.rb
index bd8e7f907a..8a8f8f946d 100644
--- a/activesupport/lib/active_support/version.rb
+++ b/activesupport/lib/active_support/version.rb
@@ -1,7 +1,7 @@
module ActiveSupport
module VERSION #:nodoc:
- MAJOR = 3
- MINOR = 2
+ MAJOR = 4
+ MINOR = 0
TINY = 0
PRE = "beta"
diff --git a/activesupport/test/abstract_unit.rb b/activesupport/test/abstract_unit.rb
index 0382739871..504ac3e9b9 100644
--- a/activesupport/test/abstract_unit.rb
+++ b/activesupport/test/abstract_unit.rb
@@ -11,15 +11,11 @@ lib = File.expand_path("#{File.dirname(__FILE__)}/../lib")
$:.unshift(lib) unless $:.include?('lib') || $:.include?(lib)
require 'active_support/core_ext/kernel/reporting'
-
require 'active_support/core_ext/string/encoding'
-if "ruby".encoding_aware?
- # These are the normal settings that will be set up by Railties
- # TODO: Have these tests support other combinations of these values
- silence_warnings do
- Encoding.default_internal = "UTF-8"
- Encoding.default_external = "UTF-8"
- end
+
+silence_warnings do
+ Encoding.default_internal = "UTF-8"
+ Encoding.default_external = "UTF-8"
end
require 'test/unit'
@@ -30,9 +26,6 @@ silence_warnings { require 'mocha' }
ENV['NO_RELOAD'] = '1'
require 'active_support'
-# Include shims until we get off 1.8.6
-require 'active_support/ruby/shim' if RUBY_VERSION < '1.8.7'
-
def uses_memcached(test_name)
require 'memcache'
begin
@@ -43,22 +36,5 @@ def uses_memcached(test_name)
end
end
-def with_kcode(code)
- if RUBY_VERSION < '1.9'
- begin
- old_kcode, $KCODE = $KCODE, code
- yield
- ensure
- $KCODE = old_kcode
- end
- else
- yield
- end
-end
-
# Show backtraces for deprecated behavior for quicker cleanup.
-ActiveSupport::Deprecation.debug = true
-
-if RUBY_VERSION < '1.9'
- $KCODE = 'UTF8'
-end
+ActiveSupport::Deprecation.debug = true \ No newline at end of file
diff --git a/activesupport/test/benchmarkable_test.rb b/activesupport/test/benchmarkable_test.rb
index 24b5b5bee1..04d4f5e503 100644
--- a/activesupport/test/benchmarkable_test.rb
+++ b/activesupport/test/benchmarkable_test.rb
@@ -19,7 +19,7 @@ class BenchmarkableTest < ActiveSupport::TestCase
def setup
@buffer = Buffer.new
- @logger = ActiveSupport::BufferedLogger.new(@buffer)
+ @logger = ActiveSupport::Logger.new(@buffer)
end
def test_without_block
@@ -42,17 +42,17 @@ class BenchmarkableTest < ActiveSupport::TestCase
end
def test_within_level
- logger.level = ActiveSupport::BufferedLogger::DEBUG
+ logger.level = ActiveSupport::Logger::DEBUG
benchmark('included_debug_run', :level => :debug) { }
assert_last_logged 'included_debug_run'
end
def test_outside_level
- logger.level = ActiveSupport::BufferedLogger::ERROR
+ logger.level = ActiveSupport::Logger::ERROR
benchmark('skipped_debug_run', :level => :debug) { }
assert_no_match(/skipped_debug_run/, buffer.last)
ensure
- logger.level = ActiveSupport::BufferedLogger::DEBUG
+ logger.level = ActiveSupport::Logger::DEBUG
end
private
diff --git a/activesupport/test/buffered_logger_test.rb b/activesupport/test/buffered_logger_test.rb
index f975685ca5..1540e8df9b 100644
--- a/activesupport/test/buffered_logger_test.rb
+++ b/activesupport/test/buffered_logger_test.rb
@@ -10,7 +10,7 @@ class BufferedLoggerTest < Test::Unit::TestCase
include MultibyteTestHelpers
include ActiveSupport::Testing::Deprecation
- Logger = ActiveSupport::BufferedLogger
+ Logger = ActiveSupport::Logger
def setup
@message = "A debug message"
@@ -113,21 +113,12 @@ class BufferedLoggerTest < Test::Unit::TestCase
def test_should_know_if_its_loglevel_is_below_a_given_level
Logger::Severity.constants.each do |level|
+ next if level.to_s == 'UNKNOWN'
@logger.level = Logger::Severity.const_get(level) - 1
assert @logger.send("#{level.downcase}?"), "didn't know if it was #{level.downcase}? or below"
end
end
- def test_should_create_the_log_directory_if_it_doesnt_exist
- tmp_directory = File.join(File.dirname(__FILE__), "tmp")
- log_file = File.join(tmp_directory, "development.log")
- FileUtils.rm_rf(tmp_directory)
- assert_deprecated do
- @logger = Logger.new(log_file)
- end
- assert File.exist?(tmp_directory)
- end
-
def test_buffer_multibyte
@logger.info(UNICODE_STRING)
@logger.info(BYTE_STRING)
diff --git a/activesupport/test/clean_logger_test.rb b/activesupport/test/clean_logger_test.rb
index 2cc46904b4..178c7c0b23 100644
--- a/activesupport/test/clean_logger_test.rb
+++ b/activesupport/test/clean_logger_test.rb
@@ -1,11 +1,11 @@
require 'abstract_unit'
require 'stringio'
-require 'active_support/core_ext/logger'
+require 'active_support/logger'
class CleanLoggerTest < Test::Unit::TestCase
def setup
@out = StringIO.new
- @logger = Logger.new(@out)
+ @logger = ActiveSupport::Logger.new(@out)
end
def test_format_message
@@ -13,40 +13,11 @@ class CleanLoggerTest < Test::Unit::TestCase
assert_equal "error\n", @out.string
end
- def test_silence
- # Without yielding self.
- @logger.silence do
- @logger.debug 'debug'
- @logger.info 'info'
- @logger.warn 'warn'
- @logger.error 'error'
- @logger.fatal 'fatal'
- end
-
- # Yielding self.
- @logger.silence do |logger|
- logger.debug 'debug'
- logger.info 'info'
- logger.warn 'warn'
- logger.error 'error'
- logger.fatal 'fatal'
- end
-
- # Silencer off.
- Logger.silencer = false
- @logger.silence do |logger|
- logger.warn 'unsilenced'
- end
- Logger.silencer = true
-
- assert_equal "error\nfatal\nerror\nfatal\nunsilenced\n", @out.string
- end
-
def test_datetime_format
@logger.formatter = Logger::Formatter.new
- @logger.datetime_format = "%Y-%m-%d"
+ @logger.formatter.datetime_format = "%Y-%m-%d"
@logger.debug 'debug'
- assert_equal "%Y-%m-%d", @logger.datetime_format
+ assert_equal "%Y-%m-%d", @logger.formatter.datetime_format
assert_match(/D, \[\d\d\d\d-\d\d-\d\d#\d+\] DEBUG -- : debug/, @out.string)
end
diff --git a/activesupport/test/core_ext/date_ext_test.rb b/activesupport/test/core_ext/date_ext_test.rb
index c040d86327..09d4765390 100644
--- a/activesupport/test/core_ext/date_ext_test.rb
+++ b/activesupport/test/core_ext/date_ext_test.rb
@@ -384,16 +384,6 @@ class DateExtCalculationsTest < ActiveSupport::TestCase
end
end
- if RUBY_VERSION < '1.9'
- def test_rfc3339
- assert_equal('1980-02-28', Date.new(1980, 2, 28).rfc3339)
- end
-
- def test_iso8601
- assert_equal('1980-02-28', Date.new(1980, 2, 28).iso8601)
- end
- end
-
def test_today
Date.stubs(:current).returns(Date.new(2000, 1, 1))
assert_equal false, Date.new(1999, 12, 31).today?
diff --git a/activesupport/test/core_ext/hash_ext_test.rb b/activesupport/test/core_ext/hash_ext_test.rb
index eb8ed761da..dfa0cdb478 100644
--- a/activesupport/test/core_ext/hash_ext_test.rb
+++ b/activesupport/test/core_ext/hash_ext_test.rb
@@ -27,11 +27,7 @@ class HashExtTest < Test::Unit::TestCase
@symbols = { :a => 1, :b => 2 }
@mixed = { :a => 1, 'b' => 2 }
@fixnums = { 0 => 1, 1 => 2 }
- if RUBY_VERSION < '1.9.0'
- @illegal_symbols = { "\0" => 1, "" => 2, [] => 3 }
- else
- @illegal_symbols = { [] => 3 }
- end
+ @illegal_symbols = { [] => 3 }
end
def test_methods
diff --git a/activesupport/test/core_ext/range_ext_test.rb b/activesupport/test/core_ext/range_ext_test.rb
index 1424fa4aca..f4b773e5fb 100644
--- a/activesupport/test/core_ext/range_ext_test.rb
+++ b/activesupport/test/core_ext/range_ext_test.rb
@@ -63,15 +63,8 @@ class RangeTest < Test::Unit::TestCase
assert_equal [1,3,5,7,9], array
end
- if RUBY_VERSION < '1.9'
- def test_cover
- assert((1..3).cover?(2))
- assert !(1..3).cover?(4)
- end
- else
- def test_cover_is_not_override
- range = (1..3)
- assert range.method(:include?) != range.method(:cover?)
- end
+ def test_cover_is_not_override
+ range = (1..3)
+ assert range.method(:include?) != range.method(:cover?)
end
end
diff --git a/activesupport/test/core_ext/string_ext_test.rb b/activesupport/test/core_ext/string_ext_test.rb
index 47b9f68ed0..aeae2579b4 100644
--- a/activesupport/test/core_ext/string_ext_test.rb
+++ b/activesupport/test/core_ext/string_ext_test.rb
@@ -160,14 +160,6 @@ class StringInflectionsTest < Test::Unit::TestCase
assert_equal 97, 'abc'.ord
end
- if RUBY_VERSION < '1.9'
- def test_getbyte
- assert_equal 97, 'a'.getbyte(0)
- assert_equal 99, 'abc'.getbyte(2)
- assert_nil 'abc'.getbyte(3)
- end
- end
-
def test_string_to_time
assert_equal Time.utc(2005, 2, 27, 23, 50), "2005-02-27 23:50".to_time
assert_equal Time.local(2005, 2, 27, 23, 50), "2005-02-27 23:50".to_time(:local)
@@ -287,21 +279,9 @@ class StringInflectionsTest < Test::Unit::TestCase
assert_equal "Hello Big[...]", "Hello Big World!".truncate(15, :omission => "[...]", :separator => ' ')
end
- if RUBY_VERSION < '1.9.0'
- def test_truncate_multibyte
- with_kcode 'none' do
- assert_equal "\354\225\210\353\205\225\355...", "\354\225\210\353\205\225\355\225\230\354\204\270\354\232\224".truncate(10)
- end
- with_kcode 'u' do
- assert_equal "\354\225\204\353\246\254\353\236\221 \354\225\204\353\246\254 ...",
- "\354\225\204\353\246\254\353\236\221 \354\225\204\353\246\254 \354\225\204\353\235\274\353\246\254\354\230\244".truncate(10)
- end
- end
- else
- def test_truncate_multibyte
- assert_equal "\354\225\204\353\246\254\353\236\221 \354\225\204\353\246\254 ...".force_encoding('UTF-8'),
- "\354\225\204\353\246\254\353\236\221 \354\225\204\353\246\254 \354\225\204\353\235\274\353\246\254\354\230\244".force_encoding('UTF-8').truncate(10)
- end
+ def test_truncate_multibyte
+ assert_equal "\354\225\204\353\246\254\353\236\221 \354\225\204\353\246\254 ...".force_encoding('UTF-8'),
+ "\354\225\204\353\246\254\353\236\221 \354\225\204\353\246\254 \354\225\204\353\235\274\353\246\254\354\230\244".force_encoding('UTF-8').truncate(10)
end
def test_constantize
@@ -338,22 +318,8 @@ class CoreExtStringMultibyteTest < ActiveSupport::TestCase
assert !BYTE_STRING.is_utf8?
end
- if RUBY_VERSION < '1.9'
- def test_mb_chars_returns_self_when_kcode_not_set
- with_kcode('none') do
- assert_kind_of String, UNICODE_STRING.mb_chars
- end
- end
-
- def test_mb_chars_returns_an_instance_of_the_chars_proxy_when_kcode_utf8
- with_kcode('UTF8') do
- assert_kind_of ActiveSupport::Multibyte.proxy_class, UNICODE_STRING.mb_chars
- end
- end
- else
- def test_mb_chars_returns_instance_of_proxy_class
- assert_kind_of ActiveSupport::Multibyte.proxy_class, UNICODE_STRING.mb_chars
- end
+ def test_mb_chars_returns_instance_of_proxy_class
+ assert_kind_of ActiveSupport::Multibyte.proxy_class, UNICODE_STRING.mb_chars
end
end
@@ -479,11 +445,7 @@ class OutputSafetyTest < ActiveSupport::TestCase
end
test 'knows whether it is encoding aware' do
- if RUBY_VERSION >= "1.9"
- assert 'ruby'.encoding_aware?
- else
- assert !'ruby'.encoding_aware?
- end
+ assert 'ruby'.encoding_aware?
end
test "call to_param returns a normal string" do
diff --git a/activesupport/test/core_ext/time_with_zone_test.rb b/activesupport/test/core_ext/time_with_zone_test.rb
index 9d9e411c28..04f5ea85a8 100644
--- a/activesupport/test/core_ext/time_with_zone_test.rb
+++ b/activesupport/test/core_ext/time_with_zone_test.rb
@@ -448,9 +448,8 @@ class TimeWithZoneTest < Test::Unit::TestCase
end
def test_ruby_19_weekday_name_query_methods
- ruby_19_or_greater = RUBY_VERSION >= '1.9'
%w(sunday? monday? tuesday? wednesday? thursday? friday? saturday?).each do |name|
- assert_equal ruby_19_or_greater, @twz.respond_to?(name)
+ assert_respond_to @twz, name
end
end
diff --git a/activesupport/test/flush_cache_on_private_memoization_test.rb b/activesupport/test/flush_cache_on_private_memoization_test.rb
deleted file mode 100644
index bc488cc743..0000000000
--- a/activesupport/test/flush_cache_on_private_memoization_test.rb
+++ /dev/null
@@ -1,45 +0,0 @@
-require 'abstract_unit'
-require 'test/unit'
-
-class FlushCacheOnPrivateMemoizationTest < Test::Unit::TestCase
- ActiveSupport::Deprecation.silence do
- extend ActiveSupport::Memoizable
- end
-
- def test_public
- assert_method_unmemoizable :pub
- end
-
- def test_protected
- assert_method_unmemoizable :prot
- end
-
- def test_private
- assert_method_unmemoizable :priv
- end
-
- def pub; rand end
- memoize :pub
-
- protected
-
- def prot; rand end
- memoize :prot
-
- private
-
- def priv; rand end
- memoize :priv
-
- def assert_method_unmemoizable(meth, message=nil)
- full_message = build_message(message, "<?> not unmemoizable.\n", meth)
- assert_block(full_message) do
- a = send meth
- b = send meth
- unmemoize_all
- c = send meth
- a == b && a != c
- end
- end
-
-end
diff --git a/activesupport/test/json/encoding_test.rb b/activesupport/test/json/encoding_test.rb
index 8cf1a54a99..ad9a497515 100644
--- a/activesupport/test/json/encoding_test.rb
+++ b/activesupport/test/json/encoding_test.rb
@@ -88,25 +88,21 @@ class TestJSONEncoding < Test::Unit::TestCase
assert_equal %({\"a\":\"b\",\"c\":\"d\"}), sorted_json(ActiveSupport::JSON.encode(:a => :b, :c => :d))
end
- def test_utf8_string_encoded_properly_when_kcode_is_utf8
- with_kcode 'UTF8' do
- result = ActiveSupport::JSON.encode('€2.99')
- assert_equal '"\\u20ac2.99"', result
- assert_equal(Encoding::UTF_8, result.encoding) if result.respond_to?(:encoding)
-
- result = ActiveSupport::JSON.encode('✎☺')
- assert_equal '"\\u270e\\u263a"', result
- assert_equal(Encoding::UTF_8, result.encoding) if result.respond_to?(:encoding)
- end
+ def test_utf8_string_encoded_properly
+ result = ActiveSupport::JSON.encode('€2.99')
+ assert_equal '"\\u20ac2.99"', result
+ assert_equal(Encoding::UTF_8, result.encoding) if result.respond_to?(:encoding)
+
+ result = ActiveSupport::JSON.encode('✎☺')
+ assert_equal '"\\u270e\\u263a"', result
+ assert_equal(Encoding::UTF_8, result.encoding) if result.respond_to?(:encoding)
end
- if '1.9'.respond_to?(:force_encoding)
- def test_non_utf8_string_transcodes
- s = '二'.encode('Shift_JIS')
- result = ActiveSupport::JSON.encode(s)
- assert_equal '"\\u4e8c"', result
- assert_equal Encoding::UTF_8, result.encoding
- end
+ def test_non_utf8_string_transcodes
+ s = '二'.encode('Shift_JIS')
+ result = ActiveSupport::JSON.encode(s)
+ assert_equal '"\\u4e8c"', result
+ assert_equal Encoding::UTF_8, result.encoding
end
def test_exception_raised_when_encoding_circular_reference_in_array
diff --git a/activesupport/test/memoizable_test.rb b/activesupport/test/memoizable_test.rb
deleted file mode 100644
index e333b9a78c..0000000000
--- a/activesupport/test/memoizable_test.rb
+++ /dev/null
@@ -1,290 +0,0 @@
-require 'abstract_unit'
-
-class MemoizableTest < ActiveSupport::TestCase
- class Person
- ActiveSupport::Deprecation.silence do
- extend ActiveSupport::Memoizable
- end
-
- attr_reader :name_calls, :age_calls, :is_developer_calls, :name_query_calls
-
- def initialize
- @name_calls = 0
- @age_calls = 0
- @is_developer_calls = 0
- @name_query_calls = 0
- end
-
- def name
- @name_calls += 1
- "Josh"
- end
-
- def name?
- @name_query_calls += 1
- true
- end
- memoize :name?
-
- def update(name)
- "Joshua"
- end
- memoize :update
-
- def age
- @age_calls += 1
- nil
- end
-
- memoize :name, :age
-
- protected
-
- def memoize_protected_test
- 'protected'
- end
- memoize :memoize_protected_test
-
- private
-
- def is_developer?
- @is_developer_calls += 1
- "Yes"
- end
- memoize :is_developer?
- end
-
- class Company
- attr_reader :name_calls
- def initialize
- @name_calls = 0
- end
-
- def name
- @name_calls += 1
- "37signals"
- end
- end
-
- module Rates
- ActiveSupport::Deprecation.silence do
- extend ActiveSupport::Memoizable
- end
-
- attr_reader :sales_tax_calls
- def sales_tax(price)
- @sales_tax_calls ||= 0
- @sales_tax_calls += 1
- price * 0.1025
- end
- memoize :sales_tax
- end
-
- class Calculator
- ActiveSupport::Deprecation.silence do
- extend ActiveSupport::Memoizable
- end
- include Rates
-
- attr_reader :fib_calls
- def initialize
- @fib_calls = 0
- end
-
- def fib(n)
- @fib_calls += 1
-
- if n == 0 || n == 1
- n
- else
- fib(n - 1) + fib(n - 2)
- end
- end
- memoize :fib
-
- def add_or_subtract(i, j, add)
- if add
- i + j
- else
- i - j
- end
- end
- memoize :add_or_subtract
-
- def counter
- @count ||= 0
- @count += 1
- end
- memoize :counter
- end
-
- def setup
- @person = Person.new
- @calculator = Calculator.new
- end
-
- def test_memoization
- assert_equal "Josh", @person.name
- assert_equal 1, @person.name_calls
-
- 3.times { assert_equal "Josh", @person.name }
- assert_equal 1, @person.name_calls
- end
-
- def test_memoization_with_punctuation
- assert_equal true, @person.name?
-
- assert_nothing_raised(NameError) do
- @person.memoize_all
- @person.unmemoize_all
- end
- end
-
- def test_memoization_flush_with_punctuation
- assert_equal true, @person.name?
- @person.flush_cache(:name?)
- 3.times { assert_equal true, @person.name? }
- assert_equal 2, @person.name_query_calls
- end
-
- def test_memoization_with_nil_value
- assert_equal nil, @person.age
- assert_equal 1, @person.age_calls
-
- 3.times { assert_equal nil, @person.age }
- assert_equal 1, @person.age_calls
- end
-
- def test_reloadable
- assert_equal 1, @calculator.counter
- assert_equal 2, @calculator.counter(:reload)
- assert_equal 2, @calculator.counter
- assert_equal 3, @calculator.counter(true)
- assert_equal 3, @calculator.counter
- end
-
- def test_flush_cache
- assert_equal 1, @calculator.counter
-
- assert @calculator.instance_variable_get(:@_memoized_counter).any?
- @calculator.flush_cache(:counter)
- assert @calculator.instance_variable_get(:@_memoized_counter).empty?
-
- assert_equal 2, @calculator.counter
- end
-
- def test_unmemoize_all
- assert_equal 1, @calculator.counter
-
- assert @calculator.instance_variable_get(:@_memoized_counter).any?
- @calculator.unmemoize_all
- assert @calculator.instance_variable_get(:@_memoized_counter).empty?
-
- assert_equal 2, @calculator.counter
- end
-
- def test_memoize_all
- @calculator.memoize_all
- assert @calculator.instance_variable_defined?(:@_memoized_counter)
- end
-
- def test_memoization_cache_is_different_for_each_instance
- assert_equal 1, @calculator.counter
- assert_equal 2, @calculator.counter(:reload)
- assert_equal 1, Calculator.new.counter
- end
-
- def test_memoized_is_not_affected_by_freeze
- @person.freeze
- assert_equal "Josh", @person.name
- assert_equal "Joshua", @person.update("Joshua")
- end
-
- def test_memoization_with_args
- assert_equal 55, @calculator.fib(10)
- assert_equal 11, @calculator.fib_calls
- end
-
- def test_reloadable_with_args
- assert_equal 55, @calculator.fib(10)
- assert_equal 11, @calculator.fib_calls
- assert_equal 55, @calculator.fib(10, :reload)
- assert_equal 12, @calculator.fib_calls
- assert_equal 55, @calculator.fib(10, true)
- assert_equal 13, @calculator.fib_calls
- end
-
- def test_memoization_with_boolean_arg
- assert_equal 4, @calculator.add_or_subtract(2, 2, true)
- assert_equal 2, @calculator.add_or_subtract(4, 2, false)
- end
-
- def test_object_memoization
- [Company.new, Company.new, Company.new].each do |company|
- ActiveSupport::Deprecation.silence do
- company.extend ActiveSupport::Memoizable
- end
- company.memoize :name
-
- assert_equal "37signals", company.name
- assert_equal 1, company.name_calls
- assert_equal "37signals", company.name
- assert_equal 1, company.name_calls
- end
- end
-
- def test_memoized_module_methods
- assert_equal 1.025, @calculator.sales_tax(10)
- assert_equal 1, @calculator.sales_tax_calls
- assert_equal 1.025, @calculator.sales_tax(10)
- assert_equal 1, @calculator.sales_tax_calls
- assert_equal 2.5625, @calculator.sales_tax(25)
- assert_equal 2, @calculator.sales_tax_calls
- end
-
- def test_object_memoized_module_methods
- company = Company.new
- company.extend(Rates)
-
- assert_equal 1.025, company.sales_tax(10)
- assert_equal 1, company.sales_tax_calls
- assert_equal 1.025, company.sales_tax(10)
- assert_equal 1, company.sales_tax_calls
- assert_equal 2.5625, company.sales_tax(25)
- assert_equal 2, company.sales_tax_calls
- end
-
- def test_double_memoization
- assert_raise(RuntimeError) { Person.memoize :name }
- person = Person.new
- ActiveSupport::Deprecation.silence do
- person.extend ActiveSupport::Memoizable
- end
- assert_raise(RuntimeError) { person.memoize :name }
-
- company = Company.new
- ActiveSupport::Deprecation.silence do
- company.extend ActiveSupport::Memoizable
- end
- company.memoize :name
- assert_raise(RuntimeError) { company.memoize :name }
- end
-
- def test_protected_method_memoization
- person = Person.new
-
- assert_raise(NoMethodError) { person.memoize_protected_test }
- assert_equal "protected", person.send(:memoize_protected_test)
- end
-
- def test_private_method_memoization
- person = Person.new
-
- assert_raise(NoMethodError) { person.is_developer? }
- assert_equal "Yes", person.send(:is_developer?)
- assert_equal 1, person.is_developer_calls
- assert_equal "Yes", person.send(:is_developer?)
- assert_equal 1, person.is_developer_calls
- end
-
-end
diff --git a/activesupport/test/message_encryptor_test.rb b/activesupport/test/message_encryptor_test.rb
index 3e6a5c6602..db97c1b80b 100644
--- a/activesupport/test/message_encryptor_test.rb
+++ b/activesupport/test/message_encryptor_test.rb
@@ -61,12 +61,6 @@ class MessageEncryptorTest < ActiveSupport::TestCase
assert_equal encryptor.decrypt_and_verify(message), { "foo" => 123, "bar" => "2010-01-01T00:00:00Z" }
end
- def test_digest_algorithm_as_second_parameter_deprecation
- assert_deprecated(/options hash/) do
- ActiveSupport::MessageEncryptor.new(SecureRandom.hex(64), 'aes-256-cbc')
- end
- end
-
private
def assert_not_decrypted(value)
diff --git a/activesupport/test/message_verifier_test.rb b/activesupport/test/message_verifier_test.rb
index 35747abe5b..5adff41653 100644
--- a/activesupport/test/message_verifier_test.rb
+++ b/activesupport/test/message_verifier_test.rb
@@ -50,12 +50,6 @@ class MessageVerifierTest < ActiveSupport::TestCase
assert_equal verifier.verify(message), { "foo" => 123, "bar" => "2010-01-01T00:00:00Z" }
end
- def test_digest_algorithm_as_second_parameter_deprecation
- assert_deprecated(/options hash/) do
- ActiveSupport::MessageVerifier.new("secret", "SHA1")
- end
- end
-
def assert_not_verified(message)
assert_raise(ActiveSupport::MessageVerifier::InvalidSignature) do
@verifier.verify(message)
diff --git a/activesupport/test/multibyte_chars_test.rb b/activesupport/test/multibyte_chars_test.rb
index bfff10fff2..ba04638354 100644
--- a/activesupport/test/multibyte_chars_test.rb
+++ b/activesupport/test/multibyte_chars_test.rb
@@ -101,15 +101,8 @@ class MultibyteCharsUTF8BehaviourTest < Test::Unit::TestCase
def setup
@chars = UNICODE_STRING.dup.mb_chars
-
- if RUBY_VERSION < '1.9'
- # Multibyte support all kinds of whitespace (ie. NEWLINE, SPACE, EM SPACE)
- @whitespace = "\n\t#{[32, 8195].pack('U*')}"
- else
- # Ruby 1.9 only supports basic whitespace
- @whitespace = "\n\t "
- end
-
+ # Ruby 1.9 only supports basic whitespace
+ @whitespace = "\n\t "
@byte_order_mark = [65279].pack('U')
end
diff --git a/activesupport/test/multibyte_utils_test.rb b/activesupport/test/multibyte_utils_test.rb
index 0a2f20d282..9a8f7050fe 100644
--- a/activesupport/test/multibyte_utils_test.rb
+++ b/activesupport/test/multibyte_utils_test.rb
@@ -56,37 +56,9 @@ class MultibyteUtilsTest < ActiveSupport::TestCase
end
end
- if RUBY_VERSION < '1.9'
- test "clean leaves ASCII strings intact" do
- with_encoding('None') do
- [
- 'word', "\270\236\010\210\245"
- ].each do |string|
- assert_equal string, ActiveSupport::Multibyte.clean(string)
- end
- end
- end
-
- test "clean cleans invalid characters from UTF-8 encoded strings" do
- with_encoding('UTF8') do
- cleaned_utf8 = [8].pack('C*')
- assert_equal example('valid UTF-8'), ActiveSupport::Multibyte.clean(example('valid UTF-8'))
- assert_equal cleaned_utf8, ActiveSupport::Multibyte.clean(example('invalid UTF-8'))
- end
- end
-
- test "clean cleans invalid characters from Shift-JIS encoded strings" do
- with_encoding('SJIS') do
- cleaned_sjis = [184, 0, 136, 165].pack('C*')
- assert_equal example('valid Shift-JIS'), ActiveSupport::Multibyte.clean(example('valid Shift-JIS'))
- assert_equal cleaned_sjis, ActiveSupport::Multibyte.clean(example('invalid Shift-JIS'))
- end
- end
- else
- test "clean is a no-op" do
- with_encoding('UTF8') do
- assert_equal example('invalid Shift-JIS'), ActiveSupport::Multibyte.clean(example('invalid Shift-JIS'))
- end
+ test "clean is a no-op" do
+ with_encoding('UTF8') do
+ assert_equal example('invalid Shift-JIS'), ActiveSupport::Multibyte.clean(example('invalid Shift-JIS'))
end
end
@@ -119,19 +91,13 @@ class MultibyteUtilsTest < ActiveSupport::TestCase
end
end
- if 'string'.respond_to?(:encoding)
- KCODE_TO_ENCODING = Hash.new(Encoding::BINARY).
- update('UTF8' => Encoding::UTF_8, 'SJIS' => Encoding::Shift_JIS)
-
- def with_encoding(enc)
- before = Encoding.default_external
- silence_warnings { Encoding.default_external = KCODE_TO_ENCODING[enc] }
+ KCODE_TO_ENCODING = Hash.new(Encoding::BINARY).
+ update('UTF8' => Encoding::UTF_8, 'SJIS' => Encoding::Shift_JIS)
- yield
-
- silence_warnings { Encoding.default_external = before }
- end
- else
- alias with_encoding with_kcode
+ def with_encoding(enc)
+ before = Encoding.default_external
+ silence_warnings { Encoding.default_external = KCODE_TO_ENCODING[enc] }
+ yield
+ silence_warnings { Encoding.default_external = before }
end
end
diff --git a/activesupport/test/ordered_hash_test.rb b/activesupport/test/ordered_hash_test.rb
index 0b5f912dc4..8119b36491 100644
--- a/activesupport/test/ordered_hash_test.rb
+++ b/activesupport/test/ordered_hash_test.rb
@@ -81,24 +81,21 @@ class OrderedHashTest < Test::Unit::TestCase
keys = []
assert_equal @ordered_hash, @ordered_hash.each_key { |k| keys << k }
assert_equal @keys, keys
- expected_class = RUBY_VERSION < '1.9' ? Enumerable::Enumerator : Enumerator
- assert_kind_of expected_class, @ordered_hash.each_key
+ assert_kind_of Enumerator, @ordered_hash.each_key
end
def test_each_value
values = []
assert_equal @ordered_hash, @ordered_hash.each_value { |v| values << v }
assert_equal @values, values
- expected_class = RUBY_VERSION < '1.9' ? Enumerable::Enumerator : Enumerator
- assert_kind_of expected_class, @ordered_hash.each_value
+ assert_kind_of Enumerator, @ordered_hash.each_value
end
def test_each
values = []
assert_equal @ordered_hash, @ordered_hash.each {|key, value| values << value}
assert_equal @values, values
- expected_class = RUBY_VERSION < '1.9' ? Enumerable::Enumerator : Enumerator
- assert_kind_of expected_class, @ordered_hash.each
+ assert_kind_of Enumerator, @ordered_hash.each
end
def test_each_with_index
@@ -114,9 +111,7 @@ class OrderedHashTest < Test::Unit::TestCase
end
assert_equal @values, values
assert_equal @keys, keys
-
- expected_class = RUBY_VERSION < '1.9' ? Enumerable::Enumerator : Enumerator
- assert_kind_of expected_class, @ordered_hash.each_pair
+ assert_kind_of Enumerator, @ordered_hash.each_pair
end
def test_find_all
diff --git a/activesupport/test/tagged_logging_test.rb b/activesupport/test/tagged_logging_test.rb
index 17c4214dfc..dd4ae319e5 100644
--- a/activesupport/test/tagged_logging_test.rb
+++ b/activesupport/test/tagged_logging_test.rb
@@ -1,9 +1,9 @@
require 'abstract_unit'
-require 'active_support/core_ext/logger'
+require 'active_support/logger'
require 'active_support/tagged_logging'
class TaggedLoggingTest < ActiveSupport::TestCase
- class MyLogger < ::Logger
+ class MyLogger < ::ActiveSupport::Logger
def flush(*)
info "[FLUSHED]"
end
diff --git a/railties/guides/rails_guides/levenshtein.rb b/railties/guides/rails_guides/levenshtein.rb
index f99c6e6ba8..489aa3ea7a 100644
--- a/railties/guides/rails_guides/levenshtein.rb
+++ b/railties/guides/rails_guides/levenshtein.rb
@@ -1,6 +1,6 @@
module RailsGuides
module Levenshtein
- # Based on the pseudocode in http://en.wikipedia.org/wiki/Levenshtein_distance.
+ # Based on the pseudocode in http://en.wikipedia.org/wiki/Levenshtein_distance
def self.distance(s1, s2)
s = s1.unpack('U*')
t = s2.unpack('U*')
diff --git a/railties/guides/source/getting_started.textile b/railties/guides/source/getting_started.textile
index 774c6a792e..54f3c74695 100644
--- a/railties/guides/source/getting_started.textile
+++ b/railties/guides/source/getting_started.textile
@@ -41,9 +41,6 @@ internet for learning Ruby, including:
* "Programming Ruby":http://www.ruby-doc.org/docs/ProgrammingRuby/
* "Why's (Poignant) Guide to Ruby":http://mislav.uniqpath.com/poignant-guide/
-Also, the example code for this guide is available in the rails github:https://github.com/rails/rails repository
-in rails/railties/guides/code/getting_started.
-
h3. What is Rails?
TIP: This section goes into the background and philosophy of the Rails framework
diff --git a/railties/guides/source/migrations.textile b/railties/guides/source/migrations.textile
index 92356edf90..66160f8b26 100644
--- a/railties/guides/source/migrations.textile
+++ b/railties/guides/source/migrations.textile
@@ -814,7 +814,7 @@ replaying the entire migration history. It is much simpler and faster to just
load into the database a description of the current schema.
For example, this is how the test database is created: the current development
-database is dumped (either to +db/schema.rb+ or +db/development.sql+) and then
+database is dumped (either to +db/schema.rb+ or +db/structure.sql+) and then
loaded into the test database.
Schema files are also useful if you want a quick look at what attributes an
diff --git a/railties/lib/rails.rb b/railties/lib/rails.rb
index 73bdd0b552..658756ad51 100644
--- a/railties/lib/rails.rb
+++ b/railties/lib/rails.rb
@@ -5,7 +5,6 @@ require 'pathname'
require 'active_support'
require 'active_support/core_ext/kernel/reporting'
require 'active_support/core_ext/array/extract_options'
-require 'active_support/core_ext/logger'
require 'rails/application'
require 'rails/version'
@@ -13,19 +12,10 @@ require 'rails/version'
require 'active_support/railtie'
require 'action_dispatch/railtie'
-# For Ruby 1.8, this initialization sets $KCODE to 'u' to enable the
-# multibyte safe operations. Plugin authors supporting other encodings
-# should override this behavior and set the relevant +default_charset+
-# on ActionController::Base.
-#
# For Ruby 1.9, UTF-8 is the default internal and external encoding.
-if RUBY_VERSION < '1.9'
- $KCODE='u'
-else
- silence_warnings do
- Encoding.default_external = Encoding::UTF_8
- Encoding.default_internal = Encoding::UTF_8
- end
+silence_warnings do
+ Encoding.default_external = Encoding::UTF_8
+ Encoding.default_internal = Encoding::UTF_8
end
module Rails
diff --git a/railties/lib/rails/application/bootstrap.rb b/railties/lib/rails/application/bootstrap.rb
index e189009cc5..78d2e6c913 100644
--- a/railties/lib/rails/application/bootstrap.rb
+++ b/railties/lib/rails/application/bootstrap.rb
@@ -33,13 +33,13 @@ module Rails
f.sync = !Rails.env.production? # make sure every write flushes
logger = ActiveSupport::TaggedLogging.new(
- ActiveSupport::BufferedLogger.new(f)
+ ActiveSupport::Logger.new(f)
)
- logger.level = ActiveSupport::BufferedLogger.const_get(config.log_level.to_s.upcase)
+ logger.level = ActiveSupport::Logger.const_get(config.log_level.to_s.upcase)
logger
rescue StandardError
- logger = ActiveSupport::TaggedLogging.new(ActiveSupport::BufferedLogger.new(STDERR))
- logger.level = ActiveSupport::BufferedLogger::WARN
+ logger = ActiveSupport::TaggedLogging.new(ActiveSupport::Logger.new(STDERR))
+ logger.level = ActiveSupport::Logger::WARN
logger.warn(
"Rails Error: Unable to access log file. Please ensure that #{path} exists and is chmod 0666. " +
"The log level has been raised to WARN and the output directed to STDERR until the problem is fixed."
diff --git a/railties/lib/rails/commands/plugin.rb b/railties/lib/rails/commands/plugin.rb
index c99a2e6685..4ddd12ae0b 100644
--- a/railties/lib/rails/commands/plugin.rb
+++ b/railties/lib/rails/commands/plugin.rb
@@ -478,7 +478,7 @@ class RecursiveHTTPFetcher
def initialize(urls_to_fetch, level = 1, cwd = ".")
@level = level
@cwd = cwd
- @urls_to_fetch = RUBY_VERSION >= '1.9' ? urls_to_fetch.lines : urls_to_fetch.to_a
+ @urls_to_fetch = urls_to_fetch.lines
@quiet = false
end
diff --git a/railties/lib/rails/generators/app_base.rb b/railties/lib/rails/generators/app_base.rb
index 197b692469..0ed1eb4af8 100644
--- a/railties/lib/rails/generators/app_base.rb
+++ b/railties/lib/rails/generators/app_base.rb
@@ -60,9 +60,6 @@ module Rails
class_option :help, :type => :boolean, :aliases => "-h", :group => :rails,
:desc => "Show this help message and quit"
-
- class_option :old_style_hash, :type => :boolean, :default => false,
- :desc => "Force using old style hash (:foo => 'bar') on Ruby >= 1.9"
end
def initialize(*args)
@@ -185,11 +182,7 @@ module Rails
end
def ruby_debugger_gemfile_entry
- if RUBY_VERSION < "1.9"
- "gem 'ruby-debug'"
- else
- "gem 'ruby-debug19', :require => 'ruby-debug'"
- end
+ "gem 'ruby-debug19', :require => 'ruby-debug'"
end
def assets_gemfile_entry
@@ -255,14 +248,9 @@ module Rails
create_file("#{destination}/.gitkeep") unless options[:skip_git]
end
- # Returns Ruby 1.9 style key-value pair if current code is running on
- # Ruby 1.9.x. Returns the old-style (with hash rocket) otherwise.
+ # Returns Ruby 1.9 style key-value pair.
def key_value(key, value)
- if options[:old_style_hash] || RUBY_VERSION < '1.9'
- ":#{key} => #{value}"
- else
- "#{key}: #{value}"
- end
+ "#{key}: #{value}"
end
end
end
diff --git a/railties/lib/rails/generators/named_base.rb b/railties/lib/rails/generators/named_base.rb
index c6c0392f43..e96fc63ee9 100644
--- a/railties/lib/rails/generators/named_base.rb
+++ b/railties/lib/rails/generators/named_base.rb
@@ -9,9 +9,6 @@ module Rails
class_option :skip_namespace, :type => :boolean, :default => false,
:desc => "Skip namespace (affects only isolated applications)"
- class_option :old_style_hash, :type => :boolean, :default => false,
- :desc => "Force using old style hash (:foo => 'bar') on Ruby >= 1.9"
-
def initialize(args, *options) #:nodoc:
@inside_template = nil
# Unfreeze name in case it's given as a frozen string
@@ -185,14 +182,9 @@ module Rails
end
end
- # Returns Ruby 1.9 style key-value pair if current code is running on
- # Ruby 1.9.x. Returns the old-style (with hash rocket) otherwise.
+ # Returns Ruby 1.9 style key-value pair.
def key_value(key, value)
- if options[:old_style_hash] || RUBY_VERSION < '1.9'
- ":#{key} => #{value}"
- else
- "#{key}: #{value}"
- end
+ "#{key}: #{value}"
end
end
end
diff --git a/railties/lib/rails/generators/rails/app/templates/Gemfile b/railties/lib/rails/generators/rails/app/templates/Gemfile
index c260cc999b..60ea394d2f 100644
--- a/railties/lib/rails/generators/rails/app/templates/Gemfile
+++ b/railties/lib/rails/generators/rails/app/templates/Gemfile
@@ -5,7 +5,6 @@ source 'https://rubygems.org'
<%= database_gemfile_entry -%>
<%= "gem 'jruby-openssl'\n" if defined?(JRUBY_VERSION) -%>
-<%= "gem 'json'\n" if RUBY_VERSION < "1.9.2" -%>
<%= assets_gemfile_entry %>
<%= javascript_gemfile_entry %>
@@ -13,6 +12,9 @@ source 'https://rubygems.org'
# To use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'
+# To use Jbuilder templates for JSON
+# gem 'jbuilder'
+
# Use unicorn as the web server
# gem 'unicorn'
diff --git a/railties/lib/rails/generators/rails/app/templates/gitignore b/railties/lib/rails/generators/rails/app/templates/gitignore
index eb3489a986..8910bf5a06 100644
--- a/railties/lib/rails/generators/rails/app/templates/gitignore
+++ b/railties/lib/rails/generators/rails/app/templates/gitignore
@@ -9,6 +9,7 @@
# Ignore the default SQLite database.
/db/*.sqlite3
+/db/*.sqlite3-journal
# Ignore all logfiles and tempfiles.
/log/*.log
diff --git a/railties/lib/rails/generators/rails/plugin_new/templates/gitignore b/railties/lib/rails/generators/rails/plugin_new/templates/gitignore
index 7833c586f3..458b2c662e 100644
--- a/railties/lib/rails/generators/rails/plugin_new/templates/gitignore
+++ b/railties/lib/rails/generators/rails/plugin_new/templates/gitignore
@@ -2,6 +2,7 @@
log/*.log
pkg/
<%= dummy_path %>/db/*.sqlite3
+<%= dummy_path %>/db/*.sqlite3-journal
<%= dummy_path %>/log/*.log
<%= dummy_path %>/tmp/
<%= dummy_path %>/.sass-cache
diff --git a/railties/lib/rails/performance_test_help.rb b/railties/lib/rails/performance_test_help.rb
index 4ac38981d0..b1285efde2 100644
--- a/railties/lib/rails/performance_test_help.rb
+++ b/railties/lib/rails/performance_test_help.rb
@@ -1,3 +1,3 @@
ActionController::Base.perform_caching = true
ActiveSupport::Dependencies.mechanism = :require
-Rails.logger.level = ActiveSupport::BufferedLogger::INFO
+Rails.logger.level = ActiveSupport::Logger::INFO
diff --git a/railties/lib/rails/ruby_version_check.rb b/railties/lib/rails/ruby_version_check.rb
index 4d57c5973c..4536fedaa3 100644
--- a/railties/lib/rails/ruby_version_check.rb
+++ b/railties/lib/rails/ruby_version_check.rb
@@ -1,8 +1,8 @@
-if RUBY_VERSION < '1.8.7'
+if RUBY_VERSION < '1.9.3'
desc = defined?(RUBY_DESCRIPTION) ? RUBY_DESCRIPTION : "ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE})"
abort <<-end_message
- Rails 3 requires Ruby 1.8.7 or 1.9.2.
+ Rails 4 requires Ruby 1.9.3+.
You're running
#{desc}
@@ -10,14 +10,4 @@ if RUBY_VERSION < '1.8.7'
Please upgrade to continue.
end_message
-elsif RUBY_VERSION > '1.9' and RUBY_VERSION < '1.9.2'
- $stderr.puts <<-end_message
-
- Rails 3 doesn't officially support Ruby 1.9.1 since recent stable
- releases have segfaulted the test suite. Please upgrade to Ruby 1.9.2.
-
- You're running
- #{RUBY_DESCRIPTION}
-
- end_message
end
diff --git a/railties/lib/rails/version.rb b/railties/lib/rails/version.rb
index 254227ecf7..ec878f9dcf 100644
--- a/railties/lib/rails/version.rb
+++ b/railties/lib/rails/version.rb
@@ -1,7 +1,7 @@
module Rails
module VERSION #:nodoc:
- MAJOR = 3
- MINOR = 2
+ MAJOR = 4
+ MINOR = 0
TINY = 0
PRE = "beta"
diff --git a/railties/test/abstract_unit.rb b/railties/test/abstract_unit.rb
index 1c3f8a701a..400068d94c 100644
--- a/railties/test/abstract_unit.rb
+++ b/railties/test/abstract_unit.rb
@@ -5,7 +5,6 @@ require 'test/unit'
require 'fileutils'
require 'active_support'
-require 'active_support/core_ext/logger'
require 'action_controller'
require 'rails/all'
diff --git a/railties/test/application/configuration_test.rb b/railties/test/application/configuration_test.rb
index 28ffff58ca..8f2e6e9ac0 100644
--- a/railties/test/application/configuration_test.rb
+++ b/railties/test/application/configuration_test.rb
@@ -189,12 +189,8 @@ module ApplicationTests
end
def assert_utf8
- if RUBY_VERSION < '1.9'
- assert_equal "UTF8", $KCODE
- else
- assert_equal Encoding::UTF_8, Encoding.default_external
- assert_equal Encoding::UTF_8, Encoding.default_internal
- end
+ assert_equal Encoding::UTF_8, Encoding.default_external
+ assert_equal Encoding::UTF_8, Encoding.default_internal
end
test "skipping config.encoding still results in 'utf-8' as the default" do
diff --git a/railties/test/application/initializers/check_ruby_version_test.rb b/railties/test/application/initializers/check_ruby_version_test.rb
deleted file mode 100644
index df7e9696a9..0000000000
--- a/railties/test/application/initializers/check_ruby_version_test.rb
+++ /dev/null
@@ -1,39 +0,0 @@
-require "isolation/abstract_unit"
-
-module ApplicationTests
- class CheckRubyVersionTest < Test::Unit::TestCase
- include ActiveSupport::Testing::Isolation
-
- def setup
- build_app
- boot_rails
- end
-
- def teardown
- teardown_app
- end
-
- test "rails initializes with ruby 1.8.7 or later, except for 1.9.1" do
- if RUBY_VERSION < '1.8.7'
- assert_rails_does_not_boot
- elsif RUBY_VERSION == '1.9.1'
- assert_rails_does_not_boot
- else
- assert_rails_boots
- end
- end
-
- def assert_rails_boots
- assert_nothing_raised "It appears that rails does not boot" do
- require "rails/all"
- end
- end
-
- def assert_rails_does_not_boot
- $stderr = File.open("/dev/null", "w")
- assert_raises(SystemExit) do
- require "rails/all"
- end
- end
- end
-end
diff --git a/railties/test/application/middleware/exceptions_test.rb b/railties/test/application/middleware/exceptions_test.rb
index a9cde42be8..aedc4fe648 100644
--- a/railties/test/application/middleware/exceptions_test.rb
+++ b/railties/test/application/middleware/exceptions_test.rb
@@ -99,7 +99,7 @@ module ApplicationTests
app_file 'app/views/foo/index.html.erb', <<-ERB
<% raise 'boooom' %>
- ✓
+ ✓測試テスト시험
ERB
app_file 'config/routes.rb', <<-RUBY
@@ -110,6 +110,7 @@ module ApplicationTests
post '/foo', :utf8 => '✓'
assert_match(/boooom/, last_response.body)
+ assert_match(/測試テスト시험/, last_response.body)
end
end
end
diff --git a/railties/test/generators/app_generator_test.rb b/railties/test/generators/app_generator_test.rb
index c456347e5c..a15943dfc6 100644
--- a/railties/test/generators/app_generator_test.rb
+++ b/railties/test/generators/app_generator_test.rb
@@ -285,17 +285,10 @@ class AppGeneratorTest < Rails::Generators::TestCase
end
end
- def test_inclusion_of_ruby_debug
+ def test_inclusion_of_ruby_debug19
run_generator
assert_file "Gemfile" do |contents|
- assert_match(/gem 'ruby-debug'/, contents) if RUBY_VERSION < '1.9'
- end
- end
-
- def test_inclusion_of_ruby_debug19_if_ruby19
- run_generator
- assert_file "Gemfile" do |contents|
- assert_match(/gem 'ruby-debug19', :require => 'ruby-debug'/, contents) unless RUBY_VERSION < '1.9'
+ assert_match(/gem 'ruby-debug19', :require => 'ruby-debug'/, contents)
end
end
@@ -337,18 +330,7 @@ class AppGeneratorTest < Rails::Generators::TestCase
def test_new_hash_style
run_generator [destination_root]
assert_file "config/initializers/session_store.rb" do |file|
- if RUBY_VERSION < "1.9"
- assert_match(/config.session_store :cookie_store, :key => '_.+_session'/, file)
- else
- assert_match(/config.session_store :cookie_store, key: '_.+_session'/, file)
- end
- end
- end
-
- def test_force_old_style_hash
- run_generator [destination_root, "--old-style-hash"]
- assert_file "config/initializers/session_store.rb" do |file|
- assert_match(/config.session_store :cookie_store, :key => '_.+_session'/, file)
+ assert_match(/config.session_store :cookie_store, key: '_.+_session'/, file)
end
end
diff --git a/railties/test/generators/mailer_generator_test.rb b/railties/test/generators/mailer_generator_test.rb
index 139d6b1421..c501780e7f 100644
--- a/railties/test/generators/mailer_generator_test.rb
+++ b/railties/test/generators/mailer_generator_test.rb
@@ -10,11 +10,7 @@ class MailerGeneratorTest < Rails::Generators::TestCase
run_generator
assert_file "app/mailers/notifier.rb" do |mailer|
assert_match(/class Notifier < ActionMailer::Base/, mailer)
- if RUBY_VERSION < "1.9"
- assert_match(/default :from => "from@example.com"/, mailer)
- else
- assert_match(/default from: "from@example.com"/, mailer)
- end
+ assert_match(/default from: "from@example.com"/, mailer)
end
end
@@ -77,33 +73,14 @@ class MailerGeneratorTest < Rails::Generators::TestCase
assert_file "app/mailers/notifier.rb" do |mailer|
assert_instance_method :foo, mailer do |foo|
- if RUBY_VERSION < "1.9"
- assert_match(/mail :to => "to@example.org"/, foo)
- else
- assert_match(/mail to: "to@example.org"/, foo)
- end
+ assert_match(/mail to: "to@example.org"/, foo)
assert_match(/@greeting = "Hi"/, foo)
end
assert_instance_method :bar, mailer do |bar|
- if RUBY_VERSION < "1.9"
- assert_match(/mail :to => "to@example.org"/, bar)
- else
- assert_match(/mail to: "to@example.org"/, bar)
- end
+ assert_match(/mail to: "to@example.org"/, bar)
assert_match(/@greeting = "Hi"/, bar)
end
end
end
-
- def test_force_old_style_hash
- run_generator ["notifier", "foo", "--old-style-hash"]
- assert_file "app/mailers/notifier.rb" do |mailer|
- assert_match(/default :from => "from@example.com"/, mailer)
-
- assert_instance_method :foo, mailer do |foo|
- assert_match(/mail :to => "to@example.org"/, foo)
- end
- end
- end
end
diff --git a/railties/test/generators/namespaced_generators_test.rb b/railties/test/generators/namespaced_generators_test.rb
index dd1e4bdac1..5c63b13dce 100644
--- a/railties/test/generators/namespaced_generators_test.rb
+++ b/railties/test/generators/namespaced_generators_test.rb
@@ -155,11 +155,7 @@ class NamespacedMailerGeneratorTest < NamespacedGeneratorTestCase
assert_file "app/mailers/test_app/notifier.rb" do |mailer|
assert_match(/module TestApp/, mailer)
assert_match(/class Notifier < ActionMailer::Base/, mailer)
- if RUBY_VERSION < "1.9"
- assert_match(/default :from => "from@example.com"/, mailer)
- else
- assert_match(/default from: "from@example.com"/, mailer)
- end
+ assert_match(/default from: "from@example.com"/, mailer)
end
end
diff --git a/railties/test/generators/scaffold_controller_generator_test.rb b/railties/test/generators/scaffold_controller_generator_test.rb
index 65b30b9fbd..1382133d7b 100644
--- a/railties/test/generators/scaffold_controller_generator_test.rb
+++ b/railties/test/generators/scaffold_controller_generator_test.rb
@@ -126,18 +126,7 @@ class ScaffoldControllerGeneratorTest < Rails::Generators::TestCase
def test_new_hash_style
run_generator
assert_file "app/controllers/users_controller.rb" do |content|
- if RUBY_VERSION < "1.9"
- assert_match(/\{ render :action => "new" \}/, content)
- else
- assert_match(/\{ render action: "new" \}/, content)
- end
- end
- end
-
- def test_force_old_style_hash
- run_generator ["User", "--old-style-hash"]
- assert_file "app/controllers/users_controller.rb" do |content|
- assert_match(/\{ render :action => "new" \}/, content)
+ assert_match(/\{ render action: "new" \}/, content)
end
end
end
diff --git a/railties/test/railties/generators_test.rb b/railties/test/railties/generators_test.rb
index f8540d69d9..6ebbabc0ff 100644
--- a/railties/test/railties/generators_test.rb
+++ b/railties/test/railties/generators_test.rb
@@ -46,10 +46,6 @@ module RailtiesTests
gem 'rails', :path => '#{RAILS_FRAMEWORK_ROOT}'
gem 'sqlite3'
-
- if RUBY_VERSION < '1.9'
- gem "ruby-debug", ">= 0.10.3"
- end
GEMFILE
end
end
diff --git a/version.rb b/version.rb
index 254227ecf7..ec878f9dcf 100644
--- a/version.rb
+++ b/version.rb
@@ -1,7 +1,7 @@
module Rails
module VERSION #:nodoc:
- MAJOR = 3
- MINOR = 2
+ MAJOR = 4
+ MINOR = 0
TINY = 0
PRE = "beta"