nanoc 3.2.4 → 3.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gemtest +0 -0
- data/ChangeLog +3 -0
- data/Gemfile +32 -0
- data/LICENSE +19 -0
- data/NEWS.md +470 -0
- data/README.md +114 -0
- data/Rakefile +14 -0
- data/bin/nanoc +7 -27
- data/bin/nanoc3 +3 -0
- data/doc/yardoc_templates/default/layout/html/footer.erb +10 -0
- data/lib/nanoc.rb +41 -0
- data/lib/nanoc/base.rb +49 -0
- data/lib/nanoc/base/compilation/checksum_store.rb +57 -0
- data/lib/nanoc/base/compilation/compiled_content_cache.rb +62 -0
- data/lib/nanoc/base/compilation/compiler.rb +458 -0
- data/lib/nanoc/base/compilation/compiler_dsl.rb +214 -0
- data/lib/nanoc/base/compilation/dependency_tracker.rb +200 -0
- data/lib/nanoc/base/compilation/filter.rb +165 -0
- data/lib/nanoc/base/compilation/item_rep_proxy.rb +103 -0
- data/lib/nanoc/base/compilation/item_rep_recorder_proxy.rb +102 -0
- data/lib/nanoc/base/compilation/outdatedness_checker.rb +223 -0
- data/lib/nanoc/base/compilation/outdatedness_reasons.rb +46 -0
- data/lib/nanoc/base/compilation/rule.rb +73 -0
- data/lib/nanoc/base/compilation/rule_context.rb +84 -0
- data/lib/nanoc/base/compilation/rule_memory_calculator.rb +40 -0
- data/lib/nanoc/base/compilation/rule_memory_store.rb +53 -0
- data/lib/nanoc/base/compilation/rules_collection.rb +243 -0
- data/lib/nanoc/base/context.rb +47 -0
- data/lib/nanoc/base/core_ext.rb +6 -0
- data/lib/nanoc/base/core_ext/array.rb +62 -0
- data/lib/nanoc/base/core_ext/hash.rb +63 -0
- data/lib/nanoc/base/core_ext/pathname.rb +26 -0
- data/lib/nanoc/base/core_ext/string.rb +46 -0
- data/lib/nanoc/base/directed_graph.rb +275 -0
- data/lib/nanoc/base/errors.rb +211 -0
- data/lib/nanoc/base/memoization.rb +67 -0
- data/lib/nanoc/base/notification_center.rb +84 -0
- data/lib/nanoc/base/ordered_hash.rb +200 -0
- data/lib/nanoc/base/plugin_registry.rb +181 -0
- data/lib/nanoc/base/result_data/item_rep.rb +492 -0
- data/lib/nanoc/base/source_data/code_snippet.rb +58 -0
- data/lib/nanoc/base/source_data/configuration.rb +24 -0
- data/lib/nanoc/base/source_data/data_source.rb +234 -0
- data/lib/nanoc/base/source_data/item.rb +301 -0
- data/lib/nanoc/base/source_data/layout.rb +130 -0
- data/lib/nanoc/base/source_data/site.rb +361 -0
- data/lib/nanoc/base/store.rb +135 -0
- data/lib/nanoc/cli.rb +137 -0
- data/lib/nanoc/cli/command_runner.rb +104 -0
- data/lib/nanoc/cli/commands/autocompile.rb +58 -0
- data/lib/nanoc/cli/commands/compile.rb +297 -0
- data/lib/nanoc/cli/commands/create_item.rb +60 -0
- data/lib/nanoc/cli/commands/create_layout.rb +73 -0
- data/lib/nanoc/cli/commands/create_site.rb +411 -0
- data/lib/nanoc/cli/commands/debug.rb +117 -0
- data/lib/nanoc/cli/commands/deploy.rb +79 -0
- data/lib/nanoc/cli/commands/info.rb +98 -0
- data/lib/nanoc/cli/commands/nanoc.rb +38 -0
- data/lib/nanoc/cli/commands/prune.rb +50 -0
- data/lib/nanoc/cli/commands/update.rb +70 -0
- data/lib/nanoc/cli/commands/view.rb +82 -0
- data/lib/nanoc/cli/commands/watch.rb +124 -0
- data/lib/nanoc/cli/error_handler.rb +199 -0
- data/lib/nanoc/cli/logger.rb +92 -0
- data/lib/nanoc/data_sources.rb +29 -0
- data/lib/nanoc/data_sources/deprecated/delicious.rb +42 -0
- data/lib/nanoc/data_sources/deprecated/last_fm.rb +87 -0
- data/lib/nanoc/data_sources/deprecated/twitter.rb +38 -0
- data/lib/nanoc/data_sources/filesystem.rb +299 -0
- data/lib/nanoc/data_sources/filesystem_unified.rb +121 -0
- data/lib/nanoc/data_sources/filesystem_verbose.rb +91 -0
- data/lib/nanoc/extra.rb +24 -0
- data/lib/nanoc/extra/auto_compiler.rb +103 -0
- data/lib/nanoc/extra/chick.rb +125 -0
- data/lib/nanoc/extra/core_ext.rb +6 -0
- data/lib/nanoc/extra/core_ext/enumerable.rb +33 -0
- data/lib/nanoc/extra/core_ext/pathname.rb +30 -0
- data/lib/nanoc/extra/core_ext/time.rb +19 -0
- data/lib/nanoc/extra/deployer.rb +47 -0
- data/lib/nanoc/extra/deployers.rb +15 -0
- data/lib/nanoc/extra/deployers/fog.rb +98 -0
- data/lib/nanoc/extra/deployers/rsync.rb +70 -0
- data/lib/nanoc/extra/file_proxy.rb +40 -0
- data/lib/nanoc/extra/pruner.rb +86 -0
- data/lib/nanoc/extra/validators.rb +12 -0
- data/lib/nanoc/extra/validators/links.rb +268 -0
- data/lib/nanoc/extra/validators/w3c.rb +95 -0
- data/lib/nanoc/extra/vcs.rb +66 -0
- data/lib/nanoc/extra/vcses.rb +17 -0
- data/lib/nanoc/extra/vcses/bazaar.rb +25 -0
- data/lib/nanoc/extra/vcses/dummy.rb +24 -0
- data/lib/nanoc/extra/vcses/git.rb +25 -0
- data/lib/nanoc/extra/vcses/mercurial.rb +25 -0
- data/lib/nanoc/extra/vcses/subversion.rb +25 -0
- data/lib/nanoc/filters.rb +59 -0
- data/lib/nanoc/filters/asciidoc.rb +38 -0
- data/lib/nanoc/filters/bluecloth.rb +19 -0
- data/lib/nanoc/filters/coderay.rb +21 -0
- data/lib/nanoc/filters/coffeescript.rb +20 -0
- data/lib/nanoc/filters/colorize_syntax.rb +298 -0
- data/lib/nanoc/filters/erb.rb +38 -0
- data/lib/nanoc/filters/erubis.rb +34 -0
- data/lib/nanoc/filters/haml.rb +27 -0
- data/lib/nanoc/filters/kramdown.rb +20 -0
- data/lib/nanoc/filters/less.rb +53 -0
- data/lib/nanoc/filters/markaby.rb +20 -0
- data/lib/nanoc/filters/maruku.rb +20 -0
- data/lib/nanoc/filters/mustache.rb +24 -0
- data/lib/nanoc/filters/rainpress.rb +19 -0
- data/lib/nanoc/filters/rdiscount.rb +22 -0
- data/lib/nanoc/filters/rdoc.rb +33 -0
- data/lib/nanoc/filters/redcarpet.rb +62 -0
- data/lib/nanoc/filters/redcloth.rb +47 -0
- data/lib/nanoc/filters/relativize_paths.rb +94 -0
- data/lib/nanoc/filters/rubypants.rb +20 -0
- data/lib/nanoc/filters/sass.rb +74 -0
- data/lib/nanoc/filters/slim.rb +25 -0
- data/lib/nanoc/filters/typogruby.rb +23 -0
- data/lib/nanoc/filters/uglify_js.rb +42 -0
- data/lib/nanoc/filters/xsl.rb +46 -0
- data/lib/nanoc/filters/yui_compressor.rb +23 -0
- data/lib/nanoc/helpers.rb +16 -0
- data/lib/nanoc/helpers/blogging.rb +319 -0
- data/lib/nanoc/helpers/breadcrumbs.rb +40 -0
- data/lib/nanoc/helpers/capturing.rb +138 -0
- data/lib/nanoc/helpers/filtering.rb +50 -0
- data/lib/nanoc/helpers/html_escape.rb +55 -0
- data/lib/nanoc/helpers/link_to.rb +151 -0
- data/lib/nanoc/helpers/rendering.rb +140 -0
- data/lib/nanoc/helpers/tagging.rb +71 -0
- data/lib/nanoc/helpers/text.rb +44 -0
- data/lib/nanoc/helpers/xml_sitemap.rb +76 -0
- data/lib/nanoc/tasks.rb +10 -0
- data/lib/nanoc/tasks/clean.rake +16 -0
- data/lib/nanoc/tasks/clean.rb +29 -0
- data/lib/nanoc/tasks/deploy/rsync.rake +16 -0
- data/lib/nanoc/tasks/validate.rake +92 -0
- data/nanoc.gemspec +49 -0
- data/tasks/doc.rake +16 -0
- data/tasks/test.rake +46 -0
- data/test/base/core_ext/array_spec.rb +73 -0
- data/test/base/core_ext/hash_spec.rb +98 -0
- data/test/base/core_ext/pathname_spec.rb +27 -0
- data/test/base/core_ext/string_spec.rb +37 -0
- data/test/base/test_checksum_store.rb +35 -0
- data/test/base/test_code_snippet.rb +31 -0
- data/test/base/test_compiler.rb +403 -0
- data/test/base/test_compiler_dsl.rb +161 -0
- data/test/base/test_context.rb +31 -0
- data/test/base/test_data_source.rb +46 -0
- data/test/base/test_dependency_tracker.rb +262 -0
- data/test/base/test_directed_graph.rb +288 -0
- data/test/base/test_filter.rb +83 -0
- data/test/base/test_item.rb +179 -0
- data/test/base/test_item_rep.rb +579 -0
- data/test/base/test_layout.rb +59 -0
- data/test/base/test_memoization.rb +90 -0
- data/test/base/test_notification_center.rb +34 -0
- data/test/base/test_outdatedness_checker.rb +394 -0
- data/test/base/test_plugin.rb +30 -0
- data/test/base/test_rule.rb +19 -0
- data/test/base/test_rule_context.rb +65 -0
- data/test/base/test_site.rb +190 -0
- data/test/cli/commands/test_compile.rb +33 -0
- data/test/cli/commands/test_create_item.rb +14 -0
- data/test/cli/commands/test_create_layout.rb +28 -0
- data/test/cli/commands/test_create_site.rb +24 -0
- data/test/cli/commands/test_deploy.rb +74 -0
- data/test/cli/commands/test_help.rb +12 -0
- data/test/cli/commands/test_info.rb +11 -0
- data/test/cli/commands/test_prune.rb +98 -0
- data/test/cli/commands/test_update.rb +10 -0
- data/test/cli/test_cli.rb +102 -0
- data/test/cli/test_error_handler.rb +29 -0
- data/test/cli/test_logger.rb +10 -0
- data/test/data_sources/test_filesystem.rb +433 -0
- data/test/data_sources/test_filesystem_unified.rb +536 -0
- data/test/data_sources/test_filesystem_verbose.rb +357 -0
- data/test/extra/core_ext/test_enumerable.rb +30 -0
- data/test/extra/core_ext/test_pathname.rb +17 -0
- data/test/extra/core_ext/test_time.rb +15 -0
- data/test/extra/deployers/test_fog.rb +67 -0
- data/test/extra/deployers/test_rsync.rb +100 -0
- data/test/extra/test_auto_compiler.rb +417 -0
- data/test/extra/test_file_proxy.rb +19 -0
- data/test/extra/test_vcs.rb +22 -0
- data/test/extra/validators/test_links.rb +62 -0
- data/test/extra/validators/test_w3c.rb +47 -0
- data/test/filters/test_asciidoc.rb +22 -0
- data/test/filters/test_bluecloth.rb +18 -0
- data/test/filters/test_coderay.rb +44 -0
- data/test/filters/test_coffeescript.rb +18 -0
- data/test/filters/test_colorize_syntax.rb +379 -0
- data/test/filters/test_erb.rb +105 -0
- data/test/filters/test_erubis.rb +78 -0
- data/test/filters/test_haml.rb +96 -0
- data/test/filters/test_kramdown.rb +18 -0
- data/test/filters/test_less.rb +113 -0
- data/test/filters/test_markaby.rb +24 -0
- data/test/filters/test_maruku.rb +18 -0
- data/test/filters/test_mustache.rb +25 -0
- data/test/filters/test_rainpress.rb +29 -0
- data/test/filters/test_rdiscount.rb +31 -0
- data/test/filters/test_rdoc.rb +18 -0
- data/test/filters/test_redcarpet.rb +73 -0
- data/test/filters/test_redcloth.rb +33 -0
- data/test/filters/test_relativize_paths.rb +533 -0
- data/test/filters/test_rubypants.rb +18 -0
- data/test/filters/test_sass.rb +229 -0
- data/test/filters/test_slim.rb +35 -0
- data/test/filters/test_typogruby.rb +21 -0
- data/test/filters/test_uglify_js.rb +30 -0
- data/test/filters/test_xsl.rb +105 -0
- data/test/filters/test_yui_compressor.rb +44 -0
- data/test/gem_loader.rb +11 -0
- data/test/helper.rb +207 -0
- data/test/helpers/test_blogging.rb +754 -0
- data/test/helpers/test_breadcrumbs.rb +81 -0
- data/test/helpers/test_capturing.rb +41 -0
- data/test/helpers/test_filtering.rb +106 -0
- data/test/helpers/test_html_escape.rb +32 -0
- data/test/helpers/test_link_to.rb +249 -0
- data/test/helpers/test_rendering.rb +89 -0
- data/test/helpers/test_tagging.rb +87 -0
- data/test/helpers/test_text.rb +24 -0
- data/test/helpers/test_xml_sitemap.rb +103 -0
- data/test/tasks/test_clean.rb +67 -0
- metadata +327 -15
- data/bin/nanoc-select +0 -86
- data/lib/nanoc-select.rb +0 -11
@@ -0,0 +1,18 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
class Nanoc::Filters::RubyPantsTest < MiniTest::Unit::TestCase
|
4
|
+
|
5
|
+
include Nanoc::TestHelpers
|
6
|
+
|
7
|
+
def test_filter
|
8
|
+
if_have 'rubypants' do
|
9
|
+
# Get filter
|
10
|
+
filter = ::Nanoc::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
|
@@ -0,0 +1,229 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
class Nanoc::Filters::SassTest < MiniTest::Unit::TestCase
|
4
|
+
|
5
|
+
include Nanoc::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 = Nanoc::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 = Nanoc::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 = Nanoc::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 = Nanoc::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 = [ Nanoc::Item.new(
|
222
|
+
'blah',
|
223
|
+
{ :content_filename => 'content/xyzzy.sass' },
|
224
|
+
'/blah/') ]
|
225
|
+
params = { :item => items[0], :items => items }.merge(params)
|
226
|
+
::Nanoc::Filters::Sass.new(params)
|
227
|
+
end
|
228
|
+
|
229
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
class Nanoc::Filters::SlimTest < MiniTest::Unit::TestCase
|
4
|
+
|
5
|
+
include Nanoc::TestHelpers
|
6
|
+
|
7
|
+
def test_filter
|
8
|
+
if_have 'slim' do
|
9
|
+
# Create filter
|
10
|
+
filter = ::Nanoc::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 = ::Nanoc::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
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
class Nanoc::Filters::TypogrubyTest < MiniTest::Unit::TestCase
|
4
|
+
|
5
|
+
include Nanoc::TestHelpers
|
6
|
+
|
7
|
+
def test_filter
|
8
|
+
if_have 'typogruby' do
|
9
|
+
# Get filter
|
10
|
+
filter = ::Nanoc::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
|
+
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
class Nanoc::Filters::UglifyJSTest < MiniTest::Unit::TestCase
|
4
|
+
|
5
|
+
include Nanoc::TestHelpers
|
6
|
+
|
7
|
+
def test_filter
|
8
|
+
if_have 'uglifier' do
|
9
|
+
# Create filter
|
10
|
+
filter = ::Nanoc::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 = ::Nanoc::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
|
@@ -0,0 +1,105 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'tempfile'
|
4
|
+
|
5
|
+
class Nanoc::Filters::XSLTest < MiniTest::Unit::TestCase
|
6
|
+
|
7
|
+
include Nanoc::TestHelpers
|
8
|
+
|
9
|
+
SAMPLE_XSL = <<-EOS
|
10
|
+
<?xml version="1.0" encoding="utf-8"?>
|
11
|
+
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
|
12
|
+
<xsl:output method="xml" version="1.0" encoding="utf-8" indent="yes"/>
|
13
|
+
<xsl:template match="/">
|
14
|
+
<html>
|
15
|
+
<head>
|
16
|
+
<title><xsl:value-of select="report/title"/></title>
|
17
|
+
</head>
|
18
|
+
<body>
|
19
|
+
<h1><xsl:value-of select="report/title"/></h1>
|
20
|
+
</body>
|
21
|
+
</html>
|
22
|
+
</xsl:template>
|
23
|
+
</xsl:stylesheet>
|
24
|
+
EOS
|
25
|
+
|
26
|
+
SAMPLE_XML_IN = <<-EOS
|
27
|
+
<?xml version="1.0" encoding="utf-8"?>
|
28
|
+
<report>
|
29
|
+
<title>My Report</title>
|
30
|
+
</report>
|
31
|
+
EOS
|
32
|
+
|
33
|
+
SAMPLE_XML_OUT = <<-EOS
|
34
|
+
<?xml version="1.0" encoding="utf-8"?>
|
35
|
+
<html>
|
36
|
+
<head>
|
37
|
+
<title>My Report</title>
|
38
|
+
</head>
|
39
|
+
<body>
|
40
|
+
<h1>My Report</h1>
|
41
|
+
</body>
|
42
|
+
</html>
|
43
|
+
EOS
|
44
|
+
|
45
|
+
SAMPLE_XSL_WITH_PARAMS = <<-EOS
|
46
|
+
<?xml version="1.0" encoding="utf-8"?>
|
47
|
+
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
|
48
|
+
<xsl:output method="xml" version="1.0" encoding="utf-8" indent="yes"/>
|
49
|
+
<xsl:template match="/">
|
50
|
+
<html>
|
51
|
+
<head>
|
52
|
+
<title><xsl:value-of select="$foo"/></title>
|
53
|
+
</head>
|
54
|
+
<body>
|
55
|
+
<h1><xsl:value-of select="$foo"/></h1>
|
56
|
+
</body>
|
57
|
+
</html>
|
58
|
+
</xsl:template>
|
59
|
+
</xsl:stylesheet>
|
60
|
+
EOS
|
61
|
+
|
62
|
+
SAMPLE_XML_IN_WITH_PARAMS = <<-EOS
|
63
|
+
<?xml version="1.0" encoding="utf-8"?>
|
64
|
+
<report>
|
65
|
+
<title>My Report</title>
|
66
|
+
</report>
|
67
|
+
EOS
|
68
|
+
|
69
|
+
SAMPLE_XML_OUT_WITH_PARAMS = <<-EOS
|
70
|
+
<?xml version="1.0" encoding="utf-8"?>
|
71
|
+
<html>
|
72
|
+
<head>
|
73
|
+
<title>bar</title>
|
74
|
+
</head>
|
75
|
+
<body>
|
76
|
+
<h1>bar</h1>
|
77
|
+
</body>
|
78
|
+
</html>
|
79
|
+
EOS
|
80
|
+
|
81
|
+
def test_filter_as_layout
|
82
|
+
if_have 'nokogiri' do
|
83
|
+
layout = Nanoc::Layout.new(SAMPLE_XSL, {}, '/layout/')
|
84
|
+
|
85
|
+
filter = ::Nanoc::Filters::XSL.new(
|
86
|
+
:layout => layout, :content => SAMPLE_XSL)
|
87
|
+
result = filter.run(SAMPLE_XML_IN)
|
88
|
+
|
89
|
+
assert_equal SAMPLE_XML_OUT, result
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
def test_filter_with_params
|
94
|
+
if_have 'nokogiri' do
|
95
|
+
layout = Nanoc::Layout.new(SAMPLE_XSL_WITH_PARAMS, {}, '/layout/')
|
96
|
+
|
97
|
+
filter = ::Nanoc::Filters::XSL.new(
|
98
|
+
:layout => layout, :content => SAMPLE_XSL_WITH_PARAMS)
|
99
|
+
result = filter.run(SAMPLE_XML_IN_WITH_PARAMS, :foo => 'bar')
|
100
|
+
|
101
|
+
assert_equal SAMPLE_XML_OUT_WITH_PARAMS, result
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
class Nanoc::Filters::YUICompressorTest < MiniTest::Unit::TestCase
|
4
|
+
|
5
|
+
include Nanoc::TestHelpers
|
6
|
+
|
7
|
+
def test_filter_javascript
|
8
|
+
if_have 'yuicompressor' do
|
9
|
+
filter = ::Nanoc::Filters::YUICompressor.new
|
10
|
+
|
11
|
+
sample_js = <<-JAVASCRIPT
|
12
|
+
function factorial(n) {
|
13
|
+
var result = 1;
|
14
|
+
for (var i = 2; i <= n; i++) {
|
15
|
+
result *= i
|
16
|
+
}
|
17
|
+
return result;
|
18
|
+
}
|
19
|
+
JAVASCRIPT
|
20
|
+
|
21
|
+
result = filter.run(sample_js, { :type => 'js', :munge => true })
|
22
|
+
assert_match "function factorial(c){var a=1;for(var b=2;b<=c;b++){a*=b}return a};", result
|
23
|
+
|
24
|
+
result = filter.run(sample_js, { :type => 'js', :munge => false })
|
25
|
+
assert_match "function factorial(n){var result=1;for(var i=2;i<=n;i++){result*=i}return result};", result
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_filter_css
|
30
|
+
if_have 'yuicompressor' do
|
31
|
+
filter = ::Nanoc::Filters::YUICompressor.new
|
32
|
+
|
33
|
+
sample_css = <<-CSS
|
34
|
+
* {
|
35
|
+
margin: 0;
|
36
|
+
}
|
37
|
+
CSS
|
38
|
+
|
39
|
+
result = filter.run(sample_css, { :type => 'css' })
|
40
|
+
assert_match "*{margin:0}", result
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|