dynamic_migrations 3.8.3 → 3.8.4

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: '08737568ccf7605e0a4d404063b7e1708e67c0ed96ab9f091bb72db627c0d50b'
4
- data.tar.gz: 404f7bd4816def6c379a9277ec9c06ad4f58d188d3911f4ca9e9c1a38cf301f8
3
+ metadata.gz: 9a9d25190ae4b67f3154feae64f9aa7a11d6b6effc9a6422cce43cde28cbcc68
4
+ data.tar.gz: 6a7a23a1d7793155f383899ec83f3477ec18581cf94a762a0729466e6d791ac4
5
5
  SHA512:
6
- metadata.gz: a403e1da441c1625e89034f07141d48c15fa07953404638795c2c11d58c79e26468f7b4b9070a37d18d6d62a91f069950b4d9ed824c6404071cee59fd3627d35
7
- data.tar.gz: 3df74c476b5d84f8b98f774a69223934823670201649bf35f3aa5a6620738c0fba046bb56ac2e8139364a39ac5a6c4cbdcea547b2cf9625bf45f570261038b80
6
+ metadata.gz: 84c9ed288329dbb5cc687335820feb293dd4aced564d9ebd8c65e0a84ab12368f8a2b774bef93af9fb9c845fb889eb8daadb9f8c60229e00cc8a78ce768ff3cd
7
+ data.tar.gz: e2b639cc38df40ed02de870e97707a71a1305819ce3eeac3d61384cdda75c764a3793616149187bf2eed3a40443a3c30f2b19d32ca3a13cf1da2a5f010e01571
data/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## [3.8.4](https://github.com/craigulliott/dynamic_migrations/compare/v3.8.3...v3.8.4) (2023-10-06)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * asserting that enum values must be unique strings, and adding ability to add additional enum values ([5cf6093](https://github.com/craigulliott/dynamic_migrations/commit/5cf6093eed96387042f70987c3999b40e4041b76))
9
+
3
10
  ## [3.8.3](https://github.com/craigulliott/dynamic_migrations/compare/v3.8.2...v3.8.3) (2023-10-06)
4
11
 
5
12
 
@@ -13,6 +13,9 @@ module DynamicMigrations
13
13
  class ExpectedValuesError < StandardError
14
14
  end
15
15
 
16
+ class ValueAlreadyExistsError < StandardError
17
+ end
18
+
16
19
  attr_reader :schema
17
20
  attr_reader :name
18
21
  attr_reader :values
@@ -25,8 +28,6 @@ module DynamicMigrations
25
28
 
26
29
  @columns = []
27
30
 
28
- @values = []
29
-
30
31
  raise ExpectedSchemaError, schema unless schema.is_a? Schema
31
32
  @schema = schema
32
33
 
@@ -36,7 +37,10 @@ module DynamicMigrations
36
37
  unless values.is_a?(Array) && values.count > 0
37
38
  raise ExpectedValuesError, "Values are required for enums"
38
39
  end
39
- @values = values
40
+ @values = []
41
+ values.each do |value|
42
+ add_value value
43
+ end
40
44
 
41
45
  unless description.nil?
42
46
  raise ExpectedStringError, description unless description.is_a? String
@@ -45,6 +49,18 @@ module DynamicMigrations
45
49
  end
46
50
  end
47
51
 
52
+ def add_value value
53
+ unless value.is_a? String
54
+ raise ValueMustBeStringError, "Value `#{value}` must be a string"
55
+ end
56
+
57
+ if @values.include? value
58
+ raise ValueAlreadyExistsError, "Value `#{value}` already exists in enum `#{name}`"
59
+ end
60
+
61
+ @values << value
62
+ end
63
+
48
64
  # returns true if this enum has a description, otehrwise false
49
65
  def has_description?
50
66
  !@description.nil?
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DynamicMigrations
4
- VERSION = "3.8.3"
4
+ VERSION = "3.8.4"
5
5
  end
@@ -16,6 +16,7 @@ module DynamicMigrations
16
16
  def full_name: -> Symbol
17
17
  def has_description?: -> bool
18
18
  def add_column: (Schema::Table::Column column) -> void
19
+ def add_value: (String value) -> void
19
20
  def differences_descriptions: (Enum other_enum) -> Array[String]
20
21
 
21
22
  class ExpectedSchemaError < StandardError
@@ -23,6 +24,12 @@ module DynamicMigrations
23
24
 
24
25
  class ExpectedValuesError < StandardError
25
26
  end
27
+
28
+ class ValueAlreadyExistsError < StandardError
29
+ end
30
+
31
+ class ValueMustBeStringError < StandardError
32
+ end
26
33
  end
27
34
  end
28
35
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dynamic_migrations
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.8.3
4
+ version: 3.8.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Craig Ulliott