persey 0.0.9 → 2.0.1
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 +5 -5
- data/.travis.yml +2 -1
- data/Dockerfile +1 -1
- data/Gemfile +3 -4
- data/README.md +6 -2
- data/Rakefile +0 -9
- data/docker-compose.yml +1 -1
- data/lib/persey/adapters/base.rb +9 -3
- data/lib/persey/adapters/ini.rb +7 -7
- data/lib/persey/adapters/json.rb +9 -10
- data/lib/persey/adapters/ssm.rb +38 -0
- data/lib/persey/adapters/toml.rb +7 -7
- data/lib/persey/adapters/yaml.rb +13 -6
- data/lib/persey/builder.rb +2 -0
- data/lib/persey/configus_patch.rb +2 -0
- data/lib/persey/inspector.rb +14 -6
- data/lib/persey/loader.rb +3 -1
- data/lib/persey/version.rb +3 -1
- data/lib/persey.rb +14 -11
- data/persey.gemspec +7 -4
- data/spec/fixtures/broken_yaml_config.yml +5 -0
- data/{test → spec}/fixtures/ini_config.ini +0 -0
- data/{test → spec}/fixtures/json_config.json +0 -0
- data/{test → spec}/fixtures/toml_config.toml +0 -0
- data/{test → spec}/fixtures/yaml_config.yml +0 -0
- data/{test → spec}/fixtures/yaml_config_with_envs.yml +0 -0
- data/spec/lib/persey_spec.rb +80 -0
- data/spec/spec_helper.rb +29 -0
- metadata +49 -19
- data/test/lib/persey_test.rb +0 -47
- data/test/test_helper.rb +0 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 25b98a5bf970d30e825aaef946b99786d99c565fe6d38a1ff1cf9f8d5dd820d5
|
4
|
+
data.tar.gz: 07c32c8824ec406863b19f534b0ce1254a4d5278fc73d5f9a43fb2dd6043c58f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3f82c680006f731c112c87f7a834aa66aea87be293dff1addd23b091e6bd151eac16931af20a1d338ea7c8acf128c34feba0517425424dc6ba524987b42767c8
|
7
|
+
data.tar.gz: edc5d2fdc4591fcbc4f2cb56e8b69ed410b6b435e5b02701abc9555b3e8931b3a9714f7a710ff5ee19f26d3993afe6560f70fbb0e9c00fd35246e7d226d20920
|
data/.travis.yml
CHANGED
data/Dockerfile
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Persey [](https://travis-ci.org/zzet/persey) [](http://badge.fury.io/rb/persey)[](https://codeclimate.com/github/zzet/persey) [](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
|
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
data/docker-compose.yml
CHANGED
data/lib/persey/adapters/base.rb
CHANGED
@@ -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.
|
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
|
data/lib/persey/adapters/ini.rb
CHANGED
@@ -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,
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
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
|
data/lib/persey/adapters/json.rb
CHANGED
@@ -1,18 +1,17 @@
|
|
1
|
-
|
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,
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
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,38 @@
|
|
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
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def ssm_client(opts)
|
33
|
+
opts[:client] || Aws::SSM::Client.new
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
data/lib/persey/adapters/toml.rb
CHANGED
@@ -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,
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
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
|
data/lib/persey/adapters/yaml.rb
CHANGED
@@ -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,
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
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
|
data/lib/persey/builder.rb
CHANGED
data/lib/persey/inspector.rb
CHANGED
@@ -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,13 +13,17 @@ module Persey
|
|
9
13
|
@sources
|
10
14
|
end
|
11
15
|
|
12
|
-
def source(source_type, config_file, namespace = nil)
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
binding.pry
|
16
|
+
def source(source_type, config_file, namespace = nil, opts = {})
|
17
|
+
klass = "persey/adapters/#{source_type}".camelize.constantize
|
18
|
+
|
19
|
+
unless klass.config_exists?(config_file, opts: opts)
|
20
|
+
raise MissingConfigFile, "Can't find #{source_type} config: #{config_file}"
|
18
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)
|
19
27
|
end
|
20
28
|
|
21
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]
|
data/lib/persey/version.rb
CHANGED
data/lib/persey.rb
CHANGED
@@ -1,13 +1,16 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
7
|
-
require
|
8
|
-
require
|
9
|
-
require
|
10
|
-
require
|
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
|
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
|
21
|
+
spec.add_runtime_dependency 'activesupport'
|
22
22
|
spec.add_runtime_dependency 'configus', '>= 0.0.5'
|
23
|
-
spec.add_runtime_dependency '
|
24
|
-
spec.add_runtime_dependency
|
25
|
-
spec.add_runtime_dependency
|
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
|
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
|
data/spec/spec_helper.rb
ADDED
@@ -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:
|
4
|
+
version: 2.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrey Kumanyaev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-11-01 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:
|
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:
|
@@ -102,6 +130,7 @@ files:
|
|
102
130
|
- lib/persey/adapters/base.rb
|
103
131
|
- lib/persey/adapters/ini.rb
|
104
132
|
- lib/persey/adapters/json.rb
|
133
|
+
- lib/persey/adapters/ssm.rb
|
105
134
|
- lib/persey/adapters/toml.rb
|
106
135
|
- lib/persey/adapters/yaml.rb
|
107
136
|
- lib/persey/builder.rb
|
@@ -110,13 +139,14 @@ files:
|
|
110
139
|
- lib/persey/loader.rb
|
111
140
|
- lib/persey/version.rb
|
112
141
|
- persey.gemspec
|
113
|
-
-
|
114
|
-
-
|
115
|
-
-
|
116
|
-
-
|
117
|
-
-
|
118
|
-
-
|
119
|
-
-
|
142
|
+
- spec/fixtures/broken_yaml_config.yml
|
143
|
+
- spec/fixtures/ini_config.ini
|
144
|
+
- spec/fixtures/json_config.json
|
145
|
+
- spec/fixtures/toml_config.toml
|
146
|
+
- spec/fixtures/yaml_config.yml
|
147
|
+
- spec/fixtures/yaml_config_with_envs.yml
|
148
|
+
- spec/lib/persey_spec.rb
|
149
|
+
- spec/spec_helper.rb
|
120
150
|
homepage: https://github.com/zzet/persey
|
121
151
|
licenses:
|
122
152
|
- MIT
|
@@ -136,16 +166,16 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
136
166
|
- !ruby/object:Gem::Version
|
137
167
|
version: '0'
|
138
168
|
requirements: []
|
139
|
-
|
140
|
-
rubygems_version: 2.5.1
|
169
|
+
rubygems_version: 3.1.2
|
141
170
|
signing_key:
|
142
171
|
specification_version: 4
|
143
172
|
summary: Helps you easily manage environment specific settings
|
144
173
|
test_files:
|
145
|
-
-
|
146
|
-
-
|
147
|
-
-
|
148
|
-
-
|
149
|
-
-
|
150
|
-
-
|
151
|
-
-
|
174
|
+
- spec/fixtures/broken_yaml_config.yml
|
175
|
+
- spec/fixtures/ini_config.ini
|
176
|
+
- spec/fixtures/json_config.json
|
177
|
+
- spec/fixtures/toml_config.toml
|
178
|
+
- spec/fixtures/yaml_config.yml
|
179
|
+
- spec/fixtures/yaml_config_with_envs.yml
|
180
|
+
- spec/lib/persey_spec.rb
|
181
|
+
- spec/spec_helper.rb
|
data/test/lib/persey_test.rb
DELETED
@@ -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
|