mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
Merge commit 'fxn/master'
This commit is contained in:
@@ -1,5 +1,3 @@
|
||||
require 'active_support/core_ext/string/bytesize'
|
||||
|
||||
module ActionController #:nodoc:
|
||||
# Methods for sending arbitrary data and for streaming files to the browser,
|
||||
# instead of rendering.
|
||||
|
||||
@@ -5,7 +5,6 @@ require 'strscan'
|
||||
require 'active_support/memoizable'
|
||||
require 'active_support/core_ext/array/wrap'
|
||||
require 'active_support/core_ext/hash/indifferent_access'
|
||||
require 'active_support/core_ext/object/tap'
|
||||
require 'active_support/core_ext/string/access'
|
||||
|
||||
module ActionDispatch
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
require 'abstract_unit'
|
||||
require 'active_support/core_ext/symbol'
|
||||
|
||||
class ActionController::Base
|
||||
class << self
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
require 'active_support/core_ext/object/tap'
|
||||
|
||||
module ActiveRecord
|
||||
module AttributeMethods
|
||||
module Dirty
|
||||
|
||||
@@ -12,7 +12,6 @@ require 'active_support/core_ext/hash/deep_merge'
|
||||
require 'active_support/core_ext/hash/indifferent_access'
|
||||
require 'active_support/core_ext/hash/slice'
|
||||
require 'active_support/core_ext/string/behavior'
|
||||
require 'active_support/core_ext/symbol'
|
||||
require 'active_support/core_ext/object/metaclass'
|
||||
|
||||
module ActiveRecord #:nodoc:
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
require 'active_support/core_ext/integer/even_odd'
|
||||
|
||||
module ActiveRecord
|
||||
# Raised by <tt>save!</tt> and <tt>create!</tt> when the record is invalid. Use the
|
||||
# +record+ method to retrieve the record which did not validate.
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
require 'abstract_unit'
|
||||
require "fixtures/person"
|
||||
require "fixtures/street_address"
|
||||
require 'active_support/core_ext/symbol'
|
||||
require 'active_support/core_ext/hash/conversions'
|
||||
|
||||
module Highrise
|
||||
|
||||
@@ -101,15 +101,6 @@ module Enumerable
|
||||
size = block_given? ? select(&block).size : self.size
|
||||
size > 1
|
||||
end
|
||||
|
||||
# Returns true if none of the elements match the given block.
|
||||
#
|
||||
# success = responses.none? {|r| r.status / 100 == 5 }
|
||||
#
|
||||
# This is a builtin method in Ruby 1.8.7 and later.
|
||||
def none?(&block)
|
||||
!any?(&block)
|
||||
end unless [].respond_to?(:none?)
|
||||
end
|
||||
|
||||
class Range #:nodoc:
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
require 'active_support/core_ext/integer/even_odd'
|
||||
require 'active_support/core_ext/integer/multiple'
|
||||
require 'active_support/core_ext/integer/inflections'
|
||||
require 'active_support/core_ext/integer/time'
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
class Integer
|
||||
# Check whether the integer is evenly divisible by the argument.
|
||||
def multiple_of?(number)
|
||||
self % number == 0
|
||||
end
|
||||
|
||||
# Is the integer a multiple of 2?
|
||||
def even?
|
||||
multiple_of? 2
|
||||
end unless method_defined?(:even?)
|
||||
|
||||
# Is the integer not a multiple of 2?
|
||||
def odd?
|
||||
!even?
|
||||
end unless method_defined?(:odd?)
|
||||
end
|
||||
@@ -0,0 +1,6 @@
|
||||
class Integer
|
||||
# Check whether the integer is evenly divisible by the argument.
|
||||
def multiple_of?(number)
|
||||
self % number == 0
|
||||
end
|
||||
end
|
||||
@@ -1,11 +1,4 @@
|
||||
class Object
|
||||
# Available in 1.8.6 and later.
|
||||
unless respond_to?(:instance_variable_defined?)
|
||||
def instance_variable_defined?(variable)
|
||||
instance_variables.include?(variable.to_s)
|
||||
end
|
||||
end
|
||||
|
||||
# Returns a hash that maps instance variable names without "@" to their
|
||||
# corresponding values. Keys are strings both in Ruby 1.8 and 1.9.
|
||||
#
|
||||
|
||||
@@ -1,3 +1,2 @@
|
||||
require 'active_support/core_ext/object/returning'
|
||||
require 'active_support/core_ext/object/tap'
|
||||
require 'active_support/core_ext/object/with_options'
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
class Object
|
||||
# Yields <code>x</code> to the block, and then returns <code>x</code>.
|
||||
# The primary purpose of this method is to "tap into" a method chain,
|
||||
# in order to perform operations on intermediate results within the chain.
|
||||
#
|
||||
# (1..10).tap { |x| puts "original: #{x.inspect}" }.to_a.
|
||||
# tap { |x| puts "array: #{x.inspect}" }.
|
||||
# select { |x| x%2 == 0 }.
|
||||
# tap { |x| puts "evens: #{x.inspect}" }.
|
||||
# map { |x| x*x }.
|
||||
# tap { |x| puts "squares: #{x.inspect}" }
|
||||
def tap
|
||||
yield self
|
||||
self
|
||||
end unless Object.respond_to?(:tap)
|
||||
end
|
||||
@@ -1,43 +0,0 @@
|
||||
require 'active_support/core_ext/kernel/reporting'
|
||||
|
||||
# Fixes the rexml vulnerability disclosed at:
|
||||
# http://www.ruby-lang.org/en/news/2008/08/23/dos-vulnerability-in-rexml/
|
||||
# This fix is identical to rexml-expansion-fix version 1.0.1
|
||||
require 'rexml/rexml'
|
||||
|
||||
# Earlier versions of rexml defined REXML::Version, newer ones REXML::VERSION
|
||||
unless (defined?(REXML::VERSION) ? REXML::VERSION : REXML::Version) > "3.1.7.2"
|
||||
silence_warnings { require 'rexml/document' }
|
||||
|
||||
# REXML in 1.8.7 has the patch but early patchlevels didn't update Version from 3.1.7.2.
|
||||
unless REXML::Document.respond_to?(:entity_expansion_limit=)
|
||||
silence_warnings { require 'rexml/entity' }
|
||||
|
||||
module REXML #:nodoc:
|
||||
class Entity < Child #:nodoc:
|
||||
undef_method :unnormalized
|
||||
def unnormalized
|
||||
document.record_entity_expansion! if document
|
||||
v = value()
|
||||
return nil if v.nil?
|
||||
@unnormalized = Text::unnormalize(v, parent)
|
||||
@unnormalized
|
||||
end
|
||||
end
|
||||
class Document < Element #:nodoc:
|
||||
@@entity_expansion_limit = 10_000
|
||||
def self.entity_expansion_limit= val
|
||||
@@entity_expansion_limit = val
|
||||
end
|
||||
|
||||
def record_entity_expansion!
|
||||
@number_of_expansions ||= 0
|
||||
@number_of_expansions += 1
|
||||
if @number_of_expansions > @@entity_expansion_limit
|
||||
raise "Number of entity expansions exceeded, processing aborted."
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -4,7 +4,6 @@ require 'active_support/core_ext/string/multibyte'
|
||||
require 'active_support/core_ext/string/starts_ends_with'
|
||||
require 'active_support/core_ext/string/inflections'
|
||||
require 'active_support/core_ext/string/access'
|
||||
require 'active_support/core_ext/string/iterators'
|
||||
require 'active_support/core_ext/string/xchar'
|
||||
require 'active_support/core_ext/string/behavior'
|
||||
require 'active_support/core_ext/string/interpolation'
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
unless '1.9'.respond_to?(:bytesize)
|
||||
class String
|
||||
alias :bytesize :size
|
||||
end
|
||||
end
|
||||
@@ -6,7 +6,6 @@
|
||||
=end
|
||||
|
||||
if RUBY_VERSION < '1.9'
|
||||
require 'active_support/core_ext/string/bytesize'
|
||||
|
||||
# KeyError is raised by String#% when the string contains a named placeholder
|
||||
# that is not contained in the given arguments hash. Ruby 1.9 includes and
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
unless '1.9'.respond_to?(:each_char)
|
||||
class String
|
||||
# Yields a single-character string for each character in the string.
|
||||
# When $KCODE = 'UTF8', multi-byte characters are yielded appropriately.
|
||||
def each_char
|
||||
require 'strscan' unless defined? ::StringScanner
|
||||
scanner, char = ::StringScanner.new(self), /./mu
|
||||
while c = scanner.scan(char)
|
||||
yield c
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,18 +1,4 @@
|
||||
class String
|
||||
unless '1.8.7 and up'.respond_to?(:start_with?)
|
||||
# Does the string start with the specified +prefix+?
|
||||
def start_with?(prefix)
|
||||
prefix = prefix.to_s
|
||||
self[0, prefix.length] == prefix
|
||||
end
|
||||
|
||||
# Does the string end with the specified +suffix+?
|
||||
def end_with?(suffix)
|
||||
suffix = suffix.to_s
|
||||
self[-suffix.length, suffix.length] == suffix
|
||||
end
|
||||
end
|
||||
|
||||
alias_method :starts_with?, :start_with?
|
||||
alias_method :ends_with?, :end_with?
|
||||
end
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
require 'active_support/core_ext/symbol/to_proc'
|
||||
@@ -1,14 +0,0 @@
|
||||
class Symbol
|
||||
# Turns the symbol into a simple proc, which is especially useful for enumerations. Examples:
|
||||
#
|
||||
# # The same as people.collect { |p| p.name }
|
||||
# people.collect(&:name)
|
||||
#
|
||||
# # The same as people.select { |p| p.manager? }.collect { |p| p.salary }
|
||||
# people.select(&:manager?).collect(&:salary)
|
||||
#
|
||||
# This is a builtin method in Ruby 1.8.7 and later.
|
||||
def to_proc
|
||||
Proc.new { |*args| args.shift.__send__(self, *args) }
|
||||
end unless :to_proc.respond_to?(:to_proc)
|
||||
end
|
||||
@@ -1,5 +1,3 @@
|
||||
require 'active_support/core_ext/string/bytesize'
|
||||
|
||||
module ActiveSupport
|
||||
# MessageVerifier makes it easy to generate and verify messages which are signed
|
||||
# to prevent tampering.
|
||||
|
||||
@@ -4,21 +4,13 @@
|
||||
# Date next_year, next_month
|
||||
# DateTime to_date, to_datetime, xmlschema
|
||||
# Enumerable group_by, each_with_object, none?
|
||||
# Integer even?, odd?
|
||||
# Object tap
|
||||
# Process Process.daemon
|
||||
# REXML security fix
|
||||
# String ord
|
||||
# Symbol to_proc
|
||||
# Time to_date, to_time, to_datetime
|
||||
require 'active_support'
|
||||
require 'active_support/core_ext/date/calculations'
|
||||
require 'active_support/core_ext/date_time/conversions'
|
||||
require 'active_support/core_ext/enumerable'
|
||||
require 'active_support/core_ext/integer/even_odd'
|
||||
require 'active_support/core_ext/object/tap'
|
||||
require 'active_support/core_ext/process/daemon'
|
||||
require 'active_support/core_ext/string/conversions'
|
||||
require 'active_support/core_ext/rexml'
|
||||
require 'active_support/core_ext/symbol/to_proc'
|
||||
require 'active_support/core_ext/time/conversions'
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
require 'abstract_unit'
|
||||
require 'active_support/core_ext/array'
|
||||
require 'active_support/core_ext/symbol'
|
||||
require 'active_support/core_ext/enumerable'
|
||||
|
||||
Payment = Struct.new(:price)
|
||||
@@ -90,15 +89,4 @@ class EnumerableTests < Test::Unit::TestCase
|
||||
assert ![ 1, 2 ].many? {|x| x > 1 }
|
||||
assert [ 1, 2, 2 ].many? {|x| x > 1 }
|
||||
end
|
||||
|
||||
def test_none
|
||||
assert [].none?
|
||||
assert [nil, false].none?
|
||||
assert ![1].none?
|
||||
|
||||
assert [].none? {|x| x > 1 }
|
||||
assert ![ 2 ].none? {|x| x > 1 }
|
||||
assert ![ 1, 2 ].none? {|x| x > 1 }
|
||||
assert [ 1, 1 ].none? {|x| x > 1 }
|
||||
end
|
||||
end
|
||||
|
||||
@@ -2,22 +2,6 @@ require 'abstract_unit'
|
||||
require 'active_support/core_ext/integer'
|
||||
|
||||
class IntegerExtTest < Test::Unit::TestCase
|
||||
def test_even
|
||||
assert [ -2, 0, 2, 4 ].all? { |i| i.even? }
|
||||
assert ![ -1, 1, 3 ].all? { |i| i.even? }
|
||||
|
||||
assert 22953686867719691230002707821868552601124472329079.odd?
|
||||
assert !22953686867719691230002707821868552601124472329079.even?
|
||||
assert 22953686867719691230002707821868552601124472329080.even?
|
||||
assert !22953686867719691230002707821868552601124472329080.odd?
|
||||
end
|
||||
|
||||
def test_odd
|
||||
assert ![ -2, 0, 2, 4 ].all? { |i| i.odd? }
|
||||
assert [ -1, 1, 3 ].all? { |i| i.odd? }
|
||||
assert 1000000000000000000000000000000000000000000000000000000001.odd?
|
||||
end
|
||||
|
||||
def test_multiple_of
|
||||
[ -7, 0, 7, 14 ].each { |i| assert i.multiple_of?(7) }
|
||||
[ -7, 7, 14 ].each { |i| assert ! i.multiple_of?(6) }
|
||||
|
||||
@@ -182,13 +182,6 @@ class ObjectInstanceVariableTest < Test::Unit::TestCase
|
||||
assert_equal %w(@bar @baz), @source.instance_variable_names.sort
|
||||
end
|
||||
|
||||
def test_instance_variable_defined
|
||||
assert @source.instance_variable_defined?('@bar')
|
||||
assert @source.instance_variable_defined?(:@bar)
|
||||
assert !@source.instance_variable_defined?(:@foo)
|
||||
assert !@source.instance_variable_defined?('@foo')
|
||||
end
|
||||
|
||||
def test_copy_instance_variables_from_without_explicit_excludes
|
||||
assert_equal [], @dest.instance_variables
|
||||
@dest.copy_instance_variables_from(@source)
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
require 'abstract_unit'
|
||||
require 'active_support/core_ext/object/metaclass'
|
||||
|
||||
class ObjectExtTest < Test::Unit::TestCase
|
||||
def test_tap_yields_and_returns_self
|
||||
foo = Object.new
|
||||
assert_equal foo, foo.tap { |x| assert_equal foo, x; :bar }
|
||||
end
|
||||
end
|
||||
@@ -185,17 +185,9 @@ class StringInflectionsTest < Test::Unit::TestCase
|
||||
assert s.starts_with?('hel')
|
||||
assert !s.starts_with?('el')
|
||||
|
||||
assert s.start_with?('h')
|
||||
assert s.start_with?('hel')
|
||||
assert !s.start_with?('el')
|
||||
|
||||
assert s.ends_with?('o')
|
||||
assert s.ends_with?('lo')
|
||||
assert !s.ends_with?('el')
|
||||
|
||||
assert s.end_with?('o')
|
||||
assert s.end_with?('lo')
|
||||
assert !s.end_with?('el')
|
||||
end
|
||||
|
||||
def test_string_squish
|
||||
@@ -214,17 +206,6 @@ class StringInflectionsTest < Test::Unit::TestCase
|
||||
# And changes the original string:
|
||||
assert_equal original, expected
|
||||
end
|
||||
|
||||
if RUBY_VERSION < '1.9'
|
||||
def test_each_char_with_utf8_string_when_kcode_is_utf8
|
||||
with_kcode('UTF8') do
|
||||
'€2.99'.each_char do |char|
|
||||
assert_not_equal 1, char.length
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class StringBehaviourTest < Test::Unit::TestCase
|
||||
@@ -350,13 +331,6 @@ class TestGetTextString < Test::Unit::TestCase
|
||||
end
|
||||
end
|
||||
|
||||
class StringBytesizeTest < Test::Unit::TestCase
|
||||
def test_bytesize
|
||||
assert_respond_to 'foo', :bytesize
|
||||
assert_equal 3, 'foo'.bytesize
|
||||
end
|
||||
end
|
||||
|
||||
class OutputSafetyTest < ActiveSupport::TestCase
|
||||
def setup
|
||||
@string = "hello"
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
require 'abstract_unit'
|
||||
|
||||
class SymbolTests < Test::Unit::TestCase
|
||||
def test_to_proc
|
||||
assert_equal %w(one two three), [:one, :two, :three].map(&:to_s)
|
||||
assert_equal(%w(one two three),
|
||||
{1 => "one", 2 => "two", 3 => "three"}.sort_by(&:first).map(&:last))
|
||||
end
|
||||
end
|
||||
@@ -3,7 +3,6 @@ require 'pp'
|
||||
require 'active_support/dependencies'
|
||||
require 'active_support/core_ext/module/loading'
|
||||
require 'active_support/core_ext/kernel/reporting'
|
||||
require 'active_support/core_ext/symbol/to_proc'
|
||||
|
||||
module ModuleWithMissing
|
||||
mattr_accessor :missing_count
|
||||
|
||||
Reference in New Issue
Block a user