nanoc 4.9.3 → 4.9.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d01ae1a36cc8bd7ac120b0f9f26ec0017083ec01086d2c954a45f0e4814b0fa7
4
- data.tar.gz: f2bb6242846d090fb321f1136a70f955dba3b43696a0266965c225fb0fb13d7a
3
+ metadata.gz: c20cba14ea42f548aa3d9b8d04673dfb71caeaf66196aa9ca23d7a48548ab55d
4
+ data.tar.gz: bdfec8da51cf47946e97dc3121027c3519ef5e735ad744c5dea93237e8366f3a
5
5
  SHA512:
6
- metadata.gz: 2180c9c63d7d19d2e87aafa2ffe0094d9685e8b0b821b7bb171ad016009668850c3aab9860f5d78a0704b90f93602f34587c987bcff748aafce1910ca4b43782
7
- data.tar.gz: 53285c7562eb828a349f3d2ba42a0c022f4dd83a0e801432e5cffdf7d659e8755e9d742b4bd253d8fe05bef2ea293886892f8d57e270f2109f4f352715ee79f5
6
+ metadata.gz: 59c881e40b1e5fbb07888cc80cce9f7d994d0b3869b8e03b5d8e8f21cd9f1272f594250345ad1ed0fb10b9926b3098672cb62e6e759e4979bcc79e1ef4f55b27
7
+ data.tar.gz: e6ce2fa2784b0c942690eeeb7c564fed7ae8a15924a4737fe9b84a519e71e8551c877ca476bceb463b2c6137352976e46d4a378aa21199a6dfe8ed0453fad779
data/NEWS.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Nanoc news
2
2
 
3
+ ## 4.9.4 (2018-08-19)
4
+
5
+ Fixes:
6
+
7
+ * Fixed an issue where compiled content of items generated in the preprocessor would not be available in the postprocessor (#1341, #1348)
8
+
3
9
  ## 4.9.3 (2018-06-09)
4
10
 
5
11
  Enhancements:
@@ -1133,7 +1139,7 @@ Fixes:
1133
1139
 
1134
1140
  * Removed the list of available deployers from the `deploy` help text and moved
1135
1141
  them into a new `--list-deployers` option [Damien Pollet]
1136
- * Fixed warning about `__send__ `and `object_id` being redefined on Ruby
1142
+ * Fixed warning about `__send__` and `object_id` being redefined on Ruby
1137
1143
  1.8.x [Justin Hileman]
1138
1144
 
1139
1145
  Enhancements:
@@ -1523,7 +1529,7 @@ Deprecated:
1523
1529
 
1524
1530
  ## 3.0.2 (2009-11-07)
1525
1531
 
1526
- * Children-only identifier patterns no longer erroneously also match parent (e.g.` /foo/*/` no longer matches `/foo/`)
1532
+ * Children-only identifier patterns no longer erroneously also match parent (e.g. `/foo/*/` no longer matches `/foo/`)
1527
1533
  * The `create_site` command no longer uses those ugly HTML entities
1528
1534
  * Install message now mentions the IRC channel
1529
1535
 
@@ -1658,9 +1664,9 @@ Changed:
1658
1664
  Removed:
1659
1665
 
1660
1666
  * Several filters have been removed and replaced by newer filters:
1661
- * `eruby`: use `erb` or `erubis` instead
1662
- * `markdown`: use `bluecloth`, `rdiscount` or `maruku` instead
1663
- * `textile`: use `redcloth` instead
1667
+ * `eruby`: use `erb` or `erubis` instead
1668
+ * `markdown`: use `bluecloth`, `rdiscount` or `maruku` instead
1669
+ * `textile`: use `redcloth` instead
1664
1670
 
1665
1671
  ## 2.0.4 (2008-05-04)
1666
1672
 
@@ -1739,8 +1745,8 @@ Removed:
1739
1745
  * The `@pages` array now also contains uncompiled pages
1740
1746
  * Pages with `skip_output` set to true will not be outputted
1741
1747
  * Added new filters
1742
- * Textile/RedCloth
1743
- * Sass
1748
+ * Textile/RedCloth
1749
+ * Sass
1744
1750
  * nanoc now warns before overwriting in `create_site`, `create_page` and `create_template` (but not in compile)
1745
1751
 
1746
1752
  ## 1.2 (2007-06-05)
@@ -9,6 +9,7 @@ require_relative 'base/contracts_support'
9
9
  require_relative 'base/error'
10
10
  require_relative 'base/errors'
11
11
  require_relative 'base/changes_stream'
12
+ require_relative 'base/assertions'
12
13
 
13
14
  require_relative 'base/entities'
14
15
  require_relative 'base/feature'
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Nanoc
4
+ module Assertions
5
+ class AssertionFailure < Nanoc::Int::Errors::InternalInconsistency
6
+ end
7
+
8
+ module Mixin
9
+ def assert(assertion)
10
+ return unless Nanoc::Int::ContractsSupport.enabled?
11
+
12
+ unless assertion.call
13
+ raise AssertionFailure, "assertion failed: #{assertion.class}"
14
+ end
15
+ end
16
+ end
17
+
18
+ class Base
19
+ def call
20
+ raise NotImplementedError
21
+ end
22
+ end
23
+
24
+ class AllItemRepsHaveCompiledContent < Nanoc::Assertions::Base
25
+ def initialize(compiled_content_cache:, item_reps:)
26
+ @compiled_content_cache = compiled_content_cache
27
+ @item_reps = item_reps
28
+ end
29
+
30
+ def call
31
+ @item_reps.all? do |rep|
32
+ @compiled_content_cache[rep]
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
@@ -99,6 +99,10 @@ module Nanoc::Int
99
99
  @_contracts_support__should_enable
100
100
  end
101
101
 
102
+ def self.enabled?
103
+ setup_once
104
+ end
105
+
102
106
  def self.included(base)
103
107
  should_enable = setup_once
104
108
 
@@ -120,11 +120,6 @@ module Nanoc::Int
120
120
  @wrapped[key] = value
121
121
  end
122
122
 
123
- def merge_recursively(c1, c2)
124
- c1.merge(c2) { |_, v1, v2| v1.is_a?(Hash) && v2.is_a?(Hash) ? merge_recursively(v1, v2) : v2 }
125
- end
126
- private :merge_recursively
127
-
128
123
  contract C::Or[Hash, self] => self
129
124
  def merge(hash)
130
125
  self.class.new(hash: merge_recursively(@wrapped, hash.to_h), env_name: @env_name)
@@ -181,5 +176,17 @@ module Nanoc::Int
181
176
  def inspect
182
177
  "<#{self.class}>"
183
178
  end
179
+
180
+ private
181
+
182
+ def merge_recursively(config1, config2)
183
+ config1.merge(config2) do |_, value1, value2|
184
+ if value1.is_a?(Hash) && value2.is_a?(Hash)
185
+ merge_recursively(value1, value2)
186
+ else
187
+ value2
188
+ end
189
+ end
190
+ end
184
191
  end
185
192
  end
@@ -8,11 +8,10 @@ module Nanoc::Int
8
8
  class CompiledContentCache < ::Nanoc::Int::Store
9
9
  include Nanoc::Int::ContractsSupport
10
10
 
11
- contract C::KeywordArgs[config: Nanoc::Int::Configuration, items: C::IterOf[Nanoc::Int::Item]] => C::Any
12
- def initialize(config:, items:)
11
+ contract C::KeywordArgs[config: Nanoc::Int::Configuration] => C::Any
12
+ def initialize(config:)
13
13
  super(Nanoc::Int::Store.tmp_path_for(config: config, store_name: 'compiled_content'), 2)
14
14
 
15
- @items = items
16
15
  @cache = {}
17
16
  end
18
17
 
@@ -36,6 +35,14 @@ module Nanoc::Int
36
35
  @cache[rep.item.identifier][rep.name] = content
37
36
  end
38
37
 
38
+ def prune(items:)
39
+ item_identifiers = Set.new(items.map(&:identifier))
40
+
41
+ @cache.keys.each do |key|
42
+ @cache.delete(key) unless item_identifiers.include?(key)
43
+ end
44
+ end
45
+
39
46
  protected
40
47
 
41
48
  def data
@@ -45,12 +52,8 @@ module Nanoc::Int
45
52
  def data=(new_data)
46
53
  @cache = {}
47
54
 
48
- item_identifiers = Set.new(@items.map(&:identifier))
49
-
50
55
  new_data.each_pair do |item_identifier, content_per_rep|
51
- if item_identifiers.include?(item_identifier)
52
- @cache[item_identifier] ||= content_per_rep
53
- end
56
+ @cache[item_identifier] ||= content_per_rep
54
57
  end
55
58
  end
56
59
  end
@@ -2,6 +2,9 @@
2
2
 
3
3
  module Nanoc::Int::Compiler::Stages
4
4
  class CompileReps < Nanoc::Int::Compiler::Stage
5
+ include Nanoc::Int::ContractsSupport
6
+ include Nanoc::Assertions::Mixin
7
+
5
8
  def initialize(reps:, outdatedness_store:, dependency_store:, action_sequences:, compilation_context:, compiled_content_cache:)
6
9
  @reps = reps
7
10
  @outdatedness_store = outdatedness_store
@@ -21,8 +24,14 @@ module Nanoc::Int::Compiler::Stages
21
24
  end
22
25
  end
23
26
  end
27
+
28
+ assert Nanoc::Assertions::AllItemRepsHaveCompiledContent.new(
29
+ compiled_content_cache: @compiled_content_cache,
30
+ item_reps: @reps,
31
+ )
24
32
  ensure
25
33
  @outdatedness_store.store
34
+ @compiled_content_cache.prune(items: @reps.map(&:item).uniq)
26
35
  @compiled_content_cache.store
27
36
  end
28
37
 
@@ -20,10 +20,7 @@ module Nanoc::Int
20
20
  Nanoc::Int::OutdatednessStore.new(config: site.config)
21
21
 
22
22
  compiled_content_cache =
23
- Nanoc::Int::CompiledContentCache.new(
24
- config: site.config,
25
- items: site.items,
26
- )
23
+ Nanoc::Int::CompiledContentCache.new(config: site.config)
27
24
 
28
25
  params = {
29
26
  compiled_content_cache: compiled_content_cache,
@@ -21,6 +21,7 @@ require_relative 'cli/cleaning_stream'
21
21
  require_relative 'cli/stream_cleaners'
22
22
  require_relative 'cli/error_handler'
23
23
  require_relative 'cli/stack_trace_writer'
24
+ require_relative 'cli/transform'
24
25
 
25
26
  require_relative 'cli/commands/compile_listeners/abstract'
26
27
  require_relative 'cli/commands/compile_listeners/debug_printer'
@@ -5,6 +5,7 @@ summary 'compile items of this site'
5
5
  description <<~EOS
6
6
  Compile all items of the current site.
7
7
  EOS
8
+ no_params
8
9
 
9
10
  flag nil, :diff, 'generate diff'
10
11
  if Nanoc::Feature.enabled?(Nanoc::Feature::LIVE_CMD)
@@ -5,6 +5,7 @@ aliases :create_site, :cs
5
5
  summary 'create a site'
6
6
  description 'Create a new site at the given path. The site will use the `filesystem` data source.'
7
7
  flag nil, :force, 'force creation of new site'
8
+ param :path
8
9
 
9
10
  module Nanoc::CLI::Commands
10
11
  class CreateSite < ::Nanoc::CLI::CommandRunner
@@ -29,7 +30,7 @@ module Nanoc::CLI::Commands
29
30
  data_sources:
30
31
  - type: filesystem
31
32
  encoding: utf-8
32
- EOS
33
+ EOS
33
34
 
34
35
  DEFAULT_RULES = <<~EOS unless defined? DEFAULT_RULES
35
36
  #!/usr/bin/env ruby
@@ -59,7 +60,7 @@ EOS
59
60
  end
60
61
 
61
62
  layout '/**/*', :erb
62
- EOS
63
+ EOS
63
64
 
64
65
  DEFAULT_ITEM = <<~EOS unless defined? DEFAULT_ITEM
65
66
  ---
@@ -76,7 +77,7 @@ EOS
76
77
  </ul>
77
78
 
78
79
  <p>If you need any help with customizing your Nanoc web site, be sure to check out the documentation (see sidebar), and be sure to subscribe to the discussion group (also see sidebar). Enjoy!</p>
79
- EOS
80
+ EOS
80
81
 
81
82
  DEFAULT_STYLESHEET = <<~EOS unless defined? DEFAULT_STYLESHEET
82
83
  * {
@@ -180,7 +181,7 @@ EOS
180
181
 
181
182
  line-height: 20px;
182
183
  }
183
- EOS
184
+ EOS
184
185
 
185
186
  DEFAULT_LAYOUT = <<~EOS unless defined? DEFAULT_LAYOUT
186
187
  <!DOCTYPE HTML>
@@ -212,14 +213,10 @@ EOS
212
213
  </div>
213
214
  </body>
214
215
  </html>
215
- EOS
216
+ EOS
216
217
 
217
218
  def run
218
- # Extract arguments
219
- if arguments.length != 1
220
- raise Nanoc::Int::Errors::GenericTrivial, "usage: #{command.usage}"
221
- end
222
- path = arguments[0]
219
+ path = arguments[:path]
223
220
 
224
221
  # Check whether site exists
225
222
  if File.exist?(path) && (!File.directory?(path) || !(Dir.entries(path) - %w[. ..]).empty?) && !options[:force]
@@ -10,6 +10,7 @@ description <<~EOS
10
10
  Also see the `auto_prune` configuration option in `nanoc.yaml` (`config.yaml`
11
11
  for older Nanoc sites), which will automatically prune after compilation.
12
12
  EOS
13
+ no_params
13
14
 
14
15
  flag :y, :yes, 'confirm deletion'
15
16
  flag :n, :'dry-run', 'print files to be deleted instead of actually deleting them'
@@ -7,6 +7,7 @@ description "
7
7
  Open an IRB shell on a context that contains @items, @layouts, and @config.
8
8
  "
9
9
  flag :p, :preprocess, 'run preprocessor'
10
+ no_params
10
11
 
11
12
  module Nanoc::CLI::Commands
12
13
  class Shell < ::Nanoc::CLI::CommandRunner
@@ -7,6 +7,7 @@ description <<~EOS
7
7
  Show information about all items, item representations and layouts in the
8
8
  current site, along with dependency information.
9
9
  EOS
10
+ no_params
10
11
 
11
12
  module Nanoc::CLI::Commands
12
13
  class ShowData < ::Nanoc::CLI::CommandRunner
@@ -7,15 +7,11 @@ description <<~EOS
7
7
  Show a list of available plugins, including filters and data sources.
8
8
  If the current directory contains a Nanoc web site, the plugins defined in this site will be shown as well.
9
9
  EOS
10
+ no_params
10
11
 
11
12
  module Nanoc::CLI::Commands
12
13
  class ShowPlugins < ::Nanoc::CLI::CommandRunner
13
14
  def run
14
- # Check arguments
15
- if arguments.any?
16
- raise Nanoc::Int::Errors::GenericTrivial, "usage: #{command.usage}"
17
- end
18
-
19
15
  # Get list of plugins (before and after)
20
16
  plugins_before = PLUGIN_CLASSES.keys.each_with_object({}) { |c, acc| acc[c] = c.all }
21
17
  site = load_site
@@ -6,6 +6,7 @@ summary 'describe the rules for each item'
6
6
  description "
7
7
  Prints the rules used for all items and layouts in the current site.
8
8
  "
9
+ no_params
9
10
 
10
11
  module Nanoc::CLI::Commands
11
12
  class ShowRules < ::Nanoc::CLI::CommandRunner
@@ -9,9 +9,10 @@ description <<~EOS
9
9
  EOS
10
10
 
11
11
  required :H, :handler, 'specify the handler to use (webrick/mongrel/...)'
12
- required :o, :host, 'specify the host to listen on (default: 127.0.0.1)'
13
- required :p, :port, 'specify the port to listen on (default: 3000)'
12
+ required :o, :host, 'specify the host to listen on (default: 127.0.0.1)', default: '127.0.0.1'
13
+ required :p, :port, 'specify the port to listen on (default: 3000)', transform: Nanoc::CLI::Transform::Port, default: 3000
14
14
  flag :L, :'live-reload', 'reload on changes'
15
+ no_params
15
16
 
16
17
  module Nanoc::CLI::Commands
17
18
  class View < ::Nanoc::CLI::CommandRunner
@@ -30,8 +31,8 @@ module Nanoc::CLI::Commands
30
31
  root: File.absolute_path(config[:output_dir]),
31
32
  live: options[:'live-reload'],
32
33
  index_filenames: config[:index_filenames],
33
- host: (options[:host] || '127.0.0.1'),
34
- port: (options[:port] || 3000).to_i,
34
+ host: options.fetch(:host),
35
+ port: options.fetch(:port),
35
36
  handler: options[:handler],
36
37
  )
37
38
 
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Nanoc::CLI
4
+ # @api private
5
+ module Transform
6
+ module Port
7
+ RANGE = 0x0001..0xffff
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
@@ -33,6 +33,8 @@ class Nanoc::DataSources::Filesystem < Nanoc::DataSource
33
33
  end
34
34
  end
35
35
 
36
+ module_function
37
+
36
38
  # Returns all files in the given directory and directories below it,
37
39
  # following symlinks up to a maximum of `recursion_limit` times.
38
40
  #
@@ -78,7 +80,6 @@ class Nanoc::DataSources::Filesystem < Nanoc::DataSource
78
80
  end
79
81
  end.compact.flatten
80
82
  end
81
- module_function :all_files_in
82
83
 
83
84
  # Returns all files and directories in the given directory and
84
85
  # directories below it.
@@ -114,7 +115,6 @@ class Nanoc::DataSources::Filesystem < Nanoc::DataSource
114
115
  patterns = base_patterns + extra_patterns
115
116
  Dir.glob(patterns)
116
117
  end
117
- module_function :all_files_and_dirs_in
118
118
 
119
119
  # Resolves the given symlink into an absolute path.
120
120
  #
@@ -147,7 +147,6 @@ class Nanoc::DataSources::Filesystem < Nanoc::DataSource
147
147
  raise UnsupportedFileTypeError.new(absolute_target)
148
148
  end
149
149
  end
150
- module_function :resolve_symlink
151
150
 
152
151
  # Reads the content of the file with the given name and returns a string
153
152
  # in UTF-8 encoding. The original encoding of the string is derived from
@@ -186,6 +185,5 @@ class Nanoc::DataSources::Filesystem < Nanoc::DataSource
186
185
 
187
186
  data
188
187
  end
189
- module_function :read_file
190
188
  end
191
189
  end
@@ -21,7 +21,7 @@ module Nanoc::Extra
21
21
 
22
22
  For details, see https://github.com/nanoc/nanoc/pull/422.
23
23
  --------------------------------------------------------------------------------
24
- EOS
24
+ EOS
25
25
 
26
26
  def self.check_and_warn
27
27
  instance.check_and_warn
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Nanoc
4
4
  # The current Nanoc version.
5
- VERSION = '4.9.3'
5
+ VERSION = '4.9.4'
6
6
  end
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.9.3
4
+ version: 4.9.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Denis Defreyne
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-06-09 00:00:00.000000000 Z
11
+ date: 2018-08-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '2.8'
33
+ version: '2.13'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '2.8'
40
+ version: '2.13'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: ddmemoize
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -166,6 +166,7 @@ files:
166
166
  - bin/nanoc
167
167
  - lib/nanoc.rb
168
168
  - lib/nanoc/base.rb
169
+ - lib/nanoc/base/assertions.rb
169
170
  - lib/nanoc/base/changes_stream.rb
170
171
  - lib/nanoc/base/contracts_support.rb
171
172
  - lib/nanoc/base/core_ext.rb
@@ -340,6 +341,7 @@ files:
340
341
  - lib/nanoc/cli/stream_cleaners/abstract.rb
341
342
  - lib/nanoc/cli/stream_cleaners/ansi_colors.rb
342
343
  - lib/nanoc/cli/stream_cleaners/utf8.rb
344
+ - lib/nanoc/cli/transform.rb
343
345
  - lib/nanoc/data_sources.rb
344
346
  - lib/nanoc/data_sources/filesystem.rb
345
347
  - lib/nanoc/data_sources/filesystem/errors.rb