Class: RoastBeef::Package
- Inherits:
-
Object
- Object
- RoastBeef::Package
- Defined in:
- lib/roastbeef/package.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#author ⇒ Object
Returns the value of attribute author.
-
#build ⇒ Object
Returns the value of attribute build.
-
#description ⇒ Object
Returns the value of attribute description.
-
#name ⇒ Object
Returns the value of attribute name.
-
#prereqs ⇒ Object
Returns the value of attribute prereqs.
-
#remove ⇒ Object
Returns the value of attribute remove.
-
#repository ⇒ Object
Returns the value of attribute repository.
-
#url ⇒ Object
Returns the value of attribute url.
Class Method Summary collapse
Instance Method Summary collapse
- #checked_out? ⇒ Boolean
-
#initialize(name, metadata) ⇒ Package
constructor
A new instance of Package.
- #inspect ⇒ Object
- #install ⇒ Object (also: #upgrade)
- #path ⇒ Object
- #to_s ⇒ Object
- #truncated_description ⇒ Object
- #unremovable? ⇒ Boolean
Constructor Details
#initialize(name, metadata) ⇒ Package
Returns a new instance of Package.
8 9 10 11 12 |
# File 'lib/roastbeef/package.rb', line 8 def initialize(name, ) .each{|k, v| send(k+'=', v) unless k == 'scm' } @build ||= ['./configure', 'make', 'sudo make install'] self.name = name end |
Instance Attribute Details
#author ⇒ Object
Returns the value of attribute author.
5 6 7 |
# File 'lib/roastbeef/package.rb', line 5 def @author end |
#build ⇒ Object
Returns the value of attribute build.
5 6 7 |
# File 'lib/roastbeef/package.rb', line 5 def build @build end |
#description ⇒ Object
Returns the value of attribute description.
5 6 7 |
# File 'lib/roastbeef/package.rb', line 5 def description @description end |
#name ⇒ Object
Returns the value of attribute name.
5 6 7 |
# File 'lib/roastbeef/package.rb', line 5 def name @name end |
#prereqs ⇒ Object
Returns the value of attribute prereqs.
5 6 7 |
# File 'lib/roastbeef/package.rb', line 5 def prereqs @prereqs end |
#remove ⇒ Object
Returns the value of attribute remove.
5 6 7 |
# File 'lib/roastbeef/package.rb', line 5 def remove @remove end |
#repository ⇒ Object
Returns the value of attribute repository.
5 6 7 |
# File 'lib/roastbeef/package.rb', line 5 def repository @repository end |
#url ⇒ Object
Returns the value of attribute url.
5 6 7 |
# File 'lib/roastbeef/package.rb', line 5 def url @url end |
Class Method Details
.all ⇒ Object
66 67 68 |
# File 'lib/roastbeef/package.rb', line 66 def self.all RoastBeef.listing.keys.map{ |name| find name } end |
.find(name, metadata = ) ⇒ Object
61 62 63 64 |
# File 'lib/roastbeef/package.rb', line 61 def self.find(name, = RoastBeef.listing[name]) require "scms/#{['scm']}_package" PACKAGE_TYPES[['scm']].new(name, ) end |
Instance Method Details
#checked_out? ⇒ Boolean
57 58 59 |
# File 'lib/roastbeef/package.rb', line 57 def checked_out? File.exist?(path) end |
#inspect ⇒ Object
45 46 47 |
# File 'lib/roastbeef/package.rb', line 45 def inspect "#{name}: #{url}\n\n#{description}" end |
#install ⇒ Object Also known as: upgrade
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/roastbeef/package.rb', line 14 def install PackageManager.install_dependencies(@prereqs) if prereqs checked_out? ? update : checkout puts("whoa hang on this package can not be automatically removed once it is installed. if you are all right with that press enter but otherwise you should do control-c to cancel.") || STDIN.gets if unremovable? # TODO: support custom configure flags system((["cd #{path}"] + build).join(' && ')) end |
#path ⇒ Object
49 50 51 |
# File 'lib/roastbeef/package.rb', line 49 def path "#{SRC_DIR}/#{name}" end |
#to_s ⇒ Object
37 38 39 |
# File 'lib/roastbeef/package.rb', line 37 def to_s "#{name} - #{truncated_description}" end |
#truncated_description ⇒ Object
41 42 43 |
# File 'lib/roastbeef/package.rb', line 41 def truncated_description description.length > 72 ? description[0 .. 72].split(' ')[0 .. -2].join(' ') + '...' : description end |
#unremovable? ⇒ Boolean
53 54 55 |
# File 'lib/roastbeef/package.rb', line 53 def unremovable? @remove.to_s == 'false' end |