web47core 0.7.0 → 0.7.6

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: c53f1926c9087f4e9cc6f6037b29401e8b5ec7a7b29bb827228a5865b486db87
4
- data.tar.gz: de8d77e1e2fb118dd40ae5f263ed08b711e370a3ce64f6ebf27d6c5898758162
3
+ metadata.gz: e8fbdc0d487e8fbc4f4b49b74603fb12b694a77267caa16e9c36d1f589418e28
4
+ data.tar.gz: 3587a074347a1807a3eb139aeb904eeb77394bfc76e754994b312736e8acc348
5
5
  SHA512:
6
- metadata.gz: f84fb47a7f6a366b40a4e6d1e3155268caa889ed606b2f5e5d0d629b9992ddc16d2c49814292b36bc448a36788c6480a7a9acf6f476eaef770c2fec66e89cd56
7
- data.tar.gz: 8682ac4e3c691e4bec4c2f2ec8313a4dd8c034c5d926cc76f7ea735c0e56d7eff838b40b68e38405be9d4d5bfc1f16fd1dfee65395d7a4fe17b432a644881d03
6
+ metadata.gz: 5a324d1aa8cfacc3116268b1f173bd6b396f60b33c5c7e5efeefae85dd668786e603e44edd0c51b9fc299efafa5fe1d0d1cbc4b4d84a1bd1b9fe5c364537fc0f
7
+ data.tar.gz: 4139018431239a2edecbdcdb40109951636a6409c367fa4b7f9dea9aae1032ce0b7d01ec2ac348816fcd6e4bfff194491c9cc444f10e486f5ca5cd254a784c99
@@ -60,15 +60,16 @@ module CoreHelper
60
60
  # 3. Length 5-10 only show the first and last character
61
61
  # 4. Otherwise show the first and last three characters
62
62
  def mask_value(value, default: '************')
63
- return default if value.blank?
63
+ return default if value.blank? || !value.respond_to?(:to_s)
64
64
 
65
- case value.length
65
+ string_value = value.to_s
66
+ case string_value.length
66
67
  when 1..4
67
- "#{value.first}***********"
68
+ "#{string_value.first}***********"
68
69
  when 5..10
69
- "#{value.first}**********#{value.last}"
70
+ "#{string_value.first}**********#{string_value.last}"
70
71
  else
71
- "#{value[0..2]}**********#{value[-3..-1]}"
72
+ "#{string_value[0..2]}**********#{string_value[-3..-1]}"
72
73
  end
73
74
  end
74
75
 
@@ -16,6 +16,7 @@ module CoreSystemConfiguration
16
16
  #
17
17
  def self.included(base)
18
18
  base.class_eval do
19
+ attr_accessor :configuration
19
20
  #
20
21
  # Fields
21
22
  #
@@ -73,27 +74,8 @@ module CoreSystemConfiguration
73
74
  end
74
75
 
75
76
  module ClassMethods
76
- #
77
- # Fetch the system configuration based on environment name. First try the rails cache
78
- # if not there, then go to the database.
79
- #
80
- # Also, if an argument error is thrown, then just fetch from the database.
81
- #
82
77
  def configuration
83
- cache_key = "SystemConfiguration::#{Rails.env}"
84
-
85
- begin
86
- config = Rails.cache.fetch(cache_key, expires_in: 90.seconds) do
87
- SystemConfiguration.find_by(environment: Rails.env)
88
- end
89
- rescue StandardError
90
- # This seems to happen in testing relative to Country, when it does, remove
91
- # ourselves from the cache and return the DB entry.
92
- Rails.cache.delete cache_key
93
- config = SystemConfiguration.find_or_create_by!(environment: Rails.env)
94
- end
95
-
96
- config.nil? ? SystemConfiguration.create(environment: Rails.env) : config
78
+ SystemConfiguration.find_or_create_by!(environment: Rails.env)
97
79
  end
98
80
 
99
81
  def smtp_configuration
@@ -110,19 +92,21 @@ module CoreSystemConfiguration
110
92
  #
111
93
  # NOTE: Currently ignored Codacy issue: When using 'method_missing', fall back on 'super'
112
94
  #
113
- # rubocop:disable Style/MethodMissingSuper
114
95
  def method_missing(method, *args, &_block)
115
- configuration.send method, *args
96
+ if configuration.respond_to?(method)
97
+ configuration.send(method, *args)
98
+ else
99
+ super
100
+ end
116
101
  end
117
102
 
118
- def respond_to?(method_name, _include_private = false)
119
- SystemConfiguration.fields.include?(method_name)
103
+ def respond_to?(method_name, include_private = false)
104
+ configuration.respond_to?(method_name, include_private) || super
120
105
  end
121
106
 
122
- def respond_to_missing?(method_name, _include_private = false)
123
- SystemConfiguration.fields.include?(method_name)
107
+ def respond_to_missing?(method_name, include_private = false)
108
+ configuration.respond_to?(method_name, include_private) || super
124
109
  end
125
- # rubocop:enable Style/MethodMissingSuper
126
110
  end
127
111
 
128
112
  #
@@ -203,7 +187,7 @@ module CoreSystemConfiguration
203
187
  config = SystemConfiguration.configuration
204
188
  path = if config.zendesk_configured? && user.present?
205
189
  time_now = Time.now.to_i
206
- jti = "#{time_now}/#{rand(36**64).to_s(36)}"
190
+ jti = "#{time_now}/#{rand(36 ** 64).to_s(36)}"
207
191
  payload = { jwt: JWT.encode({ iat: time_now, # Seconds since epoch, determine when this token is stale
208
192
  jti: jti, # Unique token identifier, helps prevent replay attacks
209
193
  name: user.name,
@@ -261,13 +245,4 @@ module CoreSystemConfiguration
261
245
  def slack_configured?
262
246
  slack_api_url.present?
263
247
  end
264
-
265
- private
266
-
267
- #
268
- # Clear the cache when the object is saved
269
- #
270
- def clear_cache
271
- Rails.cache.delete "SystemConfiguration::#{Rails.env}"
272
- end
273
248
  end
@@ -24,7 +24,7 @@ module StandardModel
24
24
  #
25
25
  belongs_to :last_modified_by, class_name: Web47core::Config.audit_model_class_name, optional: true
26
26
  belongs_to :created_by, class_name: Web47core::Config.audit_model_class_name, optional: true
27
- has_many Web47core::Config.audit_model_log_symbol, dependent: :nullify
27
+ has_many Web47core::Config.audit_model_log_symbol, dependent: :nullify, inverse_of: :model
28
28
  #
29
29
  # Callbacks
30
30
  #
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Web47core
4
- VERSION = '0.7.0'
4
+ VERSION = '0.7.6'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: web47core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.7.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Schroeder
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-05-07 00:00:00.000000000 Z
11
+ date: 2020-05-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport