Changeset 3356
- Timestamp:
- 12/27/05 03:11:03 (3 years ago)
- Files:
-
- trunk/activesupport/CHANGELOG (modified) (1 diff)
- trunk/activesupport/lib/active_support.rb (modified) (1 diff)
- trunk/activesupport/lib/active_support/core_ext/object_and_class.rb (modified) (1 diff)
- trunk/activesupport/lib/active_support/core_ext/string.rb (modified) (2 diffs)
- trunk/activesupport/lib/active_support/core_ext/string/iterators.rb (added)
- trunk/activesupport/lib/active_support/json (added)
- trunk/activesupport/lib/active_support/json.rb (added)
- trunk/activesupport/lib/active_support/json/encoders (added)
- trunk/activesupport/lib/active_support/json/encoders.rb (added)
- trunk/activesupport/lib/active_support/json/encoders/core.rb (added)
- trunk/activesupport/test/core_ext/object_and_class_ext_test.rb (modified) (1 diff)
- trunk/activesupport/test/core_ext/string_ext_test.rb (modified) (1 diff)
- trunk/activesupport/test/json.rb (added)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/activesupport/CHANGELOG
r3314 r3356 1 1 *SVN* 2 3 * Add ActiveSupport::JSON and Object#to_json for converting Ruby objects to JSON strings. [Sam Stephenson] 2 4 3 5 * Add Object#with_options for DRYing up multiple calls to methods having shared options. [Sam Stephenson] Example: trunk/activesupport/lib/active_support.rb
r3314 r3356 36 36 37 37 require 'active_support/values/time_zone' 38 39 require 'active_support/json' trunk/activesupport/lib/active_support/core_ext/object_and_class.rb
r3314 r3356 55 55 yield ActiveSupport::OptionMerger.new(self, options) 56 56 end 57 58 def instance_values 59 instance_variables.inject({}) do |values, name| 60 values[name[1..-1]] = instance_variable_get(name) 61 values 62 end 63 end 64 65 def to_json 66 ActiveSupport::JSON.encode(self) 67 end 57 68 end 58 69 trunk/activesupport/lib/active_support/core_ext/string.rb
r2171 r3356 3 3 require File.dirname(__FILE__) + '/string/access' 4 4 require File.dirname(__FILE__) + '/string/starts_ends_with' 5 require File.dirname(__FILE__) + '/string/iterators' 5 6 6 7 class String #:nodoc: … … 9 10 include ActiveSupport::CoreExtensions::String::Inflections 10 11 include ActiveSupport::CoreExtensions::String::StartsEndsWith 12 include ActiveSupport::CoreExtensions::String::Iterators 11 13 end trunk/activesupport/test/core_ext/object_and_class_ext_test.rb
r3133 r3356 105 105 assert_equal 'baz', @dest.instance_variable_get('@baz') 106 106 end 107 108 def test_instance_values 109 object = Object.new 110 object.instance_variable_set :@a, 1 111 object.instance_variable_set :@b, 2 112 assert_equal({'a' => 1, 'b' => 2}, object.instance_values) 113 end 107 114 end trunk/activesupport/test/core_ext/string_ext_test.rb
r3127 r3356 90 90 assert !s.ends_with?('el') 91 91 end 92 93 def test_each_char_with_utf8_string_when_kcode_is_utf8 94 old_kcode, $KCODE = $KCODE, 'UTF8' 95 'â¬2.99'.each_char do |char| 96 assert_not_equal 1, char.length 97 break 98 end 99 ensure 100 $KCODE = old_kcode 101 end 92 102 end