Class: RoastBeef::Package

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

Direct Known Subclasses

BzrPackage, CvsPackage, GitPackage, SvnPackage

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#authorObject

Returns the value of attribute author.



5
6
7
# File 'lib/roastbeef/package.rb', line 5

def author
  @author
end

#buildObject

Returns the value of attribute build.



5
6
7
# File 'lib/roastbeef/package.rb', line 5

def build
  @build
end

#descriptionObject

Returns the value of attribute description.



5
6
7
# File 'lib/roastbeef/package.rb', line 5

def description
  @description
end

#nameObject

Returns the value of attribute name.



5
6
7
# File 'lib/roastbeef/package.rb', line 5

def name
  @name
end

#prereqsObject

Returns the value of attribute prereqs.



5
6
7
# File 'lib/roastbeef/package.rb', line 5

def prereqs
  @prereqs
end

#removeObject

Returns the value of attribute remove.



5
6
7
# File 'lib/roastbeef/package.rb', line 5

def remove
  @remove
end

#repositoryObject

Returns the value of attribute repository.



5
6
7
# File 'lib/roastbeef/package.rb', line 5

def repository
  @repository
end

#urlObject

Returns the value of attribute url.



5
6
7
# File 'lib/roastbeef/package.rb', line 5

def url
  @url
end

Class Method Details

.allObject



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

Returns:

  • (Boolean)


57
58
59
# File 'lib/roastbeef/package.rb', line 57

def checked_out?
  File.exist?(path)
end

#inspectObject



45
46
47
# File 'lib/roastbeef/package.rb', line 45

def inspect
  "#{name}: #{url}\n\n#{description}"
end

#installObject 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

#pathObject



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

def path
  "#{SRC_DIR}/#{name}"
end

#to_sObject



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

def to_s
  "#{name} - #{truncated_description}"
end

#truncated_descriptionObject



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

Returns:

  • (Boolean)


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

def unremovable?
  @remove.to_s == 'false'
end