yaml_enumeration 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 329c035e5c90f7cd2c444c1237f2c1c5bf00b50ae6cefcf6f8658c1cdda7fe45
4
- data.tar.gz: debf948e5a235157517ef21d67c6d498f3d2a623cfc9cbe384ae7d81dc8ed05f
3
+ metadata.gz: 789056e38408fc39c5203d9b27347d67eac1223a005c4e97d6c3fbb0b50e52c9
4
+ data.tar.gz: f687bbcc331fa6959225a5701721b156ae652dc5c51540f4a85d2b8c75d66ab0
5
5
  SHA512:
6
- metadata.gz: 730bdbbefa4291935287eda1f56d78cf5f4e4c349426caf4fc20597fdb2cf43d1a627300031a45716dc57b7ecd60c4453de7ee9bb47f76341c19d908d4332a36
7
- data.tar.gz: 8b75285fa43d9440d635566104d5201f8a8192d58d4754c69c134470e8e348456e1b38519aea3b74b9be33fa0a93effd5872566e0d7f2257c86bb5f15c5e16fa
6
+ metadata.gz: 937de680ad7a668d42faa880eac779d53d0bfb9833bfdf981f50c97cf3703d113de49e550b3290ae27c9a7ca7173d44b0630cbf5922a07e60464b98886cb20e5
7
+ data.tar.gz: bc24da29146aac8453d17badffaf83176dc8c937d54eff3660ead43b8261237445741c1db95fff163bdf8f0fddeb80adc6e2f925573f3aa2d71604a4c05b3b8d
data/.travis.yml CHANGED
@@ -4,4 +4,6 @@ rvm:
4
4
  - 2.5.3
5
5
  - 2.6.5
6
6
  - 2.7.1
7
+ - 3.0.5
8
+ - 3.1.4
7
9
  before_install: gem install bundler
data/CHANGELOG.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 0.4.0
4
+ * add support for Ruby `3.1` [#7](https://github.com/alto/yaml_enumeration/pull/7)
5
+
3
6
  ## 0.3.0
4
7
  * enable exclusion of blocks of YAML from the enumeration (support YAML anchors) [#6](https://github.com/alto/yaml_enumeration/pull/6)
5
8
 
@@ -0,0 +1,14 @@
1
+ module YamlEnumeration
2
+ class Configuration
3
+
4
+ DEFAULT_PERMITTED_CLASSED = [].freeze
5
+
6
+ class << self
7
+ attr_writer :permitted_classes
8
+
9
+ def permitted_classes
10
+ @permitted_classes || DEFAULT_PERMITTED_CLASSED
11
+ end
12
+ end
13
+ end
14
+ end
@@ -13,7 +13,7 @@ module YamlEnumeration
13
13
 
14
14
  def self.load_values(filename)
15
15
  file = File.join(Rails.root, 'db', 'enumerations', "#{filename}.yml")
16
- remove_exclusions(YAML.load(ERB.new(File.read(file)).result)).values.each do |data|
16
+ remove_exclusions(yaml_load(ERB.new(File.read(file)).result)).values.each do |data|
17
17
  value data.symbolize_keys
18
18
  end
19
19
  end
@@ -126,6 +126,14 @@ module YamlEnumeration
126
126
  end
127
127
  end
128
128
 
129
+ def yaml_load(source)
130
+ begin
131
+ YAML.load(source, aliases: true, permitted_classes: Configuration.permitted_classes)
132
+ rescue ArgumentError
133
+ YAML.load(source, permitted_classes: Configuration.permiitted_classes)
134
+ end
135
+ end
136
+
129
137
  # Define singleton methods .BLAH for each type
130
138
  def with_named_items(column = :type)
131
139
  all.each do |item|
@@ -1,3 +1,3 @@
1
1
  module YamlEnumeration
2
- VERSION = "0.3.0"
2
+ VERSION = "0.4.0"
3
3
  end
@@ -1,4 +1,5 @@
1
1
  require "yaml_enumeration/version"
2
2
  require "yaml_enumeration/association"
3
3
  require "yaml_enumeration/enumeration"
4
+ require "yaml_enumeration/configuration"
4
5
  require "yaml_enumeration/railtie"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yaml_enumeration
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thorsten Boettger
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-02-03 00:00:00.000000000 Z
11
+ date: 2023-04-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -115,6 +115,7 @@ files:
115
115
  - bin/setup
116
116
  - lib/yaml_enumeration.rb
117
117
  - lib/yaml_enumeration/association.rb
118
+ - lib/yaml_enumeration/configuration.rb
118
119
  - lib/yaml_enumeration/enumeration.rb
119
120
  - lib/yaml_enumeration/railtie.rb
120
121
  - lib/yaml_enumeration/version.rb
@@ -138,7 +139,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
138
139
  - !ruby/object:Gem::Version
139
140
  version: '0'
140
141
  requirements: []
141
- rubygems_version: 3.2.17
142
+ rubygems_version: 3.3.26
142
143
  signing_key:
143
144
  specification_version: 4
144
145
  summary: Create ActiveRecord enumerations based on YAML files.