Class: FRM::Package
Instance Attribute Summary collapse
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#info ⇒ Object
readonly
Returns the value of attribute info.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(path) ⇒ Package
constructor
A new instance of Package.
- #to_h ⇒ Object
- #to_stub ⇒ Object
Methods inherited from Base
#compute_md5, #compute_sha1, #compute_sha2, #generate_gzip_pipe, #gpg_clearsign, #gpg_detached, #gpg_export_pubkey, #gunzip_pipe, #handle_errors, #run
Constructor Details
#initialize(path) ⇒ Package
Returns a new instance of Package.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/frm/package.rb', line 5 def initialize(path) @path = path raise "you need to pass a path!!!" if path.nil? raise "Can not find file: '#{path}'" unless File.exists?(path) raise "this system does not have the dpkg binary" unless system 'which dpkg > /dev/null' raise "file #{path} is not a deb" unless system "dpkg --field #{path} > /dev/null" begin @content = File.read(path) rescue Object => o STDERR.puts "Could not open file '#{path}'. Exiting..." STDERR.puts o.inspect STDERR.puts o.backtrace raise "Could not open file '#{path}'. Exiting..." end @info = get_package_info end |
Instance Attribute Details
#content ⇒ Object (readonly)
Returns the value of attribute content.
3 4 5 |
# File 'lib/frm/package.rb', line 3 def content @content end |
#info ⇒ Object (readonly)
Returns the value of attribute info.
3 4 5 |
# File 'lib/frm/package.rb', line 3 def info @info end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
3 4 5 |
# File 'lib/frm/package.rb', line 3 def path @path end |
Class Method Details
.hash_to_stub(hash) ⇒ Object
29 30 31 |
# File 'lib/frm/package.rb', line 29 def self.hash_to_stub(hash) hash.collect{|k,v| "#{k}: #{v}"}.join("\n") + "\n\n" end |
Instance Method Details
#to_h ⇒ Object
33 34 35 |
# File 'lib/frm/package.rb', line 33 def to_h return @info end |
#to_stub ⇒ Object
25 26 27 |
# File 'lib/frm/package.rb', line 25 def to_stub @info.collect{|k,v| "#{k}: #{v}"}.join("\n") + "\n\n" end |