rulebow 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.index +61 -0
- data/.yardopts +10 -0
- data/HISTORY.md +62 -0
- data/LICENSE.txt +25 -0
- data/README.md +168 -0
- data/bin/bow +4 -0
- data/demo/03_runner/01_applying_rules.md +51 -0
- data/demo/applique/ae.rb +1 -0
- data/demo/applique/rulebow.rb +11 -0
- data/demo/overview.md +0 -0
- data/lib/rulebow.rb +21 -0
- data/lib/rulebow.yml +61 -0
- data/lib/rulebow/cli.rb +181 -0
- data/lib/rulebow/core_ext.rb +3 -0
- data/lib/rulebow/core_ext/boolean.rb +10 -0
- data/lib/rulebow/core_ext/cli.rb +56 -0
- data/lib/rulebow/core_ext/true_class.rb +61 -0
- data/lib/rulebow/digest.rb +240 -0
- data/lib/rulebow/fact.rb +118 -0
- data/lib/rulebow/ignore.rb +136 -0
- data/lib/rulebow/match.rb +26 -0
- data/lib/rulebow/rule.rb +63 -0
- data/lib/rulebow/ruleset.rb +308 -0
- data/lib/rulebow/runner.rb +445 -0
- data/lib/rulebow/shellutils.rb +84 -0
- data/lib/rulebow/system.rb +153 -0
- data/lib/rulebow/watchlist.rb +203 -0
- data/man/.gitignore +2 -0
- data/man/ergo.1.ronn +50 -0
- metadata +151 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: efb2f96a12212f411d2f026740cdbc3b1134b7f6
|
4
|
+
data.tar.gz: e6c235f0892da2fad2bd5b630a9ef32bc0815936
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: fa905ec3302359749739885dcf93ebd069eb20aa20f91ce6116ebe463aa6caa6899e981fc9202fc7b9b2fe17635f7a6733f994eb388650046c8518536df4e2ec
|
7
|
+
data.tar.gz: e3f6ed30330abbc90a777b77ca1e3e33225d861f83988622dd6341c9a1fdea99423d6787458202ae8bf7604b28a8d3ce93ff8a425bbfbda10be626a596297d59
|
data/.index
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
---
|
2
|
+
revision: 2013
|
3
|
+
type: ruby
|
4
|
+
sources:
|
5
|
+
- INDEX.yml
|
6
|
+
authors:
|
7
|
+
- name: trans
|
8
|
+
email: transfire@gmail.com
|
9
|
+
organizations:
|
10
|
+
- name: Rubyworks
|
11
|
+
requirements:
|
12
|
+
- name: notify
|
13
|
+
- groups:
|
14
|
+
- build
|
15
|
+
development: true
|
16
|
+
name: detroit
|
17
|
+
- groups:
|
18
|
+
- build
|
19
|
+
development: true
|
20
|
+
name: mast
|
21
|
+
- groups:
|
22
|
+
- test
|
23
|
+
development: true
|
24
|
+
name: qed
|
25
|
+
- groups:
|
26
|
+
- test
|
27
|
+
development: true
|
28
|
+
name: ae
|
29
|
+
conflicts: []
|
30
|
+
alternatives: []
|
31
|
+
resources:
|
32
|
+
- type: home
|
33
|
+
uri: http://rubyworks.github.com/rulebow
|
34
|
+
label: Homepage
|
35
|
+
- type: code
|
36
|
+
uri: http://github.com/rubyworks/rulebow
|
37
|
+
label: Source Code
|
38
|
+
- type: bugs
|
39
|
+
uri: http://github.com/rubyworks/rulebow/issues
|
40
|
+
label: Issue Tracker
|
41
|
+
repositories:
|
42
|
+
- name: upstream
|
43
|
+
scm: git
|
44
|
+
uri: git://github.com/rubyworks/rulebow.git
|
45
|
+
categories: []
|
46
|
+
copyrights:
|
47
|
+
- holder: Rubyworks
|
48
|
+
year: '2010'
|
49
|
+
license: BSD-2-Clause
|
50
|
+
customs: []
|
51
|
+
paths:
|
52
|
+
lib:
|
53
|
+
- lib
|
54
|
+
name: rulebow
|
55
|
+
title: RULEBOW
|
56
|
+
version: 0.4.0
|
57
|
+
summary: An autological build tool.
|
58
|
+
description: Rulebow is an automated build tool with a set-logic based rule system.
|
59
|
+
Rulebow is the perfect tool for performing continuous integration during development.
|
60
|
+
created: '2010-07-05'
|
61
|
+
date: '2015-02-28'
|
data/.yardopts
ADDED
data/HISTORY.md
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
# RELEASE HISTORY
|
2
|
+
|
3
|
+
## 0.4.0 / 2014-02-29
|
4
|
+
|
5
|
+
This major release renames the project from **Ergo** to **Rulebow**.
|
6
|
+
This will be the last name change. Promise. In addition a number of
|
7
|
+
other adjustments and code improvements have been made. This may be
|
8
|
+
the first release that's actually usable in production.
|
9
|
+
|
10
|
+
Changes:
|
11
|
+
|
12
|
+
* Rename project to Rulebow.
|
13
|
+
* Rename `book` method to `ruleset`.
|
14
|
+
* Rename `state` method to `fact`.
|
15
|
+
* Use single `Rulebook` file.
|
16
|
+
|
17
|
+
|
18
|
+
## 0.3.0 / 2013-02-13
|
19
|
+
|
20
|
+
Major release removes tasks. There are only rules now! In
|
21
|
+
addition *books* have been added which allow rules to be
|
22
|
+
grouped together. Oh! And you might have noticed the name
|
23
|
+
of the project has changed from *Fire* to *Ergo*.
|
24
|
+
|
25
|
+
Changes:
|
26
|
+
|
27
|
+
* Deprecate tasks.
|
28
|
+
* Add rule books.
|
29
|
+
* Rename project to Ergo.
|
30
|
+
|
31
|
+
|
32
|
+
## 0.2.0 / 2013-02-12
|
33
|
+
|
34
|
+
This is the last version with tasks. Tasks are being deprecated
|
35
|
+
for two reasons: a) they add a great deal of complexity to the
|
36
|
+
syntax and the implementation via their need for dependencies;
|
37
|
+
and b) tasks have proven to be an excuse for poorly designed
|
38
|
+
rules, which, if properly written, would do the job just as well
|
39
|
+
if not better than any task. So it was decided that if tasks are
|
40
|
+
needed, then they should be provided via dedicated task system,
|
41
|
+
not via the rules system.
|
42
|
+
|
43
|
+
Changes:
|
44
|
+
|
45
|
+
* Default rule file is now `.fire/rules.rb` or `rules.rb`.
|
46
|
+
* Rules can depend on tasks using same hash notation as tasks.
|
47
|
+
* Modified the `#rule` method to define file rules given a string.
|
48
|
+
* Deprecated the `file` method for defining file rules.
|
49
|
+
|
50
|
+
|
51
|
+
## 0.1.0 / 2012-04-10
|
52
|
+
|
53
|
+
This is the initial release of Fire. Fire is state and rules-based
|
54
|
+
continuous integration and build tool.
|
55
|
+
|
56
|
+
Special thanks to Ari Brown for letting us take over the fire gem
|
57
|
+
for this project.
|
58
|
+
|
59
|
+
Changes:
|
60
|
+
|
61
|
+
* Happy first release day!
|
62
|
+
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
(BSD-2-Clause License)
|
2
|
+
|
3
|
+
Redistribution and use in source and binary forms,
|
4
|
+
with or without modification, are permitted provided that the following
|
5
|
+
conditions are met:
|
6
|
+
|
7
|
+
1. Redistributions of source code must retain the above copyright notice,
|
8
|
+
this list of conditions and the following disclaimer.
|
9
|
+
|
10
|
+
2. Redistributions in binary form must reproduce the above copyright
|
11
|
+
notice, this list of conditions and the following disclaimer in the
|
12
|
+
documentation and/or other materials provided with the distribution.
|
13
|
+
|
14
|
+
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
15
|
+
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
16
|
+
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
17
|
+
COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
18
|
+
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
19
|
+
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
20
|
+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
21
|
+
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
22
|
+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
23
|
+
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
24
|
+
|
25
|
+
|
data/README.md
ADDED
@@ -0,0 +1,168 @@
|
|
1
|
+
# RULEBOW
|
2
|
+
|
3
|
+
[Homepage](http://rubyworks.github.com/rulebow) -
|
4
|
+
[Report Issue](http://github.com/rubyworks/rulebow/issues) -
|
5
|
+
[Source Code](http://github.com/rubyworks/rulebow) -
|
6
|
+
[IRC Channel](http://chat.us.freenode.net/rubyworks)
|
7
|
+
|
8
|
+
***"Hey, you got logic in my build tool!"***
|
9
|
+
|
10
|
+
Rulebow is a build tool that promotes continuous integration via logic
|
11
|
+
programming. With Rulebow, the Ruby developer defines *rules* and state
|
12
|
+
conditions called *facts*. The rules are applied when their conditions
|
13
|
+
are met. Through repetitive application, this allows a project to all
|
14
|
+
but manage itself.
|
15
|
+
|
16
|
+
Rulebow is not complicated. It does not require a bazillion plug-ins.
|
17
|
+
Although some external tools can be helpful and used with it, and
|
18
|
+
it makes some procedures more convenient. For example, it makes
|
19
|
+
FileUtils methods directly available in the build script context.
|
20
|
+
Mostly it just trusts the developer to know how to write the build
|
21
|
+
scripts they need.
|
22
|
+
|
23
|
+
Below you will find a brief "Hot Minute" guide for getting up and
|
24
|
+
running with Rulebow quickly. It's just enough to give you familiarity
|
25
|
+
the basic ideas of Rulebow and how to start putting it to good use.
|
26
|
+
For more detailed instruction, explanation of terms and how the
|
27
|
+
dickens does it work under-the-hood, please consider any of the
|
28
|
+
following resources.
|
29
|
+
|
30
|
+
* [Overview of Rulebow](https://github.com/rubyworks/rulebow/wiki/Overview)
|
31
|
+
* [Helpful FAQs](https://github.com/rubyworks/rulebow/wiki/FAQ)
|
32
|
+
* [Rulebow Recepies](https://github.com/rubyworks/rulebow/wiki/Recipes)
|
33
|
+
* [API Documentation](http://rubydoc.info/gems/rulebow/frames)
|
34
|
+
|
35
|
+
|
36
|
+
## Rulebow in a Hot Minute
|
37
|
+
|
38
|
+
To install, either use RubyGems directly:
|
39
|
+
|
40
|
+
```
|
41
|
+
$ gem install rulebow
|
42
|
+
```
|
43
|
+
|
44
|
+
Or add `gem "rulebow"` to your Gemfile and run:
|
45
|
+
|
46
|
+
```
|
47
|
+
$ bundle
|
48
|
+
```
|
49
|
+
|
50
|
+
Creat a `Rulebook` file in your project.
|
51
|
+
|
52
|
+
```
|
53
|
+
$ vi Rulebook
|
54
|
+
```
|
55
|
+
|
56
|
+
And add the following example script to the file.
|
57
|
+
|
58
|
+
```ruby
|
59
|
+
ruleset :default => [:manifest, :test]
|
60
|
+
|
61
|
+
ruleset :manifest do
|
62
|
+
desc "update manifest"
|
63
|
+
|
64
|
+
globs = %w[bin/**/* lib/**/* *.md]
|
65
|
+
|
66
|
+
fact :need_manifest? do
|
67
|
+
if File.exist?('MANIFEST')
|
68
|
+
files = globs.map{ |d| Dir[d] }.flatten
|
69
|
+
saved = File.readlines('MANIFEST').map{ |f| f.strip }
|
70
|
+
files != saved
|
71
|
+
else
|
72
|
+
true
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
rule :need_manifest? do
|
77
|
+
files = globs.map{ |d| Dir[d] }.flatten
|
78
|
+
File.open('MANIFEST', 'w'){ |f| f << files.join("\n") }
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
ruleset :test do
|
83
|
+
desc "run my minitests"
|
84
|
+
|
85
|
+
rule 'lib/**/*.rb' do |libs|
|
86
|
+
$: << 'lib'
|
87
|
+
files = Dir.glob('test/**/*_test.rb')
|
88
|
+
files.each{|file| require "./" + file}
|
89
|
+
end
|
90
|
+
```
|
91
|
+
|
92
|
+
Now run it with:
|
93
|
+
|
94
|
+
$ bow
|
95
|
+
|
96
|
+
And there you go. Rulebow, in a hot minute!
|
97
|
+
|
98
|
+
|
99
|
+
## A Few More Minutes
|
100
|
+
|
101
|
+
As the capable Ruby programmer, it probable doesn't require much explanation
|
102
|
+
to understand the above code and what happened when you ran it. Just the
|
103
|
+
same, it can help to go over it with the proper terminology. Of course,
|
104
|
+
the rules in our example are simplistic and they make some basic
|
105
|
+
assumptions about a project, so you will want to modify these to suite your
|
106
|
+
needs (or dispose of them and write fresh). Nonetheless, this example
|
107
|
+
provides some clear examples of the basics of writing Rulebow scripts.
|
108
|
+
|
109
|
+
The first line in the script defines the defauly ruleset. This is the
|
110
|
+
ruleset the is executes when no specific ruleset is designated on
|
111
|
+
the command line. In this case we see that it simply depends on two
|
112
|
+
other rulesets, `test` and `manifest`.
|
113
|
+
|
114
|
+
Nex in the example we create the `manifest` ruleset. In it we first
|
115
|
+
create a *state* called `update_manifest?`. It simply checks to see
|
116
|
+
if the list of files in the project's MANIFEST file matches the project
|
117
|
+
files expected to be there. Notice it returns a boolean value, true or
|
118
|
+
false. Along with this state we create a *rule* that uses the state by
|
119
|
+
calling the `update_manifest?` method. This method was created by the
|
120
|
+
state definition above. The *rule procedure* updates the MANIFEST file
|
121
|
+
whenever the state returns `true`, i.e. the manifest does not have the
|
122
|
+
expected content.
|
123
|
+
|
124
|
+
At the end of our example script we create an additional ruleset. This
|
125
|
+
one does not reference a defined state. Instead it creates a *file state*
|
126
|
+
implicitly by passing a string argument to `rule`. A file state has a
|
127
|
+
very simple and very useful definition. It returns `true` whenever a
|
128
|
+
matching file has changed from one execution of `rulebow` to the next.
|
129
|
+
In other words, per this example, whenever a Ruby file in the `lib`
|
130
|
+
directory changes, Rulebow is going to run the units tests in the `test`
|
131
|
+
directory.
|
132
|
+
|
133
|
+
Okay, so now we have an example rulebook and have a basic grasp of
|
134
|
+
how it works. And we know we can run the rules simple by invoking the
|
135
|
+
`rulebow` command on the command line. But if we want to have rulebow run
|
136
|
+
automatically periodically, we can pass it the number of seconds to
|
137
|
+
wait between runs via the `-a/--auto` option.
|
138
|
+
|
139
|
+
$ bow -a 180
|
140
|
+
|
141
|
+
See it pays to read all the way to the end ;)
|
142
|
+
|
143
|
+
|
144
|
+
## Contributing
|
145
|
+
|
146
|
+
The Rulebow [repository](http://github.com/rubyworks/rulebow) is hosted on GitHub.
|
147
|
+
If you would like to contribute to the project (and we would be over joyed
|
148
|
+
if you did!) the rules of engagements are very simple.
|
149
|
+
|
150
|
+
1. Fork the repo.
|
151
|
+
2. Branch the repo.
|
152
|
+
3. Code and test.
|
153
|
+
4. Push the branch.
|
154
|
+
4. Submit pull request.
|
155
|
+
|
156
|
+
|
157
|
+
## Copyrights
|
158
|
+
|
159
|
+
Rulebow is copyrighted open-source software.
|
160
|
+
|
161
|
+
Copyright (c) 2011 Rubyworks. All rights reserved.
|
162
|
+
|
163
|
+
It is modifiable and redistributable under the terms of the
|
164
|
+
[BSD-2-Clause](http::/spdx.org/licenses/BSD-2-Clause) license.
|
165
|
+
|
166
|
+
See the enclosed LICENSE.txt file for details.
|
167
|
+
|
168
|
+
(火 由)
|
data/bin/bow
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
## Applying Rules
|
2
|
+
|
3
|
+
The `Runner` class handles running rules. It takes `System` as an argument and
|
4
|
+
can run all applicable rules of a specific book.
|
5
|
+
|
6
|
+
### True/False Rules
|
7
|
+
|
8
|
+
The simplist rule state is `true`, which means it will always run, or
|
9
|
+
`false` which means it will never run. These states are not very useful,
|
10
|
+
but they should still work.
|
11
|
+
|
12
|
+
Given a @system and a @ruleset defined with a simple always-true rule,
|
13
|
+
and another always-false rule:
|
14
|
+
|
15
|
+
rule(true) do
|
16
|
+
assert true
|
17
|
+
end
|
18
|
+
|
19
|
+
rule(false) do
|
20
|
+
assert false
|
21
|
+
end
|
22
|
+
|
23
|
+
Then the Runner should run the true rule and not the false rule when
|
24
|
+
applying the system's rules.
|
25
|
+
|
26
|
+
runner = Rulebow::Runner.new(:system=>@system)
|
27
|
+
|
28
|
+
runner.run('example')
|
29
|
+
|
30
|
+
### Simple State Rule
|
31
|
+
|
32
|
+
Given a @system and a @ruleset defined with a simple state:
|
33
|
+
|
34
|
+
def simple
|
35
|
+
true
|
36
|
+
end
|
37
|
+
|
38
|
+
rule :simple do
|
39
|
+
assert true
|
40
|
+
end
|
41
|
+
|
42
|
+
rule false do
|
43
|
+
assert false
|
44
|
+
end
|
45
|
+
|
46
|
+
Then the Runner should run the simple rule, but not the other.
|
47
|
+
|
48
|
+
runner = Rulebow::Runner.new(:system=>@system)
|
49
|
+
|
50
|
+
runner.run('example')
|
51
|
+
|
data/demo/applique/ae.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'ae'
|
data/demo/overview.md
ADDED
File without changes
|
data/lib/rulebow.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# ruby standard library
|
2
|
+
require 'fileutils'
|
3
|
+
require 'digest/sha1'
|
4
|
+
require 'ostruct'
|
5
|
+
|
6
|
+
# third party library
|
7
|
+
require 'notify'
|
8
|
+
|
9
|
+
# internal library
|
10
|
+
require_relative 'rulebow/core_ext'
|
11
|
+
require_relative 'rulebow/match'
|
12
|
+
require_relative 'rulebow/shellutils'
|
13
|
+
require_relative 'rulebow/fact'
|
14
|
+
require_relative 'rulebow/rule'
|
15
|
+
#require_relative 'rulebow/ignore'
|
16
|
+
require_relative 'rulebow/watchlist'
|
17
|
+
require_relative 'rulebow/digest'
|
18
|
+
require_relative 'rulebow/ruleset'
|
19
|
+
require_relative 'rulebow/system'
|
20
|
+
require_relative 'rulebow/runner'
|
21
|
+
require_relative 'rulebow/cli'
|
data/lib/rulebow.yml
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
---
|
2
|
+
revision: 2013
|
3
|
+
type: ruby
|
4
|
+
sources:
|
5
|
+
- INDEX.yml
|
6
|
+
authors:
|
7
|
+
- name: trans
|
8
|
+
email: transfire@gmail.com
|
9
|
+
organizations:
|
10
|
+
- name: Rubyworks
|
11
|
+
requirements:
|
12
|
+
- name: notify
|
13
|
+
- groups:
|
14
|
+
- build
|
15
|
+
development: true
|
16
|
+
name: detroit
|
17
|
+
- groups:
|
18
|
+
- build
|
19
|
+
development: true
|
20
|
+
name: mast
|
21
|
+
- groups:
|
22
|
+
- test
|
23
|
+
development: true
|
24
|
+
name: qed
|
25
|
+
- groups:
|
26
|
+
- test
|
27
|
+
development: true
|
28
|
+
name: ae
|
29
|
+
conflicts: []
|
30
|
+
alternatives: []
|
31
|
+
resources:
|
32
|
+
- type: home
|
33
|
+
uri: http://rubyworks.github.com/rulebow
|
34
|
+
label: Homepage
|
35
|
+
- type: code
|
36
|
+
uri: http://github.com/rubyworks/rulebow
|
37
|
+
label: Source Code
|
38
|
+
- type: bugs
|
39
|
+
uri: http://github.com/rubyworks/rulebow/issues
|
40
|
+
label: Issue Tracker
|
41
|
+
repositories:
|
42
|
+
- name: upstream
|
43
|
+
scm: git
|
44
|
+
uri: git://github.com/rubyworks/rulebow.git
|
45
|
+
categories: []
|
46
|
+
copyrights:
|
47
|
+
- holder: Rubyworks
|
48
|
+
year: '2010'
|
49
|
+
license: BSD-2-Clause
|
50
|
+
customs: []
|
51
|
+
paths:
|
52
|
+
lib:
|
53
|
+
- lib
|
54
|
+
name: rulebow
|
55
|
+
title: RULEBOW
|
56
|
+
version: 0.4.0
|
57
|
+
summary: An autological build tool.
|
58
|
+
description: Rulebow is an automated build tool with a set-logic based rule system.
|
59
|
+
Rulebow is the perfect tool for performing continuous integration during development.
|
60
|
+
created: '2010-07-05'
|
61
|
+
date: '2015-02-28'
|