activesupport 1.4.4 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of activesupport might be problematic. Click here for more details.

Files changed (126) hide show
  1. data/CHANGELOG +263 -7
  2. data/lib/active_support.rb +9 -4
  3. data/lib/active_support/basic_object.rb +5 -0
  4. data/lib/active_support/buffered_logger.rb +107 -0
  5. data/lib/active_support/clean_logger.rb +94 -5
  6. data/lib/active_support/core_ext.rb +4 -1
  7. data/lib/active_support/core_ext/array.rb +8 -2
  8. data/lib/active_support/core_ext/array/access.rb +28 -0
  9. data/lib/active_support/core_ext/array/conversions.rb +28 -15
  10. data/lib/active_support/core_ext/array/extract_options.rb +19 -0
  11. data/lib/active_support/core_ext/array/grouping.rb +20 -7
  12. data/lib/active_support/core_ext/array/random_access.rb +12 -0
  13. data/lib/active_support/core_ext/bigdecimal.rb +1 -2
  14. data/lib/active_support/core_ext/bigdecimal/{formatting.rb → conversions.rb} +1 -2
  15. data/lib/active_support/core_ext/blank.rb +2 -8
  16. data/lib/active_support/core_ext/cgi.rb +2 -2
  17. data/lib/active_support/core_ext/class.rb +4 -3
  18. data/lib/active_support/core_ext/class/attribute_accessors.rb +1 -1
  19. data/lib/active_support/core_ext/class/delegating_attributes.rb +40 -0
  20. data/lib/active_support/core_ext/class/inheritable_attributes.rb +3 -3
  21. data/lib/active_support/core_ext/class/removal.rb +2 -2
  22. data/lib/active_support/core_ext/date.rb +5 -1
  23. data/lib/active_support/core_ext/date/behavior.rb +13 -0
  24. data/lib/active_support/core_ext/date/calculations.rb +188 -0
  25. data/lib/active_support/core_ext/date/conversions.rb +69 -13
  26. data/lib/active_support/core_ext/date_time.rb +10 -0
  27. data/lib/active_support/core_ext/date_time/calculations.rb +77 -0
  28. data/lib/active_support/core_ext/date_time/conversions.rb +54 -0
  29. data/lib/active_support/core_ext/duplicable.rb +37 -0
  30. data/lib/active_support/core_ext/enumerable.rb +1 -0
  31. data/lib/active_support/core_ext/exception.rb +2 -2
  32. data/lib/active_support/core_ext/file.rb +21 -0
  33. data/lib/active_support/core_ext/float.rb +5 -0
  34. data/lib/active_support/core_ext/float/rounding.rb +24 -0
  35. data/lib/active_support/core_ext/hash.rb +5 -5
  36. data/lib/active_support/core_ext/hash/conversions.rb +86 -34
  37. data/lib/active_support/core_ext/hash/diff.rb +8 -0
  38. data/lib/active_support/core_ext/hash/except.rb +24 -0
  39. data/lib/active_support/core_ext/hash/indifferent_access.rb +15 -2
  40. data/lib/active_support/core_ext/hash/keys.rb +10 -3
  41. data/lib/active_support/core_ext/hash/reverse_merge.rb +2 -2
  42. data/lib/active_support/core_ext/hash/slice.rb +28 -0
  43. data/lib/active_support/core_ext/integer.rb +2 -2
  44. data/lib/active_support/core_ext/kernel.rb +5 -4
  45. data/lib/active_support/core_ext/kernel/debugger.rb +13 -0
  46. data/lib/active_support/core_ext/module.rb +8 -7
  47. data/lib/active_support/core_ext/module/aliasing.rb +17 -5
  48. data/lib/active_support/core_ext/module/attr_accessor_with_default.rb +31 -0
  49. data/lib/active_support/core_ext/module/attribute_accessors.rb +1 -1
  50. data/lib/active_support/core_ext/module/delegation.rb +21 -0
  51. data/lib/active_support/core_ext/name_error.rb +2 -2
  52. data/lib/active_support/core_ext/numeric.rb +2 -2
  53. data/lib/active_support/core_ext/numeric/time.rb +30 -11
  54. data/lib/active_support/core_ext/object.rb +3 -2
  55. data/lib/active_support/core_ext/object/extending.rb +40 -29
  56. data/lib/active_support/core_ext/object/instance_variables.rb +22 -0
  57. data/lib/active_support/core_ext/object/misc.rb +29 -4
  58. data/lib/active_support/core_ext/pathname.rb +1 -1
  59. data/lib/active_support/core_ext/range.rb +7 -1
  60. data/lib/active_support/core_ext/range/blockless_step.rb +22 -0
  61. data/lib/active_support/core_ext/range/conversions.rb +8 -6
  62. data/lib/active_support/core_ext/range/include_range.rb +22 -0
  63. data/lib/active_support/core_ext/range/overlaps.rb +12 -0
  64. data/lib/active_support/core_ext/string.rb +10 -7
  65. data/lib/active_support/core_ext/string/conversions.rb +5 -1
  66. data/lib/active_support/core_ext/string/unicode.rb +2 -2
  67. data/lib/active_support/core_ext/string/xchar.rb +11 -0
  68. data/lib/active_support/core_ext/symbol.rb +12 -10
  69. data/lib/active_support/core_ext/test.rb +1 -0
  70. data/lib/active_support/core_ext/test/unit/assertions.rb +62 -0
  71. data/lib/active_support/core_ext/time.rb +4 -2
  72. data/lib/active_support/core_ext/time/behavior.rb +13 -0
  73. data/lib/active_support/core_ext/time/calculations.rb +87 -54
  74. data/lib/active_support/core_ext/time/conversions.rb +71 -10
  75. data/lib/active_support/dependencies.rb +25 -24
  76. data/lib/active_support/deprecation.rb +4 -2
  77. data/lib/active_support/duration.rb +86 -0
  78. data/lib/active_support/inflections.rb +2 -1
  79. data/lib/active_support/inflector.rb +13 -6
  80. data/lib/active_support/json.rb +22 -39
  81. data/lib/active_support/json/decoding.rb +60 -0
  82. data/lib/active_support/json/encoders/date.rb +5 -0
  83. data/lib/active_support/json/encoders/date_time.rb +5 -0
  84. data/lib/active_support/json/encoders/enumerable.rb +12 -0
  85. data/lib/active_support/json/encoders/false_class.rb +5 -0
  86. data/lib/active_support/json/encoders/hash.rb +50 -0
  87. data/lib/active_support/json/encoders/nil_class.rb +5 -0
  88. data/lib/active_support/json/encoders/numeric.rb +5 -0
  89. data/lib/active_support/json/encoders/object.rb +6 -0
  90. data/lib/active_support/json/encoders/regexp.rb +5 -0
  91. data/lib/active_support/json/encoders/string.rb +30 -0
  92. data/lib/active_support/json/encoders/symbol.rb +5 -0
  93. data/lib/active_support/json/encoders/time.rb +5 -0
  94. data/lib/active_support/json/encoders/true_class.rb +5 -0
  95. data/lib/active_support/json/encoding.rb +38 -0
  96. data/lib/active_support/json/variable.rb +10 -0
  97. data/lib/active_support/multibyte.rb +7 -5
  98. data/lib/active_support/multibyte/chars.rb +6 -0
  99. data/lib/active_support/multibyte/handlers/utf8_handler.rb +115 -5
  100. data/lib/active_support/option_merger.rb +7 -7
  101. data/lib/active_support/ordered_options.rb +22 -17
  102. data/lib/active_support/test_case.rb +5 -0
  103. data/lib/active_support/testing.rb +1 -0
  104. data/lib/active_support/testing/default.rb +12 -0
  105. data/lib/active_support/values/time_zone.rb +3 -3
  106. data/lib/active_support/vendor.rb +14 -0
  107. data/lib/active_support/vendor/builder-2.1.2/blankslate.rb +113 -0
  108. data/lib/active_support/vendor/{builder.rb → builder-2.1.2/builder.rb} +0 -0
  109. data/lib/active_support/vendor/builder-2.1.2/builder/blankslate.rb +20 -0
  110. data/lib/active_support/vendor/builder-2.1.2/builder/css.rb +250 -0
  111. data/lib/active_support/vendor/{builder → builder-2.1.2/builder}/xchar.rb +11 -8
  112. data/lib/active_support/vendor/{builder → builder-2.1.2/builder}/xmlbase.rb +38 -44
  113. data/lib/active_support/vendor/{builder → builder-2.1.2/builder}/xmlevents.rb +1 -1
  114. data/lib/active_support/vendor/{builder → builder-2.1.2/builder}/xmlmarkup.rb +40 -39
  115. data/lib/active_support/vendor/{xml_simple.rb → xml-simple-1.0.11/xmlsimple.rb} +3 -3
  116. data/lib/active_support/version.rb +3 -3
  117. data/lib/active_support/whiny_nil.rb +12 -12
  118. data/lib/activesupport.rb +1 -0
  119. metadata +69 -17
  120. data/lib/active_support/binding_of_caller.rb +0 -84
  121. data/lib/active_support/breakpoint.rb +0 -528
  122. data/lib/active_support/caching_tools.rb +0 -62
  123. data/lib/active_support/json/encoders.rb +0 -25
  124. data/lib/active_support/json/encoders/core.rb +0 -70
  125. data/lib/active_support/reloadable.rb +0 -60
  126. data/lib/active_support/vendor/builder/blankslate.rb +0 -63
data/CHANGELOG CHANGED
@@ -1,18 +1,261 @@
1
- *1.4.4* (October 12th, 2007)
1
+ *2.0.0* (December 6th, 2007)
2
2
 
3
- * Backport: allow array and hash query parameters. Array route parameters are converted/to/a/path as before. #6765, #7047, #7462 [bgipsy, Jeremy McAnally, Dan Kubb, brendan, Diego Algorta Casamayou]
3
+ * Added Array#from and Array#to that behaves just from String#from and String#to [DHH]
4
4
 
5
+ * Fix that empty collections should be treated as empty arrays regardless of whitespace for Hash#from_xml #10255 [adamj]
5
6
 
6
- *1.4.3* (October 4th, 2007)
7
+ * Time#time_with_datetime_fallback, Time#to_datetime, Date#to_datetime and String#to_datetime honor Ruby's default calendar reform setting. #10201 [Geoff Buesing]
8
+
9
+ * Change Time and DateTime #end_of_month to return last second of month instead of beginning of last day of month. Closes #10200 [Geoff Buesing]
10
+
11
+ * Speedup String#blank? [Jeremy Kemper, Koz]
12
+
13
+ * Add documentation for Hash#diff. Closes #9306 [tarmo]
14
+
15
+ * Add new superclass_delegating_accessors. Similar to class inheritable attributes but with subtly different semantics. [Koz, tarmo]
16
+
17
+ * Change JSON to encode %w(< > &) as 4 digit hex codes to be in compliance with the JSON spec. Closes #9975 [josh, chuyeow, tpope]
18
+
19
+ * Fix JSON encoding/decoding bugs dealing with /'s. Closes #9990 [Rick, theamazingrando]
20
+
21
+ * Introduce a base class for all test cases used by rails applications. ActiveSupport::TestCase [Koz]
22
+
23
+ The intention is to use this to reduce the amount of monkeypatching / overriding that
24
+ is done to test/unit's classes.
25
+
26
+ * Document Enumerable and Hash #to_json. #9970 [Chu Yeow]
27
+
28
+ * Hash#to_xml handles symbol values. #9954 [Assaf]
29
+
30
+ * Hash#symbolize_keys behaves well with integer keys. #9890 [PotatoSalad]
31
+
32
+ * Multibyte: String#slice supports regexp argument. #9646 [yob]
33
+
34
+ * object.duplicable? returns true if object.dup is safe. False for nil, true, false, symbols, and numbers; true otherwise. #9333 [sur]
35
+
36
+ * Time, Date and DateTime #advance accept :weeks option. #9866 [Geoff Buesing]
37
+
38
+ * Fix Time#years_ago and #years_since from leap days. #9865 [Geoff Buesing]
39
+
40
+ * Time and DateTime#advance accept :hours, :minutes, and :seconds options. #9825 [Geoff Buesing]
41
+
42
+ * Fix Date#years_ago and #years_since from leap days. #9864 [Geoff Buesing]
43
+
44
+ * Refactor Time and Date#months_since and #months_ago to use #advance. #9863 [Geoff Buesing]
45
+
46
+ * Rebundle Builder 2.1.2 but prefer a newer RubyGem if available. [Jeremy Kemper]
47
+
48
+ * Add Range#overlaps?(range), Range#include?(range), and Range#step without a block. [brandon]
49
+
50
+ * Correct BufferedLogger#level? checks. #9806 [wildchild, Johan Sorensen]
51
+
52
+ * String#to_xs uses Eric Wong's fast_xs extension, if available, for Builder speedup. http://bogomips.org/fast_xs/ [Jeremy Kemper]
53
+
54
+ * Introduce BasicObject as Builder::BlankSlate for Ruby 1.9 forward compatibility. [Jeremy Kemper]
55
+
56
+ * Unbundle Builder in favor of a gem dependency. [Jeremy Kemper]
57
+
58
+ * Disambiguate Time, Date, and DateTime#to_json formatting. #9750 [Geoff Buesing, Chu Yeow]
59
+
60
+ * Hash#to_json takes :only or :except options to specific or omit certain hash keys. Enumerable#to_json passes through its options to each element. #9751 [Chu Yeow]
61
+
62
+ * BufferedLogger#auto_flushing = N flushes the log every N messages. Buffers with an array instead of string. Disabling auto_flushing still flushes when the buffer hits a maximum size, as a failsafe against memory-gobbling. [Jeremy Kemper]
63
+
64
+ * Fixed Date#xmlschema for dates outside the range of what can be created with Time #9744 [Geoff Buesing]
65
+
66
+ * Fixed that La Paz was included in -25200 and -14400 offsets when it should only be in -14400 #9735 [bermi]
67
+
68
+ * Fixed JSON encoding to use quoted keys according to the JSON standard #8762 [choonkat/chuyeow]
69
+
70
+ * Alias Object#send to send! for Ruby 1.9 forward compatibility. [Jeremy Kemper]
71
+
72
+ * Backport Object#instance_variable_defined? for Ruby < 1.8.6. [Jeremy Kemper]
73
+
74
+ * BufferedLogger#add converts the message to a string. #9702, #9724 [eigentone, DrMark, tomafro]
75
+
76
+ * Added ActiveSupport::BufferedLogger as a duck-typing alternative (albeit with no formatter) to the Ruby Logger, which provides a very nice speed bump (inspired by Ezra's buffered logger) [DHH]
77
+
78
+ * Object#instance_exec produces fewer garbage methods. [Mauricio Fernandez]
79
+
80
+ * Decode json strings as Dates/Times if they're using a YAML-compatible format. Closes #9614 [Rick]
81
+
82
+ * Fixed cache_page to use the request url instead of the routing options when picking a save path #8614 [josh]
83
+
84
+ * Object.subclasses_of includes anonymous subclasses. [Jeremy Kemper]
85
+
86
+ * Fixed that pluralizing an empty string should return the same empty string, not "s" #7720 [josh]
87
+
88
+ * Added call to inspect on non-string classes for the logger #8533 [codahale]
89
+
90
+ * Deprecation: remove deprecated :mday option from Time, Date, and DateTime#change. [Jeremy Kemper]
91
+
92
+ * Fix JSON decoder with nested quotes and commas. #9579 [zdennis]
93
+
94
+ * Hash#to_xml doesn't double-unescape. #8806 [Ezran]
95
+
96
+ * Added Array#rand #9170 [norbert]. Examples:
97
+
98
+ [].rand # => nil
99
+ ['a'].rand # => 'a'
100
+ [1,2,3].rand # => 1 or 2 or 3
101
+
102
+ * Deprecation: removed Reloadable. [Jeremy Kemper]
103
+
104
+ * Make the utf-handler return the correct value for non-matching regular expressions. Closes #9049 [manfred]
105
+
106
+ * Add ljust, rjust and center to utf8-handler. Closes #9165 [manfred]
107
+
108
+ * Fix Time#advance bug when trying to advance a year from leap day. Closes #8655 [gbuesing]
109
+
110
+ * Add support for []= on ActiveSupport::Multibyte::Chars. Closes #9142. [ewan, manfred]
111
+
112
+ * Added Array#extract_options! to encapsulate the pattern of getting an options hash out of a variable number of parameters #8759 [norbert].
113
+
114
+ * Let alias_attribute work with attributes with initial capital letters (legacy columns etc). Closes #8596 [mpalmer]
115
+
116
+ * Added Hash#except which is the inverse of Hash#slice -- return the hash except the keys that are specified [DHH]
117
+
118
+ * Added support for pluralization with a different starting letter than the singular version (cow/kine) #4929 [norri_b/hasmanyjosh]
7
119
 
8
120
  * Demote Hash#to_xml to use XmlSimple#xml_in_string so it can't read files or stdin. #8453 [candlerb, Jeremy Kemper]
9
121
 
122
+ * Backport clean_logger changes to support ruby 1.8.2 [mislav]
123
+
124
+ * Added proper handling of arrays #8537 [hasmanyjosh]
125
+
126
+ Before:
127
+ Hash.from_xml '<images></images>'
128
+ # => {:images => nil}
129
+
130
+ Hash.from_xml '<images><image>foo.jpg</image></images>'
131
+ # => {:images => {:image => "foo.jpg"}}
132
+
133
+ Hash.from_xml '<images><image>foo.jpg</image><image>bar.jpg</image></images>'
134
+ # => {:images => {:image => ["foo.jpg", "bar.jpg"]}}
135
+
136
+ After:
137
+ Hash.from_xml '<images type="array"></images>'
138
+ # => {:images => []}
139
+
140
+ Hash.from_xml '<images type="array"><image>foo.jpg</image></images>'
141
+ # => {:images => ["foo.jpg"]}
142
+
143
+ Hash.from_xml '<images type="array"><image>foo.jpg</image><image>bar.jpg</image></images>'
144
+ # => {:images => ["foo.jpg", "bar.jpg"]}
145
+
146
+ * Improve Time and Date test coverage. #8646 [Josh Peek]
147
+
148
+ * Add Date#since, ago, beginning_of_day, and end_of_day. Date + seconds works now. #8575 [Geoff Buesing]
149
+
150
+ * String#to_time overflows to DateTime. Add String#to_datetime. #8572 [Geoff Buesing]
151
+
152
+ * Date.yesterday and .tomorrow. #8571 [Geoff Buesing]
153
+
154
+ * Readable Date and DateTime#inspect. #8570 [Geoff Buesing]
155
+
156
+ * Move common DateTime calculations to Date. #8536 [Geoff Buesing]
157
+
158
+ * Added Date#change (like Time#change) [DHH]
159
+
160
+ * DateTime#to_time converts to Time unless out of range. #8512 [Geoff Buesing]
161
+
162
+ * Date#to_datetime, #to_s(:rfc822). #8512 [Geoff Buesing]
163
+
164
+ * Time durations use since instead of + for accuracy. #8513 [Geoff Buesing]
165
+
166
+ * escape <'s and >'s in JSON strings. #8371 [Rick]
167
+
168
+ * Inflections: MatrixTest -> MatrixTests instead of MatricesTest. #8496 [jbwiv]
169
+
170
+ * Multibyte strings respond_to the String methods they proxy so they can be duck-typed. #6549 [Tuxie]
171
+
172
+ * Array#to_xml yields the builder just like Hash and ActiveRecord::Base. #8472 [seth]
173
+
174
+ * Date, Time, and DateTime support formatting blocks in addition to strftime strings. Introduce :long_ordinal format, e.g. "February 21st, 2005". #8191 [Coda Hale]
175
+
10
176
  * Document Object#blank?. #6491 [Chris Mear]
11
177
 
12
- * Update Dependencies to ignore constants inherited from ancestors. Closes #6951. [Nicholas Seckar]
178
+ * Date, Time, and DateTime#to_json. #8399 [wycats]
179
+
180
+ * Simplify API of assert_difference by passing in an expression that is evaluated before and after the passed in block. See documenation for examples of new API. [Marcel Molina Jr.]
181
+
182
+ * Added assert_difference and assert_no_difference to test/unit assertions [Tobias Luetke]
183
+
184
+ * Removed breakpointer and Binding.of_caller in favor of relying on ruby-debug by Kent Sibilev since the breakpointer has been broken since Ruby 1.8.4 and will not be coming back [DHH]
185
+
186
+ * Added parsing of file type in Hash.xml_in so you can easily do file uploads with base64 from an API [DHH]
187
+
188
+ <person>
189
+ <name>David</name>
190
+ <avatar type="file" name="me.jpg" content_type="image/jpg">R0lGODlhkACZAPUAAM5lcfjrtMQCG=\n</avatar>
191
+ </person>
192
+
193
+ ...becomes:
194
+
195
+ attributes = { :person => { :name => "David", :avatar => #<StringIO> } }
196
+ attributes[:person][:avatar].content_type # => "image/jpg"
197
+ attributes[:person][:avatar].original_filename # => "me.jpg"
198
+ attributes[:person][:avatar].read # => binary data of the file
199
+
200
+ Which is duck-type compatible with the files that you get when doing multipart uploads through HTML.
13
201
 
14
202
  * Improved multibyte performance by relying less on exception raising #8159 [Blaine]
15
203
 
204
+ * Use XSD-compatible type names for Hash#to_xml and make the converters extendable #8047 [Tim Pope]
205
+
206
+ * Added yielding of builder in Hash#to_xml [DHH]
207
+
208
+ * Hash#with_indifferent_access now also converts hashes kept in arrays to indifferent access (makes it easier to treat HTML and XML parameters the same) [DHH]
209
+
210
+ * Hash#to_xml supports YAML attributes. #7502 [jonathan]
211
+
212
+ * Refactor ActiveSupport::JSON to be less obtuse. Add support for JSON decoding by way of Syck with ActiveSupport::JSON.decode(json_string). Prevent hash keys that are JavaScript reserved words from being unquoted during encoding. [Sam Stephenson]
213
+
214
+ * alias_method_chain preserves the original method's visibility. #7854 [Jonathan Viney]
215
+
216
+ * Update Dependencies to ignore constants inherited from ancestors. Closes #6951. [Nicholas Seckar]
217
+
218
+ * Array#to_query preserves its ordering. #7756 [Greg Spurrier]
219
+
220
+ * Out-of-range Time calculations transparently overflow to DateTime. Introduce Time#to_datetime. #7706, #7715 [Geoff Buesing]
221
+
222
+ * DateTime calculations analogous to the Date and Time extensions. #7693 [Geoff Buesing]
223
+
224
+ * Give DateTime correct .to_s implementations, lets it play nice with ActiveRecord quoting. #7649 [Geoff Buesing]
225
+
226
+ * Add File.atomic_write, allows you to write large files in an atomic manner, preventing users from seeing half written files. [Koz]
227
+
228
+ * Allow users to provide custom formatters to Logger. [aeden]
229
+
230
+ * Hash#to_query CGI-escapes its keys. [Jeremy Kemper]
231
+
232
+ * Optimize Class Inheritable Attributes so that unnecessary hashes are not created. Closes #7472 [Bruce Perens]
233
+
234
+ * :db format for Date#to_s [Jeremy Kemper]
235
+ Date.new(2007, 1, 27).to_s(:db) # => '2007-01-27'
236
+
237
+ * Added :instance_writer option to #mattr_writer/accessor, #cattr_writer/accessor, and #class_inheritable_writer to skip the creation of the instance writer. [Rick]
238
+
239
+ * Added Hash#to_query to turn a hash of values into a form-encoded query string [Nicholas Seckar]
240
+
241
+ * Increase test coverage for subclasses_of. Closes #7335. [Roman2K, Nicholas Seckar]
242
+
243
+ * Remove unused code from Duration#inspect. Closes #7180. [Rich Collins]
244
+
245
+ * Added test coverage for Inflector.inflections.clear. Closes #7179. [Rich Collins]
246
+
247
+ * ActiveSupport::Multibyte::Handlers::UTF8Handler should raise when a range and an integer are passed in (just like the native implementation). Closes #7176 [Rich Collins]
248
+
249
+ * A couple extra tests for #classify. Closes #7273. [Josh Susser]
250
+
251
+ * Better docs for Object extensions [zackchandler, Jamis Buck]
252
+
253
+ * Fix that Dates couldn't be subtracted from Dates after [5940]. [Sam Stephenson]
254
+
255
+ * Add Object#acts_like? and Time#acts_like_time? and Date#acts_like_date? to facilitate duck-typing. [Jamis Buck]
256
+
257
+ * Make 1.months and friends accurate by introducing a Duration class. #6835 [eventualbuddha]
258
+
16
259
 
17
260
  *1.4.2* (March 12th, 2007)
18
261
 
@@ -43,12 +286,22 @@ public for compatibility. [Jeremy Kemper]
43
286
 
44
287
  * Deprecation: silence warnings when reporting test errors. [Jeremy Kemper]
45
288
 
289
+ * Hash#slice(*keys) returns a new hash with only the given keys. #slice! replaces the hash with only the given keys. Works with HashWithIndifferentAccess also. [Jeremy Kemper]
290
+
291
+ * HashWithIndifferentAccess#to_hash converts to a Hash with String keys and the same default value. [Jeremy Kemper]
292
+
46
293
  * Fix remove_constant to correctly handle constant names of the form "::A::...". References #6720. [Nicholas Seckar]
47
294
 
48
295
  * Fixed Array#to_xml when it contains a series of hashes (each piece would get its own XML declaration) #6610 [thkarcher/cyu]
49
296
 
297
+ * Added Time#to_s(:time) which will just return H:M, like 17:44 [DHH]
298
+
299
+ * Add Module#attr_accessor_with_default to initialize value of attribute before setting it. Closes #6538. [Stuart Halloway, Marcel Molina Jr.]
300
+
50
301
  * Hash#to_xml handles keys with the same name as Kernel methods. #6613 [Catfish]
51
302
 
303
+ * Added Time#end_of_day to get 23:59:59 of that day [DHH]
304
+
52
305
  * Don't quote hash keys in Hash#to_json if they're valid JavaScript identifiers. Disable this with ActiveSupport::JSON.unquote_hash_key_identifiers = false if you need strict JSON compliance. [Sam Stephenson]
53
306
 
54
307
  * Lazily load the Unicode Database in the UTF-8 Handler [Rick Olson]
@@ -57,7 +310,7 @@ public for compatibility. [Jeremy Kemper]
57
310
 
58
311
  * Fix unicode JSON regexp for Onigurama compatibility. #6494 [whitley]
59
312
 
60
- * Update XmlSimple to 1.0.10. Closes #6532. [nicksieger]
313
+ * update XmlSimple to 1.0.10. Closes #6532. [nicksieger]
61
314
 
62
315
  * Update dependencies to allow constants to be defined alongside their siblings. A common case for this is AR model classes with STI; user.rb might define User, Administrator and Guest for example. [Nicholas Seckar]
63
316
 
@@ -73,7 +326,7 @@ public for compatibility. [Jeremy Kemper]
73
326
 
74
327
  * Make String#chars slicing behaviour consistent with String. Closes #6387 [Manfred Stienstra]
75
328
 
76
- * Pull in latest multibye patch. Closes #6346 [Manfred Stienstra]
329
+ * Pull in latest multibyte patch. Closes #6346 [Manfred Stienstra]
77
330
 
78
331
  * Add ActiveSupport::Multibyte. Provides String#chars which lets you deal with strings as a sequence of chars, not of bytes. Closes #6242 [Julian Tarkhanov, Manfred Stienstra, Thijs van der Vossen & Jan Behrens]
79
332
 
@@ -93,6 +346,8 @@ public for compatibility. [Jeremy Kemper]
93
346
 
94
347
  * Equate Kernel.const_missing with Object.const_missing. Fixes #5988. [Nicholas Seckar]
95
348
 
349
+ * Add ApplicationController special case to Dependencies. [Nicholas Seckar]
350
+
96
351
  * Don't pad remaining places with in_groups_of if specified padding value is false. [Marcel Molina Jr.]
97
352
 
98
353
  * Fix cases where empty xml nodes weren't being translated to nil in Hash.create_from_xml [Rick Olso n]
@@ -137,6 +392,8 @@ public for compatibility. [Jeremy Kemper]
137
392
 
138
393
  * Add extention to obtain the missing constant from NameError instances. [Nicholas Seckar]
139
394
 
395
+ * Thoroughly document inflections. #5700 [petermichaux@gmail.com]
396
+
140
397
  * Added Module#alias_attribute [Jamis/DHH]. Example:
141
398
 
142
399
  class Content < ActiveRecord::Base
@@ -260,7 +517,6 @@ public for compatibility. [Jeremy Kemper]
260
517
 
261
518
  * Add Array#split for dividing arrays into one or more subarrays by value or block. [Sam Stephenson]
262
519
 
263
-
264
520
  *1.3.1* (April 6th, 2006)
265
521
 
266
522
  * Clean paths inside of exception messages and traces. [Nicholas Seckar]
@@ -22,23 +22,28 @@
22
22
  #++
23
23
 
24
24
  $:.unshift(File.dirname(__FILE__))
25
- $:.unshift(File.dirname(__FILE__) + "/active_support/vendor")
26
-
27
- require 'builder'
28
25
 
26
+ require 'active_support/vendor'
27
+ require 'active_support/basic_object'
29
28
  require 'active_support/inflector'
30
29
 
31
30
  require 'active_support/core_ext'
31
+
32
32
  require 'active_support/clean_logger'
33
+ require 'active_support/buffered_logger'
34
+
33
35
  require 'active_support/dependencies'
34
- require 'active_support/reloadable'
35
36
  require 'active_support/deprecation'
36
37
 
37
38
  require 'active_support/ordered_options'
38
39
  require 'active_support/option_merger'
39
40
 
40
41
  require 'active_support/values/time_zone'
42
+ require 'active_support/duration'
41
43
 
42
44
  require 'active_support/json'
43
45
 
44
46
  require 'active_support/multibyte'
47
+
48
+ require 'active_support/testing'
49
+
@@ -0,0 +1,5 @@
1
+ # Ruby 1.9 introduces BasicObject. Use Builder's BlankSlate until then.
2
+ unless defined? BasicObject
3
+ require 'blankslate'
4
+ BasicObject = BlankSlate
5
+ end
@@ -0,0 +1,107 @@
1
+ module ActiveSupport
2
+ # Inspired by the buffered logger idea by Ezra
3
+ class BufferedLogger
4
+ module Severity
5
+ DEBUG = 0
6
+ INFO = 1
7
+ WARN = 2
8
+ ERROR = 3
9
+ FATAL = 4
10
+ UNKNOWN = 5
11
+ end
12
+ include Severity
13
+
14
+ MAX_BUFFER_SIZE = 1000
15
+
16
+ # Set to false to disable the silencer
17
+ cattr_accessor :silencer
18
+ self.silencer = true
19
+
20
+ # Silences the logger for the duration of the block.
21
+ def silence(temporary_level = ERROR)
22
+ if silencer
23
+ begin
24
+ old_logger_level, self.level = level, temporary_level
25
+ yield self
26
+ ensure
27
+ self.level = old_logger_level
28
+ end
29
+ else
30
+ yield self
31
+ end
32
+ end
33
+
34
+ attr_accessor :level
35
+ attr_reader :auto_flushing
36
+ attr_reader :buffer
37
+
38
+ def initialize(log, level = DEBUG)
39
+ @level = level
40
+ @buffer = []
41
+ @auto_flushing = 1
42
+
43
+ if log.respond_to?(:write)
44
+ @log = log
45
+ elsif File.exist?(log)
46
+ @log = open(log, (File::WRONLY | File::APPEND))
47
+ @log.sync = true
48
+ else
49
+ @log = open(log, (File::WRONLY | File::APPEND | File::CREAT))
50
+ @log.sync = true
51
+ @log.write("# Logfile created on %s" % [Time.now.to_s])
52
+ end
53
+ end
54
+
55
+ def add(severity, message = nil, progname = nil, &block)
56
+ return if @level > severity
57
+ message = (message || (block && block.call) || progname).to_s
58
+ # If a newline is necessary then create a new message ending with a newline.
59
+ # Ensures that the original message is not mutated.
60
+ message = "#{message}\n" unless message[-1] == ?\n
61
+ @buffer << message
62
+ auto_flush
63
+ message
64
+ end
65
+
66
+ for severity in Severity.constants
67
+ class_eval <<-EOT, __FILE__, __LINE__
68
+ def #{severity.downcase}(message = nil, progname = nil, &block)
69
+ add(#{severity}, message, progname, &block)
70
+ end
71
+
72
+ def #{severity.downcase}?
73
+ #{severity} >= @level
74
+ end
75
+ EOT
76
+ end
77
+
78
+ # Set the auto-flush period. Set to true to flush after every log message,
79
+ # to an integer to flush every N messages, or to false, nil, or zero to
80
+ # never auto-flush. If you turn auto-flushing off, be sure to regularly
81
+ # flush the log yourself -- it will eat up memory until you do.
82
+ def auto_flushing=(period)
83
+ @auto_flushing =
84
+ case period
85
+ when true; 1
86
+ when false, nil, 0; MAX_BUFFER_SIZE
87
+ when Integer; period
88
+ else raise ArgumentError, "Unrecognized auto_flushing period: #{period.inspect}"
89
+ end
90
+ end
91
+
92
+ def flush
93
+ @log.write(@buffer.slice!(0..-1).to_s) unless @buffer.empty?
94
+ end
95
+
96
+ def close
97
+ flush
98
+ @log.close if @log.respond_to?(:close)
99
+ @log = nil
100
+ end
101
+
102
+ protected
103
+ def auto_flush
104
+ flush if @buffer.size >= @auto_flushing
105
+ end
106
+ end
107
+ end