Class: Raz::ConfigFile

Inherits:
Object
  • Object
show all
Defined in:
lib/raz/config_file.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path = nil, &block) ⇒ ConfigFile

Returns a new instance of ConfigFile.

Parameters:

  • path (String) (defaults to: nil)

    path to configuration file



26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/raz/config_file.rb', line 26

def initialize(path = nil, &block)
  @path = path
  @items = []
  @ignored_paths = []
  @procs = {}

  if block_given?
    instance_eval(&block)
  else
    instance_eval(File.read(path), path)
  end
end

Instance Attribute Details

#ignored_pathsArray<String> (readonly)

Returns:

  • (Array<String>)


18
19
20
# File 'lib/raz/config_file.rb', line 18

def ignored_paths
  @ignored_paths
end

#itemsArray<Raz::Items::Group> (readonly)

Returns:



14
15
16
# File 'lib/raz/config_file.rb', line 14

def items
  @items
end

#pathString (readonly)

Returns:

  • (String)


10
11
12
# File 'lib/raz/config_file.rb', line 10

def path
  @path
end

#procsHash<Symbol, Array<Proc>> (readonly)

Returns:

  • (Hash<Symbol, Array<Proc>>)


22
23
24
# File 'lib/raz/config_file.rb', line 22

def procs
  @procs
end

Instance Method Details

#after_backup(&block) ⇒ Object



59
60
61
62
# File 'lib/raz/config_file.rb', line 59

def after_backup(&block)
  @procs[:after_backup] ||= []
  @procs[:after_backup] << block
end

#after_restore(&block) ⇒ Object



69
70
71
72
# File 'lib/raz/config_file.rb', line 69

def after_restore(&block)
  @procs[:after_restore] ||= []
  @procs[:after_restore] << block
end

#app(name, &block) ⇒ Object



45
46
47
# File 'lib/raz/config_file.rb', line 45

def app(name, &block)
  @items << Raz::Items::Application.new(name, &block)
end

#before_backup(&block) ⇒ Object



54
55
56
57
# File 'lib/raz/config_file.rb', line 54

def before_backup(&block)
  @procs[:before_backup] ||= []
  @procs[:before_backup] << block
end

#before_restore(&block) ⇒ Object



64
65
66
67
# File 'lib/raz/config_file.rb', line 64

def before_restore(&block)
  @procs[:before_restore] ||= []
  @procs[:before_restore] << block
end

#group(name, &block) ⇒ Object

API



41
42
43
# File 'lib/raz/config_file.rb', line 41

def group(name, &block)
  @items << Raz::Items::Group.new(name, &block)
end

#ignore_path(path) ⇒ Object



49
50
51
# File 'lib/raz/config_file.rb', line 49

def ignore_path(path)
  @ignored_paths << path
end