uri_config 0.0.7 → 0.0.8
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 +4 -4
- data/lib/uri_config/config.rb +7 -1
- data/lib/uri_config/version.rb +1 -1
- data/spec/config_spec.rb +27 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3df420447e8f57f3918f652e0bbcdc59cabbdc73
|
4
|
+
data.tar.gz: d47ed2b33d353dc82be7cb3876fb1cef14b0d614
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bb3963a38308048e2c802caaf60cf6f3bc576ec932cbedf894f314c401bece4754d1365a2b1f27fe155cb78654f3986a6eac3ece5b496387084912723497a13b
|
7
|
+
data.tar.gz: ff41f08ced96f8fcda1544be593c3c96247c61589fd88d12c87aa90f5506735bc6239994df4b50aa92804ff017054af7272a43b929685fa58d79cd4e7ab64db8
|
data/lib/uri_config/config.rb
CHANGED
@@ -23,6 +23,12 @@ module URIConfig
|
|
23
23
|
yield new(value)
|
24
24
|
end
|
25
25
|
|
26
|
+
def self.configure_from!(env_var)
|
27
|
+
return unless (value = ENV.fetch(env_var))
|
28
|
+
|
29
|
+
yield new(value)
|
30
|
+
end
|
31
|
+
|
26
32
|
def self.values_from(env_var, *params)
|
27
33
|
config = new(ENV.fetch(env_var))
|
28
34
|
params.map { |param| config.public_send(param) }
|
@@ -81,7 +87,7 @@ module URIConfig
|
|
81
87
|
|
82
88
|
def uri
|
83
89
|
@uri ||= URI.parse url
|
84
|
-
rescue URI::InvalidURIError
|
90
|
+
rescue URI::InvalidURIError
|
85
91
|
raise URI::InvalidURIError, "Invalid URI: <URL_SUPPRESSED>"
|
86
92
|
end
|
87
93
|
end
|
data/lib/uri_config/version.rb
CHANGED
data/spec/config_spec.rb
CHANGED
@@ -41,7 +41,7 @@ module URIConfig
|
|
41
41
|
specify do
|
42
42
|
expect do
|
43
43
|
URIConfig::Config.values_from("TEST_URL")
|
44
|
-
end.to raise_error
|
44
|
+
end.to raise_error KeyError
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
@@ -88,6 +88,32 @@ module URIConfig
|
|
88
88
|
end
|
89
89
|
end
|
90
90
|
|
91
|
+
describe ".configure_from!" do
|
92
|
+
context "when TEST_URL is not set" do
|
93
|
+
specify do
|
94
|
+
expect do
|
95
|
+
URIConfig::Config.configure_from!("TEST_URL") {}
|
96
|
+
end.to raise_error KeyError, 'key not found: "TEST_URL"'
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
context "when TEST_URL is set" do
|
101
|
+
before(:each) do
|
102
|
+
ENV["TEST_URL"] = "https://example.com/foo"
|
103
|
+
end
|
104
|
+
|
105
|
+
after(:each) do
|
106
|
+
ENV["TEST_URL"] = nil
|
107
|
+
end
|
108
|
+
|
109
|
+
specify do
|
110
|
+
expect do |b|
|
111
|
+
URIConfig::Config.configure_from!("TEST_URL", &b)
|
112
|
+
end.to yield_with_args(URIConfig::Config.new(ENV["TEST_URL"]))
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
91
117
|
# This behaviour will make it ... difficult to troubleshoot
|
92
118
|
it "should not leak secrets on error" do
|
93
119
|
url = "https://USER:secret@foo.bar.com@foo.bar.com/"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: uri_config
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonathon M. Abbott
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-09-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -117,3 +117,4 @@ test_files:
|
|
117
117
|
- spec/action_mailer_config_spec.rb
|
118
118
|
- spec/config_spec.rb
|
119
119
|
- spec/s3_config_spec.rb
|
120
|
+
has_rdoc:
|