nanoc 3.8.0 → 4.0.0a1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -0
- data/Gemfile.lock +322 -0
- data/NEWS.md +6 -0
- data/bin/nanoc +0 -18
- data/lib/nanoc.rb +5 -3
- data/lib/nanoc/base.rb +24 -6
- data/lib/nanoc/base/checksummer.rb +6 -4
- data/lib/nanoc/base/compilation/checksum_store.rb +4 -4
- data/lib/nanoc/base/compilation/compiled_content_cache.rb +5 -5
- data/lib/nanoc/base/compilation/compiler.rb +60 -65
- data/lib/nanoc/base/compilation/compiler_dsl.rb +11 -9
- data/lib/nanoc/base/compilation/dependency_tracker.rb +24 -38
- data/lib/nanoc/base/compilation/filter.rb +22 -7
- data/lib/nanoc/base/compilation/item_rep_proxy.rb +14 -12
- data/lib/nanoc/base/compilation/item_rep_recorder_proxy.rb +8 -8
- data/lib/nanoc/base/compilation/outdatedness_checker.rb +32 -32
- data/lib/nanoc/base/compilation/outdatedness_reasons.rb +3 -1
- data/lib/nanoc/base/compilation/rule.rb +9 -7
- data/lib/nanoc/base/compilation/rule_context.rb +15 -15
- data/lib/nanoc/base/compilation/rule_memory_calculator.rb +3 -3
- data/lib/nanoc/base/compilation/rule_memory_store.rb +7 -7
- data/lib/nanoc/base/compilation/rules_collection.rb +28 -30
- data/lib/nanoc/base/context.rb +2 -2
- data/lib/nanoc/base/core_ext/array.rb +17 -25
- data/lib/nanoc/base/core_ext/hash.rb +17 -25
- data/lib/nanoc/base/core_ext/pathname.rb +4 -2
- data/lib/nanoc/base/core_ext/string.rb +5 -3
- data/lib/nanoc/base/directed_graph.rb +4 -9
- data/lib/nanoc/base/error.rb +7 -0
- data/lib/nanoc/base/errors.rb +16 -23
- data/lib/nanoc/base/memoization.rb +4 -2
- data/lib/nanoc/base/notification_center.rb +3 -1
- data/lib/nanoc/base/plugin_registry.rb +14 -21
- data/lib/nanoc/base/result_data/item_rep.rb +43 -88
- data/lib/nanoc/base/source_data/code_snippet.rb +6 -4
- data/lib/nanoc/base/source_data/configuration.rb +3 -1
- data/lib/nanoc/base/source_data/data_source.rb +12 -94
- data/lib/nanoc/base/source_data/identifier.rb +50 -0
- data/lib/nanoc/base/source_data/item.rb +24 -67
- data/lib/nanoc/base/source_data/item_array.rb +6 -4
- data/lib/nanoc/base/source_data/layout.rb +17 -28
- data/lib/nanoc/base/source_data/site.rb +33 -44
- data/lib/nanoc/base/store.rb +3 -5
- data/lib/nanoc/base/temp_filename_factory.rb +3 -2
- data/lib/nanoc/base/views/config.rb +19 -0
- data/lib/nanoc/base/views/item.rb +77 -0
- data/lib/nanoc/base/views/item_collection.rb +43 -0
- data/lib/nanoc/base/views/item_rep.rb +125 -0
- data/lib/nanoc/base/views/layout.rb +42 -0
- data/lib/nanoc/base/views/layout_collection.rb +26 -0
- data/lib/nanoc/base/views/mutable_config.rb +9 -0
- data/lib/nanoc/base/views/mutable_item.rb +9 -0
- data/lib/nanoc/base/views/mutable_item_collection.rb +18 -0
- data/lib/nanoc/base/views/mutable_layout.rb +9 -0
- data/lib/nanoc/base/views/mutable_layout_collection.rb +18 -0
- data/lib/nanoc/base/views/site.rb +35 -0
- data/lib/nanoc/cli.rb +3 -6
- data/lib/nanoc/cli/ansi_string_colorizer.rb +2 -0
- data/lib/nanoc/cli/cleaning_stream.rb +2 -0
- data/lib/nanoc/cli/command_runner.rb +8 -42
- data/lib/nanoc/cli/commands/check.rb +2 -2
- data/lib/nanoc/cli/commands/compile.rb +19 -34
- data/lib/nanoc/cli/commands/create-site.rb +46 -83
- data/lib/nanoc/cli/commands/deploy.rb +4 -4
- data/lib/nanoc/cli/commands/shell.rb +1 -1
- data/lib/nanoc/cli/commands/show-plugins.rb +4 -6
- data/lib/nanoc/cli/error_handler.rb +4 -14
- data/lib/nanoc/cli/logger.rb +2 -0
- data/lib/nanoc/cli/stream_cleaners.rb +1 -0
- data/lib/nanoc/cli/stream_cleaners/abstract.rb +2 -0
- data/lib/nanoc/cli/stream_cleaners/ansi_colors.rb +2 -0
- data/lib/nanoc/cli/stream_cleaners/utf8.rb +2 -0
- data/lib/nanoc/data_sources.rb +1 -17
- data/lib/nanoc/data_sources/filesystem.rb +6 -37
- data/lib/nanoc/data_sources/filesystem_unified.rb +5 -3
- data/lib/nanoc/data_sources/filesystem_verbose.rb +5 -3
- data/lib/nanoc/data_sources/static.rb +4 -2
- data/lib/nanoc/extra.rb +1 -13
- data/lib/nanoc/extra/checking.rb +1 -0
- data/lib/nanoc/extra/checking/check.rb +4 -2
- data/lib/nanoc/extra/checking/checks.rb +1 -0
- data/lib/nanoc/extra/checking/checks/css.rb +1 -0
- data/lib/nanoc/extra/checking/checks/external_links.rb +2 -0
- data/lib/nanoc/extra/checking/checks/html.rb +1 -0
- data/lib/nanoc/extra/checking/checks/internal_links.rb +2 -0
- data/lib/nanoc/extra/checking/checks/mixed_content.rb +2 -0
- data/lib/nanoc/extra/checking/checks/stale.rb +1 -0
- data/lib/nanoc/extra/checking/dsl.rb +1 -0
- data/lib/nanoc/extra/checking/issue.rb +1 -0
- data/lib/nanoc/extra/checking/runner.rb +3 -3
- data/lib/nanoc/extra/core_ext/pathname.rb +5 -3
- data/lib/nanoc/extra/core_ext/time.rb +4 -2
- data/lib/nanoc/extra/deployer.rb +3 -1
- data/lib/nanoc/extra/deployers.rb +1 -0
- data/lib/nanoc/extra/deployers/fog.rb +2 -0
- data/lib/nanoc/extra/deployers/rsync.rb +2 -0
- data/lib/nanoc/extra/filesystem_tools.rb +3 -7
- data/lib/nanoc/extra/jruby_nokogiri_warner.rb +1 -0
- data/lib/nanoc/extra/link_collector.rb +1 -0
- data/lib/nanoc/extra/piper.rb +2 -1
- data/lib/nanoc/extra/pruner.rb +5 -3
- data/lib/nanoc/filters.rb +1 -2
- data/lib/nanoc/filters/asciidoc.rb +2 -0
- data/lib/nanoc/filters/bluecloth.rb +1 -0
- data/lib/nanoc/filters/coffeescript.rb +2 -0
- data/lib/nanoc/filters/colorize_syntax.rb +1 -12
- data/lib/nanoc/filters/erb.rb +2 -1
- data/lib/nanoc/filters/erubis.rb +2 -1
- data/lib/nanoc/filters/haml.rb +2 -1
- data/lib/nanoc/filters/handlebars.rb +2 -0
- data/lib/nanoc/filters/kramdown.rb +1 -0
- data/lib/nanoc/filters/less.rb +1 -0
- data/lib/nanoc/filters/markaby.rb +1 -0
- data/lib/nanoc/filters/maruku.rb +1 -0
- data/lib/nanoc/filters/mustache.rb +2 -0
- data/lib/nanoc/filters/pandoc.rb +1 -0
- data/lib/nanoc/filters/rainpress.rb +1 -0
- data/lib/nanoc/filters/rdiscount.rb +1 -0
- data/lib/nanoc/filters/rdoc.rb +1 -0
- data/lib/nanoc/filters/redcarpet.rb +2 -0
- data/lib/nanoc/filters/redcloth.rb +1 -0
- data/lib/nanoc/filters/relativize_paths.rb +1 -0
- data/lib/nanoc/filters/rubypants.rb +1 -0
- data/lib/nanoc/filters/sass.rb +1 -0
- data/lib/nanoc/filters/sass/sass_filesystem_importer.rb +2 -0
- data/lib/nanoc/filters/slim.rb +3 -1
- data/lib/nanoc/filters/typogruby.rb +2 -0
- data/lib/nanoc/filters/uglify_js.rb +1 -0
- data/lib/nanoc/filters/xsl.rb +2 -0
- data/lib/nanoc/filters/yui_compressor.rb +2 -0
- data/lib/nanoc/helpers/blogging.rb +30 -30
- data/lib/nanoc/helpers/breadcrumbs.rb +2 -2
- data/lib/nanoc/helpers/capturing.rb +6 -17
- data/lib/nanoc/helpers/filtering.rb +3 -3
- data/lib/nanoc/helpers/link_to.rb +3 -3
- data/lib/nanoc/helpers/rendering.rb +11 -11
- data/lib/nanoc/helpers/xml_sitemap.rb +3 -3
- data/lib/nanoc/tasks.rb +1 -0
- data/lib/nanoc/tasks/clean.rake +1 -1
- data/lib/nanoc/version.rb +1 -1
- data/tasks/doc.rake +2 -1
- data/tasks/test.rake +7 -1
- data/test/base/checksummer_spec.rb +15 -15
- data/test/base/core_ext/array_spec.rb +10 -10
- data/test/base/core_ext/hash_spec.rb +16 -16
- data/test/base/core_ext/pathname_spec.rb +2 -2
- data/test/base/core_ext/string_spec.rb +9 -9
- data/test/base/temp_filename_factory_spec.rb +3 -7
- data/test/base/test_checksum_store.rb +5 -5
- data/test/base/test_code_snippet.rb +3 -3
- data/test/base/test_compiler.rb +29 -29
- data/test/base/test_compiler_dsl.rb +23 -23
- data/test/base/test_context.rb +4 -4
- data/test/base/test_data_source.rb +17 -7
- data/test/base/test_dependency_tracker.rb +29 -29
- data/test/base/test_directed_graph.rb +27 -27
- data/test/base/test_item.rb +23 -21
- data/test/base/test_item_array.rb +18 -18
- data/test/base/test_item_rep.rb +76 -76
- data/test/base/test_item_rep_recorder_proxy.rb +4 -4
- data/test/base/test_layout.rb +8 -16
- data/test/base/test_memoization.rb +4 -4
- data/test/base/test_notification_center.rb +6 -6
- data/test/base/test_outdatedness_checker.rb +18 -18
- data/test/base/test_plugin.rb +1 -1
- data/test/base/test_rule.rb +2 -2
- data/test/base/test_rule_context.rb +5 -5
- data/test/base/test_site.rb +62 -38
- data/test/base/test_store.rb +2 -2
- data/test/cli/commands/test_check.rb +1 -1
- data/test/cli/commands/test_compile.rb +24 -18
- data/test/cli/commands/test_create_site.rb +5 -7
- data/test/cli/commands/test_deploy.rb +1 -1
- data/test/data_sources/test_filesystem.rb +22 -67
- data/test/data_sources/test_filesystem_unified.rb +10 -23
- data/test/data_sources/test_filesystem_verbose.rb +8 -53
- data/test/data_sources/test_static.rb +9 -9
- data/test/extra/checking/checks/test_stale.rb +1 -1
- data/test/extra/core_ext/test_pathname.rb +3 -3
- data/test/extra/core_ext/test_time.rb +4 -4
- data/test/extra/test_filesystem_tools.rb +1 -1
- data/test/filters/test_handlebars.rb +3 -3
- data/test/filters/test_less.rb +6 -6
- data/test/filters/test_mustache.rb +2 -2
- data/test/filters/test_relativize_paths.rb +81 -81
- data/test/filters/test_sass.rb +7 -7
- data/test/filters/test_xsl.rb +6 -6
- data/test/helper.rb +1 -1
- data/test/helpers/test_blogging.rb +78 -99
- data/test/helpers/test_breadcrumbs.rb +12 -12
- data/test/helpers/test_capturing.rb +10 -11
- data/test/helpers/test_filtering.rb +6 -6
- data/test/helpers/test_rendering.rb +3 -3
- data/test/helpers/test_tagging.rb +7 -7
- data/test/helpers/test_xml_sitemap.rb +34 -33
- metadata +19 -43
- data/lib/nanoc/cli/commands/autocompile.rb +0 -69
- data/lib/nanoc/cli/commands/create-item.rb +0 -55
- data/lib/nanoc/cli/commands/create-layout.rb +0 -68
- data/lib/nanoc/cli/commands/sync.rb +0 -32
- data/lib/nanoc/cli/commands/update.rb +0 -63
- data/lib/nanoc/cli/commands/validate-css.rb +0 -20
- data/lib/nanoc/cli/commands/validate-html.rb +0 -20
- data/lib/nanoc/cli/commands/validate-links.rb +0 -27
- data/lib/nanoc/cli/commands/watch.rb +0 -176
- data/lib/nanoc/data_sources/deprecated/delicious.rb +0 -38
- data/lib/nanoc/data_sources/deprecated/last_fm.rb +0 -85
- data/lib/nanoc/data_sources/deprecated/twitter.rb +0 -34
- data/lib/nanoc/extra/auto_compiler.rb +0 -99
- data/lib/nanoc/extra/chick.rb +0 -117
- data/lib/nanoc/extra/file_proxy.rb +0 -36
- data/lib/nanoc/extra/validators.rb +0 -8
- data/lib/nanoc/extra/validators/links.rb +0 -18
- data/lib/nanoc/extra/validators/w3c.rb +0 -23
- data/lib/nanoc/extra/vcs.rb +0 -62
- data/lib/nanoc/extra/vcses.rb +0 -15
- data/lib/nanoc/extra/vcses/bazaar.rb +0 -21
- data/lib/nanoc/extra/vcses/dummy.rb +0 -20
- data/lib/nanoc/extra/vcses/git.rb +0 -21
- data/lib/nanoc/extra/vcses/mercurial.rb +0 -21
- data/lib/nanoc/extra/vcses/subversion.rb +0 -21
- data/lib/nanoc/filters/coderay.rb +0 -19
- data/lib/nanoc3.rb +0 -3
- data/lib/nanoc3/cli.rb +0 -3
- data/lib/nanoc3/tasks.rb +0 -3
- data/test/cli/commands/test_create_item.rb +0 -10
- data/test/cli/commands/test_create_layout.rb +0 -24
- data/test/cli/commands/test_sync.rb +0 -27
- data/test/cli/commands/test_update.rb +0 -6
- data/test/cli/commands/test_watch.rb +0 -74
- data/test/extra/test_auto_compiler.rb +0 -437
- data/test/extra/test_vcs.rb +0 -18
- data/test/extra/validators/test_links.rb +0 -4
- data/test/extra/validators/test_w3c.rb +0 -37
- data/test/filters/test_coderay.rb +0 -40
data/lib/nanoc/extra/vcs.rb
DELETED
@@ -1,62 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
module Nanoc::Extra
|
4
|
-
# A very simple representation of a version control system (VCS) that
|
5
|
-
# abstracts the add, remove and move operations. It does not commit. This
|
6
|
-
# class is primarily used by data sources that store data as flat files on
|
7
|
-
# the disk.
|
8
|
-
#
|
9
|
-
# @abstract Subclass and override {#add}, {#remove} and {#move} to implement
|
10
|
-
# a custom VCS.
|
11
|
-
class VCS
|
12
|
-
extend Nanoc::PluginRegistry::PluginMethods
|
13
|
-
|
14
|
-
# Adds the file with the given filename to the working copy.
|
15
|
-
#
|
16
|
-
# @param [String] filename The name of the file to add
|
17
|
-
#
|
18
|
-
# @return [void]
|
19
|
-
#
|
20
|
-
# @abstract
|
21
|
-
def add(filename) # rubocop:disable Lint/UnusedMethodArgument
|
22
|
-
not_implemented('add')
|
23
|
-
end
|
24
|
-
|
25
|
-
# Removes the file with the given filename from the working copy. When
|
26
|
-
# this method is executed, the file should no longer be present on the
|
27
|
-
# disk.
|
28
|
-
#
|
29
|
-
# @param [String] filename The name of the file to remove
|
30
|
-
#
|
31
|
-
# @return [void]
|
32
|
-
#
|
33
|
-
# @abstract
|
34
|
-
def remove(filename) # rubocop:disable Lint/UnusedMethodArgument
|
35
|
-
not_implemented('remove')
|
36
|
-
end
|
37
|
-
|
38
|
-
# Moves the file with the given filename to a new location. When this
|
39
|
-
# method is executed, the original file should no longer be present on the
|
40
|
-
# disk.
|
41
|
-
#
|
42
|
-
# @param [String] src The old filename
|
43
|
-
#
|
44
|
-
# @param [String] dst The new filename
|
45
|
-
#
|
46
|
-
# @return [void]
|
47
|
-
#
|
48
|
-
# @abstract
|
49
|
-
def move(src, dst) # rubocop:disable Lint/UnusedMethodArgument
|
50
|
-
not_implemented('move')
|
51
|
-
end
|
52
|
-
|
53
|
-
private
|
54
|
-
|
55
|
-
def not_implemented(name)
|
56
|
-
raise NotImplementedError.new(
|
57
|
-
"#{self.class} does not override ##{name}, which is required for " \
|
58
|
-
'this data source to be used.'
|
59
|
-
)
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
data/lib/nanoc/extra/vcses.rb
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
module Nanoc::Extra::VCSes
|
4
|
-
autoload 'Bazaar', 'nanoc/extra/vcses/bazaar'
|
5
|
-
autoload 'Dummy', 'nanoc/extra/vcses/dummy'
|
6
|
-
autoload 'Git', 'nanoc/extra/vcses/git'
|
7
|
-
autoload 'Mercurial', 'nanoc/extra/vcses/mercurial'
|
8
|
-
autoload 'Subversion', 'nanoc/extra/vcses/subversion'
|
9
|
-
|
10
|
-
Nanoc::Extra::VCS.register '::Nanoc::Extra::VCSes::Bazaar', :bazaar, :bzr
|
11
|
-
Nanoc::Extra::VCS.register '::Nanoc::Extra::VCSes::Dummy', :dummy
|
12
|
-
Nanoc::Extra::VCS.register '::Nanoc::Extra::VCSes::Git', :git
|
13
|
-
Nanoc::Extra::VCS.register '::Nanoc::Extra::VCSes::Mercurial', :mercurial, :hg
|
14
|
-
Nanoc::Extra::VCS.register '::Nanoc::Extra::VCSes::Subversion', :subversion, :svn
|
15
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
module Nanoc::Extra::VCSes
|
4
|
-
# @see Nanoc::Extra::VCS
|
5
|
-
class Bazaar < Nanoc::Extra::VCS
|
6
|
-
# @see Nanoc::Extra::VCS#add
|
7
|
-
def add(filename)
|
8
|
-
system('bzr', 'add', filename)
|
9
|
-
end
|
10
|
-
|
11
|
-
# @see Nanoc::Extra::VCS#remove
|
12
|
-
def remove(filename)
|
13
|
-
system('bzr', 'rm', filename)
|
14
|
-
end
|
15
|
-
|
16
|
-
# @see Nanoc::Extra::VCS#move
|
17
|
-
def move(src, dst)
|
18
|
-
system('bzr', 'mv', src, dst)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
module Nanoc::Extra::VCSes
|
4
|
-
# @see Nanoc::Extra::VCS
|
5
|
-
class Dummy < Nanoc::Extra::VCS
|
6
|
-
# @see Nanoc::Extra::VCS#add
|
7
|
-
def add(_filename)
|
8
|
-
end
|
9
|
-
|
10
|
-
# @see Nanoc::Extra::VCS#remove
|
11
|
-
def remove(filename)
|
12
|
-
FileUtils.rm_rf(filename)
|
13
|
-
end
|
14
|
-
|
15
|
-
# @see Nanoc::Extra::VCS#move
|
16
|
-
def move(src, dst)
|
17
|
-
FileUtils.move(src, dst)
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
module Nanoc::Extra::VCSes
|
4
|
-
# @see Nanoc::Extra::VCS
|
5
|
-
class Git < Nanoc::Extra::VCS
|
6
|
-
# @see Nanoc::Extra::VCS#add
|
7
|
-
def add(filename)
|
8
|
-
system('git', 'add', filename)
|
9
|
-
end
|
10
|
-
|
11
|
-
# @see Nanoc::Extra::VCS#remove
|
12
|
-
def remove(filename)
|
13
|
-
system('git', 'rm', filename)
|
14
|
-
end
|
15
|
-
|
16
|
-
# @see Nanoc::Extra::VCS#move
|
17
|
-
def move(src, dst)
|
18
|
-
system('git', 'mv', src, dst)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
module Nanoc::Extra::VCSes
|
4
|
-
# @see Nanoc::Extra::VCS
|
5
|
-
class Mercurial < Nanoc::Extra::VCS
|
6
|
-
# @see Nanoc::Extra::VCS#add
|
7
|
-
def add(filename)
|
8
|
-
system('hg', 'add', filename)
|
9
|
-
end
|
10
|
-
|
11
|
-
# @see Nanoc::Extra::VCS#remove
|
12
|
-
def remove(filename)
|
13
|
-
system('hg', 'rm', filename)
|
14
|
-
end
|
15
|
-
|
16
|
-
# @see Nanoc::Extra::VCS#move
|
17
|
-
def move(src, dst)
|
18
|
-
system('hg', 'mv', src, dst)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
module Nanoc::Extra::VCSes
|
4
|
-
# @see Nanoc::Extra::VCS
|
5
|
-
class Subversion < Nanoc::Extra::VCS
|
6
|
-
# @see Nanoc::Extra::VCS#add
|
7
|
-
def add(filename)
|
8
|
-
system('svn', 'add', filename)
|
9
|
-
end
|
10
|
-
|
11
|
-
# @see Nanoc::Extra::VCS#remove
|
12
|
-
def remove(filename)
|
13
|
-
system('svn', 'rm', filename)
|
14
|
-
end
|
15
|
-
|
16
|
-
# @see Nanoc::Extra::VCS#move
|
17
|
-
def move(src, dst)
|
18
|
-
system('svn', 'mv', src, dst)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
module Nanoc::Filters
|
4
|
-
class CodeRay < Nanoc::Filter
|
5
|
-
requires 'coderay'
|
6
|
-
|
7
|
-
# @deprecated Use the `:colorize_syntax` filter instead.
|
8
|
-
def run(content, params = {})
|
9
|
-
# Warn
|
10
|
-
warn 'The :coderay filter is deprecated; consider using the :colorize_syntax filter instead.'
|
11
|
-
|
12
|
-
# Check params
|
13
|
-
raise ArgumentError, 'CodeRay filter requires a :language argument which is missing' if params[:language].nil?
|
14
|
-
|
15
|
-
# Get result
|
16
|
-
::CodeRay.scan(content, params[:language]).html
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
data/lib/nanoc3.rb
DELETED
data/lib/nanoc3/cli.rb
DELETED
data/lib/nanoc3/tasks.rb
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
class Nanoc::CLI::Commands::CreateLayoutTest < Nanoc::TestCase
|
4
|
-
def test_can_compile_new_layout
|
5
|
-
require 'nanoc/cli'
|
6
|
-
|
7
|
-
Nanoc::CLI.run %w( create_site foo )
|
8
|
-
|
9
|
-
FileUtils.cd('foo') do
|
10
|
-
# Create new layout
|
11
|
-
Nanoc::CLI.run %w( create_layout moo )
|
12
|
-
|
13
|
-
# Makes rules use new layout
|
14
|
-
rules_raw = File.read('Rules')
|
15
|
-
File.open('Rules', 'w') do |io|
|
16
|
-
io.write rules_raw.sub("layout 'default'", "layout 'moo'")
|
17
|
-
end
|
18
|
-
|
19
|
-
site = Nanoc::Site.new('.')
|
20
|
-
site.load_data
|
21
|
-
site.compile
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
@@ -1,27 +0,0 @@
|
|
1
|
-
class Nanoc::CLI::Commands::SyncTest < Nanoc::TestCase
|
2
|
-
def test_run
|
3
|
-
with_site do
|
4
|
-
File.open('lib/foo_data_source.rb', 'w') do |io|
|
5
|
-
io.write "class FooDataSource < Nanoc::DataSource\n"
|
6
|
-
io.write " identifier :sync_test_foo\n"
|
7
|
-
io.write " def sync\n"
|
8
|
-
io.write " File.open('foo_source_data.yaml', 'w') do |io|\n"
|
9
|
-
io.write " io.write 'sync: true'\n"
|
10
|
-
io.write " end\n"
|
11
|
-
io.write " end\n"
|
12
|
-
io.write "end\n"
|
13
|
-
end
|
14
|
-
|
15
|
-
File.open('nanoc.yaml', 'w') do |io|
|
16
|
-
io.write "data_sources:\n"
|
17
|
-
io.write " - type: sync_test_foo\n"
|
18
|
-
io.write ' items_root: /'
|
19
|
-
end
|
20
|
-
|
21
|
-
Nanoc::CLI.run %w( sync )
|
22
|
-
|
23
|
-
assert File.file?('foo_source_data.yaml')
|
24
|
-
assert_equal File.read('foo_source_data.yaml'), 'sync: true'
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
@@ -1,74 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
class Nanoc::CLI::Commands::WatchTest < Nanoc::TestCase
|
4
|
-
def test_run
|
5
|
-
with_site do |_s|
|
6
|
-
watch_thread = Thread.new do
|
7
|
-
Nanoc::CLI.run %w( watch )
|
8
|
-
end
|
9
|
-
|
10
|
-
File.open('content/index.html', 'w') { |io| io.write('Hello there!') }
|
11
|
-
wait_until_content_equals('content/index.html', 'Hello there!')
|
12
|
-
|
13
|
-
File.open('content/index.html', 'w') { |io| io.write('Hello there again!') }
|
14
|
-
wait_until_content_equals('content/index.html', 'Hello there again!')
|
15
|
-
|
16
|
-
watch_thread.kill
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
def test_notify
|
21
|
-
with_site do |_s|
|
22
|
-
watch_thread = Thread.new do
|
23
|
-
Nanoc::CLI.run %w( watch )
|
24
|
-
end
|
25
|
-
|
26
|
-
File.open('content/index.html', 'w') { |io| io.write('Hello there!') }
|
27
|
-
wait_until_exists('output/index.html')
|
28
|
-
assert_equal 'Hello there!', File.read('output/index.html')
|
29
|
-
|
30
|
-
watch_thread.kill
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
def test_growlnotify_cmd
|
35
|
-
Nanoc::CLI.setup
|
36
|
-
notifier = Nanoc::CLI::Commands::Watch::Notifier.new
|
37
|
-
assert_equal ['growlnotify', '-m', 'foo'], notifier.send(:growlnotify_cmd_for, 'foo')
|
38
|
-
end
|
39
|
-
|
40
|
-
def test_growlnotify_windows_cmd
|
41
|
-
Nanoc::CLI.setup
|
42
|
-
notifier = Nanoc::CLI::Commands::Watch::Notifier.new
|
43
|
-
assert_equal ['growlnotify', '/t:nanoc', 'foo'], notifier.send(:growlnotify_windows_cmd_for, 'foo')
|
44
|
-
end
|
45
|
-
|
46
|
-
def wait_until_exists(filename)
|
47
|
-
20.times do
|
48
|
-
break if File.file?(filename)
|
49
|
-
sleep 0.5
|
50
|
-
end
|
51
|
-
unless File.file?(filename)
|
52
|
-
raise "Expected #{filename} to appear but it didn't :("
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
def wait_until_content_equals(filename, expected_content)
|
57
|
-
wait_until_exists(filename)
|
58
|
-
|
59
|
-
20.times do
|
60
|
-
break if File.read(filename) == expected_content
|
61
|
-
sleep 0.5
|
62
|
-
end
|
63
|
-
|
64
|
-
actual_content = File.read(filename)
|
65
|
-
if actual_content != expected_content
|
66
|
-
raise "Expected #{filename} to have " \
|
67
|
-
"content #{expected_content.inspect} but it had " \
|
68
|
-
"content #{actual_content.inspect} instead :("
|
69
|
-
end
|
70
|
-
|
71
|
-
# Ugly, but seems to be necessary or changes are not picked up. :(
|
72
|
-
sleep 0.5
|
73
|
-
end
|
74
|
-
end
|
@@ -1,437 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
class Nanoc::Extra::AutoCompilerTest < Nanoc::TestCase
|
4
|
-
def test_handle_request_with_item_rep_with_index_filename
|
5
|
-
if_have 'mime/types', 'rack' do
|
6
|
-
# Create site
|
7
|
-
Nanoc::CLI.run %w( create_site bar)
|
8
|
-
|
9
|
-
FileUtils.cd('bar') do
|
10
|
-
# Create item
|
11
|
-
FileUtils.mkdir_p('content/foo')
|
12
|
-
File.open('content/foo/index.html', 'w') do |io|
|
13
|
-
io.write 'Moo!'
|
14
|
-
end
|
15
|
-
|
16
|
-
# Create output file
|
17
|
-
FileUtils.mkdir_p('output/foo')
|
18
|
-
File.open('output/foo/index.html', 'w') do |io|
|
19
|
-
io.write 'Compiled moo!'
|
20
|
-
end
|
21
|
-
|
22
|
-
# Create site
|
23
|
-
site = Nanoc::Site.new('.')
|
24
|
-
site.expects(:compile)
|
25
|
-
|
26
|
-
# Create autocompiler
|
27
|
-
autocompiler = Nanoc::Extra::AutoCompiler.new('.')
|
28
|
-
autocompiler.stubs(:build_site)
|
29
|
-
autocompiler.stubs(:site).returns(site)
|
30
|
-
|
31
|
-
# Serve
|
32
|
-
status, headers, body = autocompiler.instance_eval { call('REQUEST_METHOD' => 'GET', 'PATH_INFO' => '/foo/index.html') }
|
33
|
-
|
34
|
-
# Check response
|
35
|
-
assert_equal(200, status)
|
36
|
-
assert_equal('text/html', headers['Content-Type'])
|
37
|
-
body.each do |b|
|
38
|
-
assert_equal 'Compiled moo!', b
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
def test_handle_request_with_broken_url
|
45
|
-
if_have 'mime/types', 'rack' do
|
46
|
-
# Create site
|
47
|
-
Nanoc::CLI.run %w( create_site bar)
|
48
|
-
|
49
|
-
FileUtils.cd('bar') do
|
50
|
-
# Create site
|
51
|
-
site = Nanoc::Site.new('.')
|
52
|
-
|
53
|
-
# Create autocompiler
|
54
|
-
autocompiler = Nanoc::Extra::AutoCompiler.new('.')
|
55
|
-
autocompiler.stubs(:build_site)
|
56
|
-
autocompiler.stubs(:site).returns(site)
|
57
|
-
|
58
|
-
# Serve
|
59
|
-
status, _, _ = autocompiler.instance_eval { call('REQUEST_METHOD' => 'GET', 'PATH_INFO' => '/afjwiagoawf.html') }
|
60
|
-
|
61
|
-
# Check response
|
62
|
-
assert_equal(404, status)
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
def test_handle_request_with_file
|
68
|
-
if_have 'mime/types', 'rack' do
|
69
|
-
# Create file
|
70
|
-
FileUtils.mkdir_p('out')
|
71
|
-
File.open('out/somefile.txt', 'w') { |io| io.write('hello') }
|
72
|
-
|
73
|
-
# Create file server
|
74
|
-
file_server = mock
|
75
|
-
def file_server.call(env)
|
76
|
-
@expected_path_info = 'somefile.txt'
|
77
|
-
@actual_path_info = env['PATH_INFO']
|
78
|
-
end
|
79
|
-
def file_server.expected_path_info
|
80
|
-
@expected_path_info
|
81
|
-
end
|
82
|
-
def file_server.actual_path_info
|
83
|
-
@actual_path_info
|
84
|
-
end
|
85
|
-
|
86
|
-
# Create site
|
87
|
-
site = mock
|
88
|
-
site.expects(:items).returns([])
|
89
|
-
site.expects(:config).returns({ output_dir: 'out', index_filenames: ['index.html'] })
|
90
|
-
|
91
|
-
# Create autocompiler
|
92
|
-
autocompiler = Nanoc::Extra::AutoCompiler.new('.')
|
93
|
-
autocompiler.stubs(:build_site)
|
94
|
-
autocompiler.stubs(:site).returns(site)
|
95
|
-
autocompiler.expects(:file_server).returns(file_server)
|
96
|
-
|
97
|
-
# Run
|
98
|
-
autocompiler.instance_eval { call('REQUEST_METHOD' => 'GET', 'PATH_INFO' => 'somefile.txt') }
|
99
|
-
|
100
|
-
# Check
|
101
|
-
assert_equal(file_server.expected_path_info, file_server.actual_path_info)
|
102
|
-
end
|
103
|
-
end
|
104
|
-
|
105
|
-
def test_handle_request_with_dir_with_slash_with_index_file
|
106
|
-
if_have 'mime/types', 'rack' do
|
107
|
-
# Create file
|
108
|
-
FileUtils.mkdir_p('out/foo/bar')
|
109
|
-
File.open('out/foo/bar/index.html', 'w') { |io| io.write('hello') }
|
110
|
-
|
111
|
-
# Create file server
|
112
|
-
file_server = mock
|
113
|
-
def file_server.call(env)
|
114
|
-
@expected_path_info = '/foo/bar/index.html'
|
115
|
-
@actual_path_info = env['PATH_INFO']
|
116
|
-
end
|
117
|
-
def file_server.expected_path_info
|
118
|
-
@expected_path_info
|
119
|
-
end
|
120
|
-
def file_server.actual_path_info
|
121
|
-
@actual_path_info
|
122
|
-
end
|
123
|
-
|
124
|
-
# Create site
|
125
|
-
site = mock
|
126
|
-
site.expects(:items).returns([])
|
127
|
-
site.expects(:config).at_least_once.returns({ output_dir: 'out', index_filenames: ['index.html'] })
|
128
|
-
|
129
|
-
# Create autocompiler
|
130
|
-
autocompiler = Nanoc::Extra::AutoCompiler.new('.')
|
131
|
-
autocompiler.stubs(:build_site)
|
132
|
-
autocompiler.stubs(:site).returns(site)
|
133
|
-
autocompiler.expects(:file_server).returns(file_server)
|
134
|
-
|
135
|
-
# Run
|
136
|
-
autocompiler.instance_eval { call('REQUEST_METHOD' => 'GET', 'PATH_INFO' => '/foo/bar/') }
|
137
|
-
|
138
|
-
# Check
|
139
|
-
assert_equal(file_server.expected_path_info, file_server.actual_path_info)
|
140
|
-
end
|
141
|
-
end
|
142
|
-
|
143
|
-
def test_handle_request_with_dir_with_slash_without_index_file
|
144
|
-
if_have 'mime/types', 'rack' do
|
145
|
-
# Create file
|
146
|
-
FileUtils.mkdir_p('out/foo/bar')
|
147
|
-
File.open('out/foo/bar/someotherfile.txt', 'w') { |io| io.write('hello') }
|
148
|
-
|
149
|
-
# Create file server
|
150
|
-
file_server = mock
|
151
|
-
def file_server.call(env)
|
152
|
-
@expected_path_info = 'foo/bar/'
|
153
|
-
@actual_path_info = env['PATH_INFO']
|
154
|
-
end
|
155
|
-
def file_server.expected_path_info
|
156
|
-
@expected_path_info
|
157
|
-
end
|
158
|
-
def file_server.actual_path_info
|
159
|
-
@actual_path_info
|
160
|
-
end
|
161
|
-
|
162
|
-
# Create site
|
163
|
-
site = mock
|
164
|
-
site.expects(:items).returns([])
|
165
|
-
site.expects(:config).at_least_once.returns({ output_dir: 'out', index_filenames: ['index.html'] })
|
166
|
-
|
167
|
-
# Create autocompiler
|
168
|
-
autocompiler = Nanoc::Extra::AutoCompiler.new('.')
|
169
|
-
autocompiler.stubs(:build_site)
|
170
|
-
autocompiler.stubs(:site).returns(site)
|
171
|
-
autocompiler.expects(:file_server).returns(file_server)
|
172
|
-
|
173
|
-
# Run
|
174
|
-
autocompiler.instance_eval { call('REQUEST_METHOD' => 'GET', 'PATH_INFO' => 'foo/bar/') }
|
175
|
-
|
176
|
-
# Check
|
177
|
-
assert_equal(file_server.expected_path_info, file_server.actual_path_info)
|
178
|
-
end
|
179
|
-
end
|
180
|
-
|
181
|
-
def test_handle_request_with_dir_without_slash_with_index_file
|
182
|
-
if_have 'mime/types', 'rack' do
|
183
|
-
# Create file
|
184
|
-
FileUtils.mkdir_p('out/foo/bar')
|
185
|
-
File.open('out/foo/bar/index.html', 'w') { |io| io.write('hello') }
|
186
|
-
|
187
|
-
# Create file server
|
188
|
-
file_server = mock
|
189
|
-
def file_server.call(env)
|
190
|
-
@expected_path_info = 'foo/bar'
|
191
|
-
@actual_path_info = env['PATH_INFO']
|
192
|
-
end
|
193
|
-
def file_server.expected_path_info
|
194
|
-
@expected_path_info
|
195
|
-
end
|
196
|
-
def file_server.actual_path_info
|
197
|
-
@actual_path_info
|
198
|
-
end
|
199
|
-
|
200
|
-
# Create site
|
201
|
-
site = mock
|
202
|
-
site.expects(:items).returns([])
|
203
|
-
site.expects(:config).at_least_once.returns({ output_dir: 'out', index_filenames: ['index.html'] })
|
204
|
-
|
205
|
-
# Create autocompiler
|
206
|
-
autocompiler = Nanoc::Extra::AutoCompiler.new('.')
|
207
|
-
autocompiler.stubs(:build_site)
|
208
|
-
autocompiler.stubs(:site).returns(site)
|
209
|
-
autocompiler.expects(:file_server).returns(file_server)
|
210
|
-
|
211
|
-
# Run
|
212
|
-
autocompiler.instance_eval { call('REQUEST_METHOD' => 'GET', 'PATH_INFO' => 'foo/bar') }
|
213
|
-
|
214
|
-
# Check
|
215
|
-
assert_equal(file_server.expected_path_info, file_server.actual_path_info)
|
216
|
-
end
|
217
|
-
end
|
218
|
-
|
219
|
-
def test_handle_request_with_dir_without_slash_without_index_file
|
220
|
-
if_have 'mime/types', 'rack' do
|
221
|
-
# Create file
|
222
|
-
FileUtils.mkdir_p('out/foo/bar')
|
223
|
-
File.open('out/foo/bar/someotherfile.txt', 'w') { |io| io.write('hello') }
|
224
|
-
|
225
|
-
# Create file server
|
226
|
-
file_server = mock
|
227
|
-
def file_server.call(env)
|
228
|
-
@expected_path_info = 'foo/bar'
|
229
|
-
@actual_path_info = env['PATH_INFO']
|
230
|
-
end
|
231
|
-
def file_server.expected_path_info
|
232
|
-
@expected_path_info
|
233
|
-
end
|
234
|
-
def file_server.actual_path_info
|
235
|
-
@actual_path_info
|
236
|
-
end
|
237
|
-
|
238
|
-
# Create site
|
239
|
-
site = mock
|
240
|
-
site.expects(:items).returns([])
|
241
|
-
site.expects(:config).at_least_once.returns({ output_dir: 'out', index_filenames: ['index.html'] })
|
242
|
-
|
243
|
-
# Create autocompiler
|
244
|
-
autocompiler = Nanoc::Extra::AutoCompiler.new('.')
|
245
|
-
autocompiler.stubs(:build_site)
|
246
|
-
autocompiler.stubs(:site).returns(site)
|
247
|
-
autocompiler.expects(:file_server).returns(file_server)
|
248
|
-
|
249
|
-
# Run
|
250
|
-
autocompiler.instance_eval { call('REQUEST_METHOD' => 'GET', 'PATH_INFO' => 'foo/bar') }
|
251
|
-
|
252
|
-
# Check
|
253
|
-
assert_equal(file_server.expected_path_info, file_server.actual_path_info)
|
254
|
-
end
|
255
|
-
end
|
256
|
-
|
257
|
-
def test_handle_request_with_404
|
258
|
-
if_have 'mime/types', 'rack' do
|
259
|
-
# Create file server
|
260
|
-
file_server = mock
|
261
|
-
def file_server.call(env)
|
262
|
-
@expected_path_info = 'four-oh-four.txt'
|
263
|
-
@actual_path_info = env['PATH_INFO']
|
264
|
-
end
|
265
|
-
def file_server.expected_path_info
|
266
|
-
@expected_path_info
|
267
|
-
end
|
268
|
-
def file_server.actual_path_info
|
269
|
-
@actual_path_info
|
270
|
-
end
|
271
|
-
|
272
|
-
# Create site
|
273
|
-
site = mock
|
274
|
-
site.expects(:items).returns([])
|
275
|
-
site.expects(:config).at_least_once.returns({ output_dir: 'out', index_filenames: ['index.html'] })
|
276
|
-
|
277
|
-
# Create autocompiler
|
278
|
-
autocompiler = Nanoc::Extra::AutoCompiler.new('.')
|
279
|
-
autocompiler.stubs(:build_site)
|
280
|
-
autocompiler.stubs(:site).returns(site)
|
281
|
-
autocompiler.expects(:file_server).returns(file_server)
|
282
|
-
|
283
|
-
# Run
|
284
|
-
autocompiler.instance_eval { call('REQUEST_METHOD' => 'GET', 'PATH_INFO' => 'four-oh-four.txt') }
|
285
|
-
|
286
|
-
# Check
|
287
|
-
assert_equal(file_server.expected_path_info, file_server.actual_path_info)
|
288
|
-
end
|
289
|
-
end
|
290
|
-
|
291
|
-
def test_mime_type_of
|
292
|
-
if_have 'mime/types', 'rack' do
|
293
|
-
# Create autocompiler
|
294
|
-
autocompiler = Nanoc::Extra::AutoCompiler.new(nil)
|
295
|
-
|
296
|
-
# Create known test file
|
297
|
-
File.open('foo.html', 'w') { |io| io.write('hello') }
|
298
|
-
assert_equal(
|
299
|
-
'text/html',
|
300
|
-
autocompiler.instance_eval { mime_type_of('foo.html', 'huh') }
|
301
|
-
)
|
302
|
-
|
303
|
-
# Create unknown test file
|
304
|
-
File.open('foo', 'w') { |io| io.write('hello') }
|
305
|
-
assert_equal(
|
306
|
-
'huh',
|
307
|
-
autocompiler.instance_eval { mime_type_of('foo', 'huh') }
|
308
|
-
)
|
309
|
-
end
|
310
|
-
end
|
311
|
-
|
312
|
-
def test_serve_with_working_item
|
313
|
-
if_have 'mime/types', 'rack' do
|
314
|
-
# Create site
|
315
|
-
Nanoc::CLI.run %w( create_site bar)
|
316
|
-
|
317
|
-
FileUtils.cd('bar') do
|
318
|
-
# Create item
|
319
|
-
File.open('content/index.html', 'w') do |io|
|
320
|
-
io.write 'Moo!'
|
321
|
-
end
|
322
|
-
|
323
|
-
# Create output file
|
324
|
-
File.open('output/index.html', 'w') do |io|
|
325
|
-
io.write 'Compiled moo!'
|
326
|
-
end
|
327
|
-
|
328
|
-
# Create site
|
329
|
-
site = Nanoc::Site.new('.')
|
330
|
-
site.expects(:compile)
|
331
|
-
|
332
|
-
# Create autocompiler
|
333
|
-
autocompiler = Nanoc::Extra::AutoCompiler.new('.')
|
334
|
-
autocompiler.stubs(:build_site)
|
335
|
-
autocompiler.stubs(:site).returns(site)
|
336
|
-
|
337
|
-
# Serve
|
338
|
-
status, headers, body = autocompiler.instance_eval { call('REQUEST_METHOD' => 'GET', 'PATH_INFO' => '/') }
|
339
|
-
|
340
|
-
# Check response
|
341
|
-
assert_equal(200, status)
|
342
|
-
assert_equal('text/html', headers['Content-Type'])
|
343
|
-
body.each do |b|
|
344
|
-
assert_equal 'Compiled moo!', b
|
345
|
-
end
|
346
|
-
end
|
347
|
-
end
|
348
|
-
end
|
349
|
-
|
350
|
-
def test_serve_with_broken_item
|
351
|
-
if_have 'mime/types', 'rack' do
|
352
|
-
# Create site
|
353
|
-
Nanoc::CLI.run %w( create_site bar)
|
354
|
-
|
355
|
-
FileUtils.cd('bar') do
|
356
|
-
# Create item
|
357
|
-
File.open('content/whatever.html', 'w') do |io|
|
358
|
-
io.write 'Whatever!'
|
359
|
-
end
|
360
|
-
|
361
|
-
# Create site
|
362
|
-
site = Nanoc::Site.new('.')
|
363
|
-
site.expects(:compile).raises(RuntimeError, 'aah! fail!')
|
364
|
-
|
365
|
-
# Create autocompiler
|
366
|
-
autocompiler = Nanoc::Extra::AutoCompiler.new('.')
|
367
|
-
autocompiler.stubs(:build_site)
|
368
|
-
autocompiler.stubs(:site).returns(site)
|
369
|
-
|
370
|
-
# Serve
|
371
|
-
assert_raises(RuntimeError) do
|
372
|
-
autocompiler.instance_eval { call('REQUEST_METHOD' => 'GET', 'PATH_INFO' => '/whatever/') }
|
373
|
-
end
|
374
|
-
end
|
375
|
-
end
|
376
|
-
end
|
377
|
-
|
378
|
-
def test_reload_config_file_before_each_request
|
379
|
-
if_have 'mime/types', 'rack' do
|
380
|
-
# Create site
|
381
|
-
Nanoc::CLI.run %w( create_site foo )
|
382
|
-
|
383
|
-
FileUtils.cd('foo') do
|
384
|
-
# Create item that outputs config elements
|
385
|
-
File.open('content/index.html', 'w') do |io|
|
386
|
-
io.write 'The Grand Value of Configuration is <%= @config[:value] %>!'
|
387
|
-
end
|
388
|
-
|
389
|
-
# Create autocompiler
|
390
|
-
autocompiler = Nanoc::Extra::AutoCompiler.new('.')
|
391
|
-
|
392
|
-
# Set config to 1st value
|
393
|
-
File.open('nanoc.yaml', 'w') do |io|
|
394
|
-
io.write 'value: Foo'
|
395
|
-
end
|
396
|
-
File.utime(Time.now + 5, Time.now + 5, 'nanoc.yaml')
|
397
|
-
|
398
|
-
# Check
|
399
|
-
_status, _headers, body = autocompiler.call('REQUEST_METHOD' => 'GET', 'PATH_INFO' => '/')
|
400
|
-
body.each do |b|
|
401
|
-
assert_match(/The Grand Value of Configuration is Foo!/, b)
|
402
|
-
end
|
403
|
-
|
404
|
-
# Set config to 2nd value
|
405
|
-
File.open('nanoc.yaml', 'w') do |io|
|
406
|
-
io.write 'value: Bar'
|
407
|
-
end
|
408
|
-
File.utime(Time.now + 5, Time.now + 5, 'nanoc.yaml')
|
409
|
-
|
410
|
-
# Check
|
411
|
-
_status, _headers, body = autocompiler.call('REQUEST_METHOD' => 'GET', 'PATH_INFO' => '/')
|
412
|
-
body.each do |b|
|
413
|
-
assert_match(/The Grand Value of Configuration is Bar!/, b)
|
414
|
-
end
|
415
|
-
end
|
416
|
-
end
|
417
|
-
end
|
418
|
-
|
419
|
-
def test_call_with_uri_encoded_path
|
420
|
-
if_have 'rack' do
|
421
|
-
# Create autocompiler
|
422
|
-
autocompiler = Nanoc::Extra::AutoCompiler.new('.')
|
423
|
-
|
424
|
-
# Mock dependencies
|
425
|
-
site = mock
|
426
|
-
site.stubs(:config).returns({ output_dir: 'output/' })
|
427
|
-
site.stubs(:items).returns([])
|
428
|
-
autocompiler.stubs(:build_site)
|
429
|
-
autocompiler.stubs(:site).returns(site)
|
430
|
-
|
431
|
-
# Test
|
432
|
-
result = autocompiler.call('REQUEST_METHOD' => 'GET', 'PATH_INFO' => '/%73oftware')
|
433
|
-
assert_equal 404, result[0]
|
434
|
-
assert_match("File not found: /software\n", result[2][0])
|
435
|
-
end
|
436
|
-
end
|
437
|
-
end
|