Class: Opulent::Settings

Inherits:
Object
  • Object
show all
Defined in:
lib/opulent/settings.rb

Constant Summary collapse

BUFFER =

Set buffer variable name

:@_opulent_buffer
FILE_EXTENSION =

Default Opulent file extension

'.op'.freeze
DEFAULT_EACH_KEY =

Default yield target which is used for child block replacements

:key
DEFAULT_EACH_VALUE =

Default yield target which is used for child block replacements

:value
SELF_ENCLOSING =

List of self enclosing node elements

[
  :img, :link, :input, :meta, :br, :hr, :area, :base, :col, :command,
  :embed, :keygen, :param, :source, :track, :wbr
].freeze
MULTI_NODE =

List of inline node parents which can be either inline or have complex structures inside of them, such as anchor tags

[:a].freeze
INLINE_NODE =

List of inline node names

[
  :text, :a, :span, :strong, :em, :br, :i, :b, :small, :label, :sub, :sup,
  :abbr, :var, :code, :kbd
].freeze
INTERPOLATION_CHECK =

Check whether text should or shouldn’t be evaluated

/(?<!\\)\#\{.*\}/
EVALUATION_CHECK =

Check if the attribute value is a bare string

/\A(("((?:[^"\\]|\\.)*?)")|('(?:[^'\\]|\\.)*?')|true|false|nil)\Z/
END_INSERTION =

Check to see if we need to insert an end block for the current evaluation control do || .* end

/\A(if|begin|unless|else|elsif|when|rescue|ensure|for|while|until)\b|\bdo\s*(\|[^\|]*\|)?\s*$/
END_REMOVAL =
/\A(else|elsif|when|rescue|ensure)/
END_EXPLICIT =
/\A(end)/
SHORTHAND =

Shorthand attribute associations

{
  :'.' => :class,
  :'#' => :id,
  :'&' => :name
}.freeze
DEFAULTS =

Opulent runtime settings

{
  indent: 2,
  layouts: false,
  pretty: false,
  default_layout: :'views/layouts/application'
}

Instance Method Summary collapse

Constructor Details

#initializeSettings

Set defaults as initial settings



62
63
64
# File 'lib/opulent/settings.rb', line 62

def initialize
  @settings = DEFAULTS.clone
end

Instance Method Details

#[](name) ⇒ Object

Get an option at runtime

Parameters:

  • name (Symbol)

    Identifier for the option



70
71
72
# File 'lib/opulent/settings.rb', line 70

def [](name)
  @settings[name]
end

#[]=(name, value) ⇒ Object

Set a new option at runtime

Parameters:

  • name (Symbol)

    Identifier for the option

  • value

    Option value to be set



79
80
81
# File 'lib/opulent/settings.rb', line 79

def []=(name, value)
  @settings[name] = value
end

#delete(name) ⇒ Object

Remove an option at runtime

Parameters:

  • name (Symbol)

    Identifier for the option

  • value

    Option value to be set



88
89
90
# File 'lib/opulent/settings.rb', line 88

def delete(name)
  @settings.delete name
end

#update_settings(opts) ⇒ Object

Update the engine settings with the required option changes

Parameters:

  • opts (Hash)

    Option extension hash



96
97
98
99
100
# File 'lib/opulent/settings.rb', line 96

def update_settings(opts)
  opts.each do |key, value|
    @settings[key] = value
  end
end