Class: Vam::Dsl

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeDsl

Returns a new instance of Dsl.



16
17
18
# File 'lib/vam/dsl.rb', line 16

def initialize
  @vams = []
end

Instance Attribute Details

#repoObject (readonly)

Returns the value of attribute repo.



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

def repo
  @repo
end

#vamsObject (readonly)

Returns the value of attribute vams.



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

def vams
  @vams
end

Class Method Details

.evaluate(vamfile) ⇒ Object



9
10
11
12
13
# File 'lib/vam/dsl.rb', line 9

def self.evaluate(vamfile)
  dsl = new()
  dsl.eval_vamfile(vamfile)
  return dsl
end

Instance Method Details

#eval_vamfile(vamfile, contents = nil) ⇒ Object



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

def eval_vamfile(vamfile, contents = nil)
  contents ||= File.read(vamfile)
  instance_eval(contents, vamfile.to_s, 1)
end

#source(url) ⇒ Object



44
45
46
47
# File 'lib/vam/dsl.rb', line 44

def source(url)
  @source = url
  @repo = Repo.load url
end

#vam(name, *args) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/vam/dsl.rb', line 27

def vam(name, *args)
  options = args.last.is_a?(Hash) ? args.last.dup : {}

  if args.first.is_a?(String)
    options[:version] = args.first
  end

  begin
    vam = Vam.new name, self, options
    @vams << vam
  rescue MissingComponentError => e
    puts e.message.colorize(:red)
  end

end