yamload 0.6.0 → 0.7.0

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: e3cf322ef0fa55679eca55cf9937cd0b9c3b310a40646f42389c66ebe4969810
4
- data.tar.gz: f7e354d8873308cb068bea2c212018bf10d5cdff6dc6a517feb3442f15cce6b7
3
+ metadata.gz: 16ac85003b48e85dd2475a7ab87c43037cc953eb6d6c492fa95444dd9f09ba79
4
+ data.tar.gz: e50a8eb78728cc4975115c1474fa878080fb9ee745712e26dafffe6aeba41fa4
5
5
  SHA512:
6
- metadata.gz: 9952ff4a1d5b3c43662ed6e541ba7871af7742f470ef22e60ea2bf3c825cd84da56abec00681f64c60cc55e400d18ed25566d6a11cdd0848f5d4f7d0f11e6777
7
- data.tar.gz: 87b81d3b1d8401a4ac27a236eb31a945c9c62de6bab4e9931d5f5bfd6ce61ebd784da9388f88e76e9c0541010f89d985a623e297ef4382e96d1103578f162929
6
+ metadata.gz: e847bceccbb83e3f880b78fc8c9ea7c88541583b2adb3b70e2c5ff263afb51b519bc12f6202cb39fce469d35d400a867955d8f9fa067116de96a63cf5bd3d47d
7
+ data.tar.gz: 8f9a9267907f7d1904afe7ba576aae7443da874b1a6b09f05a74c848938212d2bcf873ea573e8f5c0731fdeb12a79dbc252f68e3e8e068fe99e81a8cd9de60a3
@@ -17,6 +17,7 @@ jobs:
17
17
  - uses: ruby/setup-ruby@v1
18
18
  with:
19
19
  bundler-cache: true
20
+ - run: bundle exec standardrb
20
21
  - run: bundle exec rake
21
22
 
22
23
  release:
@@ -5,7 +5,7 @@ jobs:
5
5
  strategy:
6
6
  fail-fast: false
7
7
  matrix:
8
- ruby: ["2.6", "2.7", "3.0"]
8
+ ruby: ["2.6", "2.7", "3.0", "3.1"]
9
9
  runs-on: ubuntu-latest
10
10
  env:
11
11
  AWS_REGION: us-east-1
@@ -15,4 +15,10 @@ jobs:
15
15
  with:
16
16
  ruby-version: ${{ matrix.ruby }}
17
17
  bundler-cache: true
18
+ - run: bundle exec standardrb
18
19
  - run: bundle exec rake
20
+ - name: Coveralls
21
+ uses: coverallsapp/github-action@master
22
+ with:
23
+ github-token: ${{ secrets.GITHUB_TOKEN }}
24
+ path-to-lcov: coverage/lcov.info
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 3.0.0
1
+ 3.1.0
data/.standard.yml ADDED
@@ -0,0 +1 @@
1
+ ruby_version: 2.6
data/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ ## 0.7.1
2
+
3
+ - Fix incorrect tags
4
+
5
+ ## 0.7.0
6
+
7
+ - [PLAT-186] Add support for Ruby 3.1
8
+
1
9
  ## 0.6.0
2
10
 
3
11
  - [TT-8616] Update to build with github actions / ruby 3.0 / rails 6.1
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- source 'https://rubygems.org'
1
+ source "https://rubygems.org"
2
2
 
3
3
  # Specify your gem's dependencies in yamload.gemspec
4
4
  gemspec
data/README.md CHANGED
@@ -1,9 +1,9 @@
1
1
  # Yamload
2
2
 
3
+ [![Ruby Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://github.com/testdouble/standard)
3
4
  [![Gem Version](https://badge.fury.io/rb/yamload.svg)](http://badge.fury.io/rb/yamload)
4
5
  [![Build Status](https://github.com/sealink/yamload/workflows/Build%20and%20Test/badge.svg?branch=master)](https://github.com/sealink/yamload/actions)
5
6
  [![Coverage Status](https://coveralls.io/repos/sealink/yamload/badge.svg)](https://coveralls.io/r/sealink/yamload)
6
- [![Code Climate](https://codeclimate.com/github/sealink/yamload/badges/gpa.svg)](https://codeclimate.com/github/sealink/yamload)
7
7
 
8
8
  - YAML files loading
9
9
  - Recursive conversion to immutable objects
data/Rakefile CHANGED
@@ -1,5 +1,5 @@
1
- require 'bundler/gem_tasks'
2
- require 'rspec/core/rake_task'
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
3
 
4
4
  RSpec::Core::RakeTask.new(:spec)
5
5
 
@@ -1,5 +1,5 @@
1
- require 'facets/hash/rekey'
2
- require 'anima'
1
+ require "facets/hash/rekey"
2
+ require "anima"
3
3
 
4
4
  module Yamload
5
5
  module Conversion
@@ -1,5 +1,5 @@
1
- require 'facets/object/dup'
2
- require 'ice_nine'
1
+ require "facets/object/dup"
2
+ require "ice_nine"
3
3
 
4
4
  module Yamload
5
5
  module Conversion
@@ -3,6 +3,6 @@ module Yamload
3
3
  end
4
4
  end
5
5
 
6
- require 'yamload/conversion/array'
7
- require 'yamload/conversion/hash'
8
- require 'yamload/conversion/object'
6
+ require "yamload/conversion/array"
7
+ require "yamload/conversion/hash"
8
+ require "yamload/conversion/object"
@@ -1,4 +1,4 @@
1
- require 'facets/hash/deep_merge'
1
+ require "facets/hash/deep_merge"
2
2
 
3
3
  module Yamload
4
4
  module Defaults
@@ -3,4 +3,4 @@ module Yamload
3
3
  end
4
4
  end
5
5
 
6
- require 'yamload/defaults/hash'
6
+ require "yamload/defaults/hash"
@@ -1,11 +1,11 @@
1
- require 'yaml'
2
- require 'ice_nine'
3
- require 'aws-sdk-secretsmanager'
4
- require 'aws-sdk-ssm'
5
-
6
- require 'yamload/loading'
7
- require 'yamload/conversion'
8
- require 'yamload/defaults'
1
+ require "yaml"
2
+ require "ice_nine"
3
+ require "aws-sdk-secretsmanager"
4
+ require "aws-sdk-ssm"
5
+
6
+ require "yamload/loading"
7
+ require "yamload/conversion"
8
+ require "yamload/defaults"
9
9
 
10
10
  module Yamload
11
11
  class Loader
@@ -1,12 +1,12 @@
1
- require 'facets/kernel/blank'
2
- require 'ice_nine'
1
+ require "facets/kernel/blank"
2
+ require "ice_nine"
3
3
 
4
4
  module Yamload
5
5
  module Loading
6
6
  class Yaml
7
7
  def initialize(file, dir)
8
8
  @file = file
9
- @dir = dir
9
+ @dir = dir
10
10
  end
11
11
 
12
12
  def exist?
@@ -26,25 +26,32 @@ module Yamload
26
26
 
27
27
  def load
28
28
  fail IOError, "#{@file}.yml could not be found" unless exist?
29
- YAML.load(erb_parsed_content).tap do |content|
30
- fail IOError, "#{@file}.yml is blank" if content.blank?
29
+ source = erb_parsed_content
30
+ content = if YAML.respond_to?(:unsafe_load)
31
+ YAML.unsafe_load(source)
32
+ else
33
+ # rubocop:disable Security::YAMLLoad
34
+ YAML.load(source)
35
+ # rubocop:enable Security::YAMLLoad
31
36
  end
37
+ fail IOError, "#{@file}.yml is blank" if content.blank?
38
+ content
32
39
  end
33
40
 
34
41
  def erb_parsed_content
35
- raw_content = File.read(filepath, encoding: 'bom|utf-8', mode: 'r')
42
+ raw_content = File.read(filepath, encoding: "bom|utf-8", mode: "r")
36
43
  ERB.new(raw_content).result(binding)
37
44
  end
38
45
 
39
46
  def filepath
40
- fail IOError, 'No yml files directory specified' if @dir.nil?
47
+ fail IOError, "No yml files directory specified" if @dir.nil?
41
48
  fail IOError, "#{@dir} is not a valid directory" unless File.directory?(@dir)
42
49
  File.join(@dir, "#{@file}.yml")
43
50
  end
44
51
 
45
52
  def secrets_client
46
53
  options = {}
47
- options[:endpoint] = ENV['AWS_SECRETS_MANAGER_ENDPOINT'] if ENV.has_key?('AWS_SECRETS_MANAGER_ENDPOINT')
54
+ options[:endpoint] = ENV["AWS_SECRETS_MANAGER_ENDPOINT"] if ENV.has_key?("AWS_SECRETS_MANAGER_ENDPOINT")
48
55
  @secrets_client ||= Aws::SecretsManager::Client.new(options)
49
56
  end
50
57
 
@@ -54,7 +61,7 @@ module Yamload
54
61
 
55
62
  def ssm_client
56
63
  options = {}
57
- options[:endpoint] = ENV['AWS_SSM_ENDPOINT'] if ENV.has_key?('AWS_SSM_ENDPOINT')
64
+ options[:endpoint] = ENV["AWS_SSM_ENDPOINT"] if ENV.has_key?("AWS_SSM_ENDPOINT")
58
65
  @ssm_client ||= Aws::SSM::Client.new(options)
59
66
  end
60
67
 
@@ -3,4 +3,4 @@ module Yamload
3
3
  end
4
4
  end
5
5
 
6
- require 'yamload/loading/yaml'
6
+ require "yamload/loading/yaml"
@@ -1,3 +1,3 @@
1
1
  module Yamload
2
- VERSION = '0.6.0'
2
+ VERSION = "0.7.0"
3
3
  end
data/lib/yamload.rb CHANGED
@@ -1,4 +1,4 @@
1
- require 'yamload/version'
1
+ require "yamload/version"
2
2
 
3
3
  module Yamload
4
4
  class << self
@@ -6,4 +6,4 @@ module Yamload
6
6
  end
7
7
  end
8
8
 
9
- require 'yamload/loader'
9
+ require "yamload/loader"
@@ -1,34 +1,34 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
- require 'yamload/conversion'
3
+ require "yamload/conversion"
4
4
 
5
5
  describe Yamload::Conversion do
6
- let(:number) { 42 }
7
- let(:string) { 'a string' }
8
- let(:array) { [number, string] }
6
+ let(:number) { 42 }
7
+ let(:string) { "a string" }
8
+ let(:array) { [number, string] }
9
9
  let(:hash) {
10
10
  {
11
- string: string,
12
- array: array,
13
- sub_hash: { something: 'else' }
11
+ string: string,
12
+ array: array,
13
+ sub_hash: {something: "else"}
14
14
  }
15
15
  }
16
16
 
17
17
  subject!(:immutable_object) { converter.to_immutable }
18
18
 
19
- context 'when converting a number' do
19
+ context "when converting a number" do
20
20
  let(:converter) { Yamload::Conversion::Object.new(number) }
21
21
  specify { is_expected.to eq number }
22
22
  end
23
23
 
24
- context 'when converting a string' do
24
+ context "when converting a string" do
25
25
  let(:converter) { Yamload::Conversion::Object.new(string) }
26
26
  specify { expect(string).not_to be_frozen }
27
27
  specify { is_expected.to be_frozen }
28
28
  specify { is_expected.to eq string }
29
29
  end
30
30
 
31
- context 'when converting an array' do
31
+ context "when converting an array" do
32
32
  let(:converter) { Yamload::Conversion::Object.new(array) }
33
33
  specify { expect(array).not_to be_frozen }
34
34
  specify { is_expected.to be_frozen }
@@ -39,8 +39,8 @@ describe Yamload::Conversion do
39
39
  specify { expect(immutable_object[1]).to eq string }
40
40
  end
41
41
 
42
- context 'when converting a hash' do
43
- let(:converter) { Yamload::Conversion::Object.new(hash) }
42
+ context "when converting a hash" do
43
+ let(:converter) { Yamload::Conversion::Object.new(hash) }
44
44
  specify { expect(hash).not_to be_frozen }
45
45
  specify { is_expected.to be_frozen }
46
46
  specify { expect(immutable_object.string).to eq string }
@@ -50,6 +50,6 @@ describe Yamload::Conversion do
50
50
  specify { expect(immutable_object.array[1]).to eq string }
51
51
  specify { expect(immutable_object.sub_hash).to be_frozen }
52
52
  specify { expect(immutable_object.sub_hash.something).to be_frozen }
53
- specify { expect(immutable_object.sub_hash.something).to eq 'else' }
53
+ specify { expect(immutable_object.sub_hash.something).to eq "else" }
54
54
  end
55
55
  end
@@ -0,0 +1,6 @@
1
+ defaults: &defaults
2
+ adapter: mysql2
3
+
4
+ development:
5
+ <<: *defaults
6
+ adapter: 'sqlite'
data/spec/loader_spec.rb CHANGED
@@ -1,56 +1,56 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
- require 'yamload'
3
+ require "yamload"
4
4
 
5
5
  describe Yamload::Loader do
6
- let(:file) { :test }
7
- let(:loader) { Yamload::Loader.new(file) }
8
- let(:content) { loader.content }
6
+ let(:file) { :test }
7
+ let(:loader) { Yamload::Loader.new(file) }
8
+ let(:content) { loader.content }
9
9
 
10
- context 'if the directory is not specified' do
10
+ context "if the directory is not specified" do
11
11
  let(:loader) { Yamload::Loader.new(file, nil) }
12
- specify { expect { content }.to raise_error IOError, 'No yml files directory specified' }
12
+ specify { expect { content }.to raise_error IOError, "No yml files directory specified" }
13
13
  end
14
14
 
15
- context 'if the directory is invalid' do
16
- let(:current_file_dir) { File.expand_path(File.dirname(__FILE__)) }
17
- let(:invalid_dir) { File.join(current_file_dir, 'invalid') }
18
- let(:loader) { Yamload::Loader.new(file, invalid_dir) }
15
+ context "if the directory is invalid" do
16
+ let(:current_file_dir) { __dir__ }
17
+ let(:invalid_dir) { File.join(current_file_dir, "invalid") }
18
+ let(:loader) { Yamload::Loader.new(file, invalid_dir) }
19
19
  specify { expect { content }.to raise_error IOError, "#{invalid_dir} is not a valid directory" }
20
20
  end
21
21
 
22
- context 'with a non existing file' do
22
+ context "with a non existing file" do
23
23
  let(:file) { :non_existing }
24
24
  specify { expect(loader).not_to exist }
25
- specify { expect { content }.to raise_error IOError, 'non_existing.yml could not be found' }
25
+ specify { expect { content }.to raise_error IOError, "non_existing.yml could not be found" }
26
26
  end
27
27
 
28
- context 'with an empty file' do
28
+ context "with an empty file" do
29
29
  let(:file) { :empty }
30
30
  specify { expect(loader).to exist }
31
- specify { expect { content }.to raise_error IOError, 'empty.yml is blank' }
31
+ specify { expect { content }.to raise_error IOError, "empty.yml is blank" }
32
32
  end
33
33
 
34
- context 'with a file containing ERB' do
34
+ context "with a file containing ERB" do
35
35
  before do
36
- allow_any_instance_of(Aws::SSM::Client).to receive(:get_parameter).
37
- with({ name: 'ssm_var', with_decryption: true }).
38
- and_return(double(parameter: double(value: 'SSM SUCCESS')))
39
- allow_any_instance_of(Aws::SecretsManager::Client).to receive(:get_secret_value).
40
- with({ secret_id: 'secret_var' }).
41
- and_return(double(secret_string: 'SECRET SUCCESS'))
36
+ allow_any_instance_of(Aws::SSM::Client).to receive(:get_parameter)
37
+ .with({name: "ssm_var", with_decryption: true})
38
+ .and_return(double(parameter: double(value: "SSM SUCCESS")))
39
+ allow_any_instance_of(Aws::SecretsManager::Client).to receive(:get_secret_value)
40
+ .with({secret_id: "secret_var"})
41
+ .and_return(double(secret_string: "SECRET SUCCESS"))
42
42
  end
43
43
 
44
44
  let(:file) { :erb }
45
- let(:expected_content) { { "erb_var" => "ERB RAN!", "ssm_var" => "SSM SUCCESS", "secret_var" => "SECRET SUCCESS" } }
45
+ let(:expected_content) { {"erb_var" => "ERB RAN!", "ssm_var" => "SSM SUCCESS", "secret_var" => "SECRET SUCCESS"} }
46
46
  specify { expect(loader).to exist }
47
47
  specify { expect(content).to eq expected_content }
48
48
 
49
- context 'with bad parameter key' do
49
+ context "with bad parameter key" do
50
50
  before do
51
- allow_any_instance_of(Aws::SSM::Client).to receive(:get_parameter).
52
- with({ name: 'bad_key', with_decryption: true }).
53
- and_raise(Aws::SSM::Errors::ParameterNotFound.new(Seahorse, 'bad_key'))
51
+ allow_any_instance_of(Aws::SSM::Client).to receive(:get_parameter)
52
+ .with({name: "bad_key", with_decryption: true})
53
+ .and_raise(Aws::SSM::Errors::ParameterNotFound.new(Seahorse, "bad_key"))
54
54
  end
55
55
  let(:file) { :erb_bad }
56
56
  specify {
@@ -59,15 +59,15 @@ describe Yamload::Loader do
59
59
  end
60
60
  end
61
61
 
62
- context 'with a file defining an array' do
62
+ context "with a file defining an array" do
63
63
  let(:file) { :array }
64
- let(:expected_content) { %w(first second third) }
64
+ let(:expected_content) { %w[first second third] }
65
65
  specify { expect(loader).to exist }
66
66
  specify { expect { content }.not_to raise_error }
67
67
  specify { expect(content).to eq expected_content }
68
68
 
69
- context 'when defaults are defined' do
70
- let(:defaults) { { test: true } }
69
+ context "when defaults are defined" do
70
+ let(:defaults) { {test: true} }
71
71
  before { loader.defaults = defaults }
72
72
  specify {
73
73
  expect { content }
@@ -76,15 +76,15 @@ describe Yamload::Loader do
76
76
  end
77
77
  end
78
78
 
79
- context 'with a file defining a string' do
79
+ context "with a file defining a string" do
80
80
  let(:file) { :string }
81
- let(:expected_content) { '1 first 2 second 3 third' }
81
+ let(:expected_content) { "1 first 2 second 3 third" }
82
82
  specify { expect(loader).to exist }
83
83
  specify { expect { content }.not_to raise_error }
84
84
  specify { expect(content).to eq expected_content }
85
85
 
86
- context 'when defaults are defined' do
87
- let(:defaults) { { test: true } }
86
+ context "when defaults are defined" do
87
+ let(:defaults) { {test: true} }
88
88
  before { loader.defaults = defaults }
89
89
  specify {
90
90
  expect { content }
@@ -93,103 +93,115 @@ describe Yamload::Loader do
93
93
  end
94
94
  end
95
95
 
96
- context 'with a file defining a hash' do
96
+ context "with an unsafe configuration" do
97
+ let(:file) { :unsafe }
98
+ let(:expected_content) {
99
+ {
100
+ "defaults" => {"adapter" => "mysql2"},
101
+ "development" => {"adapter" => "sqlite"}
102
+ }
103
+ }
104
+
105
+ specify { expect(content).to eq expected_content }
106
+ end
107
+
108
+ context "with a file defining a hash" do
97
109
  specify { expect(loader).to exist }
98
110
 
99
111
  let(:expected_content) {
100
112
  {
101
- 'test' => true,
102
- 'users' => [
113
+ "test" => true,
114
+ "users" => [
103
115
  {
104
- 'first_name' => 'Testy',
105
- 'last_name' => 'Tester',
106
- 'address' => {
107
- 'address_line_1' => '1 Test Avenue',
108
- 'address_line_2' => nil,
109
- 'city' => 'Testville',
110
- 'state' => 'TST',
111
- 'post_code' => 1234,
112
- 'country' => 'Testalia'
116
+ "first_name" => "Testy",
117
+ "last_name" => "Tester",
118
+ "address" => {
119
+ "address_line_1" => "1 Test Avenue",
120
+ "address_line_2" => nil,
121
+ "city" => "Testville",
122
+ "state" => "TST",
123
+ "post_code" => 1234,
124
+ "country" => "Testalia"
113
125
  },
114
- 'email' => 'testy.tester@test.com'
126
+ "email" => "testy.tester@test.com"
115
127
  },
116
128
  {
117
- 'first_name' => 'Speccy',
118
- 'last_name' => 'Speccer',
119
- 'address' => {
120
- 'address_line_1' => 'Unit 1',
121
- 'address_line_2' => '42 Spec Street',
122
- 'city' => 'Specwood',
123
- 'state' => 'SPC',
124
- 'post_code' => 5678,
125
- 'country' => 'Specland'
129
+ "first_name" => "Speccy",
130
+ "last_name" => "Speccer",
131
+ "address" => {
132
+ "address_line_1" => "Unit 1",
133
+ "address_line_2" => "42 Spec Street",
134
+ "city" => "Specwood",
135
+ "state" => "SPC",
136
+ "post_code" => 5678,
137
+ "country" => "Specland"
126
138
  },
127
- 'email' => 'speccy.speccer@spec.com'
139
+ "email" => "speccy.speccer@spec.com"
128
140
  }
129
141
  ],
130
- 'settings' => {
131
- 'remote_access' => true
142
+ "settings" => {
143
+ "remote_access" => true
132
144
  }
133
145
  }
134
146
  }
135
147
 
136
148
  specify { expect(content).to eq expected_content }
137
149
 
138
- let(:content_obj) { loader.obj }
150
+ let(:content_obj) { loader.obj }
139
151
 
140
152
  specify { expect(content_obj.test).to eq true }
141
- specify { expect(content_obj.users[0].first_name).to eq 'Testy' }
142
- specify { expect(content_obj.users[0].last_name).to eq 'Tester' }
143
- specify { expect(content_obj.users[0].address.address_line_1).to eq '1 Test Avenue' }
153
+ specify { expect(content_obj.users[0].first_name).to eq "Testy" }
154
+ specify { expect(content_obj.users[0].last_name).to eq "Tester" }
155
+ specify { expect(content_obj.users[0].address.address_line_1).to eq "1 Test Avenue" }
144
156
  specify { expect(content_obj.users[0].address.address_line_2).to eq nil }
145
- specify { expect(content_obj.users[0].address.city).to eq 'Testville' }
146
- specify { expect(content_obj.users[0].address.state).to eq 'TST' }
157
+ specify { expect(content_obj.users[0].address.city).to eq "Testville" }
158
+ specify { expect(content_obj.users[0].address.state).to eq "TST" }
147
159
  specify { expect(content_obj.users[0].address.post_code).to eq 1234 }
148
- specify { expect(content_obj.users[0].address.country).to eq 'Testalia' }
149
- specify { expect(content_obj.users[0].email).to eq 'testy.tester@test.com' }
150
- specify { expect(content_obj.users[1].first_name).to eq 'Speccy' }
151
- specify { expect(content_obj.users[1].last_name).to eq 'Speccer' }
152
- specify { expect(content_obj.users[1].address.address_line_1).to eq 'Unit 1' }
153
- specify { expect(content_obj.users[1].address.address_line_2).to eq '42 Spec Street' }
154
- specify { expect(content_obj.users[1].address.city).to eq 'Specwood' }
155
- specify { expect(content_obj.users[1].address.state).to eq 'SPC' }
160
+ specify { expect(content_obj.users[0].address.country).to eq "Testalia" }
161
+ specify { expect(content_obj.users[0].email).to eq "testy.tester@test.com" }
162
+ specify { expect(content_obj.users[1].first_name).to eq "Speccy" }
163
+ specify { expect(content_obj.users[1].last_name).to eq "Speccer" }
164
+ specify { expect(content_obj.users[1].address.address_line_1).to eq "Unit 1" }
165
+ specify { expect(content_obj.users[1].address.address_line_2).to eq "42 Spec Street" }
166
+ specify { expect(content_obj.users[1].address.city).to eq "Specwood" }
167
+ specify { expect(content_obj.users[1].address.state).to eq "SPC" }
156
168
  specify { expect(content_obj.users[1].address.post_code).to eq 5678 }
157
- specify { expect(content_obj.users[1].address.country).to eq 'Specland' }
158
- specify { expect(content_obj.users[1].email).to eq 'speccy.speccer@spec.com' }
169
+ specify { expect(content_obj.users[1].address.country).to eq "Specland" }
170
+ specify { expect(content_obj.users[1].email).to eq "speccy.speccer@spec.com" }
159
171
  specify { expect(content_obj.settings.remote_access).to eq true }
160
172
 
161
- context 'when trying to modify the loaded hash' do
162
- let(:new_user) { double('new user') }
163
- specify 'the hash should be immutable' do
164
- expect { content['users'] << new_user }
173
+ context "when trying to modify the loaded hash" do
174
+ let(:new_user) { double("new user") }
175
+ specify "the hash should be immutable" do
176
+ expect { content["users"] << new_user }
165
177
  .to raise_error RuntimeError, /can't modify frozen Array/i
166
- expect(content['users']).not_to include new_user
178
+ expect(content["users"]).not_to include new_user
167
179
  end
168
180
  end
169
181
 
170
- context 'when trying to modify the content object' do
171
- let(:new_user) { double('new user') }
172
- specify 'the object should be immutable' do
182
+ context "when trying to modify the content object" do
183
+ let(:new_user) { double("new user") }
184
+ specify "the object should be immutable" do
173
185
  expect { content_obj.users << new_user }
174
186
  .to raise_error RuntimeError, /can't modify frozen Array/i
175
187
  expect(content_obj.users).not_to include new_user
176
188
  end
177
189
  end
178
190
 
179
- context 'when the defaults object is not a hash' do
180
- let(:defaults) { 'not a hash' }
191
+ context "when the defaults object is not a hash" do
192
+ let(:defaults) { "not a hash" }
181
193
  specify {
182
194
  expect { loader.defaults = defaults }
183
195
  .to raise_error ArgumentError, "#{defaults} is not a hash"
184
196
  }
185
197
  end
186
198
 
187
- context 'when defaults are defined' do
199
+ context "when defaults are defined" do
188
200
  let(:defaults) {
189
201
  {
190
- 'settings' => {
191
- 'remember_user' => false,
192
- 'remote_access' => false
202
+ "settings" => {
203
+ "remember_user" => false,
204
+ "remote_access" => false
193
205
  }
194
206
  }
195
207
  }
@@ -203,7 +215,7 @@ describe Yamload::Loader do
203
215
  specify { expect(content_obj.settings.remote_access).to eq true }
204
216
  end
205
217
 
206
- context 'when reloading' do
218
+ context "when reloading" do
207
219
  let(:original_hash) { loader.content }
208
220
  before do
209
221
  original_hash
data/spec/spec_helper.rb CHANGED
@@ -1,8 +1,8 @@
1
- $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
1
+ $LOAD_PATH.unshift File.expand_path("../../lib", __FILE__)
2
2
 
3
- require 'support/coverage_loader'
3
+ require "support/coverage_loader"
4
4
 
5
- require 'yamload'
5
+ require "yamload"
6
6
 
7
- current_file_dir = File.expand_path(File.dirname(__FILE__))
8
- Yamload.dir = File.join(current_file_dir, 'fixtures')
7
+ current_file_dir = __dir__
8
+ Yamload.dir = File.join(current_file_dir, "fixtures")
@@ -1,4 +1,3 @@
1
- require 'simplecov-rcov'
2
- require 'coveralls'
3
- require 'coverage/kit'
4
- Coverage::Kit.setup(minimum_coverage: 100)
1
+ require "coverage/kit"
2
+
3
+ Coverage::Kit.setup(minimum_coverage: 99.0)
data/yamload.gemspec CHANGED
@@ -1,36 +1,34 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
1
+ lib = File.expand_path("../lib", __FILE__)
3
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'yamload/version'
3
+ require "yamload/version"
5
4
 
6
5
  Gem::Specification.new do |spec|
7
- spec.name = 'yamload'
8
- spec.version = Yamload::VERSION
9
- spec.authors = ['Alessandro Berardi', 'Adam Davies']
10
- spec.email = ['berardialessandro@gmail.com', 'adzdavies@gmail.com']
11
- spec.summary = 'YAML files loader'
12
- spec.description = 'YAML files loader with validation'
13
- spec.homepage = ''
14
- spec.license = 'MIT'
6
+ spec.name = "yamload"
7
+ spec.version = Yamload::VERSION
8
+ spec.authors = ["Alessandro Berardi", "Adam Davies"]
9
+ spec.email = ["berardialessandro@gmail.com", "adzdavies@gmail.com"]
10
+ spec.summary = "YAML files loader"
11
+ spec.description = "YAML files loader with validation"
12
+ spec.homepage = ""
13
+ spec.license = "MIT"
15
14
 
16
- spec.files = `git ls-files -z`.split("\x0")
17
- spec.executables = spec.files.grep(/^bin\//) { |f| File.basename(f) }
18
- spec.test_files = spec.files.grep(/^(test|spec|features)\//)
19
- spec.require_paths = ['lib']
15
+ spec.files = `git ls-files -z`.split("\x0")
16
+ spec.executables = spec.files.grep(/^bin\//) { |f| File.basename(f) }
17
+ spec.test_files = spec.files.grep(/^(test|spec|features)\//)
18
+ spec.require_paths = ["lib"]
20
19
 
21
- spec.required_ruby_version = '>= 2.6.0'
20
+ spec.required_ruby_version = ">= 2.6.0"
22
21
 
23
- spec.add_dependency 'anima', '>= 0.2'
24
- spec.add_dependency 'facets', '>= 3.0'
25
- spec.add_dependency 'aws-sdk-secretsmanager'
26
- spec.add_dependency 'aws-sdk-ssm'
22
+ spec.add_dependency "anima", ">= 0.2"
23
+ spec.add_dependency "facets", ">= 3.0"
24
+ spec.add_dependency "aws-sdk-secretsmanager"
25
+ spec.add_dependency "aws-sdk-ssm"
27
26
 
28
- spec.add_development_dependency 'bundler', '>= 1.7'
29
- spec.add_development_dependency 'rake', '>= 10.0'
30
- spec.add_development_dependency 'rspec', '>= 3.2'
31
- spec.add_development_dependency 'coverage-kit'
32
- spec.add_development_dependency 'simplecov-rcov', '>= 0.2'
33
- spec.add_development_dependency 'coveralls'
34
- spec.add_development_dependency 'rubocop'
35
- spec.add_development_dependency 'pry-byebug'
27
+ spec.add_development_dependency "bundler", ">= 1.7"
28
+ spec.add_development_dependency "rake", ">= 10.0"
29
+ spec.add_development_dependency "rspec", ">= 3.2"
30
+ spec.add_development_dependency "coverage-kit"
31
+ spec.add_development_dependency "rubocop"
32
+ spec.add_development_dependency "pry-byebug"
33
+ spec.add_development_dependency "standard"
36
34
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yamload
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alessandro Berardi
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2021-01-06 00:00:00.000000000 Z
12
+ date: 2022-01-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: anima
@@ -124,21 +124,7 @@ dependencies:
124
124
  - !ruby/object:Gem::Version
125
125
  version: '0'
126
126
  - !ruby/object:Gem::Dependency
127
- name: simplecov-rcov
128
- requirement: !ruby/object:Gem::Requirement
129
- requirements:
130
- - - ">="
131
- - !ruby/object:Gem::Version
132
- version: '0.2'
133
- type: :development
134
- prerelease: false
135
- version_requirements: !ruby/object:Gem::Requirement
136
- requirements:
137
- - - ">="
138
- - !ruby/object:Gem::Version
139
- version: '0.2'
140
- - !ruby/object:Gem::Dependency
141
- name: coveralls
127
+ name: rubocop
142
128
  requirement: !ruby/object:Gem::Requirement
143
129
  requirements:
144
130
  - - ">="
@@ -152,7 +138,7 @@ dependencies:
152
138
  - !ruby/object:Gem::Version
153
139
  version: '0'
154
140
  - !ruby/object:Gem::Dependency
155
- name: rubocop
141
+ name: pry-byebug
156
142
  requirement: !ruby/object:Gem::Requirement
157
143
  requirements:
158
144
  - - ">="
@@ -166,7 +152,7 @@ dependencies:
166
152
  - !ruby/object:Gem::Version
167
153
  version: '0'
168
154
  - !ruby/object:Gem::Dependency
169
- name: pry-byebug
155
+ name: standard
170
156
  requirement: !ruby/object:Gem::Requirement
171
157
  requirements:
172
158
  - - ">="
@@ -194,6 +180,7 @@ files:
194
180
  - ".rspec"
195
181
  - ".rubocop.yml"
196
182
  - ".ruby-version"
183
+ - ".standard.yml"
197
184
  - CHANGELOG.md
198
185
  - Gemfile
199
186
  - LICENSE.txt
@@ -217,6 +204,7 @@ files:
217
204
  - spec/fixtures/erb_bad.yml
218
205
  - spec/fixtures/string.yml
219
206
  - spec/fixtures/test.yml
207
+ - spec/fixtures/unsafe.yml
220
208
  - spec/loader_spec.rb
221
209
  - spec/spec_helper.rb
222
210
  - spec/support/coverage_loader.rb
@@ -240,7 +228,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
240
228
  - !ruby/object:Gem::Version
241
229
  version: '0'
242
230
  requirements: []
243
- rubygems_version: 3.2.3
231
+ rubygems_version: 3.3.3
244
232
  signing_key:
245
233
  specification_version: 4
246
234
  summary: YAML files loader
@@ -252,6 +240,7 @@ test_files:
252
240
  - spec/fixtures/erb_bad.yml
253
241
  - spec/fixtures/string.yml
254
242
  - spec/fixtures/test.yml
243
+ - spec/fixtures/unsafe.yml
255
244
  - spec/loader_spec.rb
256
245
  - spec/spec_helper.rb
257
246
  - spec/support/coverage_loader.rb