strongbox 0.3.2 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/Rakefile +4 -2
  2. data/lib/strongbox.rb +1 -1
  3. data/lib/strongbox/lock.rb +11 -0
  4. metadata +22 -2
data/Rakefile CHANGED
@@ -10,7 +10,7 @@ task :default => :test
10
10
 
11
11
  desc 'Test the strongbox gem.'
12
12
  Rake::TestTask.new(:test) do |t|
13
- t.libs << 'lib' << 'profile'
13
+ t.libs << '.'
14
14
  t.pattern = 'test/**/*_test.rb'
15
15
  t.verbose = true
16
16
  end
@@ -32,7 +32,9 @@ spec = Gem::Specification.new do |s|
32
32
  s.email = "spike@stuff-things.net"
33
33
  s.homepage = "http://stuff-things.net/strongbox"
34
34
  s.files = FileList["[A-Z]*", "init.rb", "{lib,rails}/**/*"]
35
+ s.add_runtime_dependency 'active_record'
35
36
  s.add_development_dependency 'thoughtbot-shoulda'
37
+ s.add_development_dependency 'sqlite3'
36
38
  end
37
39
 
38
40
  desc "Generate a gemspec file for GitHub"
@@ -40,4 +42,4 @@ task :gemspec do
40
42
  File.open("#{spec.name}.gemspec", 'w') do |f|
41
43
  f.write spec.to_yaml
42
44
  end
43
- end
45
+ end
data/lib/strongbox.rb CHANGED
@@ -5,7 +5,7 @@ require 'strongbox/lock'
5
5
 
6
6
  module Strongbox
7
7
 
8
- VERSION = "0.3.2"
8
+ VERSION = "0.4.0"
9
9
 
10
10
  RSA_PKCS1_PADDING = OpenSSL::PKey::RSA::PKCS1_PADDING
11
11
  RSA_SSLV23_PADDING = OpenSSL::PKey::RSA::SSLV23_PADDING
@@ -23,6 +23,7 @@ module Strongbox
23
23
  end
24
24
 
25
25
  def encrypt plaintext
26
+ ensure_required_columns
26
27
  unless @public_key
27
28
  raise StrongboxError.new("#{@instance.class} model does not have public key_file")
28
29
  end
@@ -111,6 +112,16 @@ module Strongbox
111
112
  @size
112
113
  end
113
114
 
115
+ def ensure_required_columns
116
+ columns = [@name.to_s]
117
+ columns += [@symmetric_key, @symmetric_iv] if @symmetric == :always
118
+ columns.each do |column|
119
+ unless @instance.class.column_names.include? column
120
+ raise StrongboxError.new("#{@instance.class} model does not have database column \"#{column}\"")
121
+ end
122
+ end
123
+ end
124
+
114
125
  private
115
126
  def get_rsa_key(key,password = '')
116
127
  return key if key.is_a?(OpenSSL::PKey::RSA)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: strongbox
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Spike Ilacqua
@@ -9,9 +9,19 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-06-08 00:00:00 -06:00
12
+ date: 2010-10-07 00:00:00 -06:00
13
13
  default_executable:
14
14
  dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: active_record
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: "0"
24
+ version:
15
25
  - !ruby/object:Gem::Dependency
16
26
  name: thoughtbot-shoulda
17
27
  type: :development
@@ -22,6 +32,16 @@ dependencies:
22
32
  - !ruby/object:Gem::Version
23
33
  version: "0"
24
34
  version:
35
+ - !ruby/object:Gem::Dependency
36
+ name: sqlite3
37
+ type: :development
38
+ version_requirement:
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: "0"
44
+ version:
25
45
  description:
26
46
  email: spike@stuff-things.net
27
47
  executables: []