rgl 0.5.1 → 0.5.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/ChangeLog +72 -16
- data/Gemfile +4 -3
- data/README.md +267 -0
- data/Rakefile +15 -30
- data/examples/examples.rb +11 -9
- data/examples/unix.dot +53 -0
- data/lib/rgl/adjacency.rb +2 -2
- data/lib/rgl/base.rb +4 -3
- data/lib/rgl/bellman_ford.rb +1 -2
- data/lib/rgl/bipartite.rb +2 -2
- data/lib/rgl/dijkstra.rb +3 -29
- data/lib/rgl/dot.rb +33 -14
- data/lib/rgl/edmonds_karp.rb +4 -4
- data/lib/rgl/graph_iterator.rb +4 -0
- data/lib/rgl/graphxml.rb +2 -2
- data/lib/rgl/path.rb +17 -0
- data/lib/rgl/rdot.rb +1 -1
- data/lib/rgl/traversal.rb +8 -1
- data/test/components_test.rb +2 -2
- data/test/dijkstra_issue24_test.rb +23 -0
- data/test/dot_test.rb +54 -14
- data/test/graph_test.rb +5 -0
- data/test/graph_xml_test.rb +1 -7
- data/test/path_test.rb +52 -0
- data/test/test_helper.rb +3 -0
- data/test/traversal_test.rb +26 -0
- metadata +131 -150
- data/README.rdoc +0 -248
- data/examples/images/example.jpg +0 -0
- data/examples/images/module_graph.jpg +0 -0
- data/examples/images/rgl_modules.png +0 -0
- data/lib/rgl/enumerable_ext.rb +0 -16
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: b92e64e8461dc9a3f9f471e68c9a2876e93a44f5b858e0a40a30b6933e5136a8
|
4
|
+
data.tar.gz: f820274113a375f61620272c1eb6a11127562867e8fe9af8bc20cf075aca5fc6
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 8e887b25cc41ead029b67a58a21ce02536baf92a44912d8ff2208b04477ffd9556fde68dd0c4663caa9341cecd58b8102bfafe7df7512b5cbc7285764d0952e2
|
7
|
+
data.tar.gz: a610a0225a9c63fb83a841053377b07ee0d59dabf12a4379c30a1f8c27c5618e245f9d10f5f3f5c2aef08ddb323c3e4d357ad432d0c24be49701f8fe336340ef
|
data/ChangeLog
CHANGED
@@ -1,41 +1,97 @@
|
|
1
|
+
2019-01 Release 0.5.7
|
2
|
+
|
3
|
+
Horst Duchene
|
4
|
+
* Fully automate dev setup with Gitpod (41dd00)
|
5
|
+
* Add Dockerfile to install graphviz (2bd738)
|
6
|
+
* Examples do not call dotty (6bba96)
|
7
|
+
* Add ruby license file (a21aa5)
|
8
|
+
ujihisa <ujihisa@users.noreply.github.com>
|
9
|
+
* Test against Ruby 2.6 and 2.7 as well (50ac7c)
|
10
|
+
* Fix dead links (9184f3)
|
11
|
+
Harry Lascelles <hlascelles@users.noreply.github.com>
|
12
|
+
* Update .travis.yml (45b9a2)
|
13
|
+
* Make the links more explicit (95dc3b)
|
14
|
+
Harry Lascelles
|
15
|
+
* Add explicit license to gemspec (de3647)
|
16
|
+
|
17
|
+
2019-01 Release 0.5.6
|
18
|
+
|
19
|
+
Artemy Kirienko
|
20
|
+
* PR #42 Add method Graph#path?(u, v) to check if a path exists between two vertices
|
21
|
+
Horst Duchene
|
22
|
+
* Fix #47 set_to_begin for graph iterator (881aa8)
|
23
|
+
|
24
|
+
2019-01 Release 0.5.4
|
25
|
+
|
26
|
+
Lia Skalkos
|
27
|
+
* Enable options to be passed to #write_to_graphic_file (4ca972). For details see PR #41
|
28
|
+
Horst Duchene
|
29
|
+
* Fix travis-ci errors
|
30
|
+
* Add new ruby versions
|
31
|
+
* Fix gemspec errors
|
32
|
+
* Fix lint warnings
|
33
|
+
* Use version stream 0.5.2
|
34
|
+
|
35
|
+
2017-04 Release 0.5.3
|
36
|
+
|
37
|
+
Horst Duchene
|
38
|
+
* Issue #38: Add error handling or dot functions. (719e38, 5a3423)
|
39
|
+
Thomas Orozco
|
40
|
+
* Remove Enumerable Extension (fde8a5)
|
41
|
+
* Update to codeclimate-test-reporter 1.x (25fdb5)
|
42
|
+
Mario Daskalov
|
43
|
+
* Clarify that you need graphviz in the README (35a4b4)
|
44
|
+
|
45
|
+
2016-05 Release 0.5.2
|
46
|
+
|
47
|
+
Horst Duchene
|
48
|
+
* Issue #21: Use new method vertex_id instead of object_id to identify vertices in dot export. (fa7592)
|
49
|
+
* Integrate Code Climate's test coverage reporting (0ab722)
|
50
|
+
* Clarify traversal order of DFS search (see #20). (afa788)
|
51
|
+
Chase Gilliam
|
52
|
+
* drop 1.9.3 add newer jruby and rubinius (fad333)
|
53
|
+
Matías Battocchia
|
54
|
+
* Switched to a different heap implementation. (bd7c13)
|
55
|
+
gorn
|
56
|
+
* Adding failing test for issue #24 (1f6204)
|
57
|
+
|
1
58
|
2015-12 Release 0.5.1
|
2
59
|
|
3
|
-
Horst Duchene
|
60
|
+
Horst Duchene
|
4
61
|
* Changed edge sequence to match example picture (daa88e)
|
5
62
|
|
6
|
-
Chase
|
63
|
+
Chase
|
7
64
|
* updated algorithms to 6.1 and added test unit to support newer rubies (fbd874)
|
8
65
|
|
9
|
-
Louis Rose
|
66
|
+
Louis Rose
|
10
67
|
* Fix #15. Use object IDs rather than labels to identify vertexs in DOT graph
|
11
68
|
to ensure that distinct nodes that share a label are shown. (33206f, 4fc455)
|
12
69
|
|
13
70
|
2014-12 Release 0.5.0
|
14
71
|
|
15
|
-
Horst Duchene
|
72
|
+
Horst Duchene
|
16
73
|
* Changed edge sequence to match example picture (daa88e)
|
17
74
|
* Fixed comment (6a6c93)
|
18
75
|
* Fixed spelling (7ca281)
|
19
|
-
Horst Duchêne
|
20
|
-
Chase
|
76
|
+
Horst Duchêne
|
77
|
+
Chase
|
21
78
|
* updated algorithms to 6.1 and added test unit to support newer rubies (fbd874)
|
22
|
-
Louis Rose
|
79
|
+
Louis Rose
|
23
80
|
* Fix #15. Use object IDs rather than labels to identify vertexs in DOT graph to ensure that distinct nodes that share a label are shown. (33206f)
|
24
|
-
|
25
|
-
|
81
|
+
* Issue #15. Fix tests. (4fc455)
|
26
82
|
|
27
83
|
2014-12 Release 0.5.0
|
28
|
-
Horst Duchene
|
84
|
+
Horst Duchene
|
29
85
|
* Changed edge sequence to match example picture (daa88e)
|
30
86
|
* Fixed comment (6a6c93)
|
31
87
|
* Fixed spelling (7ca281)
|
32
|
-
|
33
|
-
Chase <chase.gilliam@gmail.com>
|
88
|
+
Chase
|
34
89
|
* updated algorithms to 6.1 and added test unit to support newer rubies (fbd874)
|
35
|
-
Louis Rose
|
36
|
-
* Fix #15. Use object IDs rather than labels to identify vertexs
|
37
|
-
|
38
|
-
|
90
|
+
Louis Rose
|
91
|
+
* Fix #15. Use object IDs rather than labels to identify vertexs
|
92
|
+
in DOT graph to ensure that distinct nodes that share a label are
|
93
|
+
shown. (33206f)
|
94
|
+
* Issue #15. Fix tests. (4fc455)
|
39
95
|
|
40
96
|
2014-12 Release 0.5.0
|
41
97
|
|
data/Gemfile
CHANGED
data/README.md
ADDED
@@ -0,0 +1,267 @@
|
|
1
|
+
# Ruby Graph Library (RGL) [<img src="https://secure.travis-ci.org/monora/rgl.png?branch=master" alt="Build Status" />](https://travis-ci.org/monora/rgl) [<img src="https://codeclimate.com/github/monora/rgl/badges/coverage.svg" />](https://codeclimate.com/github/monora/rgl/coverage) [<img src="https://badge.fury.io/rb/rgl.svg" alt="Version"/>](https://badge.fury.io/rb/rgl)[![Gitpod ready-to-code](https://img.shields.io/badge/Gitpod-ready--to--code-blue?logo=gitpod)](https://gitpod.io/#https://github.com/monora/rgl)
|
2
|
+
|
3
|
+
RGL is a framework for graph data structures and algorithms.
|
4
|
+
|
5
|
+
The design of the library is much influenced by the Boost Graph Library (BGL)
|
6
|
+
which is written in C++. Refer to http://www.boost.org/libs/graph/doc for
|
7
|
+
further links and documentation on graph data structures and algorithms and
|
8
|
+
the design rationales of BGL.
|
9
|
+
|
10
|
+
A comprehensive summary of graph terminology can be found in the graph section
|
11
|
+
of the *Dictionary of Algorithms and Data Structures* at
|
12
|
+
http://www.nist.gov/dads/HTML/graph.html or
|
13
|
+
[Wikipedia](https://en.wikipedia.org/wiki/Graph_%28discrete_mathematics%29).
|
14
|
+
|
15
|
+
## Documentation
|
16
|
+
|
17
|
+
* RGL's [API Reference](http://www.rubydoc.info/github/monora/rgl) at
|
18
|
+
http://rubydoc.info
|
19
|
+
|
20
|
+
|
21
|
+
## Design principles
|
22
|
+
|
23
|
+
This document concentrates on the special issues of the implementation in
|
24
|
+
Ruby. The main design goals directly taken from the BGL design are:
|
25
|
+
|
26
|
+
* An interface for how the structure of a graph can be accessed using a
|
27
|
+
generic interface that hides the details of the graph data structure
|
28
|
+
implementation. This interface is defined by the module {RGL::Graph},
|
29
|
+
which should be included in concrete classes.
|
30
|
+
|
31
|
+
* A standardized generic interface for traversing graphs
|
32
|
+
{RGL::GraphIterator}
|
33
|
+
|
34
|
+
|
35
|
+
RGL provides some general purpose graph classes that conform to this
|
36
|
+
interface, but they are not meant to be the **only** graph classes. As in BGL
|
37
|
+
I believe that the main contribution of the RGL is the formulation of this
|
38
|
+
interface.
|
39
|
+
|
40
|
+
The BGL graph interface and graph components are generic in the sense of the
|
41
|
+
C++ Standard Template Library (STL). In Ruby other techniques are available to
|
42
|
+
express the generic character of the algorithms and data structures mainly
|
43
|
+
using mixins and iterators. The BGL documentation mentions three means to
|
44
|
+
achieve genericity:
|
45
|
+
|
46
|
+
* Algorithm/Data-Structure Interoperability
|
47
|
+
* Extension through Function Objects and Visitors
|
48
|
+
* Element Type Parameterization
|
49
|
+
* Vertex and Edge Property Multi-Parameterization
|
50
|
+
|
51
|
+
|
52
|
+
The first is easily achieved in RGL using mixins, which of course is not as
|
53
|
+
efficient than C++ templates (but much more readable :-). The second one is
|
54
|
+
even more easily implemented using standard iterators with blocks or using the
|
55
|
+
[stream](http://www.rubydoc.info/github/monora/stream) module. The third one
|
56
|
+
is no issue since Ruby is dynamically typed: Each object can be a graph
|
57
|
+
vertex. There is no need for a vertex (or even edge type). In the current
|
58
|
+
version of RGL properties of vertices are simply attached using hashes. At
|
59
|
+
first there seems to be not much need for the graph property machinery.
|
60
|
+
|
61
|
+
### Algorithms
|
62
|
+
|
63
|
+
RGL current contains a core set of algorithm patterns:
|
64
|
+
|
65
|
+
* Breadth First Search {RGL::BFSIterator}
|
66
|
+
* Depth First Search {RGL::DFSIterator}
|
67
|
+
|
68
|
+
|
69
|
+
The algorithm patterns by themselves do not compute any meaningful quantities
|
70
|
+
over graphs, they are merely building blocks for constructing graph
|
71
|
+
algorithms. The graph algorithms in RGL currently include:
|
72
|
+
|
73
|
+
* Topological Sort {RGL::TopsortIterator}
|
74
|
+
* Connected Components {RGL::Graph#each_connected_component}
|
75
|
+
* Strongly Connected Components {RGL::Graph#strongly_connected_components}
|
76
|
+
* Transitive Closure {RGL::Graph#transitive_closure}
|
77
|
+
* Dijkstras Shortest Path Algorithm {RGL::DijkstraAlgorithm}
|
78
|
+
* Bellman Ford Algorithm {RGL::BellmanFordAlgorithm}
|
79
|
+
|
80
|
+
|
81
|
+
### Data Structures
|
82
|
+
|
83
|
+
RGL currently provides two graph classes that implement a generalized
|
84
|
+
adjacency list and an edge list adaptor.
|
85
|
+
|
86
|
+
* {RGL::AdjacencyGraph}
|
87
|
+
* {RGL::ImplicitGraph}
|
88
|
+
|
89
|
+
|
90
|
+
The AdjacencyGraph class is the general purpose _swiss army knife_ of graph
|
91
|
+
classes. It is highly parameterized so that it can be optimized for different
|
92
|
+
situations: the graph is directed or undirected, allow or disallow parallel
|
93
|
+
edges, efficient access to just the out-edges, fast vertex insertion and
|
94
|
+
removal at the cost of extra space overhead, etc.
|
95
|
+
|
96
|
+
### Differences to BGL
|
97
|
+
|
98
|
+
The concepts of IncidenceGraph, AdjacencyGraph and VertexListGraph (see
|
99
|
+
http://www.boost.org/libs/graph/doc/IncidenceGraph.html) are here bundled in
|
100
|
+
the base graph module. Most methods of IncidenceGraph should be standard in
|
101
|
+
the base module Graph. The complexity guarantees can not necessarily provided.
|
102
|
+
See http://www.boost.org/libs/graph/doc/graph_concepts.html.
|
103
|
+
|
104
|
+
## Installation
|
105
|
+
|
106
|
+
% gem install rgl
|
107
|
+
|
108
|
+
or download the latest sources from the git repository
|
109
|
+
http://github.com/monora/rgl.
|
110
|
+
|
111
|
+
If you are going to use the drawing functionalities install [Graphviz](http://www.graphviz.org/).
|
112
|
+
|
113
|
+
## Running tests
|
114
|
+
|
115
|
+
Checkout RGL git repository and go to the project directory. First, install
|
116
|
+
RGL dependencies with bundler:
|
117
|
+
|
118
|
+
% bundle install
|
119
|
+
|
120
|
+
After that you can run the tests:
|
121
|
+
|
122
|
+
% rake test
|
123
|
+
|
124
|
+
## Example irb session with RGL
|
125
|
+
|
126
|
+
% irb -Ilib
|
127
|
+
|
128
|
+
irb> require 'rgl/adjacency'
|
129
|
+
irb> dg=RGL::DirectedAdjacencyGraph[1,2 ,2,3 ,2,4, 4,5, 6,4, 1,6]
|
130
|
+
# Use DOT to visualize this graph:
|
131
|
+
irb> require 'rgl/dot'
|
132
|
+
irb> dg.write_to_graphic_file('jpg')
|
133
|
+
"graph.jpg"
|
134
|
+
|
135
|
+
The result:
|
136
|
+
|
137
|
+
![Example](https://github.com/monora/rgl/raw/master/images/example.jpg)
|
138
|
+
|
139
|
+
You can control the graph layout by passing layout parameters to `write_to_graphic_file`. See
|
140
|
+
`TestDot::test_to_dot_digraph_with_options` for an example using a feature implemented by Lia
|
141
|
+
Skalkos (see [PR #41](https://github.com/monora/rgl/pull/41)).
|
142
|
+
|
143
|
+
irb> dg.directed?
|
144
|
+
true
|
145
|
+
irb> dg.vertices
|
146
|
+
[5, 6, 1, 2, 3, 4]
|
147
|
+
irb> dg.has_vertex? 4
|
148
|
+
true
|
149
|
+
|
150
|
+
Every object could be a vertex (there is no class Vertex), even the class
|
151
|
+
object *Object*:
|
152
|
+
|
153
|
+
irb> dg.has_vertex? Object
|
154
|
+
false
|
155
|
+
irb> dg.edges.sort.to_s
|
156
|
+
"(1-2)(1-6)(2-3)(2-4)(4-5)(6-4)"
|
157
|
+
irb> dg.to_undirected.edges.sort.to_s
|
158
|
+
"(1=2)(1=6)(2=3)(2=4)(5=4)(6=4)"
|
159
|
+
|
160
|
+
Add inverse edge (4-2) to directed graph:
|
161
|
+
|
162
|
+
irb> dg.add_edge 4,2
|
163
|
+
|
164
|
+
(4-2) == (2-4) in the undirected graph:
|
165
|
+
|
166
|
+
irb> dg.to_undirected.edges.sort.to_s
|
167
|
+
"(1=2)(1=6)(2=3)(2=4)(5=4)(6=4)"
|
168
|
+
|
169
|
+
(4-2) != (2-4) in directed graphs:
|
170
|
+
|
171
|
+
irb> dg.edges.sort.to_s
|
172
|
+
"(1-2)(1-6)(2-3)(2-4)(4-2)(4-5)(6-4)"
|
173
|
+
irb> dg.remove_edge 4,2
|
174
|
+
true
|
175
|
+
|
176
|
+
Check whether a path exists between vertices 1 and 5
|
177
|
+
|
178
|
+
irb> require 'rgl/path'
|
179
|
+
irb> dg.path?(1, 5)
|
180
|
+
true
|
181
|
+
|
182
|
+
*Topological sort* is implemented as an iterator:
|
183
|
+
|
184
|
+
require 'rgl/topsort'
|
185
|
+
irb> dg.topsort_iterator.to_a
|
186
|
+
[1, 2, 3, 6, 4, 5]
|
187
|
+
|
188
|
+
A more elaborated example showing *implicit graphs*:
|
189
|
+
|
190
|
+
require 'rgl/implicit'
|
191
|
+
def module_graph
|
192
|
+
RGL::ImplicitGraph.new { |g|
|
193
|
+
g.vertex_iterator { |b|
|
194
|
+
ObjectSpace.each_object(Module, &b)
|
195
|
+
}
|
196
|
+
g.adjacent_iterator { |x, b|
|
197
|
+
x.ancestors.each { |y|
|
198
|
+
b.call(y) unless x == y || y == Kernel || y == Object
|
199
|
+
}
|
200
|
+
}
|
201
|
+
g.directed = true
|
202
|
+
}
|
203
|
+
end
|
204
|
+
|
205
|
+
This function creates a directed graph, with vertices being all loaded
|
206
|
+
modules:
|
207
|
+
|
208
|
+
g = module_graph
|
209
|
+
|
210
|
+
We only want to see the ancestors of {RGL::AdjacencyGraph}:
|
211
|
+
|
212
|
+
require 'rgl/traversal'
|
213
|
+
tree = g.bfs_search_tree_from(RGL::AdjacencyGraph)
|
214
|
+
|
215
|
+
Now we want to visualize this component of g with DOT. We therefore create a
|
216
|
+
subgraph of the original graph, using a filtered graph:
|
217
|
+
|
218
|
+
g = g.vertices_filtered_by {|v| tree.has_vertex? v}
|
219
|
+
g.write_to_graphic_file('jpg')
|
220
|
+
|
221
|
+
creates the following graph image with DOT:
|
222
|
+
|
223
|
+
![Module graph](https://github.com/monora/rgl/raw/master/images/module_graph.jpg)
|
224
|
+
|
225
|
+
This graph shows all loaded RGL modules:
|
226
|
+
|
227
|
+
![RGL Modules](https://github.com/monora/rgl/raw/master/images/rgl_modules.png)
|
228
|
+
|
229
|
+
Look for more in
|
230
|
+
[examples](https://github.com/monora/rgl/tree/master/examples) directory.
|
231
|
+
|
232
|
+
I collect some links to stuff around RGL at http://del.icio.us/monora/rgl.
|
233
|
+
|
234
|
+
## Credits
|
235
|
+
|
236
|
+
Many thanks to Robert Feldt which also worked on a graph library
|
237
|
+
(http://rockit.sf.net/subprojects/graphr) who pointed me to BGL and many other
|
238
|
+
graph resources.
|
239
|
+
|
240
|
+
Robert kindly allowed to integrate his work on graphr, which I did not yet
|
241
|
+
succeed. Especially his work to output graphs for
|
242
|
+
[GraphViz](http://www.graphviz.org) is much more elaborated than the minimal
|
243
|
+
support in dot.rb.
|
244
|
+
|
245
|
+
Jeremy Siek one of the authors of the nice book [The Boost Graph
|
246
|
+
Library](http://www.boost.org/libs/graph/doc) kindly allowed to use the BGL
|
247
|
+
documentation as a *cheap* reference for RGL. He and Robert also gave feedback
|
248
|
+
and many ideas for RGL.
|
249
|
+
|
250
|
+
Dave Thomas for [RDoc](http://rdoc.sourceforge.net) which generated what you
|
251
|
+
read and matz for Ruby. Dave included in the latest version of RDoc (alpha9)
|
252
|
+
the module dot/dot.rb which I use instead of Roberts module to visualize
|
253
|
+
graphs (see rgl/dot.rb).
|
254
|
+
|
255
|
+
Jeremy Bopp, John Carter, Sascha Doerdelmann, Shawn Garbett, Andreas Schörk
|
256
|
+
and Kirill Lashuk for contributing additions, test cases and bugfixes.
|
257
|
+
|
258
|
+
Kirill Lashuk who started to take over further development in November 2012.
|
259
|
+
|
260
|
+
See also http://github.com/monora/rgl/contributors.
|
261
|
+
|
262
|
+
## Copying
|
263
|
+
|
264
|
+
RGL is Copyright (c) 2002,2004,2005,2008,2013,2015,2019,2020 by Horst
|
265
|
+
Duchene. It is free software, and may be redistributed under the [Ruby
|
266
|
+
license](https://en.wikipedia.org/wiki/Ruby_License) and terms specified in
|
267
|
+
the LICENSE file.
|
data/Rakefile
CHANGED
@@ -6,16 +6,16 @@ require 'bundler/setup'
|
|
6
6
|
require 'rubygems/package_task'
|
7
7
|
|
8
8
|
require 'rake/testtask'
|
9
|
+
require 'rake/clean'
|
9
10
|
require 'yard'
|
10
11
|
|
11
12
|
$:.unshift File.join(File.dirname(__FILE__), 'lib')
|
12
13
|
require 'rgl/base' # require base module to get RGL_VERSION
|
13
14
|
|
14
|
-
SUMMARY = "Ruby Graph Library"
|
15
15
|
SOURCES = FileList['lib/**/*.rb']
|
16
16
|
|
17
17
|
# The default task is run if rake is given no explicit arguments.
|
18
|
-
desc
|
18
|
+
desc 'Default Task'
|
19
19
|
task :default => :test
|
20
20
|
|
21
21
|
# Define a test task.
|
@@ -26,23 +26,9 @@ Rake::TestTask.new do |t|
|
|
26
26
|
t.verbose = true
|
27
27
|
end
|
28
28
|
|
29
|
-
begin
|
30
|
-
require 'rcov/rcovtask'
|
31
|
-
|
32
|
-
desc "Calculate code coverage with rcov"
|
33
|
-
Rcov::RcovTask.new(:rcov) do |t|
|
34
|
-
t.libs << 'test'
|
35
|
-
t.pattern = 'test/*_test.rb'
|
36
|
-
t.verbose = true
|
37
|
-
t.rcov_opts += ['--exclude', 'test/,gems/']
|
38
|
-
end
|
39
|
-
rescue LoadError
|
40
|
-
nil # rcov is available only on Ruby 1.8
|
41
|
-
end
|
42
|
-
|
43
29
|
# Git tagging
|
44
30
|
|
45
|
-
desc
|
31
|
+
desc 'Commit all changes as a new version commit. Tag the commit with v<version> tag'
|
46
32
|
task :tag do
|
47
33
|
puts "Committing and tagging version #{RGL_VERSION}"
|
48
34
|
`git commit -am 'Version #{RGL_VERSION}'`
|
@@ -58,13 +44,13 @@ Bundler::GemHelper.install_tasks
|
|
58
44
|
# TAGS ---------------------------------------------------------------
|
59
45
|
|
60
46
|
file 'tags' => SOURCES do
|
61
|
-
print
|
62
|
-
sh %
|
63
|
-
puts
|
47
|
+
print 'Running ctags...'
|
48
|
+
sh %(ctags #{SOURCES.join(' ')}) # vi tags
|
49
|
+
puts 'done.'
|
64
50
|
end
|
65
51
|
|
66
52
|
file 'TAGS' => SOURCES do
|
67
|
-
sh %
|
53
|
+
sh %(etags #{SOURCES.join(' ')}) # emacs TAGS
|
68
54
|
end
|
69
55
|
|
70
56
|
# Misc tasks =========================================================
|
@@ -87,36 +73,35 @@ def show_line(msg, lines, loc)
|
|
87
73
|
printf "%6s %6s %s\n", lines.to_s, loc.to_s, msg
|
88
74
|
end
|
89
75
|
|
90
|
-
desc
|
76
|
+
desc 'Count lines in the main files'
|
91
77
|
task :lines do
|
92
78
|
total_lines = 0
|
93
79
|
total_code = 0
|
94
|
-
show_line(
|
80
|
+
show_line('File Name', 'LINES', 'LOC')
|
95
81
|
SOURCES.each do |fn|
|
96
82
|
lines, codelines = count_lines(fn)
|
97
83
|
show_line(fn, lines, codelines)
|
98
84
|
total_lines += lines
|
99
|
-
total_code
|
85
|
+
total_code += codelines
|
100
86
|
end
|
101
|
-
show_line(
|
87
|
+
show_line('TOTAL', total_lines, total_code)
|
102
88
|
end
|
103
89
|
|
104
90
|
# simple rake task to output a changelog between two commits, tags ...
|
105
91
|
# output is formatted simply, commits are grouped under each author name
|
106
92
|
#
|
107
|
-
desc
|
108
|
-
task :changelog, :since_c, :until_c do |t,args|
|
93
|
+
desc 'generate changelog with nice clean output'
|
94
|
+
task :changelog, :since_c, :until_c do |t, args|
|
109
95
|
since_c = args[:since_c] || `git tag | tail -1`.chomp
|
110
96
|
until_c = args[:until_c]
|
111
|
-
cmd
|
97
|
+
cmd = `git log --pretty='format:%ci::%an <%ae>::%s::%H' #{since_c}..#{until_c}`
|
112
98
|
|
113
99
|
entries = Hash.new
|
114
100
|
changelog_content = String.new
|
115
101
|
|
116
102
|
cmd.split("\n").each do |entry|
|
117
|
-
|
103
|
+
_, author, subject, hash = entry.chomp.split('::')
|
118
104
|
entries[author] = Array.new unless entries[author]
|
119
|
-
day = date.split(" ").first
|
120
105
|
entries[author] << "#{subject} (#{hash[0..5]})" unless subject =~ /Merge/
|
121
106
|
end
|
122
107
|
|