leap 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.2.0
@@ -0,0 +1,65 @@
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{leap}
8
+ s.version = "0.2.0"
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-05-12}
13
+ s.description = %q{Leap to conclusions}
14
+ s.email = %q{andy@rossmeissl.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
+ "leap.gemspec",
27
+ "lib/leap.rb",
28
+ "lib/leap/committee.rb",
29
+ "lib/leap/core_ext.rb",
30
+ "lib/leap/decision.rb",
31
+ "lib/leap/quorum.rb",
32
+ "lib/leap/subject.rb",
33
+ "test/helper.rb",
34
+ "test/test_decider.rb"
35
+ ]
36
+ s.homepage = %q{http://github.com/rossmeissl/leap}
37
+ s.rdoc_options = ["--charset=UTF-8"]
38
+ s.require_paths = ["lib"]
39
+ s.rubygems_version = %q{1.3.6}
40
+ s.summary = %q{A heuristics engine for your Ruby objects}
41
+ s.test_files = [
42
+ "test/helper.rb",
43
+ "test/test_decider.rb"
44
+ ]
45
+
46
+ if s.respond_to? :specification_version then
47
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
48
+ s.specification_version = 3
49
+
50
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
51
+ s.add_development_dependency(%q<shoulda>, [">= 0"])
52
+ s.add_runtime_dependency(%q<blockenspiel>, [">= 0"])
53
+ s.add_runtime_dependency(%q<activesupport>, [">= 2.3.5"])
54
+ else
55
+ s.add_dependency(%q<shoulda>, [">= 0"])
56
+ s.add_dependency(%q<blockenspiel>, [">= 0"])
57
+ s.add_dependency(%q<activesupport>, [">= 2.3.5"])
58
+ end
59
+ else
60
+ s.add_dependency(%q<shoulda>, [">= 0"])
61
+ s.add_dependency(%q<blockenspiel>, [">= 0"])
62
+ s.add_dependency(%q<activesupport>, [">= 2.3.5"])
63
+ end
64
+ end
65
+
@@ -7,6 +7,7 @@ require 'active_support/version'
7
7
  end if ActiveSupport::VERSION::MAJOR == 3
8
8
  require 'blockenspiel'
9
9
 
10
+ require 'leap/core_ext'
10
11
  require 'leap/subject'
11
12
  require 'leap/committee'
12
13
  require 'leap/quorum'
@@ -8,11 +8,9 @@ module Leap
8
8
  end
9
9
 
10
10
  def report(characteristics, considerations)
11
- quorums.detect do |quorum|
11
+ quorums.grab do |quorum|
12
12
  next unless quorum.satisfied_by? characteristics
13
- if conclusion = quorum.acknowledge(characteristics, considerations)
14
- break conclusion
15
- end
13
+ quorum.acknowledge characteristics, considerations
16
14
  end
17
15
  end
18
16
 
@@ -0,0 +1,11 @@
1
+ class Array
2
+ # like detect, but returns the calculated value
3
+ def grab(&blk)
4
+ result = each do |element|
5
+ value = yield element
6
+ break value if value
7
+ end
8
+ return if result == self
9
+ result
10
+ end
11
+ end
@@ -3,8 +3,8 @@ module Leap
3
3
  attr_reader :name, :requirements, :supplements, :process
4
4
  def initialize(name, options, blk)
5
5
  @name = name
6
- @requirements = Array.wrap(options[:needs])
7
- @supplements = Array.wrap(options[:appreciates])
6
+ @requirements = Array.wrap options[:needs]
7
+ @supplements = Array.wrap options[:appreciates]
8
8
  @process = blk
9
9
  end
10
10
 
@@ -13,7 +13,8 @@ module Leap
13
13
  end
14
14
 
15
15
  def acknowledge(characteristics, considerations)
16
- process.call(*considerations.unshift(characteristics)[0...process.arity])
16
+ considerations.unshift characteristics
17
+ process.call *considerations[0...process.arity]
17
18
  end
18
19
  end
19
20
  end
@@ -2,10 +2,8 @@ module Leap
2
2
  module Subject
3
3
  def self.extended(base)
4
4
  base.instance_variable_set :@decisions, {}
5
- class << base
6
- attr_reader :decisions
7
- end
8
5
  end
6
+ attr_reader :decisions
9
7
  def decide(goal, options = {}, &blk)
10
8
  decisions[goal] = ::Leap::Decision.new goal, options
11
9
  Blockenspiel.invoke(blk, decisions[goal])
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 1
7
+ - 2
8
8
  - 0
9
- version: 0.1.0
9
+ version: 0.2.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Andy Rossmeissl
@@ -72,8 +72,10 @@ files:
72
72
  - README.rdoc
73
73
  - Rakefile
74
74
  - VERSION
75
+ - leap.gemspec
75
76
  - lib/leap.rb
76
77
  - lib/leap/committee.rb
78
+ - lib/leap/core_ext.rb
77
79
  - lib/leap/decision.rb
78
80
  - lib/leap/quorum.rb
79
81
  - lib/leap/subject.rb