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
@@ -1,10 +1,12 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
-
module Nanoc
|
3
|
+
module Nanoc::Int
|
4
4
|
# Creates checksums for given objects.
|
5
5
|
#
|
6
6
|
# A checksum is a string, such as “mL+TaqNsEeiPkWloPgCtAofT1yg=”, that is used
|
7
7
|
# to determine whether a piece of data has changed.
|
8
|
+
#
|
9
|
+
# @api private
|
8
10
|
class Checksummer
|
9
11
|
class << self
|
10
12
|
# @param obj The object to create a checksum for
|
@@ -49,11 +51,11 @@ module Nanoc
|
|
49
51
|
else
|
50
52
|
digest.update('???')
|
51
53
|
end
|
52
|
-
when Nanoc::RulesCollection
|
54
|
+
when Nanoc::Int::RulesCollection
|
53
55
|
update(obj.data, digest)
|
54
|
-
when Nanoc::CodeSnippet
|
56
|
+
when Nanoc::Int::CodeSnippet
|
55
57
|
update(obj.data, digest)
|
56
|
-
when Nanoc::Item, Nanoc::Layout
|
58
|
+
when Nanoc::Int::Item, Nanoc::Int::Layout
|
57
59
|
digest.update('content')
|
58
60
|
if obj.respond_to?(:binary?) && obj.binary?
|
59
61
|
update(Pathname.new(obj.raw_filename), digest)
|
@@ -1,12 +1,12 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
-
module Nanoc
|
3
|
+
module Nanoc::Int
|
4
4
|
# Stores checksums for objects in order to be able to detect whether a file
|
5
5
|
# has changed since the last site compilation.
|
6
6
|
#
|
7
7
|
# @api private
|
8
|
-
class ChecksumStore < ::Nanoc::Store
|
9
|
-
# @option params [Nanoc::Site] site The site where this checksum store
|
8
|
+
class ChecksumStore < ::Nanoc::Int::Store
|
9
|
+
# @option params [Nanoc::Int::Site] site The site where this checksum store
|
10
10
|
# belongs to
|
11
11
|
def initialize(params = {})
|
12
12
|
super('tmp/checksums', 1)
|
@@ -35,7 +35,7 @@ module Nanoc
|
|
35
35
|
@checksums[obj.reference] = checksum
|
36
36
|
end
|
37
37
|
|
38
|
-
# @see Nanoc::Store#unload
|
38
|
+
# @see Nanoc::Int::Store#unload
|
39
39
|
def unload
|
40
40
|
@checksums = {}
|
41
41
|
end
|
@@ -1,11 +1,11 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
-
module Nanoc
|
3
|
+
module Nanoc::Int
|
4
4
|
# Represents a cache than can be used to store already compiled content,
|
5
5
|
# to prevent it from being needlessly recompiled.
|
6
6
|
#
|
7
7
|
# @api private
|
8
|
-
class CompiledContentCache < ::Nanoc::Store
|
8
|
+
class CompiledContentCache < ::Nanoc::Int::Store
|
9
9
|
def initialize
|
10
10
|
super('tmp/compiled_content', 1)
|
11
11
|
|
@@ -17,7 +17,7 @@ module Nanoc
|
|
17
17
|
# are the snapshot names and the values the compiled content at the
|
18
18
|
# given snapshot.
|
19
19
|
#
|
20
|
-
# @param [Nanoc::ItemRep] rep The item rep to fetch the content for
|
20
|
+
# @param [Nanoc::Int::ItemRep] rep The item rep to fetch the content for
|
21
21
|
#
|
22
22
|
# @return [Hash<Symbol,String>] A hash containing the cached compiled
|
23
23
|
# content for the given item representation
|
@@ -28,7 +28,7 @@ module Nanoc
|
|
28
28
|
|
29
29
|
# Sets the compiled content for the given representation.
|
30
30
|
#
|
31
|
-
# @param [Nanoc::ItemRep] rep The item representation for which to set
|
31
|
+
# @param [Nanoc::Int::ItemRep] rep The item representation for which to set
|
32
32
|
# the compiled content
|
33
33
|
#
|
34
34
|
# @param [Hash<Symbol,String>] content A hash containing the compiled
|
@@ -40,7 +40,7 @@ module Nanoc
|
|
40
40
|
@cache[rep.item.identifier][rep.name] = content
|
41
41
|
end
|
42
42
|
|
43
|
-
# @see Nanoc::Store#unload
|
43
|
+
# @see Nanoc::Int::Store#unload
|
44
44
|
def unload
|
45
45
|
@cache = {}
|
46
46
|
end
|
@@ -1,10 +1,10 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
-
module Nanoc
|
3
|
+
module Nanoc::Int
|
4
4
|
# Responsible for compiling a site’s item representations.
|
5
5
|
#
|
6
6
|
# The compilation process makes use of notifications (see
|
7
|
-
# {Nanoc::NotificationCenter}) to track dependencies between items,
|
7
|
+
# {Nanoc::Int::NotificationCenter}) to track dependencies between items,
|
8
8
|
# layouts, etc. The following notifications are used:
|
9
9
|
#
|
10
10
|
# * `compilation_started` — indicates that the compiler has started
|
@@ -37,12 +37,14 @@ module Nanoc
|
|
37
37
|
#
|
38
38
|
# * `processing_ended` — indicates that the compiler has finished processing
|
39
39
|
# the specified object.
|
40
|
+
#
|
41
|
+
# @api private
|
40
42
|
class Compiler
|
41
|
-
extend Nanoc::Memoization
|
43
|
+
extend Nanoc::Int::Memoization
|
42
44
|
|
43
45
|
# @group Accessors
|
44
46
|
|
45
|
-
# @return [Nanoc::Site] The site this compiler belongs to
|
47
|
+
# @return [Nanoc::Int::Site] The site this compiler belongs to
|
46
48
|
attr_reader :site
|
47
49
|
|
48
50
|
# The compilation stack. When the compiler begins compiling a rep or a
|
@@ -56,7 +58,7 @@ module Nanoc
|
|
56
58
|
|
57
59
|
# Creates a new compiler fo the given site
|
58
60
|
#
|
59
|
-
# @param [Nanoc::Site] site The site this compiler belongs to
|
61
|
+
# @param [Nanoc::Int::Site] site The site this compiler belongs to
|
60
62
|
def initialize(site)
|
61
63
|
@site = site
|
62
64
|
|
@@ -88,25 +90,23 @@ module Nanoc
|
|
88
90
|
dependency_tracker.stop
|
89
91
|
store
|
90
92
|
ensure
|
91
|
-
Nanoc::TempFilenameFactory.instance.cleanup(
|
93
|
+
Nanoc::Int::TempFilenameFactory.instance.cleanup(
|
92
94
|
Nanoc::Filter::TMP_BINARY_ITEMS_DIR)
|
93
|
-
Nanoc::TempFilenameFactory.instance.cleanup(
|
94
|
-
Nanoc::ItemRep::TMP_TEXT_ITEMS_DIR)
|
95
|
+
Nanoc::Int::TempFilenameFactory.instance.cleanup(
|
96
|
+
Nanoc::Int::ItemRep::TMP_TEXT_ITEMS_DIR)
|
95
97
|
end
|
96
98
|
|
97
99
|
# @group Private instance methods
|
98
100
|
|
99
|
-
# @return [Nanoc::RulesCollection] The collection of rules to be used
|
101
|
+
# @return [Nanoc::Int::RulesCollection] The collection of rules to be used
|
100
102
|
# for compiling this site
|
101
103
|
def rules_collection
|
102
|
-
Nanoc::RulesCollection.new(self)
|
104
|
+
Nanoc::Int::RulesCollection.new(self)
|
103
105
|
end
|
104
106
|
memoize :rules_collection
|
105
107
|
|
106
108
|
# Load the helper data that is used for compiling the site.
|
107
109
|
#
|
108
|
-
# @api private
|
109
|
-
#
|
110
110
|
# @return [void]
|
111
111
|
def load
|
112
112
|
return if @loaded || @loading
|
@@ -135,8 +135,6 @@ module Nanoc
|
|
135
135
|
|
136
136
|
# Undoes the effects of {#load}. Used when {#load} raises an exception.
|
137
137
|
#
|
138
|
-
# @api private
|
139
|
-
#
|
140
138
|
# @return [void]
|
141
139
|
def unload
|
142
140
|
return if @unloading
|
@@ -158,8 +156,6 @@ module Nanoc
|
|
158
156
|
|
159
157
|
# Store the modified helper data used for compiling the site.
|
160
158
|
#
|
161
|
-
# @api private
|
162
|
-
#
|
163
159
|
# @return [void]
|
164
160
|
def store
|
165
161
|
# Calculate rule memory
|
@@ -169,7 +165,7 @@ module Nanoc
|
|
169
165
|
|
170
166
|
# Calculate checksums
|
171
167
|
objects.each do |obj|
|
172
|
-
checksum_store[obj] = obj.
|
168
|
+
checksum_store[obj] = obj.__nanoc_checksum
|
173
169
|
end
|
174
170
|
|
175
171
|
# Store
|
@@ -179,11 +175,9 @@ module Nanoc
|
|
179
175
|
# Returns the dependency tracker for this site, creating it first if it
|
180
176
|
# does not yet exist.
|
181
177
|
#
|
182
|
-
# @
|
183
|
-
#
|
184
|
-
# @return [Nanoc::DependencyTracker] The dependency tracker for this site
|
178
|
+
# @return [Nanoc::Int::DependencyTracker] The dependency tracker for this site
|
185
179
|
def dependency_tracker
|
186
|
-
dt = Nanoc::DependencyTracker.new(@site.items + @site.layouts)
|
180
|
+
dt = Nanoc::Int::DependencyTracker.new(@site.items + @site.layouts)
|
187
181
|
dt.compiler = self
|
188
182
|
dt
|
189
183
|
end
|
@@ -215,12 +209,12 @@ module Nanoc
|
|
215
209
|
items.each do |item|
|
216
210
|
# Find matching rules
|
217
211
|
matching_rules = rules_collection.item_compilation_rules_for(item)
|
218
|
-
raise Nanoc::Errors::NoMatchingCompilationRuleFound.new(item) if matching_rules.empty?
|
212
|
+
raise Nanoc::Int::Errors::NoMatchingCompilationRuleFound.new(item) if matching_rules.empty?
|
219
213
|
|
220
214
|
# Create reps
|
221
215
|
rep_names = matching_rules.map(&:rep_name).uniq
|
222
216
|
rep_names.each do |rep_name|
|
223
|
-
item.reps << ItemRep.new(item, rep_name)
|
217
|
+
item.reps << Nanoc::Int::ItemRep.new(item, rep_name)
|
224
218
|
end
|
225
219
|
end
|
226
220
|
end
|
@@ -232,7 +226,7 @@ module Nanoc
|
|
232
226
|
reps.each do |rep|
|
233
227
|
# Find matching rules
|
234
228
|
rules = rules_collection.routing_rules_for(rep)
|
235
|
-
raise Nanoc::Errors::NoMatchingRoutingRuleFound.new(rep) if rules[:last].nil?
|
229
|
+
raise Nanoc::Int::Errors::NoMatchingRoutingRuleFound.new(rep) if rules[:last].nil?
|
236
230
|
|
237
231
|
rules.each_pair do |snapshot, rule|
|
238
232
|
# Get basic path by applying matching rule
|
@@ -259,7 +253,7 @@ module Nanoc
|
|
259
253
|
end
|
260
254
|
end
|
261
255
|
|
262
|
-
# @param [Nanoc::ItemRep] rep The item representation for which the
|
256
|
+
# @param [Nanoc::Int::ItemRep] rep The item representation for which the
|
263
257
|
# assigns should be fetched
|
264
258
|
#
|
265
259
|
# @return [Hash] The assigns that should be used in the next filter/layout
|
@@ -273,20 +267,21 @@ module Nanoc
|
|
273
267
|
content_or_filename_assigns = { content: rep.content[:last] }
|
274
268
|
end
|
275
269
|
|
270
|
+
# TODO: Do not expose @site (necessary for captures store though…)
|
276
271
|
content_or_filename_assigns.merge({
|
277
|
-
item: rep.item,
|
278
|
-
rep: rep,
|
279
|
-
item_rep: rep,
|
280
|
-
items: site.items,
|
281
|
-
layouts: site.layouts,
|
282
|
-
config: site.config,
|
283
|
-
site: site
|
272
|
+
item: Nanoc::ItemView.new(rep.item),
|
273
|
+
rep: Nanoc::ItemRepView.new(rep),
|
274
|
+
item_rep: Nanoc::ItemRepView.new(rep),
|
275
|
+
items: Nanoc::ItemCollectionView.new(site.items),
|
276
|
+
layouts: Nanoc::LayoutCollectionView.new(site.layouts),
|
277
|
+
config: Nanoc::ConfigView.new(site.config),
|
278
|
+
site: Nanoc::SiteView.new(site),
|
284
279
|
})
|
285
280
|
end
|
286
281
|
|
287
|
-
# @return [Nanoc::OutdatednessChecker] The outdatedness checker
|
282
|
+
# @return [Nanoc::Int::OutdatednessChecker] The outdatedness checker
|
288
283
|
def outdatedness_checker
|
289
|
-
Nanoc::OutdatednessChecker.new(
|
284
|
+
Nanoc::Int::OutdatednessChecker.new(
|
290
285
|
site: @site,
|
291
286
|
checksum_store: checksum_store,
|
292
287
|
dependency_tracker: dependency_tracker)
|
@@ -295,19 +290,19 @@ module Nanoc
|
|
295
290
|
|
296
291
|
private
|
297
292
|
|
298
|
-
# @return [Array<Nanoc::Item>] The site’s items
|
293
|
+
# @return [Array<Nanoc::Int::Item>] The site’s items
|
299
294
|
def items
|
300
295
|
@site.items
|
301
296
|
end
|
302
297
|
memoize :items
|
303
298
|
|
304
|
-
# @return [Array<Nanoc::ItemRep>] The site’s item representations
|
299
|
+
# @return [Array<Nanoc::Int::ItemRep>] The site’s item representations
|
305
300
|
def reps
|
306
301
|
items.map(&:reps).flatten
|
307
302
|
end
|
308
303
|
memoize :reps
|
309
304
|
|
310
|
-
# @return [Array<Nanoc::Layout>] The site’s layouts
|
305
|
+
# @return [Array<Nanoc::Int::Layout>] The site’s layouts
|
311
306
|
def layouts
|
312
307
|
@site.layouts
|
313
308
|
end
|
@@ -319,11 +314,11 @@ module Nanoc
|
|
319
314
|
#
|
320
315
|
# @return [void]
|
321
316
|
def compile_reps(reps)
|
322
|
-
content_dependency_graph = Nanoc::DirectedGraph.new(reps)
|
317
|
+
content_dependency_graph = Nanoc::Int::DirectedGraph.new(reps)
|
323
318
|
|
324
319
|
# Listen to processing start/stop
|
325
|
-
Nanoc::NotificationCenter.on(:processing_started, self) { |obj| @stack.push(obj) }
|
326
|
-
Nanoc::NotificationCenter.on(:processing_ended, self) { |_obj| @stack.pop }
|
320
|
+
Nanoc::Int::NotificationCenter.on(:processing_started, self) { |obj| @stack.push(obj) }
|
321
|
+
Nanoc::Int::NotificationCenter.on(:processing_ended, self) { |_obj| @stack.pop }
|
327
322
|
|
328
323
|
# Assign snapshots
|
329
324
|
reps.each do |rep|
|
@@ -340,7 +335,7 @@ module Nanoc
|
|
340
335
|
begin
|
341
336
|
compile_rep(rep)
|
342
337
|
content_dependency_graph.delete_vertex(rep)
|
343
|
-
rescue Nanoc::Errors::UnmetDependency => e
|
338
|
+
rescue Nanoc::Int::Errors::UnmetDependency => e
|
344
339
|
content_dependency_graph.add_edge(e.rep, rep)
|
345
340
|
unless content_dependency_graph.vertices.include?(e.rep)
|
346
341
|
content_dependency_graph.add_vertex(e.rep)
|
@@ -350,33 +345,33 @@ module Nanoc
|
|
350
345
|
|
351
346
|
# Check whether everything was compiled
|
352
347
|
unless content_dependency_graph.vertices.empty?
|
353
|
-
raise Nanoc::Errors::RecursiveCompilation.new(content_dependency_graph.vertices)
|
348
|
+
raise Nanoc::Int::Errors::RecursiveCompilation.new(content_dependency_graph.vertices)
|
354
349
|
end
|
355
350
|
ensure
|
356
|
-
Nanoc::NotificationCenter.remove(:processing_started, self)
|
357
|
-
Nanoc::NotificationCenter.remove(:processing_ended, self)
|
351
|
+
Nanoc::Int::NotificationCenter.remove(:processing_started, self)
|
352
|
+
Nanoc::Int::NotificationCenter.remove(:processing_ended, self)
|
358
353
|
end
|
359
354
|
|
360
355
|
# Compiles the given item representation.
|
361
356
|
#
|
362
357
|
# This method should not be called directly; please use
|
363
|
-
# {Nanoc::Compiler#run} instead, and pass this item representation's item
|
358
|
+
# {Nanoc::Int::Compiler#run} instead, and pass this item representation's item
|
364
359
|
# as its first argument.
|
365
360
|
#
|
366
|
-
# @param [Nanoc::ItemRep] rep The rep that is to be compiled
|
361
|
+
# @param [Nanoc::Int::ItemRep] rep The rep that is to be compiled
|
367
362
|
#
|
368
363
|
# @return [void]
|
369
364
|
def compile_rep(rep)
|
370
|
-
Nanoc::NotificationCenter.post(:compilation_started, rep)
|
371
|
-
Nanoc::NotificationCenter.post(:processing_started, rep)
|
372
|
-
Nanoc::NotificationCenter.post(:visit_started, rep.item)
|
365
|
+
Nanoc::Int::NotificationCenter.post(:compilation_started, rep)
|
366
|
+
Nanoc::Int::NotificationCenter.post(:processing_started, rep)
|
367
|
+
Nanoc::Int::NotificationCenter.post(:visit_started, rep.item)
|
373
368
|
|
374
369
|
# Calculate rule memory if we haven’t yet done do
|
375
370
|
rules_collection.new_rule_memory_for_rep(rep)
|
376
371
|
|
377
372
|
if !rep.item.forced_outdated? && !outdatedness_checker.outdated?(rep) && compiled_content_cache[rep]
|
378
373
|
# Reuse content
|
379
|
-
Nanoc::NotificationCenter.post(:cached_content_used, rep)
|
374
|
+
Nanoc::Int::NotificationCenter.post(:cached_content_used, rep)
|
380
375
|
rep.content = compiled_content_cache[rep]
|
381
376
|
else
|
382
377
|
# Recalculate content
|
@@ -390,19 +385,19 @@ module Nanoc
|
|
390
385
|
rep.compiled = true
|
391
386
|
compiled_content_cache[rep] = rep.content
|
392
387
|
|
393
|
-
Nanoc::NotificationCenter.post(:processing_ended, rep)
|
394
|
-
Nanoc::NotificationCenter.post(:compilation_ended, rep)
|
388
|
+
Nanoc::Int::NotificationCenter.post(:processing_ended, rep)
|
389
|
+
Nanoc::Int::NotificationCenter.post(:compilation_ended, rep)
|
395
390
|
rescue => e
|
396
391
|
rep.forget_progress
|
397
|
-
Nanoc::NotificationCenter.post(:compilation_failed, rep, e)
|
392
|
+
Nanoc::Int::NotificationCenter.post(:compilation_failed, rep, e)
|
398
393
|
raise e
|
399
394
|
ensure
|
400
|
-
Nanoc::NotificationCenter.post(:visit_ended, rep.item)
|
395
|
+
Nanoc::Int::NotificationCenter.post(:visit_ended, rep.item)
|
401
396
|
end
|
402
397
|
|
403
398
|
# Clears the list of dependencies for items that will be recompiled.
|
404
399
|
#
|
405
|
-
# @param [Array<Nanoc::Item>] items The list of items for which to forget
|
400
|
+
# @param [Array<Nanoc::Int::Item>] items The list of items for which to forget
|
406
401
|
# the dependencies
|
407
402
|
#
|
408
403
|
# @return [void]
|
@@ -416,36 +411,36 @@ module Nanoc
|
|
416
411
|
|
417
412
|
# Returns a preprocessor context, creating one if none exists yet.
|
418
413
|
def preprocessor_context
|
419
|
-
Nanoc::Context.new({
|
420
|
-
site: @site,
|
421
|
-
config: @site.config,
|
422
|
-
items: @site.items,
|
423
|
-
layouts: @site.layouts
|
414
|
+
Nanoc::Int::Context.new({
|
415
|
+
site: Nanoc::SiteView.new(@site), # TODO: remove me
|
416
|
+
config: Nanoc::MutableConfigView.new(@site.config),
|
417
|
+
items: Nanoc::MutableItemCollectionView.new(@site.items),
|
418
|
+
layouts: Nanoc::MutableLayoutCollectionView.new(@site.layouts),
|
424
419
|
})
|
425
420
|
end
|
426
421
|
memoize :preprocessor_context
|
427
422
|
|
428
|
-
# @return [CompiledContentCache] The compiled content cache
|
423
|
+
# @return [Nanoc:Int::CompiledContentCache] The compiled content cache
|
429
424
|
def compiled_content_cache
|
430
|
-
Nanoc::CompiledContentCache.new
|
425
|
+
Nanoc::Int::CompiledContentCache.new
|
431
426
|
end
|
432
427
|
memoize :compiled_content_cache
|
433
428
|
|
434
429
|
# @return [ChecksumStore] The checksum store
|
435
430
|
def checksum_store
|
436
|
-
Nanoc::ChecksumStore.new(site: @site)
|
431
|
+
Nanoc::Int::ChecksumStore.new(site: @site)
|
437
432
|
end
|
438
433
|
memoize :checksum_store
|
439
434
|
|
440
435
|
# @return [RuleMemoryStore] The rule memory store
|
441
436
|
def rule_memory_store
|
442
|
-
Nanoc::RuleMemoryStore.new(site: @site)
|
437
|
+
Nanoc::Int::RuleMemoryStore.new(site: @site)
|
443
438
|
end
|
444
439
|
memoize :rule_memory_store
|
445
440
|
|
446
441
|
# @return [RuleMemoryCalculator] The rule memory calculator
|
447
442
|
def rule_memory_calculator
|
448
|
-
Nanoc::RuleMemoryCalculator.new(rules_collection: rules_collection)
|
443
|
+
Nanoc::Int::RuleMemoryCalculator.new(rules_collection: rules_collection)
|
449
444
|
end
|
450
445
|
memoize :rule_memory_calculator
|
451
446
|
|
@@ -1,18 +1,20 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
-
module Nanoc
|
3
|
+
module Nanoc::Int
|
4
4
|
# Contains methods that will be executed by the site’s `Rules` file.
|
5
5
|
class CompilerDSL
|
6
6
|
# The current rules filename.
|
7
7
|
#
|
8
8
|
# @return [String] The current rules filename.
|
9
|
+
#
|
10
|
+
# @api private
|
9
11
|
attr_accessor :rules_filename
|
10
12
|
|
11
13
|
# Creates a new compiler DSL for the given collection of rules.
|
12
14
|
#
|
13
15
|
# @api private
|
14
16
|
#
|
15
|
-
# @param [Nanoc::RulesCollection] rules_collection The collection of
|
17
|
+
# @param [Nanoc::Int::RulesCollection] rules_collection The collection of
|
16
18
|
# rules to modify when loading this DSL
|
17
19
|
#
|
18
20
|
# @param [Hash] config The site configuration
|
@@ -75,7 +77,7 @@ module Nanoc
|
|
75
77
|
rep_name = params[:rep] || :default
|
76
78
|
|
77
79
|
# Create rule
|
78
|
-
rule = Rule.new(identifier_to_regex(identifier), rep_name, block)
|
80
|
+
rule = Nanoc::Int::Rule.new(identifier_to_regex(identifier), rep_name, block)
|
79
81
|
@rules_collection.add_item_compilation_rule(rule)
|
80
82
|
end
|
81
83
|
|
@@ -120,7 +122,7 @@ module Nanoc
|
|
120
122
|
snapshot_name = params[:snapshot] || :last
|
121
123
|
|
122
124
|
# Create rule
|
123
|
-
rule = Rule.new(identifier_to_regex(identifier), rep_name, block, snapshot_name: snapshot_name)
|
125
|
+
rule = Nanoc::Int::Rule.new(identifier_to_regex(identifier), rep_name, block, snapshot_name: snapshot_name)
|
124
126
|
@rules_collection.add_item_routing_rule(rule)
|
125
127
|
end
|
126
128
|
|
@@ -186,7 +188,7 @@ module Nanoc
|
|
186
188
|
|
187
189
|
# Create compilation rule
|
188
190
|
compilation_block = proc {}
|
189
|
-
compilation_rule = Rule.new(identifier_to_regex(identifier), rep_name, compilation_block)
|
191
|
+
compilation_rule = Nanoc::Int::Rule.new(identifier_to_regex(identifier), rep_name, compilation_block)
|
190
192
|
@rules_collection.add_item_compilation_rule(compilation_rule)
|
191
193
|
|
192
194
|
# Create routing rule
|
@@ -197,7 +199,7 @@ module Nanoc
|
|
197
199
|
# data source.
|
198
200
|
item[:extension].nil? || (item[:content_filename].nil? && item.identifier =~ %r{#{item[:extension]}/$}) ? item.identifier.chop : item.identifier.chop + '.' + item[:extension]
|
199
201
|
end
|
200
|
-
routing_rule = Rule.new(identifier_to_regex(identifier), rep_name, routing_block, snapshot_name: :last)
|
202
|
+
routing_rule = Nanoc::Int::Rule.new(identifier_to_regex(identifier), rep_name, routing_block, snapshot_name: :last)
|
201
203
|
@rules_collection.add_item_routing_rule(routing_rule)
|
202
204
|
end
|
203
205
|
|
@@ -225,10 +227,10 @@ module Nanoc
|
|
225
227
|
|
226
228
|
rep_name = params[:rep] || :default
|
227
229
|
|
228
|
-
compilation_rule = Rule.new(identifier_to_regex(identifier), rep_name, proc {})
|
230
|
+
compilation_rule = Nanoc::Int::Rule.new(identifier_to_regex(identifier), rep_name, proc {})
|
229
231
|
@rules_collection.add_item_compilation_rule(compilation_rule)
|
230
232
|
|
231
|
-
routing_rule = Rule.new(identifier_to_regex(identifier), rep_name, proc {}, snapshot_name: :last)
|
233
|
+
routing_rule = Nanoc::Int::Rule.new(identifier_to_regex(identifier), rep_name, proc {}, snapshot_name: :last)
|
232
234
|
@rules_collection.add_item_routing_rule(routing_rule)
|
233
235
|
end
|
234
236
|
|
@@ -246,7 +248,7 @@ module Nanoc
|
|
246
248
|
# include_rules 'rules/content'
|
247
249
|
def include_rules(name)
|
248
250
|
filename = ["#{name}", "#{name}.rb", "./#{name}", "./#{name}.rb"].find { |f| File.file?(f) }
|
249
|
-
raise Nanoc::Errors::NoRulesFileFound.new if filename.nil?
|
251
|
+
raise Nanoc::Int::Errors::NoRulesFileFound.new if filename.nil?
|
250
252
|
|
251
253
|
@rules_collection.parse(filename)
|
252
254
|
end
|