Module: Nanoc::DataSources::Filesystem

Included in:
FilesystemUnified, FilesystemVerbose
Defined in:
lib/nanoc/data_sources/filesystem.rb

Overview

Provides functionality common across all filesystem data sources.

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Instance Attribute Details

- (Nanoc::Extra::VCS?) vcs

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.

Returns:



13
14
15
# File 'lib/nanoc/data_sources/filesystem.rb', line 13

def vcs
  @vcs ||= Nanoc::Extra::VCSes::Dummy.new
end

Instance Method Details

- (Object) content_dir_name



26
27
28
# File 'lib/nanoc/data_sources/filesystem.rb', line 26

def content_dir_name
  config.fetch(:content_dir, 'content')
end

- (Object) create_item(content, attributes, identifier, params = {})



54
55
56
# File 'lib/nanoc/data_sources/filesystem.rb', line 54

def create_item(content, attributes, identifier, params = {})
  create_object(content_dir_name, content, attributes, identifier, params)
end

- (Object) create_layout(content, attributes, identifier, params = {})



59
60
61
# File 'lib/nanoc/data_sources/filesystem.rb', line 59

def create_layout(content, attributes, identifier, params = {})
  create_object(layouts_dir_name, content, attributes, identifier, params)
end

- (Object) down



23
24
# File 'lib/nanoc/data_sources/filesystem.rb', line 23

def down
end

- (Object) items



44
45
46
# File 'lib/nanoc/data_sources/filesystem.rb', line 44

def items
  load_objects(content_dir_name, 'item', Nanoc::Item)
end

- (Object) layouts



49
50
51
# File 'lib/nanoc/data_sources/filesystem.rb', line 49

def layouts
  load_objects(layouts_dir_name, 'layout', Nanoc::Layout)
end

- (Object) layouts_dir_name



30
31
32
# File 'lib/nanoc/data_sources/filesystem.rb', line 30

def layouts_dir_name
  config.fetch(:layouts_dir, 'layouts')
end

- (Object) setup



35
36
37
38
39
40
41
# File 'lib/nanoc/data_sources/filesystem.rb', line 35

def setup
  # Create directories
  [ content_dir_name, layouts_dir_name ].each do |dir|
    FileUtils.mkdir_p(dir)
    vcs.add(dir)
  end
end

- (Object) up



19
20
# File 'lib/nanoc/data_sources/filesystem.rb', line 19

def up
end