nanoc 3.6.7 → 3.6.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/CONTRIBUTING.md +9 -13
- data/Gemfile +5 -1
- data/Gemfile.lock +70 -45
- data/NEWS.md +15 -1
- data/README.md +12 -119
- data/doc/yardoc_handlers/identifier.rb +34 -0
- data/lib/nanoc/base/compilation/checksum_store.rb +2 -2
- data/lib/nanoc/base/compilation/compiler.rb +3 -3
- data/lib/nanoc/base/compilation/compiler_dsl.rb +20 -15
- data/lib/nanoc/base/compilation/dependency_tracker.rb +4 -4
- data/lib/nanoc/base/compilation/filter.rb +5 -5
- data/lib/nanoc/base/compilation/item_rep_proxy.rb +2 -2
- data/lib/nanoc/base/compilation/item_rep_recorder_proxy.rb +3 -3
- data/lib/nanoc/base/compilation/outdatedness_checker.rb +49 -46
- data/lib/nanoc/base/compilation/rule.rb +6 -4
- data/lib/nanoc/base/compilation/rule_context.rb +10 -4
- data/lib/nanoc/base/compilation/rule_memory_calculator.rb +8 -7
- data/lib/nanoc/base/compilation/rule_memory_store.rb +2 -2
- data/lib/nanoc/base/compilation/rules_collection.rb +2 -2
- data/lib/nanoc/base/core_ext/array.rb +2 -2
- data/lib/nanoc/base/core_ext/date.rb +4 -2
- data/lib/nanoc/base/core_ext/hash.rb +3 -3
- data/lib/nanoc/base/core_ext/pathname.rb +1 -1
- data/lib/nanoc/base/directed_graph.rb +6 -6
- data/lib/nanoc/base/errors.rb +1 -1
- data/lib/nanoc/base/memoization.rb +4 -4
- data/lib/nanoc/base/notification_center.rb +1 -1
- data/lib/nanoc/base/ordered_hash.rb +207 -179
- data/lib/nanoc/base/plugin_registry.rb +7 -7
- data/lib/nanoc/base/result_data/item_rep.rb +25 -26
- data/lib/nanoc/base/source_data/code_snippet.rb +2 -2
- data/lib/nanoc/base/source_data/configuration.rb +1 -1
- data/lib/nanoc/base/source_data/data_source.rb +2 -2
- data/lib/nanoc/base/source_data/item.rb +16 -15
- data/lib/nanoc/base/source_data/item_array.rb +4 -4
- data/lib/nanoc/base/source_data/layout.rb +5 -5
- data/lib/nanoc/base/source_data/site.rb +6 -6
- data/lib/nanoc/base/store.rb +8 -8
- data/lib/nanoc/cli/cleaning_stream.rb +11 -12
- data/lib/nanoc/cli/command_runner.rb +8 -8
- data/lib/nanoc/cli/commands/autocompile.rb +5 -4
- data/lib/nanoc/cli/commands/check.rb +12 -11
- data/lib/nanoc/cli/commands/compile.rb +50 -52
- data/lib/nanoc/cli/commands/create-item.rb +6 -6
- data/lib/nanoc/cli/commands/create-layout.rb +6 -6
- data/lib/nanoc/cli/commands/create-site.rb +10 -13
- data/lib/nanoc/cli/commands/deploy.rb +11 -11
- data/lib/nanoc/cli/commands/prune.rb +10 -10
- data/lib/nanoc/cli/commands/shell.rb +7 -7
- data/lib/nanoc/cli/commands/show-data.rb +22 -23
- data/lib/nanoc/cli/commands/show-plugins.rb +3 -3
- data/lib/nanoc/cli/commands/show-rules.rb +8 -8
- data/lib/nanoc/cli/commands/sync.rb +4 -2
- data/lib/nanoc/cli/commands/update.rb +4 -4
- data/lib/nanoc/cli/commands/validate-css.rb +3 -3
- data/lib/nanoc/cli/commands/validate-html.rb +3 -3
- data/lib/nanoc/cli/commands/validate-links.rb +3 -3
- data/lib/nanoc/cli/commands/view.rb +5 -3
- data/lib/nanoc/cli/commands/watch.rb +12 -12
- data/lib/nanoc/cli/error_handler.rb +58 -58
- data/lib/nanoc/cli/logger.rb +6 -6
- data/lib/nanoc/cli/stream_cleaners/abstract.rb +1 -1
- data/lib/nanoc/cli/stream_cleaners.rb +0 -1
- data/lib/nanoc/cli.rb +24 -22
- data/lib/nanoc/data_sources/deprecated/delicious.rb +1 -1
- data/lib/nanoc/data_sources/deprecated/last_fm.rb +16 -14
- data/lib/nanoc/data_sources/deprecated/twitter.rb +1 -1
- data/lib/nanoc/data_sources/filesystem.rb +22 -20
- data/lib/nanoc/data_sources/filesystem_unified.rb +4 -5
- data/lib/nanoc/data_sources/filesystem_verbose.rb +2 -3
- data/lib/nanoc/data_sources/static.rb +2 -2
- data/lib/nanoc/extra/auto_compiler.rb +3 -3
- data/lib/nanoc/extra/checking/check.rb +3 -3
- data/lib/nanoc/extra/checking/checks/css.rb +2 -2
- data/lib/nanoc/extra/checking/checks/external_links.rb +9 -9
- data/lib/nanoc/extra/checking/checks/html.rb +2 -3
- data/lib/nanoc/extra/checking/checks/internal_links.rb +6 -7
- data/lib/nanoc/extra/checking/checks/stale.rb +6 -6
- data/lib/nanoc/extra/checking/dsl.rb +1 -1
- data/lib/nanoc/extra/checking/runner.rb +19 -19
- data/lib/nanoc/extra/chick.rb +11 -9
- data/lib/nanoc/extra/core_ext/pathname.rb +1 -2
- data/lib/nanoc/extra/core_ext/time.rb +2 -2
- data/lib/nanoc/extra/core_ext.rb +0 -1
- data/lib/nanoc/extra/deployer.rb +2 -2
- data/lib/nanoc/extra/deployers/fog.rb +12 -12
- data/lib/nanoc/extra/deployers/rsync.rb +6 -6
- data/lib/nanoc/extra/file_proxy.rb +1 -1
- data/lib/nanoc/extra/filesystem_tools.rb +5 -5
- data/lib/nanoc/extra/link_collector.rb +4 -3
- data/lib/nanoc/extra/pruner.rb +5 -5
- data/lib/nanoc/extra/validators/links.rb +3 -3
- data/lib/nanoc/extra/vcs.rb +1 -1
- data/lib/nanoc/filters/asciidoc.rb +3 -3
- data/lib/nanoc/filters/bluecloth.rb +1 -1
- data/lib/nanoc/filters/coderay.rb +2 -2
- data/lib/nanoc/filters/coffeescript.rb +2 -0
- data/lib/nanoc/filters/colorize_syntax.rb +16 -16
- data/lib/nanoc/filters/erb.rb +5 -5
- data/lib/nanoc/filters/erubis.rb +1 -1
- data/lib/nanoc/filters/haml.rb +1 -1
- data/lib/nanoc/filters/handlebars.rb +2 -2
- data/lib/nanoc/filters/kramdown.rb +1 -1
- data/lib/nanoc/filters/less.rb +1 -1
- data/lib/nanoc/filters/markaby.rb +1 -1
- data/lib/nanoc/filters/maruku.rb +1 -1
- data/lib/nanoc/filters/mustache.rb +1 -1
- data/lib/nanoc/filters/pandoc.rb +1 -1
- data/lib/nanoc/filters/rainpress.rb +1 -1
- data/lib/nanoc/filters/rdiscount.rb +1 -1
- data/lib/nanoc/filters/rdoc.rb +1 -1
- data/lib/nanoc/filters/redcarpet.rb +2 -2
- data/lib/nanoc/filters/redcloth.rb +9 -9
- data/lib/nanoc/filters/relativize_paths.rb +7 -8
- data/lib/nanoc/filters/rubypants.rb +1 -1
- data/lib/nanoc/filters/sass/sass_filesystem_importer.rb +1 -1
- data/lib/nanoc/filters/sass.rb +1 -1
- data/lib/nanoc/filters/slim.rb +1 -1
- data/lib/nanoc/filters/typogruby.rb +1 -1
- data/lib/nanoc/filters/uglify_js.rb +1 -1
- data/lib/nanoc/filters/xsl.rb +9 -7
- data/lib/nanoc/filters/yui_compressor.rb +2 -0
- data/lib/nanoc/helpers/blogging.rb +6 -6
- data/lib/nanoc/helpers/breadcrumbs.rb +1 -1
- data/lib/nanoc/helpers/capturing.rb +2 -2
- data/lib/nanoc/helpers/filtering.rb +1 -1
- data/lib/nanoc/helpers/html_escape.rb +3 -3
- data/lib/nanoc/helpers/link_to.rb +6 -6
- data/lib/nanoc/helpers/rendering.rb +2 -2
- data/lib/nanoc/helpers/tagging.rb +2 -2
- data/lib/nanoc/helpers/text.rb +1 -1
- data/lib/nanoc/helpers/xml_sitemap.rb +2 -2
- data/lib/nanoc/version.rb +1 -1
- data/lib/nanoc.rb +3 -2
- data/nanoc.gemspec +2 -6
- data/tasks/rubocop.rake +5 -0
- data/test/base/test_compiler_dsl.rb +20 -1
- data/test/cli/commands/test_compile.rb +4 -3
- data/test/cli/test_error_handler.rb +32 -0
- data/test/filters/test_erb.rb +1 -1
- data/test/filters/test_less.rb +1 -1
- data/test/filters/test_xsl.rb +95 -8
- metadata +30 -84
@@ -3,26 +3,26 @@
|
|
3
3
|
usage 'show-rules [thing]'
|
4
4
|
aliases :explain
|
5
5
|
summary 'describe the rules for each item'
|
6
|
-
description
|
6
|
+
description "
|
7
7
|
Prints the rules used for all items and layouts in the current site.
|
8
|
-
|
8
|
+
"
|
9
9
|
|
10
10
|
module Nanoc::CLI::Commands
|
11
11
|
|
12
12
|
class ShowRules < ::Nanoc::CLI::CommandRunner
|
13
13
|
|
14
14
|
def run
|
15
|
-
|
15
|
+
require_site
|
16
16
|
|
17
17
|
@c = Nanoc::CLI::ANSIStringColorizer
|
18
|
-
@calc =
|
18
|
+
@calc = site.compiler.rule_memory_calculator
|
19
19
|
|
20
20
|
# TODO explain /foo/
|
21
21
|
# TODO explain content/foo.html
|
22
22
|
# TODO explain output/foo/index.html
|
23
23
|
|
24
|
-
|
25
|
-
|
24
|
+
site.items.each { |i| explain_item(i) }
|
25
|
+
site.layouts.each { |l| explain_layout(l) }
|
26
26
|
end
|
27
27
|
|
28
28
|
protected
|
@@ -33,7 +33,7 @@ module Nanoc::CLI::Commands
|
|
33
33
|
item.reps.each do |rep|
|
34
34
|
puts " Rep #{rep.name}:"
|
35
35
|
if @calc[rep].empty? && rep.raw_path.nil?
|
36
|
-
puts
|
36
|
+
puts ' (nothing)'
|
37
37
|
else
|
38
38
|
@calc[rep].each do |mem|
|
39
39
|
puts ' %s %s' % [
|
@@ -55,7 +55,7 @@ module Nanoc::CLI::Commands
|
|
55
55
|
def explain_layout(layout)
|
56
56
|
puts "#{@c.c('Layout ' + layout.identifier, :bold, :yellow)}:"
|
57
57
|
puts " (from #{layout[:filename]})" if layout[:filename]
|
58
|
-
puts
|
58
|
+
puts ' %s %s' % [
|
59
59
|
@c.c(format('%-10s', 'filter'), :blue),
|
60
60
|
@calc[layout].map { |m| m.inspect }.join(', ')
|
61
61
|
]
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
1
3
|
usage 'sync'
|
2
4
|
summary 'sync data sources'
|
3
5
|
description <<-EOS
|
@@ -16,10 +18,10 @@ module Nanoc::CLI::Commands
|
|
16
18
|
end
|
17
19
|
|
18
20
|
# Make sure we are in a nanoc site directory
|
19
|
-
|
21
|
+
require_site
|
20
22
|
|
21
23
|
# Update all syncable data sources
|
22
|
-
|
24
|
+
site.data_sources.each do |data_source|
|
23
25
|
unless data_source.method(:sync).owner == Nanoc::DataSource
|
24
26
|
puts "Syncing #{data_source.config[:type]} data source: #{data_source.items_root}"
|
25
27
|
data_source.sync
|
@@ -26,13 +26,13 @@ module Nanoc::CLI::Commands
|
|
26
26
|
end
|
27
27
|
|
28
28
|
# Make sure we are in a nanoc site directory
|
29
|
-
|
29
|
+
require_site
|
30
30
|
|
31
31
|
# Set VCS if possible
|
32
|
-
|
32
|
+
set_vcs(options[:vcs])
|
33
33
|
|
34
34
|
# Check for -y switch
|
35
|
-
unless options.
|
35
|
+
unless options.key?(:yes)
|
36
36
|
$stderr.puts '*************'
|
37
37
|
$stderr.puts '** WARNING **'
|
38
38
|
$stderr.puts '*************'
|
@@ -57,7 +57,7 @@ module Nanoc::CLI::Commands
|
|
57
57
|
end
|
58
58
|
|
59
59
|
# Update
|
60
|
-
|
60
|
+
site.data_sources.each do |data_source|
|
61
61
|
data_source.update
|
62
62
|
end
|
63
63
|
end
|
@@ -4,16 +4,16 @@ usage 'validate-css [options]'
|
|
4
4
|
aliases :validate_css, :vcss
|
5
5
|
summary 'validate the site’s CSS'
|
6
6
|
be_hidden
|
7
|
-
description
|
7
|
+
description "
|
8
8
|
Validates the site’s CSS files.
|
9
|
-
|
9
|
+
"
|
10
10
|
|
11
11
|
module Nanoc::CLI::Commands
|
12
12
|
|
13
13
|
class ValidateCSS < ::Nanoc::CLI::CommandRunner
|
14
14
|
|
15
15
|
def run
|
16
|
-
warn
|
16
|
+
warn 'The `validate-css` command is deprecated. Please use the new `check` command instead.'
|
17
17
|
Nanoc::CLI.run %w( check css )
|
18
18
|
end
|
19
19
|
|
@@ -4,16 +4,16 @@ usage 'validate-html [options]'
|
|
4
4
|
aliases :validate_html, :vhtml
|
5
5
|
summary 'validate the site’s HTML'
|
6
6
|
be_hidden
|
7
|
-
description
|
7
|
+
description "
|
8
8
|
Validates the site’s HTML files.
|
9
|
-
|
9
|
+
"
|
10
10
|
|
11
11
|
module Nanoc::CLI::Commands
|
12
12
|
|
13
13
|
class ValidateHTML < ::Nanoc::CLI::CommandRunner
|
14
14
|
|
15
15
|
def run
|
16
|
-
warn
|
16
|
+
warn 'The `validate-html` command is deprecated. Please use the new `check` command instead.'
|
17
17
|
Nanoc::CLI.run %w( check html )
|
18
18
|
end
|
19
19
|
|
@@ -4,9 +4,9 @@ usage 'validate-links [options]'
|
|
4
4
|
aliases :validate_links, :vlink
|
5
5
|
summary 'validate links in site'
|
6
6
|
be_hidden
|
7
|
-
description
|
7
|
+
description "
|
8
8
|
Validates the site’s links. By default, both internal and external links will be checked.
|
9
|
-
|
9
|
+
"
|
10
10
|
|
11
11
|
flag :i, :internal, 'validate internal links only'
|
12
12
|
flag :e, :external, 'validate external links only'
|
@@ -16,7 +16,7 @@ module Nanoc::CLI::Commands
|
|
16
16
|
class ValidateLinks < ::Nanoc::CLI::CommandRunner
|
17
17
|
|
18
18
|
def run
|
19
|
-
warn
|
19
|
+
warn 'The `validate-links` command is deprecated. Please use the new `check` command instead.'
|
20
20
|
|
21
21
|
checks = []
|
22
22
|
checks << 'ilinks' if options[:internal]
|
@@ -3,7 +3,9 @@
|
|
3
3
|
usage 'view [options]'
|
4
4
|
summary 'start the web server that serves static files'
|
5
5
|
description <<-EOS
|
6
|
-
Start the static web server. Unless specified, the web server will run on port
|
6
|
+
Start the static web server. Unless specified, the web server will run on port
|
7
|
+
3000 and listen on all IP addresses. Running this static web server requires
|
8
|
+
`adsf` (not `asdf`!).
|
7
9
|
EOS
|
8
10
|
|
9
11
|
required :H, :handler, 'specify the handler to use (webrick/mongrel/...)'
|
@@ -21,7 +23,7 @@ module Nanoc::CLI::Commands
|
|
21
23
|
require 'rack'
|
22
24
|
|
23
25
|
# Make sure we are in a nanoc site directory
|
24
|
-
|
26
|
+
require_site
|
25
27
|
|
26
28
|
# Set options
|
27
29
|
options_for_rack = {
|
@@ -30,7 +32,7 @@ module Nanoc::CLI::Commands
|
|
30
32
|
}
|
31
33
|
|
32
34
|
# Get handler
|
33
|
-
if options.
|
35
|
+
if options.key?(:handler)
|
34
36
|
handler = Rack::Handler.get(options[:handler])
|
35
37
|
else
|
36
38
|
begin
|
@@ -18,7 +18,7 @@ module Nanoc::CLI::Commands
|
|
18
18
|
require 'pathname'
|
19
19
|
|
20
20
|
require_site
|
21
|
-
watcher_config =
|
21
|
+
watcher_config = site.config[:watcher] || {}
|
22
22
|
|
23
23
|
@notifier = Notifier.new
|
24
24
|
|
@@ -35,7 +35,7 @@ module Nanoc::CLI::Commands
|
|
35
35
|
if filename
|
36
36
|
print "Change detected to #{filename}; recompiling… "
|
37
37
|
else
|
38
|
-
print
|
38
|
+
print 'Watcher started; compiling the entire site… '
|
39
39
|
end
|
40
40
|
|
41
41
|
# Recompile
|
@@ -50,7 +50,7 @@ module Nanoc::CLI::Commands
|
|
50
50
|
@notifier.notify('Compilation complete')
|
51
51
|
end
|
52
52
|
|
53
|
-
time_spent = ((Time.now - start)*1000.0).round
|
53
|
+
time_spent = ((Time.now - start) * 1000.0).round
|
54
54
|
puts "done in #{format '%is %ims', *(time_spent.divmod(1000))}"
|
55
55
|
rescue Exception => e
|
56
56
|
# TODO include icon (--image misc/error-icon.png)
|
@@ -69,15 +69,15 @@ module Nanoc::CLI::Commands
|
|
69
69
|
rebuilder.call(nil)
|
70
70
|
|
71
71
|
# Get directories to watch
|
72
|
-
dirs_to_watch = watcher_config[:dirs_to_watch] ||
|
73
|
-
files_to_watch = watcher_config[:files_to_watch] ||
|
72
|
+
dirs_to_watch = watcher_config[:dirs_to_watch] || %w( content layouts lib )
|
73
|
+
files_to_watch = watcher_config[:files_to_watch] || %w( nanoc.yaml config.yaml Rules rules Rules.rb rules.rb )
|
74
74
|
files_to_watch = Regexp.new(files_to_watch.map { |name| Regexp.quote(name) + '$' }.join('|'))
|
75
75
|
ignore_dir = Regexp.new(Dir.glob('*').map { |dir| dir if File.directory?(dir) }.compact.join('|'))
|
76
76
|
|
77
77
|
# Watch
|
78
|
-
puts
|
78
|
+
puts 'Watching for changes…'
|
79
79
|
|
80
|
-
callback =
|
80
|
+
callback = proc do |modified, added, removed|
|
81
81
|
rebuilder.call(modified[0]) if modified[0]
|
82
82
|
rebuilder.call(added[0]) if added[0]
|
83
83
|
rebuilder.call(removed[0]) if removed[0]
|
@@ -108,13 +108,13 @@ module Nanoc::CLI::Commands
|
|
108
108
|
def notify(message)
|
109
109
|
return if tool.nil?
|
110
110
|
if tool == 'growlnotify' && self.on_windows?
|
111
|
-
|
111
|
+
growlnotify_windows(message)
|
112
112
|
else
|
113
113
|
send(tool.tr('-', '_'), message)
|
114
114
|
end
|
115
115
|
end
|
116
116
|
|
117
|
-
|
117
|
+
protected
|
118
118
|
|
119
119
|
def have_tool_nix?(tool)
|
120
120
|
!`which #{tool}`.empty?
|
@@ -146,7 +146,7 @@ module Nanoc::CLI::Commands
|
|
146
146
|
end
|
147
147
|
|
148
148
|
def terminal_notify(message)
|
149
|
-
TerminalNotifier.notify(message, :title =>
|
149
|
+
TerminalNotifier.notify(message, :title => 'nanoc')
|
150
150
|
end
|
151
151
|
|
152
152
|
def growlnotify_cmd_for(message)
|
@@ -154,7 +154,7 @@ module Nanoc::CLI::Commands
|
|
154
154
|
end
|
155
155
|
|
156
156
|
def growlnotify(message)
|
157
|
-
system(*
|
157
|
+
system(*growlnotify_cmd_for(message))
|
158
158
|
end
|
159
159
|
|
160
160
|
def growlnotify_windows_cmd_for(message)
|
@@ -162,7 +162,7 @@ module Nanoc::CLI::Commands
|
|
162
162
|
end
|
163
163
|
|
164
164
|
def growlnotify_windows(message)
|
165
|
-
system(*
|
165
|
+
system(*growlnotify_windows_cmd_for(message))
|
166
166
|
end
|
167
167
|
|
168
168
|
def notify_send(message)
|
@@ -9,7 +9,7 @@ module Nanoc::CLI
|
|
9
9
|
|
10
10
|
# @option params [Nanoc::CLI::Command, nil] command The command that is
|
11
11
|
# currently being executed, or nil if there is none
|
12
|
-
def initialize(params={})
|
12
|
+
def initialize(params = {})
|
13
13
|
@command = params[:command]
|
14
14
|
end
|
15
15
|
|
@@ -19,11 +19,11 @@ module Nanoc::CLI
|
|
19
19
|
# currently being executed, or nil if there is none
|
20
20
|
#
|
21
21
|
# @return [void]
|
22
|
-
def self.handle_while(params={}, &block)
|
22
|
+
def self.handle_while(params = {}, &block)
|
23
23
|
if @disabled
|
24
24
|
yield
|
25
25
|
else
|
26
|
-
|
26
|
+
new(params).handle_while(&block)
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
@@ -52,7 +52,7 @@ module Nanoc::CLI
|
|
52
52
|
# @api private
|
53
53
|
def handle_while(&block)
|
54
54
|
# Set exit handler
|
55
|
-
|
55
|
+
%w( INT TERM ).each do |signal|
|
56
56
|
Signal.trap(signal) do
|
57
57
|
puts
|
58
58
|
exit!(0)
|
@@ -60,7 +60,7 @@ module Nanoc::CLI
|
|
60
60
|
end
|
61
61
|
begin
|
62
62
|
Signal.trap('USR1') do
|
63
|
-
puts
|
63
|
+
puts 'Caught USR1; dumping a stack trace'
|
64
64
|
puts caller.map { |i| " #{i}" }.join("\n")
|
65
65
|
end
|
66
66
|
rescue ArgumentError
|
@@ -71,10 +71,10 @@ module Nanoc::CLI
|
|
71
71
|
rescue Nanoc::Errors::GenericTrivial => e
|
72
72
|
$stderr.puts "Error: #{e.message}"
|
73
73
|
exit(1)
|
74
|
-
rescue Interrupt
|
74
|
+
rescue Interrupt
|
75
75
|
exit(1)
|
76
76
|
rescue StandardError, ScriptError => e
|
77
|
-
|
77
|
+
print_error(e)
|
78
78
|
exit(1)
|
79
79
|
end
|
80
80
|
|
@@ -85,7 +85,7 @@ module Nanoc::CLI
|
|
85
85
|
#
|
86
86
|
# @return [void]
|
87
87
|
def self.print_error(error)
|
88
|
-
|
88
|
+
new.print_error(error)
|
89
89
|
end
|
90
90
|
|
91
91
|
# Prints the given error to stderr. Includes message, possible resolution
|
@@ -117,15 +117,15 @@ module Nanoc::CLI
|
|
117
117
|
def write_compact_error(error, stream)
|
118
118
|
# Header
|
119
119
|
stream.puts
|
120
|
-
stream.puts
|
120
|
+
stream.puts 'Captain! We’ve been hit!'
|
121
121
|
|
122
122
|
# Sections
|
123
|
-
|
124
|
-
|
125
|
-
|
123
|
+
write_error_message(stream, error)
|
124
|
+
write_compilation_stack(stream, error)
|
125
|
+
write_stack_trace(stream, error)
|
126
126
|
|
127
127
|
# Issue link
|
128
|
-
|
128
|
+
write_issue_link(stream)
|
129
129
|
end
|
130
130
|
|
131
131
|
# Writes a verbose representation of the error on the given stream.
|
@@ -142,15 +142,15 @@ module Nanoc::CLI
|
|
142
142
|
stream.puts "Crashlog created at #{Time.now}"
|
143
143
|
|
144
144
|
# Sections
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
145
|
+
write_error_message(stream, error, :verbose => true)
|
146
|
+
write_compilation_stack(stream, error, :verbose => true)
|
147
|
+
write_stack_trace(stream, error, :verbose => true)
|
148
|
+
write_version_information(stream, :verbose => true)
|
149
|
+
write_system_information(stream, :verbose => true)
|
150
|
+
write_installed_gems(stream, :verbose => true)
|
151
|
+
write_environment(stream, :verbose => true)
|
152
|
+
write_gemfile_lock(stream, :verbose => true)
|
153
|
+
write_load_paths(stream, :verbose => true)
|
154
154
|
end
|
155
155
|
|
156
156
|
protected
|
@@ -238,7 +238,7 @@ module Nanoc::CLI
|
|
238
238
|
# Build message
|
239
239
|
if gem_name
|
240
240
|
if self.using_bundler?
|
241
|
-
|
241
|
+
'Make sure the gem is added to Gemfile and run `bundle install`.'
|
242
242
|
else
|
243
243
|
"Install the '#{gem_name}' gem using `gem install #{gem_name}`."
|
244
244
|
end
|
@@ -258,7 +258,7 @@ module Nanoc::CLI
|
|
258
258
|
defined?(Bundler) && Bundler::SharedHelpers.in_bundle?
|
259
259
|
end
|
260
260
|
|
261
|
-
def write_section_header(stream, title, params={})
|
261
|
+
def write_section_header(stream, title, params = {})
|
262
262
|
stream.puts
|
263
263
|
if params[:verbose]
|
264
264
|
stream.puts '===== ' + title.upcase + ':'
|
@@ -268,21 +268,21 @@ module Nanoc::CLI
|
|
268
268
|
stream.puts
|
269
269
|
end
|
270
270
|
|
271
|
-
def write_error_message(stream, error, params={})
|
272
|
-
|
271
|
+
def write_error_message(stream, error, params = {})
|
272
|
+
write_section_header(stream, 'Message', params)
|
273
273
|
|
274
274
|
stream.puts "#{error.class}: #{error.message}"
|
275
|
-
resolution =
|
275
|
+
resolution = resolution_for(error)
|
276
276
|
stream.puts "#{resolution}" if resolution
|
277
277
|
end
|
278
278
|
|
279
|
-
def write_compilation_stack(stream, error, params={})
|
280
|
-
|
279
|
+
def write_compilation_stack(stream, error, params = {})
|
280
|
+
write_section_header(stream, 'Compilation stack', params)
|
281
281
|
|
282
|
-
if
|
283
|
-
stream.puts
|
282
|
+
if stack.empty?
|
283
|
+
stream.puts ' (empty)'
|
284
284
|
else
|
285
|
-
|
285
|
+
stack.reverse.each do |obj|
|
286
286
|
if obj.is_a?(Nanoc::ItemRep)
|
287
287
|
stream.puts " - [item] #{obj.item.identifier} (rep #{obj.name})"
|
288
288
|
else # layout
|
@@ -292,63 +292,63 @@ module Nanoc::CLI
|
|
292
292
|
end
|
293
293
|
end
|
294
294
|
|
295
|
-
def write_stack_trace(stream, error, params={})
|
296
|
-
|
295
|
+
def write_stack_trace(stream, error, params = {})
|
296
|
+
is_verbose = params.fetch(:verbose, false)
|
297
297
|
|
298
|
-
|
298
|
+
write_section_header(stream, 'Stack trace', params)
|
299
|
+
|
300
|
+
count = is_verbose ? -1 : 10
|
299
301
|
error.backtrace[0...count].each_with_index do |item, index|
|
300
302
|
stream.puts " #{index}. #{item}"
|
301
303
|
end
|
302
|
-
if error.backtrace.size > count
|
304
|
+
if !is_verbose && error.backtrace.size > count
|
303
305
|
stream.puts " ... #{error.backtrace.size - count} more lines omitted. See full crash log for details."
|
304
306
|
end
|
305
307
|
end
|
306
308
|
|
307
|
-
def write_issue_link(stream, params={})
|
309
|
+
def write_issue_link(stream, params = {})
|
308
310
|
stream.puts
|
309
|
-
stream.puts
|
310
|
-
stream.puts
|
311
|
+
stream.puts 'If you believe this is a bug in nanoc, please do report it at'
|
312
|
+
stream.puts '-> https://github.com/nanoc/nanoc/issues/new <-'
|
311
313
|
stream.puts
|
312
|
-
stream.puts
|
314
|
+
stream.puts 'A detailed crash log has been written to ./crash.log.'
|
313
315
|
end
|
314
316
|
|
315
|
-
def write_version_information(stream, params={})
|
316
|
-
|
317
|
+
def write_version_information(stream, params = {})
|
318
|
+
write_section_header(stream, 'Version information', params)
|
317
319
|
stream.puts Nanoc.version_information
|
318
320
|
end
|
319
321
|
|
320
|
-
def write_system_information(stream, params={})
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
rescue Errno::ENOENT
|
326
|
-
end
|
322
|
+
def write_system_information(stream, params = {})
|
323
|
+
uname = `uname -a`
|
324
|
+
write_section_header(stream, 'System information', params)
|
325
|
+
stream.puts uname
|
326
|
+
rescue Errno::ENOENT
|
327
327
|
end
|
328
328
|
|
329
|
-
def write_installed_gems(stream, params={})
|
330
|
-
|
331
|
-
|
329
|
+
def write_installed_gems(stream, params = {})
|
330
|
+
write_section_header(stream, 'Installed gems', params)
|
331
|
+
gems_and_versions.each do |g|
|
332
332
|
stream.puts " #{g.first} #{g.last.join(', ')}"
|
333
333
|
end
|
334
334
|
end
|
335
335
|
|
336
|
-
def write_environment(stream, params={})
|
337
|
-
|
336
|
+
def write_environment(stream, params = {})
|
337
|
+
write_section_header(stream, 'Environment', params)
|
338
338
|
ENV.sort.each do |e|
|
339
339
|
stream.puts "#{e.first} => #{e.last.inspect}"
|
340
340
|
end
|
341
341
|
end
|
342
342
|
|
343
|
-
def write_gemfile_lock(stream, params={})
|
343
|
+
def write_gemfile_lock(stream, params = {})
|
344
344
|
if File.exist?('Gemfile.lock')
|
345
|
-
|
345
|
+
write_section_header(stream, 'Gemfile.lock', params)
|
346
346
|
stream.puts File.read('Gemfile.lock')
|
347
347
|
end
|
348
348
|
end
|
349
349
|
|
350
|
-
def write_load_paths(stream, params={})
|
351
|
-
|
350
|
+
def write_load_paths(stream, params = {})
|
351
|
+
write_section_header(stream, 'Load paths', params)
|
352
352
|
$LOAD_PATH.each_with_index do |i, index|
|
353
353
|
stream.puts " #{index}. #{i}"
|
354
354
|
end
|
data/lib/nanoc/cli/logger.rb
CHANGED
@@ -13,8 +13,8 @@ module Nanoc::CLI
|
|
13
13
|
ACTION_COLORS = {
|
14
14
|
:create => "\e[32m", # green
|
15
15
|
:update => "\e[33m", # yellow
|
16
|
-
:identical =>
|
17
|
-
:skip =>
|
16
|
+
:identical => '', # (nothing)
|
17
|
+
:skip => '', # (nothing)
|
18
18
|
:delete => "\e[31m" # red
|
19
19
|
}
|
20
20
|
|
@@ -40,14 +40,14 @@ module Nanoc::CLI
|
|
40
40
|
# @param [String] name The name of the file the action was performed on
|
41
41
|
#
|
42
42
|
# @return [void]
|
43
|
-
def file(level, action, name, duration=nil)
|
43
|
+
def file(level, action, name, duration = nil)
|
44
44
|
log(
|
45
45
|
level,
|
46
46
|
'%s%12s%s %s%s' % [
|
47
47
|
ACTION_COLORS[action.to_sym],
|
48
48
|
action,
|
49
49
|
"\e[0m",
|
50
|
-
duration.nil? ? '' :
|
50
|
+
duration.nil? ? '' : '[%2.2fs] ' % [ duration ],
|
51
51
|
name
|
52
52
|
]
|
53
53
|
)
|
@@ -62,12 +62,12 @@ module Nanoc::CLI
|
|
62
62
|
# @param [#puts] io The stream to which the message should be written
|
63
63
|
#
|
64
64
|
# @return [void]
|
65
|
-
def log(level, message, io
|
65
|
+
def log(level, message, io = $stdout)
|
66
66
|
# Don't log when logging is disabled
|
67
67
|
return if @level == :off
|
68
68
|
|
69
69
|
# Log when level permits it
|
70
|
-
io.puts(message) if
|
70
|
+
io.puts(message) if @level == :low || @level == level
|
71
71
|
end
|
72
72
|
|
73
73
|
end
|
@@ -15,7 +15,7 @@ module Nanoc::CLI::StreamCleaners
|
|
15
15
|
#
|
16
16
|
# @return [String] The cleaned string
|
17
17
|
def clean(s)
|
18
|
-
raise NotImplementedError,
|
18
|
+
raise NotImplementedError, 'Subclasses of Nanoc::CLI::StreamCleaners::Abstract must implement #clean'
|
19
19
|
end
|
20
20
|
|
21
21
|
end
|