Class: Cloudruler::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/cloudruler/runner.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(template_file, options) ⇒ Runner

Returns a new instance of Runner.



14
15
16
17
18
# File 'lib/cloudruler/runner.rb', line 14

def initialize(template_file, options)
  @template = Template.new(self, File.expand_path(template_file))
  @rulers_root = File.expand_path(options[:rulers_root] || 'rulers', File.join(Dir.pwd))
  @rulers = []
end

Class Method Details

.dump(template_file, options = {}) ⇒ Object



7
8
9
10
11
# File 'lib/cloudruler/runner.rb', line 7

def dump(template_file, options = {})
  runner = self.new(template_file, options)
  runner.load_rulers
  runner.dump
end

Instance Method Details

#dumpObject



27
28
29
# File 'lib/cloudruler/runner.rb', line 27

def dump
  @template.resolve.dump
end

#find_ruler(name) ⇒ Object



31
32
33
34
# File 'lib/cloudruler/runner.rb', line 31

def find_ruler(name)
  name = name.to_sym
  @rulers.find { |ruler| ruler.name == name }
end

#load_rulersObject



20
21
22
23
24
25
# File 'lib/cloudruler/runner.rb', line 20

def load_rulers
  Dir.glob(File.join(@rulers_root, '*')).each do |path|
    next if Dir.exist?(path)
    @rulers << Ruler.new(path)
  end
end