Class: FRM::Package

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#compute_md5, #compute_sha1, #compute_sha2, #generate_gzip_pipe, #gpg_clearsign, #gpg_detached, #gunzip_pipe, #merge_package_file, #parse_package_stub

Constructor Details

#initialize(path, release = 'natty') ⇒ 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
# File 'lib/frm/package.rb', line 5

def initialize(path,release='natty')
  raise "you need to specify a path!!!" if path.nil?
  @path = path
  raise "Can not find file '#{path}'" unless File.exists?(path)
  @release = release
  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
  @size = File.size(@path)
  @md5 = compute_md5(@content)
  @sha1 = compute_sha1(@content)
  @sha2 = compute_sha2(@content)
end

Instance Attribute Details

#contentObject (readonly)

Returns the value of attribute content.



4
5
6
# File 'lib/frm/package.rb', line 4

def content
  @content
end

#md5Object (readonly)

Returns the value of attribute md5.



4
5
6
# File 'lib/frm/package.rb', line 4

def md5
  @md5
end

#pathObject (readonly)

Returns the value of attribute path.



4
5
6
# File 'lib/frm/package.rb', line 4

def path
  @path
end

#releaseObject (readonly)

Returns the value of attribute release.



4
5
6
# File 'lib/frm/package.rb', line 4

def release
  @release
end

#repo_filenameObject

Returns the value of attribute repo_filename.



3
4
5
# File 'lib/frm/package.rb', line 3

def repo_filename
  @repo_filename
end

#sha1Object (readonly)

Returns the value of attribute sha1.



4
5
6
# File 'lib/frm/package.rb', line 4

def sha1
  @sha1
end

#sha2Object (readonly)

Returns the value of attribute sha2.



4
5
6
# File 'lib/frm/package.rb', line 4

def sha2
  @sha2
end

#sizeObject (readonly)

Returns the value of attribute size.



4
5
6
# File 'lib/frm/package.rb', line 4

def size
  @size
end