Class: Deb
- Inherits:
-
Object
- Object
- Deb
- Defined in:
- lib/ruby-deb.rb
Constant Summary collapse
- VERSION =
"0.1"
Instance Attribute Summary collapse
-
#archive ⇒ Object
readonly
Returns the value of attribute archive.
Instance Method Summary collapse
- #control ⇒ Object
- #control_files ⇒ Object
-
#initialize(filename, options = {}) ⇒ Deb
constructor
A new instance of Deb.
-
#method_missing(m) ⇒ Object
allow to access any file in control_archive.
Constructor Details
#initialize(filename, options = {}) ⇒ Deb
Returns a new instance of Deb.
10 11 12 13 14 15 16 17 |
# File 'lib/ruby-deb.rb', line 10 def initialize(filename, = {}) @sourcefile = filename @archive = Ar.new(filename) @archive.load @control_archive = nil nil end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(m) ⇒ Object
allow to access any file in control_archive
49 50 51 52 53 54 55 56 57 |
# File 'lib/ruby-deb.rb', line 49 def method_missing(m) if @control_archive.nil? get_control_archive() end if control_files.include?(m.to_s) @control_archive[m.to_s] end end |
Instance Attribute Details
#archive ⇒ Object (readonly)
Returns the value of attribute archive.
9 10 11 |
# File 'lib/ruby-deb.rb', line 9 def archive @archive end |
Instance Method Details
#control ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/ruby-deb.rb', line 19 def control control = Hash.new if @control_archive.nil? get_control_archive() end lastfield = nil @control_archive["control"].lines.each do |l| m = l.match(/(?<field>\w+-*\w*):\ (?<value>.*)/) # standard "key: value" if m control[m["field"]] = m["value"].strip lastfield = m["field"] else # previous field was multilined, aggregate control[lastfield] += l.strip end end control end |
#control_files ⇒ Object
40 41 42 43 44 45 46 |
# File 'lib/ruby-deb.rb', line 40 def control_files if @control_archive.nil? get_control_archive() end @control_archive.keys end |