nanoc3 3.0.0 → 3.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/NEWS.rdoc CHANGED
@@ -1,5 +1,15 @@
1
1
  = nanoc News
2
2
 
3
+ == 3.0.1
4
+
5
+ * The proper exception is now raised when no matching compilation rules can
6
+ be found
7
+ * The autocompile command no longer has a duplicate --port option
8
+ * The #url_for and #feed_url methods now check the presence of the base_url
9
+ site configuration attribute
10
+ * Several outdated URLs are now up-to-date
11
+ * Error handling has been improved in general
12
+
3
13
  == 3.0
4
14
 
5
15
  New:
@@ -10,8 +10,9 @@ Markdown, etc.
10
10
  nanoc3's web site, which can be found at http://nanoc.stoneship.org, contains a
11
11
  few useful resources to help you get started with nanoc:
12
12
 
13
- * The tutorial at http://nanoc.stoneship.org/help/tutorial
14
- * The manual at http://nanoc.stoneship.org/help/manual
13
+ * The tutorial at http://nanoc.stoneship.org/tutorial
14
+ * The manual at http://nanoc.stoneship.org/manual
15
+ * The migration guide at http://nanoc.stoneship.org/migrating
15
16
 
16
17
  It is probably also worth checking out and perhaps subscribing to the
17
18
  discussion groups:
@@ -40,7 +41,7 @@ The source code is structured in a few directories:
40
41
 
41
42
  The namespaces (modules) are organised like this:
42
43
 
43
- * *Nanoc* is the namespace for everything nanoc-related (obviously). The
44
+ * *Nanoc3* is the namespace for everything nanoc-related (obviously). The
44
45
  classes in 'lib/nanoc3/base' are part of this module (not Nanoc3::Base which
45
46
  does not exist)
46
47
  * *CLI* containing everything related to the commandline tool.
@@ -3,7 +3,7 @@
3
3
  module Nanoc3
4
4
 
5
5
  # The current nanoc version.
6
- VERSION = '3.0.0'
6
+ VERSION = '3.0.1'
7
7
 
8
8
  end
9
9
 
@@ -68,8 +68,8 @@ module Nanoc3
68
68
  # Error that is raised when no compilation rule that can be applied to the
69
69
  # current item can be found.
70
70
  class NoMatchingCompilationRuleFound < Generic
71
- def initialize(rep)
72
- super("No compilation rules were found for the '#{rep.item.identifier}' item (rep '#{rep.name}').")
71
+ def initialize(item)
72
+ super("No compilation rules were found for the '#{item.identifier}' item.")
73
73
  end
74
74
  end
75
75
 
@@ -273,7 +273,7 @@ module Nanoc3
273
273
  @items.each do |item|
274
274
  # Find matching rules
275
275
  matching_rules = self.compiler.item_compilation_rules.select { |r| r.applicable_to?(item) }
276
- raise Nanoc3::Errors::NoMatchingCompilationRuleFound.new(rep) if matching_rules.empty?
276
+ raise Nanoc3::Errors::NoMatchingCompilationRuleFound.new(item) if matching_rules.empty?
277
277
 
278
278
  # Create reps
279
279
  rep_names = matching_rules.map { |r| r.rep_name }.uniq
@@ -43,29 +43,6 @@ module Nanoc3::CLI
43
43
  @site = Nanoc3::Site.new('.')
44
44
  rescue Nanoc3::Errors::UnknownDataSource => e
45
45
  $stderr.puts "Unknown data source: #{e}"
46
- exit 1
47
- rescue StandardError, ScriptError => error
48
- # Header
49
- $stderr.puts '+--- /!\ ERROR /!\ -------------------------------------------+'
50
- $stderr.puts '| An exception occured while loading the site. If you think |'
51
- $stderr.puts '| this is a bug in nanoc, please do report it at |'
52
- $stderr.puts '| <http://projects.stoneship.org/trac/nanoc/newticket> -- |'
53
- $stderr.puts '| thanks in advance! |'
54
- $stderr.puts '+-------------------------------------------------------------+'
55
-
56
- # Exception
57
- $stderr.puts
58
- $stderr.puts '=== MESSAGE:'
59
- $stderr.puts
60
- $stderr.puts "#{error.class}: #{error.message}"
61
-
62
- # Backtrace
63
- require 'enumerator'
64
- $stderr.puts
65
- $stderr.puts '=== BACKTRACE:'
66
- $stderr.puts
67
- $stderr.puts error.backtrace.to_enum(:each_with_index).map { |item, index| " #{index}. #{item}" }.join("\n")
68
-
69
46
  exit 1
70
47
  end
71
48
  end
@@ -73,6 +50,100 @@ module Nanoc3::CLI
73
50
  @site
74
51
  end
75
52
 
53
+ # Inherited from ::Cri::Base
54
+ def run(args)
55
+ super(args)
56
+ rescue Interrupt => e
57
+ exit(1)
58
+ rescue StandardError, ScriptError => e
59
+ print_error(e)
60
+ exit(1)
61
+ end
62
+
63
+ # Prints the given error to stderr. Includes message, possible resolution,
64
+ # compilation stack, backtrace, etc.
65
+ def print_error(error)
66
+ $stderr.puts
67
+
68
+ # Header
69
+ $stderr.puts '+--- /!\ ERROR /!\ -------------------------------------------+'
70
+ $stderr.puts '| An exception occured while running nanoc. If you think this |'
71
+ $stderr.puts '| is a bug in nanoc, please do report it at |'
72
+ $stderr.puts '| <http://projects.stoneship.org/trac/nanoc/newticket> -- |'
73
+ $stderr.puts '| thanks in advance! |'
74
+ $stderr.puts '+-------------------------------------------------------------+'
75
+
76
+ # Exception and resolution (if any)
77
+ $stderr.puts
78
+ $stderr.puts '=== MESSAGE:'
79
+ $stderr.puts
80
+ $stderr.puts "#{error.class}: #{error.message}"
81
+ resolution = self.resolution_for(error)
82
+ $stderr.puts "#{resolution}" if resolution
83
+
84
+ # Compilation stack
85
+ $stderr.puts
86
+ $stderr.puts '=== COMPILATION STACK:'
87
+ $stderr.puts
88
+ if ((self.site && self.site.compiler.stack) || []).empty?
89
+ $stderr.puts " (empty)"
90
+ else
91
+ self.site.compiler.stack.reverse.each do |obj|
92
+ if obj.is_a?(Nanoc3::ItemRep)
93
+ $stderr.puts " - [item] #{obj.item.identifier} (rep #{obj.name})"
94
+ else # layout
95
+ $stderr.puts " - [layout] #{obj.identifier}"
96
+ end
97
+ end
98
+ end
99
+
100
+ # Backtrace
101
+ require 'enumerator'
102
+ $stderr.puts
103
+ $stderr.puts '=== BACKTRACE:'
104
+ $stderr.puts
105
+ $stderr.puts error.backtrace.to_enum(:each_with_index).map { |item, index| " #{index}. #{item}" }.join("\n")
106
+ end
107
+
108
+ # Returns a string containing hints for resolving the given error, or nil
109
+ # if no resolution can be automatically obtained.
110
+ def resolution_for(error)
111
+ # FIXME this should probably go somewhere else so that 3rd-party code can add other gem names too
112
+ gem_names = {
113
+ 'bluecloth' => 'bluecloth',
114
+ 'builder' => 'builder',
115
+ 'coderay' => 'coderay',
116
+ 'cri' => 'cri',
117
+ 'erubis' => 'erubis',
118
+ 'haml' => 'haml',
119
+ 'json' => 'json',
120
+ 'less' => 'less',
121
+ 'markaby' => 'markaby',
122
+ 'maruku' => 'maruku',
123
+ 'mime/types' => 'mime-types',
124
+ 'rack' => 'rack',
125
+ 'rack/cache' => 'rack-cache',
126
+ 'rainpress' => 'rainpress',
127
+ 'rdiscount' => 'rdiscount',
128
+ 'redcloth' => 'redcloth',
129
+ 'rubypants' => 'rubypants',
130
+ 'sass' => 'sass',
131
+ 'w3c_validators' => 'w3c_validators'
132
+ }
133
+
134
+ case error
135
+ when LoadError
136
+ # Get gem name
137
+ lib_name = error.message.match(/no such file to load -- ([^\s]+)/)[1]
138
+ gem_name = gem_names[$1]
139
+
140
+ # Build message
141
+ if gem_name
142
+ "Try installing the '#{gem_name}' gem (`gem install #{gem_name}`) and then re-running the command."
143
+ end
144
+ end
145
+ end
146
+
76
147
  # Sets the data source's VCS to the VCS with the given name. Does nothing
77
148
  # when the site's data source does not support VCSes (i.e. does not
78
149
  # implement #vcs=).
@@ -28,11 +28,6 @@ module Nanoc3::CLI::Commands
28
28
 
29
29
  def option_definitions
30
30
  [
31
- # --port
32
- {
33
- :long => 'port', :short => 'p', :argument => :required,
34
- :desc => 'specify a port number for the autocompiler'
35
- },
36
31
  # --server
37
32
  {
38
33
  :long => 'server', :short => 's', :argument => :required,
@@ -105,11 +105,6 @@ module Nanoc3::CLI::Commands
105
105
  print_state_feedback(reps)
106
106
  print_profiling_feedback(reps)
107
107
  end
108
- rescue Interrupt => e
109
- exit(1)
110
- rescue StandardError, ScriptError => e
111
- print_error(e)
112
- exit(1)
113
108
  end
114
109
 
115
110
  private
@@ -188,47 +183,6 @@ module Nanoc3::CLI::Commands
188
183
  end
189
184
  end
190
185
 
191
- def print_error(error)
192
- $stderr.puts
193
-
194
- # Header
195
- $stderr.puts '+--- /!\ ERROR /!\ -------------------------------------------+'
196
- $stderr.puts '| An exception occured while compiling the site. If you think |'
197
- $stderr.puts '| this is a bug in nanoc, please do report it at |'
198
- $stderr.puts '| <http://projects.stoneship.org/trac/nanoc/newticket> -- |'
199
- $stderr.puts '| thanks in advance! |'
200
- $stderr.puts '+-------------------------------------------------------------+'
201
-
202
- # Exception
203
- $stderr.puts
204
- $stderr.puts '=== MESSAGE:'
205
- $stderr.puts
206
- $stderr.puts "#{error.class}: #{error.message}"
207
-
208
- # Compilation stack
209
- $stderr.puts
210
- $stderr.puts '=== COMPILATION STACK:'
211
- $stderr.puts
212
- if ((@base.site && @base.site.compiler.stack) || []).empty?
213
- $stderr.puts " (empty)"
214
- else
215
- @base.site.compiler.stack.reverse.each do |obj|
216
- if obj.is_a?(Nanoc3::ItemRep)
217
- $stderr.puts " - [item] #{obj.item.identifier} (rep #{obj.name})"
218
- else # layout
219
- $stderr.puts " - [layout] #{obj.identifier}"
220
- end
221
- end
222
- end
223
-
224
- # Backtrace
225
- require 'enumerator'
226
- $stderr.puts
227
- $stderr.puts '=== BACKTRACE:'
228
- $stderr.puts
229
- $stderr.puts error.backtrace.to_enum(:each_with_index).map { |item, index| " #{index}. #{item}" }.join("\n")
230
- end
231
-
232
186
  def rep_compilation_started(rep)
233
187
  # Profile compilation
234
188
  @rep_times ||= {}
@@ -75,7 +75,7 @@ module Nanoc3::CLI::Commands
75
75
  data_source.create_layout(
76
76
  "<html>\n" +
77
77
  " <head>\n" +
78
- " <title><%= @item.title %></title>\n" +
78
+ " <title><%= @item[:title] %></title>\n" +
79
79
  " </head>\n" +
80
80
  " <body>\n" +
81
81
  " <p>Hi, I'm a new layout. Please customize me!</p>\n" +
@@ -135,8 +135,8 @@ EOS
135
135
  <div id="sidebar">
136
136
  <h2>Documentation</h2>
137
137
  <ul>
138
- <li><a href="http://nanoc.stoneship.org/help/tutorial/">Tutorial</a></li>
139
- <li><a href="http://nanoc.stoneship.org/help/manual/">Manual</a></li>
138
+ <li><a href="http://nanoc.stoneship.org/tutorial/">Tutorial</a></li>
139
+ <li><a href="http://nanoc.stoneship.org/manual/">Manual</a></li>
140
140
  </ul>
141
141
  <h2>Community</h2>
142
142
  <ul>
@@ -199,12 +199,22 @@ module Nanoc3::Helpers
199
199
  # Returns the URL for the given item. It will return the URL containing
200
200
  # the custom path in the feed if possible, otherwise the normal path.
201
201
  def url_for(item)
202
+ # Check attributes
203
+ if @site.config[:base_url].nil?
204
+ raise RuntimeError.new('Cannot build Atom feed: site configuration has no base_url')
205
+ end
206
+
202
207
  @site.config[:base_url] + (item[:custom_path_in_feed] || item.reps[0].path)
203
208
  end
204
209
 
205
210
  # Returns the URL of the feed. It will return the custom feed URL if set,
206
211
  # or otherwise the normal feed URL.
207
212
  def feed_url
213
+ # Check attributes
214
+ if @site.config[:base_url].nil?
215
+ raise RuntimeError.new('Cannot build Atom feed: site configuration has no base_url')
216
+ end
217
+
208
218
  @item[:feed_url] || @site.config[:base_url] + @item.reps[0].path
209
219
  end
210
220
 
@@ -33,7 +33,7 @@ module Nanoc3::Helpers
33
33
  # this item, the purpose of nanoc is described, blah blah blah,” as
34
34
  # expected.
35
35
  #
36
- # This helper likely only works with ERB (and perhaps Erubis).
36
+ # This helper has been tested with ERB and Haml.
37
37
  #
38
38
  # To activate this helper, +include+ it, like this:
39
39
  #
@@ -13,7 +13,7 @@ module Nanoc3::Helpers
13
13
  # <p>Consectetur adipisicing elit...</p>
14
14
  # <% end %>
15
15
  #
16
- # This helper likely only works with ERB (and perhaps Erubis).
16
+ # This helper has been tested with ERB and Haml.
17
17
  #
18
18
  # To activate this helper, +include+ it, like this:
19
19
  #
@@ -64,7 +64,7 @@ module Nanoc3
64
64
  '... documents into static web pages'
65
65
  s.description = s.summary
66
66
  s.homepage = 'http://nanoc.stoneship.org/'
67
- s.rubyforge_project = 'nanoc3'
67
+ s.rubyforge_project = 'nanoc'
68
68
 
69
69
  s.author = 'Denis Defreyne'
70
70
  s.email = 'denis.defreyne@stoneship.org'
@@ -73,8 +73,8 @@ module Nanoc3
73
73
  ------------------------------------------------------------------------------
74
74
  Thanks for installing nanoc 3.0! Here are some resources to help you get started:
75
75
 
76
- * The tutorial at <http://nanoc.stoneship.org/help/tutorial/>
77
- * The manual at <http://nanoc.stoneship.org/help/manual/>
76
+ * The tutorial at <http://nanoc.stoneship.org/tutorial/>
77
+ * The manual at <http://nanoc.stoneship.org/manual/>
78
78
  * The discussion group at <http://groups.google.com/group/nanoc>
79
79
 
80
80
  Because nanoc 3.0 has a lot of new features, be sure to check out the nanoc blog at <http://nanoc.stoneship.org/blog/> for details about this release.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nanoc3
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 3.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Denis Defreyne
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-08-14 00:00:00 +02:00
12
+ date: 2009-10-05 00:00:00 +02:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -150,8 +150,8 @@ post_install_message: |
150
150
  ------------------------------------------------------------------------------
151
151
  Thanks for installing nanoc 3.0! Here are some resources to help you get started:
152
152
 
153
- * The tutorial at <http://nanoc.stoneship.org/help/tutorial/>
154
- * The manual at <http://nanoc.stoneship.org/help/manual/>
153
+ * The tutorial at <http://nanoc.stoneship.org/tutorial/>
154
+ * The manual at <http://nanoc.stoneship.org/manual/>
155
155
  * The discussion group at <http://groups.google.com/group/nanoc>
156
156
 
157
157
  Because nanoc 3.0 has a lot of new features, be sure to check out the nanoc blog at <http://nanoc.stoneship.org/blog/> for details about this release.
@@ -216,7 +216,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
216
216
  version:
217
217
  requirements: []
218
218
 
219
- rubyforge_project: nanoc3
219
+ rubyforge_project: nanoc
220
220
  rubygems_version: 1.3.5
221
221
  signing_key:
222
222
  specification_version: 3