super_settings 2.1.0 → 2.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +16 -0
- data/README.md +2 -0
- data/VERSION +1 -1
- data/lib/super_settings/configuration.rb +5 -0
- data/lib/super_settings/storage/active_record_storage/models.rb +7 -0
- data/lib/super_settings/storage/active_record_storage.rb +16 -8
- data/lib/super_settings/storage/null_storage.rb +72 -0
- data/lib/super_settings/storage.rb +1 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ecd3fc92a5668536f7d1300641505730c603b2c539dc069469e8559b1fbda7c2
|
4
|
+
data.tar.gz: c654d8ff805fda401c43b2df65a4f853330f5182398f7462f3d8954af4ae47e0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b97bc579ecce698c0080dab893456d36d5c3a7144695f07a13a03df1c1fb23df182c61155001066befc03922cbc945e35b43198d1d6e8fb0636faedc540bd2ce
|
7
|
+
data.tar.gz: 690abe15783bb18ca0e71494140c9d554f6ae532542a734d3027911fe771e4e93b1fde67dde18558872885e5e9b9edca96bda6587ca351847674d725e544b3c7
|
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,22 @@ All notable changes to this project will be documented in this file.
|
|
4
4
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
5
5
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
6
6
|
|
7
|
+
## 2.1.2
|
8
|
+
|
9
|
+
### Fixed
|
10
|
+
|
11
|
+
- Fixed ActiveRecord code ensure there are connections to the database before attempting to checkout a connection to avoid errors when the database is not available.
|
12
|
+
|
13
|
+
## 2.1.1
|
14
|
+
|
15
|
+
### Fixed
|
16
|
+
|
17
|
+
- Added check to ensure that ActiveRecord has a connection to the database to avoid error when settings are checked before the database is connected or when the database doesn't yet exist.
|
18
|
+
|
19
|
+
### Added
|
20
|
+
|
21
|
+
- Added `:null` storage engine that doesn't store settings at all. This is useful for testing or when the storage engine is no available in your continuous integration environment.
|
22
|
+
|
7
23
|
## 2.1.0
|
8
24
|
|
9
25
|
## Fixed
|
data/README.md
CHANGED
@@ -154,6 +154,8 @@ This gem abstracts out the storage engine and can support multiple storage mecha
|
|
154
154
|
* `SuperSettings::Storage::RedisStorage` - Stores the settings in a Redis database using the [redis](https://github.com/redis/redis-rb) gem.
|
155
155
|
* `SuperSettings::Storage::HttpStorage` - Uses the SuperSettings REST API running on another server. This is useful in a microservices architecture so you can have a central settings server used by all the services.
|
156
156
|
* `SuperSettings::Storage::S3Storage` - Stores the settings in JSON in an S3 object. This is useful for applications running on AWS that want to store settings in a central location since it does not require a dedicated database. It is possible to read the settings directly from S3 from another application.
|
157
|
+
* `SuperSettings::Storage::MongoDBStorage` - Stores the settings in a MongoDB database using the [mongo](https://github.com/mongodb/mongo-ruby-driver) gem.
|
158
|
+
* `SuperSettings::Storage::NullStorage` - Does not store settings at all. This is useful for testing or when the storage engine is not available in your continuous integration environment.
|
157
159
|
|
158
160
|
Additional storage engines can be built by creating a class that includes `SuperSettings::Storage` and implements the unimplemented methods in that module.
|
159
161
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.1.
|
1
|
+
2.1.2
|
@@ -27,6 +27,10 @@ module SuperSettings
|
|
27
27
|
@web_ui_enabled = true
|
28
28
|
@color_scheme = false
|
29
29
|
@changed_by_block = nil
|
30
|
+
@enhancement = nil
|
31
|
+
@application_name = nil
|
32
|
+
@application_logo = nil
|
33
|
+
@application_link = nil
|
30
34
|
end
|
31
35
|
|
32
36
|
def superclass
|
@@ -119,6 +123,7 @@ module SuperSettings
|
|
119
123
|
@storage = :active_record
|
120
124
|
@after_save_blocks = []
|
121
125
|
@changed_by_display = nil
|
126
|
+
@cache = nil
|
122
127
|
end
|
123
128
|
|
124
129
|
# Specify the storage engine to use for persisting settings. The value can either be specified
|
@@ -12,6 +12,13 @@ module SuperSettings
|
|
12
12
|
self.table_name = "super_settings"
|
13
13
|
|
14
14
|
has_many :history_items, class_name: "SuperSettings::Storage::ActiveRecordStorage::HistoryModel", foreign_key: :key, primary_key: :key
|
15
|
+
|
16
|
+
class << self
|
17
|
+
# ActiveRecord storage is only available if the connection pool is connected and the table exists.
|
18
|
+
def available?
|
19
|
+
connection_pool&.connected? && table_exists?
|
20
|
+
end
|
21
|
+
end
|
15
22
|
end
|
16
23
|
|
17
24
|
class HistoryModel < ApplicationRecord
|
@@ -18,7 +18,7 @@ module SuperSettings
|
|
18
18
|
|
19
19
|
class << self
|
20
20
|
def all
|
21
|
-
if Model.
|
21
|
+
if Model.available?
|
22
22
|
Model.all.collect { |model| new(model) }
|
23
23
|
else
|
24
24
|
[]
|
@@ -26,7 +26,7 @@ module SuperSettings
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def active
|
29
|
-
if Model.
|
29
|
+
if Model.available?
|
30
30
|
Model.where(deleted: false).collect { |model| new(model) }
|
31
31
|
else
|
32
32
|
[]
|
@@ -34,7 +34,7 @@ module SuperSettings
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def updated_since(time)
|
37
|
-
if Model.
|
37
|
+
if Model.available?
|
38
38
|
Model.where("updated_at > ?", time).collect { |model| new(model) }
|
39
39
|
else
|
40
40
|
[]
|
@@ -42,12 +42,12 @@ module SuperSettings
|
|
42
42
|
end
|
43
43
|
|
44
44
|
def find_by_key(key)
|
45
|
-
model = Model.where(deleted: false).find_by(key: key) if Model.
|
45
|
+
model = Model.where(deleted: false).find_by(key: key) if Model.available?
|
46
46
|
new(model) if model
|
47
47
|
end
|
48
48
|
|
49
49
|
def last_updated_at
|
50
|
-
if Model.
|
50
|
+
if Model.available?
|
51
51
|
Model.maximum(:updated_at)
|
52
52
|
end
|
53
53
|
end
|
@@ -57,15 +57,23 @@ module SuperSettings
|
|
57
57
|
end
|
58
58
|
|
59
59
|
def with_connection(&block)
|
60
|
-
Model.
|
60
|
+
if Model.available?
|
61
|
+
Model.connection_pool.with_connection(&block)
|
62
|
+
else
|
63
|
+
yield
|
64
|
+
end
|
61
65
|
end
|
62
66
|
|
63
67
|
def transaction(&block)
|
64
|
-
Model.
|
68
|
+
if Model.available?
|
69
|
+
Model.transaction(&block)
|
70
|
+
else
|
71
|
+
yield
|
72
|
+
end
|
65
73
|
end
|
66
74
|
|
67
75
|
def destroy_all
|
68
|
-
|
76
|
+
Model.transaction do
|
69
77
|
Model.delete_all
|
70
78
|
HistoryModel.delete_all
|
71
79
|
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module SuperSettings
|
4
|
+
module Storage
|
5
|
+
# No-op implementation of the SuperSettings::Storage model. You can use this model if there
|
6
|
+
# is no other storage engine available. It can be useful for situations where the normal
|
7
|
+
# storage engine is not available, such as in a continious integration environment.
|
8
|
+
class NullStorage
|
9
|
+
# :nocov:
|
10
|
+
|
11
|
+
include Storage
|
12
|
+
|
13
|
+
attr_accessor :key, :raw_value, :description, :value_type, :updated_at, :created_at, :changed_by
|
14
|
+
|
15
|
+
class << self
|
16
|
+
attr_reader :settings
|
17
|
+
|
18
|
+
def history(key)
|
19
|
+
[]
|
20
|
+
end
|
21
|
+
|
22
|
+
def destroy_all
|
23
|
+
end
|
24
|
+
|
25
|
+
def all
|
26
|
+
[]
|
27
|
+
end
|
28
|
+
|
29
|
+
def updated_since(time)
|
30
|
+
[]
|
31
|
+
end
|
32
|
+
|
33
|
+
def find_by_key(key)
|
34
|
+
nil
|
35
|
+
end
|
36
|
+
|
37
|
+
def last_updated_at
|
38
|
+
nil
|
39
|
+
end
|
40
|
+
|
41
|
+
def create_history(key:, changed_by:, created_at:, value: nil, deleted: false)
|
42
|
+
nil
|
43
|
+
end
|
44
|
+
|
45
|
+
def load_asynchronous?
|
46
|
+
false
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def history(limit: nil, offset: 0)
|
51
|
+
[]
|
52
|
+
end
|
53
|
+
|
54
|
+
def save!
|
55
|
+
true
|
56
|
+
end
|
57
|
+
|
58
|
+
def deleted=(value)
|
59
|
+
end
|
60
|
+
|
61
|
+
def deleted?
|
62
|
+
false
|
63
|
+
end
|
64
|
+
|
65
|
+
def persisted?
|
66
|
+
false
|
67
|
+
end
|
68
|
+
|
69
|
+
# :nocov:
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
@@ -13,6 +13,7 @@ module SuperSettings
|
|
13
13
|
autoload :JSONStorage, File.join(__dir__, "storage/json_storage")
|
14
14
|
autoload :S3Storage, File.join(__dir__, "storage/s3_storage")
|
15
15
|
autoload :MongoDBStorage, File.join(__dir__, "storage/mongodb_storage")
|
16
|
+
autoload :NullStorage, File.join(__dir__, "storage/null_storage")
|
16
17
|
|
17
18
|
def self.included(base)
|
18
19
|
base.extend(ClassMethods)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: super_settings
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
4
|
+
version: 2.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian Durand
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-12-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -79,6 +79,7 @@ files:
|
|
79
79
|
- lib/super_settings/storage/http_storage.rb
|
80
80
|
- lib/super_settings/storage/json_storage.rb
|
81
81
|
- lib/super_settings/storage/mongodb_storage.rb
|
82
|
+
- lib/super_settings/storage/null_storage.rb
|
82
83
|
- lib/super_settings/storage/redis_storage.rb
|
83
84
|
- lib/super_settings/storage/s3_storage.rb
|
84
85
|
- lib/super_settings/storage/storage_attributes.rb
|