nanoc3 3.2.4 → 3.3.0
Sign up to get free protection for your applications and to get access to all the features.
- metadata +14 -313
- data/.gemtest +0 -0
- data/ChangeLog +0 -3
- data/Gemfile +0 -29
- data/LICENSE +0 -19
- data/NEWS.md +0 -449
- data/README.md +0 -108
- data/Rakefile +0 -14
- data/bin/nanoc3 +0 -12
- data/doc/yardoc_templates/default/layout/html/footer.erb +0 -10
- data/lib/nanoc3.rb +0 -28
- data/lib/nanoc3/base.rb +0 -49
- data/lib/nanoc3/base/compilation/checksum_store.rb +0 -57
- data/lib/nanoc3/base/compilation/compiled_content_cache.rb +0 -62
- data/lib/nanoc3/base/compilation/compiler.rb +0 -455
- data/lib/nanoc3/base/compilation/compiler_dsl.rb +0 -214
- data/lib/nanoc3/base/compilation/dependency_tracker.rb +0 -196
- data/lib/nanoc3/base/compilation/filter.rb +0 -165
- data/lib/nanoc3/base/compilation/item_rep_proxy.rb +0 -102
- data/lib/nanoc3/base/compilation/item_rep_recorder_proxy.rb +0 -88
- data/lib/nanoc3/base/compilation/outdatedness_checker.rb +0 -223
- data/lib/nanoc3/base/compilation/outdatedness_reasons.rb +0 -46
- data/lib/nanoc3/base/compilation/rule.rb +0 -73
- data/lib/nanoc3/base/compilation/rule_context.rb +0 -84
- data/lib/nanoc3/base/compilation/rule_memory_calculator.rb +0 -40
- data/lib/nanoc3/base/compilation/rule_memory_store.rb +0 -53
- data/lib/nanoc3/base/compilation/rules_collection.rb +0 -231
- data/lib/nanoc3/base/context.rb +0 -47
- data/lib/nanoc3/base/core_ext.rb +0 -6
- data/lib/nanoc3/base/core_ext/array.rb +0 -62
- data/lib/nanoc3/base/core_ext/hash.rb +0 -63
- data/lib/nanoc3/base/core_ext/pathname.rb +0 -26
- data/lib/nanoc3/base/core_ext/string.rb +0 -46
- data/lib/nanoc3/base/directed_graph.rb +0 -275
- data/lib/nanoc3/base/errors.rb +0 -174
- data/lib/nanoc3/base/memoization.rb +0 -67
- data/lib/nanoc3/base/notification_center.rb +0 -84
- data/lib/nanoc3/base/ordered_hash.rb +0 -200
- data/lib/nanoc3/base/plugin_registry.rb +0 -165
- data/lib/nanoc3/base/result_data/item_rep.rb +0 -488
- data/lib/nanoc3/base/source_data/code_snippet.rb +0 -58
- data/lib/nanoc3/base/source_data/configuration.rb +0 -24
- data/lib/nanoc3/base/source_data/data_source.rb +0 -234
- data/lib/nanoc3/base/source_data/item.rb +0 -301
- data/lib/nanoc3/base/source_data/layout.rb +0 -130
- data/lib/nanoc3/base/source_data/site.rb +0 -361
- data/lib/nanoc3/base/store.rb +0 -135
- data/lib/nanoc3/cli.rb +0 -133
- data/lib/nanoc3/cli/command.rb +0 -139
- data/lib/nanoc3/cli/commands/autocompile.rb +0 -60
- data/lib/nanoc3/cli/commands/compile.rb +0 -280
- data/lib/nanoc3/cli/commands/create_item.rb +0 -62
- data/lib/nanoc3/cli/commands/create_layout.rb +0 -75
- data/lib/nanoc3/cli/commands/create_site.rb +0 -410
- data/lib/nanoc3/cli/commands/debug.rb +0 -119
- data/lib/nanoc3/cli/commands/info.rb +0 -98
- data/lib/nanoc3/cli/commands/nanoc.rb +0 -37
- data/lib/nanoc3/cli/commands/update.rb +0 -72
- data/lib/nanoc3/cli/commands/view.rb +0 -84
- data/lib/nanoc3/cli/commands/watch.rb +0 -125
- data/lib/nanoc3/cli/error_handler.rb +0 -193
- data/lib/nanoc3/cli/logger.rb +0 -91
- data/lib/nanoc3/data_sources.rb +0 -29
- data/lib/nanoc3/data_sources/deprecated/delicious.rb +0 -42
- data/lib/nanoc3/data_sources/deprecated/last_fm.rb +0 -87
- data/lib/nanoc3/data_sources/deprecated/twitter.rb +0 -38
- data/lib/nanoc3/data_sources/filesystem.rb +0 -299
- data/lib/nanoc3/data_sources/filesystem_unified.rb +0 -116
- data/lib/nanoc3/data_sources/filesystem_verbose.rb +0 -86
- data/lib/nanoc3/extra.rb +0 -22
- data/lib/nanoc3/extra/auto_compiler.rb +0 -103
- data/lib/nanoc3/extra/chick.rb +0 -125
- data/lib/nanoc3/extra/core_ext.rb +0 -4
- data/lib/nanoc3/extra/core_ext/enumerable.rb +0 -33
- data/lib/nanoc3/extra/core_ext/time.rb +0 -19
- data/lib/nanoc3/extra/deployers.rb +0 -11
- data/lib/nanoc3/extra/deployers/rsync.rb +0 -114
- data/lib/nanoc3/extra/file_proxy.rb +0 -40
- data/lib/nanoc3/extra/validators.rb +0 -12
- data/lib/nanoc3/extra/validators/links.rb +0 -264
- data/lib/nanoc3/extra/validators/w3c.rb +0 -95
- data/lib/nanoc3/extra/vcs.rb +0 -66
- data/lib/nanoc3/extra/vcses.rb +0 -17
- data/lib/nanoc3/extra/vcses/bazaar.rb +0 -25
- data/lib/nanoc3/extra/vcses/dummy.rb +0 -24
- data/lib/nanoc3/extra/vcses/git.rb +0 -25
- data/lib/nanoc3/extra/vcses/mercurial.rb +0 -25
- data/lib/nanoc3/extra/vcses/subversion.rb +0 -25
- data/lib/nanoc3/filters.rb +0 -53
- data/lib/nanoc3/filters/asciidoc.rb +0 -38
- data/lib/nanoc3/filters/bluecloth.rb +0 -19
- data/lib/nanoc3/filters/coderay.rb +0 -21
- data/lib/nanoc3/filters/colorize_syntax.rb +0 -261
- data/lib/nanoc3/filters/erb.rb +0 -35
- data/lib/nanoc3/filters/erubis.rb +0 -27
- data/lib/nanoc3/filters/haml.rb +0 -27
- data/lib/nanoc3/filters/kramdown.rb +0 -20
- data/lib/nanoc3/filters/less.rb +0 -53
- data/lib/nanoc3/filters/markaby.rb +0 -20
- data/lib/nanoc3/filters/maruku.rb +0 -20
- data/lib/nanoc3/filters/mustache.rb +0 -24
- data/lib/nanoc3/filters/rainpress.rb +0 -19
- data/lib/nanoc3/filters/rdiscount.rb +0 -22
- data/lib/nanoc3/filters/rdoc.rb +0 -33
- data/lib/nanoc3/filters/redcarpet.rb +0 -27
- data/lib/nanoc3/filters/redcloth.rb +0 -47
- data/lib/nanoc3/filters/relativize_paths.rb +0 -45
- data/lib/nanoc3/filters/rubypants.rb +0 -20
- data/lib/nanoc3/filters/sass.rb +0 -66
- data/lib/nanoc3/filters/slim.rb +0 -25
- data/lib/nanoc3/filters/typogruby.rb +0 -23
- data/lib/nanoc3/filters/uglify_js.rb +0 -42
- data/lib/nanoc3/helpers.rb +0 -16
- data/lib/nanoc3/helpers/blogging.rb +0 -319
- data/lib/nanoc3/helpers/breadcrumbs.rb +0 -40
- data/lib/nanoc3/helpers/capturing.rb +0 -138
- data/lib/nanoc3/helpers/filtering.rb +0 -50
- data/lib/nanoc3/helpers/html_escape.rb +0 -55
- data/lib/nanoc3/helpers/link_to.rb +0 -151
- data/lib/nanoc3/helpers/rendering.rb +0 -140
- data/lib/nanoc3/helpers/tagging.rb +0 -71
- data/lib/nanoc3/helpers/text.rb +0 -44
- data/lib/nanoc3/helpers/xml_sitemap.rb +0 -76
- data/lib/nanoc3/tasks.rb +0 -10
- data/lib/nanoc3/tasks/clean.rake +0 -16
- data/lib/nanoc3/tasks/clean.rb +0 -29
- data/lib/nanoc3/tasks/deploy/rsync.rake +0 -14
- data/lib/nanoc3/tasks/validate.rake +0 -92
- data/nanoc3.gemspec +0 -49
- data/tasks/doc.rake +0 -16
- data/tasks/test.rake +0 -44
- data/test/base/core_ext/array_spec.rb +0 -73
- data/test/base/core_ext/hash_spec.rb +0 -98
- data/test/base/core_ext/pathname_spec.rb +0 -27
- data/test/base/core_ext/string_spec.rb +0 -37
- data/test/base/test_checksum_store.rb +0 -35
- data/test/base/test_code_snippet.rb +0 -31
- data/test/base/test_compiler.rb +0 -316
- data/test/base/test_compiler_dsl.rb +0 -161
- data/test/base/test_context.rb +0 -31
- data/test/base/test_data_source.rb +0 -46
- data/test/base/test_dependency_tracker.rb +0 -262
- data/test/base/test_directed_graph.rb +0 -283
- data/test/base/test_filter.rb +0 -83
- data/test/base/test_item.rb +0 -179
- data/test/base/test_item_rep.rb +0 -553
- data/test/base/test_layout.rb +0 -59
- data/test/base/test_memoization.rb +0 -90
- data/test/base/test_notification_center.rb +0 -34
- data/test/base/test_outdatedness_checker.rb +0 -394
- data/test/base/test_plugin.rb +0 -30
- data/test/base/test_rule.rb +0 -19
- data/test/base/test_rule_context.rb +0 -65
- data/test/base/test_site.rb +0 -190
- data/test/cli/commands/test_compile.rb +0 -33
- data/test/cli/commands/test_create_item.rb +0 -14
- data/test/cli/commands/test_create_layout.rb +0 -28
- data/test/cli/commands/test_create_site.rb +0 -24
- data/test/cli/commands/test_help.rb +0 -12
- data/test/cli/commands/test_info.rb +0 -11
- data/test/cli/commands/test_update.rb +0 -10
- data/test/cli/test_cli.rb +0 -102
- data/test/cli/test_error_handler.rb +0 -29
- data/test/cli/test_logger.rb +0 -10
- data/test/data_sources/test_filesystem.rb +0 -433
- data/test/data_sources/test_filesystem_unified.rb +0 -536
- data/test/data_sources/test_filesystem_verbose.rb +0 -357
- data/test/extra/core_ext/test_enumerable.rb +0 -30
- data/test/extra/core_ext/test_time.rb +0 -15
- data/test/extra/deployers/test_rsync.rb +0 -232
- data/test/extra/test_auto_compiler.rb +0 -417
- data/test/extra/test_file_proxy.rb +0 -19
- data/test/extra/test_vcs.rb +0 -22
- data/test/extra/validators/test_links.rb +0 -51
- data/test/extra/validators/test_w3c.rb +0 -47
- data/test/filters/test_asciidoc.rb +0 -22
- data/test/filters/test_bluecloth.rb +0 -18
- data/test/filters/test_coderay.rb +0 -44
- data/test/filters/test_colorize_syntax.rb +0 -283
- data/test/filters/test_erb.rb +0 -99
- data/test/filters/test_erubis.rb +0 -70
- data/test/filters/test_haml.rb +0 -96
- data/test/filters/test_kramdown.rb +0 -18
- data/test/filters/test_less.rb +0 -113
- data/test/filters/test_markaby.rb +0 -24
- data/test/filters/test_maruku.rb +0 -18
- data/test/filters/test_mustache.rb +0 -25
- data/test/filters/test_rainpress.rb +0 -29
- data/test/filters/test_rdiscount.rb +0 -31
- data/test/filters/test_rdoc.rb +0 -18
- data/test/filters/test_redcarpet.rb +0 -63
- data/test/filters/test_redcloth.rb +0 -33
- data/test/filters/test_relativize_paths.rb +0 -332
- data/test/filters/test_rubypants.rb +0 -18
- data/test/filters/test_sass.rb +0 -229
- data/test/filters/test_slim.rb +0 -35
- data/test/filters/test_typogruby.rb +0 -21
- data/test/filters/test_uglify_js.rb +0 -30
- data/test/gem_loader.rb +0 -11
- data/test/helper.rb +0 -179
- data/test/helpers/test_blogging.rb +0 -754
- data/test/helpers/test_breadcrumbs.rb +0 -81
- data/test/helpers/test_capturing.rb +0 -41
- data/test/helpers/test_filtering.rb +0 -106
- data/test/helpers/test_html_escape.rb +0 -32
- data/test/helpers/test_link_to.rb +0 -249
- data/test/helpers/test_rendering.rb +0 -89
- data/test/helpers/test_tagging.rb +0 -87
- data/test/helpers/test_text.rb +0 -24
- data/test/helpers/test_xml_sitemap.rb +0 -103
- data/test/tasks/test_clean.rb +0 -67
@@ -1,357 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
class Nanoc3::DataSources::FilesystemVerboseTest < MiniTest::Unit::TestCase
|
4
|
-
|
5
|
-
include Nanoc3::TestHelpers
|
6
|
-
|
7
|
-
def new_data_source(params=nil)
|
8
|
-
# Mock site
|
9
|
-
site = Nanoc3::Site.new({})
|
10
|
-
|
11
|
-
# Create data source
|
12
|
-
data_source = Nanoc3::DataSources::FilesystemVerbose.new(site, nil, nil, params)
|
13
|
-
|
14
|
-
# Done
|
15
|
-
data_source
|
16
|
-
end
|
17
|
-
|
18
|
-
def test_items
|
19
|
-
# Create data source
|
20
|
-
data_source = new_data_source
|
21
|
-
|
22
|
-
# Create foo item
|
23
|
-
FileUtils.mkdir_p('content/foo')
|
24
|
-
File.open('content/foo/foo.yaml', 'w') do |io|
|
25
|
-
io.write("---\n")
|
26
|
-
io.write("title: Foo\n")
|
27
|
-
end
|
28
|
-
File.open('content/foo/foo.html', 'w') do |io|
|
29
|
-
io.write('Lorem ipsum dolor sit amet...')
|
30
|
-
end
|
31
|
-
|
32
|
-
# Create bar item
|
33
|
-
FileUtils.mkdir_p('content/bar')
|
34
|
-
File.open('content/bar/bar.yaml', 'w') do |io|
|
35
|
-
io.write("---\n")
|
36
|
-
io.write("title: Bar\n")
|
37
|
-
end
|
38
|
-
File.open('content/bar/bar.xml', 'w') do |io|
|
39
|
-
io.write("Lorem ipsum dolor sit amet...")
|
40
|
-
end
|
41
|
-
|
42
|
-
# Load items
|
43
|
-
items = data_source.items
|
44
|
-
|
45
|
-
# Check items
|
46
|
-
assert_equal(2, items.size)
|
47
|
-
assert(items.any? { |a|
|
48
|
-
a[:title] == 'Foo' &&
|
49
|
-
a[:extension] == 'html' &&
|
50
|
-
a[:content_filename] == 'content/foo/foo.html' &&
|
51
|
-
a[:meta_filename] == 'content/foo/foo.yaml'
|
52
|
-
})
|
53
|
-
assert(items.any? { |a|
|
54
|
-
a[:title] == 'Bar' &&
|
55
|
-
a[:extension] == 'xml' &&
|
56
|
-
a[:content_filename] == 'content/bar/bar.xml' &&
|
57
|
-
a[:meta_filename] == 'content/bar/bar.yaml'
|
58
|
-
})
|
59
|
-
end
|
60
|
-
|
61
|
-
def test_items_with_period_in_name
|
62
|
-
data_source = new_data_source(:allow_periods_in_identifiers => true)
|
63
|
-
|
64
|
-
# Create foo.css
|
65
|
-
FileUtils.mkdir_p('content/foo')
|
66
|
-
File.open('content/foo/foo.yaml', 'w') do |io|
|
67
|
-
io.write(YAML.dump({ 'title' => 'Foo' }))
|
68
|
-
end
|
69
|
-
File.open('content/foo/foo.css', 'w') do |io|
|
70
|
-
io.write('body.foo {}')
|
71
|
-
end
|
72
|
-
|
73
|
-
# Create foo.bar.css
|
74
|
-
FileUtils.mkdir_p('content/foo.bar')
|
75
|
-
File.open('content/foo.bar/foo.bar.yaml', 'w') do |io|
|
76
|
-
io.write(YAML.dump({ 'title' => 'Foo Bar' }))
|
77
|
-
end
|
78
|
-
File.open('content/foo.bar/foo.bar.css', 'w') do |io|
|
79
|
-
io.write('body.foobar {}')
|
80
|
-
end
|
81
|
-
|
82
|
-
# Load
|
83
|
-
items = data_source.items
|
84
|
-
|
85
|
-
# Check
|
86
|
-
assert_equal 2, items.size
|
87
|
-
assert_equal '/foo/', items[0].identifier
|
88
|
-
assert_equal 'Foo', items[0][:title]
|
89
|
-
assert_equal 'content/foo/foo.css', items[0][:content_filename]
|
90
|
-
assert_equal 'content/foo/foo.yaml', items[0][:meta_filename]
|
91
|
-
assert_equal '/foo.bar/', items[1].identifier
|
92
|
-
assert_equal 'Foo Bar', items[1][:title]
|
93
|
-
assert_equal 'content/foo.bar/foo.bar.css', items[1][:content_filename]
|
94
|
-
assert_equal 'content/foo.bar/foo.bar.yaml', items[1][:meta_filename]
|
95
|
-
end
|
96
|
-
|
97
|
-
def test_items_with_optional_meta_file
|
98
|
-
# Create data source
|
99
|
-
data_source = new_data_source
|
100
|
-
|
101
|
-
# Create foo item
|
102
|
-
FileUtils.mkdir_p('content/foo')
|
103
|
-
File.open('content/foo/foo.html', 'w') do |io|
|
104
|
-
io.write('Lorem ipsum dolor sit amet...')
|
105
|
-
end
|
106
|
-
|
107
|
-
# Create bar item
|
108
|
-
FileUtils.mkdir_p('content/bar')
|
109
|
-
File.open('content/bar/bar.yaml', 'w') do |io|
|
110
|
-
io.write("---\n")
|
111
|
-
io.write("title: Bar\n")
|
112
|
-
end
|
113
|
-
|
114
|
-
# Load items
|
115
|
-
items = data_source.items
|
116
|
-
|
117
|
-
# Check items
|
118
|
-
assert_equal(2, items.size)
|
119
|
-
assert(items.any? { |a|
|
120
|
-
a[:title] == nil &&
|
121
|
-
a[:extension] == 'html' &&
|
122
|
-
a[:content_filename] == 'content/foo/foo.html' &&
|
123
|
-
a[:meta_filename] == nil
|
124
|
-
})
|
125
|
-
assert(items.any? { |a|
|
126
|
-
a[:title] == 'Bar' &&
|
127
|
-
a[:extension] == nil &&
|
128
|
-
a[:content_filename] == nil &&
|
129
|
-
a[:meta_filename] == 'content/bar/bar.yaml'
|
130
|
-
})
|
131
|
-
end
|
132
|
-
|
133
|
-
def test_layouts
|
134
|
-
# Create data source
|
135
|
-
data_source = new_data_source
|
136
|
-
|
137
|
-
# Create layout
|
138
|
-
FileUtils.mkdir_p('layouts/foo')
|
139
|
-
File.open('layouts/foo/foo.yaml', 'w') do |io|
|
140
|
-
io.write("---\n")
|
141
|
-
io.write("filter: erb\n")
|
142
|
-
end
|
143
|
-
File.open('layouts/foo/foo.rhtml', 'w') do |io|
|
144
|
-
io.write('Lorem ipsum dolor sit amet...')
|
145
|
-
end
|
146
|
-
|
147
|
-
# Load layouts
|
148
|
-
layouts = data_source.layouts
|
149
|
-
|
150
|
-
# Check layouts
|
151
|
-
assert_equal(1, layouts.size)
|
152
|
-
assert_equal('erb', layouts[0][:filter])
|
153
|
-
assert_equal('rhtml', layouts[0][:extension])
|
154
|
-
assert_equal('layouts/foo/foo.rhtml', layouts[0][:content_filename])
|
155
|
-
assert_equal('layouts/foo/foo.yaml', layouts[0][:meta_filename])
|
156
|
-
end
|
157
|
-
|
158
|
-
def test_layouts_with_period_in_name_disallowing_periods_in_identifiers
|
159
|
-
data_source = new_data_source
|
160
|
-
|
161
|
-
# Create foo.html
|
162
|
-
FileUtils.mkdir_p('layouts/foo')
|
163
|
-
File.open('layouts/foo/foo.yaml', 'w') do |io|
|
164
|
-
io.write(YAML.dump({ 'dog' => 'woof' }))
|
165
|
-
end
|
166
|
-
File.open('layouts/foo/foo.html', 'w') do |io|
|
167
|
-
io.write('body.foo {}')
|
168
|
-
end
|
169
|
-
|
170
|
-
# Create bar.html.erb
|
171
|
-
FileUtils.mkdir_p('layouts/bar')
|
172
|
-
File.open('layouts/bar/bar.yaml', 'w') do |io|
|
173
|
-
io.write(YAML.dump({ 'cat' => 'meow' }))
|
174
|
-
end
|
175
|
-
File.open('layouts/bar/bar.html.erb', 'w') do |io|
|
176
|
-
io.write('body.foobar {}')
|
177
|
-
end
|
178
|
-
|
179
|
-
# Load
|
180
|
-
layouts = data_source.layouts.sort_by { |i| i.identifier }
|
181
|
-
|
182
|
-
# Check
|
183
|
-
assert_equal 2, layouts.size
|
184
|
-
assert_equal '/bar/', layouts[0].identifier
|
185
|
-
assert_equal 'meow', layouts[0][:cat]
|
186
|
-
assert_equal '/foo/', layouts[1].identifier
|
187
|
-
assert_equal 'woof', layouts[1][:dog]
|
188
|
-
end
|
189
|
-
|
190
|
-
def test_layouts_with_period_in_name_allowing_periods_in_identifiers
|
191
|
-
data_source = new_data_source(:allow_periods_in_identifiers => true)
|
192
|
-
|
193
|
-
# Create foo.html
|
194
|
-
FileUtils.mkdir_p('layouts/foo')
|
195
|
-
File.open('layouts/foo/foo.yaml', 'w') do |io|
|
196
|
-
io.write(YAML.dump({ 'dog' => 'woof' }))
|
197
|
-
end
|
198
|
-
File.open('layouts/foo/foo.html', 'w') do |io|
|
199
|
-
io.write('body.foo {}')
|
200
|
-
end
|
201
|
-
|
202
|
-
# Create bar.html.erb
|
203
|
-
FileUtils.mkdir_p('layouts/bar.xyz')
|
204
|
-
File.open('layouts/bar.xyz/bar.xyz.yaml', 'w') do |io|
|
205
|
-
io.write(YAML.dump({ 'cat' => 'meow' }))
|
206
|
-
end
|
207
|
-
File.open('layouts/bar.xyz/bar.xyz.html', 'w') do |io|
|
208
|
-
io.write('body.foobar {}')
|
209
|
-
end
|
210
|
-
|
211
|
-
# Load
|
212
|
-
layouts = data_source.layouts.sort_by { |i| i.identifier }
|
213
|
-
|
214
|
-
# Check
|
215
|
-
assert_equal 2, layouts.size
|
216
|
-
assert_equal '/bar.xyz/', layouts[0].identifier
|
217
|
-
assert_equal 'meow', layouts[0][:cat]
|
218
|
-
assert_equal '/foo/', layouts[1].identifier
|
219
|
-
assert_equal 'woof', layouts[1][:dog]
|
220
|
-
end
|
221
|
-
|
222
|
-
def test_create_item_at_root
|
223
|
-
# Create item
|
224
|
-
data_source = new_data_source
|
225
|
-
data_source.create_item('content here', { :foo => 'bar' }, '/')
|
226
|
-
|
227
|
-
# Check file existance
|
228
|
-
assert File.directory?('content')
|
229
|
-
assert File.file?('content/content.html')
|
230
|
-
assert File.file?('content/content.yaml')
|
231
|
-
|
232
|
-
# Check file content
|
233
|
-
assert_equal 'content here', File.read('content/content.html')
|
234
|
-
assert_match 'foo: bar', File.read('content/content.yaml')
|
235
|
-
end
|
236
|
-
|
237
|
-
def test_create_item_not_at_root
|
238
|
-
# Create item
|
239
|
-
data_source = new_data_source
|
240
|
-
data_source.create_item('content here', { :foo => 'bar' }, '/moo/')
|
241
|
-
|
242
|
-
# Check file existance
|
243
|
-
assert File.directory?('content/moo')
|
244
|
-
assert File.file?('content/moo/moo.html')
|
245
|
-
assert File.file?('content/moo/moo.yaml')
|
246
|
-
|
247
|
-
# Check file content
|
248
|
-
assert_equal 'content here', File.read('content/moo/moo.html')
|
249
|
-
assert_match 'foo: bar', File.read('content/moo/moo.yaml')
|
250
|
-
end
|
251
|
-
|
252
|
-
def test_create_layout
|
253
|
-
# Create layout
|
254
|
-
data_source = new_data_source
|
255
|
-
data_source.create_layout('content here', { :foo => 'bar' }, '/moo/')
|
256
|
-
|
257
|
-
# Check file existance
|
258
|
-
assert File.directory?('layouts/moo')
|
259
|
-
assert File.file?('layouts/moo/moo.html')
|
260
|
-
assert File.file?('layouts/moo/moo.yaml')
|
261
|
-
|
262
|
-
# Check file content
|
263
|
-
assert_equal 'content here', File.read('layouts/moo/moo.html')
|
264
|
-
assert_match 'foo: bar', File.read('layouts/moo/moo.yaml')
|
265
|
-
end
|
266
|
-
|
267
|
-
def test_load_binary_objects
|
268
|
-
# Create data source
|
269
|
-
data_source = new_data_source
|
270
|
-
|
271
|
-
# Create sample files
|
272
|
-
FileUtils.mkdir_p('foo')
|
273
|
-
File.open('foo/stuff.dat', 'w') { |io| io.write("random binary data") }
|
274
|
-
|
275
|
-
# Load
|
276
|
-
items = data_source.send(:load_objects, 'foo', 'item', Nanoc3::Item)
|
277
|
-
|
278
|
-
# Check
|
279
|
-
assert_equal 1, items.size
|
280
|
-
assert items[0].binary?
|
281
|
-
assert_equal 'foo/stuff.dat', items[0].raw_filename
|
282
|
-
assert_nil items[0].raw_content
|
283
|
-
end
|
284
|
-
|
285
|
-
def test_filename_for_with_single
|
286
|
-
data_source = new_data_source
|
287
|
-
|
288
|
-
FileUtils.mkdir_p('foo/bar')
|
289
|
-
File.open('foo/bar.ext', 'w') { |io| io.write('o hai') }
|
290
|
-
assert_equal 'foo/bar.ext', data_source.send(:filename_for, 'foo/bar', 'ext')
|
291
|
-
end
|
292
|
-
|
293
|
-
def test_filename_for_with_double
|
294
|
-
data_source = new_data_source
|
295
|
-
|
296
|
-
FileUtils.mkdir_p('foo/bar')
|
297
|
-
File.open('foo/bar/bar.ext', 'w') { |io| io.write('o hai') }
|
298
|
-
assert_equal 'foo/bar/bar.ext', data_source.send(:filename_for, 'foo/bar', 'ext')
|
299
|
-
end
|
300
|
-
|
301
|
-
def test_filename_for_with_index
|
302
|
-
data_source = new_data_source
|
303
|
-
|
304
|
-
FileUtils.mkdir_p('foo/bar')
|
305
|
-
File.open('foo/bar/index.ext', 'w') { |io| io.write('o hai') }
|
306
|
-
assert_equal 'foo/bar/index.ext', data_source.send(:filename_for, 'foo/bar', 'ext')
|
307
|
-
end
|
308
|
-
|
309
|
-
def test_filename_for_with_nil
|
310
|
-
data_source = new_data_source
|
311
|
-
|
312
|
-
assert_equal nil, data_source.send(:filename_for, 'foo/bar', nil)
|
313
|
-
end
|
314
|
-
|
315
|
-
def test_filename_for_with_single_and_empty_ext
|
316
|
-
data_source = new_data_source
|
317
|
-
|
318
|
-
FileUtils.mkdir_p('foo')
|
319
|
-
File.open('foo/bar', 'w') { |io| io.write('o hai') }
|
320
|
-
assert_equal 'foo/bar', data_source.send(:filename_for, 'foo/bar', '')
|
321
|
-
end
|
322
|
-
|
323
|
-
def test_filename_for_with_double_and_empty_ext
|
324
|
-
data_source = new_data_source
|
325
|
-
|
326
|
-
FileUtils.mkdir_p('foo/bar')
|
327
|
-
File.open('foo/bar/bar', 'w') { |io| io.write('o hai') }
|
328
|
-
assert_equal 'foo/bar/bar', data_source.send(:filename_for, 'foo/bar', '')
|
329
|
-
end
|
330
|
-
|
331
|
-
def test_filename_for_with_index_and_empty_ext
|
332
|
-
data_source = new_data_source
|
333
|
-
|
334
|
-
FileUtils.mkdir_p('foo/bar')
|
335
|
-
File.open('foo/bar/index', 'w') { |io| io.write('o hai') }
|
336
|
-
assert_equal 'foo/bar/index', data_source.send(:filename_for, 'foo/bar', '')
|
337
|
-
end
|
338
|
-
|
339
|
-
def test_compile_huge_site
|
340
|
-
if_implemented do
|
341
|
-
# Create data source
|
342
|
-
data_source = new_data_source
|
343
|
-
|
344
|
-
# Create a lot of items
|
345
|
-
count = Process.getrlimit(Process::RLIMIT_NOFILE)[0] + 5
|
346
|
-
count.times do |i|
|
347
|
-
FileUtils.mkdir_p("content/#{i}")
|
348
|
-
File.open("content/#{i}/#{i}.html", 'w') { |io| io << "This is item #{i}." }
|
349
|
-
File.open("content/#{i}/#{i}.yaml", 'w') { |io| io << "title: Item #{i}" }
|
350
|
-
end
|
351
|
-
|
352
|
-
# Read all items
|
353
|
-
data_source.items
|
354
|
-
end
|
355
|
-
end
|
356
|
-
|
357
|
-
end
|
@@ -1,30 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
class Nanoc3::ExtraCoreExtEnumerableTest < MiniTest::Unit::TestCase
|
4
|
-
|
5
|
-
include Nanoc3::TestHelpers
|
6
|
-
|
7
|
-
class MyCollection
|
8
|
-
|
9
|
-
include Enumerable
|
10
|
-
|
11
|
-
def initialize(array)
|
12
|
-
@array = array
|
13
|
-
end
|
14
|
-
|
15
|
-
def each(&block)
|
16
|
-
@array.each { |i| block.call(i) }
|
17
|
-
end
|
18
|
-
|
19
|
-
end
|
20
|
-
|
21
|
-
def test_group_by
|
22
|
-
input = MyCollection.new([ 'foo', 'bar', 'baz' ])
|
23
|
-
|
24
|
-
output_expected = { ?f => [ 'foo' ], ?b => [ 'bar', 'baz' ] }
|
25
|
-
output_actual = input.group_by { |i| i[0] }
|
26
|
-
|
27
|
-
assert_equal output_expected, output_actual
|
28
|
-
end
|
29
|
-
|
30
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
class Nanoc3::ExtraCoreExtTimeTest < MiniTest::Unit::TestCase
|
4
|
-
|
5
|
-
include Nanoc3::TestHelpers
|
6
|
-
|
7
|
-
def test_to_iso8601_date
|
8
|
-
assert_equal('2008-05-19', Time.utc(2008, 5, 19, 14, 20, 0, 0).to_iso8601_date)
|
9
|
-
end
|
10
|
-
|
11
|
-
def test_to_iso8601_time
|
12
|
-
assert_equal('2008-05-19T14:20:00Z', Time.utc(2008, 5, 19, 14, 20, 0, 0).to_iso8601_time)
|
13
|
-
end
|
14
|
-
|
15
|
-
end
|
@@ -1,232 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
class Nanoc3::Extra::Deployers::RsyncTest < MiniTest::Unit::TestCase
|
4
|
-
|
5
|
-
include Nanoc3::TestHelpers
|
6
|
-
|
7
|
-
def test_new_without_site
|
8
|
-
# Try creating site
|
9
|
-
error = assert_raises(RuntimeError) do
|
10
|
-
Nanoc3::Extra::Deployers::Rsync.new
|
11
|
-
end
|
12
|
-
|
13
|
-
# Check error message
|
14
|
-
assert_equal 'No site configuration found', error.message
|
15
|
-
end
|
16
|
-
|
17
|
-
def test_run_without_general_deploy_config
|
18
|
-
# Create config
|
19
|
-
File.open('config.yaml', 'w') do |io|
|
20
|
-
io.write "---\n"
|
21
|
-
io.write "foo: bar\n"
|
22
|
-
end
|
23
|
-
|
24
|
-
# Create site
|
25
|
-
rsync = Nanoc3::Extra::Deployers::Rsync.new
|
26
|
-
|
27
|
-
# Try running
|
28
|
-
error = assert_raises(RuntimeError) do
|
29
|
-
rsync.run
|
30
|
-
end
|
31
|
-
|
32
|
-
# Check error message
|
33
|
-
assert_equal 'No deploy configuration found', error.message
|
34
|
-
end
|
35
|
-
|
36
|
-
def test_run_without_special_deploy_config
|
37
|
-
# Create config
|
38
|
-
File.open('config.yaml', 'w') do |io|
|
39
|
-
io.write "---\n"
|
40
|
-
io.write "deploy:\n"
|
41
|
-
io.write " blahblah:\n"
|
42
|
-
io.write " stuff: more stuff\n"
|
43
|
-
end
|
44
|
-
|
45
|
-
# Create site
|
46
|
-
rsync = Nanoc3::Extra::Deployers::Rsync.new
|
47
|
-
|
48
|
-
# Try running
|
49
|
-
error = assert_raises(RuntimeError) do
|
50
|
-
rsync.run
|
51
|
-
end
|
52
|
-
|
53
|
-
# Check error message
|
54
|
-
assert_equal 'No deploy configuration found for default', error.message
|
55
|
-
end
|
56
|
-
|
57
|
-
def test_run_without_special_deploy_config_with_custom_deploy_config
|
58
|
-
# Create config
|
59
|
-
File.open('config.yaml', 'w') do |io|
|
60
|
-
io.write "---\n"
|
61
|
-
io.write "deploy:\n"
|
62
|
-
io.write " blahblah:\n"
|
63
|
-
io.write " stuff: more stuff\n"
|
64
|
-
end
|
65
|
-
|
66
|
-
# Create site
|
67
|
-
rsync = Nanoc3::Extra::Deployers::Rsync.new
|
68
|
-
|
69
|
-
# Try running
|
70
|
-
error = assert_raises(RuntimeError) do
|
71
|
-
rsync.run(:config_name => 'potrzebie')
|
72
|
-
end
|
73
|
-
|
74
|
-
# Check error message
|
75
|
-
assert_equal 'No deploy configuration found for potrzebie', error.message
|
76
|
-
end
|
77
|
-
|
78
|
-
def test_run_without_dst
|
79
|
-
# Create config
|
80
|
-
File.open('config.yaml', 'w') do |io|
|
81
|
-
io.write "---\n"
|
82
|
-
io.write "deploy:\n"
|
83
|
-
io.write " default:\n"
|
84
|
-
io.write " foo: bar\n"
|
85
|
-
end
|
86
|
-
|
87
|
-
# Create site
|
88
|
-
rsync = Nanoc3::Extra::Deployers::Rsync.new
|
89
|
-
|
90
|
-
# Try running
|
91
|
-
error = assert_raises(RuntimeError) do
|
92
|
-
rsync.run
|
93
|
-
end
|
94
|
-
|
95
|
-
# Check error message
|
96
|
-
assert_equal 'No dst found in deployment configuration', error.message
|
97
|
-
end
|
98
|
-
|
99
|
-
def test_run_with_erroneous_dst
|
100
|
-
# Create config
|
101
|
-
File.open('config.yaml', 'w') do |io|
|
102
|
-
io.write "---\n"
|
103
|
-
io.write "deploy:\n"
|
104
|
-
io.write " default:\n"
|
105
|
-
io.write " dst: asdf/\n"
|
106
|
-
end
|
107
|
-
|
108
|
-
# Create site
|
109
|
-
rsync = Nanoc3::Extra::Deployers::Rsync.new
|
110
|
-
|
111
|
-
# Try running
|
112
|
-
error = assert_raises(RuntimeError) do
|
113
|
-
rsync.run
|
114
|
-
end
|
115
|
-
|
116
|
-
# Check error message
|
117
|
-
assert_equal 'dst requires no trailing slash', error.message
|
118
|
-
end
|
119
|
-
|
120
|
-
def test_run_with_custom_deploy_config_string
|
121
|
-
# Create config
|
122
|
-
File.open('config.yaml', 'w') do |io|
|
123
|
-
io.write "---\n"
|
124
|
-
io.write "deploy:\n"
|
125
|
-
io.write " foobar:\n"
|
126
|
-
io.write " dst: asdf\n"
|
127
|
-
end
|
128
|
-
|
129
|
-
# Create site
|
130
|
-
rsync = Nanoc3::Extra::Deployers::Rsync.new
|
131
|
-
|
132
|
-
# Mock run_shell_cmd
|
133
|
-
def rsync.run_shell_cmd(args)
|
134
|
-
@shell_cms_args = args
|
135
|
-
end
|
136
|
-
|
137
|
-
# Run
|
138
|
-
rsync.run(:config_name => 'foobar')
|
139
|
-
|
140
|
-
# Check args
|
141
|
-
default_options = Nanoc3::Extra::Deployers::Rsync::DEFAULT_OPTIONS
|
142
|
-
assert_equal(
|
143
|
-
[ 'rsync', default_options, File.expand_path('output') + '/', 'asdf' ].flatten,
|
144
|
-
rsync.instance_eval { @shell_cms_args }
|
145
|
-
)
|
146
|
-
end
|
147
|
-
|
148
|
-
def test_run_with_custom_deploy_config_symbol
|
149
|
-
# Create config
|
150
|
-
File.open('config.yaml', 'w') do |io|
|
151
|
-
io.write "---\n"
|
152
|
-
io.write "deploy:\n"
|
153
|
-
io.write " foobar:\n"
|
154
|
-
io.write " dst: asdf\n"
|
155
|
-
end
|
156
|
-
|
157
|
-
# Create site
|
158
|
-
rsync = Nanoc3::Extra::Deployers::Rsync.new
|
159
|
-
|
160
|
-
# Mock run_shell_cmd
|
161
|
-
def rsync.run_shell_cmd(args)
|
162
|
-
@shell_cms_args = args
|
163
|
-
end
|
164
|
-
|
165
|
-
# Run
|
166
|
-
rsync.run(:config_name => :foobar)
|
167
|
-
|
168
|
-
# Check args
|
169
|
-
default_options = Nanoc3::Extra::Deployers::Rsync::DEFAULT_OPTIONS
|
170
|
-
assert_equal(
|
171
|
-
[ 'rsync', default_options, File.expand_path('output') + '/', 'asdf' ].flatten,
|
172
|
-
rsync.instance_eval { @shell_cms_args }
|
173
|
-
)
|
174
|
-
end
|
175
|
-
|
176
|
-
def test_run_everything_okay
|
177
|
-
# Create config
|
178
|
-
File.open('config.yaml', 'w') do |io|
|
179
|
-
io.write "---\n"
|
180
|
-
io.write "deploy:\n"
|
181
|
-
io.write " default:\n"
|
182
|
-
io.write " dst: asdf\n"
|
183
|
-
end
|
184
|
-
|
185
|
-
# Create site
|
186
|
-
rsync = Nanoc3::Extra::Deployers::Rsync.new
|
187
|
-
|
188
|
-
# Mock run_shell_cmd
|
189
|
-
def rsync.run_shell_cmd(args)
|
190
|
-
@shell_cms_args = args
|
191
|
-
end
|
192
|
-
|
193
|
-
# Run
|
194
|
-
rsync.run
|
195
|
-
|
196
|
-
# Check args
|
197
|
-
default_options = Nanoc3::Extra::Deployers::Rsync::DEFAULT_OPTIONS
|
198
|
-
assert_equal(
|
199
|
-
[ 'rsync', default_options, File.expand_path('output') + '/', 'asdf' ].flatten,
|
200
|
-
rsync.instance_eval { @shell_cms_args }
|
201
|
-
)
|
202
|
-
end
|
203
|
-
|
204
|
-
def test_run_everything_okay_dry
|
205
|
-
# Create config
|
206
|
-
File.open('config.yaml', 'w') do |io|
|
207
|
-
io.write "---\n"
|
208
|
-
io.write "deploy:\n"
|
209
|
-
io.write " default:\n"
|
210
|
-
io.write " dst: asdf\n"
|
211
|
-
end
|
212
|
-
|
213
|
-
# Create site
|
214
|
-
rsync = Nanoc3::Extra::Deployers::Rsync.new
|
215
|
-
|
216
|
-
# Mock run_shell_cmd
|
217
|
-
def rsync.run_shell_cmd(args)
|
218
|
-
@shell_cms_args = args
|
219
|
-
end
|
220
|
-
|
221
|
-
# Run
|
222
|
-
rsync.run(:dry_run => true)
|
223
|
-
|
224
|
-
# Check args
|
225
|
-
default_options = Nanoc3::Extra::Deployers::Rsync::DEFAULT_OPTIONS
|
226
|
-
assert_equal(
|
227
|
-
[ 'echo', 'rsync', default_options, File.expand_path('output') + '/', 'asdf' ].flatten,
|
228
|
-
rsync.instance_eval { @shell_cms_args }
|
229
|
-
)
|
230
|
-
end
|
231
|
-
|
232
|
-
end
|