yamload 0.3.0 → 0.7.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
- SHA1:
3
- metadata.gz: b1408c57699fd2e66c43bb9b8bd8ca269ff8a2cd
4
- data.tar.gz: 9328413c84beede3c64a92386033b00e8df036ad
2
+ SHA256:
3
+ metadata.gz: 16ac85003b48e85dd2475a7ab87c43037cc953eb6d6c492fa95444dd9f09ba79
4
+ data.tar.gz: e50a8eb78728cc4975115c1474fa878080fb9ee745712e26dafffe6aeba41fa4
5
5
  SHA512:
6
- metadata.gz: cfcfb7e8493f4e59bc4657521e9dc46c36b4648c97715f787655019882ba319a7e496162c7fdf1b96e6ad8c87130abecb3cbbf9808ed05258f6c8db57b90e991
7
- data.tar.gz: c494d7c4ca1b619f0955f3b2e2b81901e9a349d936aecb25e91340938c81fc1f57564bc945342bcb56a32c50acb3d10bb854cac01084e7d0f1e949b33b541420
6
+ metadata.gz: e847bceccbb83e3f880b78fc8c9ea7c88541583b2adb3b70e2c5ff263afb51b519bc12f6202cb39fce469d35d400a867955d8f9fa067116de96a63cf5bd3d47d
7
+ data.tar.gz: 8f9a9267907f7d1904afe7ba576aae7443da874b1a6b09f05a74c848938212d2bcf873ea573e8f5c0731fdeb12a79dbc252f68e3e8e068fe99e81a8cd9de60a3
@@ -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.4.0
1
+ 3.1.0
data/.standard.yml ADDED
@@ -0,0 +1 @@
1
+ ruby_version: 2.6
data/CHANGELOG.md CHANGED
@@ -1,4 +1,22 @@
1
- ## [Unreleased]
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
+
9
+ ## 0.6.0
10
+
11
+ - [TT-8616] Update to build with github actions / ruby 3.0 / rails 6.1
12
+
13
+ ## 0.5.0 (2020-07-02)
14
+
15
+ - [TT-7683] Add support for AWS SSM and AWS Secrets Manager
16
+
17
+ ## 0.4.0 (2020-05-20)
18
+
19
+ - [TT-7323] Bring all dependencies up to date
2
20
 
3
21
  ## 0.3.0 (2017-07-31)
4
22
 
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,8 +1,11 @@
1
- require 'yaml'
2
- require 'ice_nine'
3
- require 'yamload/loading'
4
- require 'yamload/conversion'
5
- 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"
6
9
 
7
10
  module Yamload
8
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,21 +26,54 @@ 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')
36
- ERB.new(raw_content).result
42
+ raw_content = File.read(filepath, encoding: "bom|utf-8", mode: "r")
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
51
+
52
+ def secrets_client
53
+ options = {}
54
+ options[:endpoint] = ENV["AWS_SECRETS_MANAGER_ENDPOINT"] if ENV.has_key?("AWS_SECRETS_MANAGER_ENDPOINT")
55
+ @secrets_client ||= Aws::SecretsManager::Client.new(options)
56
+ end
57
+
58
+ def get_secret(key)
59
+ secrets_client.get_secret_value(secret_id: key).secret_string
60
+ end
61
+
62
+ def ssm_client
63
+ options = {}
64
+ options[:endpoint] = ENV["AWS_SSM_ENDPOINT"] if ENV.has_key?("AWS_SSM_ENDPOINT")
65
+ @ssm_client ||= Aws::SSM::Client.new(options)
66
+ end
67
+
68
+ def get_parameter(key, encrypted: true)
69
+ ssm_client.get_parameter(
70
+ name: key,
71
+ with_decryption: encrypted
72
+ ).parameter.value
73
+ rescue Aws::SSM::Errors::ParameterNotFound => e
74
+ puts "Parameter #{key} not found"
75
+ raise e
76
+ end
44
77
  end
45
78
  end
46
79
  end
@@ -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.3.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
@@ -1,2 +1,4 @@
1
1
  ---
2
2
  erb_var: <%= 'ERB RAN!' %>
3
+ ssm_var: <%= get_parameter 'ssm_var' %>
4
+ secret_var: <%= get_secret 'secret_var' %>
@@ -0,0 +1 @@
1
+ bad_key: <%= get_parameter 'bad_key' %>
@@ -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,52 +1,73 @@
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
+ 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"))
42
+ end
43
+
35
44
  let(:file) { :erb }
36
- let(:expected_content) { { "erb_var" => "ERB RAN!" } }
45
+ let(:expected_content) { {"erb_var" => "ERB RAN!", "ssm_var" => "SSM SUCCESS", "secret_var" => "SECRET SUCCESS"} }
37
46
  specify { expect(loader).to exist }
38
47
  specify { expect(content).to eq expected_content }
48
+
49
+ context "with bad parameter key" do
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"))
54
+ end
55
+ let(:file) { :erb_bad }
56
+ specify {
57
+ expect { content }.to raise_error Aws::SSM::Errors::ParameterNotFound
58
+ }
59
+ end
39
60
  end
40
61
 
41
- context 'with a file defining an array' do
62
+ context "with a file defining an array" do
42
63
  let(:file) { :array }
43
- let(:expected_content) { %w(first second third) }
64
+ let(:expected_content) { %w[first second third] }
44
65
  specify { expect(loader).to exist }
45
66
  specify { expect { content }.not_to raise_error }
46
67
  specify { expect(content).to eq expected_content }
47
68
 
48
- context 'when defaults are defined' do
49
- let(:defaults) { { test: true } }
69
+ context "when defaults are defined" do
70
+ let(:defaults) { {test: true} }
50
71
  before { loader.defaults = defaults }
51
72
  specify {
52
73
  expect { content }
@@ -55,15 +76,15 @@ describe Yamload::Loader do
55
76
  end
56
77
  end
57
78
 
58
- context 'with a file defining a string' do
79
+ context "with a file defining a string" do
59
80
  let(:file) { :string }
60
- let(:expected_content) { '1 first 2 second 3 third' }
81
+ let(:expected_content) { "1 first 2 second 3 third" }
61
82
  specify { expect(loader).to exist }
62
83
  specify { expect { content }.not_to raise_error }
63
84
  specify { expect(content).to eq expected_content }
64
85
 
65
- context 'when defaults are defined' do
66
- let(:defaults) { { test: true } }
86
+ context "when defaults are defined" do
87
+ let(:defaults) { {test: true} }
67
88
  before { loader.defaults = defaults }
68
89
  specify {
69
90
  expect { content }
@@ -72,103 +93,115 @@ describe Yamload::Loader do
72
93
  end
73
94
  end
74
95
 
75
- 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
76
109
  specify { expect(loader).to exist }
77
110
 
78
111
  let(:expected_content) {
79
112
  {
80
- 'test' => true,
81
- 'users' => [
113
+ "test" => true,
114
+ "users" => [
82
115
  {
83
- 'first_name' => 'Testy',
84
- 'last_name' => 'Tester',
85
- 'address' => {
86
- 'address_line_1' => '1 Test Avenue',
87
- 'address_line_2' => nil,
88
- 'city' => 'Testville',
89
- 'state' => 'TST',
90
- 'post_code' => 1234,
91
- '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"
92
125
  },
93
- 'email' => 'testy.tester@test.com'
126
+ "email" => "testy.tester@test.com"
94
127
  },
95
128
  {
96
- 'first_name' => 'Speccy',
97
- 'last_name' => 'Speccer',
98
- 'address' => {
99
- 'address_line_1' => 'Unit 1',
100
- 'address_line_2' => '42 Spec Street',
101
- 'city' => 'Specwood',
102
- 'state' => 'SPC',
103
- 'post_code' => 5678,
104
- '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"
105
138
  },
106
- 'email' => 'speccy.speccer@spec.com'
139
+ "email" => "speccy.speccer@spec.com"
107
140
  }
108
141
  ],
109
- 'settings' => {
110
- 'remote_access' => true
142
+ "settings" => {
143
+ "remote_access" => true
111
144
  }
112
145
  }
113
146
  }
114
147
 
115
148
  specify { expect(content).to eq expected_content }
116
149
 
117
- let(:content_obj) { loader.obj }
150
+ let(:content_obj) { loader.obj }
118
151
 
119
152
  specify { expect(content_obj.test).to eq true }
120
- specify { expect(content_obj.users[0].first_name).to eq 'Testy' }
121
- specify { expect(content_obj.users[0].last_name).to eq 'Tester' }
122
- 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" }
123
156
  specify { expect(content_obj.users[0].address.address_line_2).to eq nil }
124
- specify { expect(content_obj.users[0].address.city).to eq 'Testville' }
125
- 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" }
126
159
  specify { expect(content_obj.users[0].address.post_code).to eq 1234 }
127
- specify { expect(content_obj.users[0].address.country).to eq 'Testalia' }
128
- specify { expect(content_obj.users[0].email).to eq 'testy.tester@test.com' }
129
- specify { expect(content_obj.users[1].first_name).to eq 'Speccy' }
130
- specify { expect(content_obj.users[1].last_name).to eq 'Speccer' }
131
- specify { expect(content_obj.users[1].address.address_line_1).to eq 'Unit 1' }
132
- specify { expect(content_obj.users[1].address.address_line_2).to eq '42 Spec Street' }
133
- specify { expect(content_obj.users[1].address.city).to eq 'Specwood' }
134
- 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" }
135
168
  specify { expect(content_obj.users[1].address.post_code).to eq 5678 }
136
- specify { expect(content_obj.users[1].address.country).to eq 'Specland' }
137
- 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" }
138
171
  specify { expect(content_obj.settings.remote_access).to eq true }
139
172
 
140
- context 'when trying to modify the loaded hash' do
141
- let(:new_user) { double('new user') }
142
- specify 'the hash should be immutable' do
143
- 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 }
144
177
  .to raise_error RuntimeError, /can't modify frozen Array/i
145
- expect(content['users']).not_to include new_user
178
+ expect(content["users"]).not_to include new_user
146
179
  end
147
180
  end
148
181
 
149
- context 'when trying to modify the content object' do
150
- let(:new_user) { double('new user') }
151
- 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
152
185
  expect { content_obj.users << new_user }
153
186
  .to raise_error RuntimeError, /can't modify frozen Array/i
154
187
  expect(content_obj.users).not_to include new_user
155
188
  end
156
189
  end
157
190
 
158
- context 'when the defaults object is not a hash' do
159
- let(:defaults) { 'not a hash' }
191
+ context "when the defaults object is not a hash" do
192
+ let(:defaults) { "not a hash" }
160
193
  specify {
161
194
  expect { loader.defaults = defaults }
162
195
  .to raise_error ArgumentError, "#{defaults} is not a hash"
163
196
  }
164
197
  end
165
198
 
166
- context 'when defaults are defined' do
199
+ context "when defaults are defined" do
167
200
  let(:defaults) {
168
201
  {
169
- 'settings' => {
170
- 'remember_user' => false,
171
- 'remote_access' => false
202
+ "settings" => {
203
+ "remember_user" => false,
204
+ "remote_access" => false
172
205
  }
173
206
  }
174
207
  }
@@ -182,7 +215,7 @@ describe Yamload::Loader do
182
215
  specify { expect(content_obj.settings.remote_access).to eq true }
183
216
  end
184
217
 
185
- context 'when reloading' do
218
+ context "when reloading" do
186
219
  let(:original_hash) { loader.content }
187
220
  before do
188
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,34 +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 = '>= 1.9.3'
20
+ spec.required_ruby_version = ">= 2.6.0"
22
21
 
23
- spec.add_dependency 'anima', '~> 0.2'
24
- spec.add_dependency 'facets', '~> 3.0'
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"
25
26
 
26
- spec.add_development_dependency 'bundler', '~> 1.7'
27
- spec.add_development_dependency 'rake', '~> 10.0'
28
- spec.add_development_dependency 'rspec', '~> 3.2'
29
- spec.add_development_dependency 'coverage-kit'
30
- spec.add_development_dependency 'simplecov-rcov', '~> 0.2'
31
- spec.add_development_dependency 'coveralls'
32
- spec.add_development_dependency 'rubocop'
33
- 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"
34
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.3.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alessandro Berardi
@@ -9,76 +9,104 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-07-31 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
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - "~>"
18
+ - - ">="
19
19
  - !ruby/object:Gem::Version
20
20
  version: '0.2'
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
- - - "~>"
25
+ - - ">="
26
26
  - !ruby/object:Gem::Version
27
27
  version: '0.2'
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: facets
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
- - - "~>"
32
+ - - ">="
33
33
  - !ruby/object:Gem::Version
34
34
  version: '3.0'
35
35
  type: :runtime
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
- - - "~>"
39
+ - - ">="
40
40
  - !ruby/object:Gem::Version
41
41
  version: '3.0'
42
+ - !ruby/object:Gem::Dependency
43
+ name: aws-sdk-secretsmanager
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
49
+ type: :runtime
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ - !ruby/object:Gem::Dependency
57
+ name: aws-sdk-ssm
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ type: :runtime
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
42
70
  - !ruby/object:Gem::Dependency
43
71
  name: bundler
44
72
  requirement: !ruby/object:Gem::Requirement
45
73
  requirements:
46
- - - "~>"
74
+ - - ">="
47
75
  - !ruby/object:Gem::Version
48
76
  version: '1.7'
49
77
  type: :development
50
78
  prerelease: false
51
79
  version_requirements: !ruby/object:Gem::Requirement
52
80
  requirements:
53
- - - "~>"
81
+ - - ">="
54
82
  - !ruby/object:Gem::Version
55
83
  version: '1.7'
56
84
  - !ruby/object:Gem::Dependency
57
85
  name: rake
58
86
  requirement: !ruby/object:Gem::Requirement
59
87
  requirements:
60
- - - "~>"
88
+ - - ">="
61
89
  - !ruby/object:Gem::Version
62
90
  version: '10.0'
63
91
  type: :development
64
92
  prerelease: false
65
93
  version_requirements: !ruby/object:Gem::Requirement
66
94
  requirements:
67
- - - "~>"
95
+ - - ">="
68
96
  - !ruby/object:Gem::Version
69
97
  version: '10.0'
70
98
  - !ruby/object:Gem::Dependency
71
99
  name: rspec
72
100
  requirement: !ruby/object:Gem::Requirement
73
101
  requirements:
74
- - - "~>"
102
+ - - ">="
75
103
  - !ruby/object:Gem::Version
76
104
  version: '3.2'
77
105
  type: :development
78
106
  prerelease: false
79
107
  version_requirements: !ruby/object:Gem::Requirement
80
108
  requirements:
81
- - - "~>"
109
+ - - ">="
82
110
  - !ruby/object:Gem::Version
83
111
  version: '3.2'
84
112
  - !ruby/object:Gem::Dependency
@@ -96,21 +124,7 @@ dependencies:
96
124
  - !ruby/object:Gem::Version
97
125
  version: '0'
98
126
  - !ruby/object:Gem::Dependency
99
- name: simplecov-rcov
100
- requirement: !ruby/object:Gem::Requirement
101
- requirements:
102
- - - "~>"
103
- - !ruby/object:Gem::Version
104
- version: '0.2'
105
- type: :development
106
- prerelease: false
107
- version_requirements: !ruby/object:Gem::Requirement
108
- requirements:
109
- - - "~>"
110
- - !ruby/object:Gem::Version
111
- version: '0.2'
112
- - !ruby/object:Gem::Dependency
113
- name: coveralls
127
+ name: rubocop
114
128
  requirement: !ruby/object:Gem::Requirement
115
129
  requirements:
116
130
  - - ">="
@@ -124,7 +138,7 @@ dependencies:
124
138
  - !ruby/object:Gem::Version
125
139
  version: '0'
126
140
  - !ruby/object:Gem::Dependency
127
- name: rubocop
141
+ name: pry-byebug
128
142
  requirement: !ruby/object:Gem::Requirement
129
143
  requirements:
130
144
  - - ">="
@@ -138,7 +152,7 @@ dependencies:
138
152
  - !ruby/object:Gem::Version
139
153
  version: '0'
140
154
  - !ruby/object:Gem::Dependency
141
- name: travis
155
+ name: standard
142
156
  requirement: !ruby/object:Gem::Requirement
143
157
  requirements:
144
158
  - - ">="
@@ -159,11 +173,14 @@ executables: []
159
173
  extensions: []
160
174
  extra_rdoc_files: []
161
175
  files:
176
+ - ".github/dependabot.yml"
177
+ - ".github/workflows/release.yml"
178
+ - ".github/workflows/ruby.yml"
162
179
  - ".gitignore"
163
180
  - ".rspec"
164
181
  - ".rubocop.yml"
165
182
  - ".ruby-version"
166
- - ".travis.yml"
183
+ - ".standard.yml"
167
184
  - CHANGELOG.md
168
185
  - Gemfile
169
186
  - LICENSE.txt
@@ -184,8 +201,10 @@ files:
184
201
  - spec/fixtures/array.yml
185
202
  - spec/fixtures/empty.yml
186
203
  - spec/fixtures/erb.yml
204
+ - spec/fixtures/erb_bad.yml
187
205
  - spec/fixtures/string.yml
188
206
  - spec/fixtures/test.yml
207
+ - spec/fixtures/unsafe.yml
189
208
  - spec/loader_spec.rb
190
209
  - spec/spec_helper.rb
191
210
  - spec/support/coverage_loader.rb
@@ -202,15 +221,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
202
221
  requirements:
203
222
  - - ">="
204
223
  - !ruby/object:Gem::Version
205
- version: 1.9.3
224
+ version: 2.6.0
206
225
  required_rubygems_version: !ruby/object:Gem::Requirement
207
226
  requirements:
208
227
  - - ">="
209
228
  - !ruby/object:Gem::Version
210
229
  version: '0'
211
230
  requirements: []
212
- rubyforge_project:
213
- rubygems_version: 2.6.8
231
+ rubygems_version: 3.3.3
214
232
  signing_key:
215
233
  specification_version: 4
216
234
  summary: YAML files loader
@@ -219,8 +237,10 @@ test_files:
219
237
  - spec/fixtures/array.yml
220
238
  - spec/fixtures/empty.yml
221
239
  - spec/fixtures/erb.yml
240
+ - spec/fixtures/erb_bad.yml
222
241
  - spec/fixtures/string.yml
223
242
  - spec/fixtures/test.yml
243
+ - spec/fixtures/unsafe.yml
224
244
  - spec/loader_spec.rb
225
245
  - spec/spec_helper.rb
226
246
  - spec/support/coverage_loader.rb
data/.travis.yml DELETED
@@ -1,13 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 2.1
4
- - 2.2
5
- - 2.3.0
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