nanoc 3.8.0 → 4.0.0a1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -0
- data/Gemfile.lock +322 -0
- data/NEWS.md +6 -0
- data/bin/nanoc +0 -18
- data/lib/nanoc.rb +5 -3
- data/lib/nanoc/base.rb +24 -6
- data/lib/nanoc/base/checksummer.rb +6 -4
- data/lib/nanoc/base/compilation/checksum_store.rb +4 -4
- data/lib/nanoc/base/compilation/compiled_content_cache.rb +5 -5
- data/lib/nanoc/base/compilation/compiler.rb +60 -65
- data/lib/nanoc/base/compilation/compiler_dsl.rb +11 -9
- data/lib/nanoc/base/compilation/dependency_tracker.rb +24 -38
- data/lib/nanoc/base/compilation/filter.rb +22 -7
- data/lib/nanoc/base/compilation/item_rep_proxy.rb +14 -12
- data/lib/nanoc/base/compilation/item_rep_recorder_proxy.rb +8 -8
- data/lib/nanoc/base/compilation/outdatedness_checker.rb +32 -32
- data/lib/nanoc/base/compilation/outdatedness_reasons.rb +3 -1
- data/lib/nanoc/base/compilation/rule.rb +9 -7
- data/lib/nanoc/base/compilation/rule_context.rb +15 -15
- data/lib/nanoc/base/compilation/rule_memory_calculator.rb +3 -3
- data/lib/nanoc/base/compilation/rule_memory_store.rb +7 -7
- data/lib/nanoc/base/compilation/rules_collection.rb +28 -30
- data/lib/nanoc/base/context.rb +2 -2
- data/lib/nanoc/base/core_ext/array.rb +17 -25
- data/lib/nanoc/base/core_ext/hash.rb +17 -25
- data/lib/nanoc/base/core_ext/pathname.rb +4 -2
- data/lib/nanoc/base/core_ext/string.rb +5 -3
- data/lib/nanoc/base/directed_graph.rb +4 -9
- data/lib/nanoc/base/error.rb +7 -0
- data/lib/nanoc/base/errors.rb +16 -23
- data/lib/nanoc/base/memoization.rb +4 -2
- data/lib/nanoc/base/notification_center.rb +3 -1
- data/lib/nanoc/base/plugin_registry.rb +14 -21
- data/lib/nanoc/base/result_data/item_rep.rb +43 -88
- data/lib/nanoc/base/source_data/code_snippet.rb +6 -4
- data/lib/nanoc/base/source_data/configuration.rb +3 -1
- data/lib/nanoc/base/source_data/data_source.rb +12 -94
- data/lib/nanoc/base/source_data/identifier.rb +50 -0
- data/lib/nanoc/base/source_data/item.rb +24 -67
- data/lib/nanoc/base/source_data/item_array.rb +6 -4
- data/lib/nanoc/base/source_data/layout.rb +17 -28
- data/lib/nanoc/base/source_data/site.rb +33 -44
- data/lib/nanoc/base/store.rb +3 -5
- data/lib/nanoc/base/temp_filename_factory.rb +3 -2
- data/lib/nanoc/base/views/config.rb +19 -0
- data/lib/nanoc/base/views/item.rb +77 -0
- data/lib/nanoc/base/views/item_collection.rb +43 -0
- data/lib/nanoc/base/views/item_rep.rb +125 -0
- data/lib/nanoc/base/views/layout.rb +42 -0
- data/lib/nanoc/base/views/layout_collection.rb +26 -0
- data/lib/nanoc/base/views/mutable_config.rb +9 -0
- data/lib/nanoc/base/views/mutable_item.rb +9 -0
- data/lib/nanoc/base/views/mutable_item_collection.rb +18 -0
- data/lib/nanoc/base/views/mutable_layout.rb +9 -0
- data/lib/nanoc/base/views/mutable_layout_collection.rb +18 -0
- data/lib/nanoc/base/views/site.rb +35 -0
- data/lib/nanoc/cli.rb +3 -6
- data/lib/nanoc/cli/ansi_string_colorizer.rb +2 -0
- data/lib/nanoc/cli/cleaning_stream.rb +2 -0
- data/lib/nanoc/cli/command_runner.rb +8 -42
- data/lib/nanoc/cli/commands/check.rb +2 -2
- data/lib/nanoc/cli/commands/compile.rb +19 -34
- data/lib/nanoc/cli/commands/create-site.rb +46 -83
- data/lib/nanoc/cli/commands/deploy.rb +4 -4
- data/lib/nanoc/cli/commands/shell.rb +1 -1
- data/lib/nanoc/cli/commands/show-plugins.rb +4 -6
- data/lib/nanoc/cli/error_handler.rb +4 -14
- data/lib/nanoc/cli/logger.rb +2 -0
- data/lib/nanoc/cli/stream_cleaners.rb +1 -0
- data/lib/nanoc/cli/stream_cleaners/abstract.rb +2 -0
- data/lib/nanoc/cli/stream_cleaners/ansi_colors.rb +2 -0
- data/lib/nanoc/cli/stream_cleaners/utf8.rb +2 -0
- data/lib/nanoc/data_sources.rb +1 -17
- data/lib/nanoc/data_sources/filesystem.rb +6 -37
- data/lib/nanoc/data_sources/filesystem_unified.rb +5 -3
- data/lib/nanoc/data_sources/filesystem_verbose.rb +5 -3
- data/lib/nanoc/data_sources/static.rb +4 -2
- data/lib/nanoc/extra.rb +1 -13
- data/lib/nanoc/extra/checking.rb +1 -0
- data/lib/nanoc/extra/checking/check.rb +4 -2
- data/lib/nanoc/extra/checking/checks.rb +1 -0
- data/lib/nanoc/extra/checking/checks/css.rb +1 -0
- data/lib/nanoc/extra/checking/checks/external_links.rb +2 -0
- data/lib/nanoc/extra/checking/checks/html.rb +1 -0
- data/lib/nanoc/extra/checking/checks/internal_links.rb +2 -0
- data/lib/nanoc/extra/checking/checks/mixed_content.rb +2 -0
- data/lib/nanoc/extra/checking/checks/stale.rb +1 -0
- data/lib/nanoc/extra/checking/dsl.rb +1 -0
- data/lib/nanoc/extra/checking/issue.rb +1 -0
- data/lib/nanoc/extra/checking/runner.rb +3 -3
- data/lib/nanoc/extra/core_ext/pathname.rb +5 -3
- data/lib/nanoc/extra/core_ext/time.rb +4 -2
- data/lib/nanoc/extra/deployer.rb +3 -1
- data/lib/nanoc/extra/deployers.rb +1 -0
- data/lib/nanoc/extra/deployers/fog.rb +2 -0
- data/lib/nanoc/extra/deployers/rsync.rb +2 -0
- data/lib/nanoc/extra/filesystem_tools.rb +3 -7
- data/lib/nanoc/extra/jruby_nokogiri_warner.rb +1 -0
- data/lib/nanoc/extra/link_collector.rb +1 -0
- data/lib/nanoc/extra/piper.rb +2 -1
- data/lib/nanoc/extra/pruner.rb +5 -3
- data/lib/nanoc/filters.rb +1 -2
- data/lib/nanoc/filters/asciidoc.rb +2 -0
- data/lib/nanoc/filters/bluecloth.rb +1 -0
- data/lib/nanoc/filters/coffeescript.rb +2 -0
- data/lib/nanoc/filters/colorize_syntax.rb +1 -12
- data/lib/nanoc/filters/erb.rb +2 -1
- data/lib/nanoc/filters/erubis.rb +2 -1
- data/lib/nanoc/filters/haml.rb +2 -1
- data/lib/nanoc/filters/handlebars.rb +2 -0
- data/lib/nanoc/filters/kramdown.rb +1 -0
- data/lib/nanoc/filters/less.rb +1 -0
- data/lib/nanoc/filters/markaby.rb +1 -0
- data/lib/nanoc/filters/maruku.rb +1 -0
- data/lib/nanoc/filters/mustache.rb +2 -0
- data/lib/nanoc/filters/pandoc.rb +1 -0
- data/lib/nanoc/filters/rainpress.rb +1 -0
- data/lib/nanoc/filters/rdiscount.rb +1 -0
- data/lib/nanoc/filters/rdoc.rb +1 -0
- data/lib/nanoc/filters/redcarpet.rb +2 -0
- data/lib/nanoc/filters/redcloth.rb +1 -0
- data/lib/nanoc/filters/relativize_paths.rb +1 -0
- data/lib/nanoc/filters/rubypants.rb +1 -0
- data/lib/nanoc/filters/sass.rb +1 -0
- data/lib/nanoc/filters/sass/sass_filesystem_importer.rb +2 -0
- data/lib/nanoc/filters/slim.rb +3 -1
- data/lib/nanoc/filters/typogruby.rb +2 -0
- data/lib/nanoc/filters/uglify_js.rb +1 -0
- data/lib/nanoc/filters/xsl.rb +2 -0
- data/lib/nanoc/filters/yui_compressor.rb +2 -0
- data/lib/nanoc/helpers/blogging.rb +30 -30
- data/lib/nanoc/helpers/breadcrumbs.rb +2 -2
- data/lib/nanoc/helpers/capturing.rb +6 -17
- data/lib/nanoc/helpers/filtering.rb +3 -3
- data/lib/nanoc/helpers/link_to.rb +3 -3
- data/lib/nanoc/helpers/rendering.rb +11 -11
- data/lib/nanoc/helpers/xml_sitemap.rb +3 -3
- data/lib/nanoc/tasks.rb +1 -0
- data/lib/nanoc/tasks/clean.rake +1 -1
- data/lib/nanoc/version.rb +1 -1
- data/tasks/doc.rake +2 -1
- data/tasks/test.rake +7 -1
- data/test/base/checksummer_spec.rb +15 -15
- data/test/base/core_ext/array_spec.rb +10 -10
- data/test/base/core_ext/hash_spec.rb +16 -16
- data/test/base/core_ext/pathname_spec.rb +2 -2
- data/test/base/core_ext/string_spec.rb +9 -9
- data/test/base/temp_filename_factory_spec.rb +3 -7
- data/test/base/test_checksum_store.rb +5 -5
- data/test/base/test_code_snippet.rb +3 -3
- data/test/base/test_compiler.rb +29 -29
- data/test/base/test_compiler_dsl.rb +23 -23
- data/test/base/test_context.rb +4 -4
- data/test/base/test_data_source.rb +17 -7
- data/test/base/test_dependency_tracker.rb +29 -29
- data/test/base/test_directed_graph.rb +27 -27
- data/test/base/test_item.rb +23 -21
- data/test/base/test_item_array.rb +18 -18
- data/test/base/test_item_rep.rb +76 -76
- data/test/base/test_item_rep_recorder_proxy.rb +4 -4
- data/test/base/test_layout.rb +8 -16
- data/test/base/test_memoization.rb +4 -4
- data/test/base/test_notification_center.rb +6 -6
- data/test/base/test_outdatedness_checker.rb +18 -18
- data/test/base/test_plugin.rb +1 -1
- data/test/base/test_rule.rb +2 -2
- data/test/base/test_rule_context.rb +5 -5
- data/test/base/test_site.rb +62 -38
- data/test/base/test_store.rb +2 -2
- data/test/cli/commands/test_check.rb +1 -1
- data/test/cli/commands/test_compile.rb +24 -18
- data/test/cli/commands/test_create_site.rb +5 -7
- data/test/cli/commands/test_deploy.rb +1 -1
- data/test/data_sources/test_filesystem.rb +22 -67
- data/test/data_sources/test_filesystem_unified.rb +10 -23
- data/test/data_sources/test_filesystem_verbose.rb +8 -53
- data/test/data_sources/test_static.rb +9 -9
- data/test/extra/checking/checks/test_stale.rb +1 -1
- data/test/extra/core_ext/test_pathname.rb +3 -3
- data/test/extra/core_ext/test_time.rb +4 -4
- data/test/extra/test_filesystem_tools.rb +1 -1
- data/test/filters/test_handlebars.rb +3 -3
- data/test/filters/test_less.rb +6 -6
- data/test/filters/test_mustache.rb +2 -2
- data/test/filters/test_relativize_paths.rb +81 -81
- data/test/filters/test_sass.rb +7 -7
- data/test/filters/test_xsl.rb +6 -6
- data/test/helper.rb +1 -1
- data/test/helpers/test_blogging.rb +78 -99
- data/test/helpers/test_breadcrumbs.rb +12 -12
- data/test/helpers/test_capturing.rb +10 -11
- data/test/helpers/test_filtering.rb +6 -6
- data/test/helpers/test_rendering.rb +3 -3
- data/test/helpers/test_tagging.rb +7 -7
- data/test/helpers/test_xml_sitemap.rb +34 -33
- metadata +19 -43
- data/lib/nanoc/cli/commands/autocompile.rb +0 -69
- data/lib/nanoc/cli/commands/create-item.rb +0 -55
- data/lib/nanoc/cli/commands/create-layout.rb +0 -68
- data/lib/nanoc/cli/commands/sync.rb +0 -32
- data/lib/nanoc/cli/commands/update.rb +0 -63
- data/lib/nanoc/cli/commands/validate-css.rb +0 -20
- data/lib/nanoc/cli/commands/validate-html.rb +0 -20
- data/lib/nanoc/cli/commands/validate-links.rb +0 -27
- data/lib/nanoc/cli/commands/watch.rb +0 -176
- data/lib/nanoc/data_sources/deprecated/delicious.rb +0 -38
- data/lib/nanoc/data_sources/deprecated/last_fm.rb +0 -85
- data/lib/nanoc/data_sources/deprecated/twitter.rb +0 -34
- data/lib/nanoc/extra/auto_compiler.rb +0 -99
- data/lib/nanoc/extra/chick.rb +0 -117
- data/lib/nanoc/extra/file_proxy.rb +0 -36
- data/lib/nanoc/extra/validators.rb +0 -8
- data/lib/nanoc/extra/validators/links.rb +0 -18
- data/lib/nanoc/extra/validators/w3c.rb +0 -23
- data/lib/nanoc/extra/vcs.rb +0 -62
- data/lib/nanoc/extra/vcses.rb +0 -15
- data/lib/nanoc/extra/vcses/bazaar.rb +0 -21
- data/lib/nanoc/extra/vcses/dummy.rb +0 -20
- data/lib/nanoc/extra/vcses/git.rb +0 -21
- data/lib/nanoc/extra/vcses/mercurial.rb +0 -21
- data/lib/nanoc/extra/vcses/subversion.rb +0 -21
- data/lib/nanoc/filters/coderay.rb +0 -19
- data/lib/nanoc3.rb +0 -3
- data/lib/nanoc3/cli.rb +0 -3
- data/lib/nanoc3/tasks.rb +0 -3
- data/test/cli/commands/test_create_item.rb +0 -10
- data/test/cli/commands/test_create_layout.rb +0 -24
- data/test/cli/commands/test_sync.rb +0 -27
- data/test/cli/commands/test_update.rb +0 -6
- data/test/cli/commands/test_watch.rb +0 -74
- data/test/extra/test_auto_compiler.rb +0 -437
- data/test/extra/test_vcs.rb +0 -18
- data/test/extra/validators/test_links.rb +0 -4
- data/test/extra/validators/test_w3c.rb +0 -37
- data/test/filters/test_coderay.rb +0 -40
data/test/base/test_item.rb
CHANGED
@@ -1,30 +1,32 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
-
class Nanoc::ItemTest < Nanoc::TestCase
|
3
|
+
class Nanoc::Int::ItemTest < Nanoc::TestCase
|
4
4
|
def test_initialize_with_attributes_with_string_keys
|
5
|
-
item = Nanoc::Item.new('foo', { 'abc' => 'xyz' }, '/foo/')
|
5
|
+
item = Nanoc::Int::Item.new('foo', { 'abc' => 'xyz' }, '/foo/')
|
6
6
|
|
7
7
|
assert_equal nil, item.attributes['abc']
|
8
8
|
assert_equal 'xyz', item.attributes[:abc]
|
9
9
|
end
|
10
10
|
|
11
11
|
def test_initialize_with_unclean_identifier
|
12
|
-
item = Nanoc::Item.new('foo', {}, '/foo')
|
12
|
+
item = Nanoc::Int::Item.new('foo', {}, '/foo')
|
13
13
|
|
14
|
-
assert_equal '/foo/', item.identifier
|
14
|
+
assert_equal '/foo/', item.identifier.to_s
|
15
15
|
end
|
16
16
|
|
17
|
-
def
|
18
|
-
item = Nanoc::Item.new(
|
17
|
+
def test_reference
|
18
|
+
item = Nanoc::Int::Item.new(
|
19
|
+
'content',
|
20
|
+
{ one: 'one in item' },
|
21
|
+
'/path/'
|
22
|
+
)
|
19
23
|
|
20
|
-
|
21
|
-
item.identifier.chop!
|
22
|
-
end
|
24
|
+
assert_equal([:item, '/path/'], item.reference)
|
23
25
|
end
|
24
26
|
|
25
27
|
def test_lookup
|
26
28
|
# Create item
|
27
|
-
item = Nanoc::Item.new(
|
29
|
+
item = Nanoc::Int::Item.new(
|
28
30
|
'content',
|
29
31
|
{ one: 'one in item' },
|
30
32
|
'/path/'
|
@@ -38,7 +40,7 @@ class Nanoc::ItemTest < Nanoc::TestCase
|
|
38
40
|
end
|
39
41
|
|
40
42
|
def test_set_attribute
|
41
|
-
item = Nanoc::Item.new('foo', {}, '/foo')
|
43
|
+
item = Nanoc::Int::Item.new('foo', {}, '/foo')
|
42
44
|
assert_equal nil, item[:motto]
|
43
45
|
|
44
46
|
item[:motto] = 'More human than human'
|
@@ -56,7 +58,7 @@ class Nanoc::ItemTest < Nanoc::TestCase
|
|
56
58
|
end
|
57
59
|
|
58
60
|
# Mock item
|
59
|
-
item = Nanoc::Item.new('foo', {}, '/foo')
|
61
|
+
item = Nanoc::Int::Item.new('foo', {}, '/foo')
|
60
62
|
item.expects(:reps).returns([rep])
|
61
63
|
|
62
64
|
# Check
|
@@ -74,7 +76,7 @@ class Nanoc::ItemTest < Nanoc::TestCase
|
|
74
76
|
end
|
75
77
|
|
76
78
|
# Mock item
|
77
|
-
item = Nanoc::Item.new('foo', {}, '/foo')
|
79
|
+
item = Nanoc::Int::Item.new('foo', {}, '/foo')
|
78
80
|
item.expects(:reps).returns([rep])
|
79
81
|
|
80
82
|
# Check
|
@@ -92,7 +94,7 @@ class Nanoc::ItemTest < Nanoc::TestCase
|
|
92
94
|
end
|
93
95
|
|
94
96
|
# Mock item
|
95
|
-
item = Nanoc::Item.new('foo', {}, '/foo')
|
97
|
+
item = Nanoc::Int::Item.new('foo', {}, '/foo')
|
96
98
|
item.expects(:reps).returns([rep])
|
97
99
|
|
98
100
|
# Check
|
@@ -101,11 +103,11 @@ class Nanoc::ItemTest < Nanoc::TestCase
|
|
101
103
|
|
102
104
|
def test_compiled_content_with_custom_nonexistant_rep
|
103
105
|
# Mock item
|
104
|
-
item = Nanoc::Item.new('foo', {}, '/foo')
|
106
|
+
item = Nanoc::Int::Item.new('foo', {}, '/foo')
|
105
107
|
item.expects(:reps).returns([])
|
106
108
|
|
107
109
|
# Check
|
108
|
-
assert_raises(Nanoc::Errors::Generic) do
|
110
|
+
assert_raises(Nanoc::Int::Errors::Generic) do
|
109
111
|
item.compiled_content(rep: :lkasdhflahgwfe)
|
110
112
|
end
|
111
113
|
end
|
@@ -117,7 +119,7 @@ class Nanoc::ItemTest < Nanoc::TestCase
|
|
117
119
|
rep.expects(:path).returns('the correct path')
|
118
120
|
|
119
121
|
# Mock item
|
120
|
-
item = Nanoc::Item.new('foo', {}, '/foo')
|
122
|
+
item = Nanoc::Int::Item.new('foo', {}, '/foo')
|
121
123
|
item.expects(:reps).returns([rep])
|
122
124
|
|
123
125
|
# Check
|
@@ -131,7 +133,7 @@ class Nanoc::ItemTest < Nanoc::TestCase
|
|
131
133
|
rep.expects(:path).returns('the correct path')
|
132
134
|
|
133
135
|
# Mock item
|
134
|
-
item = Nanoc::Item.new('foo', {}, '/foo')
|
136
|
+
item = Nanoc::Int::Item.new('foo', {}, '/foo')
|
135
137
|
item.expects(:reps).returns([rep])
|
136
138
|
|
137
139
|
# Check
|
@@ -139,7 +141,7 @@ class Nanoc::ItemTest < Nanoc::TestCase
|
|
139
141
|
end
|
140
142
|
|
141
143
|
def test_freeze_should_disallow_changes
|
142
|
-
item = Nanoc::Item.new('foo', { a: { b: 123 } }, '/foo/')
|
144
|
+
item = Nanoc::Int::Item.new('foo', { a: { b: 123 } }, '/foo/')
|
143
145
|
item.freeze
|
144
146
|
|
145
147
|
assert_raises_frozen_error do
|
@@ -152,14 +154,14 @@ class Nanoc::ItemTest < Nanoc::TestCase
|
|
152
154
|
end
|
153
155
|
|
154
156
|
def test_dump_and_load
|
155
|
-
item = Nanoc::Item.new(
|
157
|
+
item = Nanoc::Int::Item.new(
|
156
158
|
'foobar',
|
157
159
|
{ a: { b: 123 } },
|
158
160
|
'/foo/')
|
159
161
|
|
160
162
|
item = Marshal.load(Marshal.dump(item))
|
161
163
|
|
162
|
-
assert_equal '/foo/', item.identifier
|
164
|
+
assert_equal Nanoc::Identifier.new('/foo/'), item.identifier
|
163
165
|
assert_equal 'foobar', item.raw_content
|
164
166
|
assert_equal({ a: { b: 123 } }, item.attributes)
|
165
167
|
end
|
@@ -1,13 +1,13 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
-
class Nanoc::ItemArrayTest < Nanoc::TestCase
|
3
|
+
class Nanoc::Int::ItemArrayTest < Nanoc::TestCase
|
4
4
|
def setup
|
5
5
|
super
|
6
6
|
|
7
|
-
@one = Nanoc::Item.new('Item One', {}, '/one/')
|
8
|
-
@two = Nanoc::Item.new('Item Two', {}, '/two/')
|
7
|
+
@one = Nanoc::Int::Item.new('Item One', {}, '/one/')
|
8
|
+
@two = Nanoc::Int::Item.new('Item Two', {}, '/two/')
|
9
9
|
|
10
|
-
@items = Nanoc::ItemArray.new
|
10
|
+
@items = Nanoc::Int::ItemArray.new
|
11
11
|
@items << @one
|
12
12
|
@items << @two
|
13
13
|
end
|
@@ -97,7 +97,7 @@ class Nanoc::ItemArrayTest < Nanoc::TestCase
|
|
97
97
|
end
|
98
98
|
|
99
99
|
def test_regex
|
100
|
-
foo = Nanoc::Item.new('Item Foo', {}, '/foo/')
|
100
|
+
foo = Nanoc::Int::Item.new('Item Foo', {}, '/foo/')
|
101
101
|
@items << foo
|
102
102
|
|
103
103
|
assert_equal [@one], @items[/n/]
|
@@ -108,7 +108,7 @@ class Nanoc::ItemArrayTest < Nanoc::TestCase
|
|
108
108
|
assert_nil @items[2]
|
109
109
|
assert_nil @items['/foo/']
|
110
110
|
|
111
|
-
foo = Nanoc::Item.new('Item Foo', {}, '/foo/')
|
111
|
+
foo = Nanoc::Int::Item.new('Item Foo', {}, '/foo/')
|
112
112
|
@items << foo
|
113
113
|
|
114
114
|
assert_equal foo, @items[2]
|
@@ -117,10 +117,10 @@ class Nanoc::ItemArrayTest < Nanoc::TestCase
|
|
117
117
|
|
118
118
|
def test_assign
|
119
119
|
assert_raises(TypeError) do
|
120
|
-
@items['/blah/'] = Nanoc::Item.new('Item blah', {}, '/blah/')
|
120
|
+
@items['/blah/'] = Nanoc::Int::Item.new('Item blah', {}, '/blah/')
|
121
121
|
end
|
122
122
|
|
123
|
-
new_item = Nanoc::Item.new('New Item One', {}, '/one-new/')
|
123
|
+
new_item = Nanoc::Int::Item.new('New Item One', {}, '/one-new/')
|
124
124
|
@items[0] = new_item
|
125
125
|
|
126
126
|
assert_equal new_item, @items[0]
|
@@ -131,7 +131,7 @@ class Nanoc::ItemArrayTest < Nanoc::TestCase
|
|
131
131
|
def test_assign_frozen
|
132
132
|
@items.freeze
|
133
133
|
|
134
|
-
new_item = Nanoc::Item.new('New Item One', {}, '/one-new/')
|
134
|
+
new_item = Nanoc::Int::Item.new('New Item One', {}, '/one-new/')
|
135
135
|
|
136
136
|
assert_raises_frozen_error do
|
137
137
|
@items[0] = new_item
|
@@ -151,7 +151,7 @@ class Nanoc::ItemArrayTest < Nanoc::TestCase
|
|
151
151
|
|
152
152
|
def test_collect_bang
|
153
153
|
@items.collect! do |i|
|
154
|
-
Nanoc::Item.new("New #{i.raw_content}", {}, "/new#{i.identifier}")
|
154
|
+
Nanoc::Int::Item.new("New #{i.raw_content}", {}, "/new#{i.identifier}")
|
155
155
|
end
|
156
156
|
|
157
157
|
assert_nil @items['/one/']
|
@@ -169,13 +169,13 @@ class Nanoc::ItemArrayTest < Nanoc::TestCase
|
|
169
169
|
|
170
170
|
assert_raises_frozen_error do
|
171
171
|
@items.collect! do |i|
|
172
|
-
Nanoc::Item.new("New #{i.raw_content}", {}, "/new#{i.identifier}")
|
172
|
+
Nanoc::Int::Item.new("New #{i.raw_content}", {}, "/new#{i.identifier}")
|
173
173
|
end
|
174
174
|
end
|
175
175
|
end
|
176
176
|
|
177
177
|
def test_concat
|
178
|
-
new_item = Nanoc::Item.new('New item', {}, '/new/')
|
178
|
+
new_item = Nanoc::Int::Item.new('New item', {}, '/new/')
|
179
179
|
@items.concat([new_item])
|
180
180
|
|
181
181
|
assert_equal new_item, @items[2]
|
@@ -213,7 +213,7 @@ class Nanoc::ItemArrayTest < Nanoc::TestCase
|
|
213
213
|
end
|
214
214
|
|
215
215
|
def test_fill_all
|
216
|
-
@items.fill { |i| Nanoc::Item.new("Item #{i}", {}, "/new/#{i}/") }
|
216
|
+
@items.fill { |i| Nanoc::Int::Item.new("Item #{i}", {}, "/new/#{i}/") }
|
217
217
|
|
218
218
|
assert_nil @items['/one/']
|
219
219
|
assert_nil @items['/two/']
|
@@ -225,7 +225,7 @@ class Nanoc::ItemArrayTest < Nanoc::TestCase
|
|
225
225
|
end
|
226
226
|
|
227
227
|
def test_fill_range
|
228
|
-
@items.fill(1..-1) { |i| Nanoc::Item.new("Item #{i}", {}, "/new/#{i}/") }
|
228
|
+
@items.fill(1..-1) { |i| Nanoc::Int::Item.new("Item #{i}", {}, "/new/#{i}/") }
|
229
229
|
|
230
230
|
assert_equal @one, @items['/one/']
|
231
231
|
assert_nil @items['/two/']
|
@@ -260,7 +260,7 @@ class Nanoc::ItemArrayTest < Nanoc::TestCase
|
|
260
260
|
end
|
261
261
|
|
262
262
|
def test_push
|
263
|
-
pushy = Nanoc::Item.new('Pushy', {}, '/pushy/')
|
263
|
+
pushy = Nanoc::Int::Item.new('Pushy', {}, '/pushy/')
|
264
264
|
@items.push(pushy)
|
265
265
|
|
266
266
|
assert_equal @one, @items[0]
|
@@ -282,8 +282,8 @@ class Nanoc::ItemArrayTest < Nanoc::TestCase
|
|
282
282
|
end
|
283
283
|
|
284
284
|
def test_replace
|
285
|
-
max = Nanoc::Item.new('Max', {}, '/max/')
|
286
|
-
mona = Nanoc::Item.new('Mona', {}, '/mona/')
|
285
|
+
max = Nanoc::Int::Item.new('Max', {}, '/max/')
|
286
|
+
mona = Nanoc::Int::Item.new('Mona', {}, '/mona/')
|
287
287
|
|
288
288
|
@items.replace([max, mona])
|
289
289
|
|
@@ -327,7 +327,7 @@ class Nanoc::ItemArrayTest < Nanoc::TestCase
|
|
327
327
|
end
|
328
328
|
|
329
329
|
def test_unshift
|
330
|
-
unshifty = Nanoc::Item.new('Unshifty', {}, '/unshifty/')
|
330
|
+
unshifty = Nanoc::Int::Item.new('Unshifty', {}, '/unshifty/')
|
331
331
|
@items.unshift(unshifty)
|
332
332
|
|
333
333
|
assert_equal unshifty, @items[0]
|
data/test/base/test_item_rep.rb
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
-
class Nanoc::ItemRepTest < Nanoc::TestCase
|
3
|
+
class Nanoc::Int::ItemRepTest < Nanoc::TestCase
|
4
4
|
def test_created_modified_compiled
|
5
5
|
# TODO: implement
|
6
6
|
end
|
7
7
|
|
8
8
|
def test_compiled_content_with_only_last_available
|
9
9
|
# Create rep
|
10
|
-
item = Nanoc::Item.new(
|
10
|
+
item = Nanoc::Int::Item.new(
|
11
11
|
'blah blah blah', {}, '/',
|
12
12
|
binary: false, mtime: Time.now - 500
|
13
13
|
)
|
14
|
-
rep = Nanoc::ItemRep.new(item, nil)
|
14
|
+
rep = Nanoc::Int::ItemRep.new(item, nil)
|
15
15
|
rep.instance_eval { @content = { last: 'last content' } }
|
16
16
|
rep.expects(:compiled?).returns(true)
|
17
17
|
|
@@ -21,11 +21,11 @@ class Nanoc::ItemRepTest < Nanoc::TestCase
|
|
21
21
|
|
22
22
|
def test_compiled_content_with_pre_and_last_available
|
23
23
|
# Create rep
|
24
|
-
item = Nanoc::Item.new(
|
24
|
+
item = Nanoc::Int::Item.new(
|
25
25
|
'blah blah blah', {}, '/',
|
26
26
|
binary: false, mtime: Time.now - 500
|
27
27
|
)
|
28
|
-
rep = Nanoc::ItemRep.new(item, nil)
|
28
|
+
rep = Nanoc::Int::ItemRep.new(item, nil)
|
29
29
|
rep.instance_eval { @content = { pre: 'pre content', last: 'last content' } }
|
30
30
|
rep.expects(:compiled?).returns(true)
|
31
31
|
|
@@ -35,11 +35,11 @@ class Nanoc::ItemRepTest < Nanoc::TestCase
|
|
35
35
|
|
36
36
|
def test_compiled_content_with_custom_snapshot
|
37
37
|
# Create rep
|
38
|
-
item = Nanoc::Item.new(
|
38
|
+
item = Nanoc::Int::Item.new(
|
39
39
|
'blah blah blah', {}, '/',
|
40
40
|
binary: false, mtime: Time.now - 500
|
41
41
|
)
|
42
|
-
rep = Nanoc::ItemRep.new(item, nil)
|
42
|
+
rep = Nanoc::Int::ItemRep.new(item, nil)
|
43
43
|
rep.instance_eval { @content = { pre: 'pre content', last: 'last content' } }
|
44
44
|
rep.expects(:compiled?).returns(true)
|
45
45
|
|
@@ -49,57 +49,57 @@ class Nanoc::ItemRepTest < Nanoc::TestCase
|
|
49
49
|
|
50
50
|
def test_compiled_content_with_invalid_snapshot
|
51
51
|
# Create rep
|
52
|
-
item = Nanoc::Item.new(
|
52
|
+
item = Nanoc::Int::Item.new(
|
53
53
|
'blah blah blah', {}, '/',
|
54
54
|
binary: false, mtime: Time.now - 500
|
55
55
|
)
|
56
|
-
rep = Nanoc::ItemRep.new(item, nil)
|
56
|
+
rep = Nanoc::Int::ItemRep.new(item, nil)
|
57
57
|
rep.instance_eval { @content = { pre: 'pre content', last: 'last content' } }
|
58
58
|
|
59
59
|
# Check
|
60
|
-
assert_raises Nanoc::Errors::NoSuchSnapshot do
|
60
|
+
assert_raises Nanoc::Int::Errors::NoSuchSnapshot do
|
61
61
|
rep.compiled_content(snapshot: :klsjflkasdfl)
|
62
62
|
end
|
63
63
|
end
|
64
64
|
|
65
65
|
def test_compiled_content_with_uncompiled_content
|
66
66
|
# Create rep
|
67
|
-
item = Nanoc::Item.new(
|
67
|
+
item = Nanoc::Int::Item.new(
|
68
68
|
'blah blah', {}, '/',
|
69
69
|
binary: false
|
70
70
|
)
|
71
|
-
rep = Nanoc::ItemRep.new(item, nil)
|
71
|
+
rep = Nanoc::Int::ItemRep.new(item, nil)
|
72
72
|
rep.expects(:compiled?).returns(false)
|
73
73
|
|
74
74
|
# Check
|
75
|
-
assert_raises(Nanoc::Errors::UnmetDependency) do
|
75
|
+
assert_raises(Nanoc::Int::Errors::UnmetDependency) do
|
76
76
|
rep.compiled_content
|
77
77
|
end
|
78
78
|
end
|
79
79
|
|
80
80
|
def test_compiled_content_with_moving_pre_snapshot
|
81
81
|
# Create rep
|
82
|
-
item = Nanoc::Item.new(
|
82
|
+
item = Nanoc::Int::Item.new(
|
83
83
|
'blah blah', {}, '/',
|
84
84
|
binary: false
|
85
85
|
)
|
86
|
-
rep = Nanoc::ItemRep.new(item, nil)
|
86
|
+
rep = Nanoc::Int::ItemRep.new(item, nil)
|
87
87
|
rep.expects(:compiled?).returns(false)
|
88
88
|
rep.instance_eval { @content = { pre: 'pre!', last: 'last!' } }
|
89
89
|
|
90
90
|
# Check
|
91
|
-
assert_raises(Nanoc::Errors::UnmetDependency) do
|
91
|
+
assert_raises(Nanoc::Int::Errors::UnmetDependency) do
|
92
92
|
rep.compiled_content(snapshot: :pre)
|
93
93
|
end
|
94
94
|
end
|
95
95
|
|
96
96
|
def test_compiled_content_with_non_moving_pre_snapshot
|
97
97
|
# Create rep
|
98
|
-
item = Nanoc::Item.new(
|
98
|
+
item = Nanoc::Int::Item.new(
|
99
99
|
'blah blah', {}, '/',
|
100
100
|
binary: false
|
101
101
|
)
|
102
|
-
rep = Nanoc::ItemRep.new(item, nil)
|
102
|
+
rep = Nanoc::Int::ItemRep.new(item, nil)
|
103
103
|
rep.expects(:compiled?).returns(false)
|
104
104
|
rep.snapshots = [[:pre, true]]
|
105
105
|
rep.instance_eval { @content = { pre: 'pre!', post: 'post!', last: 'last!' } }
|
@@ -110,13 +110,13 @@ class Nanoc::ItemRepTest < Nanoc::TestCase
|
|
110
110
|
|
111
111
|
def test_compiled_content_with_final_pre_snapshot_in_layout
|
112
112
|
# Mock layout
|
113
|
-
layout = Nanoc::Layout.new(
|
113
|
+
layout = Nanoc::Int::Layout.new(
|
114
114
|
%(BEFORE <%= @item_rep.compiled_content(snapshot: :pre) %> AFTER),
|
115
115
|
{},
|
116
116
|
'/somelayout/')
|
117
117
|
|
118
118
|
# Create item and item rep
|
119
|
-
item = Nanoc::Item.new(
|
119
|
+
item = Nanoc::Int::Item.new(
|
120
120
|
'blah blah', {}, '/',
|
121
121
|
binary: false
|
122
122
|
)
|
@@ -136,13 +136,13 @@ class Nanoc::ItemRepTest < Nanoc::TestCase
|
|
136
136
|
site.expect(:layouts, [])
|
137
137
|
|
138
138
|
# Mock item
|
139
|
-
item = Nanoc::Item.new(
|
139
|
+
item = Nanoc::Int::Item.new(
|
140
140
|
%(<%= '<%= "blah" %' + '>' %>), {}, '/',
|
141
141
|
binary: false
|
142
142
|
)
|
143
143
|
|
144
144
|
# Create item rep
|
145
|
-
item_rep = Nanoc::ItemRep.new(item, :foo)
|
145
|
+
item_rep = Nanoc::Int::ItemRep.new(item, :foo)
|
146
146
|
item_rep.instance_eval do
|
147
147
|
@content[:raw] = item.raw_content
|
148
148
|
@content[:last] = @content[:raw]
|
@@ -161,16 +161,16 @@ class Nanoc::ItemRepTest < Nanoc::TestCase
|
|
161
161
|
|
162
162
|
def test_layout
|
163
163
|
# Mock layout
|
164
|
-
layout = Nanoc::Layout.new(%(<%= "blah" %>), {}, '/somelayout/')
|
164
|
+
layout = Nanoc::Int::Layout.new(%(<%= "blah" %>), {}, '/somelayout/')
|
165
165
|
|
166
166
|
# Mock item
|
167
|
-
item = Nanoc::Item.new(
|
167
|
+
item = Nanoc::Int::Item.new(
|
168
168
|
'blah blah', {}, '/',
|
169
169
|
binary: false
|
170
170
|
)
|
171
171
|
|
172
172
|
# Create item rep
|
173
|
-
item_rep = Nanoc::ItemRep.new(item, :foo)
|
173
|
+
item_rep = Nanoc::Int::ItemRep.new(item, :foo)
|
174
174
|
item_rep.instance_eval do
|
175
175
|
@content[:raw] = item.raw_content
|
176
176
|
@content[:last] = @content[:raw]
|
@@ -190,13 +190,13 @@ class Nanoc::ItemRepTest < Nanoc::TestCase
|
|
190
190
|
site.expect(:layouts, [])
|
191
191
|
|
192
192
|
# Mock item
|
193
|
-
item = Nanoc::Item.new(
|
193
|
+
item = Nanoc::Int::Item.new(
|
194
194
|
%(<%= '<%= "blah" %' + '>' %>), {}, '/foobar/',
|
195
195
|
binary: false
|
196
196
|
)
|
197
197
|
|
198
198
|
# Create item rep
|
199
|
-
item_rep = Nanoc::ItemRep.new(item, :foo)
|
199
|
+
item_rep = Nanoc::Int::ItemRep.new(item, :foo)
|
200
200
|
item_rep.instance_eval do
|
201
201
|
@content[:raw] = item.raw_content
|
202
202
|
@content[:last] = @content[:raw]
|
@@ -218,13 +218,13 @@ class Nanoc::ItemRepTest < Nanoc::TestCase
|
|
218
218
|
|
219
219
|
def test_snapshot_should_be_written
|
220
220
|
# Mock item
|
221
|
-
item = Nanoc::Item.new(
|
221
|
+
item = Nanoc::Int::Item.new(
|
222
222
|
'blah blah', {}, '/',
|
223
223
|
binary: false
|
224
224
|
)
|
225
225
|
|
226
226
|
# Create rep
|
227
|
-
item_rep = Nanoc::ItemRep.new(item, :foo)
|
227
|
+
item_rep = Nanoc::Int::ItemRep.new(item, :foo)
|
228
228
|
item_rep.instance_eval { @content[:last] = 'Lorem ipsum, etc.' }
|
229
229
|
item_rep.raw_paths = { moo: 'foo-moo.txt' }
|
230
230
|
|
@@ -247,16 +247,16 @@ class Nanoc::ItemRepTest < Nanoc::TestCase
|
|
247
247
|
|
248
248
|
def test_write_should_not_touch_identical_textual_files
|
249
249
|
# Mock item
|
250
|
-
item = Nanoc::Item.new(
|
250
|
+
item = Nanoc::Int::Item.new(
|
251
251
|
'blah blah', {}, '/',
|
252
252
|
binary: false
|
253
253
|
)
|
254
254
|
|
255
255
|
# Create rep
|
256
|
-
item_rep = Nanoc::ItemRep.new(item, :foo)
|
256
|
+
item_rep = Nanoc::Int::ItemRep.new(item, :foo)
|
257
257
|
def item_rep.generate_diff; end
|
258
258
|
item_rep.instance_eval { @content[:last] = 'Lorem ipsum, etc.' }
|
259
|
-
item_rep.
|
259
|
+
item_rep.raw_paths[:last] = 'foo/bar/baz/quux.txt'
|
260
260
|
|
261
261
|
# Write once
|
262
262
|
item_rep.write
|
@@ -271,15 +271,15 @@ class Nanoc::ItemRepTest < Nanoc::TestCase
|
|
271
271
|
|
272
272
|
def test_write
|
273
273
|
# Mock item
|
274
|
-
item = Nanoc::Item.new(
|
274
|
+
item = Nanoc::Int::Item.new(
|
275
275
|
'blah blah', {}, '/',
|
276
276
|
binary: false
|
277
277
|
)
|
278
278
|
|
279
279
|
# Create rep
|
280
|
-
item_rep = Nanoc::ItemRep.new(item, :foo)
|
280
|
+
item_rep = Nanoc::Int::ItemRep.new(item, :foo)
|
281
281
|
item_rep.instance_eval { @content[:last] = 'Lorem ipsum, etc.' }
|
282
|
-
item_rep.
|
282
|
+
item_rep.raw_paths[:last] = 'foo/bar/baz/quux.txt'
|
283
283
|
|
284
284
|
# Write
|
285
285
|
item_rep.write
|
@@ -291,13 +291,13 @@ class Nanoc::ItemRepTest < Nanoc::TestCase
|
|
291
291
|
|
292
292
|
def test_filter_text_to_binary
|
293
293
|
# Mock item
|
294
|
-
item = Nanoc::Item.new(
|
294
|
+
item = Nanoc::Int::Item.new(
|
295
295
|
'blah blah', {}, '/',
|
296
296
|
binary: false
|
297
297
|
)
|
298
298
|
|
299
299
|
# Create rep
|
300
|
-
rep = Nanoc::ItemRep.new(item, :foo)
|
300
|
+
rep = Nanoc::Int::ItemRep.new(item, :foo)
|
301
301
|
def rep.assigns
|
302
302
|
{}
|
303
303
|
end
|
@@ -321,13 +321,13 @@ class Nanoc::ItemRepTest < Nanoc::TestCase
|
|
321
321
|
|
322
322
|
def test_filter_with_textual_rep_and_binary_filter
|
323
323
|
# Mock item
|
324
|
-
item = Nanoc::Item.new(
|
324
|
+
item = Nanoc::Int::Item.new(
|
325
325
|
'blah blah', {}, '/',
|
326
326
|
binary: false
|
327
327
|
)
|
328
328
|
|
329
329
|
# Create rep
|
330
|
-
rep = Nanoc::ItemRep.new(item, :foo)
|
330
|
+
rep = Nanoc::Int::ItemRep.new(item, :foo)
|
331
331
|
def rep.assigns
|
332
332
|
{}
|
333
333
|
end
|
@@ -343,7 +343,7 @@ class Nanoc::ItemRepTest < Nanoc::TestCase
|
|
343
343
|
end
|
344
344
|
|
345
345
|
# Run
|
346
|
-
assert_raises ::Nanoc::Errors::CannotUseBinaryFilter do
|
346
|
+
assert_raises ::Nanoc::Int::Errors::CannotUseBinaryFilter do
|
347
347
|
rep.filter(:foo)
|
348
348
|
end
|
349
349
|
end
|
@@ -359,7 +359,7 @@ class Nanoc::ItemRepTest < Nanoc::TestCase
|
|
359
359
|
create_textual_filter
|
360
360
|
|
361
361
|
assert rep.binary?
|
362
|
-
assert_raises(Nanoc::Errors::CannotUseTextualFilter) { rep.filter(:text_filter) }
|
362
|
+
assert_raises(Nanoc::Int::Errors::CannotUseTextualFilter) { rep.filter(:text_filter) }
|
363
363
|
end
|
364
364
|
|
365
365
|
def test_writing_binary_reps_uses_content_in_last_filename
|
@@ -383,7 +383,7 @@ class Nanoc::ItemRepTest < Nanoc::TestCase
|
|
383
383
|
|
384
384
|
def test_converted_binary_rep_can_be_layed_out
|
385
385
|
# Mock layout
|
386
|
-
layout = Nanoc::Layout.new(%(<%= "blah" %> <%= yield %>), {}, '/somelayout/')
|
386
|
+
layout = Nanoc::Int::Layout.new(%(<%= "blah" %> <%= yield %>), {}, '/somelayout/')
|
387
387
|
|
388
388
|
# Create item and item rep
|
389
389
|
item = create_binary_item
|
@@ -464,7 +464,7 @@ class Nanoc::ItemRepTest < Nanoc::TestCase
|
|
464
464
|
end
|
465
465
|
rep.filter(:binary_to_text)
|
466
466
|
refute rep.binary?
|
467
|
-
assert_raises(Nanoc::Errors::CannotUseBinaryFilter) { rep.filter(:binary_filter) }
|
467
|
+
assert_raises(Nanoc::Int::Errors::CannotUseBinaryFilter) { rep.filter(:binary_filter) }
|
468
468
|
end
|
469
469
|
|
470
470
|
def test_new_content_should_be_frozen
|
@@ -475,8 +475,8 @@ class Nanoc::ItemRepTest < Nanoc::TestCase
|
|
475
475
|
end
|
476
476
|
end
|
477
477
|
|
478
|
-
item = Nanoc::Item.new('foo bar', {}, '/foo/')
|
479
|
-
rep = Nanoc::ItemRep.new(item, :default)
|
478
|
+
item = Nanoc::Int::Item.new('foo bar', {}, '/foo/')
|
479
|
+
rep = Nanoc::Int::ItemRep.new(item, :default)
|
480
480
|
rep.instance_eval { @filter_class = filter_class }
|
481
481
|
def rep.filter_named(_name)
|
482
482
|
@filter_class
|
@@ -495,8 +495,8 @@ class Nanoc::ItemRepTest < Nanoc::TestCase
|
|
495
495
|
end
|
496
496
|
end
|
497
497
|
|
498
|
-
item = Nanoc::Item.new('foo bar', {}, '/foo/')
|
499
|
-
rep = Nanoc::ItemRep.new(item, :default)
|
498
|
+
item = Nanoc::Int::Item.new('foo bar', {}, '/foo/')
|
499
|
+
rep = Nanoc::Int::ItemRep.new(item, :default)
|
500
500
|
rep.instance_eval { @filter_class = filter_class }
|
501
501
|
def rep.filter_named(_name)
|
502
502
|
@filter_class
|
@@ -510,19 +510,19 @@ class Nanoc::ItemRepTest < Nanoc::TestCase
|
|
510
510
|
|
511
511
|
def test_raw_path_should_generate_dependency
|
512
512
|
items = [
|
513
|
-
|
514
|
-
|
513
|
+
Nanoc::Int::Item.new('foo', {}, '/foo/'),
|
514
|
+
Nanoc::Int::Item.new('bar', {}, '/bar/')
|
515
515
|
]
|
516
516
|
item_reps = [
|
517
|
-
|
518
|
-
|
517
|
+
Nanoc::Int::ItemRep.new(items[0], :default),
|
518
|
+
Nanoc::Int::ItemRep.new(items[1], :default)
|
519
519
|
]
|
520
520
|
|
521
|
-
dt =
|
521
|
+
dt = Nanoc::Int::DependencyTracker.new(items)
|
522
522
|
dt.start
|
523
|
-
|
523
|
+
Nanoc::Int::NotificationCenter.post(:visit_started, items[0])
|
524
524
|
item_reps[1].raw_path
|
525
|
-
|
525
|
+
Nanoc::Int::NotificationCenter.post(:visit_ended, items[0])
|
526
526
|
dt.stop
|
527
527
|
|
528
528
|
assert_equal [items[1]], dt.objects_causing_outdatedness_of(items[0])
|
@@ -530,28 +530,28 @@ class Nanoc::ItemRepTest < Nanoc::TestCase
|
|
530
530
|
|
531
531
|
def test_path_should_generate_dependency
|
532
532
|
items = [
|
533
|
-
|
534
|
-
|
533
|
+
Nanoc::Int::Item.new('foo', {}, '/foo/'),
|
534
|
+
Nanoc::Int::Item.new('bar', {}, '/bar/')
|
535
535
|
]
|
536
536
|
item_reps = [
|
537
|
-
|
538
|
-
|
537
|
+
Nanoc::Int::ItemRep.new(items[0], :default),
|
538
|
+
Nanoc::Int::ItemRep.new(items[1], :default)
|
539
539
|
]
|
540
540
|
|
541
|
-
dt =
|
541
|
+
dt = Nanoc::Int::DependencyTracker.new(items)
|
542
542
|
dt.start
|
543
|
-
|
543
|
+
Nanoc::Int::NotificationCenter.post(:visit_started, items[0])
|
544
544
|
item_reps[1].path
|
545
|
-
|
545
|
+
Nanoc::Int::NotificationCenter.post(:visit_ended, items[0])
|
546
546
|
dt.stop
|
547
547
|
|
548
548
|
assert_equal [items[1]], dt.objects_causing_outdatedness_of(items[0])
|
549
549
|
end
|
550
550
|
|
551
551
|
def test_access_compiled_content_of_binary_item
|
552
|
-
item = Nanoc::Item.new('content/somefile.dat', {}, '/somefile/', binary: true)
|
553
|
-
item_rep = Nanoc::ItemRep.new(item, :foo)
|
554
|
-
assert_raises(Nanoc::Errors::CannotGetCompiledContentOfBinaryItem) do
|
552
|
+
item = Nanoc::Int::Item.new('content/somefile.dat', {}, '/somefile/', binary: true)
|
553
|
+
item_rep = Nanoc::Int::ItemRep.new(item, :foo)
|
554
|
+
assert_raises(Nanoc::Int::Errors::CannotGetCompiledContentOfBinaryItem) do
|
555
555
|
item_rep.compiled_content
|
556
556
|
end
|
557
557
|
end
|
@@ -560,64 +560,64 @@ class Nanoc::ItemRepTest < Nanoc::TestCase
|
|
560
560
|
# Mock item
|
561
561
|
FileUtils.mkdir_p('content')
|
562
562
|
File.open('content/meow.dat', 'w') { |io| io.write('asdf') }
|
563
|
-
item = Nanoc::Item.new(
|
563
|
+
item = Nanoc::Int::Item.new(
|
564
564
|
'content/meow.dat', {}, '/',
|
565
565
|
binary: true
|
566
566
|
)
|
567
567
|
|
568
568
|
# Create rep
|
569
|
-
item_rep = Nanoc::ItemRep.new(item, :foo)
|
569
|
+
item_rep = Nanoc::Int::ItemRep.new(item, :foo)
|
570
570
|
FileUtils.mkdir_p('tmp')
|
571
571
|
File.open('tmp/woof.dat', 'w') { |io| io.write('fdsa') }
|
572
572
|
item_rep.instance_eval { @temporary_filenames[:last] = 'tmp/woof.dat' }
|
573
|
-
item_rep.
|
573
|
+
item_rep.raw_paths[:last] = 'output/woof.dat'
|
574
574
|
|
575
575
|
# Write
|
576
576
|
notified = false
|
577
|
-
Nanoc::NotificationCenter.on(:rep_written, self) do |_rep, _raw_path, is_created, is_modified|
|
577
|
+
Nanoc::Int::NotificationCenter.on(:rep_written, self) do |_rep, _raw_path, is_created, is_modified|
|
578
578
|
notified = true
|
579
579
|
assert is_created
|
580
580
|
assert is_modified
|
581
581
|
end
|
582
582
|
item_rep.write
|
583
583
|
assert notified
|
584
|
-
Nanoc::NotificationCenter.remove(:rep_written, self)
|
584
|
+
Nanoc::Int::NotificationCenter.remove(:rep_written, self)
|
585
585
|
end
|
586
586
|
|
587
587
|
def test_write_should_calculate_is_modified_correctly_for_binary_items_existing
|
588
588
|
# Mock item
|
589
589
|
FileUtils.mkdir_p('content')
|
590
590
|
File.open('content/meow.dat', 'w') { |io| io.write('asdf') }
|
591
|
-
item = Nanoc::Item.new(
|
591
|
+
item = Nanoc::Int::Item.new(
|
592
592
|
'content/meow.dat', {}, '/',
|
593
593
|
binary: true
|
594
594
|
)
|
595
595
|
|
596
596
|
# Create rep
|
597
|
-
item_rep = Nanoc::ItemRep.new(item, :foo)
|
597
|
+
item_rep = Nanoc::Int::ItemRep.new(item, :foo)
|
598
598
|
FileUtils.mkdir_p('tmp')
|
599
599
|
File.open('tmp/woof.dat', 'w') { |io| io.write('fdsa') }
|
600
600
|
FileUtils.mkdir_p('output')
|
601
601
|
File.open('output/woof.dat', 'w') { |io| io.write('fdsa but different') }
|
602
602
|
item_rep.instance_eval { @temporary_filenames[:last] = 'tmp/woof.dat' }
|
603
|
-
item_rep.
|
603
|
+
item_rep.raw_paths[:last] = 'output/woof.dat'
|
604
604
|
|
605
605
|
# Write
|
606
606
|
notified = false
|
607
|
-
Nanoc::NotificationCenter.on(:rep_written, self) do |_rep, _raw_path, is_created, is_modified|
|
607
|
+
Nanoc::Int::NotificationCenter.on(:rep_written, self) do |_rep, _raw_path, is_created, is_modified|
|
608
608
|
notified = true
|
609
609
|
refute is_created
|
610
610
|
assert is_modified
|
611
611
|
end
|
612
612
|
item_rep.write
|
613
613
|
assert notified
|
614
|
-
Nanoc::NotificationCenter.remove(:rep_written, self)
|
614
|
+
Nanoc::Int::NotificationCenter.remove(:rep_written, self)
|
615
615
|
end
|
616
616
|
|
617
617
|
private
|
618
618
|
|
619
619
|
def create_binary_item
|
620
|
-
Nanoc::Item.new(
|
620
|
+
Nanoc::Int::Item.new(
|
621
621
|
'/a/file/name.dat', {}, '/',
|
622
622
|
binary: true
|
623
623
|
)
|
@@ -632,7 +632,7 @@ class Nanoc::ItemRepTest < Nanoc::TestCase
|
|
632
632
|
end
|
633
633
|
|
634
634
|
def create_rep_for(item, name)
|
635
|
-
Nanoc::ItemRep.new(item, name)
|
635
|
+
Nanoc::Int::ItemRep.new(item, name)
|
636
636
|
end
|
637
637
|
|
638
638
|
def create_textual_filter
|