Class: FRM::Base
- Inherits:
-
Object
show all
- Defined in:
- lib/frm/base.rb
Instance Method Summary
collapse
Instance Method Details
#compute_md5(string) ⇒ Object
4
5
6
|
# File 'lib/frm/base.rb', line 4
def compute_md5(string)
Digest::MD5.hexdigest(string)
end
|
#compute_sha1(string) ⇒ Object
8
9
10
|
# File 'lib/frm/base.rb', line 8
def compute_sha1(string)
Digest::SHA1.hexdigest(string)
end
|
#compute_sha2(string) ⇒ Object
12
13
14
|
# File 'lib/frm/base.rb', line 12
def compute_sha2(string)
Digest::SHA2.hexdigest(string)
end
|
#generate_gzip_pipe(contents) ⇒ Object
29
30
31
32
33
34
35
36
|
# File 'lib/frm/base.rb', line 29
def generate_gzip_pipe(contents)
read_buffer, write_buffer = IO.pipe
gzip_writer = Zlib::GzipWriter.new write_buffer
gzip_writer.mtime = 1 gzip_writer.write contents
gzip_writer.close
read_buffer
end
|
#gpg_clearsign(message) ⇒ Object
TODO: there has to be a better way to use gpg withen ruby. found many broken solutions :\
19
20
21
|
# File 'lib/frm/base.rb', line 19
def gpg_clearsign(message)
`echo "#{message}" | gpg --clearsign`
end
|
#gpg_detached(message) ⇒ Object
24
25
26
|
# File 'lib/frm/base.rb', line 24
def gpg_detached(message)
`echo "#{message}" | gpg -abs`
end
|
#gunzip_pipe(gziped_pipe) ⇒ Object
38
39
40
41
42
43
|
# File 'lib/frm/base.rb', line 38
def gunzip_pipe(gziped_pipe)
gzip_reader = Zlib::GzipReader.new gziped_pipe
unzipped_string = gzip_reader.read
gzip_reader.close
return unzipped_string
end
|
#merge_package_file(in_pipe, out_pipe, package_list) ⇒ Object
67
68
69
70
|
# File 'lib/frm/base.rb', line 67
def merge_package_file(in_pipe,out_pipe,package_list)
sorted_list = package_list.sort { |a,b| a['Package'] <=> b['Package'] }
merge(in_pipe,out_pipe,sorted_list)
end
|
#parse_package_stub(read_buffer) ⇒ Object
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
# File 'lib/frm/base.rb', line 45
def parse_package_stub(read_buffer)
package = {}
stub = ""
while line = read_buffer.gets
return nil if line.strip.empty?
raise "bad input" unless (match = line.match /^\w+\-?\w+?: /)
stub << line
key = match[0].delete ': ' value = match.post_match.strip
package[key] = value
if key == 'Description'
while (line = read_buffer.gets).strip != ""
package['Description'] << line
stub << line
end
package['Description'].rstrip!
return package, stub
end
end
nil
end
|