ssm_config 1.2.3 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/ssm_config/migration_helper.rb +8 -2
- data/lib/ssm_config/ssm_storage/db.rb +8 -3
- data/lib/ssm_config.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8d835d981fcf137b46b213786f9e3e2a79a8dc31540ec4e810c3a7f16dfc7ccf
|
4
|
+
data.tar.gz: 471c9e8c29bfda709bd5ac812239291ccefa9d365bbb48e8fbbe3c942fd9afbe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5ae237e3d775ecc1892f64d39fc95d332cbd0bb15da1bdb6e65247f4bf4aa2d32b522c8ceea3067017eefff756d094ac6c62c1fd74ec83545c640cb259ef857d
|
7
|
+
data.tar.gz: 0f3f9b5258f7de1f61df1f50256525ff966e3f2d7fbae1781e8d469715e0ca9750d3bd8f5c4a30c0b0ef5cab6c3aa083520536445b9c6b1b622095d0aa9f76fd
|
data/README.md
CHANGED
@@ -31,7 +31,7 @@ To utilize ActiveRecords, create the following model:
|
|
31
31
|
rails generate model SsmConfigRecord file:string:index accessor_keys:string value:text datatype:string
|
32
32
|
```
|
33
33
|
|
34
|
-
The supported datatypes are `[string, integer, boolean, float]`. The first character entered in the field `datatype` should be the character that corresponds to the first character of the datatype (so one of `[s, i, b, f]`). This field is not case-sensitive.
|
34
|
+
The supported datatypes are `[string, integer, boolean, float, erb]`. The first character entered in the field `datatype` should be the character that corresponds to the first character of the datatype (so one of `[s, i, b, f, e]`). This field is not case-sensitive. The type `erb` will store the `erb` expression in the database, and evaluate it on queries.
|
35
35
|
|
36
36
|
Booleans should also be one of `[t, f]`, corresponding to `true` and `false`. Similarly, this is not case-sensitive and only the first character of the value entered (given the datatype is a boolean) will be checked.
|
37
37
|
|
@@ -51,11 +51,17 @@ module SsmConfig
|
|
51
51
|
|
52
52
|
def determine_class(value)
|
53
53
|
return 'boolean' if (value == false) || (value == true)
|
54
|
-
return value
|
54
|
+
return 'erb' if (value[0..2] == '<%=') && (value[-2..-1] == '%>')
|
55
|
+
value.class
|
56
|
+
end
|
57
|
+
|
58
|
+
def file_path
|
59
|
+
Rails.root.join(SsmConfig::SsmStorage::Yml::CONFIG_PATH, "#{@file_name}.yml")
|
55
60
|
end
|
56
61
|
|
57
62
|
def hash
|
58
|
-
|
63
|
+
yaml_loaded = YAML.load(File.read((file_path).to_s))
|
64
|
+
(yaml_loaded[Rails.env] || yaml_loaded['any']).try(:with_indifferent_access)
|
59
65
|
end
|
60
66
|
end
|
61
67
|
end
|
@@ -3,7 +3,7 @@ module SsmConfig
|
|
3
3
|
class Db
|
4
4
|
TABLE_NAME = 'ssm_config_records'.freeze
|
5
5
|
ACTIVE_RECORD_MODEL = 'SsmConfigRecord'.freeze
|
6
|
-
VALID_DATATYPES = ['s', 'i', 'b', 'f'].freeze
|
6
|
+
VALID_DATATYPES = ['s', 'i', 'b', 'f', 'e'].freeze
|
7
7
|
def initialize(file_name)
|
8
8
|
@file_name = file_name
|
9
9
|
end
|
@@ -42,11 +42,16 @@ module SsmConfig
|
|
42
42
|
raise SsmConfig::InvalidBoolean, 'Not a valid boolean: must be one of true or false'
|
43
43
|
end
|
44
44
|
|
45
|
+
def convert_erb(value)
|
46
|
+
ERB.new(value).result
|
47
|
+
end
|
48
|
+
|
45
49
|
def transform_class(value, type)
|
46
50
|
type_char = type.to_s.downcase[0]
|
47
51
|
raise SsmConfig::UnsupportedDatatype, 'Not a valid class: must be one of string, integer, boolean, or float' unless VALID_DATATYPES.include? type_char
|
48
|
-
return value
|
49
|
-
|
52
|
+
return convert_boolean(value) if type_char == 'b'
|
53
|
+
return convert_erb(value) if type_char == 'e'
|
54
|
+
value.send("to_#{type_char}")
|
50
55
|
end
|
51
56
|
|
52
57
|
def add_flag_for_array_index(key)
|
data/lib/ssm_config.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ssm_config
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Santiago Herrera
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-07-
|
11
|
+
date: 2023-07-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -146,7 +146,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
146
146
|
- !ruby/object:Gem::Version
|
147
147
|
version: '0'
|
148
148
|
requirements: []
|
149
|
-
rubygems_version: 3.
|
149
|
+
rubygems_version: 3.2.3
|
150
150
|
signing_key:
|
151
151
|
specification_version: 4
|
152
152
|
summary: YML file loader and parser for Rails
|