nanoc3 3.1.2 → 3.1.3

Sign up to get free protection for your applications and to get access to all the features.
data/NEWS.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # nanoc news
2
2
 
3
+ ## 3.1.3 (???)
4
+
5
+ * Removed annoying win32console warning [Eric Sunshine]
6
+ * Removed color codes when not writing to a terminal, or when writing to
7
+ Windows’ console when win32console is not installed [Eric Sunshine]
8
+ * Added .xhtml and .xml to list of text extensions
9
+ * Improved support for relative Sass @imports [Chris Eppstein]
10
+
3
11
  ## 3.1.2 (2010-04-07)
4
12
 
5
13
  * Fixed bug which could cause incorrect output when compilation of an item is
data/README.md CHANGED
@@ -58,20 +58,23 @@ components, however, do have dependencies:
58
58
  * The **autocompiler** depends on `mime-types` and `rack`.
59
59
  * For **documentation generation** you’ll need `yard`.
60
60
  * For **packaging** you’ll need `rubygems` (1.3 or newer).
61
- * For **testing** you’ll need `mocha`.
61
+ * For **testing** you’ll need `mocha` and `minitest`.
62
62
 
63
63
  ## Contributors
64
64
 
65
65
  (In alphabetical order)
66
66
 
67
+ * Ben Armston
67
68
  * Colin Barrett
68
69
  * Dmitry Bilunov
69
70
  * Brian Candler
70
71
  * Chris Eppstein
72
+ * Felix Hanley
71
73
  * Starr Horne
72
74
  * Nicky Peeters
73
75
  * Christian Plessl
74
76
  * Šime Ramov
77
+ * Xavier Shay
75
78
  * “Soryu”
76
79
  * Eric Sunshine
77
80
  * Dennis Sutch
@@ -3,7 +3,7 @@
3
3
  module Nanoc3
4
4
 
5
5
  # The current nanoc version.
6
- VERSION = '3.1.2'
6
+ VERSION = '3.1.3'
7
7
 
8
8
  end
9
9
 
@@ -354,7 +354,7 @@ module Nanoc3
354
354
  if self.binary?
355
355
  # Calculate hash of old content
356
356
  if File.file?(self.raw_path)
357
- hash_old = hash(self.raw_path)
357
+ hash_old = hash_for_file(self.raw_path)
358
358
  size_old = File.size(self.raw_path)
359
359
  end
360
360
 
@@ -364,7 +364,7 @@ module Nanoc3
364
364
 
365
365
  # Check if file was modified
366
366
  size_new = File.size(self.raw_path)
367
- hash_new = hash(self.raw_path) if size_old == size_new
367
+ hash_new = hash_for_file(self.raw_path) if size_old == size_new
368
368
  @modified = (size_old != size_new || hash_old != hash_new)
369
369
  else
370
370
  # Remember old content
@@ -488,7 +488,7 @@ module Nanoc3
488
488
  end
489
489
 
490
490
  # Returns a hash of the given filename
491
- def hash(filename)
491
+ def hash_for_file(filename)
492
492
  digest = Digest::SHA1.new
493
493
  File.open(filename, 'r') do |io|
494
494
  until io.eof
@@ -39,7 +39,7 @@ module Nanoc3
39
39
  # that lacks some options, the default value will be taken from
40
40
  # `DEFAULT_CONFIG`.
41
41
  DEFAULT_CONFIG = {
42
- :text_extensions => %w( css erb haml htm html js less markdown md php rb sass txt ),
42
+ :text_extensions => %w( css erb haml htm html js less markdown md php rb sass txt xhtml xml ),
43
43
  :output_dir => 'output',
44
44
  :data_sources => [ {} ],
45
45
  :index_filenames => [ 'index.html' ],
@@ -28,13 +28,13 @@ module Nanoc3::CLI
28
28
 
29
29
  def initialize
30
30
  @level = :high
31
- @color = true
31
+ @color = $stdout.tty?
32
32
 
33
33
  # Try enabling color support on Windows
34
34
  begin
35
35
  require 'Win32/Console/ANSI' if RUBY_PLATFORM =~/mswin|mingw/
36
36
  rescue LoadError
37
- warn 'The win32console gem is not available. Install it to enable color support on Windows.'
37
+ @color = false
38
38
  end
39
39
  end
40
40
 
@@ -166,8 +166,8 @@ module Nanoc3::DataSources
166
166
  end
167
167
 
168
168
  # Reorder elements and convert to extnames
169
- filenames[0] = meta_filenames[0] ? ext_of(meta_filenames[0])[1..-1] : nil
170
- filenames[1] = content_filenames[0] ? ext_of(content_filenames[0])[1..-1] : nil
169
+ filenames[0] = meta_filenames[0] ? 'yaml' : nil
170
+ filenames[1] = content_filenames[0] ? ext_of(content_filenames[0])[1..-1] || '': nil
171
171
  end
172
172
 
173
173
  # Done
@@ -239,15 +239,15 @@ module Nanoc3::DataSources
239
239
  data = File.read(content_filename)
240
240
 
241
241
  # Check presence of metadata section
242
- if data !~ /^(-{5}|-{3})/
242
+ if data[0, 3] != '-'*3 && data[0, 5] != '-'*5
243
243
  return [ {}, data ]
244
244
  end
245
245
 
246
246
  # Split data
247
- pieces = data.split(/^(-{5}|-{3})/)
247
+ pieces = data.split(/^(-{5}|-{3})\s*$/)
248
248
  if pieces.size < 4
249
249
  raise RuntimeError.new(
250
- "The file '#{content_filename}' does not seem to be a nanoc #{kind}"
250
+ "The file '#{content_filename}' appears to start with a metadata section (three or five dashes at the top) but it does not seem to be in the correct format."
251
251
  )
252
252
  end
253
253
 
@@ -91,7 +91,13 @@ module Nanoc3::DataSources
91
91
 
92
92
  # See {Nanoc3::DataSources::Filesystem#filename_for}.
93
93
  def filename_for(base_filename, ext)
94
- ext ? base_filename + '.' + ext : nil
94
+ if ext.nil?
95
+ nil
96
+ elsif ext.empty?
97
+ base_filename
98
+ else
99
+ base_filename + '.' + ext
100
+ end
95
101
  end
96
102
 
97
103
  # Returns the identifier derived from the given filename, first stripping
@@ -64,10 +64,16 @@ module Nanoc3::DataSources
64
64
 
65
65
  # See {Nanoc3::DataSources::Filesystem#filename_for}.
66
66
  def filename_for(base_filename, ext)
67
- last_part = base_filename.split('/')[-1]
68
- base_glob = base_filename.split('/')[0..-2].join('/') + "/{index,#{last_part}}."
67
+ return nil if ext.nil?
69
68
 
70
- ext ? Dir[base_glob + ext][0] : nil
69
+ last_component = base_filename[%r{[^/]+$}]
70
+ possibilities = [
71
+ base_filename + (ext.empty? ? '' : '.' + ext), # foo/bar.html
72
+ base_filename + '/' + last_component + (ext.empty? ? '' : '.' + ext), # foo/bar/bar.html
73
+ base_filename + '/' + 'index' + (ext.empty? ? '' : '.' + ext) # foo/bar/index.html
74
+ ]
75
+
76
+ possibilities.find { |p| File.file?(p) }
71
77
  end
72
78
 
73
79
  # See {Nanoc3::DataSources::Filesystem#identifier_for_filename}.
@@ -20,7 +20,9 @@ module Nanoc3::Filters
20
20
  end
21
21
 
22
22
  # Get options
23
- options = params.merge(:filename => filename)
23
+ options = params.dup
24
+ sass_filename = options[:filename] || (@item && @item[:content_filename])
25
+ options[:filename] ||= sass_filename
24
26
 
25
27
  # Build engine
26
28
  engine = ::Sass::Engine.new(content, options)
@@ -43,8 +45,7 @@ module Nanoc3::Filters
43
45
 
44
46
  # Get import paths
45
47
  import_paths = (options[:load_paths] || []).dup
46
- import_paths.unshift(File.dirname(options[:filename])) if options[:filename]
47
-
48
+ import_paths.unshift(File.dirname(sass_filename)) if sass_filename
48
49
  # Get imported filenames
49
50
  imported_filenames = imported_nodes.map do |node|
50
51
  ::Sass::Files.find_file_to_import(node.imported_filename, import_paths)
@@ -52,8 +53,10 @@ module Nanoc3::Filters
52
53
 
53
54
  # Convert to items
54
55
  imported_items = imported_filenames.map do |filename|
55
- normalized_filename = Pathname.new(filename).realpath
56
- @items.find { |i| i[:filename] && Pathname.new(i[:filename]).realpath == normalized_filename }
56
+ pathname = Pathname.new(filename)
57
+ next unless pathname.file?
58
+ normalized_filename = pathname.realpath
59
+ @items.find { |i| i[:content_filename] && Pathname.new(i[:content_filename]).realpath == normalized_filename }
57
60
  end.compact
58
61
 
59
62
  # Require compilation of each item
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 3
7
7
  - 1
8
- - 2
9
- version: 3.1.2
8
+ - 3
9
+ version: 3.1.3
10
10
  platform: ruby
11
11
  authors:
12
12
  - Denis Defreyne
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-04-07 00:00:00 +02:00
17
+ date: 2010-04-25 00:00:00 +02:00
18
18
  default_executable: nanoc3
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency