leap 0.5.7 → 0.5.8
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +7 -0
- data/Rakefile +12 -19
- data/leap.gemspec +26 -28
- data/lib/leap.rb +4 -8
- data/lib/leap/committee.rb +1 -3
- data/lib/leap/decision.rb +1 -3
- data/lib/leap/quorum.rb +24 -2
- data/lib/leap/subject.rb +19 -18
- data/lib/leap/version.rb +3 -3
- data/lib/leap/whip.rb +19 -4
- data/test/helper.rb +16 -17
- data/test/test_leap.rb +75 -61
- metadata +69 -30
data/CHANGELOG
ADDED
data/Rakefile
CHANGED
@@ -1,27 +1,20 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
begin
|
4
|
-
require 'bundler'
|
5
|
-
rescue LoadError
|
6
|
-
$stderr.puts "You must install bundler - run `gem install bundler`"
|
7
|
-
end
|
8
|
-
|
9
|
-
begin
|
10
|
-
Bundler.setup
|
11
|
-
rescue Bundler::BundlerError => e
|
12
|
-
$stderr.puts e.message
|
13
|
-
$stderr.puts "Run `bundle install` to install missing gems"
|
14
|
-
exit e.status_code
|
15
|
-
end
|
16
|
-
|
17
|
-
require 'bueller'
|
18
|
-
Bueller::Tasks.new
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
require "bundler/gem_tasks"
|
19
3
|
|
20
4
|
require 'rake'
|
21
5
|
require 'rake/testtask'
|
22
6
|
Rake::TestTask.new(:test) do |test|
|
23
|
-
test.libs << '
|
7
|
+
test.libs << 'test'
|
24
8
|
test.pattern = 'test/**/test_*.rb'
|
25
9
|
test.verbose = true
|
26
10
|
end
|
11
|
+
|
12
|
+
require 'bueller'
|
13
|
+
Bueller::Tasks.new
|
14
|
+
|
27
15
|
task :default => :test
|
16
|
+
|
17
|
+
require 'yard'
|
18
|
+
YARD::Rake::YardocTask.new do |y|
|
19
|
+
y.options << '--no-private'
|
20
|
+
end
|
data/leap.gemspec
CHANGED
@@ -1,28 +1,26 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
s.
|
7
|
-
s.
|
8
|
-
s.
|
9
|
-
s.
|
10
|
-
s.
|
11
|
-
s.
|
12
|
-
|
13
|
-
s.
|
14
|
-
|
15
|
-
s.
|
16
|
-
s.
|
17
|
-
|
18
|
-
s.
|
19
|
-
|
20
|
-
s.add_development_dependency
|
21
|
-
s.add_development_dependency
|
22
|
-
s.
|
23
|
-
s.add_dependency '
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
s.add_dependency 'builder'
|
28
|
-
end
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path("../lib/leap/version", __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |s|
|
5
|
+
s.name = "leap"
|
6
|
+
s.version = Leap::VERSION
|
7
|
+
s.authors = ["Andy Rossmeissl", "Seamus Abshere", "Derek Kastner"]
|
8
|
+
s.email = "andy@rossmeissl.net"
|
9
|
+
s.homepage = "https://github.com/rossmeissl/leap"
|
10
|
+
s.summary = %Q{A heuristics engine for your Ruby objects}
|
11
|
+
s.description = %Q{Leap to conclusions}
|
12
|
+
|
13
|
+
s.files = `git ls-files`.split("\n")
|
14
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
15
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
16
|
+
s.require_paths = ["lib"]
|
17
|
+
|
18
|
+
s.add_development_dependency 'charisma'
|
19
|
+
s.add_development_dependency 'minitest'
|
20
|
+
s.add_development_dependency 'minitest-reporters'
|
21
|
+
s.add_development_dependency 'bueller'
|
22
|
+
s.add_dependency 'yard'
|
23
|
+
s.add_dependency 'activesupport', '>=2.3.4'
|
24
|
+
# sabshere 1/27/11 for activesupport - http://groups.google.com/group/ruby-bundler/browse_thread/thread/b4a2fc61ac0b5438
|
25
|
+
s.add_dependency 'i18n'
|
26
|
+
end
|
data/lib/leap.rb
CHANGED
@@ -1,12 +1,8 @@
|
|
1
|
+
require 'active_support'
|
1
2
|
require 'active_support/version'
|
2
|
-
|
3
|
-
active_support/core_ext
|
4
|
-
|
5
|
-
active_support/core_ext/array/extract_options
|
6
|
-
}.each do |active_support_3_requirement|
|
7
|
-
require active_support_3_requirement
|
8
|
-
end if ActiveSupport::VERSION::MAJOR == 3
|
9
|
-
require 'blockenspiel'
|
3
|
+
if ActiveSupport::VERSION::MAJOR >= 3
|
4
|
+
require 'active_support/core_ext'
|
5
|
+
end
|
10
6
|
|
11
7
|
require 'leap/subject'
|
12
8
|
require 'leap/committee'
|
data/lib/leap/committee.rb
CHANGED
@@ -49,7 +49,7 @@ module Leap
|
|
49
49
|
Leap.log.committee "Convening committee", name
|
50
50
|
quorums.each do |quorum|
|
51
51
|
Leap.log.quorum "Assessing quorum", quorum.name
|
52
|
-
next unless quorum.satisfied_by? characteristics and quorum.complies_with?
|
52
|
+
next unless quorum.satisfied_by? characteristics and quorum.complies_with? options[:comply]
|
53
53
|
Leap.log.quorum "Acknowledging quorum", quorum.name
|
54
54
|
if conclusion = quorum.acknowledge(characteristics.slice(*quorum.characteristics), considerations.dup)
|
55
55
|
Leap.log.quorum "Success", quorum.name
|
@@ -59,8 +59,6 @@ module Leap
|
|
59
59
|
nil
|
60
60
|
end
|
61
61
|
|
62
|
-
include ::Blockenspiel::DSL
|
63
|
-
|
64
62
|
# Defines a quorum within this committee.
|
65
63
|
#
|
66
64
|
# A quorum encapsulate a specific methodology for drawing the committe's conclusion.
|
data/lib/leap/decision.rb
CHANGED
@@ -48,8 +48,6 @@ module Leap
|
|
48
48
|
end
|
49
49
|
end
|
50
50
|
|
51
|
-
include ::Blockenspiel::DSL
|
52
|
-
|
53
51
|
# Define a committee within the decision.
|
54
52
|
#
|
55
53
|
# Used within a <tt>Leap::Subject#decide</tt> block to define a new committee. See <tt>Leap::Committee</tt> for details.
|
@@ -58,7 +56,7 @@ module Leap
|
|
58
56
|
def committee(name, options = {}, &blk)
|
59
57
|
committee = ::Leap::Committee.new(name, options)
|
60
58
|
@committees << committee
|
61
|
-
|
59
|
+
committee.instance_eval(&blk)
|
62
60
|
end
|
63
61
|
end
|
64
62
|
end
|
data/lib/leap/quorum.rb
CHANGED
@@ -36,10 +36,32 @@ module Leap
|
|
36
36
|
end
|
37
37
|
|
38
38
|
# Does the quorum comply with the given set of protocols?
|
39
|
-
# @param [Array]
|
39
|
+
# @param [Array, Hash, Object] guidelines The list of protocols for which we're checking compliance.
|
40
40
|
# @return [TrueClass, NilClass]
|
41
41
|
def complies_with?(guidelines)
|
42
|
-
|
42
|
+
case guidelines
|
43
|
+
when Hash
|
44
|
+
inversion = guidelines.inject({}) do |memo, pair|
|
45
|
+
protocol, committees = pair
|
46
|
+
Array.wrap(committees).each do |committee|
|
47
|
+
if memo[committee]
|
48
|
+
memo[committee] << protocol
|
49
|
+
else
|
50
|
+
memo[committee] = [protocol]
|
51
|
+
end
|
52
|
+
end
|
53
|
+
memo
|
54
|
+
end
|
55
|
+
inversion.values.any? do |committee_guidelines|
|
56
|
+
(committee_guidelines - compliance).empty?
|
57
|
+
end
|
58
|
+
when Array
|
59
|
+
(guidelines - compliance).empty?
|
60
|
+
when NilClass
|
61
|
+
true
|
62
|
+
else
|
63
|
+
compliance.include? guidelines
|
64
|
+
end
|
43
65
|
end
|
44
66
|
|
45
67
|
# Perform the quorum's methodology using the given characteristics.
|
data/lib/leap/subject.rb
CHANGED
@@ -48,30 +48,31 @@ module Leap
|
|
48
48
|
# @see Leap::ImplicitAttributes
|
49
49
|
def decide(goal, options = {}, &blk)
|
50
50
|
decisions[goal] = ::Leap::Decision.new goal, options
|
51
|
-
|
51
|
+
decisions[goal].instance_eval(&blk)
|
52
52
|
define_method goal do |*considerations|
|
53
|
+
decision = self.class.decisions[goal]
|
54
|
+
options = considerations.extract_options!
|
55
|
+
@deliberations ||= {}
|
53
56
|
Leap.instrument.decision goal do
|
54
|
-
options = considerations.extract_options!
|
55
|
-
@deliberations ||= {}
|
56
|
-
decision = self.class.decisions[goal]
|
57
57
|
characteristics = send(decision.signature_method)
|
58
58
|
@deliberations[goal] = decision.make(characteristics, options, *considerations)
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
59
|
+
end
|
60
|
+
if decision.mastered? and @deliberations[goal][goal].nil?
|
61
|
+
raise ::Leap::NoSolutionError, :goal => goal, :deliberation => @deliberations[goal]
|
62
|
+
elsif decision.mastered?
|
63
|
+
Leap.log.decision "Success", goal
|
64
|
+
@deliberations[goal][goal]
|
65
|
+
elsif options[:comply].is_a? Hash
|
66
|
+
options[:comply].each do |protocol, committees|
|
67
|
+
[committees].flatten.each do |committee|
|
68
|
+
@deliberations[goal].compliance(committee).include?(protocol) or raise ::Leap::NoSolutionError, :goal => committee, :deliberation => @deliberations[goal]
|
69
69
|
end
|
70
|
-
Leap.log.decision "Success", goal
|
71
|
-
else
|
72
|
-
Leap.log.decision "Success", goal
|
73
|
-
@deliberations[goal]
|
74
70
|
end
|
71
|
+
Leap.log.decision "Success", goal
|
72
|
+
@deliberations[goal]
|
73
|
+
else
|
74
|
+
Leap.log.decision "Success", goal
|
75
|
+
@deliberations[goal]
|
75
76
|
end
|
76
77
|
end
|
77
78
|
end
|
data/lib/leap/version.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
module Leap
|
2
|
-
VERSION = "0.5.
|
3
|
-
end
|
1
|
+
module Leap
|
2
|
+
VERSION = "0.5.8"
|
3
|
+
end
|
data/lib/leap/whip.rb
CHANGED
@@ -43,13 +43,28 @@ module Leap
|
|
43
43
|
# @param [String, Symbol] name The quorum's name
|
44
44
|
# @param [Proc] blk A proc wrapping the quorum activity to instrument
|
45
45
|
def quorum(name, &blk)
|
46
|
-
|
46
|
+
message, result = instrument(true, &blk)
|
47
|
+
Leap.log.quorum message, name
|
48
|
+
result
|
47
49
|
end
|
48
|
-
|
50
|
+
|
49
51
|
private
|
50
52
|
|
51
|
-
|
52
|
-
|
53
|
+
# Give Procs the capacity to remember their result.
|
54
|
+
module Registered
|
55
|
+
# Result storage
|
56
|
+
attr_reader :result
|
57
|
+
|
58
|
+
# Override Proc#call here to ensure storage
|
59
|
+
def call
|
60
|
+
@result = super
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def instrument(return_result_of_measured_block = false, &blk)
|
65
|
+
blk = blk.dup.extend Registered
|
66
|
+
message = 'Completed in ' + Benchmark.measure { blk.call }.format('%10.6r').gsub(/[()]/,'').strip + 's'
|
67
|
+
return_result_of_measured_block ? [message, blk.result] : message
|
53
68
|
end
|
54
69
|
end
|
55
70
|
|
data/test/helper.rb
CHANGED
@@ -1,23 +1,22 @@
|
|
1
1
|
require 'rubygems'
|
2
|
-
require 'bundler'
|
3
|
-
Bundler.setup
|
4
|
-
require 'test/unit'
|
5
|
-
require 'shoulda'
|
6
|
-
require 'charisma'
|
7
|
-
require 'active_support/version'
|
8
|
-
%w{
|
9
|
-
active_support/core_ext/hash/except
|
10
|
-
}.each do |active_support_3_requirement|
|
11
|
-
require active_support_3_requirement
|
12
|
-
end if ActiveSupport::VERSION::MAJOR == 3
|
13
|
-
|
14
|
-
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
15
|
-
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
16
|
-
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib', 'leap'))
|
2
|
+
require 'bundler/setup'
|
17
3
|
|
18
|
-
|
4
|
+
if Bundler.definition.specs['debugger'].first
|
5
|
+
require 'debugger'
|
6
|
+
elsif Bundler.definition.specs['ruby-debug'].first
|
7
|
+
require 'ruby-debug'
|
19
8
|
end
|
20
9
|
|
10
|
+
require 'minitest/unit'
|
11
|
+
require 'minitest/autorun'
|
12
|
+
require 'minitest/reporters'
|
13
|
+
MiniTest::Unit.runner = MiniTest::SuiteRunner.new
|
14
|
+
MiniTest::Unit.runner.reporters << MiniTest::Reporters::SpecReporter.new
|
15
|
+
|
16
|
+
require 'charisma'
|
17
|
+
|
18
|
+
require 'leap'
|
19
|
+
|
21
20
|
class Person
|
22
21
|
attr_reader :name
|
23
22
|
attr_reader :age
|
@@ -121,7 +120,7 @@ class Seamus
|
|
121
120
|
end
|
122
121
|
|
123
122
|
class Idea < Struct.new(:gotchas, :caveats)
|
124
|
-
def to_hash() Hash[members.zip(values)].reject {|_,v| v.nil?} end
|
123
|
+
def to_hash() Hash[members.map(&:to_sym).zip(values)].reject {|_,v| v.nil?} end
|
125
124
|
|
126
125
|
include Leap
|
127
126
|
decide :value, :with => :to_hash do
|
data/test/test_leap.rb
CHANGED
@@ -1,149 +1,161 @@
|
|
1
1
|
require 'helper'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
3
|
+
describe Leap do
|
4
|
+
describe "A generic person" do
|
5
|
+
before do
|
6
6
|
@person = Person.new
|
7
7
|
end
|
8
8
|
|
9
|
-
|
9
|
+
it 'still has a lucky number' do
|
10
10
|
assert_equal 0, @person.lucky_number
|
11
11
|
end
|
12
12
|
|
13
|
-
|
13
|
+
it 'naturally receives an International Psychics Association-compliant lucky number' do
|
14
14
|
assert_equal [:ipa], @person.deliberations[:lucky_number].compliance
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
|
-
|
19
|
-
|
18
|
+
describe "An aged person" do
|
19
|
+
before do
|
20
20
|
@person = Person.new :age => 5
|
21
21
|
end
|
22
22
|
|
23
|
-
|
23
|
+
it 'indeed has a lucky number' do
|
24
24
|
assert_equal 36, @person.lucky_number
|
25
25
|
end
|
26
26
|
|
27
|
-
|
28
|
-
assert_equal(
|
27
|
+
it 'nevertheless remembers how his lucky number was determined' do
|
28
|
+
assert_equal({:magic_integer => 6, :lucky_number => 36, :age => 5, :litmus => {}}, @person.deliberations[:lucky_number].characteristics)
|
29
29
|
assert_equal 'ninja style', @person.deliberations[:lucky_number].reports.find{ |r| r.committee.name == :magic_integer }.quorum.name
|
30
30
|
end
|
31
31
|
|
32
|
-
|
32
|
+
it 'only gives quorums what they ask for' do
|
33
33
|
assert_equal({}, @person.deliberations[:lucky_number].reports.find{ |r| r.committee.name == :litmus }.conclusion)
|
34
34
|
end
|
35
35
|
|
36
|
-
|
36
|
+
it "doesn't receive an International Psychics Association-compliant lucky number unless he asks for it" do
|
37
37
|
assert_equal [], @person.deliberations[:lucky_number].compliance
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
41
|
-
|
42
|
-
|
41
|
+
describe "A clever aged person" do
|
42
|
+
before do
|
43
43
|
@person = Person.new :magic_integer => 42, :age => 5
|
44
44
|
end
|
45
45
|
|
46
|
-
|
46
|
+
it 'can use his own magic integer in determining his lucky number' do
|
47
47
|
assert_equal 1764, @person.lucky_number
|
48
48
|
end
|
49
49
|
end
|
50
50
|
|
51
|
-
|
52
|
-
|
51
|
+
describe "A named person" do
|
52
|
+
before do
|
53
53
|
@person = Person.new :name => 'Matz'
|
54
54
|
end
|
55
55
|
|
56
|
-
|
56
|
+
it 'has access to the super magic method' do
|
57
57
|
assert_equal 1, @person.lucky_number
|
58
58
|
end
|
59
59
|
|
60
|
-
|
60
|
+
it 'can stay in compliance with International Psychics Association guidelines' do
|
61
61
|
assert_equal 0, @person.lucky_number(:comply => :ipa)
|
62
62
|
end
|
63
63
|
end
|
64
64
|
|
65
|
-
|
66
|
-
|
65
|
+
describe "A generic place" do
|
66
|
+
before do
|
67
67
|
@place = Place.new
|
68
68
|
end
|
69
69
|
|
70
|
-
|
70
|
+
it 'has decent weather' do
|
71
71
|
assert_equal :decent, @place.weather
|
72
72
|
end
|
73
73
|
end
|
74
74
|
|
75
|
-
|
76
|
-
|
75
|
+
describe "Vermont" do
|
76
|
+
before do
|
77
77
|
@place = Place.new :name => 'Vermont', :seasonality => { :summer => :warm, :winter => :cold }
|
78
78
|
end
|
79
79
|
|
80
|
-
|
80
|
+
it 'is warm in the summer' do
|
81
81
|
assert_equal :warm, @place.weather(:summer)
|
82
82
|
end
|
83
83
|
end
|
84
84
|
|
85
|
-
|
86
|
-
|
85
|
+
describe "A lazy subject" do
|
86
|
+
before do
|
87
87
|
@thing = Thing.new
|
88
88
|
@thing.anything rescue nil
|
89
89
|
end
|
90
90
|
|
91
|
-
|
91
|
+
it 'has proper implicit characteristics' do
|
92
92
|
assert_equal Hash.new, @thing.deliberations[:anything].characteristics
|
93
93
|
end
|
94
94
|
end
|
95
95
|
|
96
|
-
|
97
|
-
|
96
|
+
describe "An impossible decision" do
|
97
|
+
before do
|
98
98
|
@thing = Thing.new
|
99
99
|
end
|
100
100
|
|
101
|
-
|
102
|
-
|
101
|
+
it 'is impossible to make' do
|
102
|
+
assert_raises(::Leap::NoSolutionError, /No solution was found for "anything"/) do
|
103
103
|
@thing.anything
|
104
104
|
end
|
105
|
-
|
106
|
-
assert_match(/No solution was found for "anything"/, exception.message)
|
107
105
|
end
|
108
106
|
end
|
109
107
|
|
110
|
-
|
111
|
-
|
108
|
+
describe "A difficult decision" do
|
109
|
+
before do
|
112
110
|
@person = Person.new :name => 'Bozo'
|
113
111
|
end
|
114
112
|
|
115
|
-
|
116
|
-
|
113
|
+
it 'provides details about its apparent impossibility' do
|
114
|
+
assert_raises(::Leap::NoSolutionError, /No solution was found for "lucky_number".*magic_float: ancient recipe, name: provided as input/) do
|
117
115
|
@person.lucky_number :comply => :zeus
|
118
116
|
end
|
119
|
-
|
120
|
-
|
121
|
-
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
describe "Instrumentation" do
|
121
|
+
before do
|
122
|
+
@old_stdout = $stdout
|
123
|
+
$stdout = StringIO.new
|
124
|
+
Leap.instrument!
|
125
|
+
end
|
126
|
+
after do
|
127
|
+
$stdout = @old_stdout
|
128
|
+
Leap.send :remove_class_variable, :@@logger
|
129
|
+
Leap.send :remove_class_variable, :@@whip
|
130
|
+
end
|
131
|
+
it "doesn't interfere with computation" do
|
132
|
+
@person = Person.new :age => 5
|
133
|
+
assert_equal 36, @person.lucky_number.to_i
|
122
134
|
end
|
123
135
|
end
|
124
136
|
|
125
|
-
|
126
|
-
|
137
|
+
describe 'Seamus deciding about whether he can commit to a date' do
|
138
|
+
before do
|
127
139
|
@seamus = Seamus.new
|
128
140
|
end
|
129
141
|
|
130
|
-
|
142
|
+
it 'works for most people' do
|
131
143
|
assert_equal :maybe, @seamus.can_i_commit_to_that_date
|
132
144
|
end
|
133
145
|
|
134
|
-
|
146
|
+
it 'works for BenT, who is easygoing' do
|
135
147
|
assert_equal :maybe, @seamus.can_i_commit_to_that_date(:comply => :bent)
|
136
148
|
end
|
137
149
|
|
138
|
-
|
139
|
-
|
150
|
+
it 'never works for andy' do
|
151
|
+
assert_raises ::Leap::NoSolutionError do
|
140
152
|
@seamus.can_i_commit_to_that_date(:comply => :andy)
|
141
153
|
end
|
142
154
|
end
|
143
155
|
end
|
144
156
|
|
145
|
-
|
146
|
-
|
157
|
+
describe 'A committee' do
|
158
|
+
before do
|
147
159
|
class Owl
|
148
160
|
include Leap
|
149
161
|
decide :eye_size do
|
@@ -153,27 +165,27 @@ class TestLeap < Test::Unit::TestCase
|
|
153
165
|
end
|
154
166
|
end
|
155
167
|
|
156
|
-
|
168
|
+
it 'remembers options that it was given when it was created' do
|
157
169
|
assert_equal :length, Owl.decisions[:eye_size].committees.first.options[:measures]
|
158
170
|
end
|
159
171
|
end
|
160
172
|
|
161
|
-
|
162
|
-
|
173
|
+
describe 'A decision without a master committee' do
|
174
|
+
before do
|
163
175
|
@idea = Idea.new
|
164
176
|
@bad_idea = Idea.new(100, 10) # gotchas, caveats
|
165
177
|
end
|
166
178
|
|
167
|
-
|
179
|
+
it 'still computes' do
|
168
180
|
@idea.value
|
169
181
|
assert_equal({:cost => 0, :benefit => 9, :caveats => 1, :hangups => 0}, @idea.deliberations[:value].characteristics)
|
170
182
|
end
|
171
183
|
|
172
|
-
|
184
|
+
it 'provides easy access to committee reports' do
|
173
185
|
assert_equal 0, @idea.value[:cost]
|
174
186
|
end
|
175
187
|
|
176
|
-
|
188
|
+
it 'provides compliance specific to a certain conclusion' do
|
177
189
|
# If hangups does not comply with common sense, neither should cost
|
178
190
|
assert_equal [], @idea.deliberations[:value].compliance(:hangups)
|
179
191
|
assert_equal [], @idea.deliberations[:value].compliance(:benefit)
|
@@ -187,7 +199,7 @@ class TestLeap < Test::Unit::TestCase
|
|
187
199
|
assert_equal [:wisdom], @bad_idea.deliberations[:value].compliance(:benefit)
|
188
200
|
end
|
189
201
|
|
190
|
-
|
202
|
+
it 'only returns compliant values when compliance is requested and endpoint is unknown' do
|
191
203
|
# Nothing complies
|
192
204
|
assert_equal({}, @idea.value(:comply => :common_sense).characteristics)
|
193
205
|
|
@@ -195,16 +207,18 @@ class TestLeap < Test::Unit::TestCase
|
|
195
207
|
assert_equal({:gotchas => 100, :caveats => 10, :hangups => 100, :cost => 100}, @bad_idea.value(:comply => :common_sense).characteristics)
|
196
208
|
end
|
197
209
|
|
198
|
-
|
199
|
-
|
210
|
+
it 'returns an error message when known endpoint cannot be achieved' do
|
211
|
+
assert_raises(::Leap::NoSolutionError, /No solution was found for "benefit"/) do
|
200
212
|
@idea.value(:comply => { :common_sense => :benefit })
|
201
213
|
end
|
202
|
-
assert_match(/No solution was found for "benefit"/, exception.message)
|
203
214
|
|
204
|
-
|
215
|
+
assert_raises(::Leap::NoSolutionError, /No solution was found for "benefit"/) do
|
205
216
|
@bad_idea.value(:comply => { :common_sense => :benefit })
|
206
217
|
end
|
207
|
-
|
218
|
+
end
|
219
|
+
|
220
|
+
it 'returns compliant values when compliance is requested for specific committees' do
|
221
|
+
assert_equal 100, @bad_idea.value(:comply => { :common_sense => :cost })[:cost]
|
208
222
|
end
|
209
223
|
end
|
210
224
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: leap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.8
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -11,22 +11,27 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date:
|
14
|
+
date: 2012-09-13 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: charisma
|
18
|
-
requirement:
|
18
|
+
requirement: !ruby/object:Gem::Requirement
|
19
19
|
none: false
|
20
20
|
requirements:
|
21
|
-
- -
|
21
|
+
- - ! '>='
|
22
22
|
- !ruby/object:Gem::Version
|
23
|
-
version: 0
|
23
|
+
version: '0'
|
24
24
|
type: :development
|
25
25
|
prerelease: false
|
26
|
-
version_requirements:
|
26
|
+
version_requirements: !ruby/object:Gem::Requirement
|
27
|
+
none: false
|
28
|
+
requirements:
|
29
|
+
- - ! '>='
|
30
|
+
- !ruby/object:Gem::Version
|
31
|
+
version: '0'
|
27
32
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
29
|
-
requirement:
|
33
|
+
name: minitest
|
34
|
+
requirement: !ruby/object:Gem::Requirement
|
30
35
|
none: false
|
31
36
|
requirements:
|
32
37
|
- - ! '>='
|
@@ -34,10 +39,31 @@ dependencies:
|
|
34
39
|
version: '0'
|
35
40
|
type: :development
|
36
41
|
prerelease: false
|
37
|
-
version_requirements:
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
none: false
|
44
|
+
requirements:
|
45
|
+
- - ! '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
- !ruby/object:Gem::Dependency
|
49
|
+
name: minitest-reporters
|
50
|
+
requirement: !ruby/object:Gem::Requirement
|
51
|
+
none: false
|
52
|
+
requirements:
|
53
|
+
- - ! '>='
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0'
|
56
|
+
type: :development
|
57
|
+
prerelease: false
|
58
|
+
version_requirements: !ruby/object:Gem::Requirement
|
59
|
+
none: false
|
60
|
+
requirements:
|
61
|
+
- - ! '>='
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: '0'
|
38
64
|
- !ruby/object:Gem::Dependency
|
39
65
|
name: bueller
|
40
|
-
requirement:
|
66
|
+
requirement: !ruby/object:Gem::Requirement
|
41
67
|
none: false
|
42
68
|
requirements:
|
43
69
|
- - ! '>='
|
@@ -45,21 +71,31 @@ dependencies:
|
|
45
71
|
version: '0'
|
46
72
|
type: :development
|
47
73
|
prerelease: false
|
48
|
-
version_requirements:
|
74
|
+
version_requirements: !ruby/object:Gem::Requirement
|
75
|
+
none: false
|
76
|
+
requirements:
|
77
|
+
- - ! '>='
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: '0'
|
49
80
|
- !ruby/object:Gem::Dependency
|
50
|
-
name:
|
51
|
-
requirement:
|
81
|
+
name: yard
|
82
|
+
requirement: !ruby/object:Gem::Requirement
|
52
83
|
none: false
|
53
84
|
requirements:
|
54
85
|
- - ! '>='
|
55
86
|
- !ruby/object:Gem::Version
|
56
|
-
version: 0
|
87
|
+
version: '0'
|
57
88
|
type: :runtime
|
58
89
|
prerelease: false
|
59
|
-
version_requirements:
|
90
|
+
version_requirements: !ruby/object:Gem::Requirement
|
91
|
+
none: false
|
92
|
+
requirements:
|
93
|
+
- - ! '>='
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '0'
|
60
96
|
- !ruby/object:Gem::Dependency
|
61
97
|
name: activesupport
|
62
|
-
requirement:
|
98
|
+
requirement: !ruby/object:Gem::Requirement
|
63
99
|
none: false
|
64
100
|
requirements:
|
65
101
|
- - ! '>='
|
@@ -67,10 +103,15 @@ dependencies:
|
|
67
103
|
version: 2.3.4
|
68
104
|
type: :runtime
|
69
105
|
prerelease: false
|
70
|
-
version_requirements:
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
none: false
|
108
|
+
requirements:
|
109
|
+
- - ! '>='
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: 2.3.4
|
71
112
|
- !ruby/object:Gem::Dependency
|
72
113
|
name: i18n
|
73
|
-
requirement:
|
114
|
+
requirement: !ruby/object:Gem::Requirement
|
74
115
|
none: false
|
75
116
|
requirements:
|
76
117
|
- - ! '>='
|
@@ -78,18 +119,12 @@ dependencies:
|
|
78
119
|
version: '0'
|
79
120
|
type: :runtime
|
80
121
|
prerelease: false
|
81
|
-
version_requirements:
|
82
|
-
- !ruby/object:Gem::Dependency
|
83
|
-
name: builder
|
84
|
-
requirement: &6659700 !ruby/object:Gem::Requirement
|
122
|
+
version_requirements: !ruby/object:Gem::Requirement
|
85
123
|
none: false
|
86
124
|
requirements:
|
87
125
|
- - ! '>='
|
88
126
|
- !ruby/object:Gem::Version
|
89
127
|
version: '0'
|
90
|
-
type: :runtime
|
91
|
-
prerelease: false
|
92
|
-
version_requirements: *6659700
|
93
128
|
description: Leap to conclusions
|
94
129
|
email: andy@rossmeissl.net
|
95
130
|
executables: []
|
@@ -98,6 +133,7 @@ extra_rdoc_files: []
|
|
98
133
|
files:
|
99
134
|
- .document
|
100
135
|
- .gitignore
|
136
|
+
- CHANGELOG
|
101
137
|
- Gemfile
|
102
138
|
- README.markdown
|
103
139
|
- Rakefile
|
@@ -118,7 +154,7 @@ files:
|
|
118
154
|
- lib/leap/whip.rb
|
119
155
|
- test/helper.rb
|
120
156
|
- test/test_leap.rb
|
121
|
-
homepage:
|
157
|
+
homepage: https://github.com/rossmeissl/leap
|
122
158
|
licenses: []
|
123
159
|
post_install_message:
|
124
160
|
rdoc_options: []
|
@@ -132,7 +168,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
132
168
|
version: '0'
|
133
169
|
segments:
|
134
170
|
- 0
|
135
|
-
hash:
|
171
|
+
hash: 75148912892819623
|
136
172
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
137
173
|
none: false
|
138
174
|
requirements:
|
@@ -141,11 +177,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
141
177
|
version: '0'
|
142
178
|
segments:
|
143
179
|
- 0
|
144
|
-
hash:
|
180
|
+
hash: 75148912892819623
|
145
181
|
requirements: []
|
146
182
|
rubyforge_project:
|
147
|
-
rubygems_version: 1.8.
|
183
|
+
rubygems_version: 1.8.24
|
148
184
|
signing_key:
|
149
185
|
specification_version: 3
|
150
186
|
summary: A heuristics engine for your Ruby objects
|
151
|
-
test_files:
|
187
|
+
test_files:
|
188
|
+
- test/helper.rb
|
189
|
+
- test/test_leap.rb
|
190
|
+
has_rdoc:
|