nanoc3 3.0.4 → 3.0.5

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,13 @@
1
1
  = nanoc News
2
2
 
3
+ == 3.0.5
4
+
5
+ * Restored pre-3.0.3 behaviour of periods in identifiers. By default, a file
6
+ can have multiple extensions (e.g. content/foo.html.erb will have the
7
+ identifier /foo/), but if `allow_periods_in_identifiers` in the site
8
+ configuration is true, a file can have only one extension (e.g.
9
+ content/blog/stuff.entry.html will have the identifier /blog/stuff.entry/).
10
+
3
11
  == 3.0.4
4
12
 
5
13
  * Fixed a bug which would cause the filesystem_compact data source to
@@ -95,11 +95,15 @@ module Nanoc3::DataSources
95
95
  attributes = meta.merge(:file => Nanoc3::Extra::FileProxy.new(filename))
96
96
 
97
97
  # Get actual identifier
98
+ identifier = filename.sub(/^content/, '')
98
99
  if filename =~ /\/index\.[^\/]+$/
99
- identifier = filename.sub(/^content/, '').sub(/index\.[^\/\.]+$/, '') + '/'
100
+ regex = ((@config && @config[:allow_periods_in_identifiers]) ? /index\.[^\/\.]+$/ : /index\.[^\/]+$/)
101
+ identifier.sub!(regex, '')
100
102
  else
101
- identifier = filename.sub(/^content/, '').sub(/\.[^\/\.]+$/, '') + '/'
103
+ regex = ((@config && @config[:allow_periods_in_identifiers]) ? /\.[^\/\.]+$/ : /\.[^\/]+$/)
104
+ identifier.sub!(regex, '')
102
105
  end
106
+ identifier << '/'
103
107
 
104
108
  # Get mtime
105
109
  mtime = File.stat(filename).mtime
@@ -222,9 +222,13 @@ module Nanoc3::DataSources
222
222
  # '.rej' or '.bak')
223
223
  def content_filename_for_meta_filename(meta_filename)
224
224
  # Find all files
225
- base_filename = File.basename(meta_filename, '.yaml')
226
- dirname = File.dirname(meta_filename)
227
- filenames = Dir.entries(dirname).select { |f| f =~ /^#{base_filename}\.[^.]+$/ }.map { |f| "#{dirname}/#{f}" }
225
+ if @config && @config[:allow_periods_in_identifiers]
226
+ base_filename = File.basename(meta_filename, '.yaml')
227
+ dirname = File.dirname(meta_filename)
228
+ filenames = Dir.entries(dirname).select { |f| f =~ /^#{base_filename}\.[^.]+$/ }.map { |f| "#{dirname}/#{f}" }
229
+ else
230
+ filenames = Dir[meta_filename.sub(/\.yaml$/, '.*')]
231
+ end
228
232
 
229
233
  # Reject meta files
230
234
  filenames.reject! { |f| f =~ /\.yaml$/ }
@@ -19,11 +19,17 @@ module Nanoc3::Extra
19
19
  @path = path
20
20
  end
21
21
 
22
+ # Returns true if File instances respond to the given method; false if
23
+ # they do not.
24
+ def respond_to?(meth)
25
+ File.instance_methods.any? { |m| m == meth.to_s || m == meth.to_sym }
26
+ end
27
+
22
28
  # Makes sure all method calls are relayed to a File object, which will
23
29
  # be created right before the method call takes place and destroyed
24
30
  # right after.
25
31
  def method_missing(sym, *args, &block)
26
- File.new(@path).__send__(sym, *args, &block)
32
+ File.open(@path, 'r') { |io| io.__send__(sym, *args, &block) }
27
33
  end
28
34
 
29
35
  end
data/lib/nanoc3.rb CHANGED
@@ -3,7 +3,7 @@
3
3
  module Nanoc3
4
4
 
5
5
  # The current nanoc version.
6
- VERSION = '3.0.4'
6
+ VERSION = '3.0.5'
7
7
 
8
8
  end
9
9
 
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.4
4
+ version: 3.0.5
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: 2010-01-08 00:00:00 +01:00
12
+ date: 2010-01-13 00:00:00 +01:00
13
13
  default_executable:
14
14
  dependencies: []
15
15