persey 0.0.10 → 0.0.11

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2e1f9f5660692b33b255dc9b0157e8a13392d89c
4
- data.tar.gz: 6799d9fe91d1e3786e0f43a998ce6a03ea249a71
3
+ metadata.gz: 4b2133ecea516e37fec41f835ff20f23e1f9a071
4
+ data.tar.gz: dffc911ff91650efc41f037de58551e941b9d69c
5
5
  SHA512:
6
- metadata.gz: 570ad3fc120b38e2c530be2de118f32ad8889679a561033eecb9fd9f2d92d7e0e6cdb2a1907b6953f750c9378a456d8def7a72ff735d4586a6c67c97fcc31018
7
- data.tar.gz: 9f4170c5e32b8ca80be03def4e0eceb75dcd24f364940ad96d36a43997d68263448663e0addbcc9c024a99018cd8b6143aaafd673fcd4324d9eb45c962b3a156
6
+ metadata.gz: 1b3d757c399a4d9d81d587b1623126400bed5d2094f8af44542cc4e9155bce0a043a03450fa1de9ec26fe142bc93fbe90c9e28b1926a931dba318c80c86a79e3
7
+ data.tar.gz: c490136c10bdcc155db2f66cf90028bed006e47245219dcf7ff3dcd51686d4a7543e8734331d0d41218987011350a20bafe56ee39a6f51265c1af023df8a3f46
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.4.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) [![Dependency Status](https://gemnasium.com/zzet/persey.svg)](https://gemnasium.com/zzet/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", '>= 0.0.11'
29
29
  ```
30
30
 
31
31
  Generate default config file
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
data/lib/persey.rb CHANGED
@@ -1,13 +1,13 @@
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
+ 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'
11
11
 
12
12
  module Persey
13
13
  class << self
@@ -2,6 +2,8 @@ require 'yaml'
2
2
  require 'erb'
3
3
 
4
4
  module Persey
5
+ class MissingEnvVariable < RuntimeError; end
6
+
5
7
  module Adapters
6
8
  class Yaml < Persey::Adapters::Base
7
9
  class << self
@@ -9,8 +11,13 @@ module Persey
9
11
  begin
10
12
  raw_hash = YAML.load(ERB.new(File.read(file)).result)
11
13
  symbolize_keys(raw_hash)
12
- rescue
13
- puts "FATAL: Error while process config from file '#{file}'"
14
+ rescue KeyError => e
15
+ _, line, method = /\(erb\):(\d+):in `(.*)'/.match(e.backtrace[0]).to_a
16
+ if method == 'fetch'
17
+ raise MissingEnvVariable.new("Check line ##{line} in #{file}")
18
+ else
19
+ raise e
20
+ end
14
21
  end
15
22
  end
16
23
  end
@@ -1,6 +1,8 @@
1
1
  require 'active_support/inflector'
2
2
 
3
3
  module Persey
4
+ class MissingConfigFile < RuntimeError; end
5
+
4
6
  class Inspector
5
7
  class << self
6
8
  def analize(&block)
@@ -10,10 +12,12 @@ module Persey
10
12
  end
11
13
 
12
14
  def source(source_type, config_file, namespace = nil)
13
- override_config_file = config_file + '.override'
15
+ raise MissingConfigFile.new("Can't find #{source_type} config: #{config_file}") unless File.exist?(config_file)
14
16
 
15
17
  klass = "persey/adapters/#{source_type}".camelize.constantize
16
- @sources << { class: klass, file: config_file, namespace: namespace } if File.exist?(config_file)
18
+ @sources << { class: klass, file: config_file, namespace: namespace }
19
+
20
+ override_config_file = config_file + '.override'
17
21
  @sources << { class: klass, file: override_config_file, namespace: namespace } if File.exist?(override_config_file)
18
22
  end
19
23
 
@@ -1,3 +1,3 @@
1
1
  module Persey
2
- VERSION = "0.0.10"
2
+ VERSION = "0.0.11"
3
3
  end
data/persey.gemspec CHANGED
@@ -18,9 +18,11 @@ 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
23
  spec.add_runtime_dependency 'yajl-ruby'
24
- spec.add_runtime_dependency "toml", "~> 0.1.0"
25
- spec.add_runtime_dependency "inifile"
24
+ spec.add_runtime_dependency 'toml', '~> 0.1.0'
25
+ spec.add_runtime_dependency 'inifile'
26
+
27
+ spec.add_development_dependency 'simplecov'
26
28
  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,75 @@
1
+ require 'spec_helper'
2
+
3
+ describe Persey do
4
+ context 'true-flow input data' do
5
+ before do
6
+ plain_config = File.join(fixtures_path, 'yaml_config.yml')
7
+ env_config = File.join(fixtures_path, 'yaml_config_with_envs.yml')
8
+ plain_json_config = File.join(fixtures_path, 'json_config.json')
9
+ plain_toml_config = File.join(fixtures_path, 'toml_config.toml')
10
+ plain_ini_config = File.join(fixtures_path, 'ini_config.ini')
11
+
12
+ Persey.init :production do
13
+ source :yaml, plain_config
14
+ source :yaml, env_config, :namespace
15
+ source :json, plain_json_config, :json_config
16
+ source :toml, plain_toml_config, :toml_config
17
+ source :ini, plain_ini_config, :ini_config
18
+
19
+ env :production do
20
+ option do
21
+ first "first value"
22
+ second "second value"
23
+ end
24
+
25
+ first do
26
+ testss -> { second }
27
+ end
28
+ end
29
+ end
30
+ end
31
+
32
+ it '#config' do
33
+ expect { Persey.config }.not_to raise_exception
34
+ end
35
+
36
+ it '#config.methods' do
37
+ @config = Persey.config
38
+ expect(@config.option.first).to eq('first value')
39
+ expect(@config.first.testss).to eq('foo value')
40
+ expect(@config.first.second).to eq('foo value')
41
+ expect(@config.namespace.another_key).to eq('another key value')
42
+ expect(@config.namespace.another_key).to eq('another key value')
43
+ expect(@config.key).to eq('key value')
44
+ expect(@config.json_config.owner.name).to eq('John Doe')
45
+ expect(@config.toml_config.owner.name).to eq('Tom Preston-Werner')
46
+ expect(@config.ini_config.section1.var1).to eq('foo')
47
+ end
48
+ end
49
+
50
+ context 'false-flow data' do
51
+ it 'missing config' do
52
+ missing_config = File.join(fixtures_path, 'missing_yaml_config.yml')
53
+
54
+ expect do
55
+ Persey.init :production do
56
+ source :yaml, missing_config
57
+
58
+ env :production
59
+ end
60
+ end.to raise_error(Persey::MissingConfigFile)
61
+ end
62
+
63
+ it 'missing ENV.fetch' do
64
+ broken_yaml_config = File.join(fixtures_path, 'broken_yaml_config.yml')
65
+
66
+ expect do
67
+ Persey.init :production do
68
+ source :yaml, broken_yaml_config
69
+
70
+ env :production
71
+ end
72
+ end.to raise_error(Persey::MissingEnvVariable)
73
+ end
74
+ end
75
+ 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: 0.0.11
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: 2017-06-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -80,6 +80,20 @@ dependencies:
80
80
  - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: simplecov
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
83
97
  description: Persey helps you easily load configs from different files and use them
84
98
  from one variable. Based on Configus.
85
99
  email:
@@ -110,13 +124,14 @@ files:
110
124
  - lib/persey/loader.rb
111
125
  - lib/persey/version.rb
112
126
  - 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
127
+ - spec/fixtures/broken_yaml_config.yml
128
+ - spec/fixtures/ini_config.ini
129
+ - spec/fixtures/json_config.json
130
+ - spec/fixtures/toml_config.toml
131
+ - spec/fixtures/yaml_config.yml
132
+ - spec/fixtures/yaml_config_with_envs.yml
133
+ - spec/lib/persey_spec.rb
134
+ - spec/spec_helper.rb
120
135
  homepage: https://github.com/zzet/persey
121
136
  licenses:
122
137
  - MIT
@@ -142,10 +157,11 @@ signing_key:
142
157
  specification_version: 4
143
158
  summary: Helps you easily manage environment specific settings
144
159
  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
160
+ - spec/fixtures/broken_yaml_config.yml
161
+ - spec/fixtures/ini_config.ini
162
+ - spec/fixtures/json_config.json
163
+ - spec/fixtures/toml_config.toml
164
+ - spec/fixtures/yaml_config.yml
165
+ - spec/fixtures/yaml_config_with_envs.yml
166
+ - spec/lib/persey_spec.rb
167
+ - 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