Class: Munge::Init

Inherits:
Object
  • Object
show all
Defined in:
lib/munge/init.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(root_path:, config:, setup_path:, rules_path:) ⇒ Init

Returns a new instance of Init.



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/munge/init.rb', line 3

def initialize(root_path:,
               config:,
               setup_path:,
               rules_path:)
  @root_path  = root_path
  @setup_path = setup_path
  @rules_path = rules_path
  @binding    = binding

  system = Munge::System.new(root_path, config)

  import(setup_path)

  @app = Munge::Application.new(system)

  import(rules_path)

  @app.items.each(&:freeze)
  @app.items.freeze
end

Instance Attribute Details

#appObject (readonly)

Returns the value of attribute app.



34
35
36
# File 'lib/munge/init.rb', line 34

def app
  @app
end

#root_pathObject (readonly)

Returns the value of attribute root_path.



35
36
37
# File 'lib/munge/init.rb', line 35

def root_path
  @root_path
end

Instance Method Details

#config_pathObject



24
25
26
# File 'lib/munge/init.rb', line 24

def config_path
  File.join(root_path, "config")
end

#import(file_path) ⇒ Object



28
29
30
31
32
# File 'lib/munge/init.rb', line 28

def import(file_path)
  absolute_file_path = File.expand_path(file_path, root_path)
  contents           = File.read(absolute_file_path)
  @binding.eval(contents, absolute_file_path)
end