dragonfly-openssl 1.0.2 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -5,7 +5,7 @@ module Dragonfly
5
5
  def self.apply_configuration(app, opts = {})
6
6
  app.configure do |c|
7
7
  c.encoder.register(Encoder) do |e|
8
- e.keyfile_path = opts[:keyfile_path] if opts.has_key?(:keyfile_path)
8
+ e.key = opts[:key] if opts.has_key?(:key)
9
9
  end
10
10
 
11
11
  c.job :encrypt do |options|
@@ -2,25 +2,25 @@ module Dragonfly
2
2
  module OpenSSL
3
3
  class Encoder
4
4
  include ::Dragonfly::Configurable
5
- configurable_attr :keyfile_path, nil
5
+ configurable_attr :key, nil
6
6
 
7
7
  def encode(temp_object, format, options = {})
8
8
  throw :unable_to_handle unless [:encrypt, :decrypt].include?(format)
9
- throw :unable_to_handle if keyfile_path.nil?
9
+ throw :unable_to_handle unless key
10
10
 
11
11
  options[:meta] ||= {}
12
12
 
13
13
  original_filename = temp_object.original_filename
14
14
 
15
- tempfile = Tempfile.new(original_filename)
16
- tempfile.binmode
17
- tempfile.close
15
+ temp_file = Tempfile.new(original_filename)
16
+ temp_file.binmode
17
+ temp_file.close
18
18
 
19
19
  dec = (format == :decrypt) ? '-d ' : ''
20
20
 
21
- %x{openssl enc -aes-256-cbc #{dec} -in "#{temp_object.path}" -out "#{tempfile.path}" -k "#{keyfile_path}"}
21
+ %x{openssl enc -aes-256-cbc #{dec} -in "#{temp_object.path}" -out "#{temp_file.path}" -pass pass:"#{key}"}
22
22
 
23
- content = ::Dragonfly::TempObject.new(File.new(tempfile.path))
23
+ content = ::Dragonfly::TempObject.new(File.new(temp_file.path))
24
24
  meta = {
25
25
  name: original_filename,
26
26
  encrypted: (format != :decrypt)
@@ -1,5 +1,5 @@
1
1
  module Dragonfly
2
2
  module OpenSSL
3
- VERSION = "1.0.2"
3
+ VERSION = "1.0.3"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dragonfly-openssl
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: