Changeset 4386
- Timestamp:
- 05/31/06 22:43:53 (2 years ago)
- Files:
-
- trunk/activesupport/lib/active_support/core_ext/load_error.rb (modified) (2 diffs)
- trunk/activesupport/lib/active_support/ordered_options.rb (modified) (2 diffs)
- trunk/activesupport/lib/active_support/values/time_zone.rb (modified) (1 diff)
- trunk/activesupport/test/core_ext/kernel_test.rb (modified) (1 diff)
- trunk/activesupport/test/core_ext/module_test.rb (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/activesupport/lib/active_support/core_ext/load_error.rb
r1735 r4386 9 9 path.gsub(/\.rb$/, '') == self.path.gsub(/\.rb$/, '') 10 10 end 11 11 12 12 def self.from_message(message) 13 13 REGEXPS.each do |regexp, capture| … … 17 17 nil 18 18 end 19 19 20 20 REGEXPS = [ 21 21 [/^no such file to load -- (.+)$/i, 1], 22 22 [/^Missing \w+ (file\s*)?([^\s]+.rb)$/i, 2], 23 23 [/^Missing API definition file in (.+)$/i, 1] 24 ] 24 ] unless defined?(REGEXPS) 25 25 end 26 26 trunk/activesupport/lib/active_support/ordered_options.rb
r4318 r4386 1 1 # OrderedHash is namespaced to prevent conflicts with other implementations 2 class ActiveSupport::OrderedHash < Array #:nodoc: 3 def []=(key, value) 4 if pair = find_pair(key) 5 pair.pop 6 pair << value 7 else 8 self << [key, value] 2 module ActiveSupport 3 class OrderedHash < Array #:nodoc: 4 def []=(key, value) 5 if pair = find_pair(key) 6 pair.pop 7 pair << value 8 else 9 self << [key, value] 10 end 9 11 end 12 13 def [](key) 14 pair = find_pair(key) 15 pair ? pair.last : nil 16 end 17 18 def keys 19 self.collect { |i| i.first } 20 end 21 22 private 23 def find_pair(key) 24 self.each { |i| return i if i.first == key } 25 return false 26 end 10 27 end 11 12 def [](key)13 pair = find_pair(key)14 pair ? pair.last : nil15 end16 17 def keys18 self.collect { |i| i.first }19 end20 21 private22 def find_pair(key)23 self.each { |i| return i if i.first == key }24 return false25 end26 28 end 27 29 … … 30 32 super(key.to_sym, value) 31 33 end 32 34 33 35 def [](key) 34 36 super(key.to_sym) trunk/activesupport/lib/active_support/values/time_zone.rb
r787 r4386 170 170 # A regular expression that matches the names of all time zones in 171 171 # the USA. 172 US_ZONES = /US|Arizona|Indiana|Hawaii|Alaska/ 172 US_ZONES = /US|Arizona|Indiana|Hawaii|Alaska/ unless defined?(US_ZONES) 173 173 174 174 # A convenience method for returning a collection of TimeZone objects trunk/activesupport/test/core_ext/kernel_test.rb
r3134 r4386 35 35 silence_stderr { STDERR.puts 'hello world' } 36 36 assert_equal old_stderr_position, STDERR.tell 37 rescue Errno::ESPIPE 38 # Skip if we can't STDERR.tell 37 39 end 38 40 trunk/activesupport/test/core_ext/module_test.rb
r4311 r4386 128 128 129 129 def test_alias_method_chain 130 assert @instance.respond_to? :bar130 assert @instance.respond_to?(:bar) 131 131 feature_aliases = [:bar_with_baz, :bar_without_baz] 132 132 … … 153 153 FooClassWithBarMethod.alias_method_chain :quux!, :baz 154 154 assert @instance.respond_to?(:quux_with_baz) 155 155 156 156 assert_equal 'quux_with_baz', @instance.quux! 157 157 assert_equal 'quux', @instance.quux_without_baz