nanoc3 3.2.4 → 3.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (211) hide show
  1. metadata +14 -313
  2. data/.gemtest +0 -0
  3. data/ChangeLog +0 -3
  4. data/Gemfile +0 -29
  5. data/LICENSE +0 -19
  6. data/NEWS.md +0 -449
  7. data/README.md +0 -108
  8. data/Rakefile +0 -14
  9. data/bin/nanoc3 +0 -12
  10. data/doc/yardoc_templates/default/layout/html/footer.erb +0 -10
  11. data/lib/nanoc3.rb +0 -28
  12. data/lib/nanoc3/base.rb +0 -49
  13. data/lib/nanoc3/base/compilation/checksum_store.rb +0 -57
  14. data/lib/nanoc3/base/compilation/compiled_content_cache.rb +0 -62
  15. data/lib/nanoc3/base/compilation/compiler.rb +0 -455
  16. data/lib/nanoc3/base/compilation/compiler_dsl.rb +0 -214
  17. data/lib/nanoc3/base/compilation/dependency_tracker.rb +0 -196
  18. data/lib/nanoc3/base/compilation/filter.rb +0 -165
  19. data/lib/nanoc3/base/compilation/item_rep_proxy.rb +0 -102
  20. data/lib/nanoc3/base/compilation/item_rep_recorder_proxy.rb +0 -88
  21. data/lib/nanoc3/base/compilation/outdatedness_checker.rb +0 -223
  22. data/lib/nanoc3/base/compilation/outdatedness_reasons.rb +0 -46
  23. data/lib/nanoc3/base/compilation/rule.rb +0 -73
  24. data/lib/nanoc3/base/compilation/rule_context.rb +0 -84
  25. data/lib/nanoc3/base/compilation/rule_memory_calculator.rb +0 -40
  26. data/lib/nanoc3/base/compilation/rule_memory_store.rb +0 -53
  27. data/lib/nanoc3/base/compilation/rules_collection.rb +0 -231
  28. data/lib/nanoc3/base/context.rb +0 -47
  29. data/lib/nanoc3/base/core_ext.rb +0 -6
  30. data/lib/nanoc3/base/core_ext/array.rb +0 -62
  31. data/lib/nanoc3/base/core_ext/hash.rb +0 -63
  32. data/lib/nanoc3/base/core_ext/pathname.rb +0 -26
  33. data/lib/nanoc3/base/core_ext/string.rb +0 -46
  34. data/lib/nanoc3/base/directed_graph.rb +0 -275
  35. data/lib/nanoc3/base/errors.rb +0 -174
  36. data/lib/nanoc3/base/memoization.rb +0 -67
  37. data/lib/nanoc3/base/notification_center.rb +0 -84
  38. data/lib/nanoc3/base/ordered_hash.rb +0 -200
  39. data/lib/nanoc3/base/plugin_registry.rb +0 -165
  40. data/lib/nanoc3/base/result_data/item_rep.rb +0 -488
  41. data/lib/nanoc3/base/source_data/code_snippet.rb +0 -58
  42. data/lib/nanoc3/base/source_data/configuration.rb +0 -24
  43. data/lib/nanoc3/base/source_data/data_source.rb +0 -234
  44. data/lib/nanoc3/base/source_data/item.rb +0 -301
  45. data/lib/nanoc3/base/source_data/layout.rb +0 -130
  46. data/lib/nanoc3/base/source_data/site.rb +0 -361
  47. data/lib/nanoc3/base/store.rb +0 -135
  48. data/lib/nanoc3/cli.rb +0 -133
  49. data/lib/nanoc3/cli/command.rb +0 -139
  50. data/lib/nanoc3/cli/commands/autocompile.rb +0 -60
  51. data/lib/nanoc3/cli/commands/compile.rb +0 -280
  52. data/lib/nanoc3/cli/commands/create_item.rb +0 -62
  53. data/lib/nanoc3/cli/commands/create_layout.rb +0 -75
  54. data/lib/nanoc3/cli/commands/create_site.rb +0 -410
  55. data/lib/nanoc3/cli/commands/debug.rb +0 -119
  56. data/lib/nanoc3/cli/commands/info.rb +0 -98
  57. data/lib/nanoc3/cli/commands/nanoc.rb +0 -37
  58. data/lib/nanoc3/cli/commands/update.rb +0 -72
  59. data/lib/nanoc3/cli/commands/view.rb +0 -84
  60. data/lib/nanoc3/cli/commands/watch.rb +0 -125
  61. data/lib/nanoc3/cli/error_handler.rb +0 -193
  62. data/lib/nanoc3/cli/logger.rb +0 -91
  63. data/lib/nanoc3/data_sources.rb +0 -29
  64. data/lib/nanoc3/data_sources/deprecated/delicious.rb +0 -42
  65. data/lib/nanoc3/data_sources/deprecated/last_fm.rb +0 -87
  66. data/lib/nanoc3/data_sources/deprecated/twitter.rb +0 -38
  67. data/lib/nanoc3/data_sources/filesystem.rb +0 -299
  68. data/lib/nanoc3/data_sources/filesystem_unified.rb +0 -116
  69. data/lib/nanoc3/data_sources/filesystem_verbose.rb +0 -86
  70. data/lib/nanoc3/extra.rb +0 -22
  71. data/lib/nanoc3/extra/auto_compiler.rb +0 -103
  72. data/lib/nanoc3/extra/chick.rb +0 -125
  73. data/lib/nanoc3/extra/core_ext.rb +0 -4
  74. data/lib/nanoc3/extra/core_ext/enumerable.rb +0 -33
  75. data/lib/nanoc3/extra/core_ext/time.rb +0 -19
  76. data/lib/nanoc3/extra/deployers.rb +0 -11
  77. data/lib/nanoc3/extra/deployers/rsync.rb +0 -114
  78. data/lib/nanoc3/extra/file_proxy.rb +0 -40
  79. data/lib/nanoc3/extra/validators.rb +0 -12
  80. data/lib/nanoc3/extra/validators/links.rb +0 -264
  81. data/lib/nanoc3/extra/validators/w3c.rb +0 -95
  82. data/lib/nanoc3/extra/vcs.rb +0 -66
  83. data/lib/nanoc3/extra/vcses.rb +0 -17
  84. data/lib/nanoc3/extra/vcses/bazaar.rb +0 -25
  85. data/lib/nanoc3/extra/vcses/dummy.rb +0 -24
  86. data/lib/nanoc3/extra/vcses/git.rb +0 -25
  87. data/lib/nanoc3/extra/vcses/mercurial.rb +0 -25
  88. data/lib/nanoc3/extra/vcses/subversion.rb +0 -25
  89. data/lib/nanoc3/filters.rb +0 -53
  90. data/lib/nanoc3/filters/asciidoc.rb +0 -38
  91. data/lib/nanoc3/filters/bluecloth.rb +0 -19
  92. data/lib/nanoc3/filters/coderay.rb +0 -21
  93. data/lib/nanoc3/filters/colorize_syntax.rb +0 -261
  94. data/lib/nanoc3/filters/erb.rb +0 -35
  95. data/lib/nanoc3/filters/erubis.rb +0 -27
  96. data/lib/nanoc3/filters/haml.rb +0 -27
  97. data/lib/nanoc3/filters/kramdown.rb +0 -20
  98. data/lib/nanoc3/filters/less.rb +0 -53
  99. data/lib/nanoc3/filters/markaby.rb +0 -20
  100. data/lib/nanoc3/filters/maruku.rb +0 -20
  101. data/lib/nanoc3/filters/mustache.rb +0 -24
  102. data/lib/nanoc3/filters/rainpress.rb +0 -19
  103. data/lib/nanoc3/filters/rdiscount.rb +0 -22
  104. data/lib/nanoc3/filters/rdoc.rb +0 -33
  105. data/lib/nanoc3/filters/redcarpet.rb +0 -27
  106. data/lib/nanoc3/filters/redcloth.rb +0 -47
  107. data/lib/nanoc3/filters/relativize_paths.rb +0 -45
  108. data/lib/nanoc3/filters/rubypants.rb +0 -20
  109. data/lib/nanoc3/filters/sass.rb +0 -66
  110. data/lib/nanoc3/filters/slim.rb +0 -25
  111. data/lib/nanoc3/filters/typogruby.rb +0 -23
  112. data/lib/nanoc3/filters/uglify_js.rb +0 -42
  113. data/lib/nanoc3/helpers.rb +0 -16
  114. data/lib/nanoc3/helpers/blogging.rb +0 -319
  115. data/lib/nanoc3/helpers/breadcrumbs.rb +0 -40
  116. data/lib/nanoc3/helpers/capturing.rb +0 -138
  117. data/lib/nanoc3/helpers/filtering.rb +0 -50
  118. data/lib/nanoc3/helpers/html_escape.rb +0 -55
  119. data/lib/nanoc3/helpers/link_to.rb +0 -151
  120. data/lib/nanoc3/helpers/rendering.rb +0 -140
  121. data/lib/nanoc3/helpers/tagging.rb +0 -71
  122. data/lib/nanoc3/helpers/text.rb +0 -44
  123. data/lib/nanoc3/helpers/xml_sitemap.rb +0 -76
  124. data/lib/nanoc3/tasks.rb +0 -10
  125. data/lib/nanoc3/tasks/clean.rake +0 -16
  126. data/lib/nanoc3/tasks/clean.rb +0 -29
  127. data/lib/nanoc3/tasks/deploy/rsync.rake +0 -14
  128. data/lib/nanoc3/tasks/validate.rake +0 -92
  129. data/nanoc3.gemspec +0 -49
  130. data/tasks/doc.rake +0 -16
  131. data/tasks/test.rake +0 -44
  132. data/test/base/core_ext/array_spec.rb +0 -73
  133. data/test/base/core_ext/hash_spec.rb +0 -98
  134. data/test/base/core_ext/pathname_spec.rb +0 -27
  135. data/test/base/core_ext/string_spec.rb +0 -37
  136. data/test/base/test_checksum_store.rb +0 -35
  137. data/test/base/test_code_snippet.rb +0 -31
  138. data/test/base/test_compiler.rb +0 -316
  139. data/test/base/test_compiler_dsl.rb +0 -161
  140. data/test/base/test_context.rb +0 -31
  141. data/test/base/test_data_source.rb +0 -46
  142. data/test/base/test_dependency_tracker.rb +0 -262
  143. data/test/base/test_directed_graph.rb +0 -283
  144. data/test/base/test_filter.rb +0 -83
  145. data/test/base/test_item.rb +0 -179
  146. data/test/base/test_item_rep.rb +0 -553
  147. data/test/base/test_layout.rb +0 -59
  148. data/test/base/test_memoization.rb +0 -90
  149. data/test/base/test_notification_center.rb +0 -34
  150. data/test/base/test_outdatedness_checker.rb +0 -394
  151. data/test/base/test_plugin.rb +0 -30
  152. data/test/base/test_rule.rb +0 -19
  153. data/test/base/test_rule_context.rb +0 -65
  154. data/test/base/test_site.rb +0 -190
  155. data/test/cli/commands/test_compile.rb +0 -33
  156. data/test/cli/commands/test_create_item.rb +0 -14
  157. data/test/cli/commands/test_create_layout.rb +0 -28
  158. data/test/cli/commands/test_create_site.rb +0 -24
  159. data/test/cli/commands/test_help.rb +0 -12
  160. data/test/cli/commands/test_info.rb +0 -11
  161. data/test/cli/commands/test_update.rb +0 -10
  162. data/test/cli/test_cli.rb +0 -102
  163. data/test/cli/test_error_handler.rb +0 -29
  164. data/test/cli/test_logger.rb +0 -10
  165. data/test/data_sources/test_filesystem.rb +0 -433
  166. data/test/data_sources/test_filesystem_unified.rb +0 -536
  167. data/test/data_sources/test_filesystem_verbose.rb +0 -357
  168. data/test/extra/core_ext/test_enumerable.rb +0 -30
  169. data/test/extra/core_ext/test_time.rb +0 -15
  170. data/test/extra/deployers/test_rsync.rb +0 -232
  171. data/test/extra/test_auto_compiler.rb +0 -417
  172. data/test/extra/test_file_proxy.rb +0 -19
  173. data/test/extra/test_vcs.rb +0 -22
  174. data/test/extra/validators/test_links.rb +0 -51
  175. data/test/extra/validators/test_w3c.rb +0 -47
  176. data/test/filters/test_asciidoc.rb +0 -22
  177. data/test/filters/test_bluecloth.rb +0 -18
  178. data/test/filters/test_coderay.rb +0 -44
  179. data/test/filters/test_colorize_syntax.rb +0 -283
  180. data/test/filters/test_erb.rb +0 -99
  181. data/test/filters/test_erubis.rb +0 -70
  182. data/test/filters/test_haml.rb +0 -96
  183. data/test/filters/test_kramdown.rb +0 -18
  184. data/test/filters/test_less.rb +0 -113
  185. data/test/filters/test_markaby.rb +0 -24
  186. data/test/filters/test_maruku.rb +0 -18
  187. data/test/filters/test_mustache.rb +0 -25
  188. data/test/filters/test_rainpress.rb +0 -29
  189. data/test/filters/test_rdiscount.rb +0 -31
  190. data/test/filters/test_rdoc.rb +0 -18
  191. data/test/filters/test_redcarpet.rb +0 -63
  192. data/test/filters/test_redcloth.rb +0 -33
  193. data/test/filters/test_relativize_paths.rb +0 -332
  194. data/test/filters/test_rubypants.rb +0 -18
  195. data/test/filters/test_sass.rb +0 -229
  196. data/test/filters/test_slim.rb +0 -35
  197. data/test/filters/test_typogruby.rb +0 -21
  198. data/test/filters/test_uglify_js.rb +0 -30
  199. data/test/gem_loader.rb +0 -11
  200. data/test/helper.rb +0 -179
  201. data/test/helpers/test_blogging.rb +0 -754
  202. data/test/helpers/test_breadcrumbs.rb +0 -81
  203. data/test/helpers/test_capturing.rb +0 -41
  204. data/test/helpers/test_filtering.rb +0 -106
  205. data/test/helpers/test_html_escape.rb +0 -32
  206. data/test/helpers/test_link_to.rb +0 -249
  207. data/test/helpers/test_rendering.rb +0 -89
  208. data/test/helpers/test_tagging.rb +0 -87
  209. data/test/helpers/test_text.rb +0 -24
  210. data/test/helpers/test_xml_sitemap.rb +0 -103
  211. data/test/tasks/test_clean.rb +0 -67
@@ -1,161 +0,0 @@
1
- # encoding: utf-8
2
-
3
- class Nanoc3::CompilerDSLTest < MiniTest::Unit::TestCase
4
-
5
- include Nanoc3::TestHelpers
6
-
7
- def test_compile
8
- # TODO implement
9
- end
10
-
11
- def test_route
12
- # TODO implement
13
- end
14
-
15
- def test_layout
16
- # TODO implement
17
- end
18
-
19
- def test_passthrough
20
- # Create site
21
- Nanoc3::CLI.run %w( create_site bar)
22
- FileUtils.cd('bar') do
23
- # Create rep
24
- item = Nanoc3::Item.new('foo', { :extension => 'bar' }, '/foo/')
25
- rep = Nanoc3::ItemRep.new(item, :default)
26
-
27
- # Create other necessary stuff
28
- site = Nanoc3::Site.new('.')
29
- site.items << item
30
- compiler = site.compiler
31
- dsl = site.compiler.rules_collection.dsl
32
-
33
- # Create rule
34
- dsl.passthrough '/foo/'
35
-
36
- # Route and compile
37
- rule = compiler.rules_collection.routing_rule_for(rep)
38
- path = rule.apply_to(rep, :compiler => compiler)
39
- compiler.send :compile_rep, rep
40
-
41
- # Check result
42
- assert_equal 'foo', rep.compiled_content
43
- assert_equal '/foo.bar', path
44
- end
45
- end
46
-
47
- def test_identifier_to_regex_without_wildcards
48
- # Create compiler DSL
49
- compiler_dsl = Nanoc3::CompilerDSL.new(nil, {})
50
-
51
- actual = compiler_dsl.instance_eval { identifier_to_regex('foo') }
52
- expected = %r{^/foo/$}
53
-
54
- assert_equal(expected.to_s, actual.to_s)
55
- assert_equal(expected.source, actual.source)
56
- assert_equal(expected.kcode, actual.kcode) if expected.respond_to?(:kcode)
57
- assert_equal(expected.casefold?, actual.casefold?)
58
- assert_equal(expected.options, actual.options)
59
- end
60
-
61
- def test_identifier_to_regex_with_one_wildcard
62
- # Create compiler DSL
63
- compiler_dsl = Nanoc3::CompilerDSL.new(nil, {})
64
-
65
- actual = compiler_dsl.instance_eval { identifier_to_regex('foo/*/bar') }
66
- expected = %r{^/foo/(.*?)/bar/$}
67
-
68
- assert_equal(expected.to_s, actual.to_s)
69
- assert_equal(expected.source, actual.source)
70
- assert_equal(expected.kcode, actual.kcode) if expected.respond_to?(:kcode)
71
- assert_equal(expected.casefold?, actual.casefold?)
72
- assert_equal(expected.options, actual.options)
73
- end
74
-
75
- def test_identifier_to_regex_with_two_wildcards
76
- # Create compiler DSL
77
- compiler_dsl = Nanoc3::CompilerDSL.new(nil, {})
78
-
79
- actual = compiler_dsl.instance_eval { identifier_to_regex('foo/*/bar/*/qux') }
80
- expected = %r{^/foo/(.*?)/bar/(.*?)/qux/$}
81
-
82
- assert_equal(expected.to_s, actual.to_s)
83
- assert_equal(expected.source, actual.source)
84
- assert_equal(expected.kcode, actual.kcode) if expected.respond_to?(:kcode)
85
- assert_equal(expected.casefold?, actual.casefold?)
86
- assert_equal(expected.options, actual.options)
87
- end
88
-
89
- def test_identifier_to_regex_with_just_one_wildcard
90
- # Create compiler DSL
91
- compiler_dsl = Nanoc3::CompilerDSL.new(nil, {})
92
-
93
- actual = compiler_dsl.instance_eval { identifier_to_regex('*') }
94
- expected = %r{^/(.*?)$}
95
-
96
- assert_equal(expected.to_s, actual.to_s)
97
- assert_equal(expected.source, actual.source)
98
- assert_equal(expected.kcode, actual.kcode) if expected.respond_to?(:kcode)
99
- assert_equal(expected.casefold?, actual.casefold?)
100
- assert_equal(expected.options, actual.options)
101
- end
102
-
103
- def test_identifier_to_regex_with_root
104
- # Create compiler DSL
105
- compiler_dsl = Nanoc3::CompilerDSL.new(nil, {})
106
-
107
- actual = compiler_dsl.instance_eval { identifier_to_regex('/') }
108
- expected = %r{^/$}
109
-
110
- assert_equal(expected.to_s, actual.to_s)
111
- assert_equal(expected.source, actual.source)
112
- assert_equal(expected.kcode, actual.kcode) if expected.respond_to?(:kcode)
113
- assert_equal(expected.casefold?, actual.casefold?)
114
- assert_equal(expected.options, actual.options)
115
- end
116
-
117
- def test_identifier_to_regex_with_only_children
118
- # Create compiler DSL
119
- compiler_dsl = Nanoc3::CompilerDSL.new(nil, {})
120
-
121
- actual = compiler_dsl.instance_eval { identifier_to_regex('/foo/*/') }
122
- expected = %r{^/foo/(.*?)/$}
123
-
124
- assert_equal(expected.to_s, actual.to_s)
125
- assert_equal(expected.source, actual.source)
126
- assert_equal(expected.kcode, actual.kcode) if expected.respond_to?(:kcode)
127
- assert_equal(expected.casefold?, actual.casefold?)
128
- assert_equal(expected.options, actual.options)
129
- end
130
-
131
- def test_identifier_to_regex_with_plus_wildcard
132
- # Create compiler DSL
133
- compiler_dsl = Nanoc3::CompilerDSL.new(nil, {})
134
-
135
- actual = compiler_dsl.instance_eval { identifier_to_regex('/foo/+') }
136
- expected = %r{^/foo/(.+?)/$}
137
-
138
- assert_equal(expected.to_s, actual.to_s)
139
- assert_equal(expected.source, actual.source)
140
- assert_equal(expected.kcode, actual.kcode) if expected.respond_to?(:kcode)
141
- assert_equal(expected.casefold?, actual.casefold?)
142
- assert_equal(expected.options, actual.options)
143
- assert('/foo/bar/' =~ actual)
144
- refute('/foo/' =~ actual)
145
- end
146
-
147
- def test_dsl_has_no_access_to_compiler
148
- compiler_dsl = Nanoc3::CompilerDSL.new(nil, {})
149
- assert_raises(NameError) do
150
- compiler_dsl.instance_eval { compiler }
151
- end
152
- end
153
-
154
- def test_config
155
- $venetian = 'unsnares'
156
- compiler_dsl = Nanoc3::CompilerDSL.new(nil, { :venetian => 'snares' })
157
- compiler_dsl.instance_eval { $venetian = @config[:venetian] }
158
- assert_equal 'snares', $venetian
159
- end
160
-
161
- end
@@ -1,31 +0,0 @@
1
- # encoding: utf-8
2
-
3
- class Nanoc3::ContextTest < MiniTest::Unit::TestCase
4
-
5
- include Nanoc3::TestHelpers
6
-
7
- def test_context_with_instance_variable
8
- # Create context
9
- context = Nanoc3::Context.new({ :foo => 'bar', :baz => 'quux' })
10
-
11
- # Ensure correct evaluation
12
- assert_equal('bar', eval("@foo", context.get_binding))
13
- end
14
-
15
- def test_context_with_instance_method
16
- # Create context
17
- context = Nanoc3::Context.new({ :foo => 'bar', :baz => 'quux' })
18
-
19
- # Ensure correct evaluation
20
- assert_equal('bar', eval("foo", context.get_binding))
21
- end
22
-
23
- def test_example
24
- # Parse
25
- YARD.parse('../lib/nanoc3/base/context.rb')
26
-
27
- # Run
28
- assert_examples_correct 'Nanoc3::Context#initialize'
29
- end
30
-
31
- end
@@ -1,46 +0,0 @@
1
- # encoding: utf-8
2
-
3
- class Nanoc3::DataSourceTest < MiniTest::Unit::TestCase
4
-
5
- include Nanoc3::TestHelpers
6
-
7
- def test_loading
8
- # Create data source
9
- data_source = Nanoc3::DataSource.new(nil, nil, nil, nil)
10
- data_source.expects(:up).times(1)
11
- data_source.expects(:down).times(1)
12
-
13
- # Test nested loading
14
- assert_equal(0, data_source.instance_eval { @references })
15
- data_source.loading do
16
- assert_equal(1, data_source.instance_eval { @references })
17
- data_source.loading do
18
- assert_equal(2, data_source.instance_eval { @references })
19
- end
20
- assert_equal(1, data_source.instance_eval { @references })
21
- end
22
- assert_equal(0, data_source.instance_eval { @references })
23
- end
24
-
25
- def test_not_implemented
26
- # Create data source
27
- data_source = Nanoc3::DataSource.new(nil, nil, nil, nil)
28
-
29
- # Test optional methods
30
- data_source.up
31
- data_source.down
32
- data_source.update
33
-
34
- # Test required methods - general
35
- assert_raises(NotImplementedError) { data_source.setup }
36
-
37
- # Test methods - loading data
38
- assert_equal [], data_source.items
39
- assert_equal [], data_source.layouts
40
-
41
- # Test required method - creating data
42
- assert_raises(NotImplementedError) { data_source.create_item(nil, nil, nil) }
43
- assert_raises(NotImplementedError) { data_source.create_layout(nil, nil, nil) }
44
- end
45
-
46
- end
@@ -1,262 +0,0 @@
1
- # encoding: utf-8
2
-
3
- class Nanoc3::DependencyTrackerTest < MiniTest::Unit::TestCase
4
-
5
- include Nanoc3::TestHelpers
6
-
7
- def test_initialize
8
- # Mock items
9
- items = [ mock, mock ]
10
-
11
- # Create
12
- tracker = Nanoc3::DependencyTracker.new(items)
13
-
14
- # Verify no dependencies yet
15
- assert_empty tracker.objects_causing_outdatedness_of(items[0])
16
- assert_empty tracker.objects_causing_outdatedness_of(items[1])
17
- end
18
-
19
- def test_record_dependency
20
- # Mock items
21
- items = [ mock, mock ]
22
-
23
- # Create
24
- tracker = Nanoc3::DependencyTracker.new(items)
25
-
26
- # Record some dependencies
27
- tracker.record_dependency(items[0], items[1])
28
-
29
- # Verify dependencies
30
- assert_contains_exactly [ items[1] ], tracker.objects_causing_outdatedness_of(items[0])
31
- end
32
-
33
- def test_record_dependency_no_self
34
- # Mock items
35
- items = [ mock, mock ]
36
-
37
- # Create
38
- tracker = Nanoc3::DependencyTracker.new(items)
39
-
40
- # Record some dependencies
41
- tracker.record_dependency(items[0], items[0])
42
- tracker.record_dependency(items[0], items[1])
43
-
44
- # Verify dependencies
45
- assert_contains_exactly [ items[1] ], tracker.objects_causing_outdatedness_of(items[0])
46
- end
47
-
48
- def test_record_dependency_no_doubles
49
- # Mock items
50
- items = [ mock, mock ]
51
-
52
- # Create
53
- tracker = Nanoc3::DependencyTracker.new(items)
54
-
55
- # Record some dependencies
56
- tracker.record_dependency(items[0], items[1])
57
- tracker.record_dependency(items[0], items[1])
58
- tracker.record_dependency(items[0], items[1])
59
-
60
- # Verify dependencies
61
- assert_contains_exactly [ items[1] ], tracker.objects_causing_outdatedness_of(items[0])
62
- end
63
-
64
- def test_objects_causing_outdatedness_of
65
- # Mock items
66
- items = [ mock, mock, mock ]
67
-
68
- # Create
69
- tracker = Nanoc3::DependencyTracker.new(items)
70
-
71
- # Record some dependencies
72
- tracker.record_dependency(items[0], items[1])
73
- tracker.record_dependency(items[1], items[2])
74
-
75
- # Verify dependencies
76
- assert_contains_exactly [ items[1] ], tracker.objects_causing_outdatedness_of(items[0])
77
- end
78
-
79
- def test_objects_outdated_due_to
80
- # Mock items
81
- items = [ mock, mock, mock ]
82
-
83
- # Create
84
- tracker = Nanoc3::DependencyTracker.new(items)
85
-
86
- # Record some dependencies
87
- tracker.record_dependency(items[0], items[1])
88
- tracker.record_dependency(items[1], items[2])
89
-
90
- # Verify dependencies
91
- assert_contains_exactly [ items[0] ], tracker.objects_outdated_due_to(items[1])
92
- end
93
-
94
- def test_start_and_stop
95
- # Mock items
96
- items = [ mock, mock ]
97
-
98
- # Create
99
- tracker = Nanoc3::DependencyTracker.new(items)
100
-
101
- # Start, do something and stop
102
- tracker.start
103
- Nanoc3::NotificationCenter.post(:visit_started, items[0])
104
- Nanoc3::NotificationCenter.post(:visit_started, items[1])
105
- Nanoc3::NotificationCenter.post(:visit_ended, items[1])
106
- Nanoc3::NotificationCenter.post(:visit_ended, items[0])
107
- tracker.stop
108
-
109
- # Verify dependencies
110
- assert_contains_exactly [ items[1] ], tracker.objects_causing_outdatedness_of(items[0])
111
- assert_empty tracker.objects_causing_outdatedness_of(items[1])
112
- end
113
-
114
- def test_store_graph_and_load_graph_simple
115
- # Mock items
116
- items = [ mock('0'), mock('1'), mock('2'), mock('3') ]
117
- items.each { |i| i.stubs(:type).returns(:item) }
118
- items[0].stubs(:reference).returns([ :item, '/aaa/' ])
119
- items[1].stubs(:reference).returns([ :item, '/bbb/' ])
120
- items[2].stubs(:reference).returns([ :item, '/ccc/' ])
121
- items[3].stubs(:reference).returns([ :item, '/ddd/' ])
122
-
123
- # Create
124
- tracker = Nanoc3::DependencyTracker.new(items)
125
-
126
- # Record some dependencies
127
- tracker.record_dependency(items[0], items[1])
128
- tracker.record_dependency(items[1], items[2])
129
- tracker.record_dependency(items[1], items[3])
130
-
131
- # Store
132
- tracker.store_graph
133
- assert File.file?(tracker.filename)
134
-
135
- # Re-create
136
- tracker = Nanoc3::DependencyTracker.new(items)
137
-
138
- # Load
139
- tracker.load_graph
140
-
141
- # Check loaded graph
142
- assert_contains_exactly [ items[1] ], tracker.objects_causing_outdatedness_of(items[0])
143
- assert_contains_exactly [ items[2], items[3] ], tracker.objects_causing_outdatedness_of(items[1])
144
- assert_empty tracker.objects_causing_outdatedness_of(items[2])
145
- assert_empty tracker.objects_causing_outdatedness_of(items[3])
146
- end
147
-
148
- def test_store_graph_and_load_graph_with_removed_items
149
- # Mock items
150
- items = [ mock('0'), mock('1'), mock('2'), mock('3') ]
151
- items.each { |i| i.stubs(:type).returns(:item) }
152
- items[0].stubs(:reference).returns([ :item, '/aaa/' ])
153
- items[1].stubs(:reference).returns([ :item, '/bbb/' ])
154
- items[2].stubs(:reference).returns([ :item, '/ccc/' ])
155
- items[3].stubs(:reference).returns([ :item, '/ddd/' ])
156
-
157
- # Create new and old lists
158
- old_items = [ items[0], items[1], items[2], items[3] ]
159
- new_items = [ items[0], items[1], items[2] ]
160
-
161
- # Create
162
- tracker = Nanoc3::DependencyTracker.new(old_items)
163
-
164
- # Record some dependencies
165
- tracker.record_dependency(old_items[0], old_items[1])
166
- tracker.record_dependency(old_items[1], old_items[2])
167
- tracker.record_dependency(old_items[1], old_items[3])
168
-
169
- # Store
170
- tracker.store_graph
171
- assert File.file?(tracker.filename)
172
-
173
- # Re-create
174
- tracker = Nanoc3::DependencyTracker.new(new_items)
175
-
176
- # Load
177
- tracker.load_graph
178
-
179
- # Check loaded graph
180
- assert_contains_exactly [ items[1] ], tracker.objects_causing_outdatedness_of(items[0])
181
- assert_contains_exactly [ items[2], nil ], tracker.objects_causing_outdatedness_of(items[1])
182
- assert_empty tracker.objects_causing_outdatedness_of(items[2])
183
- end
184
-
185
- def test_store_graph_with_nils_in_dst
186
- # Mock items
187
- items = [ mock('0'), mock('1'), mock('2') ]
188
- items.each { |i| i.stubs(:type).returns(:item) }
189
- items[0].stubs(:reference).returns([ :item, '/aaa/' ])
190
- items[1].stubs(:reference).returns([ :item, '/bbb/' ])
191
- items[2].stubs(:reference).returns([ :item, '/ccc/' ])
192
-
193
- # Create
194
- tracker = Nanoc3::DependencyTracker.new(items)
195
-
196
- # Record some dependencies
197
- tracker.record_dependency(items[0], items[1])
198
- tracker.record_dependency(items[1], nil)
199
-
200
- # Store
201
- tracker.store_graph
202
- assert File.file?(tracker.filename)
203
-
204
- # Re-create
205
- tracker = Nanoc3::DependencyTracker.new(items)
206
-
207
- # Load
208
- tracker.load_graph
209
-
210
- # Check loaded graph
211
- assert_contains_exactly [ items[1] ], tracker.objects_causing_outdatedness_of(items[0])
212
- assert_contains_exactly [ nil ], tracker.objects_causing_outdatedness_of(items[1])
213
- end
214
-
215
- def test_store_graph_with_nils_in_src
216
- # Mock items
217
- items = [ mock('0'), mock('1'), mock('2') ]
218
- items.each { |i| i.stubs(:type).returns(:item) }
219
- items[0].stubs(:reference).returns([ :item, '/aaa/' ])
220
- items[1].stubs(:reference).returns([ :item, '/bbb/' ])
221
- items[2].stubs(:reference).returns([ :item, '/ccc/' ])
222
-
223
- # Create
224
- tracker = Nanoc3::DependencyTracker.new(items)
225
-
226
- # Record some dependencies
227
- tracker.record_dependency(items[0], items[1])
228
- tracker.record_dependency(nil, items[2])
229
-
230
- # Store
231
- tracker.store_graph
232
- assert File.file?(tracker.filename)
233
-
234
- # Re-create
235
- tracker = Nanoc3::DependencyTracker.new(items)
236
-
237
- # Load
238
- tracker.load_graph
239
-
240
- # Check loaded graph
241
- assert_contains_exactly [ items[1] ], tracker.objects_causing_outdatedness_of(items[0])
242
- assert_empty tracker.objects_causing_outdatedness_of(items[1])
243
- end
244
-
245
- def test_forget_dependencies_for
246
- # Mock items
247
- items = [ mock, mock, mock ]
248
-
249
- # Create
250
- tracker = Nanoc3::DependencyTracker.new(items)
251
-
252
- # Record some dependencies
253
- tracker.record_dependency(items[0], items[1])
254
- tracker.record_dependency(items[1], items[2])
255
- assert_contains_exactly [ items[1] ], tracker.objects_causing_outdatedness_of(items[0])
256
-
257
- # Forget dependencies
258
- tracker.forget_dependencies_for(items[0])
259
- assert_empty tracker.objects_causing_outdatedness_of(items[0])
260
- end
261
-
262
- end