Class: Gondler::Gomfile

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

Defined Under Namespace

Classes: NotFound

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ Gomfile

Returns a new instance of Gomfile.

Raises:



5
6
7
8
9
10
# File 'lib/gondler/gomfile.rb', line 5

def initialize(path)
  raise NotFound, path unless File.exist?(path)
  @packages = []

  load(path)
end

Instance Attribute Details

#packagesObject (readonly)

Returns the value of attribute packages.



11
12
13
# File 'lib/gondler/gomfile.rb', line 11

def packages
  @packages
end

Instance Method Details

#gom(name, options = {}) ⇒ Object Also known as: package



17
18
19
20
21
22
23
# File 'lib/gondler/gomfile.rb', line 17

def gom(name, options = {})
  options[:group] = @now_group if @now_group
  options[:os] = @now_os if @now_os

  package = Gondler::Package.new(name, options)
  @packages.push(package) if package.installable?
end

#group(*groups) ⇒ Object



26
27
28
29
30
31
# File 'lib/gondler/gomfile.rb', line 26

def group(*groups)
  @now_group = groups
  yield if block_given?
ensure
  @now_group = nil
end

#load(path) ⇒ Object



13
14
15
# File 'lib/gondler/gomfile.rb', line 13

def load(path)
  instance_eval(File.read(path))
end

#os(*oss) ⇒ Object



33
34
35
36
37
38
# File 'lib/gondler/gomfile.rb', line 33

def os(*oss)
  @now_os = oss
  yield if block_given?
ensure
  @now_os = nil
end