nanoc 4.0.2 → 4.1.0a1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CONTRIBUTING.md +17 -0
- data/Gemfile +50 -46
- data/Gemfile.lock +365 -0
- data/Guardfile +3 -0
- data/NEWS.md +21 -0
- data/README.md +1 -1
- data/lib/nanoc/base.rb +3 -15
- data/lib/nanoc/base/checksummer.rb +3 -14
- data/lib/nanoc/base/compilation/compiler.rb +112 -283
- data/lib/nanoc/base/compilation/compiler_dsl.rb +29 -37
- data/lib/nanoc/base/compilation/dependency_tracker.rb +25 -170
- data/lib/nanoc/base/compilation/filter.rb +3 -4
- data/lib/nanoc/base/compilation/item_rep_repo.rb +33 -0
- data/lib/nanoc/base/compilation/outdatedness_checker.rb +39 -53
- data/lib/nanoc/base/compilation/rule.rb +13 -24
- data/lib/nanoc/base/compilation/rule_context.rb +29 -15
- data/lib/nanoc/base/entities.rb +10 -0
- data/lib/nanoc/base/{source_data → entities}/code_snippet.rb +1 -4
- data/lib/nanoc/base/{source_data → entities}/configuration.rb +1 -1
- data/lib/nanoc/base/entities/content.rb +8 -9
- data/lib/nanoc/base/{identifiable_collection.rb → entities/identifiable_collection.rb} +0 -0
- data/lib/nanoc/base/entities/identifier.rb +11 -2
- data/lib/nanoc/base/{source_data → entities}/item.rb +0 -18
- data/lib/nanoc/base/{result_data → entities}/item_rep.rb +15 -13
- data/lib/nanoc/base/entities/rule_memory.rb +54 -0
- data/lib/nanoc/base/entities/rule_memory_action.rb +19 -0
- data/lib/nanoc/base/entities/rule_memory_actions.rb +3 -0
- data/lib/nanoc/base/entities/rule_memory_actions/filter.rb +22 -0
- data/lib/nanoc/base/entities/rule_memory_actions/layout.rb +22 -0
- data/lib/nanoc/base/entities/rule_memory_actions/snapshot.rb +26 -0
- data/lib/nanoc/base/entities/rules_collection.rb +120 -0
- data/lib/nanoc/base/{source_data → entities}/site.rb +11 -10
- data/lib/nanoc/base/repos.rb +2 -0
- data/lib/nanoc/base/repos/checksum_store.rb +3 -9
- data/lib/nanoc/base/repos/compiled_content_cache.rb +0 -5
- data/lib/nanoc/base/{source_data → repos}/data_source.rb +3 -6
- data/lib/nanoc/base/repos/dependency_store.rb +118 -0
- data/lib/nanoc/base/repos/rule_memory_store.rb +1 -5
- data/lib/nanoc/base/repos/site_loader.rb +0 -28
- data/lib/nanoc/base/repos/store.rb +0 -12
- data/lib/nanoc/base/services.rb +8 -0
- data/lib/nanoc/base/services/compiler_loader.rb +49 -0
- data/lib/nanoc/base/services/executor.rb +4 -4
- data/lib/nanoc/base/services/item_rep_builder.rb +30 -0
- data/lib/nanoc/base/services/item_rep_router.rb +55 -0
- data/lib/nanoc/base/services/item_rep_selector.rb +39 -0
- data/lib/nanoc/base/services/item_rep_writer.rb +2 -0
- data/lib/nanoc/base/services/postprocessor.rb +26 -0
- data/lib/nanoc/base/services/preprocessor.rb +26 -0
- data/lib/nanoc/base/services/recording_executor.rb +36 -22
- data/lib/nanoc/base/services/rule_memory_calculator.rb +84 -0
- data/lib/nanoc/base/services/rules_loader.rb +29 -0
- data/lib/nanoc/base/views.rb +6 -0
- data/lib/nanoc/base/views/config_view.rb +8 -2
- data/lib/nanoc/base/views/identifiable_collection_view.rb +5 -4
- data/lib/nanoc/base/views/item_rep_collection_view.rb +7 -6
- data/lib/nanoc/base/views/item_rep_view.rb +13 -12
- data/lib/nanoc/base/views/item_view.rb +18 -12
- data/lib/nanoc/base/views/layout_view.rb +1 -1
- data/lib/nanoc/base/views/mixins/document_view_mixin.rb +2 -1
- data/lib/nanoc/base/views/mutable_identifiable_collection_view.rb +1 -1
- data/lib/nanoc/base/views/mutable_item_collection_view.rb +4 -7
- data/lib/nanoc/base/views/post_compile_item_collection_view.rb +8 -0
- data/lib/nanoc/base/views/post_compile_item_view.rb +7 -0
- data/lib/nanoc/base/views/site_view.rb +3 -2
- data/lib/nanoc/base/views/view.rb +12 -0
- data/lib/nanoc/base/views/view_context.rb +12 -0
- data/lib/nanoc/cli/commands/compile.rb +13 -15
- data/lib/nanoc/cli/commands/create-site.rb +15 -0
- data/lib/nanoc/cli/commands/prune.rb +1 -1
- data/lib/nanoc/cli/commands/shell.rb +3 -3
- data/lib/nanoc/cli/commands/show-data.rb +5 -5
- data/lib/nanoc/cli/commands/show-rules.rb +2 -1
- data/lib/nanoc/cli/error_handler.rb +28 -30
- data/lib/nanoc/cli/stream_cleaners/ansi_colors.rb +1 -1
- data/lib/nanoc/data_sources/filesystem.rb +1 -1
- data/lib/nanoc/extra/checking/check.rb +8 -7
- data/lib/nanoc/extra/checking/checks/external_links.rb +14 -1
- data/lib/nanoc/extra/checking/runner.rb +1 -1
- data/lib/nanoc/extra/deployer.rb +3 -3
- data/lib/nanoc/extra/piper.rb +5 -5
- data/lib/nanoc/extra/pruner.rb +8 -7
- data/lib/nanoc/filters/relativize_paths.rb +48 -32
- data/lib/nanoc/filters/sass/sass_filesystem_importer.rb +0 -1
- data/lib/nanoc/helpers/blogging.rb +15 -7
- data/lib/nanoc/helpers/capturing.rb +56 -13
- data/lib/nanoc/helpers/link_to.rb +2 -2
- data/lib/nanoc/helpers/tagging.rb +5 -10
- data/lib/nanoc/helpers/text.rb +9 -11
- data/lib/nanoc/version.rb +1 -1
- data/nanoc-4.0.2.gem +0 -0
- data/tags +1175 -0
- data/test/base/test_compiler.rb +48 -98
- data/test/base/test_compiler_dsl.rb +113 -39
- data/test/base/test_dependency_tracker.rb +80 -79
- data/test/base/test_outdatedness_checker.rb +39 -26
- data/test/base/test_site.rb +0 -97
- data/test/cli/commands/test_compile.rb +2 -3
- data/test/extra/checking/checks/test_external_links.rb +25 -0
- data/test/extra/deployers/test_fog.rb +12 -6
- data/test/filters/test_erb.rb +1 -1
- data/test/filters/test_erubis.rb +1 -1
- data/test/filters/test_haml.rb +1 -1
- data/test/filters/test_less.rb +4 -4
- data/test/filters/test_sass.rb +1 -0
- data/test/filters/test_xsl.rb +7 -8
- data/test/helper.rb +0 -2
- data/test/helpers/test_blogging.rb +26 -23
- data/test/helpers/test_capturing.rb +131 -12
- data/test/helpers/test_filtering.rb +6 -6
- data/test/helpers/test_link_to.rb +1 -1
- data/test/helpers/test_rendering.rb +16 -24
- data/test/helpers/test_tagging.rb +13 -10
- data/test/helpers/test_xml_sitemap.rb +25 -21
- metadata +36 -14
- data/lib/nanoc/base/compilation/rule_memory_calculator.rb +0 -35
- data/lib/nanoc/base/compilation/rules_collection.rb +0 -245
- data/test/base/test_rule_context.rb +0 -78
@@ -27,19 +27,12 @@ module Nanoc::Int
|
|
27
27
|
# @param [Proc] block A block that will be called when matching items are
|
28
28
|
# compiled
|
29
29
|
#
|
30
|
-
# @
|
31
|
-
#
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
raise 'Can only create rules with patterns'
|
37
|
-
end
|
38
|
-
|
39
|
-
@pattern = pattern
|
40
|
-
@rep_name = rep_name.to_sym
|
41
|
-
@snapshot_name = params[:snapshot_name]
|
42
|
-
|
30
|
+
# @param [Symbol, nil] :snapshot The name of the snapshot this rule will
|
31
|
+
# apply to. Ignored for compilation rules, but used for routing rules.
|
32
|
+
def initialize(pattern, rep_name, block, snapshot_name: nil)
|
33
|
+
@pattern = pattern
|
34
|
+
@rep_name = rep_name.to_sym
|
35
|
+
@snapshot_name = snapshot_name
|
43
36
|
@block = block
|
44
37
|
end
|
45
38
|
|
@@ -53,19 +46,15 @@ module Nanoc::Int
|
|
53
46
|
|
54
47
|
# Applies this rule to the given item rep.
|
55
48
|
#
|
56
|
-
# @param [Nanoc::Int::ItemRep] rep
|
57
|
-
#
|
58
|
-
#
|
59
|
-
# @
|
60
|
-
#
|
61
|
-
# @raise [ArgumentError] if no compiler is passed
|
49
|
+
# @param [Nanoc::Int::ItemRep] rep
|
50
|
+
# @param [Nanoc::Int::Site] site
|
51
|
+
# @param [Nanoc::Int::Executor, Nanoc::Int::RecordingExecutor] executor
|
52
|
+
# @param [Nanoc::ViewContext] view_context
|
62
53
|
#
|
63
54
|
# @return [void]
|
64
|
-
def apply_to(rep,
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
context = Nanoc::Int::RuleContext.new(rep: rep, executor: executor, compiler: compiler)
|
55
|
+
def apply_to(rep, site:, executor:, view_context:)
|
56
|
+
context = Nanoc::Int::RuleContext.new(
|
57
|
+
rep: rep, executor: executor, site: site, view_context: view_context)
|
69
58
|
context.instance_exec(matches(rep.item.identifier), &@block)
|
70
59
|
end
|
71
60
|
|
@@ -5,21 +5,21 @@ module Nanoc::Int
|
|
5
5
|
#
|
6
6
|
# @api private
|
7
7
|
class RuleContext < Nanoc::Int::Context
|
8
|
-
# @
|
9
|
-
# @
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
@_executor =
|
8
|
+
# @param [Nanoc::Int::ItemRep] rep
|
9
|
+
# @param [Nanoc::Int::Site] site
|
10
|
+
# @param [Nanoc::Int::Executor, Nanoc::Int::RecordingExecutor] executor
|
11
|
+
# @param [Nanoc::ViewContext] view_context
|
12
|
+
def initialize(rep:, site:, executor:, view_context:)
|
13
|
+
@_executor = executor
|
14
14
|
|
15
15
|
super({
|
16
|
-
item: Nanoc::ItemView.new(rep.item),
|
17
|
-
rep: Nanoc::ItemRepView.new(rep),
|
18
|
-
item_rep: Nanoc::ItemRepView.new(rep),
|
19
|
-
items: Nanoc::ItemCollectionView.new(
|
20
|
-
layouts: Nanoc::LayoutCollectionView.new(
|
21
|
-
config: Nanoc::ConfigView.new(
|
22
|
-
site: Nanoc::SiteView.new(
|
16
|
+
item: Nanoc::ItemView.new(rep.item, view_context),
|
17
|
+
rep: Nanoc::ItemRepView.new(rep, view_context),
|
18
|
+
item_rep: Nanoc::ItemRepView.new(rep, view_context),
|
19
|
+
items: Nanoc::ItemCollectionView.new(site.items, view_context),
|
20
|
+
layouts: Nanoc::LayoutCollectionView.new(site.layouts, view_context),
|
21
|
+
config: Nanoc::ConfigView.new(site.config, view_context),
|
22
|
+
site: Nanoc::SiteView.new(site, view_context),
|
23
23
|
})
|
24
24
|
end
|
25
25
|
|
@@ -59,9 +59,23 @@ module Nanoc::Int
|
|
59
59
|
#
|
60
60
|
# @param [Symbol] snapshot_name The name of the snapshot to create
|
61
61
|
#
|
62
|
+
# @param [String, nil] path
|
63
|
+
#
|
64
|
+
# @return [void]
|
65
|
+
def snapshot(snapshot_name, path: nil)
|
66
|
+
@_executor.snapshot(rep.unwrap, snapshot_name, path: path)
|
67
|
+
end
|
68
|
+
|
69
|
+
# Creates a snapshot named :last the current compiled item content, with
|
70
|
+
# the given path. This is a convenience method for {#snapshot}.
|
71
|
+
#
|
72
|
+
# @see #snapshot
|
73
|
+
#
|
74
|
+
# @param [String] path
|
75
|
+
#
|
62
76
|
# @return [void]
|
63
|
-
def
|
64
|
-
|
77
|
+
def write(path)
|
78
|
+
snapshot(:last, path: path)
|
65
79
|
end
|
66
80
|
end
|
67
81
|
end
|
data/lib/nanoc/base/entities.rb
CHANGED
@@ -1,6 +1,16 @@
|
|
1
|
+
require_relative 'entities/code_snippet'
|
2
|
+
require_relative 'entities/configuration'
|
1
3
|
require_relative 'entities/content'
|
2
4
|
require_relative 'entities/document'
|
3
5
|
require_relative 'entities/identifier'
|
6
|
+
require_relative 'entities/identifiable_collection'
|
7
|
+
require_relative 'entities/item'
|
8
|
+
require_relative 'entities/item_rep'
|
4
9
|
require_relative 'entities/layout'
|
5
10
|
require_relative 'entities/pattern'
|
11
|
+
require_relative 'entities/rule_memory'
|
12
|
+
require_relative 'entities/rule_memory_action'
|
13
|
+
require_relative 'entities/rule_memory_actions'
|
14
|
+
require_relative 'entities/rules_collection'
|
15
|
+
require_relative 'entities/site'
|
6
16
|
require_relative 'entities/snapshot_def'
|
@@ -19,10 +19,7 @@ module Nanoc::Int
|
|
19
19
|
# compilation
|
20
20
|
#
|
21
21
|
# @param [String] filename The filename corresponding to this code snippet
|
22
|
-
|
23
|
-
# @param [Time, Hash] _params Extra parameters. Ignored by Nanoc; it is
|
24
|
-
# only included for backwards compatibility.
|
25
|
-
def initialize(data, filename, _params = nil)
|
22
|
+
def initialize(data, filename)
|
26
23
|
@data = data
|
27
24
|
@filename = filename
|
28
25
|
end
|
@@ -20,7 +20,7 @@ module Nanoc::Int
|
|
20
20
|
# that lacks some options, the default value will be taken from
|
21
21
|
# `DEFAULT_CONFIG`.
|
22
22
|
DEFAULT_CONFIG = {
|
23
|
-
text_extensions: %w( css erb haml htm html js less markdown md php rb sass scss txt xhtml xml coffee hb handlebars mustache ms slim rdoc ).sort,
|
23
|
+
text_extensions: %w( adoc asciidoc atom css erb haml htm html js less markdown md php rb sass scss txt xhtml xml coffee hb handlebars mustache ms slim rdoc ).sort,
|
24
24
|
lib_dirs: %w( lib ),
|
25
25
|
commands_dirs: %w( commands ),
|
26
26
|
output_dir: 'output',
|
@@ -31,20 +31,19 @@ module Nanoc
|
|
31
31
|
# content) or the path to the filename containing the content (if this
|
32
32
|
# is binary content).
|
33
33
|
#
|
34
|
-
# @
|
35
|
-
# binary
|
34
|
+
# @param [Boolean] binary Whether or not this item is binary
|
36
35
|
#
|
37
|
-
# @
|
38
|
-
#
|
39
|
-
def self.create(content,
|
36
|
+
# @param [String] filename Absolute path to the file containing this
|
37
|
+
# content (if any)
|
38
|
+
def self.create(content, binary: false, filename: nil)
|
40
39
|
if content.nil?
|
41
40
|
raise ArgumentError, 'Cannot create nil content'
|
42
41
|
elsif content.is_a?(Nanoc::Int::Content)
|
43
42
|
content
|
44
|
-
elsif
|
43
|
+
elsif binary
|
45
44
|
Nanoc::Int::BinaryContent.new(content)
|
46
45
|
else
|
47
|
-
Nanoc::Int::TextualContent.new(content, filename:
|
46
|
+
Nanoc::Int::TextualContent.new(content, filename: filename)
|
48
47
|
end
|
49
48
|
end
|
50
49
|
|
@@ -61,8 +60,8 @@ module Nanoc
|
|
61
60
|
# @return [String]
|
62
61
|
attr_reader :string
|
63
62
|
|
64
|
-
def initialize(string,
|
65
|
-
super(
|
63
|
+
def initialize(string, filename: nil)
|
64
|
+
super(filename)
|
66
65
|
@string = string
|
67
66
|
end
|
68
67
|
|
File without changes
|
@@ -48,8 +48,8 @@ module Nanoc
|
|
48
48
|
end
|
49
49
|
end
|
50
50
|
|
51
|
-
def initialize(string,
|
52
|
-
@type =
|
51
|
+
def initialize(string, type: :full)
|
52
|
+
@type = type
|
53
53
|
|
54
54
|
case @type
|
55
55
|
when :legacy
|
@@ -161,6 +161,15 @@ module Nanoc
|
|
161
161
|
s ? s.split('.', -1).drop(1) : []
|
162
162
|
end
|
163
163
|
|
164
|
+
def components
|
165
|
+
res = to_s.split('/')
|
166
|
+
if res.empty?
|
167
|
+
[]
|
168
|
+
else
|
169
|
+
res[1..-1]
|
170
|
+
end
|
171
|
+
end
|
172
|
+
|
164
173
|
def to_s
|
165
174
|
@string
|
166
175
|
end
|
@@ -1,31 +1,13 @@
|
|
1
1
|
module Nanoc::Int
|
2
2
|
# @api private
|
3
3
|
class Item < ::Nanoc::Int::Document
|
4
|
-
# @return [Array<Nanoc::Int::ItemRep>] This item’s list of item reps
|
5
|
-
attr_reader :reps
|
6
|
-
|
7
|
-
# @return [Nanoc::Int::Item, nil] The parent item of this item. This can be
|
8
|
-
# nil even for non-root items.
|
9
|
-
attr_accessor :parent
|
10
|
-
|
11
|
-
# @return [Array<Nanoc::Int::Item>] The child items of this item
|
12
|
-
attr_accessor :children
|
13
|
-
|
14
4
|
# @see Document#initialize
|
15
5
|
def initialize(content, attributes, identifier)
|
16
6
|
super
|
17
7
|
|
18
|
-
@parent = nil
|
19
|
-
@children = []
|
20
|
-
@reps = []
|
21
8
|
@forced_outdated_status = ForcedOutdatedStatus.new
|
22
9
|
end
|
23
10
|
|
24
|
-
def freeze
|
25
|
-
super
|
26
|
-
@children.freeze
|
27
|
-
end
|
28
|
-
|
29
11
|
# Returns an object that can be used for uniquely identifying objects.
|
30
12
|
#
|
31
13
|
# @api private
|
@@ -23,6 +23,10 @@ module Nanoc::Int
|
|
23
23
|
# @return [Enumerable<Nanoc::Int:SnapshotDef]
|
24
24
|
attr_accessor :snapshot_defs
|
25
25
|
|
26
|
+
# @return [Boolean]
|
27
|
+
attr_accessor :modified
|
28
|
+
alias_method :modified?, :modified
|
29
|
+
|
26
30
|
# @param [Nanoc::Int::Item] item
|
27
31
|
#
|
28
32
|
# @param [Symbol] name
|
@@ -47,21 +51,21 @@ module Nanoc::Int
|
|
47
51
|
|
48
52
|
# Returns the compiled content from a given snapshot.
|
49
53
|
#
|
50
|
-
# @
|
54
|
+
# @param [Symbol] snapshot The name of the snapshot from which to
|
51
55
|
# fetch the compiled content. By default, the returned compiled content
|
52
56
|
# will be the content compiled right before the first layout call (if
|
53
57
|
# any).
|
54
58
|
#
|
55
59
|
# @return [String] The compiled content at the given snapshot (or the
|
56
60
|
# default snapshot if no snapshot is specified)
|
57
|
-
def compiled_content(
|
61
|
+
def compiled_content(snapshot: nil)
|
58
62
|
# Make sure we're not binary
|
59
63
|
if binary?
|
60
64
|
raise Nanoc::Int::Errors::CannotGetCompiledContentOfBinaryItem.new(self)
|
61
65
|
end
|
62
66
|
|
63
67
|
# Get name of last pre-layout snapshot
|
64
|
-
snapshot_name =
|
68
|
+
snapshot_name = snapshot || (@snapshot_contents[:pre] ? :pre : :last)
|
65
69
|
is_moving = [:pre, :post, :last].include?(snapshot_name)
|
66
70
|
|
67
71
|
# Check existance of snapshot
|
@@ -100,13 +104,12 @@ module Nanoc::Int
|
|
100
104
|
# Returns the item rep’s raw path. It includes the path to the output
|
101
105
|
# directory and the full filename.
|
102
106
|
#
|
103
|
-
# @
|
104
|
-
#
|
107
|
+
# @param [Symbol] snapshot The snapshot for which the path should be
|
108
|
+
# returned
|
105
109
|
#
|
106
110
|
# @return [String] The item rep’s path
|
107
|
-
def raw_path(
|
108
|
-
|
109
|
-
@raw_paths[snapshot_name]
|
111
|
+
def raw_path(snapshot: :last)
|
112
|
+
@raw_paths[snapshot]
|
110
113
|
end
|
111
114
|
|
112
115
|
# Returns the item rep’s path, as used when being linked to. It starts
|
@@ -114,13 +117,12 @@ module Nanoc::Int
|
|
114
117
|
# include the path to the output directory. It will not include the
|
115
118
|
# filename if the filename is an index filename.
|
116
119
|
#
|
117
|
-
# @
|
118
|
-
#
|
120
|
+
# @param [Symbol] snapshot The snapshot for which the path should be
|
121
|
+
# returned
|
119
122
|
#
|
120
123
|
# @return [String] The item rep’s path
|
121
|
-
def path(
|
122
|
-
|
123
|
-
@paths[snapshot_name]
|
124
|
+
def path(snapshot: :last)
|
125
|
+
@paths[snapshot]
|
124
126
|
end
|
125
127
|
|
126
128
|
# Resets the compilation progress for this item representation. This is
|
@@ -0,0 +1,54 @@
|
|
1
|
+
module Nanoc::Int
|
2
|
+
class RuleMemory
|
3
|
+
include Enumerable
|
4
|
+
|
5
|
+
def initialize(item_rep)
|
6
|
+
@item_rep = item_rep
|
7
|
+
@actions = []
|
8
|
+
end
|
9
|
+
|
10
|
+
def size
|
11
|
+
@actions.size
|
12
|
+
end
|
13
|
+
|
14
|
+
def [](idx)
|
15
|
+
@actions[idx]
|
16
|
+
end
|
17
|
+
|
18
|
+
def add_filter(filter_name, params)
|
19
|
+
@actions << Nanoc::Int::RuleMemoryActions::Filter.new(filter_name, params)
|
20
|
+
end
|
21
|
+
|
22
|
+
def add_layout(layout_identifier, params)
|
23
|
+
@actions << Nanoc::Int::RuleMemoryActions::Layout.new(layout_identifier, params)
|
24
|
+
end
|
25
|
+
|
26
|
+
def add_snapshot(snapshot_name, final, path)
|
27
|
+
will_add_snapshot(snapshot_name)
|
28
|
+
@actions << Nanoc::Int::RuleMemoryActions::Snapshot.new(snapshot_name, final, path)
|
29
|
+
end
|
30
|
+
|
31
|
+
def snapshot_actions
|
32
|
+
@actions.select { |a| a.is_a?(Nanoc::Int::RuleMemoryActions::Snapshot) }
|
33
|
+
end
|
34
|
+
|
35
|
+
def serialize
|
36
|
+
map(&:serialize)
|
37
|
+
end
|
38
|
+
|
39
|
+
def each
|
40
|
+
@actions.each { |a| yield(a) }
|
41
|
+
end
|
42
|
+
|
43
|
+
private
|
44
|
+
|
45
|
+
def will_add_snapshot(name)
|
46
|
+
@_snapshot_names ||= Set.new
|
47
|
+
if @_snapshot_names.include?(name)
|
48
|
+
raise Nanoc::Int::Errors::CannotCreateMultipleSnapshotsWithSameName.new(@item_rep, name)
|
49
|
+
else
|
50
|
+
@_snapshot_names << name
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Nanoc::Int
|
2
|
+
class RuleMemoryAction
|
3
|
+
def serialize
|
4
|
+
raise NotImplementedError.new('Nanoc::RuleMemoryAction subclasses must implement #serialize and #to_s')
|
5
|
+
end
|
6
|
+
|
7
|
+
def to_s
|
8
|
+
raise NotImplementedError.new('Nanoc::RuleMemoryAction subclasses must implement #serialize and #to_s')
|
9
|
+
end
|
10
|
+
|
11
|
+
def inspect
|
12
|
+
format(
|
13
|
+
'<%s %s>',
|
14
|
+
self.class.to_s,
|
15
|
+
serialize[1..-1].map(&:inspect).join(', ')
|
16
|
+
)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Nanoc::Int::RuleMemoryActions
|
2
|
+
class Filter < Nanoc::Int::RuleMemoryAction
|
3
|
+
# filter :foo
|
4
|
+
# filter :foo, params
|
5
|
+
|
6
|
+
attr_reader :filter_name
|
7
|
+
attr_reader :params
|
8
|
+
|
9
|
+
def initialize(filter_name, params)
|
10
|
+
@filter_name = filter_name
|
11
|
+
@params = params
|
12
|
+
end
|
13
|
+
|
14
|
+
def serialize
|
15
|
+
[:filter, @filter_name, Nanoc::Int::Checksummer.calc(@params)]
|
16
|
+
end
|
17
|
+
|
18
|
+
def to_s
|
19
|
+
"filter #{@filter_name.inspect}, #{@params.inspect}"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Nanoc::Int::RuleMemoryActions
|
2
|
+
class Layout < Nanoc::Int::RuleMemoryAction
|
3
|
+
# layout '/foo.erb'
|
4
|
+
# layout '/foo.erb', params
|
5
|
+
|
6
|
+
attr_reader :layout_identifier
|
7
|
+
attr_reader :params
|
8
|
+
|
9
|
+
def initialize(layout_identifier, params)
|
10
|
+
@layout_identifier = layout_identifier
|
11
|
+
@params = params
|
12
|
+
end
|
13
|
+
|
14
|
+
def serialize
|
15
|
+
[:layout, @layout_identifier, Nanoc::Int::Checksummer.calc(@params)]
|
16
|
+
end
|
17
|
+
|
18
|
+
def to_s
|
19
|
+
"layout #{@layout_identifier.inspect}, #{@params.inspect}"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|