ssm_config 1.2.0 → 1.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 89d121720c2b6cfaf01bc67c184f32be74f0eaa3ad217a667d760047680b6491
4
- data.tar.gz: bc4eda9aa3c1b28475e3aee34fa6b7453a3992d27fc46eab06e6ce8f69314849
3
+ metadata.gz: 4e0458ce594909bd0f384194296abe115310bede9765695232662a1996202842
4
+ data.tar.gz: ddde6df256c8f06e2d95f45a254608efd9acf6ef244b6522fb7554c5e95d261d
5
5
  SHA512:
6
- metadata.gz: 05afa978a2d8c57db17e1dbf66d9cf443096a2de2b6caed961d69dffafefd6fdda0434eba7d7046ec95346f9bfffd240f794359045e9890153c17994411815f6
7
- data.tar.gz: df7370fa1b13356b249f5726b0dd203c246323d41b39d73711f0284e3f6151269e30f0261c24eac1c5945f6122480a3ca6a968a2c5e538793a9f6ad4d3f4857e
6
+ metadata.gz: 80d9191173e45d77bf045e05e63f0ccf9b8208173757d95dca67d4dbd94c63ebd5e2890d9c46fbcad8ea5fd14c5010b667b9c9d9b82ca9e99382517a110609d2
7
+ data.tar.gz: fef6162659dbf16f1d97cfdf7e62554fbd2d1a3e213945218e827433ab18801da89a3d588534ba04e3eb0175b690daf13c0c539bb6e21965e752fb8ec16a6fd4
data/README.md CHANGED
@@ -87,7 +87,18 @@ This search will be exclusive: i.e., if any row exists in the table then the gem
87
87
 
88
88
  To migrate a YAML file in the `config` directory into `SsmConfigRecord`, the class `SsmConfig::MigrationHelper` can be used. `MigrationHelper` takes in the file name, and has `up` and `down` methods.
89
89
 
90
- The `up` method will migrate the file into the table: if any validations are violated, then all rows that were added in the current call will be deleted, returning the table to the initial state.
90
+ The `up` method will migrate the file into the table: if any validations are violated, then all rows that were added in the current call will be deleted, returning the table to the initial state. The following is a custom validation for datatype (which can be added in the corresponding model file):
91
+
92
+ ```ruby
93
+ class SsmConfigRecord < ApplicationRecord
94
+ validate :datatype_support
95
+
96
+ def datatype_support
97
+ errors.add(:datatype, "is not a valid datatype (#{datatype})") unless SsmConfig::SsmStorage::Db::VALID_DATATYPES.include? datatype.downcase[0]
98
+ end
99
+ end
100
+ ```
101
+
91
102
 
92
103
  The `down` method will remove _all_ rows in the table that match the file name. A sample migration is as follows:
93
104
 
@@ -3,6 +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
7
  def initialize(file_name)
7
8
  @file_name = file_name
8
9
  end
@@ -40,9 +41,9 @@ module SsmConfig
40
41
  end
41
42
 
42
43
  def transform_class(value, type)
43
- possible_types = ['s', 'i', 'b', 'f']
44
- raise SsmConfig::UnsupportedDatatype, 'Not a valid class: must be one of string, integer, boolean, or float' unless possible_types.include? type.to_s.downcase[0]
45
- return value.send("to_#{type.to_s.downcase[0]}") unless type[0] == 'b'
44
+ type_char = type.to_s.downcase[0]
45
+ raise SsmConfig::UnsupportedDatatype, 'Not a valid class: must be one of string, integer, boolean, or float' unless VALID_DATATYPES.include? type_char
46
+ return value.send("to_#{type_char}") unless type_char == 'b'
46
47
  convert_boolean(value)
47
48
  end
48
49
 
data/lib/ssm_config.rb CHANGED
@@ -1,13 +1,13 @@
1
- require './lib/ssm_config/ssm_storage/db.rb'
2
- require './lib/ssm_config/ssm_storage/yml.rb'
3
- require './lib/ssm_config/ssm_storage/empty.rb'
4
- require './lib/ssm_config/errors.rb'
5
- require './lib/ssm_config/migration_helper.rb'
1
+ require 'ssm_config/ssm_storage/db.rb'
2
+ require 'ssm_config/ssm_storage/yml.rb'
3
+ require 'ssm_config/ssm_storage/empty.rb'
4
+ require 'ssm_config/errors.rb'
5
+ require 'ssm_config/migration_helper.rb'
6
6
  require 'active_support/core_ext/hash/indifferent_access'
7
7
  require 'active_support/time'
8
8
 
9
9
  module SsmConfig
10
- VERSION = '1.2.0'.freeze
10
+ VERSION = '1.2.2'.freeze
11
11
  REFRESH_TIME = (30.minutes).freeze
12
12
 
13
13
  class << self
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.2.0
4
+ version: 1.2.2
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-17 00:00:00.000000000 Z
11
+ date: 2023-07-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler