Class: Kozeki::Config

Inherits:
Object
  • 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

.configure(&block) ⇒ Object



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_callbacksObject



64
65
66
# File 'lib/kozeki/config.rb', line 64

def after_build_callbacks
  @options.fetch(:after_build_callbacks, [])
end

#base_directoryObject



36
37
38
# File 'lib/kozeki/config.rb', line 36

def base_directory
  @options.fetch(:base_directory, '.')
end

#cache_directoryObject



48
49
50
# File 'lib/kozeki/config.rb', line 48

def cache_directory
  @options.fetch(:cache_directory, nil)
end

#collection_list_included_prefixObject



52
53
54
# File 'lib/kozeki/config.rb', line 52

def collection_list_included_prefix
  @options.fetch(:collection_list_included_prefix, nil)
end

#collection_optionsObject



56
57
58
# File 'lib/kozeki/config.rb', line 56

def collection_options
  @options.fetch(:collection_options, [])
end

#destination_directoryObject



44
45
46
# File 'lib/kozeki/config.rb', line 44

def destination_directory
  @options.fetch(:destination_directory)
end

#destination_filesystemObject



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

#loaderObject



80
81
82
83
84
85
# File 'lib/kozeki/config.rb', line 80

def loader
  @loader ||= LoaderChain.new(
    loaders: [MarkdownLoader],
    decorators: ,
  )
end

#loggerObject



87
88
89
# File 'lib/kozeki/config.rb', line 87

def logger
  @logger ||= Logger.new($stdout)
end

#metadata_decoratorsObject



60
61
62
# File 'lib/kozeki/config.rb', line 60

def 
  @options.fetch(:metadata_decorators, [])
end

#source_directoryObject



40
41
42
# File 'lib/kozeki/config.rb', line 40

def source_directory
  @options.fetch(:source_directory)
end

#source_filesystemObject



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_pathObject



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