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 +4 -4
- data/.github/workflows/release.yml +1 -0
- data/.github/workflows/ruby.yml +7 -1
- data/.ruby-version +1 -1
- data/.standard.yml +1 -0
- data/CHANGELOG.md +8 -0
- data/Gemfile +1 -1
- data/README.md +1 -1
- data/Rakefile +2 -2
- data/lib/yamload/conversion/hash.rb +2 -2
- data/lib/yamload/conversion/object.rb +2 -2
- data/lib/yamload/conversion.rb +3 -3
- data/lib/yamload/defaults/hash.rb +1 -1
- data/lib/yamload/defaults.rb +1 -1
- data/lib/yamload/loader.rb +8 -8
- data/lib/yamload/loading/yaml.rb +16 -9
- data/lib/yamload/loading.rb +1 -1
- data/lib/yamload/version.rb +1 -1
- data/lib/yamload.rb +2 -2
- data/spec/conversion_spec.rb +14 -14
- data/spec/fixtures/unsafe.yml +6 -0
- data/spec/loader_spec.rb +103 -91
- data/spec/spec_helper.rb +5 -5
- data/spec/support/coverage_loader.rb +3 -4
- data/yamload.gemspec +26 -28
- metadata +9 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 16ac85003b48e85dd2475a7ab87c43037cc953eb6d6c492fa95444dd9f09ba79
|
4
|
+
data.tar.gz: e50a8eb78728cc4975115c1474fa878080fb9ee745712e26dafffe6aeba41fa4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e847bceccbb83e3f880b78fc8c9ea7c88541583b2adb3b70e2c5ff263afb51b519bc12f6202cb39fce469d35d400a867955d8f9fa067116de96a63cf5bd3d47d
|
7
|
+
data.tar.gz: 8f9a9267907f7d1904afe7ba576aae7443da874b1a6b09f05a74c848938212d2bcf873ea573e8f5c0731fdeb12a79dbc252f68e3e8e068fe99e81a8cd9de60a3
|
data/.github/workflows/ruby.yml
CHANGED
@@ -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.
|
1
|
+
3.1.0
|
data/.standard.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby_version: 2.6
|
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
# Yamload
|
2
2
|
|
3
|
+
[](https://github.com/testdouble/standard)
|
3
4
|
[](http://badge.fury.io/rb/yamload)
|
4
5
|
[](https://github.com/sealink/yamload/actions)
|
5
6
|
[](https://coveralls.io/r/sealink/yamload)
|
6
|
-
[](https://codeclimate.com/github/sealink/yamload)
|
7
7
|
|
8
8
|
- YAML files loading
|
9
9
|
- Recursive conversion to immutable objects
|
data/Rakefile
CHANGED
data/lib/yamload/conversion.rb
CHANGED
data/lib/yamload/defaults.rb
CHANGED
data/lib/yamload/loader.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
5
|
-
|
6
|
-
require
|
7
|
-
require
|
8
|
-
require
|
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
|
data/lib/yamload/loading/yaml.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
|
-
require
|
2
|
-
require
|
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
|
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
|
-
|
30
|
-
|
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:
|
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,
|
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[
|
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[
|
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
|
|
data/lib/yamload/loading.rb
CHANGED
data/lib/yamload/version.rb
CHANGED
data/lib/yamload.rb
CHANGED
data/spec/conversion_spec.rb
CHANGED
@@ -1,34 +1,34 @@
|
|
1
|
-
require
|
1
|
+
require "spec_helper"
|
2
2
|
|
3
|
-
require
|
3
|
+
require "yamload/conversion"
|
4
4
|
|
5
5
|
describe Yamload::Conversion do
|
6
|
-
let(:number)
|
7
|
-
let(:string)
|
8
|
-
let(:array)
|
6
|
+
let(:number) { 42 }
|
7
|
+
let(:string) { "a string" }
|
8
|
+
let(:array) { [number, string] }
|
9
9
|
let(:hash) {
|
10
10
|
{
|
11
|
-
string:
|
12
|
-
array:
|
13
|
-
sub_hash: {
|
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
|
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
|
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
|
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
|
43
|
-
let(:converter)
|
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
|
53
|
+
specify { expect(immutable_object.sub_hash.something).to eq "else" }
|
54
54
|
end
|
55
55
|
end
|
data/spec/loader_spec.rb
CHANGED
@@ -1,56 +1,56 @@
|
|
1
|
-
require
|
1
|
+
require "spec_helper"
|
2
2
|
|
3
|
-
require
|
3
|
+
require "yamload"
|
4
4
|
|
5
5
|
describe Yamload::Loader do
|
6
|
-
let(:file)
|
7
|
-
let(:loader)
|
8
|
-
let(:content)
|
6
|
+
let(:file) { :test }
|
7
|
+
let(:loader) { Yamload::Loader.new(file) }
|
8
|
+
let(:content) { loader.content }
|
9
9
|
|
10
|
-
context
|
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,
|
12
|
+
specify { expect { content }.to raise_error IOError, "No yml files directory specified" }
|
13
13
|
end
|
14
14
|
|
15
|
-
context
|
16
|
-
let(:current_file_dir)
|
17
|
-
let(:invalid_dir)
|
18
|
-
let(:loader)
|
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
|
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,
|
25
|
+
specify { expect { content }.to raise_error IOError, "non_existing.yml could not be found" }
|
26
26
|
end
|
27
27
|
|
28
|
-
context
|
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,
|
31
|
+
specify { expect { content }.to raise_error IOError, "empty.yml is blank" }
|
32
32
|
end
|
33
33
|
|
34
|
-
context
|
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({
|
38
|
-
and_return(double(parameter: double(value:
|
39
|
-
allow_any_instance_of(Aws::SecretsManager::Client).to receive(:get_secret_value)
|
40
|
-
with({
|
41
|
-
and_return(double(secret_string:
|
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) { {
|
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
|
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({
|
53
|
-
and_raise(Aws::SSM::Errors::ParameterNotFound.new(Seahorse,
|
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
|
62
|
+
context "with a file defining an array" do
|
63
63
|
let(:file) { :array }
|
64
|
-
let(:expected_content) { %w
|
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
|
70
|
-
let(:defaults) { {
|
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
|
79
|
+
context "with a file defining a string" do
|
80
80
|
let(:file) { :string }
|
81
|
-
let(:expected_content) {
|
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
|
87
|
-
let(:defaults) { {
|
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
|
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
|
-
|
102
|
-
|
113
|
+
"test" => true,
|
114
|
+
"users" => [
|
103
115
|
{
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
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
|
-
|
126
|
+
"email" => "testy.tester@test.com"
|
115
127
|
},
|
116
128
|
{
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
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
|
-
|
139
|
+
"email" => "speccy.speccer@spec.com"
|
128
140
|
}
|
129
141
|
],
|
130
|
-
|
131
|
-
|
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)
|
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
|
142
|
-
specify { expect(content_obj.users[0].last_name).to eq
|
143
|
-
specify { expect(content_obj.users[0].address.address_line_1).to eq
|
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
|
146
|
-
specify { expect(content_obj.users[0].address.state).to eq
|
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
|
149
|
-
specify { expect(content_obj.users[0].email).to eq
|
150
|
-
specify { expect(content_obj.users[1].first_name).to eq
|
151
|
-
specify { expect(content_obj.users[1].last_name).to eq
|
152
|
-
specify { expect(content_obj.users[1].address.address_line_1).to eq
|
153
|
-
specify { expect(content_obj.users[1].address.address_line_2).to eq
|
154
|
-
specify { expect(content_obj.users[1].address.city).to eq
|
155
|
-
specify { expect(content_obj.users[1].address.state).to eq
|
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
|
158
|
-
specify { expect(content_obj.users[1].email).to eq
|
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
|
162
|
-
let(:new_user) { double(
|
163
|
-
specify
|
164
|
-
expect { content[
|
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[
|
178
|
+
expect(content["users"]).not_to include new_user
|
167
179
|
end
|
168
180
|
end
|
169
181
|
|
170
|
-
context
|
171
|
-
let(:new_user) { double(
|
172
|
-
specify
|
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
|
180
|
-
let(:defaults) {
|
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
|
199
|
+
context "when defaults are defined" do
|
188
200
|
let(:defaults) {
|
189
201
|
{
|
190
|
-
|
191
|
-
|
192
|
-
|
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
|
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(
|
1
|
+
$LOAD_PATH.unshift File.expand_path("../../lib", __FILE__)
|
2
2
|
|
3
|
-
require
|
3
|
+
require "support/coverage_loader"
|
4
4
|
|
5
|
-
require
|
5
|
+
require "yamload"
|
6
6
|
|
7
|
-
current_file_dir =
|
8
|
-
Yamload.dir = File.join(current_file_dir,
|
7
|
+
current_file_dir = __dir__
|
8
|
+
Yamload.dir = File.join(current_file_dir, "fixtures")
|
@@ -1,4 +1,3 @@
|
|
1
|
-
require
|
2
|
-
|
3
|
-
|
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
|
-
|
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
|
3
|
+
require "yamload/version"
|
5
4
|
|
6
5
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name
|
8
|
-
spec.version
|
9
|
-
spec.authors
|
10
|
-
spec.email
|
11
|
-
spec.summary
|
12
|
-
spec.description
|
13
|
-
spec.homepage
|
14
|
-
spec.license
|
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
|
17
|
-
spec.executables
|
18
|
-
spec.test_files
|
19
|
-
spec.require_paths = [
|
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 =
|
20
|
+
spec.required_ruby_version = ">= 2.6.0"
|
22
21
|
|
23
|
-
spec.add_dependency
|
24
|
-
spec.add_dependency
|
25
|
-
spec.add_dependency
|
26
|
-
spec.add_dependency
|
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
|
29
|
-
spec.add_development_dependency
|
30
|
-
spec.add_development_dependency
|
31
|
-
spec.add_development_dependency
|
32
|
-
spec.add_development_dependency
|
33
|
-
spec.add_development_dependency
|
34
|
-
spec.add_development_dependency
|
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.
|
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:
|
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:
|
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:
|
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:
|
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.
|
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
|