Class: Ports::Port
- Inherits:
-
Object
- Object
- Ports::Port
- Defined in:
- lib/port_upgrade/port.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
-
#portfile_path ⇒ Object
readonly
Returns the value of attribute portfile_path.
-
#versions ⇒ Object
readonly
Returns the value of attribute versions.
Instance Method Summary collapse
-
#initialize(portname) ⇒ Port
constructor
A new instance of Port.
- #installed? ⇒ Boolean
- #outdated? ⇒ Boolean
- #portfile ⇒ Object
- #receipt_path ⇒ Object
- #receipt_path=(path) ⇒ Object
Constructor Details
#initialize(portname) ⇒ Port
Returns a new instance of Port.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/port_upgrade/port.rb', line 5 def initialize(portname) tmpp = File.join(RECEIPT_PATH,portname) @name = portname @versions = [] if File.exist?(tmpp) and File.readable?(tmpp) @rp = tmpp Find.find(@rp) do |d| next unless File.directory?(d) next if d == @rp b = File.basename(d) md = /([^+]+)((\+\w+)*)/.match(b) @versions << md[1] unless md.nil? end end Dir.entries(MACPORTS_DB).each do |d| if File.directory?(File.join(MACPORTS_DB,d)) && d != '.' && d != '..' testpath = File.join(MACPORTS_DB,d,@name,'Portfile') if File.exist?(testpath) @portfile_path = testpath break end end end raise "NoSuchPort: #{@name}" if @portfile_path.nil? end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'lib/port_upgrade/port.rb', line 3 def name @name end |
#portfile_path ⇒ Object (readonly)
Returns the value of attribute portfile_path.
3 4 5 |
# File 'lib/port_upgrade/port.rb', line 3 def portfile_path @portfile_path end |
#versions ⇒ Object (readonly)
Returns the value of attribute versions.
3 4 5 |
# File 'lib/port_upgrade/port.rb', line 3 def versions @versions end |
Instance Method Details
#installed? ⇒ Boolean
32 33 34 |
# File 'lib/port_upgrade/port.rb', line 32 def installed? @rp.nil? ? false : true end |
#outdated? ⇒ Boolean
53 54 55 56 57 58 59 60 61 62 |
# File 'lib/port_upgrade/port.rb', line 53 def outdated? result = false @versions.each do |v| if Ports::Utilities.cmp_vers(v,portfile.version) < 0 result = true break end end result end |
#portfile ⇒ Object
44 45 46 47 |
# File 'lib/port_upgrade/port.rb', line 44 def portfile return nil if @portfile_path.nil? @portfile ||= Ports::Portfile.new(@portfile_path) end |
#receipt_path ⇒ Object
40 41 42 |
# File 'lib/port_upgrade/port.rb', line 40 def receipt_path @rp end |
#receipt_path=(path) ⇒ Object
36 37 38 |
# File 'lib/port_upgrade/port.rb', line 36 def receipt_path=(path) @rp = path end |