ergo 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,112 @@
1
+ module Ergo
2
+
3
+ ##
4
+ # Ergo's logic system is a *set logic* system. That means an empty set, `[]`
5
+ # is treated as `false` and a non-empty set is `true`.
6
+ #
7
+ # Ergo handles complex logic by building-up lazy logic constructs. It's logical
8
+ # operators are defined using single charcter symbols, e.g. `&` and `|`.
9
+ #
10
+ class State
11
+ def initialize(&procedure)
12
+ @procedure = procedure
13
+ end
14
+
15
+ def call(digest)
16
+ set @procedure.call(digest)
17
+ end
18
+
19
+ # set or
20
+ def |(other)
21
+ State.new{ |d| set(self.call(d)) | set(other.call(d)) }
22
+ end
23
+
24
+ # set and
25
+ def &(other)
26
+ State.new{ |d| set(self.call(d)) & set(other.call(d)) }
27
+ end
28
+
29
+ private
30
+
31
+ #
32
+ def set(value)
33
+ case value
34
+ when Array
35
+ value.compact
36
+ when Boolean
37
+ value ? true : []
38
+ else
39
+ [value]
40
+ end
41
+ end
42
+
43
+ end
44
+
45
+ ##
46
+ # This subclass of State is specialized for file change conditions.
47
+ #
48
+ class FileState < State
49
+ # Initialize new instance of FileState.
50
+ #
51
+ # pattern - File glob or regular expression. [String,Regexp]
52
+ # digest - The system digest. [Digest]
53
+ #
54
+ def initialize(pattern) #, digest)
55
+ @pattern = pattern
56
+ #@digest = digest
57
+ end
58
+
59
+ # File glob or regular expression.
60
+ attr :pattern
61
+
62
+ # The digest. [Digest]
63
+ #attr :digest
64
+
65
+ # Process logic.
66
+ def call(digest)
67
+ result = []
68
+
69
+ case pattern
70
+ when Regexp
71
+ list = Dir.glob('**/*', File::FNM_PATHNAME)
72
+ list = digest.filter(list) # apply ignore
73
+ list.each do |fname|
74
+ if md = pattern.match(fname)
75
+ if digest.current[fname] != digest.saved[fname]
76
+ result << Match.new(fname, md)
77
+ end
78
+ end
79
+ end
80
+ # NOTE: The problem with using the digest list, is that if a rule
81
+ # adds a new file to the project, then a subsequent rule needs
82
+ # to be able to see it.
83
+ #@digest.current.keys.each do |fname|
84
+ # if md = pattern.match(fname)
85
+ # if @digest.current[fname] != @digest.saved[fname]
86
+ # result << Match.new(fname, md)
87
+ # end
88
+ # end
89
+ #end
90
+ else
91
+ list = Dir.glob(pattern, File::FNM_PATHNAME)
92
+ list = digest.filter(list)
93
+ list.each do |fname|
94
+ if digest.current[fname] != digest.saved[fname]
95
+ result << fname
96
+ end
97
+ end
98
+ #@digest.current.keys.each do |fname|
99
+ # if md = File.fnmatch?(pattern, fname, File::FNM_PATHNAME | File::FNM_EXTGLOB)
100
+ # if @digest.current[fname] != @digest.saved[fname]
101
+ # result << Match.new(fname, md)
102
+ # end
103
+ # end
104
+ #end
105
+ end
106
+
107
+ return result
108
+ end
109
+
110
+ end
111
+
112
+ end
@@ -0,0 +1,51 @@
1
+ module Ergo
2
+
3
+ # Master system instance.
4
+ #
5
+ # Returns [System]
6
+ #def self.system
7
+ # @system ||= System.new
8
+ #end
9
+
10
+ ##
11
+ # A system stores defined states and rules and books, which are subsystems.
12
+ #
13
+ class System < Book
14
+
15
+ # Initialize new System instance.
16
+ #
17
+ def initialize(script=nil, options={})
18
+ extend self
19
+ extend ShellUtils
20
+
21
+ @ignore = options[:ignore] || Ignore.new
22
+ @session = OpenStruct.new
23
+
24
+ @scripts = []
25
+ @rules = []
26
+ @states = {}
27
+ @books = {}
28
+ @digests = {}
29
+
30
+ import script if script
31
+ end
32
+
33
+ # Map of books by name.
34
+ #
35
+ # Returns [Hash]
36
+ attr :books
37
+
38
+ # Books are stored with rules to preserve order of application.
39
+ #
40
+ # Return [Book]
41
+ def book(name, &block)
42
+ @books[name.to_s] ||= (
43
+ book = Book.new(self, name, &block)
44
+ @rules << book
45
+ book
46
+ )
47
+ end
48
+
49
+ end
50
+
51
+ end
@@ -0,0 +1,2 @@
1
+ *.html
2
+ *.1
@@ -0,0 +1,50 @@
1
+ ergo(1) -- Ruby rules-based automated build tool
2
+ ===============================================
3
+
4
+ ## SYNOPSIS
5
+
6
+ `ergo`
7
+ `ergo` <bookmark> [<arg>...]<br>
8
+ `ergo` `-R`|`--rules`<br>
9
+ `ergo` `-h`|`--help`<br>
10
+
11
+
12
+ ## DESCRIPTION
13
+
14
+ Ergo is an *autological* build tool, in that it is used to automate
15
+ build procedure via logical rules-based programming. The developer only
16
+ ever needs to run a single command, `ergo`, and the majority of maintenance
17
+ details of a project are handled. Ergo largely replaces the need of more
18
+ traditional task-based build tools, but it does not complete supplant them.
19
+ They reamin a useful complement for one-off manual build procedures.
20
+
21
+
22
+ ## OPTIONS
23
+
24
+ These options act as subcommands:
25
+
26
+ * `-R`, `--rules`:
27
+ Display the described rules defined in the project's ergo script(s).
28
+
29
+ * `-h`, `--help`:
30
+ Display this help message.
31
+
32
+
33
+ ## ISSUES
34
+
35
+ **Ergo** depends on **Ronn** to provide this man-page and command help message.
36
+ Ronn depends on hpricot and rdiscount, extension libraries that are non-trivial
37
+ to install on some systems. A more portable version of this program would be
38
+ welcome.
39
+
40
+
41
+ ## COPYRIGHT
42
+
43
+ Ergo is Copyright (c) 2009 Thomas Sawyer, Rubyworks
44
+
45
+ Ergo is distributed in accordance to the **GPL-3** license.
46
+
47
+
48
+ ## SEE ALSO
49
+
50
+ ronn(1), rake(1)
metadata ADDED
@@ -0,0 +1,163 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ergo
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.3.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Trans
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-02-16 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: notify
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: detroit
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: mast
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: qed
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ - !ruby/object:Gem::Dependency
79
+ name: ae
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ description: ! 'Ergo is an automated build tool with a slick set-logic based
95
+
96
+ state/rules system, perfect for performing continuous integration.'
97
+ email:
98
+ - transfire@gmail.com
99
+ executables:
100
+ - ergo
101
+ extensions: []
102
+ extra_rdoc_files:
103
+ - LICENSE.txt
104
+ - HISTORY.md
105
+ - README.md
106
+ files:
107
+ - .index
108
+ - .yardopts
109
+ - bin/ergo
110
+ - demo/03_runner/01_applying_rules.md
111
+ - demo/applique/ae.rb
112
+ - demo/applique/ergo.rb
113
+ - demo/overview.md
114
+ - lib/ergo/book.rb
115
+ - lib/ergo/cli.rb
116
+ - lib/ergo/core_ext/boolean.rb
117
+ - lib/ergo/core_ext/cli.rb
118
+ - lib/ergo/core_ext/true_class.rb
119
+ - lib/ergo/core_ext.rb
120
+ - lib/ergo/digest.rb
121
+ - lib/ergo/ignore.rb
122
+ - lib/ergo/match.rb
123
+ - lib/ergo/rule.rb
124
+ - lib/ergo/runner.rb
125
+ - lib/ergo/shellutils.rb
126
+ - lib/ergo/state.rb
127
+ - lib/ergo/system.rb
128
+ - lib/ergo.rb
129
+ - lib/ergo.yml
130
+ - man/.gitignore
131
+ - man/ergo.1
132
+ - man/ergo.1.html
133
+ - man/ergo.1.ronn
134
+ - HISTORY.md
135
+ - README.md
136
+ - LICENSE.txt
137
+ homepage: http://rubyworks.github.com/ergo
138
+ licenses:
139
+ - BSD-2-Clause
140
+ post_install_message:
141
+ rdoc_options: []
142
+ require_paths:
143
+ - lib
144
+ required_ruby_version: !ruby/object:Gem::Requirement
145
+ none: false
146
+ requirements:
147
+ - - ! '>='
148
+ - !ruby/object:Gem::Version
149
+ version: '0'
150
+ required_rubygems_version: !ruby/object:Gem::Requirement
151
+ none: false
152
+ requirements:
153
+ - - ! '>='
154
+ - !ruby/object:Gem::Version
155
+ version: '0'
156
+ requirements: []
157
+ rubyforge_project:
158
+ rubygems_version: 1.8.24
159
+ signing_key:
160
+ specification_version: 3
161
+ summary: The best build tool, logically!
162
+ test_files: []
163
+ has_rdoc: