leap 0.2.6 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/leap.gemspec +4 -2
- data/lib/leap/committee.rb +3 -1
- data/lib/leap/decision.rb +5 -4
- data/lib/leap/deliberation.rb +15 -0
- data/lib/leap/report.rb +10 -0
- data/lib/leap/subject.rb +4 -4
- data/lib/leap.rb +2 -0
- data/test/test_leap.rb +3 -2
- metadata +6 -4
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.3.0
|
data/leap.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{leap}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.3.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Andy Rossmeissl", "Seamus Abshere"]
|
12
|
-
s.date = %q{2010-07-
|
12
|
+
s.date = %q{2010-07-06}
|
13
13
|
s.description = %q{Leap to conclusions}
|
14
14
|
s.email = %q{andy@rossmeissl.net}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -28,7 +28,9 @@ Gem::Specification.new do |s|
|
|
28
28
|
"lib/leap/committee.rb",
|
29
29
|
"lib/leap/core_ext.rb",
|
30
30
|
"lib/leap/decision.rb",
|
31
|
+
"lib/leap/deliberation.rb",
|
31
32
|
"lib/leap/quorum.rb",
|
33
|
+
"lib/leap/report.rb",
|
32
34
|
"lib/leap/subject.rb",
|
33
35
|
"test/helper.rb",
|
34
36
|
"test/test_leap.rb"
|
data/lib/leap/committee.rb
CHANGED
@@ -10,7 +10,9 @@ module Leap
|
|
10
10
|
def report(characteristics, considerations)
|
11
11
|
quorums.grab do |quorum|
|
12
12
|
next unless quorum.satisfied_by? characteristics
|
13
|
-
quorum.acknowledge
|
13
|
+
if conclusion = quorum.acknowledge(characteristics, considerations.dup)
|
14
|
+
::Leap::Report.new quorum => conclusion
|
15
|
+
end
|
14
16
|
end
|
15
17
|
end
|
16
18
|
|
data/lib/leap/decision.rb
CHANGED
@@ -9,11 +9,12 @@ module Leap
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def make(characteristics, *considerations)
|
12
|
-
committees.reverse.inject(characteristics) do |
|
13
|
-
if report = committee.report(characteristics, considerations)
|
14
|
-
|
12
|
+
committees.reverse.inject(Deliberation.new(characteristics)) do |deliberation, committee|
|
13
|
+
if report = committee.report(deliberation.characteristics, considerations)
|
14
|
+
deliberation.reports[committee.name] = report
|
15
|
+
deliberation.characteristics[committee.name] = deliberation.reports[committee.name].conclusion
|
15
16
|
end
|
16
|
-
|
17
|
+
deliberation
|
17
18
|
end
|
18
19
|
end
|
19
20
|
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Leap
|
2
|
+
class Deliberation
|
3
|
+
attr_accessor :characteristics
|
4
|
+
attr_accessor :reports
|
5
|
+
|
6
|
+
def initialize(characteristics)
|
7
|
+
self.characteristics = characteristics
|
8
|
+
self.reports = {}
|
9
|
+
end
|
10
|
+
|
11
|
+
def [](characteristic)
|
12
|
+
characteristics[characteristic]
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/lib/leap/report.rb
ADDED
data/lib/leap/subject.rb
CHANGED
@@ -2,16 +2,16 @@ module Leap
|
|
2
2
|
module Subject
|
3
3
|
def self.extended(base)
|
4
4
|
base.instance_variable_set :@decisions, {}
|
5
|
-
base.send :attr_reader, :
|
5
|
+
base.send :attr_reader, :deliberations
|
6
6
|
end
|
7
7
|
attr_reader :decisions
|
8
8
|
def decide(goal, options = {}, &blk)
|
9
9
|
decisions[goal] = ::Leap::Decision.new goal, options
|
10
10
|
Blockenspiel.invoke(blk, decisions[goal])
|
11
11
|
define_method goal do |*considerations|
|
12
|
-
@
|
13
|
-
@
|
14
|
-
@
|
12
|
+
@deliberations ||= {}
|
13
|
+
@deliberations[goal] = self.class.decisions[goal].make send(self.class.decisions[goal].signature_method), *considerations
|
14
|
+
@deliberations[goal][goal]
|
15
15
|
end
|
16
16
|
end
|
17
17
|
end
|
data/lib/leap.rb
CHANGED
data/test/test_leap.rb
CHANGED
@@ -22,11 +22,12 @@ class TestLeap < Test::Unit::TestCase
|
|
22
22
|
|
23
23
|
should 'nevertheless remember how his lucky number was determined' do
|
24
24
|
@person.lucky_number # make the decision
|
25
|
-
assert_equal({ :magic_integer => 6, :lucky_number => 36, :age => 5}, @person.
|
25
|
+
assert_equal({ :magic_integer => 6, :lucky_number => 36, :age => 5}, @person.deliberations[:lucky_number].characteristics)
|
26
|
+
assert_equal 'ninja style', @person.deliberations[:lucky_number].reports[:magic_integer].quorum.name
|
26
27
|
end
|
27
28
|
|
28
29
|
should 'but only as long as it had actually been determined' do
|
29
|
-
assert_nil @person.
|
30
|
+
assert_nil @person.deliberations
|
30
31
|
end
|
31
32
|
end
|
32
33
|
|
metadata
CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 0
|
7
|
-
-
|
8
|
-
-
|
9
|
-
version: 0.
|
7
|
+
- 3
|
8
|
+
- 0
|
9
|
+
version: 0.3.0
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Andy Rossmeissl
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-07-
|
18
|
+
date: 2010-07-06 00:00:00 -04:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -92,7 +92,9 @@ files:
|
|
92
92
|
- lib/leap/committee.rb
|
93
93
|
- lib/leap/core_ext.rb
|
94
94
|
- lib/leap/decision.rb
|
95
|
+
- lib/leap/deliberation.rb
|
95
96
|
- lib/leap/quorum.rb
|
97
|
+
- lib/leap/report.rb
|
96
98
|
- lib/leap/subject.rb
|
97
99
|
- test/helper.rb
|
98
100
|
- test/test_leap.rb
|