rools 0.1.3 → 0.1.4

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/CHANGELOG CHANGED
@@ -1,9 +1,17 @@
1
- - 0.1.1
2
- Added RuleConsequenceError
3
-
1
+ - 0.1.4
2
+ * Removed "examples" folder since my RDoc kung-fu cannot be denied and the examples were redundant
3
+ * Added Rools::open to rools.rb
4
+ * Added pscp.rb to create SshPublishers on Win32 with PuttySCP
5
+ * Added Rools::RuleSet#assert return codes, :pass and :fail
6
+ * Added stop and fail methods to RuleSet, Rules, and DefaultParameterProc
7
+ * Built Gem under Ruby 1.8.2 to fix yaml bug for RubyForge distribution
8
+
9
+ - 0.1.3
10
+ Finished most documentation
11
+ Tweaked the rakefile
12
+
4
13
  - 0.1.2
5
14
  Added RAKEFILE, README, CHANGELOG
6
15
 
7
- - 0.1.3
8
- Finished most documentation
9
- Tweaked the rakefile
16
+ - 0.1.1
17
+ Added RuleConsequenceError
data/RAKEFILE CHANGED
@@ -5,13 +5,12 @@ require 'rake/gempackagetask'
5
5
  require 'rake/contrib/rubyforgepublisher'
6
6
  require 'pscp'
7
7
 
8
- PACKAGE_VERSION = '0.1.3'
8
+ PACKAGE_VERSION = '0.1.4'
9
9
 
10
10
  PACKAGE_FILES = FileList[
11
11
  'README',
12
12
  'CHANGELOG',
13
13
  'RAKEFILE',
14
- 'lib/rools.rb',
15
14
  'lib/**/*.rb'
16
15
  ].to_a
17
16
 
@@ -21,7 +20,7 @@ ENV['RUBYFORGE_USER'] = "ssmoot@rubyforge.org"
21
20
  ENV['RUBYFORGE_PROJECT'] = "/var/www/gforge-projects/#{PROJECT}"
22
21
 
23
22
  desc 'Release Files'
24
- task :default => [:rdoc, :gem]
23
+ task :default => [:rdoc]
25
24
 
26
25
  # Generate the RDoc documentation
27
26
  rd = Rake::RDocTask.new do |rdoc|
@@ -63,5 +62,4 @@ end
63
62
  desc "Publish RDOC to RubyForge"
64
63
  task :rubyforge => [:rdoc, :gem] do
65
64
  Rake::SshDirPublisher.new(ENV['RUBYFORGE_USER'], ENV['RUBYFORGE_PROJECT'], 'doc').upload
66
- Rake::SshFilePublisher.new(ENV['RUBYFORGE_USER'], ENV['RUBYFORGE_PROJECT'], 'pkg', "#{PROJECT}-#{PACKAGE_VERSION}.gem").upload
67
65
  end
data/README CHANGED
@@ -1,4 +1,5 @@
1
- = rools -- A pure-ruby rules engine
1
+ :nodoc: YOU SHOULD NOT BE VIEWING THIS FILE DIRECTLY. PLEASE USE: gem_server
2
+ = Rools -- A pure ruby rules-engine
2
3
 
3
4
  Rools is a rules engine for abstracting business logic and program-flow. It's ideally suited to processing applications where the business logic undergoes frequent modification.
4
5
 
@@ -1,5 +1,15 @@
1
+ require 'rools/errors'
2
+ require 'rools/default_parameter_proc'
1
3
  require 'rools/rule_set'
4
+ require 'rools/rule'
2
5
 
3
- # Test Documentation
6
+ # All classes are contained in the Rools module
4
7
  module Rools
8
+
9
+ @@rule_sets = {}
10
+
11
+ # open aliases Rools::RuleSet.new, and caches RuleSets loaded by path
12
+ def self.open(path = nil, &b)
13
+ path.nil? ? Rools::RuleSet.new(path, &b) : (@@rule_sets[path] ||= Rools::RuleSet.new(path))
14
+ end
5
15
  end
@@ -47,5 +47,14 @@ module Rools
47
47
  return @working_object if @working_object && args.size == 0
48
48
  end
49
49
 
50
+ # Stops the current assertion. Does not indicate failure.
51
+ def stop(message = nil)
52
+ @rule.stop(message)
53
+ end
54
+
55
+ # Stops the current assertion and change status to :fail
56
+ def fail(message = nil)
57
+ @rule.fail(message)
58
+ end
50
59
  end
51
60
  end
@@ -103,5 +103,15 @@ module Rools
103
103
  raise RuleConsequenceError.new(rule, e)
104
104
  end
105
105
  end
106
+
107
+ # Stops the current assertion. Does not indicate failure.
108
+ def stop(message = nil)
109
+ @rule_set.stop(message)
110
+ end
111
+
112
+ # Stops the current assertion and change status to :fail
113
+ def fail(message = nil)
114
+ @rule_set.fail(message)
115
+ end
106
116
  end
107
117
  end
@@ -3,6 +3,10 @@ require 'rools/rule'
3
3
 
4
4
  module Rools
5
5
  class RuleSet
6
+
7
+ PASS = :pass
8
+ FAIL = :fail
9
+
6
10
  # You can pass a set of Rools::Rules with a block parameter,
7
11
  # or you can pass a file-path to evaluate.
8
12
  def initialize(file = nil, &b)
@@ -52,9 +56,22 @@ module Rools
52
56
  (@dependencies[@extend_rule_name] ||= []) << Rule.new(self, name, b)
53
57
  end
54
58
 
59
+ # Stops the current assertion. Does not indicate failure.
60
+ def stop(message = nil)
61
+ @assert = false
62
+ end
63
+
64
+ # Stops the current assertion and change status to :fail
65
+ def fail(message = nil)
66
+ @status = FAIL
67
+ @assert = false
68
+ end
69
+
55
70
  # Used to create a working-set of rules for an object, and evaluate it
56
- # against them.
71
+ # against them. Returns a status, simply PASS or FAIL
57
72
  def assert(obj)
73
+ @status = PASS
74
+ @assert = true
58
75
 
59
76
  # create a working-set of all parameter-matching, non-dependent rules
60
77
  available_rules = @rules.values.select { |rule| rule.parameters_match?(obj) }
@@ -100,13 +117,17 @@ module Rools
100
117
 
101
118
  end # available_rules.each
102
119
 
103
- end while(matches)
120
+ end while(matches && @assert)
104
121
 
105
122
  rescue RuleConsequenceError => rce
106
123
  # RuleConsequenceErrors are allowed to break out of the current assertion,
107
124
  # then the inner error is bubbled-up to the asserting code.
108
125
  raise rce.inner_error
109
126
  end
127
+
128
+ @assert = false
129
+
130
+ return status
110
131
  end # def assert
111
132
 
112
133
  end # class RuleSet
metadata CHANGED
@@ -1,58 +1,53 @@
1
- !ruby/object:Gem::Specification
2
- rubygems_version: 0.8.11
1
+ --- !ruby/object:Gem::Specification
2
+ rubygems_version: 0.8.10
3
3
  specification_version: 1
4
4
  name: rools
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.1.3
7
- date: 2005-12-12 00:00:00 -06:00
6
+ version: 0.1.4
7
+ date: 2005-12-14
8
8
  summary: A Rules Engine written in Ruby
9
9
  require_paths:
10
- - lib
10
+ - lib
11
11
  email: ssmoot@gmail.com; bauer.mail@gmail.com
12
12
  homepage: http://substantiality.net
13
13
  rubyforge_project: rools
14
- description: Can be used for program-flow, ideally suited to processing applications
14
+ description: "Can be used for program-flow, ideally suited to processing applications"
15
15
  autorequire: rools
16
16
  default_executable:
17
17
  bindir: bin
18
18
  has_rdoc: true
19
19
  required_ruby_version: !ruby/object:Gem::Version::Requirement
20
20
  requirements:
21
- - - ">"
22
- - !ruby/object:Gem::Version
23
- version: 0.0.0
21
+ -
22
+ - ">"
23
+ - !ruby/object:Gem::Version
24
+ version: 0.0.0
24
25
  version:
25
26
  platform: ruby
26
- signing_key:
27
- cert_chain:
28
27
  authors:
29
- - Sam Smoot
30
- - Scott Bauer
28
+ - Sam Smoot
29
+ - Scott Bauer
31
30
  files:
32
- - README
33
- - CHANGELOG
34
- - RAKEFILE
35
- - lib/rools.rb
36
- - lib/rools/default_parameter_proc.rb
37
- - lib/rools/errors.rb
38
- - lib/rools/rule.rb
39
- - lib/rools/rule_set.rb
31
+ - README
32
+ - CHANGELOG
33
+ - RAKEFILE
34
+ - lib/rools.rb
35
+ - lib/rools/default_parameter_proc.rb
36
+ - lib/rools/errors.rb
37
+ - lib/rools/rule.rb
38
+ - lib/rools/rule_set.rb
40
39
  test_files: []
41
-
42
40
  rdoc_options:
43
- - --line-numbers
44
- - --inline-source
45
- - --main
46
- - README
41
+ - "--line-numbers"
42
+ - "--inline-source"
43
+ - "--main"
44
+ - README
47
45
  extra_rdoc_files:
48
- - README
49
- - CHANGELOG
50
- - RAKEFILE
46
+ - README
47
+ - CHANGELOG
48
+ - RAKEFILE
51
49
  executables: []
52
-
53
50
  extensions: []
54
-
55
51
  requirements:
56
- - none
57
- dependencies: []
58
-
52
+ - none
53
+ dependencies: []