yamload 0.5.0 → 0.8.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: 4fdcbfb71834348eec7d1a41a9083dcfb84918b564702b6ebc32ac3f69a81dbd
4
- data.tar.gz: 9c5859db3d1e10209540447671fa67f7fac5551bd0c0352216df5afd6597029b
3
+ metadata.gz: e758b62515b04c2077aaf86f11c984d4420d4554ae2949ea42a26a74b7a51058
4
+ data.tar.gz: f81d42230bcf5e724a942681d3a41be87ebd8bde1324d19527d5439edfd16a21
5
5
  SHA512:
6
- metadata.gz: 17cbf7b431ef2820ff545507bda639713ba2173af7286637be94b7a8820862353b50264933abef8e9d81970dda432b8823dd24292d1b2a1b67f1417fd92de4df
7
- data.tar.gz: 36f0e38afbf4817d6a3437bcabbfa9cf73c8f6d6f929dba548371ab13427e1c3aaef7e7fc703555b0f81e4cfd97ba9113118b3cd31fd0ee53ad5bd307ce56d18
6
+ metadata.gz: a8b86f003e03b652f37ceb35cac2d85c56392da63ade3331477d59b5ecb010b69001bc9f61227f0a2fb0006123869bbea18cfce8b19eb528c623c78b73317461
7
+ data.tar.gz: c4939e33a6d673ac6a9dd527305e51b7e0b1cf47dc66de9ff11b9ef320c7d804401c3d587c41e2d4d5c49419ca961421d2bbe639c2fbc1088fdca191c3c70d48
@@ -0,0 +1,6 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: "bundler"
4
+ directory: "/"
5
+ schedule:
6
+ interval: "daily"
@@ -0,0 +1,62 @@
1
+ name: Release
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - "v*"
7
+
8
+ jobs:
9
+ build:
10
+ name: Build
11
+ runs-on: ubuntu-latest
12
+ env:
13
+ AWS_REGION: us-east-1
14
+ steps:
15
+ - name: Checkout
16
+ uses: actions/checkout@v2
17
+ - uses: ruby/setup-ruby@v1
18
+ with:
19
+ bundler-cache: true
20
+ - run: bundle exec standardrb
21
+ - run: bundle exec rake
22
+
23
+ release:
24
+ needs: build
25
+ name: Release
26
+ runs-on: ubuntu-latest
27
+ steps:
28
+ - name: Checkout
29
+ uses: actions/checkout@v2
30
+
31
+ - name: Generate Changelog
32
+ run: |
33
+ # Get version from github ref (remove 'refs/tags/' and prefix 'v')
34
+ version="${GITHUB_REF#refs/tags/v}"
35
+ npx changelog-parser CHANGELOG.md | jq -cr ".versions | .[] | select(.version == \"$version\") | .body" > ${{ github.workflow }}-CHANGELOG.txt
36
+
37
+ - name: Release
38
+ uses: softprops/action-gh-release@v1
39
+ with:
40
+ body_path: ${{ github.workflow }}-CHANGELOG.txt
41
+ env:
42
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
43
+
44
+ publish:
45
+ needs: [build, release]
46
+ name: Publish
47
+ runs-on: ubuntu-latest
48
+
49
+ steps:
50
+ - uses: actions/checkout@v2
51
+ - uses: ruby/setup-ruby@v1
52
+
53
+ - name: Publish to RubyGems
54
+ run: |
55
+ mkdir -p $HOME/.gem
56
+ touch $HOME/.gem/credentials
57
+ chmod 0600 $HOME/.gem/credentials
58
+ printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
59
+ gem build *.gemspec
60
+ gem push *.gem
61
+ env:
62
+ GEM_HOST_API_KEY: "${{secrets.RUBYGEMS_AUTH_TOKEN}}"
@@ -0,0 +1,24 @@
1
+ name: Build and Test
2
+ on: [push, pull_request]
3
+ jobs:
4
+ test:
5
+ strategy:
6
+ fail-fast: false
7
+ matrix:
8
+ ruby: ["2.6", "2.7", "3.0", "3.1"]
9
+ runs-on: ubuntu-latest
10
+ env:
11
+ AWS_REGION: us-east-1
12
+ steps:
13
+ - uses: actions/checkout@v2
14
+ - uses: ruby/setup-ruby@v1
15
+ with:
16
+ ruby-version: ${{ matrix.ruby }}
17
+ bundler-cache: true
18
+ - run: bundle exec standardrb
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
- 2.7.1
1
+ 3.1.0
data/.standard.yml ADDED
@@ -0,0 +1 @@
1
+ ruby_version: 2.6
data/CHANGELOG.md CHANGED
@@ -1,3 +1,19 @@
1
+ ## 0.8.0
2
+
3
+ - [PLAT-379] Improve bundler startup time
4
+
5
+ ## 0.7.1
6
+
7
+ - Fix incorrect tags
8
+
9
+ ## 0.7.0
10
+
11
+ - [PLAT-186] Add support for Ruby 3.1
12
+
13
+ ## 0.6.0
14
+
15
+ - [TT-8616] Update to build with github actions / ruby 3.0 / rails 6.1
16
+
1
17
  ## 0.5.0 (2020-07-02)
2
18
 
3
19
  - [TT-7683] Add support for AWS SSM and AWS Secrets Manager
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,14 +1,13 @@
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
- [![Build Status](https://travis-ci.org/sealink/yamload.svg?branch=master)](https://travis-ci.org/sealink/yamload)
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
- [![Dependency Status](https://gemnasium.com/sealink/yamload.svg)](https://gemnasium.com/sealink/yamload)
7
- [![Code Climate](https://codeclimate.com/github/sealink/yamload/badges/gpa.svg)](https://codeclimate.com/github/sealink/yamload)
8
7
 
9
- * YAML files loading
10
- * Recursive conversion to immutable objects
11
- * Default values
8
+ - YAML files loading
9
+ - Recursive conversion to immutable objects
10
+ - Default values
12
11
 
13
12
  ## Installation
14
13
 
@@ -29,17 +28,20 @@ Or install it yourself as:
29
28
  ## Usage
30
29
 
31
30
  Set up the YAML files directory
31
+
32
32
  ```ruby
33
33
  Yamload.dir = File.join(File.dirname(File.expand_path(__FILE__)),'config')
34
34
  ```
35
35
 
36
36
  e.g. config/test.yml
37
+
37
38
  ```yaml
38
39
  ---
39
40
  test: true
40
41
  ```
41
42
 
42
43
  Load YAML files from the directory and access keys
44
+
43
45
  ```ruby
44
46
  # Load config/test.yml
45
47
  loader = Yamload::Loader.new(:test)
@@ -50,10 +52,24 @@ loader.obj.attribute
50
52
  ```
51
53
 
52
54
  Define defaults
55
+
53
56
  ```ruby
54
57
  loader.defaults = { 'test' => true , 'coverage' => { 'minimum' => 0.95 } }
55
58
  ```
56
59
 
60
+ ## Release
61
+
62
+ To publish a new version of this gem the following steps must be taken.
63
+
64
+ * Update the version in the following files
65
+ ```
66
+ CHANGELOG.md
67
+ lib/yamload/version.rb
68
+ ````
69
+ * Create a tag using the format v0.1.0
70
+ * Follow build progress in GitHub actions
71
+
72
+
57
73
  ## Contributing
58
74
 
59
75
  1. Fork it ( https://github.com/sealink/yamload/fork )
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,8 @@
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 "yamload/loading"
4
+ require "yamload/conversion"
5
+ require "yamload/defaults"
9
6
 
10
7
  module Yamload
11
8
  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,33 @@ 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
53
+ require "aws-sdk-secretsmanager"
46
54
  options = {}
47
- options[:endpoint] = ENV['AWS_SECRETS_MANAGER_ENDPOINT'] if ENV.has_key?('AWS_SECRETS_MANAGER_ENDPOINT')
55
+ options[:endpoint] = ENV["AWS_SECRETS_MANAGER_ENDPOINT"] if ENV.has_key?("AWS_SECRETS_MANAGER_ENDPOINT")
48
56
  @secrets_client ||= Aws::SecretsManager::Client.new(options)
49
57
  end
50
58
 
@@ -53,8 +61,9 @@ module Yamload
53
61
  end
54
62
 
55
63
  def ssm_client
64
+ require "aws-sdk-ssm"
56
65
  options = {}
57
- options[:endpoint] = ENV['AWS_SSM_ENDPOINT'] if ENV.has_key?('AWS_SSM_ENDPOINT')
66
+ options[:endpoint] = ENV["AWS_SSM_ENDPOINT"] if ENV.has_key?("AWS_SSM_ENDPOINT")
58
67
  @ssm_client ||= Aws::SSM::Client.new(options)
59
68
  end
60
69
 
@@ -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.5.0'
2
+ VERSION = "0.8.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,11 @@
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
+ require "aws-sdk-ssm"
8
+ require "aws-sdk-secretsmanager"
9
+
10
+ current_file_dir = __dir__
11
+ 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.5.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 'travis'
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.5.0
4
+ version: 0.8.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: 2020-08-02 00:00:00.000000000 Z
12
+ date: 2022-07-02 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: travis
155
+ name: standard
170
156
  requirement: !ruby/object:Gem::Requirement
171
157
  requirements:
172
158
  - - ">="
@@ -187,11 +173,14 @@ executables: []
187
173
  extensions: []
188
174
  extra_rdoc_files: []
189
175
  files:
176
+ - ".github/dependabot.yml"
177
+ - ".github/workflows/release.yml"
178
+ - ".github/workflows/ruby.yml"
190
179
  - ".gitignore"
191
180
  - ".rspec"
192
181
  - ".rubocop.yml"
193
182
  - ".ruby-version"
194
- - ".travis.yml"
183
+ - ".standard.yml"
195
184
  - CHANGELOG.md
196
185
  - Gemfile
197
186
  - LICENSE.txt
@@ -215,6 +204,7 @@ files:
215
204
  - spec/fixtures/erb_bad.yml
216
205
  - spec/fixtures/string.yml
217
206
  - spec/fixtures/test.yml
207
+ - spec/fixtures/unsafe.yml
218
208
  - spec/loader_spec.rb
219
209
  - spec/spec_helper.rb
220
210
  - spec/support/coverage_loader.rb
@@ -231,14 +221,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
231
221
  requirements:
232
222
  - - ">="
233
223
  - !ruby/object:Gem::Version
234
- version: 2.5.0
224
+ version: 2.6.0
235
225
  required_rubygems_version: !ruby/object:Gem::Requirement
236
226
  requirements:
237
227
  - - ">="
238
228
  - !ruby/object:Gem::Version
239
229
  version: '0'
240
230
  requirements: []
241
- rubygems_version: 3.1.2
231
+ rubygems_version: 3.3.3
242
232
  signing_key:
243
233
  specification_version: 4
244
234
  summary: YAML files loader
@@ -250,6 +240,7 @@ test_files:
250
240
  - spec/fixtures/erb_bad.yml
251
241
  - spec/fixtures/string.yml
252
242
  - spec/fixtures/test.yml
243
+ - spec/fixtures/unsafe.yml
253
244
  - spec/loader_spec.rb
254
245
  - spec/spec_helper.rb
255
246
  - spec/support/coverage_loader.rb
data/.travis.yml DELETED
@@ -1,15 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 2.5
4
- - 2.6
5
- - 2.7
6
- script: "bundle exec rake spec"
7
- notifications:
8
- email:
9
- - support@travellink.com.au
10
- flowdock:
11
- secure: UInYCeoRfF7FEnNgW38nZDk3SXWfWN5rm+tKDWX/eWGIIUuynspe6A8776w+wG+9jSuzGt9J3WEIxxognkYiWmud96NYiKZIQDLx/6ql15A9jEvWwqnWbnaL4F368ujhwLo6V42Z6wRfTUqNeRQKki2WCw0NVmT6Y1bdTeNNy70=
12
- sudo: false
13
- cache: bundler
14
- env:
15
- - AWS_REGION: us-east-1