nanoc 4.1.1 → 4.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +16 -20
- data/LICENSE +1 -1
- data/NEWS.md +11 -0
- data/lib/nanoc.rb +1 -1
- data/lib/nanoc/base/compilation/compiler.rb +6 -5
- data/lib/nanoc/base/compilation/filter.rb +1 -1
- data/lib/nanoc/base/compilation/outdatedness_checker.rb +10 -2
- data/lib/nanoc/base/core_ext/array.rb +1 -1
- data/lib/nanoc/base/core_ext/hash.rb +1 -1
- data/lib/nanoc/base/entities/configuration.rb +5 -4
- data/lib/nanoc/base/entities/document.rb +1 -1
- data/lib/nanoc/base/entities/identifiable_collection.rb +2 -1
- data/lib/nanoc/base/entities/identifier.rb +1 -1
- data/lib/nanoc/base/entities/item_rep.rb +5 -5
- data/lib/nanoc/base/entities/rule_memory_action.rb +1 -1
- data/lib/nanoc/base/entities/rule_memory_actions/snapshot.rb +1 -1
- data/lib/nanoc/base/entities/site.rb +4 -3
- data/lib/nanoc/base/repos/site_loader.rb +5 -5
- data/lib/nanoc/base/services/executor.rb +6 -5
- data/lib/nanoc/base/services/item_rep_writer.rb +1 -1
- data/lib/nanoc/base/views/config_view.rb +1 -1
- data/lib/nanoc/base/views/item_rep_view.rb +1 -1
- data/lib/nanoc/base/views/item_without_reps_view.rb +1 -1
- data/lib/nanoc/base/views/mixins/document_view_mixin.rb +7 -9
- data/lib/nanoc/base/views/view.rb +14 -0
- data/lib/nanoc/cli.rb +2 -2
- data/lib/nanoc/cli/ansi_string_colorizer.rb +1 -1
- data/lib/nanoc/cli/cleaning_stream.rb +1 -1
- data/lib/nanoc/cli/command_runner.rb +7 -14
- data/lib/nanoc/cli/commands/check.rb +1 -1
- data/lib/nanoc/cli/commands/create-site.rb +5 -5
- data/lib/nanoc/cli/commands/shell.rb +1 -1
- data/lib/nanoc/cli/commands/show-plugins.rb +2 -2
- data/lib/nanoc/cli/commands/show-rules.rb +1 -1
- data/lib/nanoc/cli/commands/view.rb +1 -1
- data/lib/nanoc/cli/error_handler.rb +3 -11
- data/lib/nanoc/cli/logger.rb +2 -2
- data/lib/nanoc/data_sources/filesystem_unified.rb +6 -5
- data/lib/nanoc/extra/checking/checks/external_links.rb +7 -6
- data/lib/nanoc/extra/checking/checks/internal_links.rb +7 -6
- data/lib/nanoc/extra/checking/checks/mixed_content.rb +1 -1
- data/lib/nanoc/extra/checking/runner.rb +8 -7
- data/lib/nanoc/extra/deployer.rb +1 -1
- data/lib/nanoc/extra/deployers/fog.rb +2 -2
- data/lib/nanoc/extra/deployers/rsync.rb +1 -1
- data/lib/nanoc/extra/jruby_nokogiri_warner.rb +1 -1
- data/lib/nanoc/extra/link_collector.rb +1 -1
- data/lib/nanoc/filters/colorize_syntax.rb +3 -3
- data/lib/nanoc/filters/less.rb +1 -1
- data/lib/nanoc/filters/redcarpet.rb +6 -5
- data/lib/nanoc/filters/relativize_paths.rb +2 -2
- data/lib/nanoc/filters/sass/sass_filesystem_importer.rb +1 -1
- data/lib/nanoc/helpers/capturing.rb +1 -1
- data/lib/nanoc/helpers/html_escape.rb +3 -2
- data/lib/nanoc/helpers/link_to.rb +7 -6
- data/lib/nanoc/rule_dsl/compiler_dsl.rb +1 -1
- data/lib/nanoc/version.rb +1 -1
- data/nanoc.gemspec +3 -3
- data/tasks/test.rake +1 -1
- data/test/cli/test_cli.rb +2 -2
- data/test/extra/checking/checks/test_mixed_content.rb +7 -7
- data/test/filters/test_colorize_syntax.rb +2 -2
- data/test/filters/test_redcarpet.rb +6 -5
- data/test/filters/test_redcloth.rb +1 -1
- data/test/filters/test_xsl.rb +6 -6
- metadata +2 -2
@@ -1,7 +1,7 @@
|
|
1
1
|
module Nanoc
|
2
2
|
module DocumentViewMixin
|
3
3
|
# @api private
|
4
|
-
NONE = Object.new
|
4
|
+
NONE = Object.new.freeze
|
5
5
|
|
6
6
|
# @api private
|
7
7
|
def initialize(document, context)
|
@@ -18,7 +18,7 @@ module Nanoc
|
|
18
18
|
def ==(other)
|
19
19
|
other.respond_to?(:identifier) && identifier == other.identifier
|
20
20
|
end
|
21
|
-
|
21
|
+
alias eql? ==
|
22
22
|
|
23
23
|
# @see Object#hash
|
24
24
|
def hash
|
@@ -53,14 +53,12 @@ module Nanoc
|
|
53
53
|
|
54
54
|
if unwrap.attributes.key?(key)
|
55
55
|
unwrap.attributes[key]
|
56
|
+
elsif !fallback.equal?(NONE)
|
57
|
+
fallback
|
58
|
+
elsif block_given?
|
59
|
+
yield(key)
|
56
60
|
else
|
57
|
-
|
58
|
-
fallback
|
59
|
-
elsif block_given?
|
60
|
-
yield(key)
|
61
|
-
else
|
62
|
-
raise KeyError, "key not found: #{key.inspect}"
|
63
|
-
end
|
61
|
+
raise KeyError, "key not found: #{key.inspect}"
|
64
62
|
end
|
65
63
|
end
|
66
64
|
|
@@ -8,5 +8,19 @@ module Nanoc
|
|
8
8
|
def _context
|
9
9
|
@context
|
10
10
|
end
|
11
|
+
|
12
|
+
# @api private
|
13
|
+
def unwrap
|
14
|
+
raise NotImplementedError
|
15
|
+
end
|
16
|
+
|
17
|
+
# True if the wrapped object is frozen; false otherwise.
|
18
|
+
#
|
19
|
+
# @return [Boolean]
|
20
|
+
#
|
21
|
+
# @see Object#frozen?
|
22
|
+
def frozen?
|
23
|
+
unwrap.frozen?
|
24
|
+
end
|
11
25
|
end
|
12
26
|
end
|
data/lib/nanoc/cli.rb
CHANGED
@@ -180,11 +180,11 @@ module Nanoc::CLI
|
|
180
180
|
def self.wrap_in_cleaning_stream(io)
|
181
181
|
cio = ::Nanoc::CLI::CleaningStream.new(io)
|
182
182
|
|
183
|
-
unless
|
183
|
+
unless enable_utf8?(io)
|
184
184
|
cio.add_stream_cleaner(Nanoc::CLI::StreamCleaners::UTF8)
|
185
185
|
end
|
186
186
|
|
187
|
-
unless
|
187
|
+
unless enable_ansi_colors?(io)
|
188
188
|
cio.add_stream_cleaner(Nanoc::CLI::StreamCleaners::ANSIColors)
|
189
189
|
end
|
190
190
|
|
@@ -20,7 +20,7 @@ module Nanoc::CLI
|
|
20
20
|
def site
|
21
21
|
# Load site if possible
|
22
22
|
@site ||= nil
|
23
|
-
if
|
23
|
+
if is_in_site_dir? && @site.nil?
|
24
24
|
@site = Nanoc::Int::SiteLoader.new.new_from_cwd
|
25
25
|
end
|
26
26
|
|
@@ -39,26 +39,19 @@ module Nanoc::CLI
|
|
39
39
|
def in_site_dir?
|
40
40
|
Nanoc::Int::SiteLoader.cwd_is_nanoc_site?
|
41
41
|
end
|
42
|
-
|
42
|
+
alias is_in_site_dir? in_site_dir?
|
43
43
|
|
44
|
-
# Asserts that the current working directory contains a site
|
45
|
-
# ({Nanoc::Int::Site} instance). If no site is present, prints an error
|
46
|
-
# message and exits.
|
44
|
+
# Asserts that the current working directory contains a site and loads the site into memory.
|
47
45
|
#
|
48
46
|
# @return [void]
|
49
|
-
def
|
47
|
+
def load_site
|
48
|
+
print 'Loading site… '
|
49
|
+
$stdout.flush
|
50
|
+
|
50
51
|
if site.nil?
|
51
52
|
raise ::Nanoc::Int::Errors::GenericTrivial, 'The current working directory does not seem to be a Nanoc site.'
|
52
53
|
end
|
53
|
-
end
|
54
54
|
|
55
|
-
# Asserts that the current working directory contains a site (just like
|
56
|
-
# {#require_site}) and loads the site into memory.
|
57
|
-
#
|
58
|
-
# @return [void]
|
59
|
-
def load_site
|
60
|
-
print 'Loading site… '
|
61
|
-
require_site
|
62
55
|
puts 'done'
|
63
56
|
end
|
64
57
|
|
@@ -15,7 +15,7 @@ module Nanoc::CLI::Commands
|
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
|
-
DEFAULT_CONFIG = <<EOS unless defined? DEFAULT_CONFIG
|
18
|
+
DEFAULT_CONFIG = <<EOS.freeze unless defined? DEFAULT_CONFIG
|
19
19
|
# The syntax to use for patterns in the Rules file. Can be either `"glob"`
|
20
20
|
# (default) or `"legacy"`. The former will enable glob patterns, which behave
|
21
21
|
# like Ruby’s File.fnmatch. The latter will enable Nanoc 3.x-style patterns.
|
@@ -108,7 +108,7 @@ checks:
|
|
108
108
|
exclude_files: []
|
109
109
|
EOS
|
110
110
|
|
111
|
-
DEFAULT_RULES = <<EOS unless defined? DEFAULT_RULES
|
111
|
+
DEFAULT_RULES = <<EOS.freeze unless defined? DEFAULT_RULES
|
112
112
|
#!/usr/bin/env ruby
|
113
113
|
|
114
114
|
compile '/**/*.html' do
|
@@ -139,7 +139,7 @@ end
|
|
139
139
|
layout '/**/*', :erb
|
140
140
|
EOS
|
141
141
|
|
142
|
-
DEFAULT_ITEM = <<EOS unless defined? DEFAULT_ITEM
|
142
|
+
DEFAULT_ITEM = <<EOS.freeze unless defined? DEFAULT_ITEM
|
143
143
|
---
|
144
144
|
title: Home
|
145
145
|
---
|
@@ -156,7 +156,7 @@ title: Home
|
|
156
156
|
<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>
|
157
157
|
EOS
|
158
158
|
|
159
|
-
DEFAULT_STYLESHEET = <<EOS unless defined? DEFAULT_STYLESHEET
|
159
|
+
DEFAULT_STYLESHEET = <<EOS.freeze unless defined? DEFAULT_STYLESHEET
|
160
160
|
* {
|
161
161
|
margin: 0;
|
162
162
|
padding: 0;
|
@@ -260,7 +260,7 @@ a:hover {
|
|
260
260
|
}
|
261
261
|
EOS
|
262
262
|
|
263
|
-
DEFAULT_LAYOUT = <<EOS unless defined? DEFAULT_LAYOUT
|
263
|
+
DEFAULT_LAYOUT = <<EOS.freeze unless defined? DEFAULT_LAYOUT
|
264
264
|
<!DOCTYPE HTML>
|
265
265
|
<html lang="en">
|
266
266
|
<head>
|
@@ -73,13 +73,13 @@ module Nanoc::CLI::Commands
|
|
73
73
|
Nanoc::Filter,
|
74
74
|
Nanoc::DataSource,
|
75
75
|
Nanoc::Extra::Deployer,
|
76
|
-
] unless defined? PLUGIN_CLASS_ORDER
|
76
|
+
].freeze unless defined? PLUGIN_CLASS_ORDER
|
77
77
|
|
78
78
|
PLUGIN_CLASSES = {
|
79
79
|
Nanoc::Filter => 'Filters',
|
80
80
|
Nanoc::DataSource => 'Data Sources',
|
81
81
|
Nanoc::Extra::Deployer => 'Deployers',
|
82
|
-
} unless defined? PLUGIN_CLASSES
|
82
|
+
}.freeze unless defined? PLUGIN_CLASSES
|
83
83
|
|
84
84
|
def name_for_plugin_class(klass)
|
85
85
|
PLUGIN_CLASSES[klass]
|
@@ -138,7 +138,6 @@ module Nanoc::CLI
|
|
138
138
|
write_version_information(stream, verbose: true)
|
139
139
|
write_system_information(stream, verbose: true)
|
140
140
|
write_installed_gems(stream, verbose: true)
|
141
|
-
write_environment(stream, verbose: true)
|
142
141
|
write_gemfile_lock(stream, verbose: true)
|
143
142
|
write_load_paths(stream, verbose: true)
|
144
143
|
end
|
@@ -208,7 +207,7 @@ module Nanoc::CLI
|
|
208
207
|
'rubypants' => 'rubypants',
|
209
208
|
'sass' => 'sass',
|
210
209
|
'w3c_validators' => 'w3c_validators',
|
211
|
-
}
|
210
|
+
}.freeze
|
212
211
|
|
213
212
|
# Attempts to find a resolution for the given error, or nil if no
|
214
213
|
# resolution can be automatically obtained.
|
@@ -226,7 +225,7 @@ module Nanoc::CLI
|
|
226
225
|
|
227
226
|
# Build message
|
228
227
|
if gem_name
|
229
|
-
if
|
228
|
+
if using_bundler?
|
230
229
|
'Make sure the gem is added to Gemfile and run `bundle install`.'
|
231
230
|
else
|
232
231
|
"Install the '#{gem_name}' gem using `gem install #{gem_name}`."
|
@@ -262,7 +261,7 @@ module Nanoc::CLI
|
|
262
261
|
|
263
262
|
stream.puts "#{error.class}: #{error.message}"
|
264
263
|
resolution = resolution_for(error)
|
265
|
-
stream.puts
|
264
|
+
stream.puts resolution.to_s if resolution
|
266
265
|
end
|
267
266
|
|
268
267
|
def write_compilation_stack(stream, _error, verbose: false)
|
@@ -320,13 +319,6 @@ module Nanoc::CLI
|
|
320
319
|
end
|
321
320
|
end
|
322
321
|
|
323
|
-
def write_environment(stream, verbose: false)
|
324
|
-
write_section_header(stream, 'Environment', verbose: verbose)
|
325
|
-
ENV.sort.each do |e|
|
326
|
-
stream.puts "#{e.first} => #{e.last.inspect}"
|
327
|
-
end
|
328
|
-
end
|
329
|
-
|
330
322
|
def write_gemfile_lock(stream, verbose: false)
|
331
323
|
if File.exist?('Gemfile.lock')
|
332
324
|
write_section_header(stream, 'Gemfile.lock', verbose: verbose)
|
data/lib/nanoc/cli/logger.rb
CHANGED
@@ -14,7 +14,7 @@ module Nanoc::CLI
|
|
14
14
|
identical: '', # (nothing)
|
15
15
|
skip: '', # (nothing)
|
16
16
|
delete: "\e[31m" # red
|
17
|
-
}
|
17
|
+
}.freeze
|
18
18
|
|
19
19
|
include Singleton
|
20
20
|
|
@@ -48,7 +48,7 @@ module Nanoc::CLI
|
|
48
48
|
"\e[0m",
|
49
49
|
duration.nil? ? '' : format('[%2.2fs] ', duration),
|
50
50
|
name,
|
51
|
-
)
|
51
|
+
),
|
52
52
|
)
|
53
53
|
end
|
54
54
|
|
@@ -89,11 +89,12 @@ module Nanoc::DataSources
|
|
89
89
|
return Nanoc::Identifier.new(filename)
|
90
90
|
end
|
91
91
|
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
92
|
+
regex =
|
93
|
+
if filename =~ /(^|\/)index(\.[^\/]+)?$/
|
94
|
+
@config && @config[:allow_periods_in_identifiers] ? /\/?(index)?(\.[^\/\.]+)?$/ : /\/?index(\.[^\/]+)?$/
|
95
|
+
else
|
96
|
+
@config && @config[:allow_periods_in_identifiers] ? /\.[^\/\.]+$/ : /\.[^\/]+$/
|
97
|
+
end
|
97
98
|
Nanoc::Identifier.new(filename.sub(regex, ''), type: :legacy)
|
98
99
|
end
|
99
100
|
end
|
@@ -90,7 +90,7 @@ module ::Nanoc::Extra::Checking::Checks
|
|
90
90
|
end
|
91
91
|
|
92
92
|
# Skip excluded URLs
|
93
|
-
return nil if
|
93
|
+
return nil if excluded?(href)
|
94
94
|
|
95
95
|
# Skip non-HTTP URLs
|
96
96
|
return nil if url.scheme !~ /^https?$/
|
@@ -142,11 +142,12 @@ module ::Nanoc::Extra::Checking::Checks
|
|
142
142
|
end
|
143
143
|
|
144
144
|
def path_for_url(url)
|
145
|
-
|
146
|
-
path
|
147
|
-
|
148
|
-
|
149
|
-
|
145
|
+
path =
|
146
|
+
if url.path.nil? || url.path.empty?
|
147
|
+
'/'
|
148
|
+
else
|
149
|
+
url.path
|
150
|
+
end
|
150
151
|
|
151
152
|
if url.query
|
152
153
|
path << '?' << url.query
|
@@ -34,7 +34,7 @@ module Nanoc::Extra::Checking::Checks
|
|
34
34
|
return true if href == '.'
|
35
35
|
|
36
36
|
# Skip hrefs that are specified in the exclude configuration
|
37
|
-
return true if
|
37
|
+
return true if excluded?(href)
|
38
38
|
|
39
39
|
# Remove target
|
40
40
|
path = href.sub(/#.*$/, '')
|
@@ -48,11 +48,12 @@ module Nanoc::Extra::Checking::Checks
|
|
48
48
|
path = URI.unescape(path)
|
49
49
|
|
50
50
|
# Make absolute
|
51
|
-
|
52
|
-
path
|
53
|
-
|
54
|
-
|
55
|
-
|
51
|
+
path =
|
52
|
+
if path[0, 1] == '/'
|
53
|
+
@config[:output_dir] + path
|
54
|
+
else
|
55
|
+
::File.expand_path(path, ::File.dirname(origin))
|
56
|
+
end
|
56
57
|
|
57
58
|
# Check whether file exists
|
58
59
|
return true if File.file?(path)
|
@@ -3,7 +3,7 @@ module Nanoc::Extra::Checking
|
|
3
3
|
#
|
4
4
|
# @api private
|
5
5
|
class Runner
|
6
|
-
CHECKS_FILENAMES = ['Checks', 'Checks.rb', 'checks', 'checks.rb']
|
6
|
+
CHECKS_FILENAMES = ['Checks', 'Checks.rb', 'checks', 'checks.rb'].freeze
|
7
7
|
|
8
8
|
# @param [Nanoc::Int::Site] site The Nanoc site this runner is for
|
9
9
|
def initialize(site)
|
@@ -19,7 +19,7 @@ module Nanoc::Extra::Checking
|
|
19
19
|
def dsl_present?
|
20
20
|
checks_filename && File.file?(checks_filename)
|
21
21
|
end
|
22
|
-
|
22
|
+
alias has_dsl? dsl_present?
|
23
23
|
|
24
24
|
# Lists all available checks on stdout.
|
25
25
|
#
|
@@ -65,11 +65,12 @@ module Nanoc::Extra::Checking
|
|
65
65
|
def load_dsl_if_available
|
66
66
|
@dsl_loaded ||= false
|
67
67
|
unless @dsl_loaded
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
68
|
+
@dsl =
|
69
|
+
if dsl_present?
|
70
|
+
Nanoc::Extra::Checking::DSL.from_file(checks_filename)
|
71
|
+
else
|
72
|
+
nil
|
73
|
+
end
|
73
74
|
@dsl_loaded = true
|
74
75
|
end
|
75
76
|
end
|