Class: Debeasy::Package
- Inherits:
-
Object
- Object
- Debeasy::Package
- Defined in:
- lib/debeasy/package.rb
Instance Attribute Summary collapse
-
#control_file_contents ⇒ Object
readonly
Returns the value of attribute control_file_contents.
-
#filelist ⇒ Object
readonly
Returns the value of attribute filelist.
-
#package_file ⇒ Object
readonly
Returns the value of attribute package_file.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#postinst_contents ⇒ Object
readonly
Returns the value of attribute postinst_contents.
-
#postrm_contents ⇒ Object
readonly
Returns the value of attribute postrm_contents.
-
#preinst_contents ⇒ Object
readonly
Returns the value of attribute preinst_contents.
-
#prerm_contents ⇒ Object
readonly
Returns the value of attribute prerm_contents.
Instance Method Summary collapse
-
#[](field) ⇒ Object
Utility method to get the field in a hash-like way.
-
#fields ⇒ Object
Lists all the available fields on the package.
-
#initialize(path) ⇒ Package
constructor
Create a new Debeasy::Package object.
- #method_missing(m, *args, &block) ⇒ Object
-
#to_hash ⇒ Object
Get package metadata as a hash.
Constructor Details
#initialize(path) ⇒ Package
Create a new Debeasy::Package object.
Arguments:
path: (String)
21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/debeasy/package.rb', line 21 def initialize(path) @path = path raise NotAPackageError, "#{path} is not a Debian package" unless is_package_file? @package_file = Archive.read_open_filename(path) @fields = {} @filelist = [] extract_files parse_control_file generate_checksums get_size get_filename end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(m, *args, &block) ⇒ Object
46 47 48 |
# File 'lib/debeasy/package.rb', line 46 def method_missing(m, *args, &block) @fields.has_key?(m.to_s) ? @fields[m.to_s] : nil end |
Instance Attribute Details
#control_file_contents ⇒ Object (readonly)
Returns the value of attribute control_file_contents.
12 13 14 |
# File 'lib/debeasy/package.rb', line 12 def control_file_contents @control_file_contents end |
#filelist ⇒ Object (readonly)
Returns the value of attribute filelist.
12 13 14 |
# File 'lib/debeasy/package.rb', line 12 def filelist @filelist end |
#package_file ⇒ Object (readonly)
Returns the value of attribute package_file.
11 12 13 |
# File 'lib/debeasy/package.rb', line 11 def package_file @package_file end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
11 12 13 |
# File 'lib/debeasy/package.rb', line 11 def path @path end |
#postinst_contents ⇒ Object (readonly)
Returns the value of attribute postinst_contents.
14 15 16 |
# File 'lib/debeasy/package.rb', line 14 def postinst_contents @postinst_contents end |
#postrm_contents ⇒ Object (readonly)
Returns the value of attribute postrm_contents.
14 15 16 |
# File 'lib/debeasy/package.rb', line 14 def postrm_contents @postrm_contents end |
#preinst_contents ⇒ Object (readonly)
Returns the value of attribute preinst_contents.
13 14 15 |
# File 'lib/debeasy/package.rb', line 13 def preinst_contents @preinst_contents end |
#prerm_contents ⇒ Object (readonly)
Returns the value of attribute prerm_contents.
13 14 15 |
# File 'lib/debeasy/package.rb', line 13 def prerm_contents @prerm_contents end |
Instance Method Details
#[](field) ⇒ Object
Utility method to get the field in a hash-like way.
52 53 54 |
# File 'lib/debeasy/package.rb', line 52 def [](field) @fields.has_key?(field.to_s) ? @fields[field.to_s] : nil end |
#fields ⇒ Object
Lists all the available fields on the package.
36 37 38 |
# File 'lib/debeasy/package.rb', line 36 def fields @fields.keys end |
#to_hash ⇒ Object
Get package metadata as a hash.
42 43 44 |
# File 'lib/debeasy/package.rb', line 42 def to_hash @fields end |