persey 0.0.10 → 2.0.2

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: 2e1f9f5660692b33b255dc9b0157e8a13392d89c
4
- data.tar.gz: 6799d9fe91d1e3786e0f43a998ce6a03ea249a71
2
+ SHA256:
3
+ metadata.gz: 0b85f29da7689d489aa4439205ea922be1a538d9ab58fb461f96bdf7164f6a5b
4
+ data.tar.gz: 815aa0f003d3a546a4905e3d0cfcddadba219491804670d1f02e871df640e31c
5
5
  SHA512:
6
- metadata.gz: 570ad3fc120b38e2c530be2de118f32ad8889679a561033eecb9fd9f2d92d7e0e6cdb2a1907b6953f750c9378a456d8def7a72ff735d4586a6c67c97fcc31018
7
- data.tar.gz: 9f4170c5e32b8ca80be03def4e0eceb75dcd24f364940ad96d36a43997d68263448663e0addbcc9c024a99018cd8b6143aaafd673fcd4324d9eb45c962b3a156
6
+ metadata.gz: 6d371622b2c20c8ea539cfd72109c82cde99be93a1ba662b23b2a6185e553093ccab99b00c23e783a67d4da16d8c0d4fc96d9cc7fca9b149efaa8b725cc8c6fd
7
+ data.tar.gz: 00baf95e6010b789ae2b519b160bfa6fdfcea18af3bad144a2f76e28a93bf55dbaf8574b4cbe3d54125965e9c0f56797bee62412f8da9a4cb72401696498b1cb
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.7.1
data/.travis.yml CHANGED
@@ -6,4 +6,5 @@ rvm:
6
6
  - 2.2.5
7
7
  - 2.3.0
8
8
  - 2.3.1
9
- script: "bundle exec rake test"
9
+ - 2.4.1
10
+ script: "bundle exec rspec"
data/Dockerfile CHANGED
@@ -1,4 +1,4 @@
1
- FROM ruby:2.3.1
1
+ FROM ruby:2.7.1
2
2
 
3
3
  ENV APP_HOME /app
4
4
  WORKDIR $APP_HOME
data/Gemfile CHANGED
@@ -1,11 +1,10 @@
1
1
  source "http://rubygems.org"
2
2
 
3
- gemspec
4
-
5
3
  gem 'bundler'
6
4
  gem 'rake'
7
5
  gem 'pry'
8
- gem 'minitest', '> 5.0'
6
+ gem 'rspec'
9
7
  gem 'configus', require: true
10
8
  gem 'activesupport'
11
- gem 'wrong'
9
+
10
+ gemspec
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Persey [![Build Status](https://travis-ci.org/zzet/persey.png?branch=master)](https://travis-ci.org/zzet/persey) [![Gem Version](https://badge.fury.io/rb/persey.png)](http://badge.fury.io/rb/persey) [![Dependency Status](https://gemnasium.com/zzet/persey.png)](https://gemnasium.com/zzet/persey) [![Code Climate](https://codeclimate.com/github/zzet/persey.png)](https://codeclimate.com/github/zzet/persey) [![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/zzet/persey/trend.png)](https://bitdeli.com/free "Bitdeli Badge")
1
+ # Persey [![Build Status](https://travis-ci.org/zzet/persey.svg?branch=master)](https://travis-ci.org/zzet/persey) [![Gem Version](https://badge.fury.io/rb/persey.svg)](http://badge.fury.io/rb/persey)[![Code Climate](https://codeclimate.com/github/zzet/persey.svg)](https://codeclimate.com/github/zzet/persey) [![Downloads count](https://img.shields.io/gem/dt/persey.svg)](https://img.shields.io/gem/dt/persey.svg)
2
2
 
3
3
 
4
4
  ## Summary
@@ -25,7 +25,7 @@ This solution allows to **accumulate** different configs in one, with the **poss
25
25
  Add this to your `Gemfile`:
26
26
 
27
27
  ``` ruby
28
- gem "persey", '>= 0.0.10'
28
+ gem "persey", '>= 1.0.0'
29
29
  ```
30
30
 
31
31
  Generate default config file
@@ -67,6 +67,8 @@ my_node_js_config = '/rest/u/apps/node/config.json'
67
67
  my_berkshelf_config = File.join(app_path, 'provisioning', '.berkshelf')
68
68
  # And INI
69
69
  my_ini_config = File.join(app_path, 'provisioning', 'php.ini') # lol
70
+ # And AWS SSM secure string (we assume you're using JSON inside)
71
+ my_ssm_config = '/some/ssm/parameter/path.json'
70
72
 
71
73
  # Persey.init ENV["environment"] do # set current environment
72
74
  Persey.init Rails.env do # set current environment
@@ -78,6 +80,7 @@ Persey.init Rails.env do # set current environment
78
80
  source :json, my_node_js_config, :node_js_namespace
79
81
  source :toml, my_berkshelf_config, :berkshelf_namespace
80
82
  source :ini, my_ini_config, :ini_namespace
83
+ source :ssm, my_ssm_config, :ssm_namespace
81
84
 
82
85
  env :production do
83
86
  site_name 'Example'
@@ -181,6 +184,7 @@ end
181
184
  * JSON
182
185
  * TOML
183
186
  * INI
187
+ * AWS SSM Secure string (json inside)
184
188
 
185
189
  ## Similar
186
190
 
data/Rakefile CHANGED
@@ -1,10 +1 @@
1
1
  require "bundler/gem_tasks"
2
- require 'rake/testtask'
3
-
4
- Rake::TestTask.new do |t|
5
- t.libs << "test"
6
- t.test_files = FileList['test/**/*_test.rb']
7
- t.verbose = true
8
- end
9
-
10
- task :default => :test
data/docker-compose.yml CHANGED
@@ -4,4 +4,4 @@ services:
4
4
  build: .
5
5
  command: tail -f /dev/null
6
6
  volumes:
7
- - .:/gem
7
+ - .:/app
@@ -1,18 +1,24 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Persey
2
4
  module Adapters
3
5
  class Base
4
6
  class << self
5
- def load(file, env)
7
+ def load(file, env, opts)
6
8
  raise NotImplementedError
7
9
  end
8
10
 
9
11
  def symbolize_keys(hash)
10
- hash.inject({}){|res, (k, v)|
12
+ hash.each_with_object({}) do |(k, v), res|
11
13
  n_k = k.is_a?(String) ? k.to_sym : k
12
14
  n_v = v.is_a?(Hash) ? symbolize_keys(v) : v
13
15
  res[n_k] = n_v
14
16
  res
15
- }
17
+ end
18
+ end
19
+
20
+ def config_exists?(path, _opts)
21
+ File.exist?(path)
16
22
  end
17
23
  end
18
24
  end
@@ -1,16 +1,16 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'inifile'
2
4
 
3
5
  module Persey
4
6
  module Adapters
5
7
  class Ini < Persey::Adapters::Base
6
8
  class << self
7
- def load(file, env)
8
- begin
9
- raw_hash = IniFile.load(file).to_h
10
- symbolize_keys(raw_hash)
11
- rescue
12
- puts "FATAL: Error while process config from file '#{file}'"
13
- end
9
+ def load(file, _env, opts: {})
10
+ raw_hash = IniFile.load(file).to_h
11
+ symbolize_keys(raw_hash)
12
+ rescue
13
+ puts "FATAL: Error while process config from file '#{file}'"
14
14
  end
15
15
  end
16
16
  end
@@ -1,18 +1,17 @@
1
- require 'yajl'
1
+ # frozen_string_literal: true
2
+
3
+ require 'json/stream'
2
4
 
3
5
  module Persey
4
6
  module Adapters
5
7
  class Json < Persey::Adapters::Base
6
8
  class << self
7
- def load(file, env)
8
- begin
9
- json = File.new(file, 'r')
10
- parser = Yajl::Parser.new
11
- raw_hash = parser.parse(json)
12
- symbolize_keys(raw_hash)
13
- rescue
14
- puts "FATAL: Error while process config from file '#{file}'"
15
- end
9
+ def load(file, _env, opts: {})
10
+ json = File.new(file, 'r')
11
+ raw_hash = JSON::Stream::Parser.parse(json)
12
+ symbolize_keys(raw_hash)
13
+ rescue
14
+ puts "FATAL: Error while process config from file '#{file}'"
16
15
  end
17
16
  end
18
17
  end
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'json'
4
+ require 'aws-sdk-ssm'
5
+
6
+ module Persey
7
+ class MissingEnvVariable < RuntimeError; end
8
+
9
+ module Adapters
10
+ class Ssm < Persey::Adapters::Base
11
+ class << self
12
+ def load(path, _env, opts: {})
13
+ ssm = ssm_client(opts)
14
+ param = ssm.get_parameter(name: path, with_decryption: true).parameter
15
+
16
+ res = begin
17
+ JSON.parse(param.value)
18
+ rescue JSON::ParserError
19
+ param.to_h
20
+ end
21
+
22
+ symbolize_keys(res)
23
+ end
24
+
25
+ def config_exists?(path, opts: {})
26
+ ssm = ssm_client(opts)
27
+ ssm.get_parameter(name: path, with_decryption: true).parameter.nil? == false
28
+ rescue Aws::SSM::Errors::ParameterNotFound
29
+ false
30
+ end
31
+
32
+ private
33
+
34
+ def ssm_client(opts)
35
+ opts[:client] || Aws::SSM::Client.new
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
@@ -1,16 +1,16 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'toml'
2
4
 
3
5
  module Persey
4
6
  module Adapters
5
7
  class Toml < Persey::Adapters::Base
6
8
  class << self
7
- def load(file, env)
8
- begin
9
- raw_hash = TOML.load_file(file)
10
- symbolize_keys(raw_hash)
11
- rescue
12
- puts "FATAL: Error while process config from file '#{file}'"
13
- end
9
+ def load(file, _env, opts: {})
10
+ raw_hash = TOML.load_file(file)
11
+ symbolize_keys(raw_hash)
12
+ rescue
13
+ puts "FATAL: Error while process config from file '#{file}'"
14
14
  end
15
15
  end
16
16
  end
@@ -1,16 +1,23 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'yaml'
2
4
  require 'erb'
3
5
 
4
6
  module Persey
7
+ class MissingEnvVariable < RuntimeError; end
8
+
5
9
  module Adapters
6
10
  class Yaml < Persey::Adapters::Base
7
11
  class << self
8
- def load(file, env)
9
- begin
10
- raw_hash = YAML.load(ERB.new(File.read(file)).result)
11
- symbolize_keys(raw_hash)
12
- rescue
13
- puts "FATAL: Error while process config from file '#{file}'"
12
+ def load(file, _env, opts: {})
13
+ raw_hash = YAML.load(ERB.new(File.read(file)).result)
14
+ symbolize_keys(raw_hash)
15
+ rescue KeyError => e
16
+ _, line, method = /\(erb\):(\d+):in `(.*)'/.match(e.backtrace[0]).to_a
17
+ if method == 'fetch'
18
+ raise MissingEnvVariable.new("Check line ##{line} in #{file}")
19
+ else
20
+ raise e
14
21
  end
15
22
  end
16
23
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'configus'
2
4
 
3
5
  module Persey
@@ -20,7 +22,7 @@ module Persey
20
22
  e = env || @current_env
21
23
  edata = @envs[e]
22
24
 
23
- raise ArgumentError, "Undefined environment '#{ env }" if edata.nil?
25
+ raise ArgumentError, "Undefined environment '#{env}'" if edata.nil?
24
26
 
25
27
  current_config = {}
26
28
  if edata[:block]
@@ -33,7 +35,7 @@ module Persey
33
35
  current_config = deep_merge(parent_config, current_config)
34
36
  end
35
37
 
36
- current_config = @config.deep_merge(current_config)
38
+ @config.deep_merge(current_config)
37
39
  end
38
40
 
39
41
  private
@@ -41,14 +43,14 @@ module Persey
41
43
  def env(env, options = {}, &block)
42
44
  env = env.to_sym
43
45
 
44
- raise ArgumentError, "Double definition of environment '#{ env }'" if @envs.has_key?(env)
46
+ raise ArgumentError, "Double definition of environment '#{env}'" if @envs.has_key?(env)
45
47
 
46
48
  @envs[env] = { options: options }
47
49
  @envs[env][:block] = block if block_given?
48
50
  end
49
51
 
50
52
  def deep_merge(target, source)
51
- source.each_pair do |k,v|
53
+ source.each_pair do |k, v|
52
54
  tv = target[k]
53
55
  target[k] = tv.is_a?(Hash) && v.is_a?(Hash) ? deep_merge(tv, v) : v
54
56
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Configus::Config
2
4
  def method_missing(meth, *args, &blk)
3
5
  if Persey.config.to_hash.has_key?(meth)
@@ -1,6 +1,10 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'active_support/inflector'
2
4
 
3
5
  module Persey
6
+ class MissingConfigFile < RuntimeError; end
7
+
4
8
  class Inspector
5
9
  class << self
6
10
  def analize(&block)
@@ -9,12 +13,17 @@ module Persey
9
13
  @sources
10
14
  end
11
15
 
12
- def source(source_type, config_file, namespace = nil)
13
- override_config_file = config_file + '.override'
14
-
16
+ def source(source_type, config_file, namespace = nil, opts = {})
15
17
  klass = "persey/adapters/#{source_type}".camelize.constantize
16
- @sources << { class: klass, file: config_file, namespace: namespace } if File.exist?(config_file)
17
- @sources << { class: klass, file: override_config_file, namespace: namespace } if File.exist?(override_config_file)
18
+
19
+ unless klass.config_exists?(config_file, opts: opts)
20
+ raise MissingConfigFile, "Can't find #{source_type} config: #{config_file}"
21
+ end
22
+
23
+ @sources << { class: klass, file: config_file, namespace: namespace, opts: opts }
24
+
25
+ override_config_file = config_file + '.override'
26
+ @sources << { class: klass, file: override_config_file, namespace: namespace, opts: opts } if klass.config_exists?(override_config_file, opts: opts)
18
27
  end
19
28
 
20
29
  def env(*args)
data/lib/persey/loader.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Persey
2
4
  class Loader
3
5
  attr_accessor :configs
@@ -18,7 +20,7 @@ module Persey
18
20
 
19
21
  configs.each do |pdc|
20
22
  klass = pdc[:class]
21
- raw_config = klass.load(pdc[:file], env)
23
+ raw_config = klass.load(pdc[:file], env, opts: pdc[:opts])
22
24
  env_config = raw_config[env].nil? ? raw_config : raw_config[env]
23
25
 
24
26
  n = pdc[:namespace]
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Persey
2
- VERSION = "0.0.10"
4
+ VERSION = '2.0.2'
3
5
  end
data/lib/persey.rb CHANGED
@@ -1,13 +1,16 @@
1
- require "persey/version"
2
- require "persey/builder"
3
- require "persey/inspector"
4
- require "persey/loader"
5
- require "persey/adapters/base"
6
- require "persey/adapters/yaml"
7
- require "persey/adapters/json"
8
- require "persey/adapters/toml"
9
- require "persey/adapters/ini"
10
- require "persey/configus_patch"
1
+ # frozen_string_literal: true
2
+
3
+ require 'persey/version'
4
+ require 'persey/builder'
5
+ require 'persey/inspector'
6
+ require 'persey/loader'
7
+ require 'persey/adapters/base'
8
+ require 'persey/adapters/yaml'
9
+ require 'persey/adapters/json'
10
+ require 'persey/adapters/toml'
11
+ require 'persey/adapters/ini'
12
+ require 'persey/adapters/ssm'
13
+ require 'persey/configus_patch'
11
14
 
12
15
  module Persey
13
16
  class << self
@@ -19,7 +22,7 @@ module Persey
19
22
  end
20
23
 
21
24
  def config
22
- raise RuntimeError, "Please, init config before usage" if @config.nil?
25
+ raise 'Please, init config before usage' if @config.nil?
23
26
 
24
27
  @config
25
28
  end
data/persey.gemspec CHANGED
@@ -18,9 +18,12 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
- spec.add_runtime_dependency "activesupport"
21
+ spec.add_runtime_dependency 'activesupport'
22
22
  spec.add_runtime_dependency 'configus', '>= 0.0.5'
23
- spec.add_runtime_dependency 'yajl-ruby'
24
- spec.add_runtime_dependency "toml", "~> 0.1.0"
25
- spec.add_runtime_dependency "inifile"
23
+ spec.add_runtime_dependency 'json-stream'
24
+ spec.add_runtime_dependency 'toml', '~> 0.1.0'
25
+ spec.add_runtime_dependency 'inifile'
26
+ spec.add_runtime_dependency 'aws-sdk-ssm', '~> 1.120'
27
+
28
+ spec.add_development_dependency 'simplecov'
26
29
  end
@@ -0,0 +1,5 @@
1
+ ---
2
+ option: good line
3
+ hash: good hash
4
+ val: hash val
5
+ failed_string: <%= ENV.fetch('SOME_VAR') %>
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -0,0 +1,80 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ describe Persey do
6
+ context 'true-flow input data' do
7
+ before do
8
+ plain_config = File.join(fixtures_path, 'yaml_config.yml')
9
+ env_config = File.join(fixtures_path, 'yaml_config_with_envs.yml')
10
+ plain_json_config = File.join(fixtures_path, 'json_config.json')
11
+ plain_toml_config = File.join(fixtures_path, 'toml_config.toml')
12
+ plain_ini_config = File.join(fixtures_path, 'ini_config.ini')
13
+ plain_ssm_config = '/some/ssm/parameter/path.json'
14
+
15
+ Persey.init :production do
16
+ source :yaml, plain_config
17
+ source :yaml, env_config, :namespace
18
+ source :json, plain_json_config, :json_config
19
+ source :toml, plain_toml_config, :toml_config
20
+ source :ini, plain_ini_config, :ini_config
21
+ source :ssm, plain_ssm_config, :ssm_config, { client: Aws::SSM::Client.new(stub_responses: true) }
22
+
23
+ env :production do
24
+ option do
25
+ first 'first value'
26
+ second 'second value'
27
+ end
28
+
29
+ first do
30
+ testss -> { second }
31
+ end
32
+ end
33
+ end
34
+ end
35
+
36
+ it '#config' do
37
+ expect { Persey.config }.not_to raise_exception
38
+ end
39
+
40
+ it '#config.methods' do
41
+ @config = Persey.config
42
+ expect(@config.option.first).to eq('first value')
43
+ expect(@config.first.testss).to eq('foo value')
44
+ expect(@config.first.second).to eq('foo value')
45
+ expect(@config.namespace.another_key).to eq('another key value')
46
+ expect(@config.namespace.another_key).to eq('another key value')
47
+ expect(@config.key).to eq('key value')
48
+ expect(@config.json_config.owner.name).to eq('John Doe')
49
+ expect(@config.toml_config.owner.name).to eq('Tom Preston-Werner')
50
+ expect(@config.ini_config.section1.var1).to eq('foo')
51
+ expect(@config.ssm_config.value).to eq('PSParameterValue')
52
+ end
53
+ end
54
+
55
+ context 'false-flow data' do
56
+ it 'missing config' do
57
+ missing_config = File.join(fixtures_path, 'missing_yaml_config.yml')
58
+
59
+ expect do
60
+ Persey.init :production do
61
+ source :yaml, missing_config
62
+
63
+ env :production
64
+ end
65
+ end.to raise_error(Persey::MissingConfigFile)
66
+ end
67
+
68
+ it 'missing ENV.fetch' do
69
+ broken_yaml_config = File.join(fixtures_path, 'broken_yaml_config.yml')
70
+
71
+ expect do
72
+ Persey.init :production do
73
+ source :yaml, broken_yaml_config
74
+
75
+ env :production
76
+ end
77
+ end.to raise_error(Persey::MissingEnvVariable)
78
+ end
79
+ end
80
+ end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'simplecov'
4
+ SimpleCov.start do
5
+ add_filter '/spec/'
6
+ end
7
+
8
+ require 'pry'
9
+ require 'persey'
10
+
11
+ PROJECT_ROOT = File.join(Dir.pwd)
12
+
13
+ Dir[File.expand_path('..', __FILE__) + '/support/**/*.rb'].each { |f| require f }
14
+
15
+ RSpec.configure do |config|
16
+ def fixtures_path
17
+ @path ||= File.expand_path(File.join(__FILE__, "../fixtures"))
18
+ end
19
+
20
+ config.expect_with :rspec do |expectations|
21
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
22
+ end
23
+
24
+ config.mock_with :rspec do |mocks|
25
+ mocks.verify_partial_doubles = true
26
+ end
27
+
28
+ config.shared_context_metadata_behavior = :apply_to_host_groups
29
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: persey
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.10
4
+ version: 2.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrey Kumanyaev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-10-20 00:00:00.000000000 Z
11
+ date: 2021-11-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -39,7 +39,7 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: 0.0.5
41
41
  - !ruby/object:Gem::Dependency
42
- name: yajl-ruby
42
+ name: json-stream
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - ">="
@@ -80,6 +80,34 @@ dependencies:
80
80
  - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: aws-sdk-ssm
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '1.120'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '1.120'
97
+ - !ruby/object:Gem::Dependency
98
+ name: simplecov
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
83
111
  description: Persey helps you easily load configs from different files and use them
84
112
  from one variable. Based on Configus.
85
113
  email:
@@ -89,6 +117,7 @@ extensions: []
89
117
  extra_rdoc_files: []
90
118
  files:
91
119
  - ".gitignore"
120
+ - ".ruby-version"
92
121
  - ".travis.yml"
93
122
  - Dockerfile
94
123
  - Gemfile
@@ -102,6 +131,7 @@ files:
102
131
  - lib/persey/adapters/base.rb
103
132
  - lib/persey/adapters/ini.rb
104
133
  - lib/persey/adapters/json.rb
134
+ - lib/persey/adapters/ssm.rb
105
135
  - lib/persey/adapters/toml.rb
106
136
  - lib/persey/adapters/yaml.rb
107
137
  - lib/persey/builder.rb
@@ -110,13 +140,14 @@ files:
110
140
  - lib/persey/loader.rb
111
141
  - lib/persey/version.rb
112
142
  - persey.gemspec
113
- - test/fixtures/ini_config.ini
114
- - test/fixtures/json_config.json
115
- - test/fixtures/toml_config.toml
116
- - test/fixtures/yaml_config.yml
117
- - test/fixtures/yaml_config_with_envs.yml
118
- - test/lib/persey_test.rb
119
- - test/test_helper.rb
143
+ - spec/fixtures/broken_yaml_config.yml
144
+ - spec/fixtures/ini_config.ini
145
+ - spec/fixtures/json_config.json
146
+ - spec/fixtures/toml_config.toml
147
+ - spec/fixtures/yaml_config.yml
148
+ - spec/fixtures/yaml_config_with_envs.yml
149
+ - spec/lib/persey_spec.rb
150
+ - spec/spec_helper.rb
120
151
  homepage: https://github.com/zzet/persey
121
152
  licenses:
122
153
  - MIT
@@ -136,16 +167,16 @@ required_rubygems_version: !ruby/object:Gem::Requirement
136
167
  - !ruby/object:Gem::Version
137
168
  version: '0'
138
169
  requirements: []
139
- rubyforge_project:
140
- rubygems_version: 2.5.1
170
+ rubygems_version: 3.1.2
141
171
  signing_key:
142
172
  specification_version: 4
143
173
  summary: Helps you easily manage environment specific settings
144
174
  test_files:
145
- - test/fixtures/ini_config.ini
146
- - test/fixtures/json_config.json
147
- - test/fixtures/toml_config.toml
148
- - test/fixtures/yaml_config.yml
149
- - test/fixtures/yaml_config_with_envs.yml
150
- - test/lib/persey_test.rb
151
- - test/test_helper.rb
175
+ - spec/fixtures/broken_yaml_config.yml
176
+ - spec/fixtures/ini_config.ini
177
+ - spec/fixtures/json_config.json
178
+ - spec/fixtures/toml_config.toml
179
+ - spec/fixtures/yaml_config.yml
180
+ - spec/fixtures/yaml_config_with_envs.yml
181
+ - spec/lib/persey_spec.rb
182
+ - spec/spec_helper.rb
@@ -1,47 +0,0 @@
1
- require 'test_helper'
2
-
3
- class PerseyTest < TestCase
4
- def setup
5
- plain_config = File.join(fixtures_path, 'yaml_config.yml')
6
- env_config = File.join(fixtures_path, 'yaml_config_with_envs.yml')
7
- plain_json_config = File.join(fixtures_path, 'json_config.json')
8
- plain_toml_config = File.join(fixtures_path, 'toml_config.toml')
9
- plain_ini_config = File.join(fixtures_path, 'ini_config.ini')
10
-
11
- Persey.init :production do
12
- source :yaml, plain_config
13
- source :yaml, env_config, :namespace
14
- source :json, plain_json_config, :json_config
15
- source :toml, plain_toml_config, :toml_config
16
- source :ini, plain_ini_config, :ini_config
17
-
18
- env :production do
19
- option do
20
- first "first value"
21
- second "second value"
22
- end
23
-
24
- first do
25
- testss -> { second }
26
- end
27
- end
28
- end
29
- end
30
-
31
- def test_load_config
32
- assert { Persey.config }
33
- end
34
-
35
- def test_correct_config
36
- @config = Persey.config
37
- assert { @config.option.first == "first value" }
38
- assert { @config.first.testss == "foo value" }
39
- assert { @config.first.second == "foo value" }
40
- assert { @config.namespace.another_key == "another key value" }
41
- assert { @config.namespace.another_key == "another key value" }
42
- assert { @config.key == "key value" }
43
- assert { @config.json_config.owner.name == "John Doe" }
44
- assert { @config.toml_config.owner.name == "Tom Preston-Werner" }
45
- assert { @config.ini_config.section1.var1 == "foo" }
46
- end
47
- end
data/test/test_helper.rb DELETED
@@ -1,21 +0,0 @@
1
- require "rubygems"
2
- require 'bundler/setup'
3
- require 'pry'
4
-
5
- Bundler.require
6
-
7
- require 'wrong/adapters/minitest'
8
-
9
- PROJECT_ROOT = File.join(Dir.pwd)
10
-
11
- Wrong.config.color
12
-
13
- Minitest.autorun
14
-
15
- class TestCase < Minitest::Test
16
- include Wrong
17
-
18
- def fixtures_path
19
- @path ||= File.expand_path(File.join(__FILE__, "../fixtures"))
20
- end
21
- end