twitter_cldr 6.10.0 → 6.11.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: ce23d1d3e7d5428401b92b60c2570f8a2370e41beb32068fc0df7a6ce4959126
4
- data.tar.gz: 595d913024e24dd3fd86426f12288c7040904f446291145e5ba92c0945a33d12
3
+ metadata.gz: d2208001cc0fddbd8fbf3d87a557fe1c124439b8dd1abd14b5515a915cefe288
4
+ data.tar.gz: 564cdeb9423b2b055953ca9c755f93518e38d83d3895db6140593807c1e3aa05
5
5
  SHA512:
6
- metadata.gz: 402c8198faf70a1f72631e202278e2bf464a67c81d42dec357f0c474d078085054651b2bd166e1de6c1d078c83ddfbcc757de638affb3415e597d6283033465e
7
- data.tar.gz: d06ad1e4fc3aac7d069d606b75c1bcde9261f53805d9441914a042a641ed83cd0e06caa8039e7f44308726f686cc02ebeb0aeda52a693d5dbbbd9da3c0b46694
6
+ metadata.gz: 3db038bb6ec7c6d12181f5d7c087df93e18fbf7bda31642028e1f35b404072cf4cbabd7b1a993c7c6de24db9767193e80d2e5a6d77509d23ed9f6c19d4bfe31d
7
+ data.tar.gz: 6e93f77989434c7e7b97cd8c2081dacf9de00803781737df787dac93b19b8f0460cfc326f9baaea2da2b2f9503b11ab131816569f22a826bc8f87acf5abb06d2
@@ -10,7 +10,18 @@ module TwitterCldr
10
10
 
11
11
  class Loader
12
12
 
13
+ class << self
14
+ def load_yaml(yaml, permitted_classes: [])
15
+ if RUBY_VERSION >= '2.6.0'
16
+ YAML.safe_load(yaml, permitted_classes: permitted_classes)
17
+ else
18
+ YAML.safe_load(yaml, permitted_classes)
19
+ end
20
+ end
21
+ end
22
+
13
23
  VALID_EXTS = %w(.yml .dump).freeze
24
+ PERMITTED_YAML_CLASSES = [Range, Regexp, Symbol, Time].freeze
14
25
 
15
26
  def get_resource(*path)
16
27
  resources_cache[resource_file_path(path)]
@@ -105,7 +116,7 @@ module TwitterCldr
105
116
  end
106
117
 
107
118
  def load_yaml_resource(path, merge_custom = true)
108
- base = YAML.load(read_resource_file(path))
119
+ base = load_yaml(read_resource_file(path), permitted_classes: PERMITTED_YAML_CLASSES)
109
120
  custom_path = File.join("custom", path)
110
121
 
111
122
  if merge_custom && custom_resource_exists?(custom_path) && !TwitterCldr.disable_custom_locale_resources
@@ -115,6 +126,10 @@ module TwitterCldr
115
126
  base
116
127
  end
117
128
 
129
+ def load_yaml(yaml, permitted_classes: [])
130
+ self.class.load_yaml(yaml, permitted_classes: permitted_classes)
131
+ end
132
+
118
133
  def load_marshalled_resource(path, _merge_custom = :unused)
119
134
  Marshal.load(read_resource_file(path))
120
135
  end
@@ -4,5 +4,5 @@
4
4
  # http://www.apache.org/licenses/LICENSE-2.0
5
5
 
6
6
  module TwitterCldr
7
- VERSION = '6.10.0'
7
+ VERSION = '6.11.0'
8
8
  end
@@ -69,7 +69,9 @@ describe TwitterCldr::Localized::LocalizedArray do
69
69
  describe "#to_yaml" do
70
70
  it "should be able to successfully roundtrip the array" do
71
71
  arr = [:foo, "bar", Object.new]
72
- result = YAML.load(arr.localize.to_yaml)
72
+ result = TwitterCldr::Resources::Loader.load_yaml(
73
+ arr.localize.to_yaml, permitted_classes: [Object, Symbol]
74
+ )
73
75
 
74
76
  expect(result[0]).to eq(:foo)
75
77
  expect(result[1]).to eq("bar")
@@ -9,7 +9,7 @@ describe TwitterCldr::Localized::LocalizedHash do
9
9
  describe "#to_yaml" do
10
10
  it "should be able to successfully roundtrip the hash" do
11
11
  hash = { foo: "bar", "string_key" => Object.new }
12
- result = YAML.load(hash.localize.to_yaml)
12
+ result = TwitterCldr::Resources::Loader.load_yaml(hash.localize.to_yaml, permitted_classes: [Object, Symbol])
13
13
 
14
14
  expect(result).to include(:foo)
15
15
  expect(result).to include("string_key")
@@ -345,7 +345,6 @@ describe TwitterCldr::Utils do
345
345
  :foo,
346
346
  1..10,
347
347
  /abc\nxyz/i,
348
- @struct,
349
348
  @klass,
350
349
  ]
351
350
  s.force_encoding("BINARY") if s.respond_to? :force_encoding
@@ -373,7 +372,7 @@ describe TwitterCldr::Utils do
373
372
  obj
374
373
  end
375
374
  y = TwitterCldr::Utils::YAML.dump(src, syck_compatible: true)
376
- r = YAML.load(y)
375
+ r = TwitterCldr::Resources::Loader.load_yaml(y, permitted_classes: [Date, Moo, Range, Regexp, Symbol, Time])
377
376
  expect(src).to eq(r)
378
377
  end
379
378
  end
@@ -402,7 +401,7 @@ describe TwitterCldr::Utils do
402
401
  {1=>-2, -1=>@gif, '_foo'=>'bar', 'ぬお-ぬお'=>321},
403
402
  ].each do |src|
404
403
  y = TwitterCldr::Utils::YAML.dump(src, syck_compatible: true)
405
- r = YAML.load(y)
404
+ r = TwitterCldr::Resources::Loader.load_yaml(y, permitted_classes: [Date, Range, Symbol, Time])
406
405
  expect(src).to eq(r)
407
406
  end
408
407
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: twitter_cldr
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.10.0
4
+ version: 6.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cameron Dutro
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-12-18 00:00:00.000000000 Z
11
+ date: 2021-12-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: camertron-eprun
@@ -3987,7 +3987,7 @@ homepage: https://twitter.com
3987
3987
  licenses:
3988
3988
  - Apache-2.0
3989
3989
  metadata: {}
3990
- post_install_message:
3990
+ post_install_message:
3991
3991
  rdoc_options: []
3992
3992
  require_paths:
3993
3993
  - lib
@@ -4002,8 +4002,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
4002
4002
  - !ruby/object:Gem::Version
4003
4003
  version: '0'
4004
4004
  requirements: []
4005
- rubygems_version: 3.2.22
4006
- signing_key:
4005
+ rubyforge_project:
4006
+ rubygems_version: 2.7.6.3
4007
+ signing_key:
4007
4008
  specification_version: 4
4008
4009
  summary: Ruby implementation of the ICU (International Components for Unicode) that
4009
4010
  uses the Common Locale Data Repository to format dates, plurals, and more.