Module: Ognivo::Utils

Defined in:
lib/ognivo/utils.rb

Class Method Summary collapse

Class Method Details

.signature(file, dsa_file) ⇒ Object



9
10
11
12
13
14
15
# File 'lib/ognivo/utils.rb', line 9

def self.signature(file, dsa_file)
  sha_cmd = "openssl dgst -sha1 -binary < #{file}"
  sign_cmd = "openssl dgst -dss1 -sign #{dsa_file}"
  base64_cmd = 'openssl enc -base64'
  output = `#{sha_cmd} | #{sign_cmd} | #{base64_cmd}`
  output.strip
end

.update_item_for_file(file, item, dsa_file) ⇒ Object



3
4
5
6
7
# File 'lib/ognivo/utils.rb', line 3

def self.update_item_for_file(file, item, dsa_file)
  item.pub_date = File.ctime(file)
  item.length = File.size(file)
  item.dsa_signature = signature(file, dsa_file) if dsa_file
end