configurate 0.1.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/Changelog.md +30 -0
- data/README.md +96 -20
- data/lib/configurate.rb +26 -15
- data/lib/configurate/lookup_chain.rb +19 -17
- data/lib/configurate/provider.rb +34 -27
- data/lib/configurate/provider/dynamic.rb +34 -17
- data/lib/configurate/provider/env.rb +18 -14
- data/lib/configurate/provider/string_hash.rb +46 -0
- data/lib/configurate/provider/toml.rb +39 -0
- data/lib/configurate/provider/yaml.rb +26 -32
- data/lib/configurate/proxy.rb +42 -13
- data/lib/configurate/setting_path.rb +20 -8
- data/spec/configurate/lookup_chain_spec.rb +11 -9
- data/spec/configurate/provider/dynamic_spec.rb +13 -5
- data/spec/configurate/provider/env_spec.rb +13 -11
- data/spec/configurate/provider/string_hash_spec.rb +82 -0
- data/spec/configurate/provider/toml_spec.rb +112 -0
- data/spec/configurate/provider/yaml_spec.rb +42 -18
- data/spec/configurate/provider_spec.rb +15 -2
- data/spec/configurate/proxy_spec.rb +33 -7
- data/spec/configurate/setting_path_spec.rb +39 -20
- data/spec/configurate_spec.rb +5 -3
- data/spec/spec_helper.rb +8 -5
- metadata +31 -13
- checksums.yaml.gz.asc +0 -11
- data.tar.gz.asc +0 -11
- metadata.gz.asc +0 -11
@@ -1,46 +1,61 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "spec_helper"
|
2
4
|
|
3
5
|
describe Configurate::SettingPath do
|
4
6
|
let(:normal_path) { described_class.new([:foo]) }
|
5
7
|
let(:question_path) { described_class.new([:foo?]) }
|
8
|
+
let(:action_path) { described_class.new([:foo!]) }
|
6
9
|
let(:setter_path) { described_class.new([:foo=]) }
|
7
10
|
let(:long_path) { described_class.new(["foo", "bar?"]) }
|
8
11
|
|
9
12
|
describe "#initialize" do
|
10
13
|
context "with a string" do
|
11
14
|
it "creates a path" do
|
12
|
-
expect(described_class.new
|
15
|
+
expect(described_class.new(long_path.to_s)).to eq long_path
|
13
16
|
end
|
14
17
|
end
|
15
18
|
end
|
16
19
|
|
17
|
-
describe "#
|
20
|
+
describe "#question?" do
|
18
21
|
context "with a question signature as setting" do
|
19
|
-
subject { question_path.
|
22
|
+
subject { question_path.question? }
|
20
23
|
it { should be_truthy }
|
21
24
|
end
|
22
25
|
|
23
26
|
context "with a normal path as setting" do
|
24
|
-
subject { normal_path.
|
27
|
+
subject { normal_path.question? }
|
25
28
|
it { should be_falsey }
|
26
29
|
end
|
27
30
|
end
|
28
31
|
|
29
|
-
describe "#
|
32
|
+
describe "#action?" do
|
33
|
+
context "with a action signature as setting" do
|
34
|
+
subject { action_path.action? }
|
35
|
+
it { should be_truthy }
|
36
|
+
end
|
37
|
+
|
38
|
+
context "with a normal path as setting" do
|
39
|
+
subject { normal_path.action? }
|
40
|
+
it { should be_falsey }
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
describe "#setter?" do
|
30
45
|
context "with a setter signature as setting" do
|
31
|
-
subject { setter_path.
|
46
|
+
subject { setter_path.setter? }
|
32
47
|
it { should be_truthy }
|
33
48
|
end
|
34
49
|
|
35
50
|
context "with a normal path as setting" do
|
36
|
-
subject { normal_path.
|
51
|
+
subject { normal_path.setter? }
|
37
52
|
it { should be_falsey }
|
38
53
|
end
|
39
54
|
end
|
40
55
|
|
41
56
|
describe "#initialize_copy" do
|
42
57
|
it "modifying a copy leaves the original unchanged" do
|
43
|
-
original = described_class.new [
|
58
|
+
original = described_class.new %w[foo bar]
|
44
59
|
copy = original.clone
|
45
60
|
copy << "baz"
|
46
61
|
expect(copy).to include "baz"
|
@@ -48,42 +63,46 @@ describe Configurate::SettingPath do
|
|
48
63
|
end
|
49
64
|
end
|
50
65
|
|
51
|
-
|
52
|
-
describe "#is_question_or_setter?" do
|
66
|
+
describe "#question_action_or_setter?" do
|
53
67
|
context "with a question signature as setting" do
|
54
|
-
subject { question_path.
|
68
|
+
subject { question_path.question_action_or_setter? }
|
69
|
+
it { should be_truthy }
|
70
|
+
end
|
71
|
+
|
72
|
+
context "with an action signature as setting" do
|
73
|
+
subject { action_path.question_action_or_setter? }
|
55
74
|
it { should be_truthy }
|
56
75
|
end
|
57
76
|
|
58
77
|
context "with a setter signature as setting" do
|
59
|
-
subject { setter_path.
|
78
|
+
subject { setter_path.question_action_or_setter? }
|
60
79
|
it { should be_truthy }
|
61
80
|
end
|
62
81
|
|
63
82
|
context "with a normal path as setting" do
|
64
|
-
subject { normal_path.
|
83
|
+
subject { normal_path.question_action_or_setter? }
|
65
84
|
it { should be_falsey }
|
66
85
|
end
|
67
86
|
end
|
68
87
|
|
69
88
|
describe "#each" do
|
70
89
|
it "should strip special characters" do
|
71
|
-
expect(long_path.all? {
|
90
|
+
expect(long_path.all? {|c| c.include? "?" }).to be_falsey
|
72
91
|
end
|
73
92
|
end
|
74
93
|
|
75
|
-
[
|
94
|
+
%i[join first last shift pop].each do |method|
|
76
95
|
describe "##{method}" do
|
77
96
|
subject { question_path.public_send method }
|
78
97
|
it { should_not include "?" }
|
79
98
|
end
|
80
99
|
end
|
81
100
|
|
82
|
-
[
|
101
|
+
%i[<< unshift push].each do |method|
|
83
102
|
describe "##{method}" do
|
84
|
-
it
|
103
|
+
it "converts the argument to a string" do
|
85
104
|
arg = double
|
86
|
-
expect(arg).to receive(:to_s).and_return(
|
105
|
+
expect(arg).to receive(:to_s).and_return("bar")
|
87
106
|
described_class.new.public_send method, arg
|
88
107
|
end
|
89
108
|
end
|
@@ -102,7 +121,7 @@ describe Configurate::SettingPath do
|
|
102
121
|
|
103
122
|
describe "#inspect" do
|
104
123
|
it "includes the dotted path" do
|
105
|
-
path = described_class.new([
|
124
|
+
path = described_class.new(%i[foo bar])
|
106
125
|
expect(path.inspect).to include "foo.bar"
|
107
126
|
end
|
108
127
|
end
|
data/spec/configurate_spec.rb
CHANGED
@@ -1,4 +1,6 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "spec_helper"
|
2
4
|
|
3
5
|
describe Configurate::Settings do
|
4
6
|
describe "#method_missing" do
|
@@ -12,8 +14,8 @@ describe Configurate::Settings do
|
|
12
14
|
end
|
13
15
|
end
|
14
16
|
|
15
|
-
|
16
|
-
describe
|
17
|
+
%i(lookup add_provider []).each do |method|
|
18
|
+
describe method.to_s do
|
17
19
|
subject { described_class.create }
|
18
20
|
|
19
21
|
it "delegates the call to #lookup_chain" do
|
data/spec/spec_helper.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# This file was generated by the `rspec --init` command. Conventionally, all
|
2
4
|
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
3
5
|
# Require this file using `require "spec_helper"` to ensure that it is only
|
@@ -5,17 +7,18 @@
|
|
5
7
|
#
|
6
8
|
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
7
9
|
|
8
|
-
|
9
10
|
begin
|
10
|
-
require
|
11
|
+
require "coveralls"
|
11
12
|
Coveralls.wear!
|
12
|
-
rescue LoadError
|
13
|
+
rescue LoadError
|
14
|
+
end
|
13
15
|
|
14
|
-
require
|
16
|
+
require "configurate"
|
15
17
|
|
16
18
|
def silence_stderr
|
17
19
|
$stderr = StringIO.new
|
18
20
|
yield
|
21
|
+
ensure
|
19
22
|
$stderr = STDERR
|
20
23
|
end
|
21
24
|
|
@@ -27,7 +30,7 @@ RSpec.configure do |config|
|
|
27
30
|
# order dependency and want to debug it, you can fix the order by providing
|
28
31
|
# the seed, which is printed after each run.
|
29
32
|
# --seed 1234
|
30
|
-
config.order =
|
33
|
+
config.order = "random"
|
31
34
|
|
32
35
|
config.expect_with :rspec do |expect_config|
|
33
36
|
expect_config.syntax = :expect
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: configurate
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonne Haß
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-09-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '3.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: toml-rb
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 2.0.1
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 2.0.1
|
41
55
|
description: Configurate is a flexible configuration system that can read settings
|
42
56
|
from multiple sources at the same time.
|
43
57
|
email: me@jhass.eu
|
@@ -53,12 +67,16 @@ files:
|
|
53
67
|
- lib/configurate/provider.rb
|
54
68
|
- lib/configurate/provider/dynamic.rb
|
55
69
|
- lib/configurate/provider/env.rb
|
70
|
+
- lib/configurate/provider/string_hash.rb
|
71
|
+
- lib/configurate/provider/toml.rb
|
56
72
|
- lib/configurate/provider/yaml.rb
|
57
73
|
- lib/configurate/proxy.rb
|
58
74
|
- lib/configurate/setting_path.rb
|
59
75
|
- spec/configurate/lookup_chain_spec.rb
|
60
76
|
- spec/configurate/provider/dynamic_spec.rb
|
61
77
|
- spec/configurate/provider/env_spec.rb
|
78
|
+
- spec/configurate/provider/string_hash_spec.rb
|
79
|
+
- spec/configurate/provider/toml_spec.rb
|
62
80
|
- spec/configurate/provider/yaml_spec.rb
|
63
81
|
- spec/configurate/provider_spec.rb
|
64
82
|
- spec/configurate/proxy_spec.rb
|
@@ -69,7 +87,7 @@ homepage: http://jhass.github.io/configurate
|
|
69
87
|
licenses:
|
70
88
|
- MIT
|
71
89
|
metadata: {}
|
72
|
-
post_install_message:
|
90
|
+
post_install_message:
|
73
91
|
rdoc_options: []
|
74
92
|
require_paths:
|
75
93
|
- lib
|
@@ -77,26 +95,26 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
77
95
|
requirements:
|
78
96
|
- - ">="
|
79
97
|
- !ruby/object:Gem::Version
|
80
|
-
version:
|
98
|
+
version: 2.0.0
|
81
99
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
82
100
|
requirements:
|
83
101
|
- - ">="
|
84
102
|
- !ruby/object:Gem::Version
|
85
103
|
version: '0'
|
86
104
|
requirements: []
|
87
|
-
|
88
|
-
|
89
|
-
signing_key:
|
105
|
+
rubygems_version: 3.1.2
|
106
|
+
signing_key:
|
90
107
|
specification_version: 4
|
91
108
|
summary: Flexbile configuration system
|
92
109
|
test_files:
|
93
|
-
- spec/
|
110
|
+
- spec/spec_helper.rb
|
94
111
|
- spec/configurate/lookup_chain_spec.rb
|
112
|
+
- spec/configurate/provider/toml_spec.rb
|
113
|
+
- spec/configurate/provider/dynamic_spec.rb
|
95
114
|
- spec/configurate/provider/yaml_spec.rb
|
115
|
+
- spec/configurate/provider/string_hash_spec.rb
|
96
116
|
- spec/configurate/provider/env_spec.rb
|
97
|
-
- spec/configurate/provider/dynamic_spec.rb
|
98
|
-
- spec/configurate/setting_path_spec.rb
|
99
117
|
- spec/configurate/proxy_spec.rb
|
100
|
-
- spec/
|
118
|
+
- spec/configurate/provider_spec.rb
|
119
|
+
- spec/configurate/setting_path_spec.rb
|
101
120
|
- spec/configurate_spec.rb
|
102
|
-
has_rdoc:
|
checksums.yaml.gz.asc
DELETED
@@ -1,11 +0,0 @@
|
|
1
|
-
-----BEGIN PGP SIGNATURE-----
|
2
|
-
Version: GnuPG v2
|
3
|
-
|
4
|
-
iQEcBAABAgAGB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