Class: Ablerc::DSL

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

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *args, &block) ⇒ Object



54
55
56
# File 'lib/ablerc/dsl.rb', line 54

def method_missing(method_name, *args, &block)
  raise "You tried to call the method #{method_name}. There is no such method."
end

Instance Method Details

#context(name, options) ⇒ Object



40
41
42
# File 'lib/ablerc/dsl.rb', line 40

def context(name, options)
  Ablerc::Context.new(name, options)
end

#option(name, behaviors = {}, &block) ⇒ Object

Describe the options available

Parameters

  • name - A valid name for the option

  • behaviors - Behaviors used to for this option

  • block - A proc that should be run against the option value.

Options

  • allow - The option value must be in this list

  • boolean - The option will accept true, false, 0, 1



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

def option(name, behaviors = {}, &block)
  Ablerc.options << Ablerc::Option.new(name, behaviors, &block)
end

#rc_file_name(file_name) ⇒ Object

The name of the file to be used for the configuration of this app Include a dot if you expect hidden file behavior.



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

def rc_file_name(file_name)
  Ablerc.rc_file_name = file_name
end

#respond_to?(*args) ⇒ Boolean

Returns:

  • (Boolean)


59
# File 'lib/ablerc/dsl.rb', line 59

def respond_to? *args; super; end

#scheme(*contexts) ⇒ Object

Describes the order in which configuration files are loaded. Default is :global, :user, :local which will search for rc_file_name in these directories:

 /etc/.ablerc
 ~/.ablerc
./.ablerc

Configuration options cascade and override previously loaded options. scheme :global, :user, :local



21
22
23
# File 'lib/ablerc/dsl.rb', line 21

def scheme(*contexts)
  Ablerc.scheme = contexts
end

#stub(options) ⇒ Object

Configures stub options for #generate

Options

  • header - Text to be included at the beginning of the rc file

  • footer - Text to be included at the end of the rc file



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

def stub(options)
 Ablerc.stub_options = options
end