Class: Brandish::Configure::DSL

Inherits:
Object
  • Object
show all
Defined in:
lib/brandish/configure/dsl.rb,
lib/brandish/configure/dsl/form.rb

Overview

The DSL for configuration files for Brandish. This is used to construct a configure object.

Defined Under Namespace

Classes: Form

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(configure = Configure.new) ⇒ DSL

Creates a DSL object with the given configuration object.

Parameters:

  • configure (Configure) (defaults to: Configure.new)


24
25
26
# File 'lib/brandish/configure/dsl.rb', line 24

def initialize(configure = Configure.new)
  @configure = configure
end

Class Method Details

.call(configure = Configure.new) ⇒ DSL

Creates a new DSL object with the given configuration object, and yields it.

Parameters:

  • configure (Configure) (defaults to: Configure.new)

    The configuration instance.

Returns:



17
18
19
# File 'lib/brandish/configure/dsl.rb', line 17

def self.call(configure = Configure.new)
  DSL.new(configure).tap { |t| yield t }
end

Instance Method Details

#form(*arguments) {|form| ... } ⇒ void

This method returns an undefined value.

Creates a new form for the configuration object. This takes arguments and a block. The block is yielded the form instance.

Yields:

See Also:



120
121
122
123
124
125
126
# File 'lib/brandish/configure/dsl.rb', line 120

def form(*arguments)
  instance = DSL::Form.new(*arguments)
  yield instance
  form = Configure::Form.new(*instance.data)
  @configure.forms << form
  form
end

#get(name) ⇒ ::Object Also known as: []

Retrives a given option key. The name is interned, making it a symbol.

Parameters:

  • name (::Symbol, #intern)

    The name of the option key.

Returns:

  • (::Object)

    The option value.



43
44
45
# File 'lib/brandish/configure/dsl.rb', line 43

def get(name)
  @configure.options.fetch(name)
end

#output::Pathname Also known as: output_path

Retrieves the output directory of the Brandish project. This is where all of the outputs are placed. This is normally "./output".

Returns:

  • (::Pathname)

    The full path to the output.



85
86
87
# File 'lib/brandish/configure/dsl.rb', line 85

def output
  self[:output]
end

#output=(output) ⇒ void Also known as: output_path=

This method returns an undefined value.

Sets the output directory of the Brandish project. This is where all of the outputs are placed. This is normally "./output".

Parameters:

  • output (::String, ::Pathname)

    The path to the output directory.



76
77
78
79
# File 'lib/brandish/configure/dsl.rb', line 76

def output=(output)
  path = _expand_path(output, root)
  self[:output] = path
end

#root::Pathname Also known as: root_path

Retrieves the root path of the Brandish project. This is where all of the important files are located. Very rarely should this be set to anything other than ".".

Returns:

  • (::Pathname)

    The full path to the root.



64
65
66
# File 'lib/brandish/configure/dsl.rb', line 64

def root
  self[:root]
end

#root=(root) ⇒ void Also known as: root_path=

This method returns an undefined value.

Sets the root path of the Brandish project. This is where all of the important files are located. Very rarely should this be set to anything other than ".".

Parameters:

  • root (::String, ::Pathname)

    The new root.



54
55
56
57
# File 'lib/brandish/configure/dsl.rb', line 54

def root=(root)
  path = _expand_path(root, Dir.pwd)
  self[:root] = path
end

#set(name, value) ⇒ void Also known as: []=

This method returns an undefined value.

Sets a given option key to a value. The name is interned, making it a symbol.

Parameters:

  • name (::Symbol, #intern)

    The name of the option key.

  • value (::Object)

    The option value.



34
35
36
# File 'lib/brandish/configure/dsl.rb', line 34

def set(name, value)
  @configure.options[name.intern] = value
end

#sources::Pathname Also known as: source_paths

Retrives the source directories of the Brandish project. This is where all of the sources are located. This is normally "./source".

Returns:

  • (::Pathname)

    The full path to the sources.



96
97
98
# File 'lib/brandish/configure/dsl.rb', line 96

def sources
  self[:sources]
end

#templates::Pathname Also known as: template_paths

Retrieves the template directory of the Brandish project. This is where all of the templates are placed. This is normally "./template".

Returns:

  • (::Pathname)

    The full path to the template.



106
107
108
# File 'lib/brandish/configure/dsl.rb', line 106

def templates
  self[:templates]
end