activesupport 1.4.0 → 1.4.1

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.

data/CHANGELOG CHANGED
@@ -1,3 +1,12 @@
1
+ *1.4.1* (February 5th, 2007)
2
+
3
+ * Optimize Class Inheritable Attributes so that unnecessary hashes are not created. [Bruce Perens]
4
+
5
+ * Added :instance_writer option to #mattr_writer/accessor, #cattr_writer/accessor, and #class_inheritable_writer to skip the creation of the instance writer. [Rick]
6
+
7
+ * Full test coverage for Inflector. #7228 [Dan Kubb]
8
+
9
+
1
10
  *1.4.0* (January 16th, 2007)
2
11
 
3
12
  * Document Inflector.ordinalize and merge docs from String inflections. #7023 [smeade]
@@ -3,6 +3,7 @@
3
3
  class Class # :nodoc:
4
4
  def cattr_reader(*syms)
5
5
  syms.flatten.each do |sym|
6
+ next if sym.is_a?(Hash)
6
7
  class_eval(<<-EOS, __FILE__, __LINE__)
7
8
  unless defined? @@#{sym}
8
9
  @@#{sym} = nil
@@ -20,6 +21,7 @@ class Class # :nodoc:
20
21
  end
21
22
 
22
23
  def cattr_writer(*syms)
24
+ options = syms.last.is_a?(Hash) ? syms.pop : {}
23
25
  syms.flatten.each do |sym|
24
26
  class_eval(<<-EOS, __FILE__, __LINE__)
25
27
  unless defined? @@#{sym}
@@ -30,9 +32,11 @@ class Class # :nodoc:
30
32
  @@#{sym} = obj
31
33
  end
32
34
 
35
+ #{"
33
36
  def #{sym}=(obj)
34
37
  @@#{sym} = obj
35
38
  end
39
+ " unless options[:instance_writer] == false }
36
40
  EOS
37
41
  end
38
42
  end
@@ -9,6 +9,7 @@ end
9
9
  class Class # :nodoc:
10
10
  def class_inheritable_reader(*syms)
11
11
  syms.each do |sym|
12
+ next if sym.is_a?(Hash)
12
13
  class_eval <<-EOS
13
14
  def self.#{sym}
14
15
  read_inheritable_attribute(:#{sym})
@@ -22,43 +23,52 @@ class Class # :nodoc:
22
23
  end
23
24
 
24
25
  def class_inheritable_writer(*syms)
26
+ options = syms.last.is_a?(Hash) ? syms.pop : {}
25
27
  syms.each do |sym|
26
28
  class_eval <<-EOS
27
29
  def self.#{sym}=(obj)
28
30
  write_inheritable_attribute(:#{sym}, obj)
29
31
  end
30
32
 
33
+ #{"
31
34
  def #{sym}=(obj)
32
35
  self.class.#{sym} = obj
33
36
  end
37
+ " unless options[:instance_writer] == false }
34
38
  EOS
35
39
  end
36
40
  end
37
41
 
38
42
  def class_inheritable_array_writer(*syms)
43
+ options = syms.last.is_a?(Hash) ? syms.pop : {}
39
44
  syms.each do |sym|
40
45
  class_eval <<-EOS
41
46
  def self.#{sym}=(obj)
42
47
  write_inheritable_array(:#{sym}, obj)
43
48
  end
44
49
 
50
+ #{"
45
51
  def #{sym}=(obj)
46
52
  self.class.#{sym} = obj
47
53
  end
54
+ " unless options[:instance_writer] == false }
48
55
  EOS
49
56
  end
50
57
  end
51
58
 
52
59
  def class_inheritable_hash_writer(*syms)
60
+ options = syms.last.is_a?(Hash) ? syms.pop : {}
53
61
  syms.each do |sym|
54
62
  class_eval <<-EOS
55
63
  def self.#{sym}=(obj)
56
64
  write_inheritable_hash(:#{sym}, obj)
57
65
  end
58
66
 
67
+ #{"
59
68
  def #{sym}=(obj)
60
69
  self.class.#{sym} = obj
61
70
  end
71
+ " unless options[:instance_writer] == false }
62
72
  EOS
63
73
  end
64
74
  end
@@ -79,10 +89,13 @@ class Class # :nodoc:
79
89
  end
80
90
 
81
91
  def inheritable_attributes
82
- @inheritable_attributes ||= {}
92
+ @inheritable_attributes ||= EMPTY_INHERITABLE_ATTRIBUTES
83
93
  end
84
94
 
85
95
  def write_inheritable_attribute(key, value)
96
+ if inheritable_attributes.equal?(EMPTY_INHERITABLE_ATTRIBUTES)
97
+ @inheritable_attributes = {}
98
+ end
86
99
  inheritable_attributes[key] = value
87
100
  end
88
101
 
@@ -101,15 +114,22 @@ class Class # :nodoc:
101
114
  end
102
115
 
103
116
  def reset_inheritable_attributes
104
- inheritable_attributes.clear
117
+ @inheritable_attributes = EMPTY_INHERITABLE_ATTRIBUTES
105
118
  end
106
119
 
107
- private
120
+ private
121
+ # Prevent this constant from being created multiple times
122
+ EMPTY_INHERITABLE_ATTRIBUTES = {}.freeze unless const_defined?(:EMPTY_INHERITABLE_ATTRIBUTES)
123
+
108
124
  def inherited_with_inheritable_attributes(child)
109
125
  inherited_without_inheritable_attributes(child) if respond_to?(:inherited_without_inheritable_attributes)
110
126
 
111
- new_inheritable_attributes = inheritable_attributes.inject({}) do |memo, (key, value)|
112
- memo.update(key => (value.dup rescue value))
127
+ if inheritable_attributes.equal?(EMPTY_INHERITABLE_ATTRIBUTES)
128
+ new_inheritable_attributes = EMPTY_INHERITABLE_ATTRIBUTES
129
+ else
130
+ new_inheritable_attributes = inheritable_attributes.inject({}) do |memo, (key, value)|
131
+ memo.update(key => (value.dup rescue value))
132
+ end
113
133
  end
114
134
 
115
135
  child.instance_variable_set('@inheritable_attributes', new_inheritable_attributes)
@@ -3,6 +3,7 @@
3
3
  class Module # :nodoc:
4
4
  def mattr_reader(*syms)
5
5
  syms.each do |sym|
6
+ next if sym.is_a?(Hash)
6
7
  class_eval(<<-EOS, __FILE__, __LINE__)
7
8
  unless defined? @@#{sym}
8
9
  @@#{sym} = nil
@@ -20,6 +21,7 @@ class Module # :nodoc:
20
21
  end
21
22
 
22
23
  def mattr_writer(*syms)
24
+ options = syms.last.is_a?(Hash) ? syms.pop : {}
23
25
  syms.each do |sym|
24
26
  class_eval(<<-EOS, __FILE__, __LINE__)
25
27
  unless defined? @@#{sym}
@@ -29,10 +31,12 @@ class Module # :nodoc:
29
31
  def self.#{sym}=(obj)
30
32
  @@#{sym} = obj
31
33
  end
32
-
34
+
35
+ #{"
33
36
  def #{sym}=(obj)
34
37
  @@#{sym} = obj
35
38
  end
39
+ " unless options[:instance_writer] == false }
36
40
  EOS
37
41
  end
38
42
  end
@@ -1,7 +1,5 @@
1
-
2
1
  # Add a +missing_name+ method to NameError instances.
3
- class NameError < StandardError
4
-
2
+ class NameError < StandardError #:nodoc:
5
3
  # Add a method to obtain the missing name from a NameError.
6
4
  def missing_name
7
5
  $1 if /((::)?([A-Z]\w*)(::[A-Z]\w*)*)$/ =~ message
@@ -16,5 +14,4 @@ class NameError < StandardError
16
14
  missing_name == name.to_s
17
15
  end
18
16
  end
19
-
20
17
  end
@@ -47,7 +47,6 @@ module Dependencies #:nodoc:
47
47
  mattr_accessor :log_activity
48
48
  self.log_activity = false
49
49
 
50
- # :nodoc:
51
50
  # An internal stack used to record which constants are loaded by any block.
52
51
  mattr_accessor :constant_watch_stack
53
52
  self.constant_watch_stack = []
@@ -382,7 +381,7 @@ module Dependencies #:nodoc:
382
381
  end
383
382
  end
384
383
 
385
- class LoadingModule
384
+ class LoadingModule #:nodoc:
386
385
  # Old style environment.rb referenced this method directly. Please note, it doesn't
387
386
  # actualy *do* anything any more.
388
387
  def self.root(*args)
@@ -1,7 +1,7 @@
1
1
  require 'yaml'
2
2
 
3
3
  module ActiveSupport
4
- module Deprecation
4
+ module Deprecation #:nodoc:
5
5
  mattr_accessor :debug
6
6
  self.debug = false
7
7
 
@@ -81,7 +81,7 @@ module ActiveSupport
81
81
  # Warnings are not silenced by default.
82
82
  self.silenced = false
83
83
 
84
- module ClassMethods
84
+ module ClassMethods #:nodoc:
85
85
  # Declare that a method has been deprecated.
86
86
  def deprecate(*method_names)
87
87
  options = method_names.last.is_a?(Hash) ? method_names.pop : {}
@@ -112,7 +112,7 @@ module ActiveSupport
112
112
  end
113
113
  end
114
114
 
115
- module Assertions
115
+ module Assertions #:nodoc:
116
116
  def assert_deprecated(match = nil, &block)
117
117
  result, warnings = collect_deprecations(&block)
118
118
  assert !warnings.empty?, "Expected a deprecation warning within the block but received none"
@@ -145,7 +145,7 @@ module ActiveSupport
145
145
 
146
146
  # Stand-in for @request, @attributes, @params, etc which emits deprecation
147
147
  # warnings on any method call (except #inspect).
148
- class DeprecatedInstanceVariableProxy
148
+ class DeprecatedInstanceVariableProxy #:nodoc:
149
149
  instance_methods.each { |m| undef_method m unless m =~ /^__/ }
150
150
 
151
151
  def initialize(instance, method, var = "@#{method}")
@@ -243,12 +243,11 @@ module Inflector
243
243
  # "Module".constantize #=> Module
244
244
  # "Class".constantize #=> Class
245
245
  def constantize(camel_cased_word)
246
- unless /^(::)?([A-Z]\w*)(::[A-Z]\w*)*$/ =~ camel_cased_word
246
+ unless /\A(?:::)?([A-Z]\w*(?:::[A-Z]\w*)*)\z/ =~ camel_cased_word
247
247
  raise NameError, "#{camel_cased_word.inspect} is not a valid constant name!"
248
248
  end
249
249
 
250
- camel_cased_word = "::#{camel_cased_word}" unless $1
251
- Object.module_eval(camel_cased_word, __FILE__, __LINE__)
250
+ Object.module_eval("::#{$1}", __FILE__, __LINE__)
252
251
  end
253
252
 
254
253
  # Ordinalize turns a number into an ordinal string used to denote the
@@ -1,4 +1,4 @@
1
- module ActiveSupport::Multibyte
1
+ module ActiveSupport::Multibyte #:nodoc:
2
2
  DEFAULT_NORMALIZATION_FORM = :kc
3
3
  NORMALIZATIONS_FORMS = [:c, :kc, :d, :kd]
4
4
  UNICODE_VERSION = '5.0.0'
@@ -2,7 +2,7 @@ require 'active_support/multibyte/handlers/utf8_handler'
2
2
  require 'active_support/multibyte/handlers/passthru_handler'
3
3
 
4
4
  # Encapsulates all the functionality related to the Chars proxy.
5
- module ActiveSupport::Multibyte
5
+ module ActiveSupport::Multibyte #:nodoc:
6
6
  # Chars enables you to work transparently with multibyte encodings in the Ruby String class without having extensive
7
7
  # knowledge about the encoding. A Chars object accepts a string upon initialization and proxies String methods in an
8
8
  # encoding safe manner. All the normal String methods are also implemented on the proxy.
@@ -1,6 +1,6 @@
1
1
  # Chars uses this handler when $KCODE is not set to 'UTF8'. Because this handler doesn't define any methods all call
2
2
  # will be forwarded to String.
3
- class ActiveSupport::Multibyte::Handlers::PassthruHandler
3
+ class ActiveSupport::Multibyte::Handlers::PassthruHandler #:nodoc:
4
4
 
5
5
  # Return the original byteoffset
6
6
  def self.translate_offset(string, byte_offset) #:nodoc:
@@ -1,6 +1,7 @@
1
1
  # Contains all the handlers and helper classes
2
- module ActiveSupport::Multibyte::Handlers
3
- class EncodingError < ArgumentError; end
2
+ module ActiveSupport::Multibyte::Handlers #:nodoc:
3
+ class EncodingError < ArgumentError #:nodoc:
4
+ end
4
5
 
5
6
  class Codepoint #:nodoc:
6
7
  attr_accessor :code, :combining_class, :decomp_type, :decomp_mapping, :uppercase_mapping, :lowercase_mapping
@@ -1,8 +1,7 @@
1
1
  # Methods in this handler call functions in the utf8proc ruby extension. These are significantly faster than the
2
2
  # pure ruby versions. Chars automatically uses this handler when it can load the utf8proc extension. For
3
3
  # documentation on handler methods see UTF8Handler.
4
- class ActiveSupport::Multibyte::Handlers::UTF8HandlerProc < ActiveSupport::Multibyte::Handlers::UTF8Handler
5
-
4
+ class ActiveSupport::Multibyte::Handlers::UTF8HandlerProc < ActiveSupport::Multibyte::Handlers::UTF8Handler #:nodoc:
6
5
  class << self
7
6
  def normalize(str, form=ActiveSupport::Multibyte::DEFAULT_NORMALIZATION_FORM) #:nodoc:
8
7
  codepoints = str.unpack('U*')
@@ -4,9 +4,8 @@ require 'active_support/deprecation'
4
4
  #
5
5
  # Deprecated as of Rails 1.2.
6
6
  # All autoloaded objects are now unloaded.
7
- module Reloadable
8
- class << self
9
-
7
+ module Reloadable #:nodoc:
8
+ class << self
10
9
  def included(base) #nodoc:
11
10
  unless base.ancestors.include?(Reloadable::Subclasses) # Avoid double warning
12
11
  ActiveSupport::Deprecation.warn "Reloadable has been deprecated and has no effect.", caller
@@ -37,7 +36,7 @@ module Reloadable
37
36
  #
38
37
  # Deprecated as of Rails 1.2.
39
38
  # All autoloaded objects are now unloaded.
40
- module Subclasses
39
+ module Subclasses #:nodoc:
41
40
  def self.included(base) #nodoc:
42
41
  base.send :include, Reloadable
43
42
  ActiveSupport::Deprecation.warn "Reloadable::Subclasses has been deprecated and has no effect.", caller
@@ -48,8 +47,7 @@ module Reloadable
48
47
  end
49
48
  end
50
49
 
51
- module Deprecated
52
-
50
+ module Deprecated #:nodoc:
53
51
  def self.included(base)
54
52
  class << base
55
53
  define_method(:reloadable?) do
@@ -58,7 +56,5 @@ module Reloadable
58
56
  end
59
57
  end
60
58
  end
61
-
62
59
  end
63
-
64
60
  end
@@ -15,7 +15,7 @@ class XmlSimple
15
15
 
16
16
  # A simple cache for XML documents that were already transformed
17
17
  # by xml_in.
18
- class Cache
18
+ class Cache #:nodoc:
19
19
  # Creates and initializes a new Cache object.
20
20
  def initialize
21
21
  @mem_share_cache = {}
@@ -2,7 +2,7 @@ module ActiveSupport
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 1
4
4
  MINOR = 4
5
- TINY = 0
5
+ TINY = 1
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.0
3
3
  specification_version: 1
4
4
  name: activesupport
5
5
  version: !ruby/object:Gem::Version
6
- version: 1.4.0
7
- date: 2007-01-17 00:00:00 -06:00
6
+ version: 1.4.1
7
+ date: 2007-02-05 00:00:00 -06:00
8
8
  summary: Support and utility classes used by the Rails framework.
9
9
  require_paths:
10
10
  - lib