characterizable 0.0.14 → 0.0.15

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.14
1
+ 0.0.15
@@ -1,63 +1,63 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in rakefile, and run the gemspec command
4
- # -*- encoding: utf-8 -*-
5
-
6
- Gem::Specification.new do |s|
7
- s.name = %q{characterizable}
8
- s.version = "0.0.14"
9
-
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Andy Rossmeissl", "Seamus Abshere"]
12
- s.date = %q{2010-08-13}
13
- s.description = %q{Characterize the relationship between "attributes" (getters/setters) of instances of a class}
14
- s.email = %q{seamus@abshere.net}
15
- s.extra_rdoc_files = [
16
- "LICENSE",
17
- "README.rdoc"
18
- ]
19
- s.files = [
20
- ".document",
21
- ".gitignore",
22
- "LICENSE",
23
- "README.rdoc",
24
- "Rakefile",
25
- "VERSION",
26
- "characterizable.gemspec",
27
- "lib/characterizable.rb",
28
- "test/helper.rb",
29
- "test/test_characterizable.rb"
30
- ]
31
- s.homepage = %q{http://github.com/seamusabshere/characterizable}
32
- s.rdoc_options = ["--charset=UTF-8"]
33
- s.require_paths = ["lib"]
34
- s.rubygems_version = %q{1.3.6}
35
- s.summary = %q{Characterize instances of a class}
36
- s.test_files = [
37
- "test/helper.rb",
38
- "test/test_characterizable.rb"
39
- ]
40
-
41
- if s.respond_to? :specification_version then
42
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
43
- s.specification_version = 3
44
-
45
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
46
- s.add_runtime_dependency(%q<blockenspiel>, [">= 0.3.2"])
47
- s.add_runtime_dependency(%q<activesupport>, [">= 2.3.5"])
48
- s.add_development_dependency(%q<to_json_fix>, [">= 0.0.1"])
49
- s.add_development_dependency(%q<shoulda>, [">= 0"])
50
- else
51
- s.add_dependency(%q<blockenspiel>, [">= 0.3.2"])
52
- s.add_dependency(%q<activesupport>, [">= 2.3.5"])
53
- s.add_dependency(%q<to_json_fix>, [">= 0.0.1"])
54
- s.add_dependency(%q<shoulda>, [">= 0"])
55
- end
56
- else
57
- s.add_dependency(%q<blockenspiel>, [">= 0.3.2"])
58
- s.add_dependency(%q<activesupport>, [">= 2.3.5"])
59
- s.add_dependency(%q<to_json_fix>, [">= 0.0.1"])
60
- s.add_dependency(%q<shoulda>, [">= 0"])
61
- end
62
- end
63
-
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{characterizable}
8
+ s.version = "0.0.15"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Andy Rossmeissl", "Seamus Abshere"]
12
+ s.date = %q{2010-08-15}
13
+ s.description = %q{Characterize the relationship between "attributes" (getters/setters) of instances of a class}
14
+ s.email = %q{seamus@abshere.net}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE",
17
+ "README.rdoc"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ ".gitignore",
22
+ "LICENSE",
23
+ "README.rdoc",
24
+ "Rakefile",
25
+ "VERSION",
26
+ "characterizable.gemspec",
27
+ "lib/characterizable.rb",
28
+ "test/helper.rb",
29
+ "test/test_characterizable.rb"
30
+ ]
31
+ s.homepage = %q{http://github.com/seamusabshere/characterizable}
32
+ s.rdoc_options = ["--charset=UTF-8"]
33
+ s.require_paths = ["lib"]
34
+ s.rubygems_version = %q{1.3.7}
35
+ s.summary = %q{Characterize instances of a class}
36
+ s.test_files = [
37
+ "test/helper.rb",
38
+ "test/test_characterizable.rb"
39
+ ]
40
+
41
+ if s.respond_to? :specification_version then
42
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
43
+ s.specification_version = 3
44
+
45
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
46
+ s.add_runtime_dependency(%q<blockenspiel>, [">= 0.3.2"])
47
+ s.add_runtime_dependency(%q<activesupport>, [">= 2.3.5"])
48
+ s.add_development_dependency(%q<to_json_fix>, [">= 0.0.1"])
49
+ s.add_development_dependency(%q<shoulda>, [">= 0"])
50
+ else
51
+ s.add_dependency(%q<blockenspiel>, [">= 0.3.2"])
52
+ s.add_dependency(%q<activesupport>, [">= 2.3.5"])
53
+ s.add_dependency(%q<to_json_fix>, [">= 0.0.1"])
54
+ s.add_dependency(%q<shoulda>, [">= 0"])
55
+ end
56
+ else
57
+ s.add_dependency(%q<blockenspiel>, [">= 0.3.2"])
58
+ s.add_dependency(%q<activesupport>, [">= 2.3.5"])
59
+ s.add_dependency(%q<to_json_fix>, [">= 0.0.1"])
60
+ s.add_dependency(%q<shoulda>, [">= 0"])
61
+ end
62
+ end
63
+
@@ -8,7 +8,6 @@ require 'active_support/version'
8
8
  active_support/core_ext/object/blank
9
9
  active_support/core_ext/array/wrap
10
10
  active_support/core_ext/module/aliasing
11
- active_support/core_ext/module/delegation
12
11
  }.each do |active_support_3_requirement|
13
12
  require active_support_3_requirement
14
13
  end if ActiveSupport::VERSION::MAJOR == 3
@@ -74,14 +73,14 @@ module Characterizable
74
73
  def _take_snapshot
75
74
  target.characterizable_base.characteristics.each do |_, c|
76
75
  if c.known?(target)
77
- #if c.effective?(target)
76
+ if c.effective?(target)
78
77
  self[c.name] = c.value(target)
79
- #elsif !c.untrumped?(target)
80
- # trumped_keys.push c.name
81
- #elsif !c.revealed?(target)
82
- # wasted_keys.push c.name
83
- # lacking_keys.push c.prerequisite
84
- #end
78
+ elsif !c.untrumped?(target)
79
+ trumped_keys.push c.name
80
+ elsif !c.revealed?(target)
81
+ wasted_keys.push c.name
82
+ lacking_keys.push c.prerequisite
83
+ end
85
84
  end
86
85
  end
87
86
  end
@@ -99,7 +98,7 @@ module Characterizable
99
98
  @lacking_keys ||= Array.new
100
99
  end
101
100
  def effective
102
- target.characterizable_base.characteristics.select { |_, c| c.known?(self) }
101
+ target.characterizable_base.characteristics.select { |_, c| c.effective?(self) }
103
102
  end
104
103
  def potential
105
104
  target.characterizable_base.characteristics.select { |_, c| c.potential?(self) }
@@ -120,11 +119,15 @@ module Characterizable
120
119
  self.characterizable_base ||= Characterizable::Base.new self
121
120
  Blockenspiel.invoke block, characterizable_base
122
121
  end
123
- delegate :characteristics, :to => :characterizable_base
122
+ def characteristics
123
+ characterizable_base.characteristics
124
+ end
124
125
  end
125
126
 
126
127
  class CharacteristicAlreadyDefined < ArgumentError
127
128
  end
129
+ class CyclicalTrumping < ArgumentError
130
+ end
128
131
 
129
132
  class Base
130
133
  attr_reader :klass
@@ -166,6 +169,11 @@ module Characterizable
166
169
  @prerequisite = options.delete(:prerequisite)
167
170
  @options = options
168
171
  Blockenspiel.invoke block, self if block_given?
172
+ trumps.each do |trump|
173
+ if c = characteristics[trump] and c.trumps.include? name
174
+ raise CyclicalTrumping, "On #{base.klass}, '#{c.name}' and '#{name}' trump each other"
175
+ end
176
+ end
169
177
  end
170
178
  def to_json(*)
171
179
  { :name => name, :trumps => trumps, :prerequisite => prerequisite, :options => options }.to_json
@@ -174,9 +182,11 @@ module Characterizable
174
182
  "<Characterizable::Characteristic name=#{name.inspect} trumps=#{trumps.inspect} prerequisite=#{prerequisite.inspect} options=#{options.inspect}>"
175
183
  end
176
184
  def trumped_by
177
- @_trumped_by ||= characteristics.select { |_, c| c.trumps.include? name }
185
+ characteristics.select { |_, c| c.trumps.include? name }
186
+ end
187
+ def characteristics
188
+ base.characteristics
178
189
  end
179
- delegate :characteristics, :to => :base
180
190
  def value(target)
181
191
  case target
182
192
  when Hash
@@ -410,4 +410,19 @@ class TestCharacterizable < Test::Unit::TestCase
410
410
  end
411
411
  end
412
412
  end
413
+
414
+ # this used to cause infinite loops
415
+ should 'not let two characteristics trump each other' do
416
+ assert_raises ::Characterizable::CyclicalTrumping do
417
+ class Universe
418
+ include Characterizable
419
+ attr_accessor :matter
420
+ attr_accessor :antimatter
421
+ characterize do
422
+ has :matter, :trumps => :antimatter
423
+ has :antimatter, :trumps => :matter
424
+ end
425
+ end
426
+ end
427
+ end
413
428
  end
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: characterizable
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 1
4
5
  prerelease: false
5
6
  segments:
6
7
  - 0
7
8
  - 0
8
- - 14
9
- version: 0.0.14
9
+ - 15
10
+ version: 0.0.15
10
11
  platform: ruby
11
12
  authors:
12
13
  - Andy Rossmeissl
@@ -15,16 +16,18 @@ autorequire:
15
16
  bindir: bin
16
17
  cert_chain: []
17
18
 
18
- date: 2010-08-13 00:00:00 -05:00
19
+ date: 2010-08-15 00:00:00 -04:00
19
20
  default_executable:
20
21
  dependencies:
21
22
  - !ruby/object:Gem::Dependency
22
23
  name: blockenspiel
23
24
  prerelease: false
24
25
  requirement: &id001 !ruby/object:Gem::Requirement
26
+ none: false
25
27
  requirements:
26
28
  - - ">="
27
29
  - !ruby/object:Gem::Version
30
+ hash: 23
28
31
  segments:
29
32
  - 0
30
33
  - 3
@@ -36,9 +39,11 @@ dependencies:
36
39
  name: activesupport
37
40
  prerelease: false
38
41
  requirement: &id002 !ruby/object:Gem::Requirement
42
+ none: false
39
43
  requirements:
40
44
  - - ">="
41
45
  - !ruby/object:Gem::Version
46
+ hash: 9
42
47
  segments:
43
48
  - 2
44
49
  - 3
@@ -50,9 +55,11 @@ dependencies:
50
55
  name: to_json_fix
51
56
  prerelease: false
52
57
  requirement: &id003 !ruby/object:Gem::Requirement
58
+ none: false
53
59
  requirements:
54
60
  - - ">="
55
61
  - !ruby/object:Gem::Version
62
+ hash: 29
56
63
  segments:
57
64
  - 0
58
65
  - 0
@@ -64,9 +71,11 @@ dependencies:
64
71
  name: shoulda
65
72
  prerelease: false
66
73
  requirement: &id004 !ruby/object:Gem::Requirement
74
+ none: false
67
75
  requirements:
68
76
  - - ">="
69
77
  - !ruby/object:Gem::Version
78
+ hash: 3
70
79
  segments:
71
80
  - 0
72
81
  version: "0"
@@ -102,23 +111,27 @@ rdoc_options:
102
111
  require_paths:
103
112
  - lib
104
113
  required_ruby_version: !ruby/object:Gem::Requirement
114
+ none: false
105
115
  requirements:
106
116
  - - ">="
107
117
  - !ruby/object:Gem::Version
118
+ hash: 3
108
119
  segments:
109
120
  - 0
110
121
  version: "0"
111
122
  required_rubygems_version: !ruby/object:Gem::Requirement
123
+ none: false
112
124
  requirements:
113
125
  - - ">="
114
126
  - !ruby/object:Gem::Version
127
+ hash: 3
115
128
  segments:
116
129
  - 0
117
130
  version: "0"
118
131
  requirements: []
119
132
 
120
133
  rubyforge_project:
121
- rubygems_version: 1.3.6
134
+ rubygems_version: 1.3.7
122
135
  signing_key:
123
136
  specification_version: 3
124
137
  summary: Characterize instances of a class