nanoc 3.2.4 → 3.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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,30 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
class Nanoc::PluginTest < MiniTest::Unit::TestCase
|
|
4
|
+
|
|
5
|
+
include Nanoc::TestHelpers
|
|
6
|
+
|
|
7
|
+
class SampleFilter < Nanoc::Filter
|
|
8
|
+
identifier :_plugin_test_sample_filter
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def test_named
|
|
12
|
+
# Find existant filter
|
|
13
|
+
filter = Nanoc::Filter.named(:erb)
|
|
14
|
+
assert(!filter.nil?)
|
|
15
|
+
|
|
16
|
+
# Find non-existant filter
|
|
17
|
+
filter = Nanoc::Filter.named(:lksdaffhdlkashlgkskahf)
|
|
18
|
+
assert(filter.nil?)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def test_register
|
|
22
|
+
SampleFilter.send(:identifier, :_plugin_test_sample_filter)
|
|
23
|
+
|
|
24
|
+
registry = Nanoc::PluginRegistry.instance
|
|
25
|
+
filter = registry.find(Nanoc::Filter, :_plugin_test_sample_filter)
|
|
26
|
+
|
|
27
|
+
refute_nil filter
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
class Nanoc::RuleTest < MiniTest::Unit::TestCase
|
|
4
|
+
|
|
5
|
+
include Nanoc::TestHelpers
|
|
6
|
+
|
|
7
|
+
def test_initialize
|
|
8
|
+
# TODO implement
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def test_applicable_to
|
|
12
|
+
# TODO implement
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def test_apply_to
|
|
16
|
+
# TODO implement
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
end
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
class Nanoc::RuleContextTest < MiniTest::Unit::TestCase
|
|
4
|
+
|
|
5
|
+
include Nanoc::TestHelpers
|
|
6
|
+
|
|
7
|
+
def test_objects
|
|
8
|
+
# Mock everything
|
|
9
|
+
config = mock
|
|
10
|
+
items = mock
|
|
11
|
+
layouts = mock
|
|
12
|
+
site = mock
|
|
13
|
+
site.stubs(:config).returns(config)
|
|
14
|
+
site.stubs(:items).returns(items)
|
|
15
|
+
site.stubs(:layouts).returns(layouts)
|
|
16
|
+
item = mock
|
|
17
|
+
item.stubs(:site).returns(site)
|
|
18
|
+
rep = mock
|
|
19
|
+
rep.stubs(:item).returns(item)
|
|
20
|
+
compiler = Nanoc::Compiler.new(site)
|
|
21
|
+
|
|
22
|
+
# Create context
|
|
23
|
+
@rule_context = Nanoc::RuleContext.new(:rep => rep, :compiler => compiler)
|
|
24
|
+
|
|
25
|
+
# Check
|
|
26
|
+
assert_equal rep, @rule_context.rep
|
|
27
|
+
assert_equal item, @rule_context.item
|
|
28
|
+
assert_equal site, @rule_context.site
|
|
29
|
+
assert_equal config, @rule_context.config
|
|
30
|
+
assert_equal layouts, @rule_context.layouts
|
|
31
|
+
assert_equal items, @rule_context.items
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def test_actions
|
|
35
|
+
# Mock everything
|
|
36
|
+
config = mock
|
|
37
|
+
items = mock
|
|
38
|
+
layouts = mock
|
|
39
|
+
site = mock
|
|
40
|
+
site.stubs(:config).returns(config)
|
|
41
|
+
site.stubs(:items).returns(items)
|
|
42
|
+
site.stubs(:layouts).returns(layouts)
|
|
43
|
+
item = mock
|
|
44
|
+
item.stubs(:site).returns(site)
|
|
45
|
+
|
|
46
|
+
# Mock rep
|
|
47
|
+
rep = mock
|
|
48
|
+
rep.stubs(:item).returns(item)
|
|
49
|
+
rep.expects(:filter).with(:foo, { :bar => 'baz' })
|
|
50
|
+
rep.expects(:layout).with('foo')
|
|
51
|
+
rep.expects(:snapshot).with('awesome')
|
|
52
|
+
|
|
53
|
+
# Mock compiler
|
|
54
|
+
compiler = Nanoc::Compiler.new(site)
|
|
55
|
+
|
|
56
|
+
# Create context
|
|
57
|
+
@rule_context = Nanoc::RuleContext.new(:rep => rep, :compiler => compiler)
|
|
58
|
+
|
|
59
|
+
# Check
|
|
60
|
+
rep.filter :foo, :bar => 'baz'
|
|
61
|
+
rep.layout 'foo'
|
|
62
|
+
rep.snapshot 'awesome'
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
end
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
class Nanoc::SiteTest < MiniTest::Unit::TestCase
|
|
4
|
+
|
|
5
|
+
include Nanoc::TestHelpers
|
|
6
|
+
|
|
7
|
+
def test_initialize_with_dir_without_config_yaml
|
|
8
|
+
assert_raises(Errno::ENOENT) do
|
|
9
|
+
site = Nanoc::Site.new('.')
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def test_initialize_with_dir_with_config_yaml
|
|
14
|
+
File.open('config.yaml', 'w') { |io| io.write('output_dir: public_html') }
|
|
15
|
+
site = Nanoc::Site.new('.')
|
|
16
|
+
assert_equal 'public_html', site.config[:output_dir]
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def test_initialize_with_config_hash
|
|
20
|
+
site = Nanoc::Site.new(:foo => 'bar')
|
|
21
|
+
assert_equal 'bar', site.config[:foo]
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def test_initialize_with_incomplete_data_source_config
|
|
25
|
+
site = Nanoc::Site.new(:data_sources => [ { :type => 'foo', :items_root => '/bar/' } ])
|
|
26
|
+
assert_equal('foo', site.config[:data_sources][0][:type])
|
|
27
|
+
assert_equal('/bar/', site.config[:data_sources][0][:items_root])
|
|
28
|
+
assert_equal('/', site.config[:data_sources][0][:layouts_root])
|
|
29
|
+
assert_equal({}, site.config[:data_sources][0][:config])
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def test_load_rules_with_existing_rules_file
|
|
33
|
+
# Mock DSL
|
|
34
|
+
dsl = mock
|
|
35
|
+
dsl.expects(:compile).with('*')
|
|
36
|
+
|
|
37
|
+
# Create site
|
|
38
|
+
site = Nanoc::Site.new({})
|
|
39
|
+
site.compiler.rules_collection.expects(:dsl).returns(dsl)
|
|
40
|
+
|
|
41
|
+
# Create rules file
|
|
42
|
+
File.open('Rules', 'w') do |io|
|
|
43
|
+
io.write <<-EOF
|
|
44
|
+
compile '*' do
|
|
45
|
+
# ... do nothing ...
|
|
46
|
+
end
|
|
47
|
+
EOF
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
# Load rules
|
|
51
|
+
site.compiler.rules_collection.load
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def test_load_data_sources_first
|
|
55
|
+
# Create site
|
|
56
|
+
Nanoc::CLI.run %w( create_site bar)
|
|
57
|
+
|
|
58
|
+
FileUtils.cd('bar') do
|
|
59
|
+
# Create data source code
|
|
60
|
+
File.open('lib/some_data_source.rb', 'w') do |io|
|
|
61
|
+
io.write "class FooDataSource < Nanoc::DataSource\n"
|
|
62
|
+
io.write " identifier :site_test_foo\n"
|
|
63
|
+
io.write " def items ; [ Nanoc::Item.new('content', {}, '/foo/') ] ; end\n"
|
|
64
|
+
io.write "end\n"
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
# Update configuration
|
|
68
|
+
File.open('config.yaml', 'w') do |io|
|
|
69
|
+
io.write "data_sources:\n"
|
|
70
|
+
io.write " - type: site_test_foo"
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
# Create site
|
|
74
|
+
site = Nanoc::Site.new('.')
|
|
75
|
+
site.load_data
|
|
76
|
+
|
|
77
|
+
# Check
|
|
78
|
+
assert_equal 1, site.data_sources.size
|
|
79
|
+
assert_equal '/foo/', site.items[0].identifier
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def test_setup_child_parent_links
|
|
84
|
+
Nanoc::CLI.run %w( create_site bar)
|
|
85
|
+
FileUtils.cd('bar') do
|
|
86
|
+
Nanoc::CLI.run %w( create_item /parent/ )
|
|
87
|
+
Nanoc::CLI.run %w( create_item /parent/foo/ )
|
|
88
|
+
Nanoc::CLI.run %w( create_item /parent/bar/ )
|
|
89
|
+
Nanoc::CLI.run %w( create_item /parent/bar/qux/ )
|
|
90
|
+
|
|
91
|
+
site = Nanoc::Site.new('.')
|
|
92
|
+
|
|
93
|
+
root = site.items.find { |i| i.identifier == '/' }
|
|
94
|
+
style = site.items.find { |i| i.identifier == '/stylesheet/' }
|
|
95
|
+
parent = site.items.find { |i| i.identifier == '/parent/' }
|
|
96
|
+
foo = site.items.find { |i| i.identifier == '/parent/foo/' }
|
|
97
|
+
bar = site.items.find { |i| i.identifier == '/parent/bar/' }
|
|
98
|
+
qux = site.items.find { |i| i.identifier == '/parent/bar/qux/' }
|
|
99
|
+
|
|
100
|
+
assert_equal Set.new([ parent, style ]), Set.new(root.children)
|
|
101
|
+
assert_equal Set.new([ foo, bar ]), Set.new(parent.children)
|
|
102
|
+
assert_equal Set.new([ qux ]), Set.new(bar.children)
|
|
103
|
+
|
|
104
|
+
assert_equal nil, root.parent
|
|
105
|
+
assert_equal root, parent.parent
|
|
106
|
+
assert_equal parent, foo.parent
|
|
107
|
+
assert_equal parent, bar.parent
|
|
108
|
+
assert_equal bar, qux.parent
|
|
109
|
+
end
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
describe 'Nanoc::Site#initialize' do
|
|
115
|
+
|
|
116
|
+
include Nanoc::TestHelpers
|
|
117
|
+
|
|
118
|
+
it 'should merge default config' do
|
|
119
|
+
site = Nanoc::Site.new(:foo => 'bar')
|
|
120
|
+
site.config[:foo].must_equal 'bar'
|
|
121
|
+
site.config[:output_dir].must_equal 'output'
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
it 'should not raise under normal circumstances' do
|
|
125
|
+
Nanoc::Site.new({})
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
it 'should not raise for non-existant output directory' do
|
|
129
|
+
Nanoc::Site.new(:output_dir => 'fklsdhailfdjalghlkasdflhagjskajdf')
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
it 'should not raise for unknown data sources' do
|
|
133
|
+
proc do
|
|
134
|
+
Nanoc::Site.new(:data_source => 'fklsdhailfdjalghlkasdflhagjskajdf')
|
|
135
|
+
end
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
describe 'Nanoc::Site#compiler' do
|
|
141
|
+
|
|
142
|
+
include Nanoc::TestHelpers
|
|
143
|
+
|
|
144
|
+
it 'should not raise under normal circumstances' do
|
|
145
|
+
site = Nanoc::Site.new({})
|
|
146
|
+
site.compiler
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
describe 'Nanoc::Site#data_sources' do
|
|
152
|
+
|
|
153
|
+
include Nanoc::TestHelpers
|
|
154
|
+
|
|
155
|
+
it 'should not raise for known data sources' do
|
|
156
|
+
site = Nanoc::Site.new({})
|
|
157
|
+
site.data_sources
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
it 'should raise for unknown data sources' do
|
|
161
|
+
proc do
|
|
162
|
+
site = Nanoc::Site.new(
|
|
163
|
+
:data_sources => [
|
|
164
|
+
{ :type => 'fklsdhailfdjalghlkasdflhagjskajdf' }
|
|
165
|
+
]
|
|
166
|
+
)
|
|
167
|
+
site.data_sources
|
|
168
|
+
end.must_raise Nanoc::Errors::UnknownDataSource
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
it 'should also use the toplevel config for data sources' do
|
|
172
|
+
with_site do
|
|
173
|
+
File.open('config.yaml', 'w') do |io|
|
|
174
|
+
io.write "data_sources:\n"
|
|
175
|
+
io.write " -\n"
|
|
176
|
+
io.write " type: filesystem_unified\n"
|
|
177
|
+
io.write " aaa: one\n"
|
|
178
|
+
io.write " config:\n"
|
|
179
|
+
io.write " bbb: two\n"
|
|
180
|
+
end
|
|
181
|
+
|
|
182
|
+
site = Nanoc::Site.new('.')
|
|
183
|
+
data_sources = site.data_sources
|
|
184
|
+
|
|
185
|
+
assert data_sources.first.config[:aaa] = 'one'
|
|
186
|
+
assert data_sources.first.config[:bbb] = 'two'
|
|
187
|
+
end
|
|
188
|
+
end
|
|
189
|
+
|
|
190
|
+
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
class Nanoc::CLI::Commands::CompileTest < MiniTest::Unit::TestCase
|
|
4
|
+
|
|
5
|
+
include Nanoc::TestHelpers
|
|
6
|
+
|
|
7
|
+
def test_profiling_information
|
|
8
|
+
with_site do |site|
|
|
9
|
+
Nanoc::CLI.run %w( create_item foo )
|
|
10
|
+
Nanoc::CLI.run %w( create_item bar )
|
|
11
|
+
Nanoc::CLI.run %w( create_item baz )
|
|
12
|
+
|
|
13
|
+
File.open('Rules', 'w') do |io|
|
|
14
|
+
io.write "compile '*' do\n"
|
|
15
|
+
io.write " filter :erb\n"
|
|
16
|
+
io.write "end\n"
|
|
17
|
+
io.write "\n"
|
|
18
|
+
io.write "route '*' do\n"
|
|
19
|
+
io.write " if item.binary?\n"
|
|
20
|
+
io.write " item.identifier.chop + '.' + item[:extension]\n"
|
|
21
|
+
io.write " else\n"
|
|
22
|
+
io.write " item.identifier + 'index.html'\n"
|
|
23
|
+
io.write " end\n"
|
|
24
|
+
io.write "end\n"
|
|
25
|
+
io.write "\n"
|
|
26
|
+
io.write "layout '*', :erb\n"
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
Nanoc::CLI.run %w( compile --verbose )
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
class Nanoc::CLI::Commands::CreateItemTest < MiniTest::Unit::TestCase
|
|
4
|
+
|
|
5
|
+
include Nanoc::TestHelpers
|
|
6
|
+
|
|
7
|
+
def test_run
|
|
8
|
+
with_site do |site|
|
|
9
|
+
Nanoc::CLI.run %w( create_item /blah/ )
|
|
10
|
+
assert File.file?('content/blah.html')
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
class Nanoc::CLI::Commands::CreateLayoutTest < MiniTest::Unit::TestCase
|
|
4
|
+
|
|
5
|
+
include Nanoc::TestHelpers
|
|
6
|
+
|
|
7
|
+
def test_can_compile_new_layout
|
|
8
|
+
require 'nanoc/cli'
|
|
9
|
+
|
|
10
|
+
Nanoc::CLI.run %w( create_site foo )
|
|
11
|
+
|
|
12
|
+
FileUtils.cd('foo') do
|
|
13
|
+
# Create new layout
|
|
14
|
+
Nanoc::CLI.run %w( create_layout moo )
|
|
15
|
+
|
|
16
|
+
# Makes rules use new layout
|
|
17
|
+
rules_raw = File.read('Rules')
|
|
18
|
+
File.open('Rules', 'w') do |io|
|
|
19
|
+
io.write rules_raw.sub("layout 'default'", "layout 'moo'")
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
site = Nanoc::Site.new('.')
|
|
23
|
+
site.load_data
|
|
24
|
+
site.compile
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
class Nanoc::CLI::Commands::CreateSiteTest < MiniTest::Unit::TestCase
|
|
4
|
+
|
|
5
|
+
include Nanoc::TestHelpers
|
|
6
|
+
|
|
7
|
+
def test_create_site_with_existing_name
|
|
8
|
+
Nanoc::CLI.run %w( create_site foo )
|
|
9
|
+
assert_raises(SystemExit) do
|
|
10
|
+
Nanoc::CLI.run %w( create_site foo )
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def test_can_compile_new_site
|
|
15
|
+
Nanoc::CLI.run %w( create_site foo )
|
|
16
|
+
|
|
17
|
+
FileUtils.cd('foo') do
|
|
18
|
+
site = Nanoc::Site.new('.')
|
|
19
|
+
site.load_data
|
|
20
|
+
site.compile
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
end
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
class Nanoc::CLI::Commands::DeployTest < MiniTest::Unit::TestCase
|
|
4
|
+
|
|
5
|
+
include Nanoc::TestHelpers
|
|
6
|
+
|
|
7
|
+
def test_deploy
|
|
8
|
+
if_have 'systemu' do
|
|
9
|
+
with_site do |site|
|
|
10
|
+
File.open('config.yaml', 'w') do |io|
|
|
11
|
+
io.write "deploy:\n"
|
|
12
|
+
io.write " public:\n"
|
|
13
|
+
io.write " kind: rsync\n"
|
|
14
|
+
io.write " dst: mydestination"
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
FileUtils.mkdir_p('output')
|
|
18
|
+
File.open('output/blah.html', 'w') { |io| io.write 'moo' }
|
|
19
|
+
|
|
20
|
+
Nanoc::CLI.run %w( deploy -t public )
|
|
21
|
+
|
|
22
|
+
assert File.directory?('mydestination')
|
|
23
|
+
assert File.file?('mydestination/blah.html')
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def test_deploy_with_dry_run
|
|
29
|
+
if_have 'systemu' do
|
|
30
|
+
with_site do |site|
|
|
31
|
+
File.open('config.yaml', 'w') do |io|
|
|
32
|
+
io.write "deploy:\n"
|
|
33
|
+
io.write " public:\n"
|
|
34
|
+
io.write " kind: rsync\n"
|
|
35
|
+
io.write " dst: mydestination"
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
FileUtils.mkdir_p('output')
|
|
39
|
+
File.open('output/blah.html', 'w') { |io| io.write 'moo' }
|
|
40
|
+
|
|
41
|
+
Nanoc::CLI.run %w( deploy -t public -n )
|
|
42
|
+
|
|
43
|
+
refute File.directory?('mydestination')
|
|
44
|
+
refute File.file?('mydestination/blah.html')
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def test_deploy_with_list
|
|
50
|
+
if_have 'systemu' do
|
|
51
|
+
with_site do |site|
|
|
52
|
+
File.open('config.yaml', 'w') do |io|
|
|
53
|
+
io.write "deploy:\n"
|
|
54
|
+
io.write " public:\n"
|
|
55
|
+
io.write " kind: rsync\n"
|
|
56
|
+
io.write " dst: mydestination"
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
FileUtils.mkdir_p('output')
|
|
60
|
+
File.open('output/blah.html', 'w') { |io| io.write 'moo' }
|
|
61
|
+
|
|
62
|
+
ios = capturing_stdio do
|
|
63
|
+
Nanoc::CLI.run %w( deploy -l )
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
assert ios[:stdout].include?('Available deployment configurations:')
|
|
67
|
+
|
|
68
|
+
refute File.directory?('mydestination')
|
|
69
|
+
refute File.file?('mydestination/blah.html')
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
end
|