nanoc 4.8.19 → 4.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +1 -1
  3. data/NEWS.md +21 -0
  4. data/lib/nanoc.rb +5 -4
  5. data/lib/nanoc/base/entities/directed_graph.rb +4 -4
  6. data/lib/nanoc/base/entities/identifier.rb +5 -0
  7. data/lib/nanoc/base/feature.rb +1 -2
  8. data/lib/nanoc/base/repos/dependency_store.rb +4 -4
  9. data/lib/nanoc/base/services/compiler/phases/abstract.rb +8 -0
  10. data/lib/nanoc/base/services/compiler/phases/write.rb +58 -1
  11. data/lib/nanoc/base/services/compiler/stages/compile_reps.rb +39 -29
  12. data/lib/nanoc/base/services/compiler/stages/determine_outdatedness.rb +2 -2
  13. data/lib/nanoc/base/services/instrumentor.rb +1 -1
  14. data/lib/nanoc/base/services/item_rep_writer.rb +2 -2
  15. data/lib/nanoc/base/views/compilation_item_rep_view.rb +7 -0
  16. data/lib/nanoc/checking.rb +4 -1
  17. data/lib/nanoc/checking/check.rb +7 -0
  18. data/lib/nanoc/checking/checks/external_links.rb +21 -12
  19. data/lib/nanoc/checking/dsl.rb +5 -7
  20. data/lib/nanoc/checking/loader.rb +50 -0
  21. data/lib/nanoc/checking/runner.rb +18 -40
  22. data/lib/nanoc/cli.rb +1 -1
  23. data/lib/nanoc/cli/ansi_string_colorizer.rb +4 -4
  24. data/lib/nanoc/cli/cleaning_stream.rb +12 -12
  25. data/lib/nanoc/cli/commands/check.rb +5 -15
  26. data/lib/nanoc/cli/commands/compile_listeners/diff_generator.rb +7 -7
  27. data/lib/nanoc/cli/commands/compile_listeners/file_action_printer.rb +12 -2
  28. data/lib/nanoc/cli/commands/compile_listeners/timing_recorder.rb +27 -19
  29. data/lib/nanoc/cli/commands/deploy.rb +1 -1
  30. data/lib/nanoc/cli/commands/show-rules.rb +2 -2
  31. data/lib/nanoc/cli/error_handler.rb +1 -4
  32. data/lib/nanoc/cli/stream_cleaners/abstract.rb +2 -2
  33. data/lib/nanoc/cli/stream_cleaners/ansi_colors.rb +2 -2
  34. data/lib/nanoc/cli/stream_cleaners/utf8.rb +2 -2
  35. data/lib/nanoc/data_sources/filesystem/parser.rb +1 -1
  36. data/lib/nanoc/deploying/deployers/fog.rb +3 -3
  37. data/lib/nanoc/extra.rb +1 -2
  38. data/lib/nanoc/filters/colorize_syntax.rb +2 -2
  39. data/lib/nanoc/filters/relativize_paths.rb +2 -2
  40. data/lib/nanoc/helpers/blogging.rb +11 -11
  41. data/lib/nanoc/rule_dsl/compilation_rule_context.rb +1 -1
  42. data/lib/nanoc/version.rb +1 -1
  43. metadata +27 -13
  44. data/lib/nanoc/extra/parallel_collection.rb +0 -57
@@ -89,7 +89,7 @@ module Nanoc::CLI::Commands
89
89
 
90
90
  def check
91
91
  runner = Nanoc::Checking::Runner.new(@site)
92
- if runner.dsl_present?
92
+ if runner.any_enabled_checks?
93
93
  puts 'Running issue checks…'
94
94
  is_success = runner.run_for_deploy
95
95
  if is_success
@@ -54,8 +54,8 @@ module Nanoc::CLI::Commands
54
54
  puts
55
55
  end
56
56
 
57
- def fmt_heading(s)
58
- Nanoc::CLI::ANSIStringColorizer.c(s, :bold, :yellow)
57
+ def fmt_heading(str)
58
+ Nanoc::CLI::ANSIStringColorizer.c(str, :bold, :yellow)
59
59
  end
60
60
  end
61
61
  end
@@ -150,10 +150,7 @@ module Nanoc::CLI
150
150
 
151
151
  # @api private
152
152
  def forwards_stack_trace?
153
- feature_enabled = Nanoc::Feature.enabled?(Nanoc::Feature::SENSIBLE_STACK_TRACES)
154
- ruby_2_5_used = ruby_version.start_with?('2.5')
155
-
156
- feature_enabled || ruby_2_5_used
153
+ ruby_version.start_with?('2.5')
157
154
  end
158
155
 
159
156
  # @api private
@@ -11,10 +11,10 @@ module Nanoc::CLI::StreamCleaners
11
11
  class Abstract
12
12
  # Returns a cleaned version of the given string.
13
13
  #
14
- # @param [String] s The string to clean
14
+ # @param [String] str The string to clean
15
15
  #
16
16
  # @return [String] The cleaned string
17
- def clean(s) # rubocop:disable Lint/UnusedMethodArgument
17
+ def clean(str) # rubocop:disable Lint/UnusedMethodArgument
18
18
  raise NotImplementedError, 'Subclasses of Nanoc::CLI::StreamCleaners::Abstract must implement #clean'
19
19
  end
20
20
  end
@@ -6,8 +6,8 @@ module Nanoc::CLI::StreamCleaners
6
6
  # @api private
7
7
  class ANSIColors < Abstract
8
8
  # @see Nanoc::CLI::StreamCleaners::Abstract#clean
9
- def clean(s)
10
- s.gsub(/\e\[.+?m/, '')
9
+ def clean(str)
10
+ str.gsub(/\e\[.+?m/, '')
11
11
  end
12
12
  end
13
13
  end
@@ -6,9 +6,9 @@ module Nanoc::CLI::StreamCleaners
6
6
  # @api private
7
7
  class UTF8 < Abstract
8
8
  # @see Nanoc::CLI::StreamCleaners::Abstract#clean
9
- def clean(s)
9
+ def clean(str)
10
10
  # FIXME: this decomposition is not generally usable
11
- s
11
+ str
12
12
  .unicode_normalize(:nfkd)
13
13
  .tr('─┼“”‘’', '-+""\'\'')
14
14
  .gsub('©', '(c)')
@@ -52,7 +52,7 @@ class Nanoc::DataSources::Filesystem
52
52
  end
53
53
 
54
54
  meta = parse_metadata(pieces[2], content_filename)
55
- content = pieces[4]
55
+ content = pieces[4].sub(/\A\n/, '')
56
56
 
57
57
  ParseResult.new(content: content, attributes: meta, attributes_data: pieces[2])
58
58
  end
@@ -71,11 +71,11 @@ module Nanoc::Deploying::Deployers
71
71
  @is_dry_run
72
72
  end
73
73
 
74
- def log_effectful(s)
74
+ def log_effectful(str)
75
75
  if @is_dry_run
76
- puts "[dry run] #{s}"
76
+ puts "[dry run] #{str}"
77
77
  else
78
- puts s
78
+ puts str
79
79
  end
80
80
  end
81
81
  end
data/lib/nanoc/extra.rb CHANGED
@@ -15,8 +15,7 @@ module Nanoc::Extra
15
15
  Pruner = Nanoc::Pruner
16
16
  end
17
17
 
18
- require_relative 'extra/link_collector.rb'
18
+ require_relative 'extra/link_collector'
19
19
  require_relative 'extra/piper'
20
20
  require_relative 'extra/jruby_nokogiri_warner'
21
21
  require_relative 'extra/core_ext'
22
- require_relative 'extra/parallel_collection'
@@ -128,8 +128,8 @@ module Nanoc::Filters
128
128
  protected
129
129
 
130
130
  # Removes the first blank lines and any whitespace at the end.
131
- def strip(s)
132
- s.lines.drop_while { |line| line.strip.empty? }.join.rstrip
131
+ def strip(str)
132
+ str.lines.drop_while { |line| line.strip.empty? }.join.rstrip
133
133
  end
134
134
 
135
135
  def colorizer_name_for(language)
@@ -136,8 +136,8 @@ module Nanoc::Filters
136
136
  node.replace(Nokogiri::XML::Comment.new(doc, content))
137
137
  end
138
138
 
139
- def path_is_relativizable?(s)
140
- s.start_with?('/')
139
+ def path_is_relativizable?(path)
140
+ path.start_with?('/')
141
141
  end
142
142
  end
143
143
  end
@@ -137,25 +137,25 @@ module Nanoc::Helpers
137
137
  end
138
138
  end
139
139
 
140
- def build_for_article(a, xml)
140
+ def build_for_article(article, xml)
141
141
  # Get URL
142
- url = url_for(a)
142
+ url = url_for(article)
143
143
  return if url.nil?
144
144
 
145
145
  xml.entry do
146
146
  # Add primary attributes
147
- xml.id atom_tag_for(a)
148
- xml.title a[:title], type: 'html'
147
+ xml.id atom_tag_for(article)
148
+ xml.title article[:title], type: 'html'
149
149
 
150
150
  # Add dates
151
- xml.published attribute_to_time(a[:created_at]).__nanoc_to_iso8601_time
152
- xml.updated attribute_to_time(a[:updated_at] || a[:created_at]).__nanoc_to_iso8601_time
151
+ xml.published attribute_to_time(article[:created_at]).__nanoc_to_iso8601_time
152
+ xml.updated attribute_to_time(article[:updated_at] || article[:created_at]).__nanoc_to_iso8601_time
153
153
 
154
154
  # Add specific author information
155
- if a[:author_name] || a[:author_uri]
155
+ if article[:author_name] || article[:author_uri]
156
156
  xml.author do
157
- xml.name a[:author_name] || author_name
158
- xml.uri a[:author_uri] || author_uri
157
+ xml.name article[:author_name] || author_name
158
+ xml.uri article[:author_uri] || author_uri
159
159
  end
160
160
  end
161
161
 
@@ -163,8 +163,8 @@ module Nanoc::Helpers
163
163
  xml.link(rel: 'alternate', href: url)
164
164
 
165
165
  # Add content
166
- summary = excerpt_proc.call(a)
167
- xml.content content_proc.call(a), type: 'html'
166
+ summary = excerpt_proc.call(article)
167
+ xml.content content_proc.call(article), type: 'html'
168
168
  xml.summary summary, type: 'html' unless summary.nil?
169
169
  end
170
170
  end
@@ -64,7 +64,7 @@ module Nanoc::RuleDSL
64
64
  #
65
65
  # @see #snapshot
66
66
  #
67
- # @param [String] path
67
+ # @param [String] arg
68
68
  #
69
69
  # @return [void]
70
70
  def write(arg)
data/lib/nanoc/version.rb CHANGED
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Nanoc
4
4
  # The current Nanoc version.
5
- VERSION = '4.8.19'
5
+ VERSION = '4.9.0'
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.8.19
4
+ version: 4.9.0
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-01-01 00:00:00.000000000 Z
11
+ date: 2018-01-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable
@@ -42,18 +42,18 @@ dependencies:
42
42
  name: ddmemoize
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '='
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 1.0.0a3
47
+ version: '1.0'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '='
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 1.0.0a3
54
+ version: '1.0'
55
55
  - !ruby/object:Gem::Dependency
56
- name: ddplugin
56
+ name: ddmetrics
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
@@ -67,19 +67,19 @@ dependencies:
67
67
  - !ruby/object:Gem::Version
68
68
  version: '1.0'
69
69
  - !ruby/object:Gem::Dependency
70
- name: ddtelemetry
70
+ name: ddplugin
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - '='
73
+ - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: 1.0.0a2
75
+ version: '1.0'
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - '='
80
+ - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: 1.0.0a2
82
+ version: '1.0'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: hamster
85
85
  requirement: !ruby/object:Gem::Requirement
@@ -94,6 +94,20 @@ dependencies:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
96
  version: '3.0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: parallel
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '1.12'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '1.12'
97
111
  - !ruby/object:Gem::Dependency
98
112
  name: ref
99
113
  requirement: !ruby/object:Gem::Requirement
@@ -282,6 +296,7 @@ files:
282
296
  - lib/nanoc/checking/checks/w3c_validator.rb
283
297
  - lib/nanoc/checking/dsl.rb
284
298
  - lib/nanoc/checking/issue.rb
299
+ - lib/nanoc/checking/loader.rb
285
300
  - lib/nanoc/checking/runner.rb
286
301
  - lib/nanoc/cli.rb
287
302
  - lib/nanoc/cli/ansi_string_colorizer.rb
@@ -328,7 +343,6 @@ files:
328
343
  - lib/nanoc/extra/core_ext/time.rb
329
344
  - lib/nanoc/extra/jruby_nokogiri_warner.rb
330
345
  - lib/nanoc/extra/link_collector.rb
331
- - lib/nanoc/extra/parallel_collection.rb
332
346
  - lib/nanoc/extra/piper.rb
333
347
  - lib/nanoc/filters.rb
334
348
  - lib/nanoc/filters/asciidoc.rb
@@ -1,57 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Nanoc::Extra
4
- # @api private
5
- class ParallelCollection
6
- STOP = Object.new
7
-
8
- include Nanoc::Int::ContractsSupport
9
-
10
- contract C::RespondTo[:each], C::KeywordArgs[parallelism: Integer] => C::Any
11
- def initialize(enum, parallelism: 2)
12
- @enum = enum
13
- @parallelism = parallelism
14
- end
15
-
16
- contract C::Func[C::Any => C::Any] => self
17
- def each
18
- queue = SizedQueue.new(2 * @parallelism)
19
- error = nil
20
-
21
- threads = (1..@parallelism).map do
22
- Thread.new do
23
- loop do
24
- begin
25
- elem = queue.pop
26
- break if error
27
- break if STOP.equal?(elem)
28
- yield elem
29
- rescue => err
30
- error = err
31
- break
32
- end
33
- end
34
- end
35
- end
36
-
37
- @enum.each { |e| queue << e }
38
- @parallelism.times { queue << STOP }
39
-
40
- threads.each(&:join)
41
-
42
- raise error if error
43
- self
44
- end
45
-
46
- contract C::Func[C::Any => C::Any] => C::RespondTo[:each]
47
- def map
48
- [].tap do |all|
49
- mutex = Mutex.new
50
- each do |e|
51
- res = yield(e)
52
- mutex.synchronize { all << res }
53
- end
54
- end
55
- end
56
- end
57
- end