Class: Kozeki::Dsl

Inherits:
Object
  • Object
show all
Defined in:
lib/kozeki/dsl.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Dsl

Returns a new instance of Dsl.



3
4
5
# File 'lib/kozeki/dsl.rb', line 3

def initialize(options)
  @options = options
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



7
8
9
# File 'lib/kozeki/dsl.rb', line 7

def options
  @options
end

Class Method Details

.eval(options: {}, &block) ⇒ Object



16
17
18
19
20
21
# File 'lib/kozeki/dsl.rb', line 16

def self.eval(options: {}, &block)
  d = self.new(options)
  d.base_directory('.')
  d.instance_eval(&block)
  d
end

.load_file(path, options: {}) ⇒ Object



9
10
11
12
13
14
# File 'lib/kozeki/dsl.rb', line 9

def self.load_file(path, options: {})
  d = self.new(options)
  d.base_directory(File.dirname(path))
  d.instance_eval(File.read(path), path, 1)
  d
end

Instance Method Details

#base_directory(path) ⇒ Object



23
24
25
# File 'lib/kozeki/dsl.rb', line 23

def base_directory(path)
  @options[:base_directory] = path
end

#cache_directory(path) ⇒ Object



35
36
37
# File 'lib/kozeki/dsl.rb', line 35

def cache_directory(path)
  @options[:cache_directory] = path
end

#collection_list_included_prefix(*prefixes) ⇒ Object



39
40
41
# File 'lib/kozeki/dsl.rb', line 39

def collection_list_included_prefix(*prefixes)
  (@options[:collection_list_included_prefix] ||= []).concat prefixes.flatten.map(&:to_s)
end

#collection_options(prefix:, **options) ⇒ Object



43
44
45
46
47
# File 'lib/kozeki/dsl.rb', line 43

def collection_options(prefix:, **options)
  @options[:collection_options] ||= []
  # FIXME: recursive dependency :<
  @options[:collection_options].push(Config::CollectionOptions.new(prefix:, **options))
end

#destination_directory(path) ⇒ Object



31
32
33
# File 'lib/kozeki/dsl.rb', line 31

def destination_directory(path)
  @options[:destination_directory] = path
end

#destination_filesystem(x) ⇒ Object



57
58
59
# File 'lib/kozeki/dsl.rb', line 57

def destination_filesystem(x)
  @options[:destination_filesystem] = x
end

#metadata_decorator(&block) ⇒ Object



49
50
51
# File 'lib/kozeki/dsl.rb', line 49

def (&block)
  (@options[:metadata_decorators] ||= []).push(block)
end

#on_after_build(&block) ⇒ Object



61
62
63
# File 'lib/kozeki/dsl.rb', line 61

def on_after_build(&block)
  (@options[:after_build_callbacks] ||= []).push(block)
end

#source_directory(path) ⇒ Object



27
28
29
# File 'lib/kozeki/dsl.rb', line 27

def source_directory(path)
  @options[:source_directory] = path
end

#source_filesystem(x) ⇒ Object



53
54
55
# File 'lib/kozeki/dsl.rb', line 53

def source_filesystem(x)
  @options[:source_filesystem] = x
end