nanoc3 3.2.4 → 3.3.0
Sign up to get free protection for your applications and to get access to all the features.
- metadata +14 -313
- data/.gemtest +0 -0
- data/ChangeLog +0 -3
- data/Gemfile +0 -29
- data/LICENSE +0 -19
- data/NEWS.md +0 -449
- data/README.md +0 -108
- data/Rakefile +0 -14
- data/bin/nanoc3 +0 -12
- data/doc/yardoc_templates/default/layout/html/footer.erb +0 -10
- data/lib/nanoc3.rb +0 -28
- data/lib/nanoc3/base.rb +0 -49
- data/lib/nanoc3/base/compilation/checksum_store.rb +0 -57
- data/lib/nanoc3/base/compilation/compiled_content_cache.rb +0 -62
- data/lib/nanoc3/base/compilation/compiler.rb +0 -455
- data/lib/nanoc3/base/compilation/compiler_dsl.rb +0 -214
- data/lib/nanoc3/base/compilation/dependency_tracker.rb +0 -196
- data/lib/nanoc3/base/compilation/filter.rb +0 -165
- data/lib/nanoc3/base/compilation/item_rep_proxy.rb +0 -102
- data/lib/nanoc3/base/compilation/item_rep_recorder_proxy.rb +0 -88
- data/lib/nanoc3/base/compilation/outdatedness_checker.rb +0 -223
- data/lib/nanoc3/base/compilation/outdatedness_reasons.rb +0 -46
- data/lib/nanoc3/base/compilation/rule.rb +0 -73
- data/lib/nanoc3/base/compilation/rule_context.rb +0 -84
- data/lib/nanoc3/base/compilation/rule_memory_calculator.rb +0 -40
- data/lib/nanoc3/base/compilation/rule_memory_store.rb +0 -53
- data/lib/nanoc3/base/compilation/rules_collection.rb +0 -231
- data/lib/nanoc3/base/context.rb +0 -47
- data/lib/nanoc3/base/core_ext.rb +0 -6
- data/lib/nanoc3/base/core_ext/array.rb +0 -62
- data/lib/nanoc3/base/core_ext/hash.rb +0 -63
- data/lib/nanoc3/base/core_ext/pathname.rb +0 -26
- data/lib/nanoc3/base/core_ext/string.rb +0 -46
- data/lib/nanoc3/base/directed_graph.rb +0 -275
- data/lib/nanoc3/base/errors.rb +0 -174
- data/lib/nanoc3/base/memoization.rb +0 -67
- data/lib/nanoc3/base/notification_center.rb +0 -84
- data/lib/nanoc3/base/ordered_hash.rb +0 -200
- data/lib/nanoc3/base/plugin_registry.rb +0 -165
- data/lib/nanoc3/base/result_data/item_rep.rb +0 -488
- data/lib/nanoc3/base/source_data/code_snippet.rb +0 -58
- data/lib/nanoc3/base/source_data/configuration.rb +0 -24
- data/lib/nanoc3/base/source_data/data_source.rb +0 -234
- data/lib/nanoc3/base/source_data/item.rb +0 -301
- data/lib/nanoc3/base/source_data/layout.rb +0 -130
- data/lib/nanoc3/base/source_data/site.rb +0 -361
- data/lib/nanoc3/base/store.rb +0 -135
- data/lib/nanoc3/cli.rb +0 -133
- data/lib/nanoc3/cli/command.rb +0 -139
- data/lib/nanoc3/cli/commands/autocompile.rb +0 -60
- data/lib/nanoc3/cli/commands/compile.rb +0 -280
- data/lib/nanoc3/cli/commands/create_item.rb +0 -62
- data/lib/nanoc3/cli/commands/create_layout.rb +0 -75
- data/lib/nanoc3/cli/commands/create_site.rb +0 -410
- data/lib/nanoc3/cli/commands/debug.rb +0 -119
- data/lib/nanoc3/cli/commands/info.rb +0 -98
- data/lib/nanoc3/cli/commands/nanoc.rb +0 -37
- data/lib/nanoc3/cli/commands/update.rb +0 -72
- data/lib/nanoc3/cli/commands/view.rb +0 -84
- data/lib/nanoc3/cli/commands/watch.rb +0 -125
- data/lib/nanoc3/cli/error_handler.rb +0 -193
- data/lib/nanoc3/cli/logger.rb +0 -91
- data/lib/nanoc3/data_sources.rb +0 -29
- data/lib/nanoc3/data_sources/deprecated/delicious.rb +0 -42
- data/lib/nanoc3/data_sources/deprecated/last_fm.rb +0 -87
- data/lib/nanoc3/data_sources/deprecated/twitter.rb +0 -38
- data/lib/nanoc3/data_sources/filesystem.rb +0 -299
- data/lib/nanoc3/data_sources/filesystem_unified.rb +0 -116
- data/lib/nanoc3/data_sources/filesystem_verbose.rb +0 -86
- data/lib/nanoc3/extra.rb +0 -22
- data/lib/nanoc3/extra/auto_compiler.rb +0 -103
- data/lib/nanoc3/extra/chick.rb +0 -125
- data/lib/nanoc3/extra/core_ext.rb +0 -4
- data/lib/nanoc3/extra/core_ext/enumerable.rb +0 -33
- data/lib/nanoc3/extra/core_ext/time.rb +0 -19
- data/lib/nanoc3/extra/deployers.rb +0 -11
- data/lib/nanoc3/extra/deployers/rsync.rb +0 -114
- data/lib/nanoc3/extra/file_proxy.rb +0 -40
- data/lib/nanoc3/extra/validators.rb +0 -12
- data/lib/nanoc3/extra/validators/links.rb +0 -264
- data/lib/nanoc3/extra/validators/w3c.rb +0 -95
- data/lib/nanoc3/extra/vcs.rb +0 -66
- data/lib/nanoc3/extra/vcses.rb +0 -17
- data/lib/nanoc3/extra/vcses/bazaar.rb +0 -25
- data/lib/nanoc3/extra/vcses/dummy.rb +0 -24
- data/lib/nanoc3/extra/vcses/git.rb +0 -25
- data/lib/nanoc3/extra/vcses/mercurial.rb +0 -25
- data/lib/nanoc3/extra/vcses/subversion.rb +0 -25
- data/lib/nanoc3/filters.rb +0 -53
- data/lib/nanoc3/filters/asciidoc.rb +0 -38
- data/lib/nanoc3/filters/bluecloth.rb +0 -19
- data/lib/nanoc3/filters/coderay.rb +0 -21
- data/lib/nanoc3/filters/colorize_syntax.rb +0 -261
- data/lib/nanoc3/filters/erb.rb +0 -35
- data/lib/nanoc3/filters/erubis.rb +0 -27
- data/lib/nanoc3/filters/haml.rb +0 -27
- data/lib/nanoc3/filters/kramdown.rb +0 -20
- data/lib/nanoc3/filters/less.rb +0 -53
- data/lib/nanoc3/filters/markaby.rb +0 -20
- data/lib/nanoc3/filters/maruku.rb +0 -20
- data/lib/nanoc3/filters/mustache.rb +0 -24
- data/lib/nanoc3/filters/rainpress.rb +0 -19
- data/lib/nanoc3/filters/rdiscount.rb +0 -22
- data/lib/nanoc3/filters/rdoc.rb +0 -33
- data/lib/nanoc3/filters/redcarpet.rb +0 -27
- data/lib/nanoc3/filters/redcloth.rb +0 -47
- data/lib/nanoc3/filters/relativize_paths.rb +0 -45
- data/lib/nanoc3/filters/rubypants.rb +0 -20
- data/lib/nanoc3/filters/sass.rb +0 -66
- data/lib/nanoc3/filters/slim.rb +0 -25
- data/lib/nanoc3/filters/typogruby.rb +0 -23
- data/lib/nanoc3/filters/uglify_js.rb +0 -42
- data/lib/nanoc3/helpers.rb +0 -16
- data/lib/nanoc3/helpers/blogging.rb +0 -319
- data/lib/nanoc3/helpers/breadcrumbs.rb +0 -40
- data/lib/nanoc3/helpers/capturing.rb +0 -138
- data/lib/nanoc3/helpers/filtering.rb +0 -50
- data/lib/nanoc3/helpers/html_escape.rb +0 -55
- data/lib/nanoc3/helpers/link_to.rb +0 -151
- data/lib/nanoc3/helpers/rendering.rb +0 -140
- data/lib/nanoc3/helpers/tagging.rb +0 -71
- data/lib/nanoc3/helpers/text.rb +0 -44
- data/lib/nanoc3/helpers/xml_sitemap.rb +0 -76
- data/lib/nanoc3/tasks.rb +0 -10
- data/lib/nanoc3/tasks/clean.rake +0 -16
- data/lib/nanoc3/tasks/clean.rb +0 -29
- data/lib/nanoc3/tasks/deploy/rsync.rake +0 -14
- data/lib/nanoc3/tasks/validate.rake +0 -92
- data/nanoc3.gemspec +0 -49
- data/tasks/doc.rake +0 -16
- data/tasks/test.rake +0 -44
- data/test/base/core_ext/array_spec.rb +0 -73
- data/test/base/core_ext/hash_spec.rb +0 -98
- data/test/base/core_ext/pathname_spec.rb +0 -27
- data/test/base/core_ext/string_spec.rb +0 -37
- data/test/base/test_checksum_store.rb +0 -35
- data/test/base/test_code_snippet.rb +0 -31
- data/test/base/test_compiler.rb +0 -316
- data/test/base/test_compiler_dsl.rb +0 -161
- data/test/base/test_context.rb +0 -31
- data/test/base/test_data_source.rb +0 -46
- data/test/base/test_dependency_tracker.rb +0 -262
- data/test/base/test_directed_graph.rb +0 -283
- data/test/base/test_filter.rb +0 -83
- data/test/base/test_item.rb +0 -179
- data/test/base/test_item_rep.rb +0 -553
- data/test/base/test_layout.rb +0 -59
- data/test/base/test_memoization.rb +0 -90
- data/test/base/test_notification_center.rb +0 -34
- data/test/base/test_outdatedness_checker.rb +0 -394
- data/test/base/test_plugin.rb +0 -30
- data/test/base/test_rule.rb +0 -19
- data/test/base/test_rule_context.rb +0 -65
- data/test/base/test_site.rb +0 -190
- data/test/cli/commands/test_compile.rb +0 -33
- data/test/cli/commands/test_create_item.rb +0 -14
- data/test/cli/commands/test_create_layout.rb +0 -28
- data/test/cli/commands/test_create_site.rb +0 -24
- data/test/cli/commands/test_help.rb +0 -12
- data/test/cli/commands/test_info.rb +0 -11
- data/test/cli/commands/test_update.rb +0 -10
- data/test/cli/test_cli.rb +0 -102
- data/test/cli/test_error_handler.rb +0 -29
- data/test/cli/test_logger.rb +0 -10
- data/test/data_sources/test_filesystem.rb +0 -433
- data/test/data_sources/test_filesystem_unified.rb +0 -536
- data/test/data_sources/test_filesystem_verbose.rb +0 -357
- data/test/extra/core_ext/test_enumerable.rb +0 -30
- data/test/extra/core_ext/test_time.rb +0 -15
- data/test/extra/deployers/test_rsync.rb +0 -232
- data/test/extra/test_auto_compiler.rb +0 -417
- data/test/extra/test_file_proxy.rb +0 -19
- data/test/extra/test_vcs.rb +0 -22
- data/test/extra/validators/test_links.rb +0 -51
- data/test/extra/validators/test_w3c.rb +0 -47
- data/test/filters/test_asciidoc.rb +0 -22
- data/test/filters/test_bluecloth.rb +0 -18
- data/test/filters/test_coderay.rb +0 -44
- data/test/filters/test_colorize_syntax.rb +0 -283
- data/test/filters/test_erb.rb +0 -99
- data/test/filters/test_erubis.rb +0 -70
- data/test/filters/test_haml.rb +0 -96
- data/test/filters/test_kramdown.rb +0 -18
- data/test/filters/test_less.rb +0 -113
- data/test/filters/test_markaby.rb +0 -24
- data/test/filters/test_maruku.rb +0 -18
- data/test/filters/test_mustache.rb +0 -25
- data/test/filters/test_rainpress.rb +0 -29
- data/test/filters/test_rdiscount.rb +0 -31
- data/test/filters/test_rdoc.rb +0 -18
- data/test/filters/test_redcarpet.rb +0 -63
- data/test/filters/test_redcloth.rb +0 -33
- data/test/filters/test_relativize_paths.rb +0 -332
- data/test/filters/test_rubypants.rb +0 -18
- data/test/filters/test_sass.rb +0 -229
- data/test/filters/test_slim.rb +0 -35
- data/test/filters/test_typogruby.rb +0 -21
- data/test/filters/test_uglify_js.rb +0 -30
- data/test/gem_loader.rb +0 -11
- data/test/helper.rb +0 -179
- data/test/helpers/test_blogging.rb +0 -754
- data/test/helpers/test_breadcrumbs.rb +0 -81
- data/test/helpers/test_capturing.rb +0 -41
- data/test/helpers/test_filtering.rb +0 -106
- data/test/helpers/test_html_escape.rb +0 -32
- data/test/helpers/test_link_to.rb +0 -249
- data/test/helpers/test_rendering.rb +0 -89
- data/test/helpers/test_tagging.rb +0 -87
- data/test/helpers/test_text.rb +0 -24
- data/test/helpers/test_xml_sitemap.rb +0 -103
- data/test/tasks/test_clean.rb +0 -67
@@ -1,283 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
class Nanoc3::DirectedGraphTest < MiniTest::Unit::TestCase
|
4
|
-
|
5
|
-
include Nanoc3::TestHelpers
|
6
|
-
|
7
|
-
def test_direct_predecessors
|
8
|
-
graph = Nanoc3::DirectedGraph.new([ 1, 2, 3 ])
|
9
|
-
graph.add_edge(1, 2)
|
10
|
-
graph.add_edge(2, 3)
|
11
|
-
|
12
|
-
assert_equal [], graph.direct_predecessors_of(1)
|
13
|
-
assert_equal [ 1 ], graph.direct_predecessors_of(2)
|
14
|
-
assert_equal [ 2 ], graph.direct_predecessors_of(3)
|
15
|
-
end
|
16
|
-
|
17
|
-
def test_predecessors
|
18
|
-
graph = Nanoc3::DirectedGraph.new([ 1, 2, 3 ])
|
19
|
-
graph.add_edge(1, 2)
|
20
|
-
graph.add_edge(2, 3)
|
21
|
-
|
22
|
-
assert_equal [], graph.predecessors_of(1).sort
|
23
|
-
assert_equal [ 1 ], graph.predecessors_of(2).sort
|
24
|
-
assert_equal [ 1, 2 ], graph.predecessors_of(3).sort
|
25
|
-
end
|
26
|
-
|
27
|
-
def test_direct_successors
|
28
|
-
graph = Nanoc3::DirectedGraph.new([ 1, 2, 3 ])
|
29
|
-
graph.add_edge(1, 2)
|
30
|
-
graph.add_edge(2, 3)
|
31
|
-
|
32
|
-
assert_equal [ 2 ], graph.direct_successors_of(1)
|
33
|
-
assert_equal [ 3 ], graph.direct_successors_of(2)
|
34
|
-
assert_equal [], graph.direct_successors_of(3)
|
35
|
-
end
|
36
|
-
|
37
|
-
def test_successors
|
38
|
-
graph = Nanoc3::DirectedGraph.new([ 1, 2, 3 ])
|
39
|
-
graph.add_edge(1, 2)
|
40
|
-
graph.add_edge(2, 3)
|
41
|
-
|
42
|
-
assert_equal [ 2, 3 ], graph.successors_of(1).sort
|
43
|
-
assert_equal [ 3 ], graph.successors_of(2).sort
|
44
|
-
assert_equal [], graph.successors_of(3).sort
|
45
|
-
end
|
46
|
-
|
47
|
-
def test_edges
|
48
|
-
graph = Nanoc3::DirectedGraph.new([ 1, 2, 3 ])
|
49
|
-
graph.add_edge(1, 2)
|
50
|
-
graph.add_edge(2, 3)
|
51
|
-
|
52
|
-
assert_equal [ [ 0, 1 ], [ 1, 2 ] ], graph.edges.sort
|
53
|
-
end
|
54
|
-
|
55
|
-
def test_edges_with_new_vertices
|
56
|
-
graph = Nanoc3::DirectedGraph.new([ 1 ])
|
57
|
-
graph.add_edge(1, 2)
|
58
|
-
graph.add_edge(3, 2)
|
59
|
-
|
60
|
-
assert_equal [ [ 0, 1 ], [ 2, 1 ] ], graph.edges.sort
|
61
|
-
end
|
62
|
-
|
63
|
-
def test_add_edge
|
64
|
-
graph = Nanoc3::DirectedGraph.new([ 1, 2, 3 ])
|
65
|
-
|
66
|
-
assert_equal [], graph.successors_of(1)
|
67
|
-
assert_equal [], graph.predecessors_of(2)
|
68
|
-
|
69
|
-
graph.add_edge(1, 2)
|
70
|
-
|
71
|
-
assert_equal [ 2 ], graph.successors_of(1)
|
72
|
-
assert_equal [ 1 ], graph.predecessors_of(2)
|
73
|
-
end
|
74
|
-
|
75
|
-
def test_add_edge_with_new_vertices
|
76
|
-
graph = Nanoc3::DirectedGraph.new([ 1 ])
|
77
|
-
graph.add_edge(1, 2)
|
78
|
-
graph.add_edge(3, 2)
|
79
|
-
|
80
|
-
assert graph.vertices.include?(2)
|
81
|
-
assert graph.vertices.include?(3)
|
82
|
-
end
|
83
|
-
|
84
|
-
def test_delete_edge
|
85
|
-
graph = Nanoc3::DirectedGraph.new([ 1, 2, 3 ])
|
86
|
-
graph.add_edge(1,2)
|
87
|
-
|
88
|
-
assert_equal [ 2 ], graph.successors_of(1)
|
89
|
-
assert_equal [ 1 ], graph.predecessors_of(2)
|
90
|
-
|
91
|
-
graph.delete_edge(1, 2)
|
92
|
-
|
93
|
-
assert_equal [], graph.successors_of(1)
|
94
|
-
assert_equal [], graph.predecessors_of(2)
|
95
|
-
end
|
96
|
-
|
97
|
-
def test_delete_edges_from
|
98
|
-
graph = Nanoc3::DirectedGraph.new([ 1, 2, 3 ])
|
99
|
-
|
100
|
-
graph.add_edge(1, 2)
|
101
|
-
graph.add_edge(2, 1)
|
102
|
-
graph.add_edge(2, 3)
|
103
|
-
graph.add_edge(3, 2)
|
104
|
-
graph.add_edge(1, 3)
|
105
|
-
graph.add_edge(3, 1)
|
106
|
-
|
107
|
-
assert_equal [ 2, 3 ], graph.direct_predecessors_of(1).sort
|
108
|
-
assert_equal [ 2, 3 ], graph.direct_successors_of(1).sort
|
109
|
-
assert_equal [ 1, 3 ], graph.direct_predecessors_of(2).sort
|
110
|
-
assert_equal [ 1, 3 ], graph.direct_successors_of(2).sort
|
111
|
-
assert_equal [ 1, 2 ], graph.direct_predecessors_of(3).sort
|
112
|
-
assert_equal [ 1, 2 ], graph.direct_successors_of(3).sort
|
113
|
-
assert_equal Set.new([]), graph.roots
|
114
|
-
|
115
|
-
graph.delete_edges_from(1)
|
116
|
-
|
117
|
-
assert_equal [ 2, 3 ], graph.direct_predecessors_of(1).sort
|
118
|
-
assert_equal [ ], graph.direct_successors_of(1).sort
|
119
|
-
assert_equal [ 3 ], graph.direct_predecessors_of(2).sort
|
120
|
-
assert_equal [ 1, 3 ], graph.direct_successors_of(2).sort
|
121
|
-
assert_equal [ 2 ], graph.direct_predecessors_of(3).sort
|
122
|
-
assert_equal [ 1, 2 ], graph.direct_successors_of(3).sort
|
123
|
-
assert_equal Set.new([]), graph.roots
|
124
|
-
|
125
|
-
graph.delete_edges_from(2)
|
126
|
-
|
127
|
-
assert_equal [ 3 ], graph.direct_predecessors_of(1).sort
|
128
|
-
assert_equal [ ], graph.direct_successors_of(1).sort
|
129
|
-
assert_equal [ 3 ], graph.direct_predecessors_of(2).sort
|
130
|
-
assert_equal [ ], graph.direct_successors_of(2).sort
|
131
|
-
assert_equal [ ], graph.direct_predecessors_of(3).sort
|
132
|
-
assert_equal [ 1, 2 ], graph.direct_successors_of(3).sort
|
133
|
-
assert_equal Set.new([ 3 ]), graph.roots
|
134
|
-
end
|
135
|
-
|
136
|
-
def test_delete_edges_to
|
137
|
-
graph = Nanoc3::DirectedGraph.new([ 1, 2, 3 ])
|
138
|
-
|
139
|
-
graph.add_edge(1, 2)
|
140
|
-
graph.add_edge(2, 1)
|
141
|
-
graph.add_edge(2, 3)
|
142
|
-
graph.add_edge(3, 2)
|
143
|
-
graph.add_edge(1, 3)
|
144
|
-
graph.add_edge(3, 1)
|
145
|
-
|
146
|
-
assert_equal [ 2, 3 ], graph.direct_predecessors_of(1).sort
|
147
|
-
assert_equal [ 2, 3 ], graph.direct_successors_of(1).sort
|
148
|
-
assert_equal [ 1, 3 ], graph.direct_predecessors_of(2).sort
|
149
|
-
assert_equal [ 1, 3 ], graph.direct_successors_of(2).sort
|
150
|
-
assert_equal [ 1, 2 ], graph.direct_predecessors_of(3).sort
|
151
|
-
assert_equal [ 1, 2 ], graph.direct_successors_of(3).sort
|
152
|
-
assert_equal Set.new([]), graph.roots
|
153
|
-
|
154
|
-
graph.delete_edges_to(1)
|
155
|
-
|
156
|
-
assert_equal [ ], graph.direct_predecessors_of(1).sort
|
157
|
-
assert_equal [ 2, 3 ], graph.direct_successors_of(1).sort
|
158
|
-
assert_equal [ 1, 3 ], graph.direct_predecessors_of(2).sort
|
159
|
-
assert_equal [ 3 ], graph.direct_successors_of(2).sort
|
160
|
-
assert_equal [ 1, 2 ], graph.direct_predecessors_of(3).sort
|
161
|
-
assert_equal [ 2 ], graph.direct_successors_of(3).sort
|
162
|
-
assert_equal Set.new([ 1 ]), graph.roots
|
163
|
-
|
164
|
-
graph.delete_edges_to(2)
|
165
|
-
|
166
|
-
assert_equal [ ], graph.direct_predecessors_of(1).sort
|
167
|
-
assert_equal [ 3 ], graph.direct_successors_of(1).sort
|
168
|
-
assert_equal [ ], graph.direct_predecessors_of(2).sort
|
169
|
-
assert_equal [ 3 ], graph.direct_successors_of(2).sort
|
170
|
-
assert_equal [ 1, 2 ], graph.direct_predecessors_of(3).sort
|
171
|
-
assert_equal [ ], graph.direct_successors_of(3).sort
|
172
|
-
assert_equal Set.new([ 1, 2 ]), graph.roots
|
173
|
-
end
|
174
|
-
|
175
|
-
def test_delete_vertex
|
176
|
-
graph = Nanoc3::DirectedGraph.new([ 1, 2, 3 ])
|
177
|
-
|
178
|
-
graph.add_edge(1, 2)
|
179
|
-
graph.add_edge(2, 1)
|
180
|
-
graph.add_edge(2, 3)
|
181
|
-
graph.add_edge(3, 2)
|
182
|
-
graph.add_edge(1, 3)
|
183
|
-
graph.add_edge(3, 1)
|
184
|
-
|
185
|
-
graph.delete_vertex(2)
|
186
|
-
|
187
|
-
assert_equal [ 3 ], graph.direct_predecessors_of(1).sort
|
188
|
-
assert_equal [ 3 ], graph.direct_successors_of(1).sort
|
189
|
-
assert_equal [ 1 ], graph.direct_predecessors_of(3).sort
|
190
|
-
assert_equal [ 1 ], graph.direct_successors_of(3).sort
|
191
|
-
assert_equal Set.new([]), graph.roots
|
192
|
-
end
|
193
|
-
|
194
|
-
def test_delete_vertex_resulting_roots
|
195
|
-
graph = Nanoc3::DirectedGraph.new([ 1, 2, 3 ])
|
196
|
-
assert_equal Set.new([ 1, 2, 3 ]), graph.roots
|
197
|
-
|
198
|
-
graph.add_edge(1, 2)
|
199
|
-
graph.add_edge(2, 3)
|
200
|
-
assert_equal Set.new([ 1 ]), graph.roots
|
201
|
-
|
202
|
-
graph.delete_vertex(2)
|
203
|
-
assert_equal Set.new([ 1, 3 ]), graph.roots
|
204
|
-
end
|
205
|
-
|
206
|
-
def test_should_return_empty_array_for_nonexistant_vertices
|
207
|
-
graph = Nanoc3::DirectedGraph.new([ 1, 2, 3 ])
|
208
|
-
|
209
|
-
assert_equal [], graph.direct_predecessors_of(4)
|
210
|
-
assert_equal [], graph.predecessors_of(4)
|
211
|
-
assert_equal [], graph.direct_successors_of(4)
|
212
|
-
assert_equal [], graph.successors_of(4)
|
213
|
-
end
|
214
|
-
|
215
|
-
def test_roots_after_init
|
216
|
-
graph = Nanoc3::DirectedGraph.new([ 1, 2, 3 ])
|
217
|
-
|
218
|
-
assert_equal Set.new([ 1, 2, 3 ]), graph.roots
|
219
|
-
end
|
220
|
-
|
221
|
-
def test_roots_after_adding_edge
|
222
|
-
graph = Nanoc3::DirectedGraph.new([ 1, 2, 3 ])
|
223
|
-
graph.add_edge(1, 2)
|
224
|
-
assert_equal Set.new([ 1, 3 ]), graph.roots
|
225
|
-
|
226
|
-
graph = Nanoc3::DirectedGraph.new([ 1, 2, 3 ])
|
227
|
-
graph.add_edge(1, 3)
|
228
|
-
assert_equal Set.new([ 1, 2 ]), graph.roots
|
229
|
-
|
230
|
-
graph = Nanoc3::DirectedGraph.new([ 1, 2, 3 ])
|
231
|
-
graph.add_edge(2, 1)
|
232
|
-
assert_equal Set.new([ 2, 3 ]), graph.roots
|
233
|
-
|
234
|
-
graph = Nanoc3::DirectedGraph.new([ 1, 2, 3 ])
|
235
|
-
graph.add_edge(1, 2)
|
236
|
-
graph.add_edge(2, 3)
|
237
|
-
assert_equal Set.new([ 1 ]), graph.roots
|
238
|
-
|
239
|
-
graph = Nanoc3::DirectedGraph.new([ 1, 2, 3 ])
|
240
|
-
graph.add_edge(1, 2)
|
241
|
-
graph.add_edge(2, 3)
|
242
|
-
graph.add_edge(3, 1)
|
243
|
-
assert_equal Set.new([]), graph.roots
|
244
|
-
end
|
245
|
-
|
246
|
-
def test_roots_after_removing_edge
|
247
|
-
graph = Nanoc3::DirectedGraph.new([ 1, 2, 3 ])
|
248
|
-
graph.add_edge(1, 2)
|
249
|
-
graph.delete_edge(1, 2)
|
250
|
-
assert_equal Set.new([ 1, 2, 3 ]), graph.roots
|
251
|
-
|
252
|
-
graph = Nanoc3::DirectedGraph.new([ 1, 2, 3 ])
|
253
|
-
graph.add_edge(1, 3)
|
254
|
-
assert_equal Set.new([ 1, 2 ]), graph.roots
|
255
|
-
graph.delete_edge(1, 2) # no such edge
|
256
|
-
assert_equal Set.new([ 1, 2 ]), graph.roots
|
257
|
-
|
258
|
-
graph = Nanoc3::DirectedGraph.new([ 1, 2, 3 ])
|
259
|
-
graph.add_edge(2, 1)
|
260
|
-
graph.delete_edge(2, 1)
|
261
|
-
assert_equal Set.new([ 1, 2, 3 ]), graph.roots
|
262
|
-
|
263
|
-
graph = Nanoc3::DirectedGraph.new([ 1, 2, 3 ])
|
264
|
-
graph.add_edge(1, 2)
|
265
|
-
graph.add_edge(2, 3)
|
266
|
-
graph.delete_edge(1, 2)
|
267
|
-
assert_equal Set.new([ 1, 2 ]), graph.roots
|
268
|
-
graph.delete_edge(2, 3)
|
269
|
-
assert_equal Set.new([ 1, 2, 3 ]), graph.roots
|
270
|
-
|
271
|
-
graph = Nanoc3::DirectedGraph.new([ 1, 2, 3 ])
|
272
|
-
graph.add_edge(1, 2)
|
273
|
-
graph.add_edge(2, 3)
|
274
|
-
graph.add_edge(3, 1)
|
275
|
-
graph.delete_edge(1, 2)
|
276
|
-
assert_equal Set.new([ 2 ]), graph.roots
|
277
|
-
graph.delete_edge(2, 3)
|
278
|
-
assert_equal Set.new([ 2, 3 ]), graph.roots
|
279
|
-
graph.delete_edge(3, 1)
|
280
|
-
assert_equal Set.new([ 1, 2, 3 ]), graph.roots
|
281
|
-
end
|
282
|
-
|
283
|
-
end
|
data/test/base/test_filter.rb
DELETED
@@ -1,83 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
class Nanoc3::FilterTest < MiniTest::Unit::TestCase
|
4
|
-
|
5
|
-
include Nanoc3::TestHelpers
|
6
|
-
|
7
|
-
def test_initialize
|
8
|
-
# Create filter
|
9
|
-
filter = Nanoc3::Filter.new
|
10
|
-
|
11
|
-
# Test assigns
|
12
|
-
assert_equal({}, filter.instance_eval { @assigns })
|
13
|
-
end
|
14
|
-
|
15
|
-
def test_assigns
|
16
|
-
# Create filter
|
17
|
-
filter = Nanoc3::Filter.new({ :foo => 'bar' })
|
18
|
-
|
19
|
-
# Check assigns
|
20
|
-
assert_equal('bar', filter.assigns[:foo])
|
21
|
-
end
|
22
|
-
|
23
|
-
def test_assigns_with_instance_variables
|
24
|
-
# Create filter
|
25
|
-
filter = Nanoc3::Filter.new({ :foo => 'bar' })
|
26
|
-
|
27
|
-
# Check assigns
|
28
|
-
assert_equal('bar', filter.instance_eval { @foo })
|
29
|
-
end
|
30
|
-
|
31
|
-
def test_assigns_with_instance_methods
|
32
|
-
# Create filter
|
33
|
-
filter = Nanoc3::Filter.new({ :foo => 'bar' })
|
34
|
-
|
35
|
-
# Check assigns
|
36
|
-
assert_equal('bar', filter.instance_eval { foo })
|
37
|
-
end
|
38
|
-
|
39
|
-
def test_run
|
40
|
-
# Create filter
|
41
|
-
filter = Nanoc3::Filter.new
|
42
|
-
|
43
|
-
# Make sure an error is raised
|
44
|
-
assert_raises(NotImplementedError) do
|
45
|
-
filter.run(nil)
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
def test_filename_item
|
50
|
-
# Mock items
|
51
|
-
item = mock
|
52
|
-
item.expects(:identifier).returns('/foo/bar/baz/')
|
53
|
-
item_rep = mock
|
54
|
-
item_rep.expects(:name).returns(:quux)
|
55
|
-
|
56
|
-
# Create filter
|
57
|
-
filter = Nanoc3::Filter.new({ :item => item, :item_rep => item_rep })
|
58
|
-
|
59
|
-
# Check filename
|
60
|
-
assert_equal('item /foo/bar/baz/ (rep quux)', filter.filename)
|
61
|
-
end
|
62
|
-
|
63
|
-
def test_filename_layout
|
64
|
-
# Mock items
|
65
|
-
layout = mock
|
66
|
-
layout.expects(:identifier).returns('/wohba/')
|
67
|
-
|
68
|
-
# Create filter
|
69
|
-
filter = Nanoc3::Filter.new({ :item => mock, :item_rep => mock, :layout => layout })
|
70
|
-
|
71
|
-
# Check filename
|
72
|
-
assert_equal('layout /wohba/', filter.filename)
|
73
|
-
end
|
74
|
-
|
75
|
-
def test_filename_unknown
|
76
|
-
# Create filter
|
77
|
-
filter = Nanoc3::Filter.new({})
|
78
|
-
|
79
|
-
# Check filename
|
80
|
-
assert_equal('?', filter.filename)
|
81
|
-
end
|
82
|
-
|
83
|
-
end
|
data/test/base/test_item.rb
DELETED
@@ -1,179 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
class Nanoc3::ItemTest < MiniTest::Unit::TestCase
|
4
|
-
|
5
|
-
include Nanoc3::TestHelpers
|
6
|
-
|
7
|
-
def test_initialize_with_attributes_with_string_keys
|
8
|
-
item = Nanoc3::Item.new("foo", { 'abc' => 'xyz' }, '/foo/')
|
9
|
-
|
10
|
-
assert_equal nil, item.attributes['abc']
|
11
|
-
assert_equal 'xyz', item.attributes[:abc]
|
12
|
-
end
|
13
|
-
|
14
|
-
def test_initialize_with_unclean_identifier
|
15
|
-
item = Nanoc3::Item.new("foo", {}, '/foo')
|
16
|
-
|
17
|
-
assert_equal '/foo/', item.identifier
|
18
|
-
end
|
19
|
-
|
20
|
-
def test_frozen_identifier
|
21
|
-
item = Nanoc3::Item.new("foo", {}, '/foo')
|
22
|
-
|
23
|
-
raised = false
|
24
|
-
begin
|
25
|
-
item.identifier.chop!
|
26
|
-
rescue => error
|
27
|
-
raised = true
|
28
|
-
assert_match /^can't modify frozen [Ss]tring$/, error.message
|
29
|
-
end
|
30
|
-
assert raised, 'Should have raised when trying to modify a frozen string'
|
31
|
-
end
|
32
|
-
|
33
|
-
def test_lookup
|
34
|
-
# Create item
|
35
|
-
item = Nanoc3::Item.new(
|
36
|
-
"content",
|
37
|
-
{ :one => 'one in item' },
|
38
|
-
'/path/'
|
39
|
-
)
|
40
|
-
|
41
|
-
# Test finding one
|
42
|
-
assert_equal('one in item', item[:one])
|
43
|
-
|
44
|
-
# Test finding two
|
45
|
-
assert_equal(nil, item[:two])
|
46
|
-
end
|
47
|
-
|
48
|
-
def test_set_attribute
|
49
|
-
item = Nanoc3::Item.new("foo", {}, '/foo')
|
50
|
-
assert_equal nil, item[:motto]
|
51
|
-
|
52
|
-
item[:motto] = 'More human than human'
|
53
|
-
assert_equal 'More human than human', item[:motto]
|
54
|
-
end
|
55
|
-
|
56
|
-
def test_compiled_content_with_default_rep_and_default_snapshot
|
57
|
-
# Mock rep
|
58
|
-
rep = Object.new
|
59
|
-
def rep.name ; :default ; end
|
60
|
-
def rep.compiled_content(params)
|
61
|
-
"content at #{params[:snapshot].inspect}"
|
62
|
-
end
|
63
|
-
|
64
|
-
# Mock item
|
65
|
-
item = Nanoc3::Item.new("foo", {}, '/foo')
|
66
|
-
item.expects(:reps).returns([ rep ])
|
67
|
-
|
68
|
-
# Check
|
69
|
-
assert_equal 'content at nil', item.compiled_content
|
70
|
-
end
|
71
|
-
|
72
|
-
def test_compiled_content_with_custom_rep_and_default_snapshot
|
73
|
-
# Mock reps
|
74
|
-
rep = Object.new
|
75
|
-
def rep.name ; :foo ; end
|
76
|
-
def rep.compiled_content(params)
|
77
|
-
"content at #{params[:snapshot].inspect}"
|
78
|
-
end
|
79
|
-
|
80
|
-
# Mock item
|
81
|
-
item = Nanoc3::Item.new("foo", {}, '/foo')
|
82
|
-
item.expects(:reps).returns([ rep ])
|
83
|
-
|
84
|
-
# Check
|
85
|
-
assert_equal 'content at nil', item.compiled_content(:rep => :foo)
|
86
|
-
end
|
87
|
-
|
88
|
-
def test_compiled_content_with_default_rep_and_custom_snapshot
|
89
|
-
# Mock reps
|
90
|
-
rep = Object.new
|
91
|
-
def rep.name ; :default ; end
|
92
|
-
def rep.compiled_content(params)
|
93
|
-
"content at #{params[:snapshot].inspect}"
|
94
|
-
end
|
95
|
-
|
96
|
-
# Mock item
|
97
|
-
item = Nanoc3::Item.new("foo", {}, '/foo')
|
98
|
-
item.expects(:reps).returns([ rep ])
|
99
|
-
|
100
|
-
# Check
|
101
|
-
assert_equal 'content at :blah', item.compiled_content(:snapshot => :blah)
|
102
|
-
end
|
103
|
-
|
104
|
-
def test_compiled_content_with_custom_nonexistant_rep
|
105
|
-
# Mock item
|
106
|
-
item = Nanoc3::Item.new("foo", {}, '/foo')
|
107
|
-
item.expects(:reps).returns([])
|
108
|
-
|
109
|
-
# Check
|
110
|
-
assert_raises(Nanoc3::Errors::Generic) do
|
111
|
-
item.compiled_content(:rep => :lkasdhflahgwfe)
|
112
|
-
end
|
113
|
-
end
|
114
|
-
|
115
|
-
def test_path_with_default_rep
|
116
|
-
# Mock reps
|
117
|
-
rep = mock
|
118
|
-
rep.expects(:name).returns(:default)
|
119
|
-
rep.expects(:path).returns('the correct path')
|
120
|
-
|
121
|
-
# Mock item
|
122
|
-
item = Nanoc3::Item.new("foo", {}, '/foo')
|
123
|
-
item.expects(:reps).returns([ rep ])
|
124
|
-
|
125
|
-
# Check
|
126
|
-
assert_equal 'the correct path', item.path
|
127
|
-
end
|
128
|
-
|
129
|
-
def test_path_with_custom_rep
|
130
|
-
# Mock reps
|
131
|
-
rep = mock
|
132
|
-
rep.expects(:name).returns(:moo)
|
133
|
-
rep.expects(:path).returns('the correct path')
|
134
|
-
|
135
|
-
# Mock item
|
136
|
-
item = Nanoc3::Item.new("foo", {}, '/foo')
|
137
|
-
item.expects(:reps).returns([ rep ])
|
138
|
-
|
139
|
-
# Check
|
140
|
-
assert_equal 'the correct path', item.path(:rep => :moo)
|
141
|
-
end
|
142
|
-
|
143
|
-
def test_freeze_should_disallow_changes
|
144
|
-
item = Nanoc3::Item.new("foo", { :a => { :b => 123 }}, '/foo/')
|
145
|
-
item.freeze
|
146
|
-
|
147
|
-
raised = false
|
148
|
-
begin
|
149
|
-
item[:abc] = '123'
|
150
|
-
rescue => e
|
151
|
-
raised = true
|
152
|
-
assert_match /^can't modify frozen /, e.message
|
153
|
-
end
|
154
|
-
assert raised
|
155
|
-
|
156
|
-
raised = false
|
157
|
-
begin
|
158
|
-
item[:a][:b] = '456'
|
159
|
-
rescue => e
|
160
|
-
raised = true
|
161
|
-
assert_match /^can't modify frozen /, e.message
|
162
|
-
end
|
163
|
-
assert raised
|
164
|
-
end
|
165
|
-
|
166
|
-
def test_dump_and_load
|
167
|
-
item = Nanoc3::Item.new(
|
168
|
-
"foobar",
|
169
|
-
{ :a => { :b => 123 }},
|
170
|
-
'/foo/')
|
171
|
-
|
172
|
-
item = Marshal.load(Marshal.dump(item))
|
173
|
-
|
174
|
-
assert_equal '/foo/', item.identifier
|
175
|
-
assert_equal 'foobar', item.raw_content
|
176
|
-
assert_equal({ :a => { :b => 123 }}, item.attributes)
|
177
|
-
end
|
178
|
-
|
179
|
-
end
|