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
@@ -0,0 +1,26 @@
|
|
1
|
+
module Nanoc::Int::RuleMemoryActions
|
2
|
+
class Snapshot < Nanoc::Int::RuleMemoryAction
|
3
|
+
# snapshot :before_layout
|
4
|
+
# snapshot :before_layout, final: true
|
5
|
+
# snapshot :before_layout, path: '/about.md'
|
6
|
+
|
7
|
+
attr_reader :snapshot_name
|
8
|
+
attr_reader :final
|
9
|
+
attr_reader :path
|
10
|
+
alias_method :final?, :final
|
11
|
+
|
12
|
+
def initialize(snapshot_name, final, path)
|
13
|
+
@snapshot_name = snapshot_name
|
14
|
+
@final = final
|
15
|
+
@path = path
|
16
|
+
end
|
17
|
+
|
18
|
+
def serialize
|
19
|
+
[:snapshot, @snapshot_name, @final, @path]
|
20
|
+
end
|
21
|
+
|
22
|
+
def to_s
|
23
|
+
"snapshot #{@snapshot_name.inspect}, final: #{@final.inspect}, path: #{@path.inspect}"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,120 @@
|
|
1
|
+
module Nanoc::Int
|
2
|
+
# Keeps track of the rules in a site.
|
3
|
+
#
|
4
|
+
# @api private
|
5
|
+
class RulesCollection
|
6
|
+
# @return [String] the contents of the Rules file
|
7
|
+
attr_accessor :data
|
8
|
+
|
9
|
+
# The hash containing layout-to-filter mapping rules. This hash is
|
10
|
+
# ordered: iterating over the hash will happen in insertion order.
|
11
|
+
#
|
12
|
+
# @return [Hash] The layout-to-filter mapping rules
|
13
|
+
attr_reader :layout_filter_mapping
|
14
|
+
|
15
|
+
# The hash containing preprocessor code blocks that will be executed after
|
16
|
+
# all data is loaded but before the site is compiled.
|
17
|
+
#
|
18
|
+
# @return [Hash] The hash containing the preprocessor code blocks that will
|
19
|
+
# be executed after all data is loaded but before the site is compiled
|
20
|
+
attr_accessor :preprocessors
|
21
|
+
|
22
|
+
# The hash containing postprocessor code blocks that will be executed after
|
23
|
+
# all data is loaded and the site is compiled.
|
24
|
+
#
|
25
|
+
# @return [Hash] The hash containing the postprocessor code blocks that will
|
26
|
+
# be executed after all data is loaded and the site is compiled
|
27
|
+
attr_accessor :postprocessors
|
28
|
+
|
29
|
+
def initialize
|
30
|
+
@item_compilation_rules = []
|
31
|
+
@item_routing_rules = []
|
32
|
+
@layout_filter_mapping = {}
|
33
|
+
@preprocessors = {}
|
34
|
+
@postprocessors = {}
|
35
|
+
end
|
36
|
+
|
37
|
+
# Add the given rule to the list of item compilation rules.
|
38
|
+
#
|
39
|
+
# @param [Nanoc::Int::Rule] rule The item compilation rule to add
|
40
|
+
#
|
41
|
+
# @return [void]
|
42
|
+
def add_item_compilation_rule(rule)
|
43
|
+
@item_compilation_rules << rule
|
44
|
+
end
|
45
|
+
|
46
|
+
# Add the given rule to the list of item routing rules.
|
47
|
+
#
|
48
|
+
# @param [Nanoc::Int::Rule] rule The item routing rule to add
|
49
|
+
#
|
50
|
+
# @return [void]
|
51
|
+
def add_item_routing_rule(rule)
|
52
|
+
@item_routing_rules << rule
|
53
|
+
end
|
54
|
+
|
55
|
+
# @param [Nanoc::Int::Item] item The item for which the compilation rules
|
56
|
+
# should be retrieved
|
57
|
+
#
|
58
|
+
# @return [Array] The list of item compilation rules for the given item
|
59
|
+
def item_compilation_rules_for(item)
|
60
|
+
@item_compilation_rules.select { |r| r.applicable_to?(item) }
|
61
|
+
end
|
62
|
+
|
63
|
+
# Finds the first matching compilation rule for the given item
|
64
|
+
# representation.
|
65
|
+
#
|
66
|
+
# @param [Nanoc::Int::ItemRep] rep The item rep for which to fetch the rule
|
67
|
+
#
|
68
|
+
# @return [Nanoc::Int::Rule, nil] The compilation rule for the given item rep,
|
69
|
+
# or nil if no rules have been found
|
70
|
+
def compilation_rule_for(rep)
|
71
|
+
@item_compilation_rules.find do |rule|
|
72
|
+
rule.applicable_to?(rep.item) && rule.rep_name == rep.name
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
# Returns the list of routing rules that can be applied to the given item
|
77
|
+
# representation. For each snapshot, the first matching rule will be
|
78
|
+
# returned. The result is a hash containing the corresponding rule for
|
79
|
+
# each snapshot.
|
80
|
+
#
|
81
|
+
# @param [Nanoc::Int::ItemRep] rep The item rep for which to fetch the rules
|
82
|
+
#
|
83
|
+
# @return [Hash<Symbol, Nanoc::Int::Rule>] The routing rules for the given rep
|
84
|
+
def routing_rules_for(rep)
|
85
|
+
rules = {}
|
86
|
+
@item_routing_rules.each do |rule|
|
87
|
+
next unless rule.applicable_to?(rep.item)
|
88
|
+
next if rule.rep_name != rep.name
|
89
|
+
next if rules.key?(rule.snapshot_name)
|
90
|
+
|
91
|
+
rules[rule.snapshot_name] = rule
|
92
|
+
end
|
93
|
+
rules
|
94
|
+
end
|
95
|
+
|
96
|
+
# Finds the filter name and arguments to use for the given layout.
|
97
|
+
#
|
98
|
+
# @param [Nanoc::Int::Layout] layout The layout for which to fetch the filter.
|
99
|
+
#
|
100
|
+
# @return [Array, nil] A tuple containing the filter name and the filter
|
101
|
+
# arguments for the given layout.
|
102
|
+
def filter_for_layout(layout)
|
103
|
+
@layout_filter_mapping.each_pair do |pattern, filter_name_and_args|
|
104
|
+
return filter_name_and_args if pattern.match?(layout.identifier)
|
105
|
+
end
|
106
|
+
nil
|
107
|
+
end
|
108
|
+
|
109
|
+
# Returns an object that can be used for uniquely identifying objects.
|
110
|
+
#
|
111
|
+
# @return [Object] An unique reference to this object
|
112
|
+
def reference
|
113
|
+
:rules
|
114
|
+
end
|
115
|
+
|
116
|
+
def inspect
|
117
|
+
"<#{self.class}>"
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
@@ -1,14 +1,15 @@
|
|
1
1
|
module Nanoc::Int
|
2
2
|
# @api private
|
3
3
|
class Site
|
4
|
-
# @
|
5
|
-
#
|
6
|
-
# @
|
7
|
-
|
8
|
-
|
9
|
-
@
|
10
|
-
@
|
11
|
-
@
|
4
|
+
# @param [Nanoc::Int::Configuration] config
|
5
|
+
# @param [Enumerable<Nanoc::Int::CodeSnippet>] code_snippets
|
6
|
+
# @param [Enumerable<Nanoc::Int::Item>] items
|
7
|
+
# @param [Enumerable<Nanoc::Int::Layout>] layouts
|
8
|
+
def initialize(config:, code_snippets:, items:, layouts:)
|
9
|
+
@config = config
|
10
|
+
@code_snippets = code_snippets
|
11
|
+
@items = items
|
12
|
+
@layouts = layouts
|
12
13
|
|
13
14
|
ensure_identifier_uniqueness(@items, 'item')
|
14
15
|
ensure_identifier_uniqueness(@layouts, 'layout')
|
@@ -20,7 +21,7 @@ module Nanoc::Int
|
|
20
21
|
#
|
21
22
|
# @since 3.2.0
|
22
23
|
def compile
|
23
|
-
compiler.
|
24
|
+
compiler.run_all
|
24
25
|
end
|
25
26
|
|
26
27
|
# Returns the compiler for this site. Will create a new compiler if none
|
@@ -28,7 +29,7 @@ module Nanoc::Int
|
|
28
29
|
#
|
29
30
|
# @return [Nanoc::Int::Compiler] The compiler for this site
|
30
31
|
def compiler
|
31
|
-
@compiler ||= Nanoc::Int::
|
32
|
+
@compiler ||= Nanoc::Int::CompilerLoader.new.load(self)
|
32
33
|
end
|
33
34
|
|
34
35
|
attr_reader :code_snippets
|
data/lib/nanoc/base/repos.rb
CHANGED
@@ -3,5 +3,7 @@ require_relative 'repos/store'
|
|
3
3
|
require_relative 'repos/checksum_store'
|
4
4
|
require_relative 'repos/compiled_content_cache'
|
5
5
|
require_relative 'repos/config_loader'
|
6
|
+
require_relative 'repos/data_source'
|
7
|
+
require_relative 'repos/dependency_store'
|
6
8
|
require_relative 'repos/rule_memory_store'
|
7
9
|
require_relative 'repos/site_loader'
|
@@ -4,12 +4,11 @@ module Nanoc::Int
|
|
4
4
|
#
|
5
5
|
# @api private
|
6
6
|
class ChecksumStore < ::Nanoc::Int::Store
|
7
|
-
# @
|
8
|
-
|
9
|
-
def initialize(params = {})
|
7
|
+
# @param [Nanoc::Int::Site] site
|
8
|
+
def initialize(site: nil)
|
10
9
|
super('tmp/checksums', 1)
|
11
10
|
|
12
|
-
@site =
|
11
|
+
@site = site
|
13
12
|
|
14
13
|
@checksums = {}
|
15
14
|
end
|
@@ -33,11 +32,6 @@ module Nanoc::Int
|
|
33
32
|
@checksums[obj.reference] = checksum
|
34
33
|
end
|
35
34
|
|
36
|
-
# @see Nanoc::Int::Store#unload
|
37
|
-
def unload
|
38
|
-
@checksums = {}
|
39
|
-
end
|
40
|
-
|
41
35
|
protected
|
42
36
|
|
43
37
|
def data
|
@@ -138,12 +138,9 @@ module Nanoc
|
|
138
138
|
#
|
139
139
|
# @param [String] identifier This item's identifier.
|
140
140
|
#
|
141
|
-
# @param [
|
142
|
-
|
143
|
-
|
144
|
-
# binary
|
145
|
-
def new_item(content, attributes, identifier, params = {})
|
146
|
-
content = Nanoc::Int::Content.create(content, params)
|
141
|
+
# @param [Boolean] :binary Whether or not this item is binary
|
142
|
+
def new_item(content, attributes, identifier, binary: false)
|
143
|
+
content = Nanoc::Int::Content.create(content, binary: binary)
|
147
144
|
Nanoc::Int::Item.new(content, attributes, identifier)
|
148
145
|
end
|
149
146
|
|
@@ -0,0 +1,118 @@
|
|
1
|
+
module Nanoc::Int
|
2
|
+
# @api private
|
3
|
+
class DependencyStore < ::Nanoc::Int::Store
|
4
|
+
# @return [Array<Nanoc::Int::Item, Nanoc::Int::Layout>]
|
5
|
+
attr_reader :objects
|
6
|
+
|
7
|
+
# @param [Array<Nanoc::Int::Item, Nanoc::Int::Layout>] objects
|
8
|
+
def initialize(objects)
|
9
|
+
super('tmp/dependencies', 4)
|
10
|
+
|
11
|
+
@objects = objects
|
12
|
+
@graph = Nanoc::Int::DirectedGraph.new([nil] + @objects)
|
13
|
+
end
|
14
|
+
|
15
|
+
# Returns the direct dependencies for the given object.
|
16
|
+
#
|
17
|
+
# The direct dependencies of the given object include the items and
|
18
|
+
# layouts that, when outdated will cause the given object to be marked as
|
19
|
+
# outdated. Indirect dependencies will not be returned (e.g. if A depends
|
20
|
+
# on B which depends on C, then the direct dependencies of A do not
|
21
|
+
# include C).
|
22
|
+
#
|
23
|
+
# The direct predecessors can include nil, which indicates an item that is
|
24
|
+
# no longer present in the site.
|
25
|
+
#
|
26
|
+
# @param [Nanoc::Int::Item, Nanoc::Int::Layout] object The object for
|
27
|
+
# which to fetch the direct predecessors
|
28
|
+
#
|
29
|
+
# @return [Array<Nanoc::Int::Item, Nanoc::Int::Layout, nil>] The direct
|
30
|
+
# predecessors of
|
31
|
+
# the given object
|
32
|
+
def objects_causing_outdatedness_of(object)
|
33
|
+
@graph.direct_predecessors_of(object)
|
34
|
+
end
|
35
|
+
|
36
|
+
# Returns the direct inverse dependencies for the given object.
|
37
|
+
#
|
38
|
+
# The direct inverse dependencies of the given object include the objects
|
39
|
+
# that will be marked as outdated when the given object is outdated.
|
40
|
+
# Indirect dependencies will not be returned (e.g. if A depends on B which
|
41
|
+
# depends on C, then the direct inverse dependencies of C do not include
|
42
|
+
# A).
|
43
|
+
#
|
44
|
+
# @param [Nanoc::Int::Item, Nanoc::Int::Layout] object The object for which to
|
45
|
+
# fetch the direct successors
|
46
|
+
#
|
47
|
+
# @return [Array<Nanoc::Int::Item, Nanoc::Int::Layout>] The direct successors of
|
48
|
+
# the given object
|
49
|
+
def objects_outdated_due_to(object)
|
50
|
+
@graph.direct_successors_of(object).compact
|
51
|
+
end
|
52
|
+
|
53
|
+
# Records a dependency from `src` to `dst` in the dependency graph. When
|
54
|
+
# `dst` is oudated, `src` will also become outdated.
|
55
|
+
#
|
56
|
+
# @param [Nanoc::Int::Item, Nanoc::Int::Layout] src The source of the dependency,
|
57
|
+
# i.e. the object that will become outdated if dst is outdated
|
58
|
+
#
|
59
|
+
# @param [Nanoc::Int::Item, Nanoc::Int::Layout] dst The destination of the
|
60
|
+
# dependency, i.e. the object that will cause the source to become
|
61
|
+
# outdated if the destination is outdated
|
62
|
+
#
|
63
|
+
# @return [void]
|
64
|
+
def record_dependency(src, dst)
|
65
|
+
# Warning! dst and src are *reversed* here!
|
66
|
+
@graph.add_edge(dst, src) unless src == dst
|
67
|
+
end
|
68
|
+
|
69
|
+
# Empties the list of dependencies for the given object. This is necessary
|
70
|
+
# before recompiling the given object, because otherwise old dependencies
|
71
|
+
# will stick around and new dependencies will appear twice. This function
|
72
|
+
# removes all incoming edges for the given vertex.
|
73
|
+
#
|
74
|
+
# @param [Nanoc::Int::Item, Nanoc::Int::Layout] object The object for which to
|
75
|
+
# forget all dependencies
|
76
|
+
#
|
77
|
+
# @return [void]
|
78
|
+
def forget_dependencies_for(object)
|
79
|
+
@graph.delete_edges_to(object)
|
80
|
+
end
|
81
|
+
|
82
|
+
protected
|
83
|
+
|
84
|
+
def data
|
85
|
+
{
|
86
|
+
edges: @graph.edges,
|
87
|
+
vertices: @graph.vertices.map { |obj| obj && obj.reference },
|
88
|
+
}
|
89
|
+
end
|
90
|
+
|
91
|
+
def data=(new_data)
|
92
|
+
# Create new graph
|
93
|
+
@graph = Nanoc::Int::DirectedGraph.new([nil] + @objects)
|
94
|
+
|
95
|
+
# Load vertices
|
96
|
+
previous_objects = new_data[:vertices].map do |reference|
|
97
|
+
@objects.find { |obj| reference == obj.reference }
|
98
|
+
end
|
99
|
+
|
100
|
+
# Load edges
|
101
|
+
new_data[:edges].each do |edge|
|
102
|
+
from_index, to_index = *edge
|
103
|
+
from = from_index && previous_objects[from_index]
|
104
|
+
to = to_index && previous_objects[to_index]
|
105
|
+
@graph.add_edge(from, to)
|
106
|
+
end
|
107
|
+
|
108
|
+
# Record dependency from all items on new items
|
109
|
+
new_objects = (@objects - previous_objects)
|
110
|
+
new_objects.each do |new_obj|
|
111
|
+
@objects.each do |obj|
|
112
|
+
next unless obj.is_a?(Nanoc::Int::Item)
|
113
|
+
@graph.add_edge(new_obj, obj)
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
@@ -4,13 +4,9 @@ module Nanoc::Int
|
|
4
4
|
#
|
5
5
|
# @api private
|
6
6
|
class RuleMemoryStore < ::Nanoc::Int::Store
|
7
|
-
|
8
|
-
# belongs to
|
9
|
-
def initialize(params = {})
|
7
|
+
def initialize
|
10
8
|
super('tmp/rule_memory', 1)
|
11
9
|
|
12
|
-
@site = params[:site] if params.key?(:site)
|
13
|
-
|
14
10
|
@rule_memories = {}
|
15
11
|
end
|
16
12
|
|
@@ -12,32 +12,6 @@ module Nanoc::Int
|
|
12
12
|
site_from_config(Nanoc::Int::ConfigLoader.new.new_from_cwd)
|
13
13
|
end
|
14
14
|
|
15
|
-
# @api private
|
16
|
-
def setup_child_parent_links(items)
|
17
|
-
items.each do |item|
|
18
|
-
item.parent = nil
|
19
|
-
item.children = []
|
20
|
-
end
|
21
|
-
|
22
|
-
item_map = {}
|
23
|
-
items.each do |item|
|
24
|
-
next if item.identifier !~ /\/\z/
|
25
|
-
item_map[item.identifier.to_s] = item
|
26
|
-
end
|
27
|
-
|
28
|
-
items.each do |item|
|
29
|
-
parent_id_end = item.identifier.to_s.rindex('/', -2)
|
30
|
-
next unless parent_id_end
|
31
|
-
|
32
|
-
parent_id = item.identifier.to_s[0..parent_id_end]
|
33
|
-
parent = item_map[parent_id]
|
34
|
-
next unless parent
|
35
|
-
|
36
|
-
item.parent = parent
|
37
|
-
parent.children << item
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
15
|
private
|
42
16
|
|
43
17
|
def site_from_config(config)
|
@@ -60,8 +34,6 @@ module Nanoc::Int
|
|
60
34
|
end
|
61
35
|
end
|
62
36
|
|
63
|
-
setup_child_parent_links(items)
|
64
|
-
|
65
37
|
Nanoc::Int::Site.new(
|
66
38
|
config: config,
|
67
39
|
code_snippets: code_snippets,
|
@@ -57,15 +57,9 @@ module Nanoc::Int
|
|
57
57
|
#
|
58
58
|
# @return [void]
|
59
59
|
def load
|
60
|
-
# Don’t load twice
|
61
|
-
if @loaded
|
62
|
-
return
|
63
|
-
end
|
64
|
-
|
65
60
|
# Check file existance
|
66
61
|
unless File.file?(filename)
|
67
62
|
no_data_found
|
68
|
-
@loaded = true
|
69
63
|
return
|
70
64
|
end
|
71
65
|
|
@@ -74,13 +68,11 @@ module Nanoc::Int
|
|
74
68
|
# Check version
|
75
69
|
if pstore[:version] != version
|
76
70
|
version_mismatch_detected
|
77
|
-
@loaded = true
|
78
71
|
return
|
79
72
|
end
|
80
73
|
|
81
74
|
# Load
|
82
75
|
self.data = pstore[:data]
|
83
|
-
@loaded = true
|
84
76
|
end
|
85
77
|
rescue
|
86
78
|
FileUtils.rm_f(filename)
|
@@ -88,10 +80,6 @@ module Nanoc::Int
|
|
88
80
|
end
|
89
81
|
end
|
90
82
|
|
91
|
-
# Undoes the effects of {#load}. Used when {#load} raises an exception.
|
92
|
-
def unload
|
93
|
-
end
|
94
|
-
|
95
83
|
# Stores the data contained in memory to the filesystem. This method will
|
96
84
|
# use the {#data} method to fetch the data that should be written.
|
97
85
|
#
|