nanoc 4.11.0 → 4.11.1
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 +4 -7
- data/lib/nanoc/base.rb +3 -3
- data/lib/nanoc/base/assertions.rb +1 -1
- data/lib/nanoc/base/entities.rb +2 -20
- data/lib/nanoc/base/entities/action_sequence.rb +60 -64
- data/lib/nanoc/base/entities/checksum_collection.rb +23 -21
- data/lib/nanoc/base/entities/dependency.rb +24 -22
- data/lib/nanoc/base/entities/outdatedness_reasons.rb +74 -72
- data/lib/nanoc/base/entities/outdatedness_status.rb +19 -17
- data/lib/nanoc/base/entities/props.rb +119 -117
- data/lib/nanoc/base/entities/site.rb +46 -50
- data/lib/nanoc/base/errors.rb +183 -198
- data/lib/nanoc/base/repos.rb +4 -2
- data/lib/nanoc/base/repos/action_sequence_store.rb +44 -42
- data/lib/nanoc/base/repos/aggregate_data_source.rb +24 -22
- data/lib/nanoc/base/repos/checksum_store.rb +51 -49
- data/lib/nanoc/base/repos/compiled_content_cache.rb +47 -45
- data/lib/nanoc/base/repos/compiled_content_store.rb +76 -0
- data/lib/nanoc/base/repos/config_loader.rb +74 -72
- data/lib/nanoc/base/repos/dependency_store.rb +174 -172
- data/lib/nanoc/base/repos/in_mem_data_source.rb +17 -15
- data/lib/nanoc/base/repos/item_rep_repo.rb +26 -24
- data/lib/nanoc/base/repos/outdatedness_store.rb +50 -48
- data/lib/nanoc/base/repos/prefixed_data_source.rb +21 -19
- data/lib/nanoc/base/repos/site_loader.rb +75 -73
- data/lib/nanoc/base/repos/store.rb +93 -91
- data/lib/nanoc/base/services.rb +7 -3
- data/lib/nanoc/base/services/action_provider.rb +23 -21
- data/lib/nanoc/base/services/action_sequence_builder.rb +42 -34
- data/lib/nanoc/base/services/compilation_context.rb +49 -47
- data/lib/nanoc/base/services/compiler.rb +177 -170
- data/lib/nanoc/base/services/compiler/phases.rb +8 -1
- data/lib/nanoc/base/services/compiler/phases/abstract.rb +44 -38
- data/lib/nanoc/base/services/compiler/phases/cache.rb +34 -28
- data/lib/nanoc/base/services/compiler/phases/mark_done.rb +17 -11
- data/lib/nanoc/base/services/compiler/phases/notify.rb +21 -0
- data/lib/nanoc/base/services/compiler/phases/recalculate.rb +37 -31
- data/lib/nanoc/base/services/compiler/phases/resume.rb +47 -48
- data/lib/nanoc/base/services/compiler/phases/write.rb +65 -59
- data/lib/nanoc/base/services/compiler/stage.rb +27 -8
- data/lib/nanoc/base/services/compiler/stages.rb +7 -1
- data/lib/nanoc/base/services/compiler/stages/build_reps.rb +25 -19
- data/lib/nanoc/base/services/compiler/stages/calculate_checksums.rb +34 -28
- data/lib/nanoc/base/services/compiler/stages/cleanup.rb +33 -27
- data/lib/nanoc/base/services/compiler/stages/compile_reps.rb +79 -69
- data/lib/nanoc/base/services/compiler/stages/determine_outdatedness.rb +46 -40
- data/lib/nanoc/base/services/compiler/stages/forget_outdated_dependencies.rb +15 -9
- data/lib/nanoc/base/services/compiler/stages/load_stores.rb +28 -22
- data/lib/nanoc/base/services/compiler/stages/postprocess.rb +16 -10
- data/lib/nanoc/base/services/compiler/stages/preprocess.rb +25 -19
- data/lib/nanoc/base/services/compiler/stages/prune.rb +23 -17
- data/lib/nanoc/base/services/compiler/stages/store_post_compilation_state.rb +15 -9
- data/lib/nanoc/base/services/compiler/stages/store_pre_compilation_state.rb +26 -20
- data/lib/nanoc/base/services/compiler_loader.rb +26 -24
- data/lib/nanoc/base/services/dependency_tracker.rb +47 -45
- data/lib/nanoc/base/services/executor.rb +16 -15
- data/lib/nanoc/base/services/filter.rb +37 -5
- data/lib/nanoc/base/services/instrumentor.rb +12 -10
- data/lib/nanoc/base/services/item_rep_builder.rb +21 -19
- data/lib/nanoc/base/services/item_rep_router.rb +72 -70
- data/lib/nanoc/base/services/item_rep_selector.rb +48 -46
- data/lib/nanoc/base/services/item_rep_writer.rb +58 -53
- data/lib/nanoc/base/services/outdatedness_checker.rb +181 -179
- data/lib/nanoc/base/services/outdatedness_rule.rb +23 -21
- data/lib/nanoc/base/services/outdatedness_rules.rb +5 -3
- data/lib/nanoc/base/services/outdatedness_rules/attributes_modified.rb +28 -24
- data/lib/nanoc/base/services/outdatedness_rules/code_snippets_modified.rb +20 -16
- data/lib/nanoc/base/services/outdatedness_rules/content_modified.rb +13 -9
- data/lib/nanoc/base/services/outdatedness_rules/item_collection_extended.rb +12 -8
- data/lib/nanoc/base/services/outdatedness_rules/layout_collection_extended.rb +12 -8
- data/lib/nanoc/base/services/outdatedness_rules/not_written.rb +10 -6
- data/lib/nanoc/base/services/outdatedness_rules/rules_modified.rb +39 -35
- data/lib/nanoc/base/services/outdatedness_rules/uses_always_outdated_filter.rb +19 -15
- data/lib/nanoc/base/services/pruner.rb +2 -2
- data/lib/nanoc/base/views.rb +7 -0
- data/lib/nanoc/base/views/basic_item_view.rb +1 -1
- data/lib/nanoc/base/views/compilation_item_rep_view.rb +2 -2
- data/lib/nanoc/base/views/identifiable_collection_view.rb +2 -2
- data/lib/nanoc/base/views/mixins/document_view_mixin.rb +1 -1
- data/lib/nanoc/base/views/mixins/mutable_document_view_mixin.rb +5 -5
- data/lib/nanoc/base/views/mutable_item_collection_view.rb +3 -3
- data/lib/nanoc/base/views/mutable_layout_collection_view.rb +2 -2
- data/lib/nanoc/base/views/view_context_for_compilation.rb +6 -6
- data/lib/nanoc/base/views/view_context_for_pre_compilation.rb +2 -2
- data/lib/nanoc/base/views/view_context_for_shell.rb +2 -2
- data/lib/nanoc/checking/check.rb +1 -1
- data/lib/nanoc/cli/commands/compile_listeners/abstract.rb +24 -7
- data/lib/nanoc/cli/commands/compile_listeners/debug_printer.rb +79 -15
- data/lib/nanoc/cli/commands/compile_listeners/diff_generator.rb +4 -7
- data/lib/nanoc/cli/commands/compile_listeners/file_action_printer.rb +15 -24
- data/lib/nanoc/cli/commands/compile_listeners/timing_recorder.rb +22 -18
- data/lib/nanoc/cli/commands/create-site.rb +2 -7
- data/lib/nanoc/cli/commands/shell.rb +1 -1
- data/lib/nanoc/cli/commands/show-data.rb +9 -9
- data/lib/nanoc/cli/logger.rb +1 -1
- data/lib/nanoc/data_sources/filesystem.rb +8 -8
- data/lib/nanoc/filters/erb.rb +1 -1
- data/lib/nanoc/filters/erubi.rb +1 -1
- data/lib/nanoc/filters/erubis.rb +1 -1
- data/lib/nanoc/filters/haml.rb +1 -1
- data/lib/nanoc/filters/sass.rb +1 -1
- data/lib/nanoc/filters/slim.rb +1 -1
- data/lib/nanoc/helpers/breadcrumbs.rb +2 -2
- data/lib/nanoc/helpers/capturing.rb +9 -8
- data/lib/nanoc/helpers/filtering.rb +2 -2
- data/lib/nanoc/helpers/rendering.rb +1 -1
- data/lib/nanoc/rule_dsl.rb +10 -0
- data/lib/nanoc/rule_dsl/action_provider.rb +3 -3
- data/lib/nanoc/rule_dsl/action_recorder.rb +3 -3
- data/lib/nanoc/rule_dsl/action_sequence_calculator.rb +7 -7
- data/lib/nanoc/rule_dsl/compilation_rule.rb +2 -2
- data/lib/nanoc/rule_dsl/compilation_rule_context.rb +9 -9
- data/lib/nanoc/rule_dsl/compiler_dsl.rb +4 -4
- data/lib/nanoc/rule_dsl/routing_rule.rb +3 -3
- data/lib/nanoc/rule_dsl/rule.rb +5 -5
- data/lib/nanoc/rule_dsl/rule_context.rb +3 -3
- data/lib/nanoc/rule_dsl/rules_collection.rb +4 -4
- data/lib/nanoc/spec.rb +15 -15
- data/lib/nanoc/version.rb +1 -1
- metadata +10 -111
- data/lib/nanoc/base/contracts_support.rb +0 -130
- data/lib/nanoc/base/core_ext.rb +0 -5
- data/lib/nanoc/base/core_ext/array.rb +0 -50
- data/lib/nanoc/base/core_ext/hash.rb +0 -54
- data/lib/nanoc/base/core_ext/string.rb +0 -16
- data/lib/nanoc/base/entities/code_snippet.rb +0 -53
- data/lib/nanoc/base/entities/configuration-schema.json +0 -122
- data/lib/nanoc/base/entities/configuration.rb +0 -206
- data/lib/nanoc/base/entities/content.rb +0 -112
- data/lib/nanoc/base/entities/context.rb +0 -70
- data/lib/nanoc/base/entities/directed_graph.rb +0 -195
- data/lib/nanoc/base/entities/document.rb +0 -125
- data/lib/nanoc/base/entities/identifiable_collection.rb +0 -141
- data/lib/nanoc/base/entities/identifier.rb +0 -222
- data/lib/nanoc/base/entities/item.rb +0 -10
- data/lib/nanoc/base/entities/item_collection.rb +0 -14
- data/lib/nanoc/base/entities/item_rep.rb +0 -91
- data/lib/nanoc/base/entities/layout.rb +0 -10
- data/lib/nanoc/base/entities/layout_collection.rb +0 -14
- data/lib/nanoc/base/entities/lazy_value.rb +0 -43
- data/lib/nanoc/base/entities/pattern.rb +0 -85
- data/lib/nanoc/base/entities/processing_action.rb +0 -21
- data/lib/nanoc/base/entities/processing_actions.rb +0 -5
- data/lib/nanoc/base/entities/processing_actions/filter.rb +0 -36
- data/lib/nanoc/base/entities/processing_actions/layout.rb +0 -36
- data/lib/nanoc/base/entities/processing_actions/snapshot.rb +0 -46
- data/lib/nanoc/base/entities/snapshot_def.rb +0 -22
- data/lib/nanoc/base/repos/data_source.rb +0 -168
- data/lib/nanoc/base/repos/snapshot_repo.rb +0 -67
- data/lib/nanoc/base/services/checksummer.rb +0 -274
- data/lib/nanoc/base/services/notification_center.rb +0 -87
- data/lib/nanoc/base/services/temp_filename_factory.rb +0 -52
@@ -1,141 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Nanoc::Int
|
4
|
-
# @api private
|
5
|
-
class IdentifiableCollection
|
6
|
-
DDMemoize.activate(self)
|
7
|
-
|
8
|
-
include Nanoc::Int::ContractsSupport
|
9
|
-
include Enumerable
|
10
|
-
|
11
|
-
extend Forwardable
|
12
|
-
|
13
|
-
def_delegator :@objects, :each
|
14
|
-
def_delegator :@objects, :size
|
15
|
-
|
16
|
-
def initialize(*)
|
17
|
-
raise 'IdentifiableCollection is abstract and cannot be instantiated'
|
18
|
-
end
|
19
|
-
|
20
|
-
contract C::Or[Hash, C::Named['Nanoc::Int::Configuration']], C::IterOf[C::RespondTo[:identifier]], C::Maybe[String] => C::Any
|
21
|
-
def initialize_basic(config, objects = [], name = nil)
|
22
|
-
@config = config
|
23
|
-
@objects = Hamster::Vector.new(objects)
|
24
|
-
@name = name
|
25
|
-
end
|
26
|
-
|
27
|
-
contract C::None => String
|
28
|
-
def inspect
|
29
|
-
"<#{self.class}>"
|
30
|
-
end
|
31
|
-
|
32
|
-
contract C::None => self
|
33
|
-
def freeze
|
34
|
-
@objects.freeze
|
35
|
-
@objects.each(&:freeze)
|
36
|
-
build_mapping
|
37
|
-
super
|
38
|
-
end
|
39
|
-
|
40
|
-
contract C::Any => C::Maybe[C::RespondTo[:identifier]]
|
41
|
-
def [](arg)
|
42
|
-
if frozen?
|
43
|
-
get_memoized(arg)
|
44
|
-
else
|
45
|
-
get_unmemoized(arg)
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
contract C::Any => C::IterOf[C::RespondTo[:identifier]]
|
50
|
-
def find_all(arg)
|
51
|
-
if frozen?
|
52
|
-
find_all_memoized(arg)
|
53
|
-
else
|
54
|
-
find_all_unmemoized(arg)
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
contract C::None => C::ArrayOf[C::RespondTo[:identifier]]
|
59
|
-
def to_a
|
60
|
-
@objects.to_a
|
61
|
-
end
|
62
|
-
|
63
|
-
contract C::None => C::Bool
|
64
|
-
def empty?
|
65
|
-
@objects.empty?
|
66
|
-
end
|
67
|
-
|
68
|
-
contract C::RespondTo[:identifier] => self
|
69
|
-
def add(obj)
|
70
|
-
self.class.new(@config, @objects.add(obj))
|
71
|
-
end
|
72
|
-
|
73
|
-
contract C::Func[C::RespondTo[:identifier] => C::Any] => self
|
74
|
-
def reject(&block)
|
75
|
-
self.class.new(@config, @objects.reject(&block))
|
76
|
-
end
|
77
|
-
|
78
|
-
contract C::Any => C::Maybe[C::RespondTo[:identifier]]
|
79
|
-
def object_with_identifier(identifier)
|
80
|
-
if frozen?
|
81
|
-
@mapping[identifier.to_s]
|
82
|
-
else
|
83
|
-
@objects.find { |i| i.identifier == identifier }
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
protected
|
88
|
-
|
89
|
-
contract C::Any => C::Maybe[C::RespondTo[:identifier]]
|
90
|
-
def get_unmemoized(arg)
|
91
|
-
case arg
|
92
|
-
when Nanoc::Identifier
|
93
|
-
object_with_identifier(arg)
|
94
|
-
when String
|
95
|
-
object_with_identifier(arg) || object_matching_glob(arg)
|
96
|
-
when Regexp
|
97
|
-
@objects.find { |i| i.identifier.to_s =~ arg }
|
98
|
-
else
|
99
|
-
raise ArgumentError, "don’t know how to fetch objects by #{arg.inspect}"
|
100
|
-
end
|
101
|
-
end
|
102
|
-
|
103
|
-
contract C::Any => C::Maybe[C::RespondTo[:identifier]]
|
104
|
-
memoized def get_memoized(arg)
|
105
|
-
get_unmemoized(arg)
|
106
|
-
end
|
107
|
-
|
108
|
-
contract C::Any => C::IterOf[C::RespondTo[:identifier]]
|
109
|
-
def find_all_unmemoized(arg)
|
110
|
-
pat = Nanoc::Int::Pattern.from(arg)
|
111
|
-
select { |i| pat.match?(i.identifier) }
|
112
|
-
end
|
113
|
-
|
114
|
-
contract C::Any => C::IterOf[C::RespondTo[:identifier]]
|
115
|
-
memoized def find_all_memoized(arg)
|
116
|
-
find_all_unmemoized(arg)
|
117
|
-
end
|
118
|
-
|
119
|
-
def object_matching_glob(glob)
|
120
|
-
if use_globs?
|
121
|
-
pat = Nanoc::Int::Pattern.from(glob)
|
122
|
-
@objects.find { |i| pat.match?(i.identifier) }
|
123
|
-
else
|
124
|
-
nil
|
125
|
-
end
|
126
|
-
end
|
127
|
-
|
128
|
-
def build_mapping
|
129
|
-
@mapping = {}
|
130
|
-
@objects.each do |object|
|
131
|
-
@mapping[object.identifier.to_s] = object
|
132
|
-
end
|
133
|
-
@mapping.freeze
|
134
|
-
end
|
135
|
-
|
136
|
-
contract C::None => C::Bool
|
137
|
-
def use_globs?
|
138
|
-
@config[:string_pattern_type] == 'glob'
|
139
|
-
end
|
140
|
-
end
|
141
|
-
end
|
@@ -1,222 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Nanoc
|
4
|
-
class Identifier
|
5
|
-
include Comparable
|
6
|
-
include Nanoc::Int::ContractsSupport
|
7
|
-
|
8
|
-
# @api private
|
9
|
-
class InvalidIdentifierError < ::Nanoc::Error
|
10
|
-
def initialize(string)
|
11
|
-
super("Invalid identifier (does not start with a slash): #{string.inspect}")
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
# @api private
|
16
|
-
class InvalidFullIdentifierError < ::Nanoc::Error
|
17
|
-
def initialize(string)
|
18
|
-
super("Invalid full identifier (ends with a slash): #{string.inspect}")
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
# @api private
|
23
|
-
class InvalidTypeError < ::Nanoc::Error
|
24
|
-
def initialize(type)
|
25
|
-
super("Invalid type for identifier: #{type.inspect} (can be :full or :legacy)")
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
# @api private
|
30
|
-
class InvalidPrefixError < ::Nanoc::Error
|
31
|
-
def initialize(string)
|
32
|
-
super("Invalid prefix (does not start with a slash): #{string.inspect}")
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
# @api private
|
37
|
-
class UnsupportedLegacyOperationError < ::Nanoc::Error
|
38
|
-
def initialize
|
39
|
-
super('Cannot use this method on legacy identifiers')
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
# @api private
|
44
|
-
class NonCoercibleObjectError < ::Nanoc::Error
|
45
|
-
def initialize(obj)
|
46
|
-
super("#{obj.inspect} cannot be converted into a Nanoc::Identifier")
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
contract C::Any => self
|
51
|
-
def self.from(obj)
|
52
|
-
case obj
|
53
|
-
when Nanoc::Identifier
|
54
|
-
obj
|
55
|
-
when String
|
56
|
-
Nanoc::Identifier.new(obj)
|
57
|
-
else
|
58
|
-
raise NonCoercibleObjectError.new(obj)
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
contract String, C::KeywordArgs[type: C::Optional[Symbol]] => C::Any
|
63
|
-
def initialize(string, type: :full)
|
64
|
-
@type = type
|
65
|
-
|
66
|
-
case @type
|
67
|
-
when :legacy
|
68
|
-
@string = "/#{string}/".gsub(/^\/+|\/+$/, '/').freeze
|
69
|
-
when :full
|
70
|
-
raise InvalidIdentifierError.new(string) if string !~ /\A\//
|
71
|
-
raise InvalidFullIdentifierError.new(string) if string =~ /\/\z/
|
72
|
-
|
73
|
-
@string = string.dup.freeze
|
74
|
-
else
|
75
|
-
raise InvalidTypeError.new(@type)
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
contract C::Any => C::Bool
|
80
|
-
def ==(other)
|
81
|
-
case other
|
82
|
-
when Nanoc::Identifier, String
|
83
|
-
to_s == other.to_s
|
84
|
-
else
|
85
|
-
false
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
contract C::Any => C::Bool
|
90
|
-
def eql?(other)
|
91
|
-
other.is_a?(self.class) && to_s == other.to_s
|
92
|
-
end
|
93
|
-
|
94
|
-
contract C::None => C::Num
|
95
|
-
def hash
|
96
|
-
self.class.hash ^ to_s.hash
|
97
|
-
end
|
98
|
-
|
99
|
-
contract C::Any => C::Maybe[C::Num]
|
100
|
-
def =~(other)
|
101
|
-
Nanoc::Int::Pattern.from(other).match?(to_s) ? 0 : nil
|
102
|
-
end
|
103
|
-
|
104
|
-
contract C::Any => C::Bool
|
105
|
-
def match?(other)
|
106
|
-
Nanoc::Int::Pattern.from(other).match?(to_s)
|
107
|
-
end
|
108
|
-
|
109
|
-
contract C::Any => C::Num
|
110
|
-
def <=>(other)
|
111
|
-
to_s <=> other.to_s
|
112
|
-
end
|
113
|
-
|
114
|
-
contract C::None => C::Bool
|
115
|
-
# Whether or not this is a full identifier (i.e.includes the extension).
|
116
|
-
def full?
|
117
|
-
@type == :full
|
118
|
-
end
|
119
|
-
|
120
|
-
contract C::None => C::Bool
|
121
|
-
# Whether or not this is a legacy identifier (i.e. does not include the extension).
|
122
|
-
def legacy?
|
123
|
-
@type == :legacy
|
124
|
-
end
|
125
|
-
|
126
|
-
contract C::None => String
|
127
|
-
# @return [String]
|
128
|
-
def chop
|
129
|
-
to_s.chop
|
130
|
-
end
|
131
|
-
|
132
|
-
contract String => String
|
133
|
-
# @return [String]
|
134
|
-
def +(other)
|
135
|
-
to_s + other
|
136
|
-
end
|
137
|
-
|
138
|
-
contract String => self
|
139
|
-
# @return [Nanoc::Identifier]
|
140
|
-
def prefix(string)
|
141
|
-
unless /\A\//.match?(string)
|
142
|
-
raise InvalidPrefixError.new(string)
|
143
|
-
end
|
144
|
-
|
145
|
-
Nanoc::Identifier.new(string.sub(/\/+\z/, '') + @string, type: @type)
|
146
|
-
end
|
147
|
-
|
148
|
-
contract C::None => String
|
149
|
-
# The identifier, as string, with the last extension removed
|
150
|
-
def without_ext
|
151
|
-
unless full?
|
152
|
-
raise UnsupportedLegacyOperationError
|
153
|
-
end
|
154
|
-
|
155
|
-
extname = File.extname(@string)
|
156
|
-
|
157
|
-
if !extname.empty?
|
158
|
-
@string[0..-extname.size - 1]
|
159
|
-
else
|
160
|
-
@string
|
161
|
-
end
|
162
|
-
end
|
163
|
-
|
164
|
-
contract C::None => C::Maybe[String]
|
165
|
-
# The extension, without a leading dot
|
166
|
-
def ext
|
167
|
-
unless full?
|
168
|
-
raise UnsupportedLegacyOperationError
|
169
|
-
end
|
170
|
-
|
171
|
-
s = File.extname(@string)
|
172
|
-
s && s[1..-1]
|
173
|
-
end
|
174
|
-
|
175
|
-
contract C::None => String
|
176
|
-
# The identifier, as string, with all extensions removed
|
177
|
-
def without_exts
|
178
|
-
extname = exts.join('.')
|
179
|
-
if !extname.empty?
|
180
|
-
@string[0..-extname.size - 2]
|
181
|
-
else
|
182
|
-
@string
|
183
|
-
end
|
184
|
-
end
|
185
|
-
|
186
|
-
contract C::None => C::ArrayOf[String]
|
187
|
-
# The list of extensions, without a leading dot
|
188
|
-
def exts
|
189
|
-
unless full?
|
190
|
-
raise UnsupportedLegacyOperationError
|
191
|
-
end
|
192
|
-
|
193
|
-
s = File.basename(@string)
|
194
|
-
s ? s.split('.', -1).drop(1) : []
|
195
|
-
end
|
196
|
-
|
197
|
-
contract C::None => C::ArrayOf[String]
|
198
|
-
def components
|
199
|
-
res = to_s.split('/')
|
200
|
-
if res.empty?
|
201
|
-
[]
|
202
|
-
else
|
203
|
-
res[1..-1]
|
204
|
-
end
|
205
|
-
end
|
206
|
-
|
207
|
-
contract C::None => String
|
208
|
-
def to_s
|
209
|
-
@string
|
210
|
-
end
|
211
|
-
|
212
|
-
contract C::None => String
|
213
|
-
def to_str
|
214
|
-
@string
|
215
|
-
end
|
216
|
-
|
217
|
-
contract C::None => String
|
218
|
-
def inspect
|
219
|
-
"<Nanoc::Identifier type=#{@type} #{to_s.inspect}>"
|
220
|
-
end
|
221
|
-
end
|
222
|
-
end
|
@@ -1,14 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Nanoc::Int
|
4
|
-
# @api private
|
5
|
-
class ItemCollection < IdentifiableCollection
|
6
|
-
def initialize(config, objects = [])
|
7
|
-
initialize_basic(config, objects, 'items')
|
8
|
-
end
|
9
|
-
|
10
|
-
def reference
|
11
|
-
'items'
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
@@ -1,91 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Nanoc::Int
|
4
|
-
# @api private
|
5
|
-
class ItemRep
|
6
|
-
include Nanoc::Int::ContractsSupport
|
7
|
-
|
8
|
-
contract C::None => C::Bool
|
9
|
-
attr_accessor :compiled
|
10
|
-
alias compiled? compiled
|
11
|
-
|
12
|
-
contract C::None => C::HashOf[Symbol => C::IterOf[String]]
|
13
|
-
attr_reader :raw_paths
|
14
|
-
|
15
|
-
contract C::None => C::HashOf[Symbol => C::IterOf[String]]
|
16
|
-
attr_reader :paths
|
17
|
-
|
18
|
-
contract C::None => Nanoc::Int::Item
|
19
|
-
attr_reader :item
|
20
|
-
|
21
|
-
contract C::None => Symbol
|
22
|
-
attr_reader :name
|
23
|
-
|
24
|
-
contract C::None => C::IterOf[C::Named['Nanoc::Int::SnapshotDef']]
|
25
|
-
attr_accessor :snapshot_defs
|
26
|
-
|
27
|
-
contract C::None => C::Bool
|
28
|
-
attr_accessor :modified
|
29
|
-
alias modified? modified
|
30
|
-
|
31
|
-
contract Nanoc::Int::Item, Symbol => C::Any
|
32
|
-
def initialize(item, name)
|
33
|
-
# Set primary attributes
|
34
|
-
@item = item
|
35
|
-
@name = name
|
36
|
-
|
37
|
-
# Set default attributes
|
38
|
-
@raw_paths = {}
|
39
|
-
@paths = {}
|
40
|
-
@snapshot_defs = []
|
41
|
-
|
42
|
-
# Reset flags
|
43
|
-
@compiled = false
|
44
|
-
@modified = false
|
45
|
-
end
|
46
|
-
|
47
|
-
contract C::HashOf[Symbol => C::IterOf[C::AbsolutePathString]] => C::HashOf[Symbol => C::IterOf[C::AbsolutePathString]]
|
48
|
-
def raw_paths=(val)
|
49
|
-
@raw_paths = val
|
50
|
-
end
|
51
|
-
|
52
|
-
contract C::HashOf[Symbol => C::IterOf[String]] => C::HashOf[Symbol => C::IterOf[String]]
|
53
|
-
def paths=(val)
|
54
|
-
@paths = val
|
55
|
-
end
|
56
|
-
|
57
|
-
contract Symbol => C::Bool
|
58
|
-
def snapshot?(name)
|
59
|
-
snapshot_defs.any? { |sd| sd.name == name }
|
60
|
-
end
|
61
|
-
|
62
|
-
contract C::KeywordArgs[snapshot: C::Optional[Symbol]] => C::Maybe[String]
|
63
|
-
# Returns the item rep’s raw path. It includes the path to the output
|
64
|
-
# directory and the full filename.
|
65
|
-
def raw_path(snapshot: :last)
|
66
|
-
@raw_paths.fetch(snapshot, []).first
|
67
|
-
end
|
68
|
-
|
69
|
-
contract C::KeywordArgs[snapshot: C::Optional[Symbol]] => C::Maybe[String]
|
70
|
-
# Returns the item rep’s path, as used when being linked to. It starts
|
71
|
-
# with a slash and it is relative to the output directory. It does not
|
72
|
-
# include the path to the output directory. It will not include the
|
73
|
-
# filename if the filename is an index filename.
|
74
|
-
def path(snapshot: :last)
|
75
|
-
@paths.fetch(snapshot, []).first
|
76
|
-
end
|
77
|
-
|
78
|
-
# Returns an object that can be used for uniquely identifying objects.
|
79
|
-
def reference
|
80
|
-
"item_rep:#{item.identifier}:#{name}"
|
81
|
-
end
|
82
|
-
|
83
|
-
def to_s
|
84
|
-
"#{item.identifier} (rep name #{name.inspect})"
|
85
|
-
end
|
86
|
-
|
87
|
-
def inspect
|
88
|
-
"<#{self.class} name=\"#{name}\" raw_path=\"#{raw_path}\" item.identifier=\"#{item.identifier}\">"
|
89
|
-
end
|
90
|
-
end
|
91
|
-
end
|