sym-crypt 1.0.0 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5e828980386f173a51e6ad0c195d111c03915c34
4
- data.tar.gz: 9848959836ff2cd48bb0296623584d088e249b3e
3
+ metadata.gz: cd20f28d2e3ea08eb54871c9d25bf55a47d6b95d
4
+ data.tar.gz: 740d6d96ba353c00ff6d185ae14b55c0dfae7b69
5
5
  SHA512:
6
- metadata.gz: ba7aee05452ca1f6d0e15ec0c7dd93d2da98f0401fafd7e9b014858f4d336f06d28c99af0f633a96cd1758396c21588c5ce286ea220854675e761ebb994dcc9c
7
- data.tar.gz: ff851287744f108721acd1bd03b5fb85bdccdaabc3db9b77fd93a6cd4f22398e549d1c9daaf662b44a4aeee1c79458a64b7507be089871d3b7d39d416b044327
6
+ metadata.gz: 0b0215c403256940fcdcef2db57679aa335d7644790f9dd627e0e8cae08c04722e2ac41d6e3c0d87a863a1924321ae6b3a516d574664a0e7100510324268ea87
7
+ data.tar.gz: 680f12b2b0222029989b804c356c3529969134844b4cdd6fb39ecf16b9e31d2578c22b730dba97bcb89fa1cc21a8034e557c0fcb78502f779cc098eccfdc8e1c
@@ -0,0 +1,43 @@
1
+ require 'singleton'
2
+ module Sym
3
+ module Configurable
4
+ def self.included(base)
5
+ base.instance_eval do
6
+ include Singleton
7
+ class << self
8
+ include Sym::Configurable::ClassMethods
9
+ end
10
+ end
11
+ end
12
+
13
+ module ClassMethods
14
+ def config
15
+ instance
16
+ end
17
+
18
+ def configure
19
+ yield config if block_given?
20
+ config
21
+ end
22
+
23
+ def defaults!
24
+ [ self, *self.ancestors ].each do |klazz|
25
+ next unless klazz.is_a?(Class)
26
+ if klazz.const_defined?(:DEFAULTS)
27
+ default_proc = self.const_get(:DEFAULTS)
28
+ if default_proc.respond_to?(:call)
29
+ configure(&default_proc)
30
+ end
31
+ end
32
+ end
33
+ end
34
+
35
+ def property(prop_name)
36
+ config.send(prop_name)
37
+ end
38
+
39
+ alias_method :prop, :property
40
+ alias_method :[], :property
41
+ end
42
+ end
43
+ end
@@ -1,17 +1,12 @@
1
1
  require 'zlib'
2
2
  require 'logger'
3
3
 
4
- require 'sym/crypt/configuration'
5
4
  require 'sym/crypt/version'
6
5
  require 'sym/crypt/errors'
7
6
 
8
- Sym::Crypt::Configuration.configure do |config|
9
- config.password_cipher = 'AES-128-CBC'
10
- config.data_cipher = 'AES-256-CBC'
11
- config.private_key_cipher = config.data_cipher
12
- config.compression_enabled = true
13
- config.compression_level = Zlib::BEST_COMPRESSION
14
- end
7
+ require 'sym/crypt/configuration'
8
+
9
+ Sym::Crypt::Configuration.defaults!
15
10
 
16
11
  require 'sym/crypt/extensions/class_methods'
17
12
  require 'sym/crypt/extensions/instance_methods'
@@ -103,7 +98,14 @@ module Sym
103
98
  end
104
99
  end
105
100
 
101
+ Sym::Crypt::Configuration.configure do |config|
102
+ config.password_cipher = 'AES-128-CBC'
106
103
 
104
+ config.data_cipher = 'AES-256-CBC'
105
+ config.private_key_cipher = config.data_cipher
106
+ config.compression_enabled = true
107
+ config.compression_level = Zlib::BEST_COMPRESSION
108
+ end
107
109
 
108
110
  class Object
109
111
  unless self.methods.include?(:present?)
@@ -1,3 +1,6 @@
1
+ require 'singleton'
2
+ require 'sym/configurable'
3
+ require 'ostruct'
1
4
  module Sym
2
5
  module Crypt
3
6
  # This class encapsulates application configuration, and exports
@@ -21,24 +24,27 @@ module Sym
21
24
  # config.compression_level = Zlib::BEST_COMPRESSION
22
25
  # end
23
26
 
24
- class Configuration
25
- class << self
26
- attr_accessor :config
27
+ class Configuration < OpenStruct
27
28
 
28
- def configure
29
- self.config ||= Configuration.new
30
- yield config if block_given?
31
- end
29
+ include Sym::Configurable
32
30
 
33
- def property(name)
34
- self.config.send(name)
31
+ class << self
32
+ def defaults!
33
+ configure(&default_proc)
35
34
  end
36
- end
37
35
 
38
- # See file +lib/sym/crypt.rb+ where these values are defined.
36
+ private
39
37
 
40
- attr_accessor :data_cipher, :password_cipher, :private_key_cipher
41
- attr_accessor :compression_enabled, :compression_level
38
+ def default_proc
39
+ ->(config) do
40
+ config.password_cipher = 'AES-128-CBC'
41
+ config.data_cipher = 'AES-256-CBC'
42
+ config.private_key_cipher = config.data_cipher
43
+ config.compression_enabled = true
44
+ config.compression_level = Zlib::BEST_COMPRESSION
45
+ end
46
+ end
47
+ end
42
48
  end
43
49
  end
44
50
  end
@@ -1,6 +1,6 @@
1
1
  module Sym
2
2
  module Crypt
3
- VERSION = '1.0.0'
3
+ VERSION = '1.1.1'
4
4
  DESCRIPTION = <<-eof
5
5
  sym-crypt is a core encryption module for the symmetric encryption app
6
6
  (and a corresponding gem) "sym", and contains the main base serialization,
@@ -28,6 +28,7 @@ Gem::Specification.new do |spec|
28
28
 
29
29
  spec.add_development_dependency 'codeclimate-test-reporter', '~> 1.0'
30
30
  spec.add_development_dependency 'simplecov'
31
+ spec.add_development_dependency 'colored2'
31
32
  spec.add_development_dependency 'irbtools'
32
33
  spec.add_development_dependency 'bundler', '~> 1'
33
34
  spec.add_development_dependency 'rake'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sym-crypt
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Konstantin Gredeskoul
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-07-31 00:00:00.000000000 Z
11
+ date: 2017-10-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: codeclimate-test-reporter
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: colored2
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: irbtools
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -148,6 +162,7 @@ files:
148
162
  - Rakefile
149
163
  - bin/console
150
164
  - bin/setup
165
+ - lib/sym/configurable.rb
151
166
  - lib/sym/crypt.rb
152
167
  - lib/sym/crypt/cipher_handler.rb
153
168
  - lib/sym/crypt/configuration.rb