Sha256: 22d722d72c6d47112bae1412d1b786d35e38be7c848d40b85f7bf48f8add9d43
Contents?: true
Size: 1.73 KB
Versions: 2
Compression:
Stored size: 1.73 KB
Contents
require 'rake_factory' require 'ruby_gpg2' module RakeGPG module Tasks module Encryption class Encrypt < RakeFactory::Task default_name :encrypt default_description "Encrypt a file using GPG" parameter :key_file_path, required: true parameter :input_file_path, required: true parameter :output_file_path, required: true parameter :work_directory, default: 'build/gpg' parameter :home_directory, default: :temporary parameter :armor, default: true parameter :trust_mode, default: :always action do |t| mkdir_p(t.work_directory) if t.home_directory == :temporary Dir.mktmpdir( 'home', t.work_directory) do |home_directory| do_encrypt(t, home_directory) end else do_encrypt(t, t.home_directory) end end private def do_encrypt(t, home_directory) puts "Encrypting #{t.input_file_path} for key #{t.key_file_path}..." result = RubyGPG2.import( key_file_paths: [t.key_file_path], work_directory: t.work_directory, home_directory: home_directory, with_status: true) key_fingerprint = result .status .filter_by_type(:import_ok) .first_line .key_fingerprint RubyGPG2.encrypt( recipient: key_fingerprint, input_file_path: t.input_file_path, output_file_path: t.output_file_path, home_directory: home_directory, armor: t.armor, trust_mode: t.trust_mode) puts "Done." end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rake_gpg-0.6.0 | lib/rake_gpg/tasks/encryption/encrypt.rb |
rake_gpg-0.5.0.pre.1 | lib/rake_gpg/tasks/encryption/encrypt.rb |