germinate 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -0
- data/History.txt +26 -0
- data/README.rdoc +152 -0
- data/Rakefile +43 -0
- data/TODO +140 -0
- data/bin/germ +260 -0
- data/cucumber.yml +2 -0
- data/examples/basic.rb +123 -0
- data/examples/short.rb +19 -0
- data/features/author-formats-article.feature +111 -0
- data/features/author-lists-info.pending_feature +48 -0
- data/features/author-publishes-article-source.feature +5 -0
- data/features/author-publishes-article.feature +57 -0
- data/features/author-republishes-article.feature +5 -0
- data/features/author-selects-hunks.feature +26 -0
- data/features/author-sets-variables.feature +88 -0
- data/features/author-updates-article-source.feature +5 -0
- data/features/author-views-stuff.pending_feature +52 -0
- data/features/bin/quoter +6 -0
- data/features/bin/sorter +4 -0
- data/features/example_articles/bracketing.rb +27 -0
- data/features/example_articles/escaping.txt +13 -0
- data/features/example_articles/excerpt_output.rb +16 -0
- data/features/example_articles/hello.rb +9 -0
- data/features/example_articles/pipelines.txt +25 -0
- data/features/example_articles/regexen.rb +24 -0
- data/features/example_articles/sample_offsets.rb +18 -0
- data/features/example_articles/specials.rb +19 -0
- data/features/example_articles/stderr.rb +10 -0
- data/features/example_articles/wrapping.rb +8 -0
- data/features/example_output/bracketing.out +23 -0
- data/features/example_output/code_samples.txt +186 -0
- data/features/example_output/escaping.out +5 -0
- data/features/example_output/excerpt_output.out +6 -0
- data/features/example_output/hello.txt +1 -0
- data/features/example_output/pipelines.out +28 -0
- data/features/example_output/regexen.txt +22 -0
- data/features/example_output/sample_offsets.txt +15 -0
- data/features/example_output/specials.txt +40 -0
- data/features/example_output/stderr.out +3 -0
- data/features/example_output/wrapping.txt +3 -0
- data/features/step_definitions/germinate.rb +42 -0
- data/features/support/env.rb +20 -0
- data/germinate.gemspec +55 -0
- data/lib/germinate.rb +54 -0
- data/lib/germinate/application.rb +113 -0
- data/lib/germinate/article_editor.rb +20 -0
- data/lib/germinate/formatter.rb +119 -0
- data/lib/germinate/hunk.rb +183 -0
- data/lib/germinate/implicit_insertion.rb +9 -0
- data/lib/germinate/insertion.rb +29 -0
- data/lib/germinate/librarian.rb +293 -0
- data/lib/germinate/origin.rb +5 -0
- data/lib/germinate/pipeline.rb +13 -0
- data/lib/germinate/publisher.rb +57 -0
- data/lib/germinate/reader.rb +266 -0
- data/lib/germinate/selector.rb +136 -0
- data/lib/germinate/shared_style_attributes.rb +54 -0
- data/lib/germinate/shell_process.rb +94 -0
- data/lib/germinate/shell_publisher.rb +19 -0
- data/lib/germinate/simple_publisher.rb +7 -0
- data/lib/germinate/source_file.rb +41 -0
- data/lib/germinate/text_transforms.rb +119 -0
- data/lib/germinate/transform_process.rb +25 -0
- data/lib/germinate/variable.rb +23 -0
- data/sample.rb +14 -0
- data/spec/germinate/application_spec.rb +31 -0
- data/spec/germinate/article_editor_spec.rb +97 -0
- data/spec/germinate/code_hunk_spec.rb +73 -0
- data/spec/germinate/file_hunk_spec.rb +28 -0
- data/spec/germinate/formatter_spec.rb +160 -0
- data/spec/germinate/hunk_spec.rb +84 -0
- data/spec/germinate/implicit_insertion_spec.rb +33 -0
- data/spec/germinate/insertion_spec.rb +19 -0
- data/spec/germinate/librarian_spec.rb +555 -0
- data/spec/germinate/pipeline_spec.rb +34 -0
- data/spec/germinate/process_spec.rb +105 -0
- data/spec/germinate/publisher_spec.rb +130 -0
- data/spec/germinate/reader_spec.rb +385 -0
- data/spec/germinate/selector_spec.rb +121 -0
- data/spec/germinate/shell_publisher_spec.rb +61 -0
- data/spec/germinate/source_file_spec.rb +99 -0
- data/spec/germinate/text_hunk_spec.rb +98 -0
- data/spec/germinate/text_transforms_spec.rb +242 -0
- data/spec/germinate/transform_process_spec.rb +50 -0
- data/spec/germinate/variable_spec.rb +14 -0
- data/spec/germinate_spec.rb +8 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +16 -0
- data/tasks/ann.rake +80 -0
- data/tasks/bones.rake +20 -0
- data/tasks/cucumber.rake +5 -0
- data/tasks/gem.rake +201 -0
- data/tasks/git.rake +40 -0
- data/tasks/notes.rake +27 -0
- data/tasks/post_load.rake +34 -0
- data/tasks/rdoc.rake +51 -0
- data/tasks/rubyforge.rake +55 -0
- data/tasks/setup.rb +292 -0
- data/tasks/spec.rake +54 -0
- data/tasks/svn.rake +47 -0
- data/tasks/test.rake +40 -0
- data/tasks/zentest.rake +36 -0
- data/test/test_germinate.rb +0 -0
- metadata +228 -0
@@ -0,0 +1,52 @@
|
|
1
|
+
Note: this is a debug feature and its not worth specifying until it gets a bit
|
2
|
+
more stable.
|
3
|
+
Feature: author views information
|
4
|
+
|
5
|
+
As an author
|
6
|
+
I want to view the components of my article
|
7
|
+
So that I can diagnose errors in output
|
8
|
+
|
9
|
+
Scenario: list stuff
|
10
|
+
Given an article with the contents:
|
11
|
+
"""
|
12
|
+
# :TEXT:
|
13
|
+
# Anonymous section 1
|
14
|
+
|
15
|
+
anonymous code 1
|
16
|
+
# :END:
|
17
|
+
|
18
|
+
anonymous code 2
|
19
|
+
|
20
|
+
# :TEXT: A
|
21
|
+
# Section A
|
22
|
+
|
23
|
+
# :SAMPLE: X
|
24
|
+
code sample X
|
25
|
+
|
26
|
+
# :PROCESS: frob, "aaa"
|
27
|
+
# :PROCESS: munge, "bbb"
|
28
|
+
"""
|
29
|
+
When I run the command "germ show --section=SECTION1" on the article
|
30
|
+
Then the output should be as follows:
|
31
|
+
"""
|
32
|
+
# Anonymous section 1
|
33
|
+
|
34
|
+
Insertion[@SECTION1]
|
35
|
+
"""
|
36
|
+
When I run the command "germ show --section=A" on the article
|
37
|
+
Then the output should be as follows:
|
38
|
+
"""
|
39
|
+
# Section A
|
40
|
+
|
41
|
+
"""
|
42
|
+
When I run the command "germ show --sample=X" on the article
|
43
|
+
Then the output should be as follows:
|
44
|
+
"""
|
45
|
+
code sample X
|
46
|
+
|
47
|
+
"""
|
48
|
+
When I run the command "germ show --process=munge" on the article
|
49
|
+
Then the output should be as follows:
|
50
|
+
"""
|
51
|
+
bbb
|
52
|
+
"""
|
data/features/bin/quoter
ADDED
data/features/bin/sorter
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# :BRACKET_CODE: "[", "]"
|
2
|
+
|
3
|
+
# :SAMPLE: main
|
4
|
+
def main
|
5
|
+
hello
|
6
|
+
end
|
7
|
+
|
8
|
+
# :SAMPLE: hello, { brackets: [ "{", "}" ] }
|
9
|
+
def hello
|
10
|
+
puts "hello"
|
11
|
+
end
|
12
|
+
|
13
|
+
# :TEXT:
|
14
|
+
# Should have square brackets
|
15
|
+
# :INSERT: @main
|
16
|
+
|
17
|
+
# :TEXT:
|
18
|
+
# Should have curly brackets
|
19
|
+
# :INSERT: @hello
|
20
|
+
|
21
|
+
# :TEXT:
|
22
|
+
# Should have curly brackets
|
23
|
+
# :INSERT: @hello:2
|
24
|
+
|
25
|
+
# :TEXT:
|
26
|
+
# Should have angle brackets
|
27
|
+
# :INSERT: @hello:2, { brackets: [ "<", ">" ] }
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# What if you want to write about Germinate in Germinate? Escaping is the key.
|
2
|
+
|
3
|
+
# :TEXT:
|
4
|
+
# Here are some Germinate directives
|
5
|
+
# \:TEXT:
|
6
|
+
# \:SAMPLE:
|
7
|
+
# \:INSERT:
|
8
|
+
# You get the idea.
|
9
|
+
|
10
|
+
# It works in code too:
|
11
|
+
|
12
|
+
# :SAMPLE:
|
13
|
+
# \:PROCESS: foo, bar
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# We can excerpt the output of a command instead of running the command on an
|
2
|
+
# excerpt.
|
3
|
+
# :PROCESS: ruby, "ruby %f"
|
4
|
+
# :SAMPLE:
|
5
|
+
|
6
|
+
puts "-" * 3
|
7
|
+
puts "line 1"
|
8
|
+
puts "-" * 5
|
9
|
+
|
10
|
+
puts "=" * 3
|
11
|
+
puts "line 2"
|
12
|
+
puts "=" * 5
|
13
|
+
|
14
|
+
# :TEXT:
|
15
|
+
# :INSERT: $SOURCE|ruby:/===/../=====/
|
16
|
+
# :INSERT: $SOURCE|ruby:/---/../-----/
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# A %f will be replaced with a path to a temporary file
|
2
|
+
# :PROCESS: quote, "quoter %f"
|
3
|
+
#
|
4
|
+
# If there is no %f the content will be piped into the command on STDIN
|
5
|
+
# :PROCESS: sort, "sorter"
|
6
|
+
|
7
|
+
# :SAMPLE: names
|
8
|
+
joe
|
9
|
+
sally
|
10
|
+
aaron
|
11
|
+
george
|
12
|
+
zack
|
13
|
+
susan
|
14
|
+
# :TEXT:
|
15
|
+
# Sorting the sample:
|
16
|
+
# :INSERT: @names|sort
|
17
|
+
#
|
18
|
+
# Quoting the sample:
|
19
|
+
# :INSERT: @names|quote
|
20
|
+
#
|
21
|
+
# We can combine pipelines with excerpting:
|
22
|
+
# :INSERT: @names:2..4|quote
|
23
|
+
#
|
24
|
+
# And we can chain processes to form a true pipeline:
|
25
|
+
# :INSERT: @names|sort|quote
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# :SAMPLE: A
|
2
|
+
|
3
|
+
def foo
|
4
|
+
# ...
|
5
|
+
end
|
6
|
+
|
7
|
+
def bar
|
8
|
+
# ...
|
9
|
+
end
|
10
|
+
|
11
|
+
class Frob
|
12
|
+
# ...
|
13
|
+
end
|
14
|
+
|
15
|
+
# :TEXT:
|
16
|
+
# We can select code by regexp
|
17
|
+
# :INSERT: @A:/foo/../end/
|
18
|
+
#
|
19
|
+
# Or with a regex and a length
|
20
|
+
# :INSERT: @A:/bar/,7
|
21
|
+
#
|
22
|
+
# Ending offset can be exclusive
|
23
|
+
# :INSERT: @A:/foo/.../Frob/
|
24
|
+
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# :SAMPLE: A
|
2
|
+
a_line_1 = 1
|
3
|
+
a_line_2 = 2
|
4
|
+
a_line_3 = 3
|
5
|
+
a_line_4 = 4
|
6
|
+
|
7
|
+
# :TEXT:
|
8
|
+
# We can specify a starting offset:
|
9
|
+
# :INSERT: @A:2
|
10
|
+
#
|
11
|
+
# And an ending offset
|
12
|
+
# :INSERT: @A:2..3
|
13
|
+
#
|
14
|
+
# Ending offset can be exclusive
|
15
|
+
# :INSERT: @A:1...3
|
16
|
+
#
|
17
|
+
# We can specify offset and count instead
|
18
|
+
# :INSERT: @A:2,3
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# :SAMPLE: A
|
2
|
+
a_line_1 = 1
|
3
|
+
a_line_2 = 2
|
4
|
+
a_line_3 = 3
|
5
|
+
a_line_4 = 4
|
6
|
+
|
7
|
+
# :SAMPLE: B
|
8
|
+
b_line_1 = 1
|
9
|
+
b_line_2 = 2
|
10
|
+
|
11
|
+
# :TEXT:
|
12
|
+
# We can paste in all the code:
|
13
|
+
# :INSERT: $CODE, { disable_transforms: true }
|
14
|
+
#
|
15
|
+
# Or all the text:
|
16
|
+
# :INSERT: $TEXT, { disable_transforms: true }
|
17
|
+
#
|
18
|
+
# Or the entire source file
|
19
|
+
# :INSERT: $SOURCE, { disable_transforms: true }
|
@@ -0,0 +1,10 @@
|
|
1
|
+
# We can capture both STDOUT and STDERR by using shell modifiers
|
2
|
+
# :PROCESS: ruby, "ruby %f 2>&1"
|
3
|
+
# :SAMPLE: output
|
4
|
+
$stdout.sync = true
|
5
|
+
$stdout.puts "Hello, STDOUT"
|
6
|
+
$stderr.puts "Hello, STDERR"
|
7
|
+
$stdout.puts "Hello again, STDOUT"
|
8
|
+
|
9
|
+
# :TEXT:
|
10
|
+
# :INSERT: $SOURCE|ruby
|
@@ -0,0 +1,23 @@
|
|
1
|
+
Should have square brackets
|
2
|
+
[
|
3
|
+
def main
|
4
|
+
hello
|
5
|
+
end
|
6
|
+
]
|
7
|
+
|
8
|
+
Should have curly brackets
|
9
|
+
{
|
10
|
+
def hello
|
11
|
+
puts "hello"
|
12
|
+
end
|
13
|
+
}
|
14
|
+
|
15
|
+
Should have curly brackets
|
16
|
+
{
|
17
|
+
puts "hello"
|
18
|
+
}
|
19
|
+
|
20
|
+
Should have angle brackets
|
21
|
+
<
|
22
|
+
puts "hello"
|
23
|
+
>
|
@@ -0,0 +1,186 @@
|
|
1
|
+
Hi there! Here's a Hello, World method:
|
2
|
+
|
3
|
+
def hello
|
4
|
+
puts "Hello, World!"
|
5
|
+
end
|
6
|
+
|
7
|
+
The immediately following code sample can be implicitly referenced:
|
8
|
+
|
9
|
+
def nameless
|
10
|
+
puts "I have no name"
|
11
|
+
end
|
12
|
+
|
13
|
+
Or explicitly referenced
|
14
|
+
|
15
|
+
def foo
|
16
|
+
puts "foo"
|
17
|
+
end
|
18
|
+
|
19
|
+
Samples can be referenced by name
|
20
|
+
|
21
|
+
def fred
|
22
|
+
# This comment is part of the sample
|
23
|
+
puts "Hello, my name is Fred"
|
24
|
+
puts "la la la"
|
25
|
+
end
|
26
|
+
|
27
|
+
Or by index:
|
28
|
+
|
29
|
+
def boring
|
30
|
+
1 + 1
|
31
|
+
end
|
32
|
+
|
33
|
+
SOURCE is a special sample which contains this entire source file.
|
34
|
+
|
35
|
+
# This example demonstrates the use of code samples.
|
36
|
+
|
37
|
+
# :TEXT:
|
38
|
+
# Hi there! Here's a Hello, World method:
|
39
|
+
|
40
|
+
def hello
|
41
|
+
puts "Hello, World!"
|
42
|
+
end
|
43
|
+
|
44
|
+
# :CUT:
|
45
|
+
# Here's some boring support code we don't want to show the world.
|
46
|
+
|
47
|
+
def boring
|
48
|
+
1 + 1
|
49
|
+
end
|
50
|
+
|
51
|
+
# Here are two a named samples:
|
52
|
+
# :SAMPLE: fred
|
53
|
+
|
54
|
+
def fred
|
55
|
+
# This comment is part of the sample
|
56
|
+
puts "Hello, my name is Fred"
|
57
|
+
puts "la la la"
|
58
|
+
end
|
59
|
+
|
60
|
+
# :SAMPLE: sally
|
61
|
+
|
62
|
+
def sally
|
63
|
+
puts "Hello, my name is Sally"
|
64
|
+
end
|
65
|
+
|
66
|
+
# :END:
|
67
|
+
# Sample "sally" ends above, and does not include the following.
|
68
|
+
|
69
|
+
def wizard
|
70
|
+
puts "Pay no attention to the man behind the curtain!"
|
71
|
+
end
|
72
|
+
|
73
|
+
# Samples can be inside comment blocks
|
74
|
+
# :SAMPLE: george
|
75
|
+
# (defun george () (format "Hello from George"))
|
76
|
+
# :CUT:
|
77
|
+
|
78
|
+
# Samples can have comment markers stripped
|
79
|
+
# :SAMPLE: mary, { uncomment: true }
|
80
|
+
# (defun mary () (format "Hello from Mary"))
|
81
|
+
# :CUT:
|
82
|
+
|
83
|
+
# :TEXT:
|
84
|
+
# The immediately following code sample can be implicitly referenced:
|
85
|
+
# :INSERT:
|
86
|
+
# :CUT:
|
87
|
+
def nameless
|
88
|
+
puts "I have no name"
|
89
|
+
end
|
90
|
+
|
91
|
+
# :TEXT:
|
92
|
+
# Or explicitly referenced
|
93
|
+
# :INSERT: FOLLOWING
|
94
|
+
# :CUT:
|
95
|
+
def foo
|
96
|
+
puts "foo"
|
97
|
+
end
|
98
|
+
|
99
|
+
# :TEXT:
|
100
|
+
# Samples can be referenced by name
|
101
|
+
# :INSERT: fred
|
102
|
+
#
|
103
|
+
# Or by index:
|
104
|
+
# :INSERT: #2
|
105
|
+
#
|
106
|
+
# SOURCE is a special sample which contains this entire source file.
|
107
|
+
# :INSERT: SOURCE, { indent: 4 }
|
108
|
+
#
|
109
|
+
# CODE is a special sample which contains all the non-text portions of this
|
110
|
+
# file.
|
111
|
+
# :INSERT: CODE, { indent: " > " }
|
112
|
+
#
|
113
|
+
# We can select specific lines:
|
114
|
+
# :INSERT: sally:2
|
115
|
+
#
|
116
|
+
# Or ranges of lines:
|
117
|
+
# :INSERT: sally:2..3
|
118
|
+
#
|
119
|
+
# Or lines matching a regex:
|
120
|
+
# :INSERT: sally:/def/
|
121
|
+
#
|
122
|
+
# Or ranges of regexen:
|
123
|
+
# :INSERT: fred:/puts/.../end/
|
124
|
+
|
125
|
+
CODE is a special sample which contains all the non-text portions of this file.
|
126
|
+
|
127
|
+
> # This example demonstrates the use of code samples.
|
128
|
+
>
|
129
|
+
> def hello
|
130
|
+
> puts "Hello, World!"
|
131
|
+
> end
|
132
|
+
>
|
133
|
+
> # Here's some boring support code we don't want to show the world.
|
134
|
+
>
|
135
|
+
> def boring
|
136
|
+
> 1 + 1
|
137
|
+
> end
|
138
|
+
>
|
139
|
+
> # Here are two a named samples:
|
140
|
+
>
|
141
|
+
> def fred
|
142
|
+
> # This comment is part of the sample
|
143
|
+
> puts "Hello, my name is Fred"
|
144
|
+
> puts "la la la"
|
145
|
+
> end
|
146
|
+
>
|
147
|
+
> def sally
|
148
|
+
> puts "Hello, my name is Sally"
|
149
|
+
> end
|
150
|
+
>
|
151
|
+
> # Sample "sally" ends above, and does not include the following.
|
152
|
+
>
|
153
|
+
> def wizard
|
154
|
+
> puts "Pay no attention to the man behind the curtain!"
|
155
|
+
> end
|
156
|
+
>
|
157
|
+
> # Samples can be inside comment blocks
|
158
|
+
>
|
159
|
+
> # Samples can have comment markers stripped
|
160
|
+
>
|
161
|
+
> def nameless
|
162
|
+
> puts "I have no name"
|
163
|
+
> end
|
164
|
+
>
|
165
|
+
> def foo
|
166
|
+
> puts "foo"
|
167
|
+
> end
|
168
|
+
|
169
|
+
We can select specific lines:
|
170
|
+
|
171
|
+
puts "Hello, my name is Sally"
|
172
|
+
|
173
|
+
Or ranges of lines:
|
174
|
+
|
175
|
+
puts "Hello, my name is Sally"
|
176
|
+
end
|
177
|
+
|
178
|
+
Or lines matching a regex:
|
179
|
+
|
180
|
+
def sally
|
181
|
+
|
182
|
+
# Or ranges of regexen:
|
183
|
+
|
184
|
+
puts "Hello, my name is Fred"
|
185
|
+
puts "la la la"
|
186
|
+
|