Class: Kozeki::Config
- Inherits:
-
Object
show all
- Defined in:
- lib/kozeki/config.rb
Defined Under Namespace
Classes: CollectionOptions
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(options) ⇒ Config
Returns a new instance of Config.
12
13
14
15
16
17
18
|
# File 'lib/kozeki/config.rb', line 12
def initialize(options)
@options = options
@source_filesystem = nil
@destination_filesystem = nil
@loader = nil
@logger = nil
end
|
Class Method Details
24
25
26
|
# File 'lib/kozeki/config.rb', line 24
def self.configure(&block)
new(Dsl.eval(&block).options)
end
|
.load_file(path) ⇒ Object
20
21
22
|
# File 'lib/kozeki/config.rb', line 20
def self.load_file(path)
new(Dsl.load_file(path).options)
end
|
Instance Method Details
#[](k) ⇒ Object
28
29
30
|
# File 'lib/kozeki/config.rb', line 28
def [](k)
@options[k]
end
|
#after_build_callbacks ⇒ Object
64
65
66
|
# File 'lib/kozeki/config.rb', line 64
def after_build_callbacks
@options.fetch(:after_build_callbacks, [])
end
|
#base_directory ⇒ Object
36
37
38
|
# File 'lib/kozeki/config.rb', line 36
def base_directory
@options.fetch(:base_directory, '.')
end
|
#cache_directory ⇒ Object
48
49
50
|
# File 'lib/kozeki/config.rb', line 48
def cache_directory
@options.fetch(:cache_directory, nil)
end
|
#collection_list_included_prefix ⇒ Object
52
53
54
|
# File 'lib/kozeki/config.rb', line 52
def collection_list_included_prefix
@options.fetch(:collection_list_included_prefix, nil)
end
|
#collection_options ⇒ Object
56
57
58
|
# File 'lib/kozeki/config.rb', line 56
def collection_options
@options.fetch(:collection_options, [])
end
|
#destination_directory ⇒ Object
44
45
46
|
# File 'lib/kozeki/config.rb', line 44
def destination_directory
@options.fetch(:destination_directory)
end
|
#destination_filesystem ⇒ Object
76
77
78
|
# File 'lib/kozeki/config.rb', line 76
def destination_filesystem
@destination_filesystem ||= @options.fetch(:destination_filesystem) { LocalFilesystem.new(File.expand_path(destination_directory, base_directory)) }
end
|
#fetch(k, *args) ⇒ Object
32
33
34
|
# File 'lib/kozeki/config.rb', line 32
def fetch(k,*args)
@options.fetch(k,*args)
end
|
#loader ⇒ Object
80
81
82
83
84
85
|
# File 'lib/kozeki/config.rb', line 80
def loader
@loader ||= LoaderChain.new(
loaders: [MarkdownLoader],
decorators: metadata_decorators,
)
end
|
#logger ⇒ Object
87
88
89
|
# File 'lib/kozeki/config.rb', line 87
def logger
@logger ||= Logger.new($stdout)
end
|
60
61
62
|
# File 'lib/kozeki/config.rb', line 60
def metadata_decorators
@options.fetch(:metadata_decorators, [])
end
|
#source_directory ⇒ Object
40
41
42
|
# File 'lib/kozeki/config.rb', line 40
def source_directory
@options.fetch(:source_directory)
end
|
#source_filesystem ⇒ Object
72
73
74
|
# File 'lib/kozeki/config.rb', line 72
def source_filesystem
@source_filesystem ||= @options.fetch(:source_filesystem) { LocalFilesystem.new(File.expand_path(source_directory, base_directory)) }
end
|
#state_path ⇒ Object
68
69
70
|
# File 'lib/kozeki/config.rb', line 68
def state_path
cache_directory ? File.join(File.expand_path(cache_directory, base_directory), 'state.sqlite3') : ':memory:'
end
|