Class: LibrarianChefDSLParser

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cheffile, &data) ⇒ LibrarianChefDSLParser

Returns a new instance of LibrarianChefDSLParser.



7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/librarian_chef_dsl_parser.rb', line 7

def initialize(cheffile, &data)
  @cheffile = cheffile
  @cookbooks = []
  data = false

  uri = URI.parse(cheffile)
  if %w( http https ).include?(uri.scheme)
    data = Net::HTTP.get(uri)
  else
    data = File.read(cheffile)
  end
  instance_eval data
end

Instance Attribute Details

#cookbooksObject

Returns the value of attribute cookbooks.



5
6
7
# File 'lib/librarian_chef_dsl_parser.rb', line 5

def cookbooks
  @cookbooks
end

#site(*val) ⇒ Object

Returns the value of attribute site.



5
6
7
# File 'lib/librarian_chef_dsl_parser.rb', line 5

def site
  @site
end

Instance Method Details

#cheffileObject



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

def cheffile
  @cheffile
end

#cookbook(name, options) ⇒ Object



29
30
31
32
# File 'lib/librarian_chef_dsl_parser.rb', line 29

def cookbook(name, options)
  cookbook = { "name" => name, "options" => options }
  @cookbooks.push(cookbook)
end