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,18 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
class Nanoc3::Filters::RubyPantsTest < MiniTest::Unit::TestCase
|
4
|
-
|
5
|
-
include Nanoc3::TestHelpers
|
6
|
-
|
7
|
-
def test_filter
|
8
|
-
if_have 'rubypants' do
|
9
|
-
# Get filter
|
10
|
-
filter = ::Nanoc3::Filters::RubyPants.new
|
11
|
-
|
12
|
-
# Run filter
|
13
|
-
result = filter.run("Wait---what?")
|
14
|
-
assert_equal("Wait—what?", result)
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
end
|
data/test/filters/test_sass.rb
DELETED
@@ -1,229 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
class Nanoc3::Filters::SassTest < MiniTest::Unit::TestCase
|
4
|
-
|
5
|
-
include Nanoc3::TestHelpers
|
6
|
-
|
7
|
-
def test_filter
|
8
|
-
if_have 'sass' do
|
9
|
-
# Get filter
|
10
|
-
filter = create_filter({ :foo => 'bar' })
|
11
|
-
|
12
|
-
# Run filter
|
13
|
-
result = filter.run(".foo #bar\n color: #f00")
|
14
|
-
assert_match(/.foo\s+#bar\s*\{\s*color:\s+(red|#f00);?\s*\}/, result)
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
def test_filter_with_params
|
19
|
-
if_have 'sass' do
|
20
|
-
# Create filter
|
21
|
-
filter = create_filter({ :foo => 'bar' })
|
22
|
-
|
23
|
-
# Check with compact
|
24
|
-
result = filter.run(".foo #bar\n color: #f00", :style => 'compact')
|
25
|
-
assert_match(/^\.foo #bar[\s\n]*\{[\s\n]*color:\s*(red|#f00);?[\s\n]*\}/m, result)
|
26
|
-
|
27
|
-
# Check with compressed
|
28
|
-
result = filter.run(".foo #bar\n color: #f00", :style => 'compressed')
|
29
|
-
assert_match(/^\.foo #bar[\s\n]*\{[\s\n]*color:\s*(red|#f00);?[\s\n]*\}/m, result)
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
def test_filter_error
|
34
|
-
if_have 'sass' do
|
35
|
-
# Create filter
|
36
|
-
filter = create_filter
|
37
|
-
|
38
|
-
# Run filter
|
39
|
-
raised = false
|
40
|
-
begin
|
41
|
-
filter.run('$*#&!@($')
|
42
|
-
rescue Sass::SyntaxError => e
|
43
|
-
assert_match ':1', e.backtrace[0]
|
44
|
-
raised = true
|
45
|
-
end
|
46
|
-
assert raised
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
def test_filter_can_import_external_files
|
51
|
-
if_have 'sass' do
|
52
|
-
# Create filter
|
53
|
-
filter = create_filter
|
54
|
-
|
55
|
-
# Create sample file
|
56
|
-
File.open('moo.sass', 'w') { |io| io.write "body\n color: red" }
|
57
|
-
|
58
|
-
# Run filter
|
59
|
-
filter.run('@import moo')
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
def test_filter_can_import_relative_files
|
64
|
-
if_have 'sass' do
|
65
|
-
# Create filter
|
66
|
-
filter = create_filter
|
67
|
-
|
68
|
-
# Create sample file
|
69
|
-
File.open('moo.sass', 'w') { |io| io.write %Q{@import subdir/relative} }
|
70
|
-
FileUtils.mkdir_p("subdir")
|
71
|
-
File.open('subdir/relative.sass', 'w') { |io| io.write "body\n color: red" }
|
72
|
-
|
73
|
-
# Run filter
|
74
|
-
filter.run('@import moo')
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
def test_filter_will_skip_items_without_filename
|
79
|
-
if_have 'sass' do
|
80
|
-
# Create filter
|
81
|
-
filter = create_filter
|
82
|
-
|
83
|
-
# Create sample file
|
84
|
-
File.open('moo.sass', 'w') { |io| io.write "body\n color: red" }
|
85
|
-
|
86
|
-
# Run filter
|
87
|
-
filter.run('@import moo')
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
|
-
def test_css_imports_work
|
92
|
-
if_have 'sass' do
|
93
|
-
# Create filter
|
94
|
-
filter = create_filter
|
95
|
-
|
96
|
-
# Run filter
|
97
|
-
filter.run('@import moo.css')
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
|
-
def test_recompile_includes
|
102
|
-
if_have 'sass' do
|
103
|
-
with_site do |site|
|
104
|
-
# Create two Sass files
|
105
|
-
Dir['content/*'].each { |i| FileUtils.rm(i) }
|
106
|
-
File.open('content/a.sass', 'w') do |io|
|
107
|
-
io.write('@import b.sass')
|
108
|
-
end
|
109
|
-
File.open('content/b.sass', 'w') do |io|
|
110
|
-
io.write("p\n color: red")
|
111
|
-
end
|
112
|
-
|
113
|
-
# Update rules
|
114
|
-
File.open('Rules', 'w') do |io|
|
115
|
-
io.write "compile '*' do\n"
|
116
|
-
io.write " filter :sass\n"
|
117
|
-
io.write "end\n"
|
118
|
-
io.write "\n"
|
119
|
-
io.write "route '/a/' do\n"
|
120
|
-
io.write " item.identifier.chop + '.css'\n"
|
121
|
-
io.write "end\n"
|
122
|
-
io.write "\n"
|
123
|
-
io.write "route '/b/' do\n"
|
124
|
-
io.write " nil\n"
|
125
|
-
io.write "end\n"
|
126
|
-
end
|
127
|
-
|
128
|
-
# Compile
|
129
|
-
site = Nanoc3::Site.new('.')
|
130
|
-
site.compile
|
131
|
-
|
132
|
-
# Check
|
133
|
-
assert Dir['output/*'].size == 1
|
134
|
-
assert File.file?('output/a.css')
|
135
|
-
refute File.file?('output/b.css')
|
136
|
-
assert_match /^p\s*\{\s*color:\s*red;?\s*\}/,
|
137
|
-
File.read('output/a.css')
|
138
|
-
|
139
|
-
# Update included file
|
140
|
-
File.open('content/b.sass', 'w') do |io|
|
141
|
-
io.write("p\n color: blue")
|
142
|
-
end
|
143
|
-
|
144
|
-
# Recompile
|
145
|
-
site = Nanoc3::Site.new('.')
|
146
|
-
site.compile
|
147
|
-
|
148
|
-
# Recheck
|
149
|
-
assert Dir['output/*'].size == 1
|
150
|
-
assert File.file?('output/a.css')
|
151
|
-
refute File.file?('output/b.css')
|
152
|
-
assert_match /^p\s*\{\s*color:\s*blue;?\s*\}/,
|
153
|
-
File.read('output/a.css')
|
154
|
-
end
|
155
|
-
end
|
156
|
-
end
|
157
|
-
|
158
|
-
def test_recompile_includes_with_underscore_without_extension
|
159
|
-
if_have 'sass' do
|
160
|
-
with_site do |site|
|
161
|
-
# Create two Sass files
|
162
|
-
Dir['content/*'].each { |i| FileUtils.rm(i) }
|
163
|
-
File.open('content/a.sass', 'w') do |io|
|
164
|
-
io.write('@import b')
|
165
|
-
end
|
166
|
-
File.open('content/_b.sass', 'w') do |io|
|
167
|
-
io.write("p\n color: red")
|
168
|
-
end
|
169
|
-
|
170
|
-
# Update rules
|
171
|
-
File.open('Rules', 'w') do |io|
|
172
|
-
io.write "compile '*' do\n"
|
173
|
-
io.write " filter :sass\n"
|
174
|
-
io.write "end\n"
|
175
|
-
io.write "\n"
|
176
|
-
io.write "route '/a/' do\n"
|
177
|
-
io.write " item.identifier.chop + '.css'\n"
|
178
|
-
io.write "end\n"
|
179
|
-
io.write "\n"
|
180
|
-
io.write "route '/_b/' do\n"
|
181
|
-
io.write " nil\n"
|
182
|
-
io.write "end\n"
|
183
|
-
end
|
184
|
-
|
185
|
-
# Compile
|
186
|
-
site = Nanoc3::Site.new('.')
|
187
|
-
site.compile
|
188
|
-
|
189
|
-
# Check
|
190
|
-
assert Dir['output/*'].size == 1
|
191
|
-
assert File.file?('output/a.css')
|
192
|
-
refute File.file?('output/b.css')
|
193
|
-
assert_match /^p\s*\{\s*color:\s*red;?\s*\}/,
|
194
|
-
File.read('output/a.css')
|
195
|
-
|
196
|
-
# Update included file
|
197
|
-
File.open('content/_b.sass', 'w') do |io|
|
198
|
-
io.write("p\n color: blue")
|
199
|
-
end
|
200
|
-
|
201
|
-
# Recompile
|
202
|
-
site = Nanoc3::Site.new('.')
|
203
|
-
site.compile
|
204
|
-
|
205
|
-
# Recheck
|
206
|
-
assert Dir['output/*'].size == 1
|
207
|
-
assert File.file?('output/a.css')
|
208
|
-
refute File.file?('output/b.css')
|
209
|
-
assert_match /^p\s*\{\s*color:\s*blue;?\s*\}/,
|
210
|
-
File.read('output/a.css')
|
211
|
-
end
|
212
|
-
end
|
213
|
-
end
|
214
|
-
|
215
|
-
private
|
216
|
-
|
217
|
-
def create_filter(params={})
|
218
|
-
FileUtils.mkdir_p('content')
|
219
|
-
File.open('content/xyzzy.sass', 'w') { |io| io.write('p\n color: green')}
|
220
|
-
|
221
|
-
items = [ Nanoc3::Item.new(
|
222
|
-
'blah',
|
223
|
-
{ :content_filename => 'content/xyzzy.sass' },
|
224
|
-
'/blah/') ]
|
225
|
-
params = { :item => items[0], :items => items }.merge(params)
|
226
|
-
::Nanoc3::Filters::Sass.new(params)
|
227
|
-
end
|
228
|
-
|
229
|
-
end
|
data/test/filters/test_slim.rb
DELETED
@@ -1,35 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
class Nanoc3::Filters::SlimTest < MiniTest::Unit::TestCase
|
4
|
-
|
5
|
-
include Nanoc3::TestHelpers
|
6
|
-
|
7
|
-
def test_filter
|
8
|
-
if_have 'slim' do
|
9
|
-
# Create filter
|
10
|
-
filter = ::Nanoc3::Filters::Slim.new({ :rabbit => 'The rabbit is on the branch.' })
|
11
|
-
|
12
|
-
# Run filter (no assigns)
|
13
|
-
result = filter.run('html')
|
14
|
-
assert_match(/<html>.*<\/html>/, result)
|
15
|
-
|
16
|
-
# Run filter (assigns without @)
|
17
|
-
result = filter.run('p = rabbit')
|
18
|
-
assert_equal("<p>The rabbit is on the branch.</p>", result)
|
19
|
-
|
20
|
-
# Run filter (assigns with @)
|
21
|
-
result = filter.run('p = @rabbit')
|
22
|
-
assert_equal("<p>The rabbit is on the branch.</p>", result)
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
def test_filter_with_yield
|
27
|
-
if_have 'slim' do
|
28
|
-
filter = ::Nanoc3::Filters::Slim.new({ :content => 'The rabbit is on the branch.' })
|
29
|
-
|
30
|
-
result = filter.run('p = yield')
|
31
|
-
assert_equal("<p>The rabbit is on the branch.</p>", result)
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
class Nanoc3::Filters::TypogrubyTest < MiniTest::Unit::TestCase
|
4
|
-
|
5
|
-
include Nanoc3::TestHelpers
|
6
|
-
|
7
|
-
def test_filter
|
8
|
-
if_have 'typogruby' do
|
9
|
-
# Get filter
|
10
|
-
filter = ::Nanoc3::Filters::Typogruby.new
|
11
|
-
|
12
|
-
# Run filter
|
13
|
-
a = '"Typogruby makes HTML look smarter & better, don\'t you think?"'
|
14
|
-
b = '<span class="dquo">“</span>Typogruby makes <span class="caps">HTML</span> look smarter <span class="amp">&</span> better, don’t you think?”'
|
15
|
-
result = filter.run(a)
|
16
|
-
assert_equal(b, result)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
end
|
21
|
-
|
@@ -1,30 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
class Nanoc3::Filters::UglifyJSTest < MiniTest::Unit::TestCase
|
4
|
-
|
5
|
-
include Nanoc3::TestHelpers
|
6
|
-
|
7
|
-
def test_filter
|
8
|
-
if_have 'uglifier' do
|
9
|
-
# Create filter
|
10
|
-
filter = ::Nanoc3::Filters::UglifyJS.new
|
11
|
-
|
12
|
-
# Run filter
|
13
|
-
result = filter.run("foo = 1; (function(bar) { if (true) alert(bar); })(foo)")
|
14
|
-
assert_equal("foo=1,function(a){alert(a)}(foo)", result)
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
def test_filter_with_options
|
19
|
-
|
20
|
-
if_have 'uglifier' do
|
21
|
-
# Create filter
|
22
|
-
filter = ::Nanoc3::Filters::UglifyJS.new
|
23
|
-
|
24
|
-
# Run filter
|
25
|
-
result = filter.run("foo = 1; (function(bar) { if (true) alert(bar); })(foo)", :toplevel => true)
|
26
|
-
assert_equal("foo=1,function(a){alert(a)}(foo)", result)
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
end
|
data/test/gem_loader.rb
DELETED
data/test/helper.rb
DELETED
@@ -1,179 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
# Set up gem loading (necessary for cri dependency)
|
4
|
-
require File.dirname(__FILE__) + '/gem_loader.rb'
|
5
|
-
|
6
|
-
# Load unit testing stuff
|
7
|
-
begin
|
8
|
-
require 'minitest/unit'
|
9
|
-
require 'minitest/spec'
|
10
|
-
require 'minitest/mock'
|
11
|
-
require 'mocha'
|
12
|
-
rescue => e
|
13
|
-
$stderr.puts "To run the nanoc unit tests, you need minitest and mocha."
|
14
|
-
raise e
|
15
|
-
end
|
16
|
-
|
17
|
-
# Load nanoc
|
18
|
-
$LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__) + '/../lib'))
|
19
|
-
require 'nanoc3'
|
20
|
-
require 'nanoc3/cli'
|
21
|
-
require 'nanoc3/tasks'
|
22
|
-
|
23
|
-
# Load miscellaneous requirements
|
24
|
-
require 'stringio'
|
25
|
-
|
26
|
-
module Nanoc3::TestHelpers
|
27
|
-
|
28
|
-
def if_have(*libs)
|
29
|
-
libs.each do |lib|
|
30
|
-
begin
|
31
|
-
require lib
|
32
|
-
rescue LoadError
|
33
|
-
skip "requiring #{lib} failed"
|
34
|
-
return
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
yield
|
39
|
-
end
|
40
|
-
|
41
|
-
def if_implemented
|
42
|
-
begin
|
43
|
-
yield
|
44
|
-
rescue NotImplementedError, NameError
|
45
|
-
skip $!
|
46
|
-
return
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
def with_site(params={})
|
51
|
-
# Build site name
|
52
|
-
site_name = params[:name]
|
53
|
-
if site_name.nil?
|
54
|
-
@site_num ||= 0
|
55
|
-
site_name = "site-#{@site_num}"
|
56
|
-
@site_num += 1
|
57
|
-
end
|
58
|
-
|
59
|
-
# Build rules
|
60
|
-
rules_content = <<EOS
|
61
|
-
compile '*' do
|
62
|
-
{{compilation_rule_content}}
|
63
|
-
end
|
64
|
-
|
65
|
-
route '*' do
|
66
|
-
if item.binary?
|
67
|
-
item.identifier.chop + '.' + item[:extension]
|
68
|
-
else
|
69
|
-
item.identifier + 'index.html'
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
layout '*', :erb
|
74
|
-
EOS
|
75
|
-
rules_content.gsub!('{{compilation_rule_content}}', params[:compilation_rule_content] || '')
|
76
|
-
|
77
|
-
# Create site
|
78
|
-
unless File.directory?(site_name)
|
79
|
-
FileUtils.mkdir_p(site_name)
|
80
|
-
FileUtils.cd(site_name) do
|
81
|
-
FileUtils.mkdir_p('content')
|
82
|
-
FileUtils.mkdir_p('layouts')
|
83
|
-
FileUtils.mkdir_p('lib')
|
84
|
-
FileUtils.mkdir_p('output')
|
85
|
-
|
86
|
-
if params[:has_layout]
|
87
|
-
File.open('layouts/default.html', 'w') do |io|
|
88
|
-
io.write('... <%= @yield %> ...')
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
|
-
File.open('config.yaml', 'w') { |io| io.write('stuff: 12345') }
|
93
|
-
File.open('Rules', 'w') { |io| io.write(rules_content) }
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|
97
|
-
# Yield site
|
98
|
-
FileUtils.cd(site_name) do
|
99
|
-
yield Nanoc3::Site.new('.')
|
100
|
-
end
|
101
|
-
end
|
102
|
-
|
103
|
-
def setup
|
104
|
-
# Check skipped
|
105
|
-
if ENV['skip']
|
106
|
-
if ENV['skip'].split(',').include?(self.class.to_s)
|
107
|
-
skip 'manually skipped'
|
108
|
-
end
|
109
|
-
end
|
110
|
-
|
111
|
-
# Clean up
|
112
|
-
GC.start
|
113
|
-
|
114
|
-
# Go quiet
|
115
|
-
unless ENV['QUIET'] == 'false'
|
116
|
-
$stdout = StringIO.new
|
117
|
-
$stderr = StringIO.new
|
118
|
-
end
|
119
|
-
|
120
|
-
# Enter tmp
|
121
|
-
FileUtils.mkdir_p('tmp')
|
122
|
-
FileUtils.cd('tmp')
|
123
|
-
end
|
124
|
-
|
125
|
-
def teardown
|
126
|
-
# Exit tmp
|
127
|
-
FileUtils.cd('..')
|
128
|
-
FileUtils.rm_rf('tmp')
|
129
|
-
|
130
|
-
# Go unquiet
|
131
|
-
unless ENV['QUIET'] == 'false'
|
132
|
-
$stdout = STDOUT
|
133
|
-
$stderr = STDERR
|
134
|
-
end
|
135
|
-
end
|
136
|
-
|
137
|
-
# Adapted from http://github.com/lsegal/yard-examples/tree/master/doctest
|
138
|
-
def assert_examples_correct(object)
|
139
|
-
P(object).tags(:example).each do |example|
|
140
|
-
begin
|
141
|
-
# Get input and output
|
142
|
-
parts = example.text.split(/# ?=>/).map { |s| s.strip }
|
143
|
-
code = parts[0].strip
|
144
|
-
expected_out_raw = parts[1].strip
|
145
|
-
|
146
|
-
# Evaluate
|
147
|
-
expected_out = eval(parts[1])
|
148
|
-
actual_out = instance_eval("#{code}")
|
149
|
-
rescue Exception => e
|
150
|
-
e.message << " (code: #{code}; expected output: #{expected_out_raw})"
|
151
|
-
raise e
|
152
|
-
end
|
153
|
-
|
154
|
-
assert_equal expected_out, actual_out,
|
155
|
-
"Incorrect example: #{code}"
|
156
|
-
end
|
157
|
-
end
|
158
|
-
|
159
|
-
def assert_contains_exactly(expected, actual)
|
160
|
-
assert_equal expected.size, actual.size,
|
161
|
-
'Expected %s to be of same size as %s' % [actual.inspect, expected.inspect]
|
162
|
-
remaining = actual.dup.to_a
|
163
|
-
expected.each do |e|
|
164
|
-
index = remaining.index(e)
|
165
|
-
remaining.delete_at(index) if index
|
166
|
-
end
|
167
|
-
assert remaining.empty?,
|
168
|
-
'Expected %s to contain all the elements of %s' % [actual.inspect, expected.inspect]
|
169
|
-
end
|
170
|
-
|
171
|
-
end
|
172
|
-
|
173
|
-
# A more precise inspect method for Time improves assert failure messages.
|
174
|
-
#
|
175
|
-
class Time
|
176
|
-
def inspect
|
177
|
-
strftime("%a %b %d %H:%M:%S.#{"%06d" % usec} %Z %Y")
|
178
|
-
end
|
179
|
-
end
|