nanoc 4.1.1 → 4.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (67) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +16 -20
  3. data/LICENSE +1 -1
  4. data/NEWS.md +11 -0
  5. data/lib/nanoc.rb +1 -1
  6. data/lib/nanoc/base/compilation/compiler.rb +6 -5
  7. data/lib/nanoc/base/compilation/filter.rb +1 -1
  8. data/lib/nanoc/base/compilation/outdatedness_checker.rb +10 -2
  9. data/lib/nanoc/base/core_ext/array.rb +1 -1
  10. data/lib/nanoc/base/core_ext/hash.rb +1 -1
  11. data/lib/nanoc/base/entities/configuration.rb +5 -4
  12. data/lib/nanoc/base/entities/document.rb +1 -1
  13. data/lib/nanoc/base/entities/identifiable_collection.rb +2 -1
  14. data/lib/nanoc/base/entities/identifier.rb +1 -1
  15. data/lib/nanoc/base/entities/item_rep.rb +5 -5
  16. data/lib/nanoc/base/entities/rule_memory_action.rb +1 -1
  17. data/lib/nanoc/base/entities/rule_memory_actions/snapshot.rb +1 -1
  18. data/lib/nanoc/base/entities/site.rb +4 -3
  19. data/lib/nanoc/base/repos/site_loader.rb +5 -5
  20. data/lib/nanoc/base/services/executor.rb +6 -5
  21. data/lib/nanoc/base/services/item_rep_writer.rb +1 -1
  22. data/lib/nanoc/base/views/config_view.rb +1 -1
  23. data/lib/nanoc/base/views/item_rep_view.rb +1 -1
  24. data/lib/nanoc/base/views/item_without_reps_view.rb +1 -1
  25. data/lib/nanoc/base/views/mixins/document_view_mixin.rb +7 -9
  26. data/lib/nanoc/base/views/view.rb +14 -0
  27. data/lib/nanoc/cli.rb +2 -2
  28. data/lib/nanoc/cli/ansi_string_colorizer.rb +1 -1
  29. data/lib/nanoc/cli/cleaning_stream.rb +1 -1
  30. data/lib/nanoc/cli/command_runner.rb +7 -14
  31. data/lib/nanoc/cli/commands/check.rb +1 -1
  32. data/lib/nanoc/cli/commands/create-site.rb +5 -5
  33. data/lib/nanoc/cli/commands/shell.rb +1 -1
  34. data/lib/nanoc/cli/commands/show-plugins.rb +2 -2
  35. data/lib/nanoc/cli/commands/show-rules.rb +1 -1
  36. data/lib/nanoc/cli/commands/view.rb +1 -1
  37. data/lib/nanoc/cli/error_handler.rb +3 -11
  38. data/lib/nanoc/cli/logger.rb +2 -2
  39. data/lib/nanoc/data_sources/filesystem_unified.rb +6 -5
  40. data/lib/nanoc/extra/checking/checks/external_links.rb +7 -6
  41. data/lib/nanoc/extra/checking/checks/internal_links.rb +7 -6
  42. data/lib/nanoc/extra/checking/checks/mixed_content.rb +1 -1
  43. data/lib/nanoc/extra/checking/runner.rb +8 -7
  44. data/lib/nanoc/extra/deployer.rb +1 -1
  45. data/lib/nanoc/extra/deployers/fog.rb +2 -2
  46. data/lib/nanoc/extra/deployers/rsync.rb +1 -1
  47. data/lib/nanoc/extra/jruby_nokogiri_warner.rb +1 -1
  48. data/lib/nanoc/extra/link_collector.rb +1 -1
  49. data/lib/nanoc/filters/colorize_syntax.rb +3 -3
  50. data/lib/nanoc/filters/less.rb +1 -1
  51. data/lib/nanoc/filters/redcarpet.rb +6 -5
  52. data/lib/nanoc/filters/relativize_paths.rb +2 -2
  53. data/lib/nanoc/filters/sass/sass_filesystem_importer.rb +1 -1
  54. data/lib/nanoc/helpers/capturing.rb +1 -1
  55. data/lib/nanoc/helpers/html_escape.rb +3 -2
  56. data/lib/nanoc/helpers/link_to.rb +7 -6
  57. data/lib/nanoc/rule_dsl/compiler_dsl.rb +1 -1
  58. data/lib/nanoc/version.rb +1 -1
  59. data/nanoc.gemspec +3 -3
  60. data/tasks/test.rake +1 -1
  61. data/test/cli/test_cli.rb +2 -2
  62. data/test/extra/checking/checks/test_mixed_content.rb +7 -7
  63. data/test/filters/test_colorize_syntax.rb +2 -2
  64. data/test/filters/test_redcarpet.rb +6 -5
  65. data/test/filters/test_redcloth.rb +1 -1
  66. data/test/filters/test_xsl.rb +6 -6
  67. metadata +2 -2
@@ -18,7 +18,7 @@ module Nanoc::Extra
18
18
  # @return [Boolean] true if the deployer should only show what would be
19
19
  # deployed instead of doing the actual deployment
20
20
  attr_reader :dry_run
21
- alias_method :dry_run?, :dry_run
21
+ alias dry_run? dry_run
22
22
 
23
23
  # @param [String] source_path The path to the directory that contains the
24
24
  # files to upload. It should not have a trailing slash.
@@ -37,7 +37,7 @@ module Nanoc::Extra::Deployers
37
37
  error 'The path requires no trailing slash' if path && path[-1, 1] == '/'
38
38
 
39
39
  # Mock if necessary
40
- if self.dry_run?
40
+ if dry_run?
41
41
  puts 'Dry run - simulation'
42
42
  ::Fog.mock!
43
43
  end
@@ -95,7 +95,7 @@ module Nanoc::Extra::Deployers
95
95
  keys_to_invalidate.concat(keys_to_destroy)
96
96
  cdn = ::Fog::CDN.new(config)
97
97
  # fog cannot mock CDN requests
98
- unless self.dry_run?
98
+ unless dry_run?
99
99
  distribution = cdn.get_distribution(cdn_id)
100
100
  # usual limit per invalidation: 1000 objects
101
101
  keys_to_invalidate.each_slice(1000) do |paths|
@@ -33,7 +33,7 @@ module Nanoc::Extra::Deployers
33
33
  '--exclude=".hg"',
34
34
  '--exclude=".svn"',
35
35
  '--exclude=".git"',
36
- ]
36
+ ].freeze
37
37
 
38
38
  # @see Nanoc::Extra::Deployer#run
39
39
  def run
@@ -5,7 +5,7 @@ module Nanoc::Extra
5
5
  class JRubyNokogiriWarner
6
6
  include Singleton
7
7
 
8
- TEXT = <<EOS
8
+ TEXT = <<EOS.freeze
9
9
  --------------------------------------------------------------------------------
10
10
  Note:
11
11
 
@@ -12,7 +12,7 @@ module ::Nanoc::Extra
12
12
  'link' => :href,
13
13
  'script' => :src,
14
14
  'video' => :src,
15
- }
15
+ }.freeze
16
16
 
17
17
  def initialize(filenames, mode = nil)
18
18
  Nanoc::Extra::JRubyNokogiriWarner.check_and_warn
@@ -246,7 +246,7 @@ module Nanoc::Filters
246
246
  wrap: '-W',
247
247
  include_style: '-I',
248
248
  line_numbers: '-l',
249
- }
249
+ }.freeze
250
250
 
251
251
  # Runs the content through [Highlight](http://www.andre-simon.de/doku/highlight/en/highlight.html).
252
252
  #
@@ -347,7 +347,7 @@ module Nanoc::Filters
347
347
 
348
348
  protected
349
349
 
350
- KNOWN_COLORIZERS = [:coderay, :dummy, :pygmentize, :pygmentsrb, :simon_highlight, :rouge]
350
+ KNOWN_COLORIZERS = [:coderay, :dummy, :pygmentize, :pygmentsrb, :simon_highlight, :rouge].freeze
351
351
 
352
352
  # Removes the first blank lines and any whitespace at the end.
353
353
  def strip(s)
@@ -367,7 +367,7 @@ module Nanoc::Filters
367
367
  colorizer = @colorizers[language.to_sym]
368
368
  if KNOWN_COLORIZERS.include?(colorizer)
369
369
  sym = (colorizer.to_s + '_postprocess').to_sym
370
- if self.respond_to?(sym)
370
+ if respond_to?(sym)
371
371
  send(sym, language, element)
372
372
  end
373
373
  else
@@ -15,7 +15,7 @@ module Nanoc::Filters
15
15
  imports.concat(content.scan(/^@import\s+(["'])([^\1]+?)\1;/))
16
16
  imports.concat(content.scan(/^@import\s+url\((["']?)([^)]+?)\1\);/))
17
17
  imported_filenames = imports.map do |i|
18
- i[1].match(/\.(less|css)$/) ? i[1] : i[1] + '.less'
18
+ i[1] =~ /\.(less|css)$/ ? i[1] : i[1] + '.less'
19
19
  end
20
20
 
21
21
  # Convert to items
@@ -62,11 +62,12 @@ module Nanoc::Filters
62
62
  end
63
63
 
64
64
  # Create renderer
65
- if renderer_class == ::Redcarpet::Render::HTML_TOC
66
- renderer = renderer_class.new
67
- else
68
- renderer = renderer_class.new(renderer_options)
69
- end
65
+ renderer =
66
+ if renderer_class == ::Redcarpet::Render::HTML_TOC
67
+ renderer_class.new
68
+ else
69
+ renderer_class.new(renderer_options)
70
+ end
70
71
 
71
72
  # Render
72
73
  if with_toc
@@ -4,7 +4,7 @@ module Nanoc::Filters
4
4
  require 'nanoc/helpers/link_to'
5
5
  include Nanoc::Helpers::LinkTo
6
6
 
7
- SELECTORS = ['*/@href', '*/@src', 'object/@data', 'param[@name="movie"]/@content', 'comment()']
7
+ SELECTORS = ['*/@href', '*/@src', 'object/@data', 'param[@name="movie"]/@content', 'comment()'].freeze
8
8
 
9
9
  # Relativizes all paths in the given content, which can be HTML, XHTML, XML
10
10
  # or CSS. This filter is quite useful if a site needs to be hosted in a
@@ -89,7 +89,7 @@ module Nanoc::Filters
89
89
  doc.xpath(selector, namespaces).each do |node|
90
90
  if node.name == 'comment'
91
91
  nokogiri_process_comment(node, doc, selectors, namespaces, klass, type)
92
- elsif self.path_is_relativizable?(node.content)
92
+ elsif path_is_relativizable?(node.content)
93
93
  node.content = relative_path_to(node.content)
94
94
  end
95
95
  end
@@ -1,6 +1,6 @@
1
1
  # @api private
2
2
  class ::Sass::Importers::Filesystem
3
- alias_method :_orig_find, :_find
3
+ alias _orig_find _find
4
4
 
5
5
  def _find(dir, name, options)
6
6
  # Find filename
@@ -177,7 +177,7 @@ module Nanoc::Helpers
177
177
  erbout_length = erbout.length
178
178
 
179
179
  # Execute block
180
- block.call
180
+ yield
181
181
 
182
182
  # Get new piece of erbout
183
183
  erbout_addition = erbout[erbout_length..-1]
@@ -34,7 +34,8 @@ module Nanoc::Helpers
34
34
  buffer = eval('_erbout', block.binding)
35
35
  buffer << escaped_data
36
36
  elsif string
37
- string.gsub('&', '&amp;')
37
+ string
38
+ .gsub('&', '&amp;')
38
39
  .gsub('<', '&lt;')
39
40
  .gsub('>', '&gt;')
40
41
  .gsub('"', '&quot;')
@@ -44,6 +45,6 @@ module Nanoc::Helpers
44
45
  end
45
46
  end
46
47
 
47
- alias_method :h, :html_escape
48
+ alias h html_escape
48
49
  end
49
50
  end
@@ -123,7 +123,7 @@ module Nanoc::Helpers
123
123
  end
124
124
 
125
125
  # Handle Windows network (UNC) paths
126
- if path.start_with?('//') || path.start_with?('\\\\')
126
+ if path.start_with?('//', '\\\\')
127
127
  return path
128
128
  end
129
129
 
@@ -136,11 +136,12 @@ module Nanoc::Helpers
136
136
 
137
137
  # Calculate the relative path (method depends on whether destination is
138
138
  # a directory or not).
139
- if src_path.to_s[-1, 1] != '/'
140
- relative_path = dst_path.relative_path_from(src_path.dirname).to_s
141
- else
142
- relative_path = dst_path.relative_path_from(src_path).to_s
143
- end
139
+ relative_path =
140
+ if src_path.to_s[-1, 1] != '/'
141
+ dst_path.relative_path_from(src_path.dirname).to_s
142
+ else
143
+ dst_path.relative_path_from(src_path).to_s
144
+ end
144
145
 
145
146
  # Add trailing slash if necessary
146
147
  if dst_path.to_s[-1, 1] == '/'
@@ -232,7 +232,7 @@ module Nanoc::RuleDSL
232
232
  # include_rules 'rules/assets'
233
233
  # include_rules 'rules/content'
234
234
  def include_rules(name)
235
- filename = ["#{name}", "#{name}.rb", "./#{name}", "./#{name}.rb"].find { |f| File.file?(f) }
235
+ filename = [name.to_s, "#{name}.rb", "./#{name}", "./#{name}.rb"].find { |f| File.file?(f) }
236
236
  raise Nanoc::Int::Errors::NoRulesFileFound.new if filename.nil?
237
237
 
238
238
  Nanoc::RuleDSL::RulesLoader.new(@config, @rules_collection).parse(filename)
@@ -1,4 +1,4 @@
1
1
  module Nanoc
2
2
  # The current Nanoc version.
3
- VERSION = '4.1.1'
3
+ VERSION = '4.1.2'.freeze
4
4
  end
@@ -13,9 +13,9 @@ Gem::Specification.new do |s|
13
13
 
14
14
  s.files =
15
15
  Dir['[A-Z]*'] +
16
- Dir['doc/yardoc_{templates,handlers}/**/*'] +
17
- Dir['{bin,lib,tasks,test}/**/*'] +
18
- ['nanoc.gemspec']
16
+ Dir['doc/yardoc_{templates,handlers}/**/*'] +
17
+ Dir['{bin,lib,tasks,test}/**/*'] +
18
+ ['nanoc.gemspec']
19
19
  s.executables = ['nanoc']
20
20
  s.require_paths = ['lib']
21
21
 
@@ -4,7 +4,7 @@ require 'coveralls/rake/task'
4
4
 
5
5
  Coveralls::RakeTask.new
6
6
 
7
- SUBDIRS = %w( * base cli data_sources extra filters helpers )
7
+ SUBDIRS = %w( * base cli data_sources extra filters helpers ).freeze
8
8
 
9
9
  namespace :test do
10
10
  SUBDIRS.each do |dir|
@@ -1,5 +1,5 @@
1
1
  class Nanoc::CLITest < Nanoc::TestCase
2
- COMMAND_CODE = <<EOS
2
+ COMMAND_CODE = <<EOS.freeze
3
3
  usage '_test [options]'
4
4
  summary 'meh'
5
5
  description 'longer meh'
@@ -9,7 +9,7 @@ run do |opts, args, cmd|
9
9
  end
10
10
  EOS
11
11
 
12
- SUBCOMMAND_CODE = <<EOS
12
+ SUBCOMMAND_CODE = <<EOS.freeze
13
13
  usage '_sub [options]'
14
14
  summary 'meh sub'
15
15
  description 'longer meh sub'
@@ -25,7 +25,7 @@ class Nanoc::Extra::Checking::Checks::MixedContentTest < Nanoc::TestCase
25
25
  check = Nanoc::Extra::Checking::Checks::MixedContent.create(site)
26
26
  check.run
27
27
 
28
- assert check.issues.empty?
28
+ assert_empty check.issues
29
29
  end
30
30
  end
31
31
 
@@ -43,7 +43,7 @@ class Nanoc::Extra::Checking::Checks::MixedContentTest < Nanoc::TestCase
43
43
  check = Nanoc::Extra::Checking::Checks::MixedContent.create(site)
44
44
  check.run
45
45
 
46
- assert check.issues.empty?
46
+ assert_empty check.issues
47
47
  end
48
48
  end
49
49
 
@@ -61,7 +61,7 @@ class Nanoc::Extra::Checking::Checks::MixedContentTest < Nanoc::TestCase
61
61
  check = Nanoc::Extra::Checking::Checks::MixedContent.create(site)
62
62
  check.run
63
63
 
64
- assert check.issues.empty?
64
+ assert_empty check.issues
65
65
  end
66
66
  end
67
67
 
@@ -79,7 +79,7 @@ class Nanoc::Extra::Checking::Checks::MixedContentTest < Nanoc::TestCase
79
79
  check = Nanoc::Extra::Checking::Checks::MixedContent.create(site)
80
80
  check.run
81
81
 
82
- assert check.issues.empty?
82
+ assert_empty check.issues
83
83
  end
84
84
  end
85
85
 
@@ -97,7 +97,7 @@ class Nanoc::Extra::Checking::Checks::MixedContentTest < Nanoc::TestCase
97
97
  check = Nanoc::Extra::Checking::Checks::MixedContent.create(site)
98
98
  check.run
99
99
 
100
- assert check.issues.empty?
100
+ assert_empty check.issues
101
101
  end
102
102
  end
103
103
 
@@ -115,7 +115,7 @@ class Nanoc::Extra::Checking::Checks::MixedContentTest < Nanoc::TestCase
115
115
  check = Nanoc::Extra::Checking::Checks::MixedContent.create(site)
116
116
  check.run
117
117
 
118
- assert check.issues.empty?
118
+ assert_empty check.issues
119
119
  end
120
120
  end
121
121
 
@@ -180,7 +180,7 @@ class Nanoc::Extra::Checking::Checks::MixedContentTest < Nanoc::TestCase
180
180
  check = Nanoc::Extra::Checking::Checks::MixedContent.create(site)
181
181
  check.run
182
182
 
183
- assert check.issues.empty?
183
+ assert_empty check.issues
184
184
  end
185
185
  end
186
186
  end
@@ -1,6 +1,6 @@
1
1
  class Nanoc::Filters::ColorizeSyntaxTest < Nanoc::TestCase
2
- CODERAY_PRE = '<div class="CodeRay"><div class="code">'
3
- CODERAY_POST = '</div></div>'
2
+ CODERAY_PRE = '<div class="CodeRay"><div class="code">'.freeze
3
+ CODERAY_POST = '</div></div>'.freeze
4
4
 
5
5
  def test_coderay_simple
6
6
  if_have 'coderay', 'nokogiri' do
@@ -56,11 +56,12 @@ class Nanoc::Filters::RedcarpetTest < Nanoc::TestCase
56
56
  # Run filter
57
57
  input = "![Alt](/path/to/img 'Title')"
58
58
  output_expected = %r{<img src="/path/to/img" alt="Alt" title="Title"/>}
59
- if ::Redcarpet::VERSION > '2'
60
- output_actual = filter.setup_and_run(input, renderer_options: { xhtml: true })
61
- else
62
- output_actual = filter.setup_and_run(input, options: [:xhtml])
63
- end
59
+ output_actual =
60
+ if ::Redcarpet::VERSION > '2'
61
+ filter.setup_and_run(input, renderer_options: { xhtml: true })
62
+ else
63
+ filter.setup_and_run(input, options: [:xhtml])
64
+ end
64
65
  assert_match(output_expected, output_actual)
65
66
  end
66
67
  end
@@ -17,7 +17,7 @@ class Nanoc::Filters::RedClothTest < Nanoc::TestCase
17
17
 
18
18
  # Run filter without options
19
19
  result = filter.setup_and_run('I am a member of SPECTRE.')
20
- assert_equal("<p>I am a member of <span class=\"caps\">SPECTRE</span>.</p>", result)
20
+ assert_equal('<p>I am a member of <span class="caps">SPECTRE</span>.</p>', result)
21
21
 
22
22
  # Run filter with options
23
23
  result = filter.setup_and_run('I am a member of SPECTRE.', no_span_caps: true)
@@ -1,7 +1,7 @@
1
1
  require 'tempfile'
2
2
 
3
3
  class Nanoc::Filters::XSLTest < Nanoc::TestCase
4
- SAMPLE_XSL = <<-EOS
4
+ SAMPLE_XSL = <<-EOS.freeze
5
5
  <?xml version="1.0" encoding="utf-8"?>
6
6
  <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
7
7
  <xsl:output method="xml" version="1.0" encoding="utf-8" indent="yes"/>
@@ -18,7 +18,7 @@ class Nanoc::Filters::XSLTest < Nanoc::TestCase
18
18
  </xsl:stylesheet>
19
19
  EOS
20
20
 
21
- SAMPLE_XML_IN = <<-EOS
21
+ SAMPLE_XML_IN = <<-EOS.freeze
22
22
  <?xml version="1.0" encoding="utf-8"?>
23
23
  <report>
24
24
  <title>My Report</title>
@@ -27,7 +27,7 @@ EOS
27
27
 
28
28
  SAMPLE_XML_OUT = %r{\A<\?xml version="1.0" encoding="utf-8"\?>\s*<html>\s*<head>\s*<title>My Report</title>\s*</head>\s*<body>\s*<h1>My Report</h1>\s*</body>\s*</html>\s*\Z}m
29
29
 
30
- SAMPLE_XSL_WITH_PARAMS = <<-EOS
30
+ SAMPLE_XSL_WITH_PARAMS = <<-EOS.freeze
31
31
  <?xml version="1.0" encoding="utf-8"?>
32
32
  <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
33
33
  <xsl:output method="xml" version="1.0" encoding="utf-8" indent="yes"/>
@@ -45,7 +45,7 @@ EOS
45
45
  </xsl:stylesheet>
46
46
  EOS
47
47
 
48
- SAMPLE_XML_IN_WITH_PARAMS = <<-EOS
48
+ SAMPLE_XML_IN_WITH_PARAMS = <<-EOS.freeze
49
49
  <?xml version="1.0" encoding="utf-8"?>
50
50
  <report>
51
51
  <title>My Report</title>
@@ -54,7 +54,7 @@ EOS
54
54
 
55
55
  SAMPLE_XML_OUT_WITH_PARAMS = %r{\A<\?xml version="1.0" encoding="utf-8"\?>\s*<html>\s*<head>\s*<title>My Report</title>\s*</head>\s*<body>\s*<h1>bar</h1>\s*</body>\s*</html>\s*\Z}m
56
56
 
57
- SAMPLE_XSL_WITH_OMIT_XML_DECL = <<-EOS
57
+ SAMPLE_XSL_WITH_OMIT_XML_DECL = <<-EOS.freeze
58
58
  <?xml version="1.0" encoding="utf-8"?>
59
59
  <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
60
60
  <xsl:output method="xml" version="1.0" encoding="utf-8" indent="yes"
@@ -72,7 +72,7 @@ EOS
72
72
  </xsl:stylesheet>
73
73
  EOS
74
74
 
75
- SAMPLE_XML_IN_WITH_OMIT_XML_DECL = <<-EOS
75
+ SAMPLE_XML_IN_WITH_OMIT_XML_DECL = <<-EOS.freeze
76
76
  <?xml version="1.0" encoding="utf-8"?>
77
77
  <report>
78
78
  <title>My Report</title>
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.1.1
4
+ version: 4.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Denis Defreyne
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-30 00:00:00.000000000 Z
11
+ date: 2016-01-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cri