nanoc 3.7.3 → 3.7.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +71 -46
- data/NEWS.md +14 -0
- data/lib/nanoc.rb +1 -1
- data/lib/nanoc/base/checksummer.rb +1 -1
- data/lib/nanoc/base/compilation/checksum_store.rb +1 -1
- data/lib/nanoc/base/compilation/compiled_content_cache.rb +1 -1
- data/lib/nanoc/base/compilation/compiler.rb +11 -10
- data/lib/nanoc/base/compilation/compiler_dsl.rb +4 -4
- data/lib/nanoc/base/compilation/dependency_tracker.rb +7 -7
- data/lib/nanoc/base/compilation/filter.rb +1 -1
- data/lib/nanoc/base/compilation/item_rep_proxy.rb +6 -5
- data/lib/nanoc/base/compilation/item_rep_recorder_proxy.rb +8 -7
- data/lib/nanoc/base/compilation/outdatedness_checker.rb +6 -6
- data/lib/nanoc/base/compilation/rule.rb +1 -1
- data/lib/nanoc/base/compilation/rule_memory_store.rb +1 -1
- data/lib/nanoc/base/compilation/rules_collection.rb +5 -5
- data/lib/nanoc/base/context.rb +1 -1
- data/lib/nanoc/base/core_ext/array.rb +1 -1
- data/lib/nanoc/base/core_ext/date.rb +1 -1
- data/lib/nanoc/base/core_ext/hash.rb +1 -1
- data/lib/nanoc/base/directed_graph.rb +3 -3
- data/lib/nanoc/base/memoization.rb +1 -1
- data/lib/nanoc/base/notification_center.rb +1 -1
- data/lib/nanoc/base/ordered_hash.rb +1 -1
- data/lib/nanoc/base/plugin_registry.rb +3 -3
- data/lib/nanoc/base/result_data/item_rep.rb +13 -11
- data/lib/nanoc/base/source_data/code_snippet.rb +2 -2
- data/lib/nanoc/base/source_data/data_source.rb +3 -3
- data/lib/nanoc/base/source_data/item.rb +8 -8
- data/lib/nanoc/base/source_data/item_array.rb +1 -1
- data/lib/nanoc/base/source_data/layout.rb +1 -1
- data/lib/nanoc/base/source_data/site.rb +27 -18
- data/lib/nanoc/base/store.rb +3 -3
- data/lib/nanoc/base/temp_filename_factory.rb +2 -2
- data/lib/nanoc/cli.rb +6 -6
- data/lib/nanoc/cli/cleaning_stream.rb +1 -1
- data/lib/nanoc/cli/command_runner.rb +4 -3
- data/lib/nanoc/cli/commands/autocompile.rb +3 -3
- data/lib/nanoc/cli/commands/check.rb +3 -3
- data/lib/nanoc/cli/commands/compile.rb +23 -23
- data/lib/nanoc/cli/commands/create-item.rb +5 -5
- data/lib/nanoc/cli/commands/create-layout.rb +14 -14
- data/lib/nanoc/cli/commands/create-site.rb +6 -6
- data/lib/nanoc/cli/commands/deploy.rb +8 -8
- data/lib/nanoc/cli/commands/nanoc.rb +3 -3
- data/lib/nanoc/cli/commands/prune.rb +3 -3
- data/lib/nanoc/cli/commands/shell.rb +4 -4
- data/lib/nanoc/cli/commands/show-data.rb +5 -5
- data/lib/nanoc/cli/commands/show-plugins.rb +5 -5
- data/lib/nanoc/cli/commands/show-rules.rb +4 -4
- data/lib/nanoc/cli/commands/sync.rb +1 -1
- data/lib/nanoc/cli/commands/update.rb +13 -13
- data/lib/nanoc/cli/commands/validate-css.rb +3 -3
- data/lib/nanoc/cli/commands/validate-html.rb +3 -3
- data/lib/nanoc/cli/commands/validate-links.rb +6 -6
- data/lib/nanoc/cli/commands/view.rb +4 -4
- data/lib/nanoc/cli/commands/watch.rb +11 -11
- data/lib/nanoc/cli/error_handler.rb +10 -10
- data/lib/nanoc/cli/logger.rb +1 -1
- data/lib/nanoc/cli/stream_cleaners/abstract.rb +1 -1
- data/lib/nanoc/data_sources/deprecated/last_fm.rb +5 -5
- data/lib/nanoc/data_sources/deprecated/twitter.rb +1 -1
- data/lib/nanoc/data_sources/filesystem.rb +16 -16
- data/lib/nanoc/data_sources/filesystem_unified.rb +1 -1
- data/lib/nanoc/data_sources/filesystem_verbose.rb +1 -1
- data/lib/nanoc/data_sources/static.rb +1 -1
- data/lib/nanoc/extra/auto_compiler.rb +2 -2
- data/lib/nanoc/extra/checking/check.rb +11 -1
- data/lib/nanoc/extra/checking/checks/external_links.rb +15 -7
- data/lib/nanoc/extra/checking/checks/internal_links.rb +3 -3
- data/lib/nanoc/extra/checking/checks/stale.rb +6 -6
- data/lib/nanoc/extra/checking/runner.rb +10 -9
- data/lib/nanoc/extra/chick.rb +2 -2
- data/lib/nanoc/extra/core_ext/enumerable.rb +1 -1
- data/lib/nanoc/extra/deployers/fog.rb +2 -2
- data/lib/nanoc/extra/deployers/rsync.rb +3 -3
- data/lib/nanoc/extra/file_proxy.rb +3 -3
- data/lib/nanoc/extra/jruby_nokogiri_warner.rb +1 -1
- data/lib/nanoc/extra/link_collector.rb +3 -3
- data/lib/nanoc/extra/piper.rb +2 -2
- data/lib/nanoc/extra/pruner.rb +4 -3
- data/lib/nanoc/extra/validators/links.rb +2 -2
- data/lib/nanoc/extra/validators/w3c.rb +1 -1
- data/lib/nanoc/extra/vcs.rb +5 -5
- data/lib/nanoc/extra/vcses/dummy.rb +1 -1
- data/lib/nanoc/filters/asciidoc.rb +1 -1
- data/lib/nanoc/filters/bluecloth.rb +1 -1
- data/lib/nanoc/filters/coffeescript.rb +1 -1
- data/lib/nanoc/filters/colorize_syntax.rb +19 -21
- data/lib/nanoc/filters/erubis.rb +1 -1
- data/lib/nanoc/filters/handlebars.rb +1 -1
- data/lib/nanoc/filters/less.rb +2 -2
- data/lib/nanoc/filters/markaby.rb +1 -1
- data/lib/nanoc/filters/mustache.rb +1 -1
- data/lib/nanoc/filters/rdoc.rb +1 -1
- data/lib/nanoc/filters/relativize_paths.rb +5 -5
- data/lib/nanoc/filters/rubypants.rb +1 -1
- data/lib/nanoc/filters/sass/sass_filesystem_importer.rb +1 -1
- data/lib/nanoc/filters/typogruby.rb +1 -1
- data/lib/nanoc/filters/xsl.rb +1 -1
- data/lib/nanoc/helpers/blogging.rb +12 -12
- data/lib/nanoc/helpers/capturing.rb +3 -3
- data/lib/nanoc/helpers/html_escape.rb +6 -6
- data/lib/nanoc/helpers/tagging.rb +1 -1
- data/lib/nanoc/helpers/xml_sitemap.rb +4 -4
- data/lib/nanoc/tasks/clean.rake +1 -1
- data/lib/nanoc/tasks/clean.rb +1 -1
- data/lib/nanoc/tasks/deploy/rsync.rake +2 -2
- data/lib/nanoc/version.rb +1 -1
- data/tasks/rubocop.rake +1 -0
- data/test/base/core_ext/array_spec.rb +7 -7
- data/test/base/core_ext/hash_spec.rb +1 -1
- data/test/base/test_checksum_store.rb +1 -1
- data/test/base/test_compiler.rb +14 -14
- data/test/base/test_compiler_dsl.rb +13 -13
- data/test/base/test_context.rb +2 -2
- data/test/base/test_dependency_tracker.rb +42 -42
- data/test/base/test_directed_graph.rb +102 -102
- data/test/base/test_item.rb +21 -21
- data/test/base/test_item_array.rb +19 -19
- data/test/base/test_item_rep.rb +50 -50
- data/test/base/test_layout.rb +6 -6
- data/test/base/test_outdatedness_checker.rb +2 -2
- data/test/base/test_rule_context.rb +2 -2
- data/test/base/test_site.rb +5 -5
- data/test/cli/commands/test_compile.rb +7 -7
- data/test/cli/commands/test_create_site.rb +2 -2
- data/test/cli/commands/test_deploy.rb +10 -10
- data/test/cli/commands/test_prune.rb +2 -2
- data/test/cli/commands/test_sync.rb +1 -1
- data/test/cli/commands/test_watch.rb +7 -7
- data/test/cli/test_cleaning_stream.rb +4 -4
- data/test/cli/test_cli.rb +3 -3
- data/test/cli/test_error_handler.rb +3 -3
- data/test/data_sources/test_filesystem.rb +19 -19
- data/test/data_sources/test_filesystem_unified.rb +30 -30
- data/test/data_sources/test_filesystem_verbose.rb +3 -3
- data/test/data_sources/test_static.rb +9 -9
- data/test/extra/checking/checks/test_stale.rb +8 -8
- data/test/extra/checking/test_check.rb +11 -1
- data/test/extra/checking/test_dsl.rb +1 -1
- data/test/extra/core_ext/test_enumerable.rb +2 -2
- data/test/extra/deployers/test_fog.rb +10 -10
- data/test/extra/deployers/test_rsync.rb +2 -2
- data/test/extra/test_auto_compiler.rb +28 -28
- data/test/extra/test_filesystem_tools.rb +3 -3
- data/test/extra/test_link_collector.rb +39 -20
- data/test/extra/validators/test_w3c.rb +5 -5
- data/test/filters/test_asciidoc.rb +2 -2
- data/test/filters/test_bluecloth.rb +1 -1
- data/test/filters/test_coffeescript.rb +1 -1
- data/test/filters/test_colorize_syntax.rb +20 -13
- data/test/filters/test_erb.rb +1 -1
- data/test/filters/test_kramdown.rb +1 -1
- data/test/filters/test_less.rb +10 -10
- data/test/filters/test_markaby.rb +2 -2
- data/test/filters/test_maruku.rb +2 -2
- data/test/filters/test_pandoc.rb +3 -3
- data/test/filters/test_rainpress.rb +4 -4
- data/test/filters/test_rdiscount.rb +2 -2
- data/test/filters/test_rdoc.rb +1 -1
- data/test/filters/test_redcarpet.rb +5 -5
- data/test/filters/test_redcloth.rb +5 -5
- data/test/filters/test_relativize_paths.rb +33 -31
- data/test/filters/test_rubypants.rb +2 -2
- data/test/filters/test_sass.rb +8 -8
- data/test/filters/test_slim.rb +3 -3
- data/test/filters/test_uglify_js.rb +1 -1
- data/test/filters/test_yui_compressor.rb +3 -3
- data/test/gem_loader.rb +1 -1
- data/test/helper.rb +14 -16
- data/test/helpers/test_blogging.rb +28 -28
- data/test/helpers/test_breadcrumbs.rb +12 -12
- data/test/helpers/test_capturing.rb +7 -7
- data/test/helpers/test_filtering.rb +16 -16
- data/test/helpers/test_link_to.rb +3 -3
- data/test/helpers/test_rendering.rb +1 -1
- data/test/helpers/test_tagging.rb +11 -11
- data/test/helpers/test_xml_sitemap.rb +18 -18
- data/test/tasks/test_clean.rb +8 -8
- metadata +2 -2
@@ -3,78 +3,78 @@
|
|
3
3
|
class Nanoc::DirectedGraphTest < Nanoc::TestCase
|
4
4
|
|
5
5
|
def test_direct_predecessors
|
6
|
-
graph = Nanoc::DirectedGraph.new([
|
6
|
+
graph = Nanoc::DirectedGraph.new([1, 2, 3])
|
7
7
|
graph.add_edge(1, 2)
|
8
8
|
graph.add_edge(2, 3)
|
9
9
|
|
10
10
|
assert_equal [], graph.direct_predecessors_of(1)
|
11
|
-
assert_equal [
|
12
|
-
assert_equal [
|
11
|
+
assert_equal [1], graph.direct_predecessors_of(2)
|
12
|
+
assert_equal [2], graph.direct_predecessors_of(3)
|
13
13
|
end
|
14
14
|
|
15
15
|
def test_predecessors
|
16
|
-
graph = Nanoc::DirectedGraph.new([
|
16
|
+
graph = Nanoc::DirectedGraph.new([1, 2, 3])
|
17
17
|
graph.add_edge(1, 2)
|
18
18
|
graph.add_edge(2, 3)
|
19
19
|
|
20
20
|
assert_equal [], graph.predecessors_of(1).sort
|
21
|
-
assert_equal [
|
22
|
-
assert_equal [
|
21
|
+
assert_equal [1], graph.predecessors_of(2).sort
|
22
|
+
assert_equal [1, 2], graph.predecessors_of(3).sort
|
23
23
|
end
|
24
24
|
|
25
25
|
def test_direct_successors
|
26
|
-
graph = Nanoc::DirectedGraph.new([
|
26
|
+
graph = Nanoc::DirectedGraph.new([1, 2, 3])
|
27
27
|
graph.add_edge(1, 2)
|
28
28
|
graph.add_edge(2, 3)
|
29
29
|
|
30
|
-
assert_equal [
|
31
|
-
assert_equal [
|
30
|
+
assert_equal [2], graph.direct_successors_of(1)
|
31
|
+
assert_equal [3], graph.direct_successors_of(2)
|
32
32
|
assert_equal [], graph.direct_successors_of(3)
|
33
33
|
end
|
34
34
|
|
35
35
|
def test_successors
|
36
|
-
graph = Nanoc::DirectedGraph.new([
|
36
|
+
graph = Nanoc::DirectedGraph.new([1, 2, 3])
|
37
37
|
graph.add_edge(1, 2)
|
38
38
|
graph.add_edge(2, 3)
|
39
39
|
|
40
|
-
assert_equal [
|
41
|
-
assert_equal [
|
40
|
+
assert_equal [2, 3], graph.successors_of(1).sort
|
41
|
+
assert_equal [3], graph.successors_of(2).sort
|
42
42
|
assert_equal [], graph.successors_of(3).sort
|
43
43
|
end
|
44
44
|
|
45
45
|
def test_edges
|
46
|
-
graph = Nanoc::DirectedGraph.new([
|
46
|
+
graph = Nanoc::DirectedGraph.new([1, 2, 3])
|
47
47
|
graph.add_edge(1, 2)
|
48
48
|
graph.add_edge(2, 3)
|
49
49
|
|
50
|
-
assert_equal [
|
50
|
+
assert_equal [[0, 1], [1, 2]], graph.edges.sort
|
51
51
|
end
|
52
52
|
|
53
53
|
def test_edges_with_new_vertices
|
54
|
-
graph = Nanoc::DirectedGraph.new([
|
55
|
-
assert_equal [
|
54
|
+
graph = Nanoc::DirectedGraph.new([1])
|
55
|
+
assert_equal [1], graph.vertices
|
56
56
|
graph.add_edge(1, 2)
|
57
|
-
assert_equal [
|
57
|
+
assert_equal [1, 2], graph.vertices
|
58
58
|
graph.add_edge(3, 2)
|
59
|
-
assert_equal [
|
59
|
+
assert_equal [1, 2, 3], graph.vertices
|
60
60
|
|
61
|
-
assert_equal [
|
61
|
+
assert_equal [[0, 1], [2, 1]], graph.edges.sort
|
62
62
|
end
|
63
63
|
|
64
64
|
def test_add_edge
|
65
|
-
graph = Nanoc::DirectedGraph.new([
|
65
|
+
graph = Nanoc::DirectedGraph.new([1, 2, 3])
|
66
66
|
|
67
67
|
assert_equal [], graph.successors_of(1)
|
68
68
|
assert_equal [], graph.predecessors_of(2)
|
69
69
|
|
70
70
|
graph.add_edge(1, 2)
|
71
71
|
|
72
|
-
assert_equal [
|
73
|
-
assert_equal [
|
72
|
+
assert_equal [2], graph.successors_of(1)
|
73
|
+
assert_equal [1], graph.predecessors_of(2)
|
74
74
|
end
|
75
75
|
|
76
76
|
def test_add_edge_with_new_vertices
|
77
|
-
graph = Nanoc::DirectedGraph.new([
|
77
|
+
graph = Nanoc::DirectedGraph.new([1])
|
78
78
|
graph.add_edge(1, 2)
|
79
79
|
graph.add_edge(3, 2)
|
80
80
|
|
@@ -83,11 +83,11 @@ class Nanoc::DirectedGraphTest < Nanoc::TestCase
|
|
83
83
|
end
|
84
84
|
|
85
85
|
def test_delete_edge
|
86
|
-
graph = Nanoc::DirectedGraph.new([
|
86
|
+
graph = Nanoc::DirectedGraph.new([1, 2, 3])
|
87
87
|
graph.add_edge(1,2)
|
88
88
|
|
89
|
-
assert_equal [
|
90
|
-
assert_equal [
|
89
|
+
assert_equal [2], graph.successors_of(1)
|
90
|
+
assert_equal [1], graph.predecessors_of(2)
|
91
91
|
|
92
92
|
graph.delete_edge(1, 2)
|
93
93
|
|
@@ -96,7 +96,7 @@ class Nanoc::DirectedGraphTest < Nanoc::TestCase
|
|
96
96
|
end
|
97
97
|
|
98
98
|
def test_delete_edges_from
|
99
|
-
graph = Nanoc::DirectedGraph.new([
|
99
|
+
graph = Nanoc::DirectedGraph.new([1, 2, 3])
|
100
100
|
|
101
101
|
graph.add_edge(1, 2)
|
102
102
|
graph.add_edge(2, 1)
|
@@ -105,37 +105,37 @@ class Nanoc::DirectedGraphTest < Nanoc::TestCase
|
|
105
105
|
graph.add_edge(1, 3)
|
106
106
|
graph.add_edge(3, 1)
|
107
107
|
|
108
|
-
assert_equal [
|
109
|
-
assert_equal [
|
110
|
-
assert_equal [
|
111
|
-
assert_equal [
|
112
|
-
assert_equal [
|
113
|
-
assert_equal [
|
108
|
+
assert_equal [2, 3], graph.direct_predecessors_of(1).sort
|
109
|
+
assert_equal [2, 3], graph.direct_successors_of(1).sort
|
110
|
+
assert_equal [1, 3], graph.direct_predecessors_of(2).sort
|
111
|
+
assert_equal [1, 3], graph.direct_successors_of(2).sort
|
112
|
+
assert_equal [1, 2], graph.direct_predecessors_of(3).sort
|
113
|
+
assert_equal [1, 2], graph.direct_successors_of(3).sort
|
114
114
|
assert_equal Set.new([]), graph.roots
|
115
115
|
|
116
116
|
graph.delete_edges_from(1)
|
117
117
|
|
118
|
-
assert_equal [
|
119
|
-
assert_equal [
|
120
|
-
assert_equal [
|
121
|
-
assert_equal [
|
122
|
-
assert_equal [
|
123
|
-
assert_equal [
|
118
|
+
assert_equal [2, 3], graph.direct_predecessors_of(1).sort
|
119
|
+
assert_equal [], graph.direct_successors_of(1).sort
|
120
|
+
assert_equal [3], graph.direct_predecessors_of(2).sort
|
121
|
+
assert_equal [1, 3], graph.direct_successors_of(2).sort
|
122
|
+
assert_equal [2], graph.direct_predecessors_of(3).sort
|
123
|
+
assert_equal [1, 2], graph.direct_successors_of(3).sort
|
124
124
|
assert_equal Set.new([]), graph.roots
|
125
125
|
|
126
126
|
graph.delete_edges_from(2)
|
127
127
|
|
128
|
-
assert_equal [
|
129
|
-
assert_equal [
|
130
|
-
assert_equal [
|
131
|
-
assert_equal [
|
132
|
-
assert_equal [
|
133
|
-
assert_equal [
|
134
|
-
assert_equal Set.new([
|
128
|
+
assert_equal [3], graph.direct_predecessors_of(1).sort
|
129
|
+
assert_equal [], graph.direct_successors_of(1).sort
|
130
|
+
assert_equal [3], graph.direct_predecessors_of(2).sort
|
131
|
+
assert_equal [], graph.direct_successors_of(2).sort
|
132
|
+
assert_equal [], graph.direct_predecessors_of(3).sort
|
133
|
+
assert_equal [1, 2], graph.direct_successors_of(3).sort
|
134
|
+
assert_equal Set.new([3]), graph.roots
|
135
135
|
end
|
136
136
|
|
137
137
|
def test_delete_edges_to
|
138
|
-
graph = Nanoc::DirectedGraph.new([
|
138
|
+
graph = Nanoc::DirectedGraph.new([1, 2, 3])
|
139
139
|
|
140
140
|
graph.add_edge(1, 2)
|
141
141
|
graph.add_edge(2, 1)
|
@@ -144,37 +144,37 @@ class Nanoc::DirectedGraphTest < Nanoc::TestCase
|
|
144
144
|
graph.add_edge(1, 3)
|
145
145
|
graph.add_edge(3, 1)
|
146
146
|
|
147
|
-
assert_equal [
|
148
|
-
assert_equal [
|
149
|
-
assert_equal [
|
150
|
-
assert_equal [
|
151
|
-
assert_equal [
|
152
|
-
assert_equal [
|
147
|
+
assert_equal [2, 3], graph.direct_predecessors_of(1).sort
|
148
|
+
assert_equal [2, 3], graph.direct_successors_of(1).sort
|
149
|
+
assert_equal [1, 3], graph.direct_predecessors_of(2).sort
|
150
|
+
assert_equal [1, 3], graph.direct_successors_of(2).sort
|
151
|
+
assert_equal [1, 2], graph.direct_predecessors_of(3).sort
|
152
|
+
assert_equal [1, 2], graph.direct_successors_of(3).sort
|
153
153
|
assert_equal Set.new([]), graph.roots
|
154
154
|
|
155
155
|
graph.delete_edges_to(1)
|
156
156
|
|
157
|
-
assert_equal [
|
158
|
-
assert_equal [
|
159
|
-
assert_equal [
|
160
|
-
assert_equal [
|
161
|
-
assert_equal [
|
162
|
-
assert_equal [
|
163
|
-
assert_equal Set.new([
|
157
|
+
assert_equal [], graph.direct_predecessors_of(1).sort
|
158
|
+
assert_equal [2, 3], graph.direct_successors_of(1).sort
|
159
|
+
assert_equal [1, 3], graph.direct_predecessors_of(2).sort
|
160
|
+
assert_equal [3], graph.direct_successors_of(2).sort
|
161
|
+
assert_equal [1, 2], graph.direct_predecessors_of(3).sort
|
162
|
+
assert_equal [2], graph.direct_successors_of(3).sort
|
163
|
+
assert_equal Set.new([1]), graph.roots
|
164
164
|
|
165
165
|
graph.delete_edges_to(2)
|
166
166
|
|
167
|
-
assert_equal [
|
168
|
-
assert_equal [
|
169
|
-
assert_equal [
|
170
|
-
assert_equal [
|
171
|
-
assert_equal [
|
172
|
-
assert_equal [
|
173
|
-
assert_equal Set.new([
|
167
|
+
assert_equal [], graph.direct_predecessors_of(1).sort
|
168
|
+
assert_equal [3], graph.direct_successors_of(1).sort
|
169
|
+
assert_equal [], graph.direct_predecessors_of(2).sort
|
170
|
+
assert_equal [3], graph.direct_successors_of(2).sort
|
171
|
+
assert_equal [1, 2], graph.direct_predecessors_of(3).sort
|
172
|
+
assert_equal [], graph.direct_successors_of(3).sort
|
173
|
+
assert_equal Set.new([1, 2]), graph.roots
|
174
174
|
end
|
175
175
|
|
176
176
|
def test_delete_vertex
|
177
|
-
graph = Nanoc::DirectedGraph.new([
|
177
|
+
graph = Nanoc::DirectedGraph.new([1, 2, 3])
|
178
178
|
|
179
179
|
graph.add_edge(1, 2)
|
180
180
|
graph.add_edge(2, 1)
|
@@ -185,27 +185,27 @@ class Nanoc::DirectedGraphTest < Nanoc::TestCase
|
|
185
185
|
|
186
186
|
graph.delete_vertex(2)
|
187
187
|
|
188
|
-
assert_equal [
|
189
|
-
assert_equal [
|
190
|
-
assert_equal [
|
191
|
-
assert_equal [
|
188
|
+
assert_equal [3], graph.direct_predecessors_of(1).sort
|
189
|
+
assert_equal [3], graph.direct_successors_of(1).sort
|
190
|
+
assert_equal [1], graph.direct_predecessors_of(3).sort
|
191
|
+
assert_equal [1], graph.direct_successors_of(3).sort
|
192
192
|
assert_equal Set.new([]), graph.roots
|
193
193
|
end
|
194
194
|
|
195
195
|
def test_delete_vertex_resulting_roots
|
196
|
-
graph = Nanoc::DirectedGraph.new([
|
197
|
-
assert_equal Set.new([
|
196
|
+
graph = Nanoc::DirectedGraph.new([1, 2, 3])
|
197
|
+
assert_equal Set.new([1, 2, 3]), graph.roots
|
198
198
|
|
199
199
|
graph.add_edge(1, 2)
|
200
200
|
graph.add_edge(2, 3)
|
201
|
-
assert_equal Set.new([
|
201
|
+
assert_equal Set.new([1]), graph.roots
|
202
202
|
|
203
203
|
graph.delete_vertex(2)
|
204
|
-
assert_equal Set.new([
|
204
|
+
assert_equal Set.new([1, 3]), graph.roots
|
205
205
|
end
|
206
206
|
|
207
207
|
def test_should_return_empty_array_for_nonexistant_vertices
|
208
|
-
graph = Nanoc::DirectedGraph.new([
|
208
|
+
graph = Nanoc::DirectedGraph.new([1, 2, 3])
|
209
209
|
|
210
210
|
assert_equal [], graph.direct_predecessors_of(4)
|
211
211
|
assert_equal [], graph.predecessors_of(4)
|
@@ -214,30 +214,30 @@ class Nanoc::DirectedGraphTest < Nanoc::TestCase
|
|
214
214
|
end
|
215
215
|
|
216
216
|
def test_roots_after_init
|
217
|
-
graph = Nanoc::DirectedGraph.new([
|
217
|
+
graph = Nanoc::DirectedGraph.new([1, 2, 3])
|
218
218
|
|
219
|
-
assert_equal Set.new([
|
219
|
+
assert_equal Set.new([1, 2, 3]), graph.roots
|
220
220
|
end
|
221
221
|
|
222
222
|
def test_roots_after_adding_edge
|
223
|
-
graph = Nanoc::DirectedGraph.new([
|
223
|
+
graph = Nanoc::DirectedGraph.new([1, 2, 3])
|
224
224
|
graph.add_edge(1, 2)
|
225
|
-
assert_equal Set.new([
|
225
|
+
assert_equal Set.new([1, 3]), graph.roots
|
226
226
|
|
227
|
-
graph = Nanoc::DirectedGraph.new([
|
227
|
+
graph = Nanoc::DirectedGraph.new([1, 2, 3])
|
228
228
|
graph.add_edge(1, 3)
|
229
|
-
assert_equal Set.new([
|
229
|
+
assert_equal Set.new([1, 2]), graph.roots
|
230
230
|
|
231
|
-
graph = Nanoc::DirectedGraph.new([
|
231
|
+
graph = Nanoc::DirectedGraph.new([1, 2, 3])
|
232
232
|
graph.add_edge(2, 1)
|
233
|
-
assert_equal Set.new([
|
233
|
+
assert_equal Set.new([2, 3]), graph.roots
|
234
234
|
|
235
|
-
graph = Nanoc::DirectedGraph.new([
|
235
|
+
graph = Nanoc::DirectedGraph.new([1, 2, 3])
|
236
236
|
graph.add_edge(1, 2)
|
237
237
|
graph.add_edge(2, 3)
|
238
|
-
assert_equal Set.new([
|
238
|
+
assert_equal Set.new([1]), graph.roots
|
239
239
|
|
240
|
-
graph = Nanoc::DirectedGraph.new([
|
240
|
+
graph = Nanoc::DirectedGraph.new([1, 2, 3])
|
241
241
|
graph.add_edge(1, 2)
|
242
242
|
graph.add_edge(2, 3)
|
243
243
|
graph.add_edge(3, 1)
|
@@ -245,40 +245,40 @@ class Nanoc::DirectedGraphTest < Nanoc::TestCase
|
|
245
245
|
end
|
246
246
|
|
247
247
|
def test_roots_after_removing_edge
|
248
|
-
graph = Nanoc::DirectedGraph.new([
|
248
|
+
graph = Nanoc::DirectedGraph.new([1, 2, 3])
|
249
249
|
graph.add_edge(1, 2)
|
250
250
|
graph.delete_edge(1, 2)
|
251
|
-
assert_equal Set.new([
|
251
|
+
assert_equal Set.new([1, 2, 3]), graph.roots
|
252
252
|
|
253
|
-
graph = Nanoc::DirectedGraph.new([
|
253
|
+
graph = Nanoc::DirectedGraph.new([1, 2, 3])
|
254
254
|
graph.add_edge(1, 3)
|
255
|
-
assert_equal Set.new([
|
255
|
+
assert_equal Set.new([1, 2]), graph.roots
|
256
256
|
graph.delete_edge(1, 2) # no such edge
|
257
|
-
assert_equal Set.new([
|
257
|
+
assert_equal Set.new([1, 2]), graph.roots
|
258
258
|
|
259
|
-
graph = Nanoc::DirectedGraph.new([
|
259
|
+
graph = Nanoc::DirectedGraph.new([1, 2, 3])
|
260
260
|
graph.add_edge(2, 1)
|
261
261
|
graph.delete_edge(2, 1)
|
262
|
-
assert_equal Set.new([
|
262
|
+
assert_equal Set.new([1, 2, 3]), graph.roots
|
263
263
|
|
264
|
-
graph = Nanoc::DirectedGraph.new([
|
264
|
+
graph = Nanoc::DirectedGraph.new([1, 2, 3])
|
265
265
|
graph.add_edge(1, 2)
|
266
266
|
graph.add_edge(2, 3)
|
267
267
|
graph.delete_edge(1, 2)
|
268
|
-
assert_equal Set.new([
|
268
|
+
assert_equal Set.new([1, 2]), graph.roots
|
269
269
|
graph.delete_edge(2, 3)
|
270
|
-
assert_equal Set.new([
|
270
|
+
assert_equal Set.new([1, 2, 3]), graph.roots
|
271
271
|
|
272
|
-
graph = Nanoc::DirectedGraph.new([
|
272
|
+
graph = Nanoc::DirectedGraph.new([1, 2, 3])
|
273
273
|
graph.add_edge(1, 2)
|
274
274
|
graph.add_edge(2, 3)
|
275
275
|
graph.add_edge(3, 1)
|
276
276
|
graph.delete_edge(1, 2)
|
277
|
-
assert_equal Set.new([
|
277
|
+
assert_equal Set.new([2]), graph.roots
|
278
278
|
graph.delete_edge(2, 3)
|
279
|
-
assert_equal Set.new([
|
279
|
+
assert_equal Set.new([2, 3]), graph.roots
|
280
280
|
graph.delete_edge(3, 1)
|
281
|
-
assert_equal Set.new([
|
281
|
+
assert_equal Set.new([1, 2, 3]), graph.roots
|
282
282
|
end
|
283
283
|
|
284
284
|
def test_example
|
data/test/base/test_item.rb
CHANGED
@@ -3,20 +3,20 @@
|
|
3
3
|
class Nanoc::ItemTest < Nanoc::TestCase
|
4
4
|
|
5
5
|
def test_initialize_with_attributes_with_string_keys
|
6
|
-
item = Nanoc::Item.new(
|
6
|
+
item = Nanoc::Item.new('foo', { 'abc' => 'xyz' }, '/foo/')
|
7
7
|
|
8
8
|
assert_equal nil, item.attributes['abc']
|
9
9
|
assert_equal 'xyz', item.attributes[:abc]
|
10
10
|
end
|
11
11
|
|
12
12
|
def test_initialize_with_unclean_identifier
|
13
|
-
item = Nanoc::Item.new(
|
13
|
+
item = Nanoc::Item.new('foo', {}, '/foo')
|
14
14
|
|
15
15
|
assert_equal '/foo/', item.identifier
|
16
16
|
end
|
17
17
|
|
18
18
|
def test_frozen_identifier
|
19
|
-
item = Nanoc::Item.new(
|
19
|
+
item = Nanoc::Item.new('foo', {}, '/foo')
|
20
20
|
|
21
21
|
assert_raises_frozen_error do
|
22
22
|
item.identifier.chop!
|
@@ -26,7 +26,7 @@ class Nanoc::ItemTest < Nanoc::TestCase
|
|
26
26
|
def test_lookup
|
27
27
|
# Create item
|
28
28
|
item = Nanoc::Item.new(
|
29
|
-
|
29
|
+
'content',
|
30
30
|
{ :one => 'one in item' },
|
31
31
|
'/path/'
|
32
32
|
)
|
@@ -39,7 +39,7 @@ class Nanoc::ItemTest < Nanoc::TestCase
|
|
39
39
|
end
|
40
40
|
|
41
41
|
def test_set_attribute
|
42
|
-
item = Nanoc::Item.new(
|
42
|
+
item = Nanoc::Item.new('foo', {}, '/foo')
|
43
43
|
assert_equal nil, item[:motto]
|
44
44
|
|
45
45
|
item[:motto] = 'More human than human'
|
@@ -49,14 +49,14 @@ class Nanoc::ItemTest < Nanoc::TestCase
|
|
49
49
|
def test_compiled_content_with_default_rep_and_default_snapshot
|
50
50
|
# Mock rep
|
51
51
|
rep = Object.new
|
52
|
-
def rep.name
|
52
|
+
def rep.name; :default; end
|
53
53
|
def rep.compiled_content(params)
|
54
54
|
"content at #{params[:snapshot].inspect}"
|
55
55
|
end
|
56
56
|
|
57
57
|
# Mock item
|
58
|
-
item = Nanoc::Item.new(
|
59
|
-
item.expects(:reps).returns([
|
58
|
+
item = Nanoc::Item.new('foo', {}, '/foo')
|
59
|
+
item.expects(:reps).returns([rep])
|
60
60
|
|
61
61
|
# Check
|
62
62
|
assert_equal 'content at nil', item.compiled_content
|
@@ -65,14 +65,14 @@ class Nanoc::ItemTest < Nanoc::TestCase
|
|
65
65
|
def test_compiled_content_with_custom_rep_and_default_snapshot
|
66
66
|
# Mock reps
|
67
67
|
rep = Object.new
|
68
|
-
def rep.name
|
68
|
+
def rep.name; :foo; end
|
69
69
|
def rep.compiled_content(params)
|
70
70
|
"content at #{params[:snapshot].inspect}"
|
71
71
|
end
|
72
72
|
|
73
73
|
# Mock item
|
74
|
-
item = Nanoc::Item.new(
|
75
|
-
item.expects(:reps).returns([
|
74
|
+
item = Nanoc::Item.new('foo', {}, '/foo')
|
75
|
+
item.expects(:reps).returns([rep])
|
76
76
|
|
77
77
|
# Check
|
78
78
|
assert_equal 'content at nil', item.compiled_content(:rep => :foo)
|
@@ -81,14 +81,14 @@ class Nanoc::ItemTest < Nanoc::TestCase
|
|
81
81
|
def test_compiled_content_with_default_rep_and_custom_snapshot
|
82
82
|
# Mock reps
|
83
83
|
rep = Object.new
|
84
|
-
def rep.name
|
84
|
+
def rep.name; :default; end
|
85
85
|
def rep.compiled_content(params)
|
86
86
|
"content at #{params[:snapshot].inspect}"
|
87
87
|
end
|
88
88
|
|
89
89
|
# Mock item
|
90
|
-
item = Nanoc::Item.new(
|
91
|
-
item.expects(:reps).returns([
|
90
|
+
item = Nanoc::Item.new('foo', {}, '/foo')
|
91
|
+
item.expects(:reps).returns([rep])
|
92
92
|
|
93
93
|
# Check
|
94
94
|
assert_equal 'content at :blah', item.compiled_content(:snapshot => :blah)
|
@@ -96,7 +96,7 @@ class Nanoc::ItemTest < Nanoc::TestCase
|
|
96
96
|
|
97
97
|
def test_compiled_content_with_custom_nonexistant_rep
|
98
98
|
# Mock item
|
99
|
-
item = Nanoc::Item.new(
|
99
|
+
item = Nanoc::Item.new('foo', {}, '/foo')
|
100
100
|
item.expects(:reps).returns([])
|
101
101
|
|
102
102
|
# Check
|
@@ -112,8 +112,8 @@ class Nanoc::ItemTest < Nanoc::TestCase
|
|
112
112
|
rep.expects(:path).returns('the correct path')
|
113
113
|
|
114
114
|
# Mock item
|
115
|
-
item = Nanoc::Item.new(
|
116
|
-
item.expects(:reps).returns([
|
115
|
+
item = Nanoc::Item.new('foo', {}, '/foo')
|
116
|
+
item.expects(:reps).returns([rep])
|
117
117
|
|
118
118
|
# Check
|
119
119
|
assert_equal 'the correct path', item.path
|
@@ -126,15 +126,15 @@ class Nanoc::ItemTest < Nanoc::TestCase
|
|
126
126
|
rep.expects(:path).returns('the correct path')
|
127
127
|
|
128
128
|
# Mock item
|
129
|
-
item = Nanoc::Item.new(
|
130
|
-
item.expects(:reps).returns([
|
129
|
+
item = Nanoc::Item.new('foo', {}, '/foo')
|
130
|
+
item.expects(:reps).returns([rep])
|
131
131
|
|
132
132
|
# Check
|
133
133
|
assert_equal 'the correct path', item.path(:rep => :moo)
|
134
134
|
end
|
135
135
|
|
136
136
|
def test_freeze_should_disallow_changes
|
137
|
-
item = Nanoc::Item.new(
|
137
|
+
item = Nanoc::Item.new('foo', { :a => { :b => 123 }}, '/foo/')
|
138
138
|
item.freeze
|
139
139
|
|
140
140
|
assert_raises_frozen_error do
|
@@ -148,7 +148,7 @@ class Nanoc::ItemTest < Nanoc::TestCase
|
|
148
148
|
|
149
149
|
def test_dump_and_load
|
150
150
|
item = Nanoc::Item.new(
|
151
|
-
|
151
|
+
'foobar',
|
152
152
|
{ :a => { :b => 123 }},
|
153
153
|
'/foo/')
|
154
154
|
|