rails_surrogate_key_logging 0.2.1 → 0.4.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
  SHA256:
3
- metadata.gz: 4f209a8f18098917e60dbd9dbe93a1d6367eeaf16e2da104bbbba0351fb09956
4
- data.tar.gz: 0d70d2d6ed37c4981c286fbed4f409f397babd3695a90141a886d24b19ba2634
3
+ metadata.gz: d69d68a6bbbb693ad6e0858b770aab8ee4c430e309447bae5b4a7cd222286852
4
+ data.tar.gz: 9b72303771b0704d71eb69dcd24e1120d7e4de0d755cfb8d07ad2ea520df90e1
5
5
  SHA512:
6
- metadata.gz: c12692d51a77d61a606193aee29f77016f2386076c6334e35f8dfeb324a52f3caed7860a3ea83c44f2a91c861cd379eb8d2ed21002ace9732f5e9b8acfebe6fb
7
- data.tar.gz: 969985b95d785c04f0c90042e57ce3bf2826d529adf96aac611994fa061a7c254175e4bcaa13eee4f39f18e95000bbd2ddaa268547d1317f6893d3e24a43d5db
6
+ metadata.gz: 128b93f900cf248c250de95e8f4fd64db8ed4c437ffbe1eb40a79fbf002d101e4f3b566622aee962b434a3ebf0b196e559eab45f8a5e6cafc54398a6151a4658
7
+ data.tar.gz: b15e7ac8901f0d43bf0f95f99e657bb65d90b4a2ec3e9123672ccf8a6464b587b32be03ab523b1b2214ce7cf77d66207a852081821885ba3a60d6099157ee9eb
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SurrogateKeyLogging
4
+ class ApplicationRecord < ::ActiveRecord::Base
5
+ self.abstract_class = true
6
+
7
+ def self.table_name
8
+ "#{Rails.application.config.database_configuration["surrogate_key_logging_#{Rails.env}"]['database']}.#{compute_table_name}"
9
+ end
10
+
11
+ end
12
+
13
+ class << self
14
+ def table_name_prefix; end
15
+ end
16
+
17
+ end
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SurrogateKeyLogging
4
+ class Surrogate < ApplicationRecord
5
+ class << self
6
+ def hash_value(value)
7
+ Digest::SHA512.hexdigest value.to_s
8
+ end
9
+
10
+ def value_for_surrogate(surrogate)
11
+ where(key: surrogate).select(:value).first&.value
12
+ end
13
+
14
+ def surrogate_for_value(value)
15
+ where(hashed_value: hash_value(value)).select(:key).first&.key
16
+ end
17
+
18
+ def add(surrogate, value)
19
+ s = new(key: surrogate, value: value, hashed_value: hash_value(value))
20
+ s.save
21
+ end
22
+
23
+ def use(surrogate)
24
+ where(key: surrogate).touch_all
25
+ end
26
+ end
27
+ end
28
+ end
@@ -18,8 +18,8 @@ module SurrogateKeyLogging
18
18
  end
19
19
 
20
20
  rake_tasks do
21
- load 'tasks/surrogate_key_logging.rake'
22
- load 'tasks/key_store/active_record.rake'
21
+ # load 'tasks/surrogate_key_logging.rake'
22
+ # load 'tasks/key_store/active_record.rake'
23
23
  end
24
24
 
25
25
  initializer 'surrogate_key_logging.config' do |app|
@@ -15,6 +15,7 @@ module SurrogateKeyLogging
15
15
  end
16
16
 
17
17
  def get(value)
18
+ return if value.blank?
18
19
  if should_cache
19
20
  get_cached(value)
20
21
  else
@@ -4,8 +4,8 @@ module SurrogateKeyLogging
4
4
 
5
5
  module Version
6
6
  MAJOR = 0
7
- MINOR = 2
8
- PATCH = 1
7
+ MINOR = 4
8
+ PATCH = 0
9
9
 
10
10
  end
11
11
 
@@ -64,6 +64,10 @@ module SurrogateKeyLogging
64
64
  parameter_filter.filter params
65
65
  end
66
66
 
67
+ def surrogate_for(value)
68
+ key_manager.get(value)
69
+ end
70
+
67
71
  def add_param_to_filter(attr, *parents)
68
72
  if parents.empty?
69
73
  surrogate_attributes attr.to_s
@@ -21,7 +21,7 @@ Gem::Specification.new do |s|
21
21
  'rubygems_mfa_required' => 'true',
22
22
  }
23
23
 
24
- s.files = Dir['lib/**/*', 'README.md', 'MIT-LICENSE', 'rails_surrogate_key_logging.gemspec']
24
+ s.files = Dir['app/**/*', 'lib/**/*', 'README.md', 'MIT-LICENSE', 'rails_surrogate_key_logging.gemspec']
25
25
 
26
26
  s.require_paths = %w[ lib ]
27
27
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_surrogate_key_logging
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Taylor Yelverton
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-01-24 00:00:00.000000000 Z
11
+ date: 2023-02-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionpack
@@ -97,6 +97,8 @@ extensions: []
97
97
  extra_rdoc_files: []
98
98
  files:
99
99
  - README.md
100
+ - app/models/surrogate_key_logging/application_record.rb
101
+ - app/models/surrogate_key_logging/surrogate.rb
100
102
  - lib/rails_surrogate_key_logging.rb
101
103
  - lib/surrogate_key_logging.rb
102
104
  - lib/surrogate_key_logging/action_controller.rb