Class: Orca::Package
- Inherits:
-
Object
- Object
- Orca::Package
- Defined in:
- lib/orca/package.rb
Instance Attribute Summary collapse
-
#actions ⇒ Object
readonly
Returns the value of attribute actions.
-
#children ⇒ Object
readonly
Returns the value of attribute children.
-
#dependancies ⇒ Object
readonly
Returns the value of attribute dependancies.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #action(name, &definition) ⇒ Object
- #apply(&definition) ⇒ Object
- #command(name, &definition) ⇒ Object
- #depends_on(*pkg_names) ⇒ Object
-
#initialize(name) ⇒ Package
constructor
A new instance of Package.
- #provides_command?(name) ⇒ Boolean
- #remove(&definition) ⇒ Object
- #to_s ⇒ Object
- #triggers(*pkg_names) ⇒ Object
- #validate(&definition) ⇒ Object
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
#actions ⇒ Object (readonly)
Returns the value of attribute actions.
2 3 4 |
# File 'lib/orca/package.rb', line 2 def actions @actions end |
#children ⇒ Object (readonly)
Returns the value of attribute children.
2 3 4 |
# File 'lib/orca/package.rb', line 2 def children @children end |
#dependancies ⇒ Object (readonly)
Returns the value of attribute dependancies.
2 3 4 |
# File 'lib/orca/package.rb', line 2 def dependancies @dependancies end |
#name ⇒ Object (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
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_s ⇒ Object
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 |