lib/nanoc/data_sources/filesystem.rb in nanoc-3.7.4 vs lib/nanoc/data_sources/filesystem.rb in nanoc-3.7.5
- old
+ new
@@ -1,12 +1,10 @@
# encoding: utf-8
module Nanoc::DataSources
-
# Provides functionality common across all filesystem data sources.
module Filesystem
-
# The VCS that will be called when adding, deleting and moving files. If
# no VCS has been set, or if the VCS has been set to `nil`, a dummy VCS
# will be returned.
#
# @return [Nanoc::Extra::VCS, nil] The VCS that will be used.
@@ -99,18 +97,18 @@
meta, content_or_filename = parse(content_filename, meta_filename, kind)
end
# Get attributes
attributes = {
- :filename => content_filename,
- :content_filename => content_filename,
- :meta_filename => meta_filename,
- :extension => content_filename ? ext_of(content_filename)[1..-1] : nil,
+ filename: content_filename,
+ content_filename: content_filename,
+ meta_filename: meta_filename,
+ extension: content_filename ? ext_of(content_filename)[1..-1] : nil,
# WARNING :file is deprecated; please create a File object manually
# using the :content_filename or :meta_filename attributes.
- # TODO [in nanoc 4.0] remove me
- :file => content_filename ? Nanoc::Extra::FileProxy.new(content_filename) : nil
+ # TODO: [in nanoc 4.0] remove me
+ file: content_filename ? Nanoc::Extra::FileProxy.new(content_filename) : nil
}.merge(meta)
# Get identifier
if meta_filename
identifier = identifier_for_filename(meta_filename[(dir_name.length + 1)..-1])
@@ -134,11 +132,11 @@
end
# Create layout object
klass.new(
content_or_filename, attributes, identifier,
- :binary => is_binary, :mtime => mtime
+ binary: is_binary, mtime: mtime
)
end
end
# Finds all items/layouts/... in the given base directory. Returns a hash
@@ -151,11 +149,12 @@
# 'content/foo' => [ 'yaml', 'html' ],
# 'content/bar' => [ 'yaml', nil ],
# 'content/qux' => [ nil, 'html' ]
# }
def all_split_files_in(dir_name)
- grouped_filenames = all_files_in(dir_name)
+ grouped_filenames =
+ all_files_in(dir_name)
.reject { |fn| fn =~ /(~|\.orig|\.rej|\.bak)$/ }
.group_by { |fn| basename_of(fn) }
grouped_filenames.each_pair do |key, filenames|
# Divide
@@ -178,11 +177,11 @@
grouped_filenames
end
# Returns all files in the given directory and directories below it.
def all_files_in(dir_name)
- Nanoc::Extra::FilesystemTools.all_files_in(dir_name)
+ Nanoc::Extra::FilesystemTools.all_files_in(dir_name, config[:extra_files])
end
# Returns the filename for the given base filename and the extension.
#
# If the extension is nil, this function should return nil as well.
@@ -316,9 +315,7 @@
# Raises an invalid encoding error for the given filename and encoding.
def raise_encoding_error(filename, encoding)
raise RuntimeError.new("Could not read #{filename} because the file is not valid #{encoding}.")
end
-
end
-
end