smart_env 0.0.2 → 0.0.3
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.
- data/lib/smart_env/uri_proxy.rb +6 -0
- data/lib/smart_env/version.rb +1 -1
- data/spec/uri_spec.rb +4 -1
- metadata +2 -2
data/lib/smart_env/uri_proxy.rb
CHANGED
@@ -1,14 +1,20 @@
|
|
1
1
|
require 'uri'
|
2
|
+
require 'cgi'
|
2
3
|
require 'forwardable'
|
3
4
|
|
4
5
|
module SmartEnv
|
5
6
|
class UriProxy < BasicObject
|
7
|
+
attr_reader :params
|
6
8
|
extend ::Forwardable
|
7
9
|
def_delegators :@uri, *(::URI::Generic::COMPONENT + [:user, :password])
|
8
10
|
|
9
11
|
def initialize(uri)
|
10
12
|
@original = uri
|
11
13
|
@uri = ::URI.parse(uri)
|
14
|
+
@params = ::CGI.parse(@uri.query.to_s)
|
15
|
+
@params.each do |key, values|
|
16
|
+
@params[key] = values.first if values.size == 1
|
17
|
+
end
|
12
18
|
end
|
13
19
|
|
14
20
|
def base_uri
|
data/lib/smart_env/version.rb
CHANGED
data/spec/uri_spec.rb
CHANGED
@@ -12,7 +12,6 @@ describe SmartEnv, 'uri support' do
|
|
12
12
|
end
|
13
13
|
|
14
14
|
context "with a value FOO that is a URI" do
|
15
|
-
|
16
15
|
before do
|
17
16
|
@url = 'http://username:password@this.domain.example.com:3000/path?var=val'
|
18
17
|
ENV['FOO'] = @url
|
@@ -46,5 +45,9 @@ describe SmartEnv, 'uri support' do
|
|
46
45
|
it "should respond to #port with the port" do
|
47
46
|
ENV['FOO'].port.should == 3000
|
48
47
|
end
|
48
|
+
|
49
|
+
it "should expose params via the #params method" do
|
50
|
+
ENV['FOO'].params['var'].should == 'val'
|
51
|
+
end
|
49
52
|
end
|
50
53
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: smart_env
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-08-
|
12
|
+
date: 2011-08-26 00:00:00.000000000 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
description: Allows you to register Proxy classes for ENV vars by using blocks to
|