Class: Orca::Package

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Package

Returns a new instance of Package.



4
5
6
7
8
9
10
11
# File 'lib/orca/package.rb', line 4

def initialize(name)
  @name = name
  @dependancies = []
  @children = []
  @actions = {}
  @commands = {}
  @remove = nil
end

Instance Attribute Details

#actionsObject (readonly)

Returns the value of attribute actions.



2
3
4
# File 'lib/orca/package.rb', line 2

def actions
  @actions
end

#childrenObject (readonly)

Returns the value of attribute children.



2
3
4
# File 'lib/orca/package.rb', line 2

def children
  @children
end

#dependanciesObject (readonly)

Returns the value of attribute dependancies.



2
3
4
# File 'lib/orca/package.rb', line 2

def dependancies
  @dependancies
end

#nameObject (readonly)

Returns the value of attribute name.



2
3
4
# File 'lib/orca/package.rb', line 2

def name
  @name
end

Instance Method Details

#action(name, &definition) ⇒ Object



37
38
39
# File 'lib/orca/package.rb', line 37

def action(name, &definition)
  @actions[name] = definition
end

#apply(&definition) ⇒ Object



29
30
31
# File 'lib/orca/package.rb', line 29

def apply(&definition)
  command(:apply, &definition)
end

#command(name, &definition) ⇒ Object



41
42
43
44
45
46
47
# File 'lib/orca/package.rb', line 41

def command(name, &definition)
  if block_given?
    (@commands[name.to_sym] ||= []) << definition
  else
    @commands[name.to_sym]
  end
end

#depends_on(*pkg_names) ⇒ Object



13
14
15
16
17
# File 'lib/orca/package.rb', line 13

def depends_on(*pkg_names)
  pkg_names.each do |pkg_name|
    @dependancies << pkg_name
  end
end

#provides_command?(name) ⇒ Boolean

Returns:

  • (Boolean)


49
50
51
# File 'lib/orca/package.rb', line 49

def provides_command?(name)
  @commands.has_key?(name.to_sym)
end

#remove(&definition) ⇒ Object



33
34
35
# File 'lib/orca/package.rb', line 33

def remove(&definition)
  command(:remove, &definition)
end

#to_sObject



53
54
55
# File 'lib/orca/package.rb', line 53

def to_s
  self.name
end

#triggers(*pkg_names) ⇒ Object



19
20
21
22
23
# File 'lib/orca/package.rb', line 19

def triggers(*pkg_names)
  pkg_names.each do |pkg_name|
    @children << pkg_name
  end
end

#validate(&definition) ⇒ Object



25
26
27
# File 'lib/orca/package.rb', line 25

def validate(&definition)
  command(:validate, &definition)
end