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.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Instance Method Summary collapse
- #action(name, &definition) ⇒ Object
- #apply(&definition) ⇒ Object
- #as(user) ⇒ 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 12 |
# File 'lib/orca/package.rb', line 4 def initialize(name) @name = name @user = nil @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 |
#user ⇒ Object (readonly)
Returns the value of attribute user.
2 3 4 |
# File 'lib/orca/package.rb', line 2 def user @user end |
Instance Method Details
#action(name, &definition) ⇒ Object
42 43 44 |
# File 'lib/orca/package.rb', line 42 def action(name, &definition) @actions[name] = definition end |
#apply(&definition) ⇒ Object
30 31 32 |
# File 'lib/orca/package.rb', line 30 def apply(&definition) command(:apply, &definition) end |
#as(user) ⇒ Object
38 39 40 |
# File 'lib/orca/package.rb', line 38 def as(user) @user = user end |
#command(name, &definition) ⇒ Object
46 47 48 49 50 51 52 |
# File 'lib/orca/package.rb', line 46 def command(name, &definition) if block_given? (@commands[name.to_sym] ||= []) << definition else @commands[name.to_sym] end end |
#depends_on(*pkg_names) ⇒ Object
14 15 16 17 18 |
# File 'lib/orca/package.rb', line 14 def depends_on(*pkg_names) pkg_names.each do |pkg_name| @dependancies << pkg_name end end |
#provides_command?(name) ⇒ Boolean
54 55 56 |
# File 'lib/orca/package.rb', line 54 def provides_command?(name) @commands.has_key?(name.to_sym) end |
#remove(&definition) ⇒ Object
34 35 36 |
# File 'lib/orca/package.rb', line 34 def remove(&definition) command(:remove, &definition) end |
#to_s ⇒ Object
58 59 60 |
# File 'lib/orca/package.rb', line 58 def to_s self.name end |
#triggers(*pkg_names) ⇒ Object
20 21 22 23 24 |
# File 'lib/orca/package.rb', line 20 def triggers(*pkg_names) pkg_names.each do |pkg_name| @children << pkg_name end end |
#validate(&definition) ⇒ Object
26 27 28 |
# File 'lib/orca/package.rb', line 26 def validate(&definition) command(:validate, &definition) end |