nanoc 3.6.7 → 3.6.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (144) hide show
  1. checksums.yaml +8 -8
  2. data/CONTRIBUTING.md +9 -13
  3. data/Gemfile +5 -1
  4. data/Gemfile.lock +70 -45
  5. data/NEWS.md +15 -1
  6. data/README.md +12 -119
  7. data/doc/yardoc_handlers/identifier.rb +34 -0
  8. data/lib/nanoc/base/compilation/checksum_store.rb +2 -2
  9. data/lib/nanoc/base/compilation/compiler.rb +3 -3
  10. data/lib/nanoc/base/compilation/compiler_dsl.rb +20 -15
  11. data/lib/nanoc/base/compilation/dependency_tracker.rb +4 -4
  12. data/lib/nanoc/base/compilation/filter.rb +5 -5
  13. data/lib/nanoc/base/compilation/item_rep_proxy.rb +2 -2
  14. data/lib/nanoc/base/compilation/item_rep_recorder_proxy.rb +3 -3
  15. data/lib/nanoc/base/compilation/outdatedness_checker.rb +49 -46
  16. data/lib/nanoc/base/compilation/rule.rb +6 -4
  17. data/lib/nanoc/base/compilation/rule_context.rb +10 -4
  18. data/lib/nanoc/base/compilation/rule_memory_calculator.rb +8 -7
  19. data/lib/nanoc/base/compilation/rule_memory_store.rb +2 -2
  20. data/lib/nanoc/base/compilation/rules_collection.rb +2 -2
  21. data/lib/nanoc/base/core_ext/array.rb +2 -2
  22. data/lib/nanoc/base/core_ext/date.rb +4 -2
  23. data/lib/nanoc/base/core_ext/hash.rb +3 -3
  24. data/lib/nanoc/base/core_ext/pathname.rb +1 -1
  25. data/lib/nanoc/base/directed_graph.rb +6 -6
  26. data/lib/nanoc/base/errors.rb +1 -1
  27. data/lib/nanoc/base/memoization.rb +4 -4
  28. data/lib/nanoc/base/notification_center.rb +1 -1
  29. data/lib/nanoc/base/ordered_hash.rb +207 -179
  30. data/lib/nanoc/base/plugin_registry.rb +7 -7
  31. data/lib/nanoc/base/result_data/item_rep.rb +25 -26
  32. data/lib/nanoc/base/source_data/code_snippet.rb +2 -2
  33. data/lib/nanoc/base/source_data/configuration.rb +1 -1
  34. data/lib/nanoc/base/source_data/data_source.rb +2 -2
  35. data/lib/nanoc/base/source_data/item.rb +16 -15
  36. data/lib/nanoc/base/source_data/item_array.rb +4 -4
  37. data/lib/nanoc/base/source_data/layout.rb +5 -5
  38. data/lib/nanoc/base/source_data/site.rb +6 -6
  39. data/lib/nanoc/base/store.rb +8 -8
  40. data/lib/nanoc/cli/cleaning_stream.rb +11 -12
  41. data/lib/nanoc/cli/command_runner.rb +8 -8
  42. data/lib/nanoc/cli/commands/autocompile.rb +5 -4
  43. data/lib/nanoc/cli/commands/check.rb +12 -11
  44. data/lib/nanoc/cli/commands/compile.rb +50 -52
  45. data/lib/nanoc/cli/commands/create-item.rb +6 -6
  46. data/lib/nanoc/cli/commands/create-layout.rb +6 -6
  47. data/lib/nanoc/cli/commands/create-site.rb +10 -13
  48. data/lib/nanoc/cli/commands/deploy.rb +11 -11
  49. data/lib/nanoc/cli/commands/prune.rb +10 -10
  50. data/lib/nanoc/cli/commands/shell.rb +7 -7
  51. data/lib/nanoc/cli/commands/show-data.rb +22 -23
  52. data/lib/nanoc/cli/commands/show-plugins.rb +3 -3
  53. data/lib/nanoc/cli/commands/show-rules.rb +8 -8
  54. data/lib/nanoc/cli/commands/sync.rb +4 -2
  55. data/lib/nanoc/cli/commands/update.rb +4 -4
  56. data/lib/nanoc/cli/commands/validate-css.rb +3 -3
  57. data/lib/nanoc/cli/commands/validate-html.rb +3 -3
  58. data/lib/nanoc/cli/commands/validate-links.rb +3 -3
  59. data/lib/nanoc/cli/commands/view.rb +5 -3
  60. data/lib/nanoc/cli/commands/watch.rb +12 -12
  61. data/lib/nanoc/cli/error_handler.rb +58 -58
  62. data/lib/nanoc/cli/logger.rb +6 -6
  63. data/lib/nanoc/cli/stream_cleaners/abstract.rb +1 -1
  64. data/lib/nanoc/cli/stream_cleaners.rb +0 -1
  65. data/lib/nanoc/cli.rb +24 -22
  66. data/lib/nanoc/data_sources/deprecated/delicious.rb +1 -1
  67. data/lib/nanoc/data_sources/deprecated/last_fm.rb +16 -14
  68. data/lib/nanoc/data_sources/deprecated/twitter.rb +1 -1
  69. data/lib/nanoc/data_sources/filesystem.rb +22 -20
  70. data/lib/nanoc/data_sources/filesystem_unified.rb +4 -5
  71. data/lib/nanoc/data_sources/filesystem_verbose.rb +2 -3
  72. data/lib/nanoc/data_sources/static.rb +2 -2
  73. data/lib/nanoc/extra/auto_compiler.rb +3 -3
  74. data/lib/nanoc/extra/checking/check.rb +3 -3
  75. data/lib/nanoc/extra/checking/checks/css.rb +2 -2
  76. data/lib/nanoc/extra/checking/checks/external_links.rb +9 -9
  77. data/lib/nanoc/extra/checking/checks/html.rb +2 -3
  78. data/lib/nanoc/extra/checking/checks/internal_links.rb +6 -7
  79. data/lib/nanoc/extra/checking/checks/stale.rb +6 -6
  80. data/lib/nanoc/extra/checking/dsl.rb +1 -1
  81. data/lib/nanoc/extra/checking/runner.rb +19 -19
  82. data/lib/nanoc/extra/chick.rb +11 -9
  83. data/lib/nanoc/extra/core_ext/pathname.rb +1 -2
  84. data/lib/nanoc/extra/core_ext/time.rb +2 -2
  85. data/lib/nanoc/extra/core_ext.rb +0 -1
  86. data/lib/nanoc/extra/deployer.rb +2 -2
  87. data/lib/nanoc/extra/deployers/fog.rb +12 -12
  88. data/lib/nanoc/extra/deployers/rsync.rb +6 -6
  89. data/lib/nanoc/extra/file_proxy.rb +1 -1
  90. data/lib/nanoc/extra/filesystem_tools.rb +5 -5
  91. data/lib/nanoc/extra/link_collector.rb +4 -3
  92. data/lib/nanoc/extra/pruner.rb +5 -5
  93. data/lib/nanoc/extra/validators/links.rb +3 -3
  94. data/lib/nanoc/extra/vcs.rb +1 -1
  95. data/lib/nanoc/filters/asciidoc.rb +3 -3
  96. data/lib/nanoc/filters/bluecloth.rb +1 -1
  97. data/lib/nanoc/filters/coderay.rb +2 -2
  98. data/lib/nanoc/filters/coffeescript.rb +2 -0
  99. data/lib/nanoc/filters/colorize_syntax.rb +16 -16
  100. data/lib/nanoc/filters/erb.rb +5 -5
  101. data/lib/nanoc/filters/erubis.rb +1 -1
  102. data/lib/nanoc/filters/haml.rb +1 -1
  103. data/lib/nanoc/filters/handlebars.rb +2 -2
  104. data/lib/nanoc/filters/kramdown.rb +1 -1
  105. data/lib/nanoc/filters/less.rb +1 -1
  106. data/lib/nanoc/filters/markaby.rb +1 -1
  107. data/lib/nanoc/filters/maruku.rb +1 -1
  108. data/lib/nanoc/filters/mustache.rb +1 -1
  109. data/lib/nanoc/filters/pandoc.rb +1 -1
  110. data/lib/nanoc/filters/rainpress.rb +1 -1
  111. data/lib/nanoc/filters/rdiscount.rb +1 -1
  112. data/lib/nanoc/filters/rdoc.rb +1 -1
  113. data/lib/nanoc/filters/redcarpet.rb +2 -2
  114. data/lib/nanoc/filters/redcloth.rb +9 -9
  115. data/lib/nanoc/filters/relativize_paths.rb +7 -8
  116. data/lib/nanoc/filters/rubypants.rb +1 -1
  117. data/lib/nanoc/filters/sass/sass_filesystem_importer.rb +1 -1
  118. data/lib/nanoc/filters/sass.rb +1 -1
  119. data/lib/nanoc/filters/slim.rb +1 -1
  120. data/lib/nanoc/filters/typogruby.rb +1 -1
  121. data/lib/nanoc/filters/uglify_js.rb +1 -1
  122. data/lib/nanoc/filters/xsl.rb +9 -7
  123. data/lib/nanoc/filters/yui_compressor.rb +2 -0
  124. data/lib/nanoc/helpers/blogging.rb +6 -6
  125. data/lib/nanoc/helpers/breadcrumbs.rb +1 -1
  126. data/lib/nanoc/helpers/capturing.rb +2 -2
  127. data/lib/nanoc/helpers/filtering.rb +1 -1
  128. data/lib/nanoc/helpers/html_escape.rb +3 -3
  129. data/lib/nanoc/helpers/link_to.rb +6 -6
  130. data/lib/nanoc/helpers/rendering.rb +2 -2
  131. data/lib/nanoc/helpers/tagging.rb +2 -2
  132. data/lib/nanoc/helpers/text.rb +1 -1
  133. data/lib/nanoc/helpers/xml_sitemap.rb +2 -2
  134. data/lib/nanoc/version.rb +1 -1
  135. data/lib/nanoc.rb +3 -2
  136. data/nanoc.gemspec +2 -6
  137. data/tasks/rubocop.rake +5 -0
  138. data/test/base/test_compiler_dsl.rb +20 -1
  139. data/test/cli/commands/test_compile.rb +4 -3
  140. data/test/cli/test_error_handler.rb +32 -0
  141. data/test/filters/test_erb.rb +1 -1
  142. data/test/filters/test_less.rb +1 -1
  143. data/test/filters/test_xsl.rb +95 -8
  144. 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 <<-EOS
6
+ description "
7
7
  Prints the rules used for all items and layouts in the current site.
8
- EOS
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
- self.require_site
15
+ require_site
16
16
 
17
17
  @c = Nanoc::CLI::ANSIStringColorizer
18
- @calc = self.site.compiler.rule_memory_calculator
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
- self.site.items.each { |i| self.explain_item(i) }
25
- self.site.layouts.each { |l| self.explain_layout(l) }
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 " (nothing)"
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 " %s %s" % [
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
- self.require_site
21
+ require_site
20
22
 
21
23
  # Update all syncable data sources
22
- self.site.data_sources.each do |data_source|
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
- self.require_site
29
+ require_site
30
30
 
31
31
  # Set VCS if possible
32
- self.set_vcs(options[:vcs])
32
+ set_vcs(options[:vcs])
33
33
 
34
34
  # Check for -y switch
35
- unless options.has_key?(:yes)
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
- self.site.data_sources.each do |data_source|
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 <<-EOS
7
+ description "
8
8
  Validates the site’s CSS files.
9
- EOS
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 "The `validate-css` command is deprecated. Please use the new `check` command instead."
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 <<-EOS
7
+ description "
8
8
  Validates the site’s HTML files.
9
- EOS
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 "The `validate-html` command is deprecated. Please use the new `check` command instead."
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 <<-EOS
7
+ description "
8
8
  Validates the site’s links. By default, both internal and external links will be checked.
9
- EOS
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 "The `validate-links` command is deprecated. Please use the new `check` command instead."
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 3000 and listen on all IP addresses. Running this static web server requires `adsf` (not `asdf`!).
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
- self.require_site
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.has_key?(:handler)
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 = self.site.config[:watcher] || {}
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 "Watcher started; compiling the entire site… "
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] || [ 'content', 'layouts', 'lib' ]
73
- files_to_watch = watcher_config[:files_to_watch] || [ 'nanoc.yaml', 'config.yaml', 'Rules', 'rules', 'Rules.rb', 'rules.rb' ]
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 "Watching for changes…"
78
+ puts 'Watching for changes…'
79
79
 
80
- callback = Proc.new do |modified, added, removed|
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
- self.growlnotify_windows(message)
111
+ growlnotify_windows(message)
112
112
  else
113
113
  send(tool.tr('-', '_'), message)
114
114
  end
115
115
  end
116
116
 
117
- protected
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 => "nanoc")
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(*self.growlnotify_cmd_for(message))
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(*self.growlnotify_windows_cmd_for(message))
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
- self.new(params).handle_while(&block)
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
- [ 'INT', 'TERM' ].each do |signal|
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 "Caught USR1; dumping a stack trace"
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 => e
74
+ rescue Interrupt
75
75
  exit(1)
76
76
  rescue StandardError, ScriptError => e
77
- self.print_error(e)
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
- self.new.print_error(error)
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 "Captain! We’ve been hit!"
120
+ stream.puts 'Captain! We’ve been hit!'
121
121
 
122
122
  # Sections
123
- self.write_error_message( stream, error)
124
- self.write_compilation_stack(stream, error)
125
- self.write_stack_trace( stream, error)
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
- self.write_issue_link(stream)
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
- self.write_error_message( stream, error, :verbose => true)
146
- self.write_compilation_stack( stream, error, :verbose => true)
147
- self.write_stack_trace( stream, error, :verbose => true)
148
- self.write_version_information(stream, :verbose => true)
149
- self.write_system_information( stream, :verbose => true)
150
- self.write_installed_gems( stream, :verbose => true)
151
- self.write_environment( stream, :verbose => true)
152
- self.write_gemfile_lock( stream, :verbose => true)
153
- self.write_load_paths( stream, :verbose => true)
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
- "Make sure the gem is added to Gemfile and run `bundle install`."
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
- self.write_section_header(stream, 'Message', params)
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 = self.resolution_for(error)
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
- self.write_section_header(stream, 'Compilation stack', params)
279
+ def write_compilation_stack(stream, error, params = {})
280
+ write_section_header(stream, 'Compilation stack', params)
281
281
 
282
- if self.stack.empty?
283
- stream.puts " (empty)"
282
+ if stack.empty?
283
+ stream.puts ' (empty)'
284
284
  else
285
- self.stack.reverse.each do |obj|
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
- self.write_section_header(stream, 'Stack trace', params)
295
+ def write_stack_trace(stream, error, params = {})
296
+ is_verbose = params.fetch(:verbose, false)
297
297
 
298
- count = params[:verbose] ? -1 : 10
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 "If you believe this is a bug in nanoc, please do report it at"
310
- stream.puts "-> https://github.com/nanoc/nanoc/issues/new <-"
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 "A detailed crash log has been written to ./crash.log."
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
- self.write_section_header(stream, 'Version information', params)
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
- begin
322
- uname = `uname -a`
323
- self.write_section_header(stream, 'System information', params)
324
- stream.puts uname
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
- self.write_section_header(stream, 'Installed gems', params)
331
- self.gems_and_versions.each do |g|
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
- self.write_section_header(stream, 'Environment', params)
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
- self.write_section_header(stream, 'Gemfile.lock', params)
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
- self.write_section_header(stream, 'Load paths', params)
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
@@ -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 => "", # (nothing)
17
- :skip => "", # (nothing)
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? ? '' : "[%2.2fs] " % [ duration ],
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=$stdout)
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 (@level == :low or @level == level)
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, "Subclasses of Nanoc::CLI::StreamCleaners::Abstract must implement #clean"
18
+ raise NotImplementedError, 'Subclasses of Nanoc::CLI::StreamCleaners::Abstract must implement #clean'
19
19
  end
20
20
 
21
21
  end
@@ -11,4 +11,3 @@ module Nanoc::CLI
11
11
  end
12
12
 
13
13
  end
14
-