hashed_attr 0.1.0 → 0.2.0

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: 6ff55ce0fc59516e780c39b16505ebebeab4da98
4
- data.tar.gz: 4a9ddd481f3f841b2e906ce3d3a1f8d9a32362c9
3
+ metadata.gz: 1ffaafd0698989e95d8181ddc6d613031cb122c2
4
+ data.tar.gz: 738ccaf5ac722f0031e15bf2629f3e492e3e43bb
5
5
  SHA512:
6
- metadata.gz: ec628ca808b4e7743d90756d2f1b621a9efa73225b3c1fdfc06083d53d5a87356d03e17a716f52caeb862bf5138be9e75f9ec088b15eb840db8c70926ed32855
7
- data.tar.gz: 7e96ccc49c9b9ca4ec47d75635f80e7fcf2921c72af0a8e3744f2bf2f49be79b39faac2f4afdf22f3cc4755dd64fc67d45349136d44f9010b8df32a7d42ec1f6
6
+ metadata.gz: 165148db1d23927161978cc7a22960837845084b3a230e2c2f30ee938cd53c28577bc67c8111e36e383812e2f7886941a15ef60b60ccf798e083a6122355640d
7
+ data.tar.gz: 61f1933acdbe068c5d47addd158ee35ea1e104058142ca5e9740756680d91ee819dc266219d2c4251446a8a6627ac900ee67943e1b442b11f2ecb8fe803c6da4
@@ -1,8 +1,8 @@
1
- require './lib/hash_attr/version'
1
+ require './lib/hashed_attr/version'
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = 'hashed_attr'
5
- spec.version = HashAttr::VERSION
5
+ spec.version = HashedAttr::VERSION
6
6
  spec.authors = ['Dann Luciano']
7
7
  spec.email = ['dannluciano@gmail.com']
8
8
  spec.summary = 'Hash attributes using SHA512 (or your custom hash strategy). Works with and without ActiveRecord.'
@@ -0,0 +1,17 @@
1
+ require 'forwardable'
2
+
3
+ module HashedAttr
4
+ require 'hashed_attr/version'
5
+ require 'hashed_attr/encryptor'
6
+ require 'hashed_attr/base'
7
+ require 'hashed_attr/active_record' if defined?(ActiveRecord)
8
+
9
+ class << self
10
+ extend Forwardable
11
+ def_delegators Base, :encryptor, :encryptor=
12
+ end
13
+
14
+ def self.included(target)
15
+ target.send :include, Base
16
+ end
17
+ end
@@ -0,0 +1,2 @@
1
+ require 'hashed_attr'
2
+ ActiveRecord::Base.send :include, HashedAttr::Base
@@ -1,4 +1,4 @@
1
- module HashAttr
1
+ module HashedAttr
2
2
  module Base
3
3
  def self.included(target)
4
4
  target.extend(ClassMethods)
@@ -6,24 +6,24 @@ module HashAttr
6
6
 
7
7
  class << self
8
8
  # Define the object that will encrypt/decrypt values.
9
- # By default, it's HashAttr::Encryptor
9
+ # By default, it's HashedAttr::Encryptor
10
10
  attr_accessor :encryptor
11
11
  end
12
12
 
13
13
  # Set initial encryptor engine.
14
- self.encryptor = Encryptor
14
+ self.encryptor = HashedAttr::Encryptor
15
15
 
16
16
  module ClassMethods
17
- def hash_attr(*args)
17
+ def hashed_attr(*args)
18
18
 
19
19
  args.each do |attribute|
20
- define_encrypted_attribute(attribute)
20
+ define_hashed_attribute(attribute)
21
21
  end
22
22
  end
23
23
 
24
24
  private
25
25
 
26
- def define_encrypted_attribute(attribute)
26
+ def define_hashed_attribute(attribute)
27
27
  define_method attribute do
28
28
  instance_variable_get("@#{attribute}")
29
29
  end
@@ -31,7 +31,7 @@ module HashAttr
31
31
  define_method "#{attribute}=" do |value|
32
32
  instance_variable_set("@#{attribute}", value)
33
33
  send("hashed_#{attribute}=", nil)
34
- send("hashed_#{attribute}=", HashAttr.encryptor.encrypt(value)) if value
34
+ send("hashed_#{attribute}=", HashedAttr.encryptor.encrypt(value)) if value
35
35
  end
36
36
  end
37
37
  end
@@ -1,7 +1,6 @@
1
1
  require 'digest/sha2'
2
- require 'base64'
3
2
 
4
- module HashAttr
3
+ module HashedAttr
5
4
  class Encryptor
6
5
  def self.encrypt(value)
7
6
  new().encrypt(value)
@@ -0,0 +1,3 @@
1
+ module HashedAttr
2
+ VERSION = '0.2.0'
3
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hashed_attr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dann Luciano
@@ -124,12 +124,12 @@ files:
124
124
  - LICENSE.txt
125
125
  - README.md
126
126
  - Rakefile
127
- - hash_attr.gemspec
128
- - lib/hash_attr.rb
129
- - lib/hash_attr/active_record.rb
130
- - lib/hash_attr/base.rb
131
- - lib/hash_attr/encryptor.rb
132
- - lib/hash_attr/version.rb
127
+ - hashed_attr.gemspec
128
+ - lib/hashed_attr.rb
129
+ - lib/hashed_attr/active_record.rb
130
+ - lib/hashed_attr/base.rb
131
+ - lib/hashed_attr/encryptor.rb
132
+ - lib/hashed_attr/version.rb
133
133
  homepage: http://rubygems.org/gems/hashed_attr
134
134
  licenses:
135
135
  - MIT
data/lib/hash_attr.rb DELETED
@@ -1,17 +0,0 @@
1
- require 'forwardable'
2
-
3
- module HashAttr
4
- require 'hash_attr/version'
5
- require 'hash_attr/encryptor'
6
- require 'hash_attr/base'
7
- require 'hash_attr/active_record' if defined?(ActiveRecord)
8
-
9
- class << self
10
- extend Forwardable
11
- def_delegators Base, :encryptor, :encryptor=
12
- end
13
-
14
- def self.included(target)
15
- target.send :include, Base
16
- end
17
- end
@@ -1,2 +0,0 @@
1
- require 'hash_attr'
2
- ActiveRecord::Base.send :include, HashAttr::Base
@@ -1,3 +0,0 @@
1
- module HashAttr
2
- VERSION = '0.1.0'
3
- end