ergo 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.index +62 -0
- data/.yardopts +10 -0
- data/HISTORY.md +47 -0
- data/LICENSE.txt +25 -0
- data/README.md +161 -0
- data/bin/ergo +4 -0
- data/demo/03_runner/01_applying_rules.md +51 -0
- data/demo/applique/ae.rb +1 -0
- data/demo/applique/ergo.rb +7 -0
- data/demo/overview.md +0 -0
- data/lib/ergo.rb +20 -0
- data/lib/ergo.yml +62 -0
- data/lib/ergo/book.rb +218 -0
- data/lib/ergo/cli.rb +185 -0
- data/lib/ergo/core_ext.rb +4 -0
- data/lib/ergo/core_ext/boolean.rb +10 -0
- data/lib/ergo/core_ext/cli.rb +56 -0
- data/lib/ergo/core_ext/true_class.rb +58 -0
- data/lib/ergo/digest.rb +196 -0
- data/lib/ergo/ignore.rb +146 -0
- data/lib/ergo/match.rb +26 -0
- data/lib/ergo/rule.rb +134 -0
- data/lib/ergo/runner.rb +377 -0
- data/lib/ergo/shellutils.rb +79 -0
- data/lib/ergo/state.rb +112 -0
- data/lib/ergo/system.rb +51 -0
- data/man/.gitignore +2 -0
- data/man/ergo.1.ronn +50 -0
- metadata +163 -0
data/.index
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
---
|
2
|
+
revision: 2013
|
3
|
+
type: ruby
|
4
|
+
sources:
|
5
|
+
- var
|
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/ergo
|
34
|
+
label: Homepage
|
35
|
+
- type: code
|
36
|
+
uri: http://github.com/rubyworks/ergo
|
37
|
+
label: Source Code
|
38
|
+
- type: bugs
|
39
|
+
uri: http://github.com/rubyworks/ergo/issues
|
40
|
+
label: Issue Tracker
|
41
|
+
repositories:
|
42
|
+
- name: upstream
|
43
|
+
scm: git
|
44
|
+
uri: git://github.com/rubyworks/ergo.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
|
+
created: '2010-07-05'
|
55
|
+
summary: The best build tool, logically!
|
56
|
+
title: Ergo
|
57
|
+
version: 0.3.0
|
58
|
+
name: ergo
|
59
|
+
description: ! 'Ergo is an automated build tool with a slick set-logic based
|
60
|
+
|
61
|
+
state/rules system, perfect for performing continuous integration.'
|
62
|
+
date: '2013-02-16'
|
data/.yardopts
ADDED
data/HISTORY.md
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
# RELEASE HISTORY
|
2
|
+
|
3
|
+
## 0.3.0 / 2013-02-13
|
4
|
+
|
5
|
+
Major release removes tasks. There are only rules now! In
|
6
|
+
addition *books* have been added which allow rules to be
|
7
|
+
grouped together. Oh! And you might have noticed the name
|
8
|
+
of the project has changed from *Fire* to *Ergo*.
|
9
|
+
|
10
|
+
Changes:
|
11
|
+
|
12
|
+
* Deprecate tasks.
|
13
|
+
* Add rule books.
|
14
|
+
* Rename project to Ergo.
|
15
|
+
|
16
|
+
|
17
|
+
## 0.2.0 / 2013-02-12
|
18
|
+
|
19
|
+
This is the last version with tasks. Tasks are being deprecated
|
20
|
+
for two reasons: a) they add a great deal of complexity to the
|
21
|
+
syntax and the implementation via their need for dependencies;
|
22
|
+
and b) tasks have proven to be an excuse for poorly designed
|
23
|
+
rules, which, if properly written, would do the job just as well
|
24
|
+
if not better than any task. So it was decided that if tasks are
|
25
|
+
needed, then they should be provided via dedicated task system,
|
26
|
+
not via the rules system.
|
27
|
+
|
28
|
+
Changes:
|
29
|
+
|
30
|
+
* Default rule file is now `.fire/rules.rb` or `rules.rb`.
|
31
|
+
* Rules can depend on tasks using same hash notation as tasks.
|
32
|
+
* Modified the `#rule` method to define file rules given a string.
|
33
|
+
* Deprecated the `file` method for defining file rules.
|
34
|
+
|
35
|
+
|
36
|
+
## 0.1.0 / 2012-04-10
|
37
|
+
|
38
|
+
This is the initial release of Fire. Fire is state and rules-based
|
39
|
+
continuous integration and build tool.
|
40
|
+
|
41
|
+
Special thanks to Ari Brown for letting us take over the fire gem
|
42
|
+
for this project. "Fire" is perfect fit.
|
43
|
+
|
44
|
+
Changes:
|
45
|
+
|
46
|
+
* Happy first release day!
|
47
|
+
|
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,161 @@
|
|
1
|
+
# Ergo 由
|
2
|
+
|
3
|
+
[Homepage](http://rubyworks.github.com/ergo) /
|
4
|
+
[Report Issue](http://github.com/rubyworks/ergo/issues) /
|
5
|
+
[Source Code](http://github.com/rubyworks/ergo) /
|
6
|
+
[IRC Channel](http://chat.us.freenode.net/rubyworks)
|
7
|
+
|
8
|
+
***"Logic programming meets the build tool."***
|
9
|
+
|
10
|
+
Ergo is a build tool that promotes continuous integration via logic
|
11
|
+
programming. With Ergo, the Ruby developer defines rules and state
|
12
|
+
conditions. The rules are applied when their state conditions are
|
13
|
+
met. Through repetitive application, this allows a project to all
|
14
|
+
but manage itself.
|
15
|
+
|
16
|
+
Ergo is not complicated. It goes 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 Ergo quickly. It's just enough to give you familiarity
|
25
|
+
the basic ideas of Ergo 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 Ergo](https://github.com/rubyworks/ergo/wiki/Overview-of-Ergo)
|
31
|
+
* [Helpful FAQs](https://github.com/rubyworks/ergo/wiki/FAQ)
|
32
|
+
* [Ergo Recepies](https://github.com/rubyworks/ergo/wiki/Ergo-Recipes)
|
33
|
+
* [API Documentation](http://rubydoc.info/gems/ergo/frames)
|
34
|
+
|
35
|
+
|
36
|
+
## Ergo in a Hot Minute
|
37
|
+
|
38
|
+
To install, either use RubyGems directly:
|
39
|
+
|
40
|
+
```
|
41
|
+
$ gem install ergo
|
42
|
+
```
|
43
|
+
|
44
|
+
Or add `gem "ergo"` to your Gemfile and run:
|
45
|
+
|
46
|
+
```
|
47
|
+
$ bundle install
|
48
|
+
```
|
49
|
+
|
50
|
+
Create a `.ergo` directory in your project.
|
51
|
+
|
52
|
+
```
|
53
|
+
$ mkdir .ergo
|
54
|
+
```
|
55
|
+
|
56
|
+
Edit the `.ergo/script.rb` file.
|
57
|
+
|
58
|
+
```
|
59
|
+
$ vi .ergo/script.rb
|
60
|
+
```
|
61
|
+
|
62
|
+
And add the following example script to the file.
|
63
|
+
|
64
|
+
```ruby
|
65
|
+
manifest = %w[bin/**/* lib/**/* *.md]
|
66
|
+
|
67
|
+
state :need_manifest? do
|
68
|
+
if File.exist?('MANIFEST')
|
69
|
+
files = manifest.map{ |d| Dir[d] }.flatten
|
70
|
+
saved = File.readlines('MANIFEST').map{ |f| f.strip }
|
71
|
+
files != saved
|
72
|
+
else
|
73
|
+
true
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
desc "update manifest"
|
78
|
+
rule need_manifest? do
|
79
|
+
files = manifest.map{ |d| Dir[d] }.flatten
|
80
|
+
File.open('MANIFEST', 'w'){ |f| f << files.join("\n") }
|
81
|
+
end
|
82
|
+
|
83
|
+
desc "run my minitests"
|
84
|
+
rule 'lib/**/*.rb' do |libs|
|
85
|
+
$: << 'lib'
|
86
|
+
files = Dir.glob('test/**/*_test.rb')
|
87
|
+
files.each{|file| require "./" + file}
|
88
|
+
end
|
89
|
+
```
|
90
|
+
|
91
|
+
Now run it with:
|
92
|
+
|
93
|
+
$ ergo
|
94
|
+
|
95
|
+
And there you go. Ergo, in a hot minute!
|
96
|
+
|
97
|
+
|
98
|
+
## A Few More Minutes
|
99
|
+
|
100
|
+
As the capable Ruby programmer, it probable doesn't require much explanation
|
101
|
+
to understand the above code and what happened when you ran it. Just the
|
102
|
+
same it can help to go over it with the proper terminology. Of course,
|
103
|
+
the rules in our example are simplistic and they make some basic
|
104
|
+
assumptions about a project, so you will want to modify these to suite your
|
105
|
+
needs (or dispose of them and write fresh). Nonetheless, this example
|
106
|
+
provides some clear examples of the basics of writing Ergo scripts.
|
107
|
+
|
108
|
+
In the example we first create a *state* called `update_manifest?`. It
|
109
|
+
simply checks to see if the list of files in the project's MANIFEST
|
110
|
+
file matches the project files expected to be there. Notice it returns
|
111
|
+
a boolean value, true or false. Along with this state we create a *rule*
|
112
|
+
that uses the state by calling the `update_manifest?` method. This method
|
113
|
+
was created by the state definition above. The *rule procedure* updates the
|
114
|
+
MANIFEST file whenever the state return `true`, i.e. the manifest does
|
115
|
+
not have the expected content.
|
116
|
+
|
117
|
+
At the end of our example script we create an additional rule. This
|
118
|
+
one does not reference a defined state. Instead it create a *file state*
|
119
|
+
implicitly by passing a string argument to `rule`. A file state has a
|
120
|
+
very simple and very useful definition. It returns `true` whenever a
|
121
|
+
matching file has changed from one execution of `ergo` to the next.
|
122
|
+
In other words, per this example, whenever a Ruby file in the `lib`
|
123
|
+
directory changes, Ergo is going to run the units tests in the `test`
|
124
|
+
directory.
|
125
|
+
|
126
|
+
Okay, so now we have a example rules script and have a basic grasp of
|
127
|
+
how it works. And we know we can run the rules simple by invoking the
|
128
|
+
`ergo` command on command line. But if we want to have ergo run
|
129
|
+
automatically periodically, we can pass it the number of seconds to
|
130
|
+
wait between runs via the `-a/--auto` option.
|
131
|
+
|
132
|
+
$ ergo -a 180
|
133
|
+
|
134
|
+
See it pays to read all the way to the end ;)
|
135
|
+
|
136
|
+
|
137
|
+
## Contributing
|
138
|
+
|
139
|
+
The Ergo [repository](http://github.com/rubyworks/ergo) is hosted on GitHub.
|
140
|
+
If you would like to contribute to the project (and we would be over joyed
|
141
|
+
if you did!) the rules of engagements are very simple.
|
142
|
+
|
143
|
+
1. Fork the repo.
|
144
|
+
2. Branch the repo.
|
145
|
+
3. Code and test.
|
146
|
+
4. Push the branch.
|
147
|
+
4. Submit pull request.
|
148
|
+
|
149
|
+
|
150
|
+
## Copyrights
|
151
|
+
|
152
|
+
Ergo is copyrighted open-source software.
|
153
|
+
|
154
|
+
Copyright (c) 2011 Rubyworks. All rights reserved.
|
155
|
+
|
156
|
+
It is modifiable and redistributable under the terms of the
|
157
|
+
[BSD-2-Clause](http::/spdx.org/licenses/BSD-2-Clause) license.
|
158
|
+
|
159
|
+
See the enclosed LICENSE.txt file for details.
|
160
|
+
|
161
|
+
(火)
|
data/bin/ergo
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 or a specific book of rules.
|
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 defined with a simple always-true rule, and another
|
13
|
+
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 = Ergo::Runner.new(:system=>@system, :root=>Dir.pwd)
|
27
|
+
|
28
|
+
runner.run
|
29
|
+
|
30
|
+
### Simple State Rule
|
31
|
+
|
32
|
+
Given a @system defined with a simple state:
|
33
|
+
|
34
|
+
state :simple do
|
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 = Ergo::Runner.new(:system=>@system)
|
49
|
+
|
50
|
+
runner.run
|
51
|
+
|
data/demo/applique/ae.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'ae'
|
data/demo/overview.md
ADDED
File without changes
|
data/lib/ergo.rb
ADDED
@@ -0,0 +1,20 @@
|
|
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 'ergo/core_ext'
|
11
|
+
require_relative 'ergo/match'
|
12
|
+
require_relative 'ergo/shellutils'
|
13
|
+
require_relative 'ergo/state'
|
14
|
+
require_relative 'ergo/rule'
|
15
|
+
require_relative 'ergo/ignore'
|
16
|
+
require_relative 'ergo/digest'
|
17
|
+
require_relative 'ergo/book'
|
18
|
+
require_relative 'ergo/system'
|
19
|
+
require_relative 'ergo/runner'
|
20
|
+
require_relative 'ergo/cli'
|
data/lib/ergo.yml
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
---
|
2
|
+
revision: 2013
|
3
|
+
type: ruby
|
4
|
+
sources:
|
5
|
+
- var
|
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/ergo
|
34
|
+
label: Homepage
|
35
|
+
- type: code
|
36
|
+
uri: http://github.com/rubyworks/ergo
|
37
|
+
label: Source Code
|
38
|
+
- type: bugs
|
39
|
+
uri: http://github.com/rubyworks/ergo/issues
|
40
|
+
label: Issue Tracker
|
41
|
+
repositories:
|
42
|
+
- name: upstream
|
43
|
+
scm: git
|
44
|
+
uri: git://github.com/rubyworks/ergo.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
|
+
created: '2010-07-05'
|
55
|
+
summary: The best build tool, logically!
|
56
|
+
title: Ergo
|
57
|
+
version: 0.3.0
|
58
|
+
name: ergo
|
59
|
+
description: ! 'Ergo is an automated build tool with a slick set-logic based
|
60
|
+
|
61
|
+
state/rules system, perfect for performing continuous integration.'
|
62
|
+
date: '2013-02-16'
|