super_settings 2.1.0 → 2.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -0
- data/README.md +4 -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 +5 -5
- 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: c245924ff453f5cd0bde098003e6dc05d54b21aba4a42ddaf7c614c63233a542
|
4
|
+
data.tar.gz: fb8672624d5c688794f8492be263534ed4e46ac49684f76d9bbf3bd120b62579
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 605db9f00bbd1865203caaf7515c3d5f1ad83911653dd9410c69344dda0b21b8e58167806186969a6d2b27d4867a61d97b29333715c3f139741f16a3d3b0a635
|
7
|
+
data.tar.gz: b1565e3ace970a26a8d126ec27e3bee6786b5da85e33e25bbde5a947af12e8067a23d143870b7012dd449b86ab5658fbeb99fb365bc8f738276cf8672ffc318d
|
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,16 @@ 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.1
|
8
|
+
|
9
|
+
### Fixed
|
10
|
+
|
11
|
+
- 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.
|
12
|
+
|
13
|
+
### Added
|
14
|
+
|
15
|
+
- 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.
|
16
|
+
|
7
17
|
## 2.1.0
|
8
18
|
|
9
19
|
## 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
|
|
@@ -391,10 +393,12 @@ bundle exec rackup
|
|
391
393
|
|
392
394
|
By default this will use Redis for storage using the default Redis URL. You can change the storage engine with the `STORAGE` environment variable.
|
393
395
|
|
396
|
+
- `active_record` - Use the ActiveRecord storage engine.
|
394
397
|
- `redis` - Use the Redis storage engine. The Redis URL can be set with the `REDIS_URL` environment variable.
|
395
398
|
- `http` - Use the HTTP storage engine. The URL for the REST API can be set with the `REST_API_URL` environment variable.
|
396
399
|
- `s3` - Use the S3 storage engine. The S3 URL can be set with the `S3_URL` environment variable.
|
397
400
|
- `mongodb` - Use the MongoDB storage engine. The MongoDB URL can be set with the `MONGODB_URL` environment variable.
|
401
|
+
- `null` - Use the null storage engine. This storage engine does not store settings at all.
|
398
402
|
|
399
403
|
You can bring up all of these storage engines locally with the included docker-compose configuration.
|
400
404
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.1.
|
1
|
+
2.1.1
|
@@ -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
|
@@ -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.1
|
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-02 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
|