devver-germinate 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. data/.gitignore +2 -0
  2. data/History.txt +4 -0
  3. data/README.rdoc +132 -0
  4. data/Rakefile +43 -0
  5. data/bin/germ +133 -0
  6. data/cucumber.yml +2 -0
  7. data/examples/basic.rb +118 -0
  8. data/examples/short.rb +17 -0
  9. data/features/author-formats-article.feature +108 -0
  10. data/features/author-lists-info.feature +45 -0
  11. data/features/author-publishes-article-source.feature +5 -0
  12. data/features/author-publishes-article.feature +5 -0
  13. data/features/author-republishes-article.feature +5 -0
  14. data/features/author-selects-hunks.feature +26 -0
  15. data/features/author-updates-article-source.feature +5 -0
  16. data/features/author-views-stuff.feature +48 -0
  17. data/features/bin/quoter +6 -0
  18. data/features/bin/sorter +4 -0
  19. data/features/example_articles/code_samples.rb +89 -0
  20. data/features/example_articles/escaping.txt +12 -0
  21. data/features/example_articles/hello.rb +9 -0
  22. data/features/example_articles/pipelines.txt +25 -0
  23. data/features/example_articles/regexen.rb +24 -0
  24. data/features/example_articles/sample_offsets.rb +18 -0
  25. data/features/example_articles/specials.rb +19 -0
  26. data/features/example_articles/wrapping.rb +8 -0
  27. data/features/example_output/code_samples.txt +186 -0
  28. data/features/example_output/escaping.out +5 -0
  29. data/features/example_output/hello.txt +1 -0
  30. data/features/example_output/pipelines.out +28 -0
  31. data/features/example_output/regexen.txt +22 -0
  32. data/features/example_output/sample_offsets.txt +15 -0
  33. data/features/example_output/specials.txt +36 -0
  34. data/features/example_output/wrapping.txt +3 -0
  35. data/features/step_definitions/germinate.rb +30 -0
  36. data/features/support/env.rb +18 -0
  37. data/germinate.gemspec +55 -0
  38. data/lib/germinate.rb +54 -0
  39. data/lib/germinate/application.rb +62 -0
  40. data/lib/germinate/article_editor.rb +20 -0
  41. data/lib/germinate/article_formatter.rb +75 -0
  42. data/lib/germinate/formatter.rb +119 -0
  43. data/lib/germinate/hunk.rb +149 -0
  44. data/lib/germinate/implicit_insertion.rb +9 -0
  45. data/lib/germinate/insertion.rb +15 -0
  46. data/lib/germinate/librarian.rb +179 -0
  47. data/lib/germinate/pipeline.rb +11 -0
  48. data/lib/germinate/process.rb +67 -0
  49. data/lib/germinate/reader.rb +212 -0
  50. data/lib/germinate/selector.rb +95 -0
  51. data/lib/germinate/shared_style_attributes.rb +23 -0
  52. data/lib/germinate/text_transforms.rb +90 -0
  53. data/spec/germinate/application_spec.rb +14 -0
  54. data/spec/germinate/article_editor_spec.rb +97 -0
  55. data/spec/germinate/article_formatter_spec.rb +153 -0
  56. data/spec/germinate/code_hunk_spec.rb +45 -0
  57. data/spec/germinate/formatter_spec.rb +160 -0
  58. data/spec/germinate/hunk_spec.rb +77 -0
  59. data/spec/germinate/implicit_insertion_spec.rb +33 -0
  60. data/spec/germinate/insertion_spec.rb +18 -0
  61. data/spec/germinate/librarian_spec.rb +336 -0
  62. data/spec/germinate/pipeline_spec.rb +24 -0
  63. data/spec/germinate/process_spec.rb +64 -0
  64. data/spec/germinate/reader_spec.rb +306 -0
  65. data/spec/germinate/selector_spec.rb +65 -0
  66. data/spec/germinate/text_hunk_spec.rb +53 -0
  67. data/spec/germinate/text_transforms_spec.rb +154 -0
  68. data/spec/germinate_spec.rb +8 -0
  69. data/spec/spec.opts +1 -0
  70. data/spec/spec_helper.rb +16 -0
  71. data/tasks/ann.rake +80 -0
  72. data/tasks/bones.rake +20 -0
  73. data/tasks/cucumber.rake +5 -0
  74. data/tasks/gem.rake +201 -0
  75. data/tasks/git.rake +40 -0
  76. data/tasks/notes.rake +27 -0
  77. data/tasks/post_load.rake +34 -0
  78. data/tasks/rdoc.rake +51 -0
  79. data/tasks/rubyforge.rake +55 -0
  80. data/tasks/setup.rb +292 -0
  81. data/tasks/spec.rake +54 -0
  82. data/tasks/svn.rake +47 -0
  83. data/tasks/test.rake +40 -0
  84. data/tasks/zentest.rake +36 -0
  85. data/test/test_germinate.rb +0 -0
  86. metadata +209 -0
@@ -0,0 +1,108 @@
1
+ Feature: author formats article
2
+
3
+ As an author
4
+ I want to format my articles
5
+ So that they can be published
6
+
7
+ Scenario: format text followed by code
8
+ Given an article with the contents:
9
+ """
10
+ # :TEXT:
11
+ # This is my article
12
+
13
+ this is my code
14
+ """
15
+ When I run the format command on the article
16
+ Then the output should be as follows:
17
+ """
18
+ This is my article
19
+
20
+ this is my code
21
+ """
22
+
23
+ Scenario: format code with bracketing
24
+ Given an article with the contents:
25
+ """
26
+ # :BRACKET_CODE: "<pre>", "</pre>"
27
+ # :TEXT:
28
+ # This is my article
29
+
30
+ this is my code
31
+ """
32
+ When I run the format command on the article
33
+ Then the output should be as follows:
34
+ """
35
+ This is my article
36
+
37
+ <pre>
38
+ this is my code
39
+ </pre>
40
+ """
41
+
42
+ Scenario: override default bracketing
43
+ Given an article with the contents:
44
+ """
45
+ # :BRACKET_CODE: "<pre>", "</pre>"
46
+ # :TEXT: SECTION1
47
+ # This is my article
48
+
49
+ # :SAMPLE: SECTION1, { brackets: [ '[code]', '[/code]' ] }
50
+ this is my code
51
+ """
52
+ When I run the format command on the article
53
+ Then the output should be as follows:
54
+ """
55
+ This is my article
56
+
57
+ [code]
58
+ this is my code
59
+ [/code]
60
+ """
61
+
62
+ Scenario: insert a named section
63
+ Given an article with the contents:
64
+ """
65
+ # :BRACKET_CODE: "<pre>", "</pre>"
66
+
67
+ # :SAMPLE: sample1
68
+ code sample 1
69
+
70
+ # :SAMPLE: sample2
71
+ code sample 2
72
+
73
+ # :TEXT:
74
+ # Here is example 2:
75
+ # :INSERT: @sample2
76
+ #
77
+ # And here is example 1:
78
+ # :INSERT: @sample1
79
+ """
80
+ When I run the format command on the article
81
+ Then the output should be as follows:
82
+ """
83
+ Here is example 2:
84
+ <pre>
85
+ code sample 2
86
+ </pre>
87
+
88
+ And here is example 1:
89
+ <pre>
90
+ code sample 1
91
+ </pre>
92
+ """
93
+
94
+ Scenario Outline: more formatting examples
95
+ Given the article "<input_file>"
96
+ When I run the format command on the article
97
+ Then the output should look like "<output_file>"
98
+
99
+ Scenarios:
100
+ | input_file | output_file |
101
+ | hello.rb | hello.txt |
102
+ | wrapping.rb | wrapping.txt |
103
+ | sample_offsets.rb | sample_offsets.txt |
104
+ | specials.rb | specials.txt |
105
+ | regexen.rb | regexen.txt |
106
+ | pipelines.txt | pipelines.out |
107
+ | escaping.txt | escaping.out |
108
+
@@ -0,0 +1,45 @@
1
+ Feature: author lists information
2
+
3
+ As an author
4
+ I want to list the various components of my article
5
+ So that I can diagnose errors in output
6
+
7
+ Scenario: list stuff
8
+ Given an article with the contents:
9
+ """
10
+ # :TEXT:
11
+ # Anonymous section 1
12
+
13
+ anonymous code 1
14
+ # :END:
15
+
16
+ anonymous code 2
17
+
18
+ # :TEXT: A
19
+ # Section A
20
+
21
+ # :SAMPLE: X
22
+ code sample X
23
+
24
+ # :PROCESS: frob, "aaa"
25
+ # :PROCESS: munge, "bbb"
26
+ """
27
+ When I run the command "germ list --sections" on the article
28
+ Then the output should be as follows:
29
+ """
30
+ SECTION1
31
+ A
32
+ """
33
+ When I run the command "germ list --samples" on the article
34
+ Then the output should be as follows:
35
+ """
36
+ SECTION1
37
+ SECTION2
38
+ X
39
+ """
40
+ When I run the command "germ list --processes" on the article
41
+ Then the output should be as follows:
42
+ """
43
+ frob
44
+ munge
45
+ """
@@ -0,0 +1,5 @@
1
+ Feature: author publishes article source
2
+
3
+ As an author
4
+ I want to publish my article source code to Gist
5
+ So that I can share it with other programmers
@@ -0,0 +1,5 @@
1
+ Feature: author publishes article
2
+
3
+ As an author
4
+ I want to publish my article as a blog post
5
+ So that the world can see it
@@ -0,0 +1,5 @@
1
+ Feature: author re-publishes article
2
+
3
+ As an author
4
+ I want to re-publish my article after updating it
5
+ So that the world can see the latest version
@@ -0,0 +1,26 @@
1
+ Feature: author experiments with selectors
2
+
3
+ As an author
4
+ I want to test the behavior of various selectors
5
+ So that I know what to use in my article
6
+
7
+ Scenario: list stuff
8
+ Given an article with the contents:
9
+ """
10
+ # :TEXT: A
11
+ # Section A
12
+
13
+ # :SAMPLE: X
14
+ X 1
15
+ X 2
16
+ X 3
17
+ X 4
18
+
19
+ # :PROCESS: quote, "quoter %f"
20
+ """
21
+ When I run the command "germ select --selector='@X:2..3|quote'" on the article
22
+ Then the output should be as follows:
23
+ """
24
+ > X 2
25
+ > X 3
26
+ """
@@ -0,0 +1,5 @@
1
+ Feature: author updates article source
2
+
3
+ As an author
4
+ I want to push changes to article source code
5
+ So that other programmers will see the latest version
@@ -0,0 +1,48 @@
1
+ Feature: author views information
2
+
3
+ As an author
4
+ I want to view the components of my article
5
+ So that I can diagnose errors in output
6
+
7
+ Scenario: list stuff
8
+ Given an article with the contents:
9
+ """
10
+ # :TEXT:
11
+ # Anonymous section 1
12
+
13
+ anonymous code 1
14
+ # :END:
15
+
16
+ anonymous code 2
17
+
18
+ # :TEXT: A
19
+ # Section A
20
+
21
+ # :SAMPLE: X
22
+ code sample X
23
+
24
+ # :PROCESS: frob, "aaa"
25
+ # :PROCESS: munge, "bbb"
26
+ """
27
+ When I run the command "germ show --section=SECTION1" on the article
28
+ Then the output should be as follows:
29
+ """
30
+ # Anonymous section 1
31
+ """
32
+ When I run the command "germ show --section=A" on the article
33
+ Then the output should be as follows:
34
+ """
35
+ # Section A
36
+
37
+ """
38
+ When I run the command "germ show --sample=X" on the article
39
+ Then the output should be as follows:
40
+ """
41
+ code sample X
42
+
43
+ """
44
+ When I run the command "germ show --process=munge" on the article
45
+ Then the output should be as follows:
46
+ """
47
+ bbb
48
+ """
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ File.open(ARGV[0]) do |file|
3
+ file.each_line do |line|
4
+ puts "> #{line.chomp}"
5
+ end
6
+ end
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ $stdin.readlines.sort.each do |line|
3
+ puts line
4
+ end
@@ -0,0 +1,89 @@
1
+ # This example demonstrates the use of code samples.
2
+
3
+ # :TEXT:
4
+ # Hi there! Here's a Hello, World method:
5
+
6
+ def hello
7
+ puts "Hello, World!"
8
+ end
9
+
10
+ # :CUT:
11
+ # Here's some boring support code we don't want to show the world.
12
+
13
+ def boring
14
+ 1 + 1
15
+ end
16
+
17
+ # Here are two a named samples:
18
+ # :SAMPLE: fred
19
+
20
+ def fred
21
+ # This comment is part of the sample
22
+ puts "Hello, my name is Fred"
23
+ puts "la la la"
24
+ end
25
+
26
+ # :SAMPLE: sally
27
+
28
+ def sally
29
+ puts "Hello, my name is Sally"
30
+ end
31
+
32
+ # :END:
33
+ # Sample "sally" ends above, and does not include the following.
34
+
35
+ def wizard
36
+ puts "Pay no attention to the man behind the curtain!"
37
+ end
38
+
39
+ # Samples can be inside comment blocks
40
+ # :SAMPLE: george
41
+ # (defun george () (format "Hello from George"))
42
+ # :CUT:
43
+
44
+ # Samples can have comment markers stripped
45
+ # :SAMPLE: mary, { uncomment: true }
46
+ # (defun mary () (format "Hello from Mary"))
47
+ # :CUT:
48
+
49
+ # :TEXT:
50
+ # The immediately following code sample can be implicitly referenced:
51
+ # :INSERT:
52
+ # :CUT:
53
+ def nameless
54
+ puts "I have no name"
55
+ end
56
+
57
+ # :TEXT:
58
+ # Or explicitly referenced
59
+ # :INSERT: FOLLOWING
60
+ # :CUT:
61
+ def foo
62
+ puts "foo"
63
+ end
64
+
65
+ # :TEXT:
66
+ # Samples can be referenced by name
67
+ # :INSERT: fred
68
+ #
69
+ # Or by index:
70
+ # :INSERT: #2
71
+ #
72
+ # SOURCE is a special sample which contains the entire source file.
73
+ # :INSERT: SOURCE, { indent: 4 }
74
+ #
75
+ # CODE is a special sample which contains all the non-text portions of this
76
+ # file.
77
+ # :INSERT: CODE, { indent: " > " }
78
+ #
79
+ # We can select specific lines:
80
+ # :INSERT: sally:2
81
+ #
82
+ # Or ranges of lines:
83
+ # :INSERT: sally:2..3
84
+ #
85
+ # Or lines matching a regex:
86
+ # :INSERT: sally:/def/
87
+ #
88
+ # Or ranges of regexen:
89
+ # :INSERT: fred:/puts/.../end/
@@ -0,0 +1,12 @@
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
+ # :SAMPLE:
12
+ # \:PROCESS: foo, bar
@@ -0,0 +1,9 @@
1
+ # A hello, world demo for Germinate
2
+ # This section should not appear in the output
3
+
4
+ # :TEXT:
5
+ # Hello, world!
6
+ # :CUT:
7
+
8
+ def ignore_me
9
+ end
@@ -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