rubyless 0.8.3 → 0.8.4

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,4 +1,9 @@
1
- == 0.8.3
1
+ == 0.8.4 2011-06-15
2
+
3
+ * Minor enhancements
4
+ * Fixed: should clear cache on safe_method declaration.
5
+
6
+ == 0.8.3 2011-06-15
2
7
 
3
8
  * Major enhancements
4
9
  * Better support for literal Arrays.
data/README.rdoc CHANGED
@@ -65,6 +65,12 @@ You can look at the tests for an idea of how to declare things. If you have more
65
65
 
66
66
  http://zenadmin.org/community
67
67
 
68
+ == WARNING:
69
+
70
+ Changing the safe methods during runtime removes the cache for all classes and
71
+ should therefore be avoided in favor of dynamic "safe_method_type" methods for the
72
+ objects/classes concerned.
73
+
68
74
  == REQUIREMENTS:
69
75
 
70
76
  * parse_tree
@@ -1,3 +1,3 @@
1
1
  module RubyLess
2
- VERSION = '0.8.3'
2
+ VERSION = '0.8.4'
3
3
  end
@@ -6,7 +6,6 @@ module RubyLess
6
6
 
7
7
  # List of safe methods for a specific class.
8
8
  def self.safe_methods_for(klass)
9
- # Caching safe_methods_all is bad when modules are dynamically added / removed.
10
9
  @@_safe_methods_parsed[klass] ||= build_safe_methods_list(klass)
11
10
  end
12
11
 
@@ -58,6 +57,9 @@ module RubyLess
58
57
 
59
58
  # Declare a safe method for a given class ( same as #safe_method)
60
59
  def self.safe_method_for(klass, methods_hash)
60
+ # This is why defining new safe methods during runtime is BAD.
61
+ @@_safe_methods_parsed = {} # rebuild all cache
62
+
61
63
  defaults = methods_hash.delete(:defaults) || {}
62
64
 
63
65
  list = (@@_safe_methods[klass] ||= {})
@@ -243,16 +245,20 @@ module RubyLess
243
245
  def self.build_safe_methods_list(klass)
244
246
  list = SignatureHash.new
245
247
  (@@_safe_methods[klass] || {}).map do |signature, return_value|
246
- if return_value.kind_of?(Hash)
247
- return_value[:class] = parse_class(return_value[:class])
248
- elsif return_value.kind_of?(Proc) || return_value.kind_of?(Symbol)
249
- # keep
248
+ if return_value.frozen?
249
+ # Already parsed, skip
250
250
  else
251
- return_value = {:class => return_value}
251
+ if return_value.kind_of?(Hash)
252
+ return_value[:class] = parse_class(return_value[:class])
253
+ elsif return_value.kind_of?(Proc) || return_value.kind_of?(Symbol)
254
+ # keep
255
+ else
256
+ return_value = {:class => return_value}
257
+ end
258
+ return_value.freeze
252
259
  end
253
- method = signature.shift
254
- signature = [method] + signature.map {|e| parse_class(e)}
255
- list[signature] = return_value.freeze
260
+ signature = [signature.first] + signature[1..-1].map {|e| parse_class(e)}
261
+ list[signature] = return_value
256
262
  end
257
263
  list
258
264
  end
data/rubyless.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{rubyless}
8
- s.version = "0.8.3"
8
+ s.version = "0.8.4"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Gaspard Bucher"]
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubyless
3
3
  version: !ruby/object:Gem::Version
4
- hash: 57
4
+ hash: 55
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 8
9
- - 3
10
- version: 0.8.3
9
+ - 4
10
+ version: 0.8.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Gaspard Bucher