nanoc 4.11.12 → 4.11.13

Sign up to get free protection for your applications and to get access to all the features.
Files changed (124) hide show
  1. checksums.yaml +4 -4
  2. data/NEWS.md +7 -1
  3. data/bin/nanoc +1 -1
  4. data/lib/nanoc.rb +2 -27
  5. data/lib/nanoc/base.rb +3 -6
  6. data/lib/nanoc/base/errors.rb +6 -104
  7. data/lib/nanoc/checking/check.rb +4 -4
  8. data/lib/nanoc/checking/checks/external_links.rb +1 -1
  9. data/lib/nanoc/checking/checks/stale.rb +1 -1
  10. data/lib/nanoc/checking/runner.rb +2 -2
  11. data/lib/nanoc/data_sources/filesystem/tools.rb +4 -4
  12. data/lib/nanoc/extra.rb +1 -1
  13. data/lib/nanoc/helpers/blogging.rb +8 -8
  14. data/lib/nanoc/helpers/capturing.rb +1 -1
  15. data/lib/nanoc/helpers/link_to.rb +1 -1
  16. data/lib/nanoc/orig_cli.rb +20 -0
  17. data/lib/nanoc/{cli → orig_cli}/commands/check.rb +3 -3
  18. data/lib/nanoc/{cli → orig_cli}/commands/deploy.rb +8 -8
  19. data/lib/nanoc/{cli → orig_cli}/commands/show-rules.rb +3 -3
  20. data/lib/nanoc/rule_dsl/action_provider.rb +5 -5
  21. data/lib/nanoc/rule_dsl/action_recorder.rb +4 -4
  22. data/lib/nanoc/rule_dsl/compilation_rule_context.rb +1 -1
  23. data/lib/nanoc/rule_dsl/compiler_dsl.rb +1 -1
  24. data/lib/nanoc/rule_dsl/rule_context.rb +6 -6
  25. data/lib/nanoc/version.rb +1 -1
  26. metadata +13 -152
  27. data/lib/nanoc/base/error.rb +0 -7
  28. data/lib/nanoc/base/feature.rb +0 -104
  29. data/lib/nanoc/base/repos.rb +0 -4
  30. data/lib/nanoc/base/repos/config_loader.rb +0 -95
  31. data/lib/nanoc/base/repos/site_loader.rb +0 -102
  32. data/lib/nanoc/base/services.rb +0 -23
  33. data/lib/nanoc/base/services/compiler.rb +0 -214
  34. data/lib/nanoc/base/services/compiler/phases.rb +0 -19
  35. data/lib/nanoc/base/services/compiler/phases/abstract.rb +0 -50
  36. data/lib/nanoc/base/services/compiler/phases/cache.rb +0 -45
  37. data/lib/nanoc/base/services/compiler/phases/mark_done.rb +0 -25
  38. data/lib/nanoc/base/services/compiler/phases/notify.rb +0 -21
  39. data/lib/nanoc/base/services/compiler/phases/recalculate.rb +0 -51
  40. data/lib/nanoc/base/services/compiler/phases/resume.rb +0 -54
  41. data/lib/nanoc/base/services/compiler/phases/write.rb +0 -86
  42. data/lib/nanoc/base/services/compiler/stages.rb +0 -23
  43. data/lib/nanoc/base/services/compiler/stages/build_reps.rb +0 -38
  44. data/lib/nanoc/base/services/compiler/stages/calculate_checksums.rb +0 -44
  45. data/lib/nanoc/base/services/compiler/stages/cleanup.rb +0 -45
  46. data/lib/nanoc/base/services/compiler/stages/compile_reps.rb +0 -98
  47. data/lib/nanoc/base/services/compiler/stages/determine_outdatedness.rb +0 -51
  48. data/lib/nanoc/base/services/compiler/stages/forget_outdated_dependencies.rb +0 -22
  49. data/lib/nanoc/base/services/compiler/stages/load_stores.rb +0 -37
  50. data/lib/nanoc/base/services/compiler/stages/postprocess.rb +0 -23
  51. data/lib/nanoc/base/services/compiler/stages/preprocess.rb +0 -34
  52. data/lib/nanoc/base/services/compiler/stages/prune.rb +0 -32
  53. data/lib/nanoc/base/services/compiler/stages/store_post_compilation_state.rb +0 -22
  54. data/lib/nanoc/base/services/compiler/stages/store_pre_compilation_state.rb +0 -34
  55. data/lib/nanoc/base/services/compiler_loader.rb +0 -48
  56. data/lib/nanoc/base/services/executor.rb +0 -134
  57. data/lib/nanoc/base/services/filter.rb +0 -267
  58. data/lib/nanoc/base/services/item_rep_builder.rb +0 -54
  59. data/lib/nanoc/base/services/item_rep_selector.rb +0 -69
  60. data/lib/nanoc/base/services/item_rep_writer.rb +0 -86
  61. data/lib/nanoc/base/services/outdatedness_checker.rb +0 -222
  62. data/lib/nanoc/base/services/outdatedness_rules.rb +0 -18
  63. data/lib/nanoc/base/services/outdatedness_rules/attributes_modified.rb +0 -41
  64. data/lib/nanoc/base/services/outdatedness_rules/code_snippets_modified.rb +0 -31
  65. data/lib/nanoc/base/services/outdatedness_rules/content_modified.rb +0 -21
  66. data/lib/nanoc/base/services/outdatedness_rules/item_collection_extended.rb +0 -20
  67. data/lib/nanoc/base/services/outdatedness_rules/layout_collection_extended.rb +0 -20
  68. data/lib/nanoc/base/services/outdatedness_rules/not_written.rb +0 -17
  69. data/lib/nanoc/base/services/outdatedness_rules/rules_modified.rb +0 -45
  70. data/lib/nanoc/base/services/outdatedness_rules/uses_always_outdated_filter.rb +0 -26
  71. data/lib/nanoc/base/services/pruner.rb +0 -123
  72. data/lib/nanoc/base/views.rb +0 -40
  73. data/lib/nanoc/base/views/basic_item_rep_collection_view.rb +0 -86
  74. data/lib/nanoc/base/views/basic_item_rep_view.rb +0 -81
  75. data/lib/nanoc/base/views/basic_item_view.rb +0 -52
  76. data/lib/nanoc/base/views/compilation_item_rep_collection_view.rb +0 -10
  77. data/lib/nanoc/base/views/compilation_item_rep_view.rb +0 -49
  78. data/lib/nanoc/base/views/compilation_item_view.rb +0 -45
  79. data/lib/nanoc/base/views/config_view.rb +0 -68
  80. data/lib/nanoc/base/views/identifiable_collection_view.rb +0 -109
  81. data/lib/nanoc/base/views/item_collection_with_reps_view.rb +0 -10
  82. data/lib/nanoc/base/views/item_collection_without_reps_view.rb +0 -10
  83. data/lib/nanoc/base/views/layout_collection_view.rb +0 -10
  84. data/lib/nanoc/base/views/layout_view.rb +0 -7
  85. data/lib/nanoc/base/views/mixins/document_view_mixin.rb +0 -88
  86. data/lib/nanoc/base/views/mixins/mutable_document_view_mixin.rb +0 -58
  87. data/lib/nanoc/base/views/mutable_config_view.rb +0 -14
  88. data/lib/nanoc/base/views/mutable_identifiable_collection_view.rb +0 -17
  89. data/lib/nanoc/base/views/mutable_item_collection_view.rb +0 -32
  90. data/lib/nanoc/base/views/mutable_item_view.rb +0 -7
  91. data/lib/nanoc/base/views/mutable_layout_collection_view.rb +0 -24
  92. data/lib/nanoc/base/views/mutable_layout_view.rb +0 -7
  93. data/lib/nanoc/base/views/post_compile_item_collection_view.rb +0 -10
  94. data/lib/nanoc/base/views/post_compile_item_rep_collection_view.rb +0 -10
  95. data/lib/nanoc/base/views/post_compile_item_rep_view.rb +0 -31
  96. data/lib/nanoc/base/views/post_compile_item_view.rb +0 -18
  97. data/lib/nanoc/base/views/view.rb +0 -41
  98. data/lib/nanoc/cli.rb +0 -241
  99. data/lib/nanoc/cli/ansi_string_colorizer.rb +0 -28
  100. data/lib/nanoc/cli/cleaning_stream.rb +0 -160
  101. data/lib/nanoc/cli/command_runner.rb +0 -72
  102. data/lib/nanoc/cli/commands/compile.rb +0 -57
  103. data/lib/nanoc/cli/commands/compile_listeners/abstract.rb +0 -58
  104. data/lib/nanoc/cli/commands/compile_listeners/aggregate.rb +0 -50
  105. data/lib/nanoc/cli/commands/compile_listeners/debug_printer.rb +0 -100
  106. data/lib/nanoc/cli/commands/compile_listeners/diff_generator.rb +0 -101
  107. data/lib/nanoc/cli/commands/compile_listeners/file_action_printer.rb +0 -76
  108. data/lib/nanoc/cli/commands/compile_listeners/timing_recorder.rb +0 -170
  109. data/lib/nanoc/cli/commands/create-site.rb +0 -257
  110. data/lib/nanoc/cli/commands/nanoc.rb +0 -42
  111. data/lib/nanoc/cli/commands/prune.rb +0 -49
  112. data/lib/nanoc/cli/commands/shell.rb +0 -57
  113. data/lib/nanoc/cli/commands/show-data.rb +0 -185
  114. data/lib/nanoc/cli/commands/show-plugins.rb +0 -89
  115. data/lib/nanoc/cli/commands/view.rb +0 -68
  116. data/lib/nanoc/cli/error_handler.rb +0 -365
  117. data/lib/nanoc/cli/logger.rb +0 -75
  118. data/lib/nanoc/cli/stack_trace_writer.rb +0 -50
  119. data/lib/nanoc/cli/stream_cleaners.rb +0 -10
  120. data/lib/nanoc/cli/stream_cleaners/abstract.rb +0 -21
  121. data/lib/nanoc/cli/stream_cleaners/ansi_colors.rb +0 -13
  122. data/lib/nanoc/cli/stream_cleaners/utf8.rb +0 -17
  123. data/lib/nanoc/cli/transform.rb +0 -16
  124. data/lib/nanoc/spec.rb +0 -240
@@ -1,10 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # @api private
4
- module Nanoc::CLI::StreamCleaners
5
- end
6
-
7
- require_relative 'stream_cleaners/abstract'
8
-
9
- require_relative 'stream_cleaners/ansi_colors'
10
- require_relative 'stream_cleaners/utf8'
@@ -1,21 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Nanoc::CLI::StreamCleaners
4
- # Superclass for all stream cleaners. Stream cleaners have a single method,
5
- # {#clean}, that takes a string and returns a cleaned string. Stream cleaners
6
- # can have state, so they can act as a FSM.
7
- #
8
- # @abstract Subclasses must implement {#clean}
9
- #
10
- # @api private
11
- class Abstract
12
- # Returns a cleaned version of the given string.
13
- #
14
- # @param [String] str The string to clean
15
- #
16
- # @return [String] The cleaned string
17
- def clean(str) # rubocop:disable Lint/UnusedMethodArgument
18
- raise NotImplementedError, 'Subclasses of Nanoc::CLI::StreamCleaners::Abstract must implement #clean'
19
- end
20
- end
21
- end
@@ -1,13 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Nanoc::CLI::StreamCleaners
4
- # Removes ANSI color escape sequences.
5
- #
6
- # @api private
7
- class ANSIColors < Abstract
8
- # @see Nanoc::CLI::StreamCleaners::Abstract#clean
9
- def clean(str)
10
- str.gsub(/\e\[.+?m/, '')
11
- end
12
- end
13
- end
@@ -1,17 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Nanoc::CLI::StreamCleaners
4
- # Simplifies output by replacing UTF-8 characters with their ASCII decompositions.
5
- #
6
- # @api private
7
- class UTF8 < Abstract
8
- # @see Nanoc::CLI::StreamCleaners::Abstract#clean
9
- def clean(str)
10
- # FIXME: this decomposition is not generally usable
11
- str
12
- .unicode_normalize(:nfkd)
13
- .tr('─┼“”‘’', '-+""\'\'')
14
- .gsub('©', '(c)')
15
- end
16
- end
17
- end
@@ -1,16 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Nanoc::CLI
4
- # @api private
5
- module Transform
6
- module Port
7
- RANGE = (0x0001..0xffff).freeze
8
-
9
- def self.call(data)
10
- Integer(data).tap do |int|
11
- raise 'not a valid port' unless RANGE.cover?(int)
12
- end
13
- end
14
- end
15
- end
16
- end
@@ -1,240 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Nanoc
4
- # @api private
5
- module Spec
6
- module Helper
7
- def chdir(dir)
8
- here = Dir.getwd
9
- Dir.chdir(dir)
10
- yield
11
- ensure
12
- Dir.chdir(here)
13
- end
14
-
15
- def command?(cmd)
16
- TTY::Which.exist?(cmd)
17
- end
18
-
19
- def skip_unless_have_command(cmd)
20
- skip "Could not find external command \"#{cmd}\"" unless command?(cmd)
21
- end
22
-
23
- def skip_unless_gem_available(gem)
24
- require gem
25
- rescue LoadError
26
- skip "Could not load gem \"#{gem}\""
27
- end
28
-
29
- def sleep_until(max: 3.0)
30
- start = Time.now
31
- loop do
32
- diff = (Time.now - start).to_f
33
- if diff > max
34
- raise "Waited for #{diff}s for condition to become true, but it never did"
35
- end
36
-
37
- break if yield
38
-
39
- sleep 0.1
40
- end
41
- end
42
- end
43
-
44
- class HelperContext
45
- # @return [Nanoc::Core::DependencyTracker]
46
- attr_reader :dependency_tracker
47
-
48
- attr_reader :erbout
49
-
50
- # @param [Module] mod The helper module to create a context for
51
- def initialize(mod)
52
- @mod = mod
53
-
54
- @erbout = +''
55
- @action_sequence = {}
56
- @config = Nanoc::Core::Configuration.new(dir: Dir.getwd).with_defaults
57
- @reps = Nanoc::Core::ItemRepRepo.new
58
- @items = Nanoc::Core::ItemCollection.new(@config)
59
- @layouts = Nanoc::Core::LayoutCollection.new(@config)
60
- @dependency_tracker = Nanoc::Core::DependencyTracker.new(Object.new)
61
- @compiled_content_store = Nanoc::Core::CompiledContentStore.new
62
- @action_provider = new_action_provider
63
- end
64
-
65
- # Creates a new item and adds it to the site’s collection of items.
66
- #
67
- # @param [String] content The uncompiled item content
68
- #
69
- # @param [Hash] attributes A hash containing this item's attributes
70
- #
71
- # @param [Nanoc::Core::Identifier, String] identifier This item's identifier
72
- #
73
- # @return [Nanoc::CompilationItemView] A view for the newly created item
74
- def create_item(content, attributes, identifier)
75
- item = Nanoc::Core::Item.new(content, attributes, identifier)
76
- @items = @items.add(item)
77
- self
78
- end
79
-
80
- # Creates a new layout and adds it to the site’s collection of layouts.
81
- #
82
- # @param [String] content The raw layout content
83
- #
84
- # @param [Hash] attributes A hash containing this layout's attributes
85
- #
86
- # @param [Nanoc::Core::Identifier, String] identifier This layout's identifier
87
- #
88
- # @return [Nanoc::CompilationItemView] A view for the newly created layout
89
- def create_layout(content, attributes, identifier)
90
- layout = Nanoc::Core::Layout.new(content, attributes, identifier)
91
- @layouts = @layouts.add(layout)
92
- self
93
- end
94
-
95
- # Creates a new representation for the given item.
96
- #
97
- # @param [Nanoc::CompilationItemView] item The item to create a represetation for
98
- #
99
- # @param [String] path The path of the `:last` snapshot of this item representation
100
- # @param [Symbol] rep The rep name to create
101
- def create_rep(item, path, rep = :default)
102
- rep = Nanoc::Core::ItemRep.new(item._unwrap, rep)
103
- rep.paths[:last] = [path]
104
- @reps << rep
105
- self
106
- end
107
-
108
- # @return [Object] An object that includes the helper functions
109
- def helper
110
- mod = @mod
111
- klass = Class.new(Nanoc::Core::Context) { include mod }
112
- klass.new(assigns)
113
- end
114
-
115
- def item=(item)
116
- @item = item ? item._unwrap : nil
117
- end
118
-
119
- def item_rep=(item_rep)
120
- @item_rep = item_rep ? item_rep._unwrap : nil
121
- end
122
-
123
- # @return [Nanoc::MutableConfigView]
124
- def config
125
- assigns[:config]
126
- end
127
-
128
- # @return [Nanoc::CompilationItemView, nil]
129
- def item
130
- assigns[:item]
131
- end
132
-
133
- # @return [Nanoc::BasicItemRepView, nil]
134
- def item_rep
135
- assigns[:item_rep]
136
- end
137
-
138
- # @return [Nanoc::ItemCollectionWithRepsView]
139
- def items
140
- assigns[:items]
141
- end
142
-
143
- # @return [Nanoc::LayoutCollectionView]
144
- def layouts
145
- assigns[:layouts]
146
- end
147
-
148
- def action_sequence_for(obj)
149
- @action_sequence.fetch(obj, [])
150
- end
151
-
152
- def update_action_sequence(obj, memory)
153
- @action_sequence[obj] = memory
154
- end
155
-
156
- def compiled_content_store
157
- view_context.compiled_content_store
158
- end
159
-
160
- private
161
-
162
- def view_context
163
- compilation_context =
164
- Nanoc::Core::CompilationContext.new(
165
- action_provider: @action_provider,
166
- reps: @reps,
167
- site: site,
168
- compiled_content_cache: Nanoc::Core::CompiledContentCache.new(config: @config),
169
- compiled_content_store: @compiled_content_store,
170
- )
171
-
172
- Nanoc::Core::ViewContextForCompilation.new(
173
- reps: @reps,
174
- items: @items,
175
- dependency_tracker: @dependency_tracker,
176
- compilation_context: compilation_context,
177
- compiled_content_store: @compiled_content_store,
178
- )
179
- end
180
-
181
- def new_action_provider
182
- Class.new(Nanoc::Core::ActionProvider) do
183
- def self.for(_context)
184
- raise NotImplementedError
185
- end
186
-
187
- def initialize(context)
188
- @context = context
189
- end
190
-
191
- def rep_names_for(_item)
192
- [:default]
193
- end
194
-
195
- def action_sequence_for(obj)
196
- @context.action_sequence_for(obj)
197
- end
198
-
199
- def snapshots_defs_for(_rep)
200
- [Nanoc::Core::SnapshotDef.new(:last, binary: false)]
201
- end
202
- end.new(self)
203
- end
204
-
205
- def new_compiler_for(site)
206
- Nanoc::Int::CompilerLoader.new.load(site, action_provider: @action_provider)
207
- end
208
-
209
- def site
210
- @_site ||=
211
- Nanoc::Core::Site.new(
212
- config: @config,
213
- code_snippets: [],
214
- data_source: Nanoc::Core::InMemoryDataSource.new(@items, @layouts),
215
- )
216
- end
217
-
218
- def assigns
219
- {
220
- config: Nanoc::MutableConfigView.new(@config, view_context),
221
- item_rep: @item_rep ? Nanoc::CompilationItemRepView.new(@item_rep, view_context) : nil,
222
- item: @item ? Nanoc::CompilationItemView.new(@item, view_context) : nil,
223
- items: Nanoc::ItemCollectionWithRepsView.new(@items, view_context),
224
- layouts: Nanoc::LayoutCollectionView.new(@layouts, view_context),
225
- _erbout: @erbout,
226
- }
227
- end
228
- end
229
-
230
- module HelperHelper
231
- def ctx
232
- @_ctx ||= HelperContext.new(described_class)
233
- end
234
-
235
- def helper
236
- @_helper ||= ctx.helper
237
- end
238
- end
239
- end
240
- end