nanoc 4.11.4 → 4.11.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/NEWS.md +6 -0
- data/lib/nanoc.rb +1 -0
- data/lib/nanoc/base/entities.rb +0 -4
- data/lib/nanoc/base/entities/outdatedness_reasons.rb +9 -9
- data/lib/nanoc/base/entities/outdatedness_status.rb +1 -1
- data/lib/nanoc/base/repos/dependency_store.rb +5 -5
- data/lib/nanoc/base/repos/site_loader.rb +1 -1
- data/lib/nanoc/base/services/compiler.rb +2 -2
- data/lib/nanoc/base/services/compiler/stages/preprocess.rb +1 -1
- data/lib/nanoc/base/services/outdatedness_checker.rb +2 -2
- data/lib/nanoc/checking/checks/external_links.rb +1 -1
- data/lib/nanoc/checking/runner.rb +1 -1
- data/lib/nanoc/rule_dsl/action_provider.rb +1 -1
- data/lib/nanoc/rule_dsl/action_sequence_calculator.rb +1 -1
- data/lib/nanoc/rule_dsl/compilation_rule.rb +1 -1
- data/lib/nanoc/rule_dsl/compilation_rule_context.rb +1 -1
- data/lib/nanoc/rule_dsl/routing_rule.rb +1 -1
- data/lib/nanoc/rule_dsl/rule_context.rb +1 -1
- data/lib/nanoc/spec.rb +2 -2
- data/lib/nanoc/version.rb +1 -1
- metadata +18 -7
- data/lib/nanoc/base/entities/dependency.rb +0 -35
- data/lib/nanoc/base/entities/props.rb +0 -150
- data/lib/nanoc/base/entities/site.rb +0 -71
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 33e67e26b0ffd077aa8a4c28ecf16e992f75486e70d8695868b166b789ad2a66
|
4
|
+
data.tar.gz: 9b09738037843e30d6c3c947825c5b2c3cdfeb9597e398534c97c6036a50adaa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 78a5a649be27147d22e1bed0a0599db2bf1d013233cc0af24476257e1703b49351f6f268f3d617eaebf9efd74514c1f68f3d37b5254005317393119a78c3a330
|
7
|
+
data.tar.gz: ac3fab845b4a1677d19577965ecc683b0977528391d447337fdf4cfd358f1acfd40108e12759ebf7aa8a284261496c92f3f671face43ec35d36fbaa81cea8fad
|
data/NEWS.md
CHANGED
data/lib/nanoc.rb
CHANGED
data/lib/nanoc/base/entities.rb
CHANGED
@@ -3,9 +3,5 @@
|
|
3
3
|
# Re-exported from Nanoc::Core
|
4
4
|
Nanoc::Identifier = Nanoc::Core::Identifier
|
5
5
|
|
6
|
-
require_relative 'entities/props'
|
7
|
-
require_relative 'entities/site'
|
8
|
-
|
9
6
|
require_relative 'entities/outdatedness_status'
|
10
7
|
require_relative 'entities/outdatedness_reasons'
|
11
|
-
require_relative 'entities/dependency'
|
@@ -12,12 +12,12 @@ module Nanoc
|
|
12
12
|
# @return [String] A descriptive message for this outdatedness reason
|
13
13
|
attr_reader :message
|
14
14
|
|
15
|
-
# @return [Nanoc::
|
15
|
+
# @return [Nanoc::Core::DependencyProps]
|
16
16
|
attr_reader :props
|
17
17
|
|
18
18
|
# @param [String] message The descriptive message for this outdatedness
|
19
19
|
# reason
|
20
|
-
def initialize(message, props = Nanoc::
|
20
|
+
def initialize(message, props = Nanoc::Core::DependencyProps.new)
|
21
21
|
@message = message
|
22
22
|
@props = props
|
23
23
|
end
|
@@ -25,7 +25,7 @@ module Nanoc
|
|
25
25
|
|
26
26
|
CodeSnippetsModified = Generic.new(
|
27
27
|
'The code snippets have been modified since the last time the site was compiled.',
|
28
|
-
|
28
|
+
Nanoc::Core::DependencyProps.new(raw_content: true, attributes: true, compiled_content: true, path: true),
|
29
29
|
)
|
30
30
|
|
31
31
|
DependenciesOutdated = Generic.new(
|
@@ -34,17 +34,17 @@ module Nanoc
|
|
34
34
|
|
35
35
|
NotWritten = Generic.new(
|
36
36
|
'This item representation has not yet been written to the output directory (but it does have a path).',
|
37
|
-
|
37
|
+
Nanoc::Core::DependencyProps.new(raw_content: true, attributes: true, compiled_content: true, path: true),
|
38
38
|
)
|
39
39
|
|
40
40
|
RulesModified = Generic.new(
|
41
41
|
'The rules file has been modified since the last time the site was compiled.',
|
42
|
-
|
42
|
+
Nanoc::Core::DependencyProps.new(compiled_content: true, path: true),
|
43
43
|
)
|
44
44
|
|
45
45
|
ContentModified = Generic.new(
|
46
46
|
'The content of this item has been modified since the last time the site was compiled.',
|
47
|
-
|
47
|
+
Nanoc::Core::DependencyProps.new(raw_content: true, compiled_content: true),
|
48
48
|
)
|
49
49
|
|
50
50
|
class DocumentCollectionExtended < Generic
|
@@ -53,7 +53,7 @@ module Nanoc
|
|
53
53
|
def initialize(objects)
|
54
54
|
super(
|
55
55
|
'New items/layouts have been added to the site.',
|
56
|
-
|
56
|
+
Nanoc::Core::DependencyProps.new(raw_content: true),
|
57
57
|
)
|
58
58
|
|
59
59
|
@objects = objects
|
@@ -72,7 +72,7 @@ module Nanoc
|
|
72
72
|
def initialize(attributes)
|
73
73
|
super(
|
74
74
|
'The attributes of this item have been modified since the last time the site was compiled.',
|
75
|
-
|
75
|
+
Nanoc::Core::DependencyProps.new(attributes: true, compiled_content: true),
|
76
76
|
)
|
77
77
|
|
78
78
|
@attributes = attributes
|
@@ -81,7 +81,7 @@ module Nanoc
|
|
81
81
|
|
82
82
|
UsesAlwaysOutdatedFilter = Generic.new(
|
83
83
|
'This item rep uses one or more filters that cannot track dependencies, and will thus always be considered as outdated.',
|
84
|
-
|
84
|
+
Nanoc::Core::DependencyProps.new(raw_content: true, attributes: true, compiled_content: true),
|
85
85
|
)
|
86
86
|
end
|
87
87
|
end
|
@@ -30,15 +30,15 @@ module Nanoc
|
|
30
30
|
C_OBJ_SRC = Nanoc::Core::Item
|
31
31
|
C_OBJ_DST = C::Or[Nanoc::Core::Item, Nanoc::Core::Layout, Nanoc::Core::Configuration, Nanoc::Core::IdentifiableCollection]
|
32
32
|
|
33
|
-
contract C_OBJ_SRC => C::ArrayOf[Nanoc::
|
33
|
+
contract C_OBJ_SRC => C::ArrayOf[Nanoc::Core::Dependency]
|
34
34
|
def dependencies_causing_outdatedness_of(object)
|
35
35
|
objects_causing_outdatedness_of(object).map do |other_object|
|
36
36
|
props = props_for(other_object, object)
|
37
37
|
|
38
|
-
Nanoc::
|
38
|
+
Nanoc::Core::Dependency.new(
|
39
39
|
other_object,
|
40
40
|
object,
|
41
|
-
Nanoc::
|
41
|
+
Nanoc::Core::DependencyProps.new(
|
42
42
|
raw_content: props.fetch(:raw_content, false),
|
43
43
|
attributes: props.fetch(:attributes, false),
|
44
44
|
compiled_content: props.fetch(:compiled_content, false),
|
@@ -114,8 +114,8 @@ module Nanoc
|
|
114
114
|
src_ref = obj2ref(src)
|
115
115
|
dst_ref = obj2ref(dst)
|
116
116
|
|
117
|
-
existing_props = Nanoc::
|
118
|
-
new_props = Nanoc::
|
117
|
+
existing_props = Nanoc::Core::DependencyProps.new(@graph.props_for(dst_ref, src_ref) || {})
|
118
|
+
new_props = Nanoc::Core::DependencyProps.new(raw_content: raw_content, attributes: attributes, compiled_content: compiled_content, path: path)
|
119
119
|
props = existing_props.merge(new_props)
|
120
120
|
|
121
121
|
@graph.add_edge(dst_ref, src_ref, props: props.to_h)
|
@@ -21,12 +21,12 @@ module Nanoc
|
|
21
21
|
@compiled_content_store = Nanoc::Int::CompiledContentStore.new
|
22
22
|
end
|
23
23
|
|
24
|
-
contract Nanoc::
|
24
|
+
contract Nanoc::Core::Site => C::Any
|
25
25
|
def self.compile(site)
|
26
26
|
new_for(site).run_until_end
|
27
27
|
end
|
28
28
|
|
29
|
-
contract Nanoc::
|
29
|
+
contract Nanoc::Core::Site => Nanoc::Int::Compiler
|
30
30
|
def self.new_for(site)
|
31
31
|
Nanoc::Int::CompilerLoader.new.load(site)
|
32
32
|
end
|
@@ -16,7 +16,7 @@ module Nanoc
|
|
16
16
|
return if @site.preprocessed?
|
17
17
|
|
18
18
|
if @action_provider.need_preprocessing?
|
19
|
-
@site.data_source = Nanoc::Core::
|
19
|
+
@site.data_source = Nanoc::Core::InMemoryDataSource.new(@site.items, @site.layouts, @site.data_source)
|
20
20
|
@action_provider.preprocess(@site)
|
21
21
|
|
22
22
|
@dependency_store.items = @site.items
|
@@ -115,7 +115,7 @@ module Nanoc
|
|
115
115
|
C_ITEM_OR_REP = C::Or[Nanoc::Core::Item, Nanoc::Core::ItemRep]
|
116
116
|
C_ACTION_SEQUENCES = C::HashOf[C_OBJ => Nanoc::Core::ActionSequence]
|
117
117
|
|
118
|
-
contract C::KeywordArgs[site: Nanoc::
|
118
|
+
contract C::KeywordArgs[site: Nanoc::Core::Site, checksum_store: Nanoc::Int::ChecksumStore, checksums: Nanoc::Core::ChecksumCollection, dependency_store: Nanoc::Int::DependencyStore, action_sequence_store: Nanoc::Int::ActionSequenceStore, action_sequences: C_ACTION_SEQUENCES, reps: Nanoc::Int::ItemRepRepo] => C::Any
|
119
119
|
def initialize(site:, checksum_store:, checksums:, dependency_store:, action_sequence_store:, action_sequences:, reps:)
|
120
120
|
@site = site
|
121
121
|
@checksum_store = checksum_store
|
@@ -185,7 +185,7 @@ module Nanoc
|
|
185
185
|
is_outdated
|
186
186
|
end
|
187
187
|
|
188
|
-
contract Nanoc::
|
188
|
+
contract Nanoc::Core::Dependency => C::Bool
|
189
189
|
def dependency_causes_outdatedness?(dependency)
|
190
190
|
return true if dependency.from.nil?
|
191
191
|
|
@@ -78,7 +78,7 @@ module ::Nanoc::Checking::Checks
|
|
78
78
|
return Result.new(href, 'redirection without a target location') if location.nil?
|
79
79
|
|
80
80
|
if /^30[18]$/.match?(res.code)
|
81
|
-
return Result.new(href, "link
|
81
|
+
return Result.new(href, "link has moved permanently to '#{location}'")
|
82
82
|
end
|
83
83
|
|
84
84
|
url = URI.parse(location)
|
@@ -50,7 +50,7 @@ module Nanoc::RuleDSL
|
|
50
50
|
end
|
51
51
|
|
52
52
|
site.data_source =
|
53
|
-
Nanoc::Core::
|
53
|
+
Nanoc::Core::InMemoryDataSource.new(ctx.items._unwrap, ctx.layouts._unwrap, site.data_source)
|
54
54
|
end
|
55
55
|
|
56
56
|
def postprocess(site, compiler)
|
@@ -31,7 +31,7 @@ module Nanoc::RuleDSL
|
|
31
31
|
# @api private
|
32
32
|
attr_accessor :rules_collection
|
33
33
|
|
34
|
-
# @param [Nanoc::
|
34
|
+
# @param [Nanoc::Core::Site] site
|
35
35
|
# @param [Nanoc::RuleDSL::RulesCollection] rules_collection
|
36
36
|
def initialize(site:, rules_collection:)
|
37
37
|
@site = site
|
@@ -5,7 +5,7 @@ module Nanoc::RuleDSL
|
|
5
5
|
include Nanoc::Core::ContractsSupport
|
6
6
|
|
7
7
|
contract Nanoc::Core::ItemRep, C::KeywordArgs[
|
8
|
-
site: Nanoc::
|
8
|
+
site: Nanoc::Core::Site,
|
9
9
|
recorder: Nanoc::RuleDSL::ActionRecorder,
|
10
10
|
view_context: Nanoc::ViewContextForPreCompilation,
|
11
11
|
] => C::Any
|
data/lib/nanoc/spec.rb
CHANGED
@@ -208,10 +208,10 @@ module Nanoc
|
|
208
208
|
|
209
209
|
def site
|
210
210
|
@_site ||=
|
211
|
-
Nanoc::
|
211
|
+
Nanoc::Core::Site.new(
|
212
212
|
config: @config,
|
213
213
|
code_snippets: [],
|
214
|
-
data_source: Nanoc::Core::
|
214
|
+
data_source: Nanoc::Core::InMemoryDataSource.new(@items, @layouts),
|
215
215
|
)
|
216
216
|
end
|
217
217
|
|
data/lib/nanoc/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nanoc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.11.
|
4
|
+
version: 4.11.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Denis Defreyne
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-04-
|
11
|
+
date: 2019-04-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '2.5'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: colored
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.2'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.2'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: cri
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -44,14 +58,14 @@ dependencies:
|
|
44
58
|
requirements:
|
45
59
|
- - '='
|
46
60
|
- !ruby/object:Gem::Version
|
47
|
-
version: 4.11.
|
61
|
+
version: 4.11.5
|
48
62
|
type: :runtime
|
49
63
|
prerelease: false
|
50
64
|
version_requirements: !ruby/object:Gem::Requirement
|
51
65
|
requirements:
|
52
66
|
- - '='
|
53
67
|
- !ruby/object:Gem::Version
|
54
|
-
version: 4.11.
|
68
|
+
version: 4.11.5
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: parallel
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -155,11 +169,8 @@ files:
|
|
155
169
|
- lib/nanoc/base/assertions.rb
|
156
170
|
- lib/nanoc/base/changes_stream.rb
|
157
171
|
- lib/nanoc/base/entities.rb
|
158
|
-
- lib/nanoc/base/entities/dependency.rb
|
159
172
|
- lib/nanoc/base/entities/outdatedness_reasons.rb
|
160
173
|
- lib/nanoc/base/entities/outdatedness_status.rb
|
161
|
-
- lib/nanoc/base/entities/props.rb
|
162
|
-
- lib/nanoc/base/entities/site.rb
|
163
174
|
- lib/nanoc/base/error.rb
|
164
175
|
- lib/nanoc/base/errors.rb
|
165
176
|
- lib/nanoc/base/feature.rb
|
@@ -1,35 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Nanoc
|
4
|
-
module Int
|
5
|
-
# @api private
|
6
|
-
# A dependency between two items/layouts.
|
7
|
-
class Dependency
|
8
|
-
include Nanoc::Core::ContractsSupport
|
9
|
-
|
10
|
-
C_OBJ_FROM = C::Or[Nanoc::Core::Item, Nanoc::Core::Layout, Nanoc::Core::Configuration, Nanoc::Core::IdentifiableCollection]
|
11
|
-
C_OBJ_TO = Nanoc::Core::Item
|
12
|
-
|
13
|
-
contract C::None => C::Maybe[C_OBJ_FROM]
|
14
|
-
attr_reader :from
|
15
|
-
|
16
|
-
contract C::None => C::Maybe[C_OBJ_TO]
|
17
|
-
attr_reader :to
|
18
|
-
|
19
|
-
contract C::None => Nanoc::Int::Props
|
20
|
-
attr_reader :props
|
21
|
-
|
22
|
-
contract C::Maybe[C_OBJ_FROM], C::Maybe[C_OBJ_TO], Nanoc::Int::Props => C::Any
|
23
|
-
def initialize(from, to, props)
|
24
|
-
@from = from
|
25
|
-
@to = to
|
26
|
-
@props = props
|
27
|
-
end
|
28
|
-
|
29
|
-
contract C::None => String
|
30
|
-
def inspect
|
31
|
-
"Dependency(#{@from.inspect} -> #{@to.inspect}, #{@props.inspect})"
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
@@ -1,150 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Nanoc
|
4
|
-
module Int
|
5
|
-
# @api private
|
6
|
-
class Props
|
7
|
-
include Nanoc::Core::ContractsSupport
|
8
|
-
|
9
|
-
attr_reader :attributes
|
10
|
-
attr_reader :raw_content
|
11
|
-
|
12
|
-
# TODO: Split raw_content for documents and collections
|
13
|
-
C_RAW_CONTENT = C::Or[C::IterOf[C::Or[String, Regexp]], C::Bool]
|
14
|
-
C_ATTRS = C::Or[C::IterOf[Symbol], C::Bool]
|
15
|
-
contract C::KeywordArgs[raw_content: C::Optional[C_RAW_CONTENT], attributes: C::Optional[C_ATTRS], compiled_content: C::Optional[C::Bool], path: C::Optional[C::Bool]] => C::Any
|
16
|
-
def initialize(raw_content: false, attributes: false, compiled_content: false, path: false)
|
17
|
-
@compiled_content = compiled_content
|
18
|
-
@path = path
|
19
|
-
|
20
|
-
@attributes =
|
21
|
-
case attributes
|
22
|
-
when Set
|
23
|
-
attributes
|
24
|
-
when Enumerable
|
25
|
-
Set.new(attributes)
|
26
|
-
else
|
27
|
-
attributes
|
28
|
-
end
|
29
|
-
|
30
|
-
@raw_content =
|
31
|
-
case raw_content
|
32
|
-
when Set
|
33
|
-
raw_content
|
34
|
-
when Enumerable
|
35
|
-
Set.new(raw_content)
|
36
|
-
else
|
37
|
-
raw_content
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
contract C::None => String
|
42
|
-
def inspect
|
43
|
-
(+'').tap do |s|
|
44
|
-
s << 'Props('
|
45
|
-
s << (raw_content? ? 'r' : '_')
|
46
|
-
s << (attributes? ? 'a' : '_')
|
47
|
-
s << (compiled_content? ? 'c' : '_')
|
48
|
-
s << (path? ? 'p' : '_')
|
49
|
-
s << ')'
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
contract C::None => String
|
54
|
-
def to_s
|
55
|
-
(+'').tap do |s|
|
56
|
-
s << (raw_content? ? 'r' : '_')
|
57
|
-
s << (attributes? ? 'a' : '_')
|
58
|
-
s << (compiled_content? ? 'c' : '_')
|
59
|
-
s << (path? ? 'p' : '_')
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
contract C::None => C::Bool
|
64
|
-
def raw_content?
|
65
|
-
case @raw_content
|
66
|
-
when Enumerable
|
67
|
-
@raw_content.any?
|
68
|
-
else
|
69
|
-
@raw_content
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
contract C::None => C::Bool
|
74
|
-
def attributes?
|
75
|
-
case @attributes
|
76
|
-
when Enumerable
|
77
|
-
@attributes.any?
|
78
|
-
else
|
79
|
-
@attributes
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
contract C::None => C::Bool
|
84
|
-
def compiled_content?
|
85
|
-
@compiled_content
|
86
|
-
end
|
87
|
-
|
88
|
-
contract C::None => C::Bool
|
89
|
-
def path?
|
90
|
-
@path
|
91
|
-
end
|
92
|
-
|
93
|
-
contract Nanoc::Int::Props => Nanoc::Int::Props
|
94
|
-
def merge(other)
|
95
|
-
Props.new(
|
96
|
-
raw_content: merge_raw_content(other),
|
97
|
-
attributes: merge_attributes(other),
|
98
|
-
compiled_content: compiled_content? || other.compiled_content?,
|
99
|
-
path: path? || other.path?,
|
100
|
-
)
|
101
|
-
end
|
102
|
-
|
103
|
-
def merge_raw_content(other)
|
104
|
-
merge_prop(raw_content, other.raw_content)
|
105
|
-
end
|
106
|
-
|
107
|
-
def merge_attributes(other)
|
108
|
-
merge_prop(attributes, other.attributes)
|
109
|
-
end
|
110
|
-
|
111
|
-
def merge_prop(own, other)
|
112
|
-
case own
|
113
|
-
when true
|
114
|
-
true
|
115
|
-
when false
|
116
|
-
other
|
117
|
-
else
|
118
|
-
case other
|
119
|
-
when true
|
120
|
-
true
|
121
|
-
when false
|
122
|
-
own
|
123
|
-
else
|
124
|
-
own + other
|
125
|
-
end
|
126
|
-
end
|
127
|
-
end
|
128
|
-
|
129
|
-
contract C::None => Set
|
130
|
-
def active
|
131
|
-
Set.new.tap do |pr|
|
132
|
-
pr << :raw_content if raw_content?
|
133
|
-
pr << :attributes if attributes?
|
134
|
-
pr << :compiled_content if compiled_content?
|
135
|
-
pr << :path if path?
|
136
|
-
end
|
137
|
-
end
|
138
|
-
|
139
|
-
contract C::None => Hash
|
140
|
-
def to_h
|
141
|
-
{
|
142
|
-
raw_content: raw_content,
|
143
|
-
attributes: attributes,
|
144
|
-
compiled_content: compiled_content?,
|
145
|
-
path: path?,
|
146
|
-
}
|
147
|
-
end
|
148
|
-
end
|
149
|
-
end
|
150
|
-
end
|
@@ -1,71 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Nanoc
|
4
|
-
module Int
|
5
|
-
# @api private
|
6
|
-
class Site
|
7
|
-
# Error that is raised when multiple items or layouts with the same identifier exist.
|
8
|
-
class DuplicateIdentifierError < ::Nanoc::Error
|
9
|
-
def initialize(identifier, type)
|
10
|
-
super("There are multiple #{type}s with the #{identifier} identifier.")
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
include Nanoc::Core::ContractsSupport
|
15
|
-
|
16
|
-
attr_reader :code_snippets
|
17
|
-
attr_reader :config
|
18
|
-
attr_accessor :data_source
|
19
|
-
|
20
|
-
contract C::KeywordArgs[config: Nanoc::Core::Configuration, code_snippets: C::IterOf[Nanoc::Core::CodeSnippet], data_source: C::Named['Nanoc::DataSource']] => C::Any
|
21
|
-
def initialize(config:, code_snippets:, data_source:)
|
22
|
-
@config = config
|
23
|
-
@code_snippets = code_snippets
|
24
|
-
@data_source = data_source
|
25
|
-
|
26
|
-
@preprocessed = false
|
27
|
-
|
28
|
-
ensure_identifier_uniqueness(@data_source.items, 'item')
|
29
|
-
ensure_identifier_uniqueness(@data_source.layouts, 'layout')
|
30
|
-
end
|
31
|
-
|
32
|
-
def mark_as_preprocessed
|
33
|
-
@preprocessed = true
|
34
|
-
end
|
35
|
-
|
36
|
-
def preprocessed?
|
37
|
-
@preprocessed
|
38
|
-
end
|
39
|
-
|
40
|
-
def items
|
41
|
-
@data_source.items
|
42
|
-
end
|
43
|
-
|
44
|
-
def layouts
|
45
|
-
@data_source.layouts
|
46
|
-
end
|
47
|
-
|
48
|
-
contract C::None => self
|
49
|
-
def freeze
|
50
|
-
config.freeze
|
51
|
-
items.freeze
|
52
|
-
layouts.freeze
|
53
|
-
code_snippets.__nanoc_freeze_recursively
|
54
|
-
self
|
55
|
-
end
|
56
|
-
|
57
|
-
contract C::IterOf[C::Or[Nanoc::Core::Item, Nanoc::Core::Layout]], String => self
|
58
|
-
def ensure_identifier_uniqueness(objects, type)
|
59
|
-
seen = Set.new
|
60
|
-
objects.each do |obj|
|
61
|
-
if seen.include?(obj.identifier)
|
62
|
-
raise DuplicateIdentifierError.new(obj.identifier, type)
|
63
|
-
end
|
64
|
-
|
65
|
-
seen << obj.identifier
|
66
|
-
end
|
67
|
-
self
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|