nanoc3 3.0.9 → 3.1.0a1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (104) hide show
  1. data/LICENSE +1 -1
  2. data/NEWS.md +360 -0
  3. data/README.md +85 -0
  4. data/Rakefile +2 -2
  5. data/bin/nanoc3 +0 -4
  6. data/lib/nanoc3/base/code_snippet.rb +14 -6
  7. data/lib/nanoc3/base/compiler.rb +68 -49
  8. data/lib/nanoc3/base/compiler_dsl.rb +70 -29
  9. data/lib/nanoc3/base/context.rb +47 -0
  10. data/lib/nanoc3/base/core_ext/array.rb +4 -0
  11. data/lib/nanoc3/base/core_ext/hash.rb +5 -1
  12. data/lib/nanoc3/base/core_ext/string.rb +2 -0
  13. data/lib/nanoc3/base/data_source.rb +132 -96
  14. data/lib/nanoc3/base/dependency_tracker.rb +160 -185
  15. data/lib/nanoc3/base/directed_graph.rb +252 -0
  16. data/lib/nanoc3/base/errors.rb +52 -4
  17. data/lib/nanoc3/base/filter.rb +43 -28
  18. data/lib/nanoc3/base/item.rb +93 -25
  19. data/lib/nanoc3/base/item_rep.rb +166 -55
  20. data/lib/nanoc3/base/layout.rb +16 -13
  21. data/lib/nanoc3/base/notification_center.rb +28 -12
  22. data/lib/nanoc3/base/plugin_registry.rb +158 -0
  23. data/lib/nanoc3/base/rule.rb +27 -8
  24. data/lib/nanoc3/base/rule_context.rb +59 -46
  25. data/lib/nanoc3/base/site.rb +124 -77
  26. data/lib/nanoc3/base.rb +7 -2
  27. data/lib/nanoc3/cli/base.rb +4 -1
  28. data/lib/nanoc3/cli/commands/autocompile.rb +5 -4
  29. data/lib/nanoc3/cli/commands/compile.rb +28 -7
  30. data/lib/nanoc3/cli/commands/create_item.rb +1 -1
  31. data/lib/nanoc3/cli/commands/create_layout.rb +1 -1
  32. data/lib/nanoc3/cli/commands/create_site.rb +46 -22
  33. data/lib/nanoc3/cli/commands/debug.rb +100 -0
  34. data/lib/nanoc3/cli/commands/help.rb +1 -1
  35. data/lib/nanoc3/cli/commands/info.rb +1 -1
  36. data/lib/nanoc3/cli/commands/view.rb +85 -0
  37. data/lib/nanoc3/cli/commands.rb +2 -0
  38. data/lib/nanoc3/cli/logger.rb +7 -0
  39. data/lib/nanoc3/cli.rb +0 -3
  40. data/lib/nanoc3/data_sources/{delicious.rb → deprecated/delicious.rb} +1 -24
  41. data/lib/nanoc3/data_sources/{last_fm.rb → deprecated/last_fm.rb} +1 -27
  42. data/lib/nanoc3/data_sources/{twitter.rb → deprecated/twitter.rb} +1 -14
  43. data/lib/nanoc3/data_sources/filesystem.rb +188 -176
  44. data/lib/nanoc3/data_sources/filesystem_unified.rb +107 -0
  45. data/lib/nanoc3/data_sources/filesystem_verbose.rb +80 -0
  46. data/lib/nanoc3/data_sources.rb +18 -9
  47. data/lib/nanoc3/extra/core_ext/enumerable.rb +39 -0
  48. data/lib/nanoc3/extra/core_ext/time.rb +2 -2
  49. data/lib/nanoc3/extra/core_ext.rb +1 -0
  50. data/lib/nanoc3/extra/deployers/rsync.rb +49 -3
  51. data/lib/nanoc3/extra/file_proxy.rb +7 -0
  52. data/lib/nanoc3/extra/vcs.rb +25 -24
  53. data/lib/nanoc3/extra/vcses/bazaar.rb +4 -0
  54. data/lib/nanoc3/extra/vcses/dummy.rb +4 -0
  55. data/lib/nanoc3/extra/vcses/git.rb +4 -0
  56. data/lib/nanoc3/extra/vcses/mercurial.rb +4 -0
  57. data/lib/nanoc3/extra/vcses/subversion.rb +4 -0
  58. data/lib/nanoc3/extra.rb +4 -1
  59. data/lib/nanoc3/filters/erb.rb +1 -1
  60. data/lib/nanoc3/filters/erubis.rb +1 -1
  61. data/lib/nanoc3/filters/haml.rb +1 -1
  62. data/lib/nanoc3/filters/kramdown.rb +14 -0
  63. data/lib/nanoc3/filters/maruku.rb +1 -1
  64. data/lib/nanoc3/filters/rainpress.rb +1 -1
  65. data/lib/nanoc3/filters/rdiscount.rb +3 -1
  66. data/lib/nanoc3/filters.rb +2 -0
  67. data/lib/nanoc3/helpers/blogging.rb +91 -75
  68. data/lib/nanoc3/helpers/breadcrumbs.rb +18 -10
  69. data/lib/nanoc3/helpers/capturing.rb +24 -29
  70. data/lib/nanoc3/helpers/filtering.rb +20 -17
  71. data/lib/nanoc3/helpers/html_escape.rb +7 -4
  72. data/lib/nanoc3/helpers/link_to.rb +51 -41
  73. data/lib/nanoc3/helpers/rendering.rb +15 -8
  74. data/lib/nanoc3/helpers/tagging.rb +27 -21
  75. data/lib/nanoc3/helpers/text.rb +12 -8
  76. data/lib/nanoc3/helpers/xml_sitemap.rb +13 -15
  77. data/lib/nanoc3/tasks/deploy/rsync.rake +4 -1
  78. data/lib/nanoc3/tasks.rb +2 -1
  79. data/lib/nanoc3.rb +24 -1
  80. metadata +43 -87
  81. data/NEWS.rdoc +0 -328
  82. data/README.rdoc +0 -83
  83. data/lib/nanoc3/base/plugin.rb +0 -88
  84. data/lib/nanoc3/base/preprocessor_context.rb +0 -37
  85. data/lib/nanoc3/data_sources/filesystem_combined.rb +0 -214
  86. data/lib/nanoc3/data_sources/filesystem_common.rb +0 -22
  87. data/lib/nanoc3/data_sources/filesystem_compact.rb +0 -256
  88. data/lib/nanoc3/extra/context.rb +0 -24
  89. data/lib/nanoc3/package.rb +0 -107
  90. data/vendor/cri/ChangeLog +0 -0
  91. data/vendor/cri/LICENSE +0 -19
  92. data/vendor/cri/NEWS +0 -0
  93. data/vendor/cri/README +0 -4
  94. data/vendor/cri/Rakefile +0 -25
  95. data/vendor/cri/lib/cri/base.rb +0 -153
  96. data/vendor/cri/lib/cri/command.rb +0 -105
  97. data/vendor/cri/lib/cri/core_ext/string.rb +0 -41
  98. data/vendor/cri/lib/cri/core_ext.rb +0 -8
  99. data/vendor/cri/lib/cri/option_parser.rb +0 -186
  100. data/vendor/cri/lib/cri.rb +0 -12
  101. data/vendor/cri/test/test_base.rb +0 -6
  102. data/vendor/cri/test/test_command.rb +0 -6
  103. data/vendor/cri/test/test_core_ext.rb +0 -21
  104. data/vendor/cri/test/test_option_parser.rb +0 -279
@@ -1,279 +0,0 @@
1
- class Cri::OptionParserTest < MiniTest::Unit::TestCase
2
-
3
- def test_parse_without_options
4
- input = %w( foo bar baz )
5
- definitions = []
6
-
7
- result = Cri::OptionParser.parse(input, definitions)
8
-
9
- assert_equal({}, result[:options])
10
- assert_equal([ 'foo', 'bar', 'baz' ], result[:arguments])
11
- end
12
-
13
- def test_parse_with_invalid_option
14
- input = %w( foo -x )
15
- definitions = []
16
-
17
- result = nil
18
-
19
- assert_raises(Cri::OptionParser::IllegalOptionError) do
20
- result = Cri::OptionParser.parse(input, definitions)
21
- end
22
- end
23
-
24
- def test_parse_without_options
25
- input = %w( foo )
26
- definitions = [
27
- { :long => 'aaa', :short => 'a', :argument => :forbidden }
28
- ]
29
-
30
- result = Cri::OptionParser.parse(input, definitions)
31
-
32
- assert(!result[:options][:aaa])
33
- end
34
-
35
- def test_parse_with_long_valueless_option
36
- input = %w( foo --aaa bar )
37
- definitions = [
38
- { :long => 'aaa', :short => 'a', :argument => :forbidden }
39
- ]
40
-
41
- result = Cri::OptionParser.parse(input, definitions)
42
-
43
- assert(result[:options][:aaa])
44
- assert_equal([ 'foo', 'bar' ], result[:arguments])
45
- end
46
-
47
- def test_parse_with_long_valueful_option
48
- input = %w( foo --aaa xxx bar )
49
- definitions = [
50
- { :long => 'aaa', :short => 'a', :argument => :required }
51
- ]
52
-
53
- result = Cri::OptionParser.parse(input, definitions)
54
-
55
- assert_equal({ :aaa => 'xxx' }, result[:options])
56
- assert_equal([ 'foo', 'bar' ], result[:arguments])
57
- end
58
-
59
- def test_parse_with_long_valueful_equalsign_option
60
- input = %w( foo --aaa=xxx bar )
61
- definitions = [
62
- { :long => 'aaa', :short => 'a', :argument => :required }
63
- ]
64
-
65
- result = Cri::OptionParser.parse(input, definitions)
66
-
67
- assert_equal({ :aaa => 'xxx' }, result[:options])
68
- assert_equal([ 'foo', 'bar' ], result[:arguments])
69
- end
70
-
71
- def test_parse_with_long_valueful_option_with_missing_value
72
- input = %w( foo --aaa )
73
- definitions = [
74
- { :long => 'aaa', :short => 'a', :argument => :required }
75
- ]
76
-
77
- result = nil
78
-
79
- assert_raises(Cri::OptionParser::OptionRequiresAnArgumentError) do
80
- result = Cri::OptionParser.parse(input, definitions)
81
- end
82
- end
83
-
84
- def test_parse_with_two_long_valueful_options
85
- input = %w( foo --all --port 2 )
86
- definitions = [
87
- { :long => 'all', :short => 'a', :argument => :required },
88
- { :long => 'port', :short => 'p', :argument => :required }
89
- ]
90
-
91
- result = nil
92
-
93
- assert_raises(Cri::OptionParser::OptionRequiresAnArgumentError) do
94
- result = Cri::OptionParser.parse(input, definitions)
95
- end
96
- end
97
-
98
- def test_parse_with_long_valueless_option_with_optional_value
99
- input = %w( foo --aaa )
100
- definitions = [
101
- { :long => 'aaa', :short => 'a', :argument => :optional }
102
- ]
103
-
104
- result = Cri::OptionParser.parse(input, definitions)
105
-
106
- assert(result[:options][:aaa])
107
- assert_equal([ 'foo' ], result[:arguments])
108
- end
109
-
110
- def test_parse_with_long_valueful_option_with_optional_value
111
- input = %w( foo --aaa xxx )
112
- definitions = [
113
- { :long => 'aaa', :short => 'a', :argument => :optional }
114
- ]
115
-
116
- result = Cri::OptionParser.parse(input, definitions)
117
-
118
- assert_equal({ :aaa => 'xxx' }, result[:options])
119
- assert_equal([ 'foo' ], result[:arguments])
120
- end
121
-
122
- def test_parse_with_long_valueless_option_with_optional_value_and_more_options
123
- input = %w( foo --aaa -b -c )
124
- definitions = [
125
- { :long => 'aaa', :short => 'a', :argument => :optional },
126
- { :long => 'bbb', :short => 'b', :argument => :forbidden },
127
- { :long => 'ccc', :short => 'c', :argument => :forbidden }
128
- ]
129
-
130
- result = Cri::OptionParser.parse(input, definitions)
131
-
132
- assert(result[:options][:aaa])
133
- assert(result[:options][:bbb])
134
- assert(result[:options][:ccc])
135
- assert_equal([ 'foo' ], result[:arguments])
136
- end
137
-
138
- def test_parse_with_short_valueless_options
139
- input = %w( foo -a bar )
140
- definitions = [
141
- { :long => 'aaa', :short => 'a', :argument => :forbidden }
142
- ]
143
-
144
- result = Cri::OptionParser.parse(input, definitions)
145
-
146
- assert(result[:options][:aaa])
147
- assert_equal([ 'foo', 'bar' ], result[:arguments])
148
- end
149
-
150
- def test_parse_with_short_valueful_option_with_missing_value
151
- input = %w( foo -a )
152
- definitions = [
153
- { :long => 'aaa', :short => 'a', :argument => :required }
154
- ]
155
-
156
- result = nil
157
-
158
- assert_raises(Cri::OptionParser::OptionRequiresAnArgumentError) do
159
- result = Cri::OptionParser.parse(input, definitions)
160
- end
161
- end
162
-
163
- def test_parse_with_short_combined_valueless_options
164
- input = %w( foo -abc bar )
165
- definitions = [
166
- { :long => 'aaa', :short => 'a', :argument => :forbidden },
167
- { :long => 'bbb', :short => 'b', :argument => :forbidden },
168
- { :long => 'ccc', :short => 'c', :argument => :forbidden }
169
- ]
170
-
171
- result = Cri::OptionParser.parse(input, definitions)
172
-
173
- assert(result[:options][:aaa])
174
- assert(result[:options][:bbb])
175
- assert(result[:options][:ccc])
176
- assert_equal([ 'foo', 'bar' ], result[:arguments])
177
- end
178
-
179
- def test_parse_with_short_combined_valueful_options_with_missing_value
180
- input = %w( foo -abc bar )
181
- definitions = [
182
- { :long => 'aaa', :short => 'a', :argument => :required },
183
- { :long => 'bbb', :short => 'b', :argument => :forbidden },
184
- { :long => 'ccc', :short => 'c', :argument => :forbidden }
185
- ]
186
-
187
- result = nil
188
-
189
- assert_raises(Cri::OptionParser::OptionRequiresAnArgumentError) do
190
- result = Cri::OptionParser.parse(input, definitions)
191
- end
192
- end
193
-
194
- def test_parse_with_two_short_valueful_options
195
- input = %w( foo -a -p 2 )
196
- definitions = [
197
- { :long => 'all', :short => 'a', :argument => :required },
198
- { :long => 'port', :short => 'p', :argument => :required }
199
- ]
200
-
201
- result = nil
202
-
203
- assert_raises(Cri::OptionParser::OptionRequiresAnArgumentError) do
204
- result = Cri::OptionParser.parse(input, definitions)
205
- end
206
- end
207
-
208
- def test_parse_with_short_valueless_option_with_optional_value
209
- input = %w( foo -a )
210
- definitions = [
211
- { :long => 'aaa', :short => 'a', :argument => :optional }
212
- ]
213
-
214
- result = Cri::OptionParser.parse(input, definitions)
215
-
216
- assert(result[:options][:aaa])
217
- assert_equal([ 'foo' ], result[:arguments])
218
- end
219
-
220
- def test_parse_with_short_valueful_option_with_optional_value
221
- input = %w( foo -a xxx )
222
- definitions = [
223
- { :long => 'aaa', :short => 'a', :argument => :optional }
224
- ]
225
-
226
- result = Cri::OptionParser.parse(input, definitions)
227
-
228
- assert_equal({ :aaa => 'xxx' }, result[:options])
229
- assert_equal([ 'foo' ], result[:arguments])
230
- end
231
-
232
- def test_parse_with_short_valueless_option_with_optional_value_and_more_options
233
- input = %w( foo -a -b -c )
234
- definitions = [
235
- { :long => 'aaa', :short => 'a', :argument => :optional },
236
- { :long => 'bbb', :short => 'b', :argument => :forbidden },
237
- { :long => 'ccc', :short => 'c', :argument => :forbidden }
238
- ]
239
-
240
- result = Cri::OptionParser.parse(input, definitions)
241
-
242
- assert(result[:options][:aaa])
243
- assert(result[:options][:bbb])
244
- assert(result[:options][:ccc])
245
- assert_equal([ 'foo' ], result[:arguments])
246
- end
247
-
248
- def test_parse_with_single_hyphen
249
- input = %w( foo - bar )
250
- definitions = []
251
-
252
- result = Cri::OptionParser.parse(input, definitions)
253
-
254
- assert_equal({}, result[:options])
255
- assert_equal([ 'foo', '-', 'bar' ], result[:arguments])
256
- end
257
-
258
- def test_parse_with_end_marker
259
- input = %w( foo bar -- -x --yyy -abc )
260
- definitions = []
261
-
262
- result = Cri::OptionParser.parse(input, definitions)
263
-
264
- assert_equal({}, result[:options])
265
- assert_equal([ 'foo', 'bar', '-x', '--yyy', '-abc' ], result[:arguments])
266
- end
267
-
268
- def test_parse_with_end_marker_between_option_key_and_value
269
- input = %w( foo --aaa -- zzz )
270
- definitions = [
271
- { :long => 'aaa', :short => 'a', :argument => :required }
272
- ]
273
-
274
- assert_raises(Cri::OptionParser::OptionRequiresAnArgumentError) do
275
- result = Cri::OptionParser.parse(input, definitions)
276
- end
277
- end
278
-
279
- end