confyio 2.0.0 → 2.1.0
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/confy/config.rb +36 -11
- data/lib/confy/http_client/auth_handler.rb +0 -2
- metadata +13 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 58372fe4871d226c0d4e12fcf1fd39f73be7e15e
|
4
|
+
data.tar.gz: d13686c5f09d80b3174eda687f70dcd050f02785
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4a738798bdbad4c78b45bc7078fd64780e3d13ec07bbc4a90ca822f2699c95def34d7a2c6f2132c5ee943438138b8c23fba99d617f2e3779c867fbabebabcf57
|
7
|
+
data.tar.gz: fc8bfd25c75d64948749b7b7cf3532348f9e8d9415423f10d0798666964fcff724d8222739a9ab3a19274f0dd4da8581d409d00a378af72f9406ab49a2dd31b5
|
data/lib/confy/config.rb
CHANGED
@@ -7,27 +7,52 @@ module Confy
|
|
7
7
|
|
8
8
|
class Config
|
9
9
|
|
10
|
-
def self.
|
11
|
-
|
10
|
+
def self.match(url)
|
11
|
+
if url.is_a?(String)
|
12
12
|
name_regex = '([a-z0-9][a-z0-9-]*[a-z0-9])'
|
13
|
-
|
14
|
-
|
13
|
+
token_regex = '([a-f0-9]{40})'
|
14
|
+
path_regex = 'orgs\\/' + name_regex + '(\\/projects\\/' + name_regex + '\\/envs\\/' + name_regex + '\\/config|\\/config\\/' + token_regex + ')'
|
15
|
+
url_regex = Regexp.new('(https?:\\/\\/)((.*):(.*)@)?(.*)\\/(' + path_regex + '|heroku\\/config)', true)
|
15
16
|
|
16
17
|
matches = url_regex.match(url)
|
17
18
|
|
18
|
-
raise 'Invalid
|
19
|
+
raise 'Invalid URL' if matches.nil?
|
19
20
|
|
20
21
|
url = {
|
21
|
-
:host => matches[1] + matches[
|
22
|
-
:user => matches[
|
22
|
+
:host => matches[1] + matches[5],
|
23
|
+
:user => matches[3], :pass => matches[4],
|
24
|
+
:org => matches[7], :project => matches[9], :env => matches[10],
|
25
|
+
:token => matches[11],
|
26
|
+
:heroku => (matches[6] == 'heroku/config')
|
23
27
|
}
|
24
28
|
end
|
25
29
|
|
26
|
-
raise 'Invalid
|
30
|
+
raise 'Invalid URL' if !url.is_a?(Hash)
|
31
|
+
|
32
|
+
if url[:host] and url[:user] and url[:pass] and url[:heroku]
|
33
|
+
url[:path] = '/heroku/config'
|
34
|
+
elsif url[:host] and url[:token] and url[:org]
|
35
|
+
url[:path] = '/orgs/' + url[:org] + '/config/' + url[:token]
|
36
|
+
elsif url[:host] and url[:user] and url[:pass] and url[:org] and url[:project] and url[:env]
|
37
|
+
url[:path] = '/orgs/' + url[:org] + '/projects/' + url[:project] + '/envs/' + url[:env] + '/config'
|
38
|
+
else
|
39
|
+
raise 'Invalid URL'
|
40
|
+
end
|
41
|
+
|
42
|
+
url
|
43
|
+
end
|
44
|
+
|
45
|
+
def self.load(url = {})
|
46
|
+
url = self.match(url)
|
47
|
+
|
48
|
+
auth = {}
|
49
|
+
|
50
|
+
if url[:user] and url[:pass]
|
51
|
+
auth[:username] = url[:user]
|
52
|
+
auth[:password] = url[:pass]
|
53
|
+
end
|
27
54
|
|
28
|
-
client = Confy::Client.new({
|
29
|
-
:username => url[:user], :password => url[:pass]
|
30
|
-
}, { :base => url[:host] })
|
55
|
+
client = Confy::Client.new(auth, { :base => url[:host] })
|
31
56
|
|
32
57
|
body = client.instance_variable_get(:@http_client).get(url[:path]).body
|
33
58
|
|
metadata
CHANGED
@@ -1,53 +1,53 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: confyio
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pavan Kumar Sunkara
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-12-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0.9'
|
20
|
-
- -
|
20
|
+
- - ">="
|
21
21
|
- !ruby/object:Gem::Version
|
22
22
|
version: 0.9.0
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
26
26
|
requirements:
|
27
|
-
- - ~>
|
27
|
+
- - "~>"
|
28
28
|
- !ruby/object:Gem::Version
|
29
29
|
version: '0.9'
|
30
|
-
- -
|
30
|
+
- - ">="
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: 0.9.0
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: json
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
36
36
|
requirements:
|
37
|
-
- - ~>
|
37
|
+
- - "~>"
|
38
38
|
- !ruby/object:Gem::Version
|
39
39
|
version: '1.7'
|
40
|
-
- -
|
40
|
+
- - ">="
|
41
41
|
- !ruby/object:Gem::Version
|
42
42
|
version: 1.7.7
|
43
43
|
type: :runtime
|
44
44
|
prerelease: false
|
45
45
|
version_requirements: !ruby/object:Gem::Requirement
|
46
46
|
requirements:
|
47
|
-
- - ~>
|
47
|
+
- - "~>"
|
48
48
|
- !ruby/object:Gem::Version
|
49
49
|
version: '1.7'
|
50
|
-
- -
|
50
|
+
- - ">="
|
51
51
|
- !ruby/object:Gem::Version
|
52
52
|
version: 1.7.7
|
53
53
|
description: Official Confy API library client for ruby
|
@@ -86,19 +86,18 @@ require_paths:
|
|
86
86
|
- lib
|
87
87
|
required_ruby_version: !ruby/object:Gem::Requirement
|
88
88
|
requirements:
|
89
|
-
- -
|
89
|
+
- - ">="
|
90
90
|
- !ruby/object:Gem::Version
|
91
91
|
version: '0'
|
92
92
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- -
|
94
|
+
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
97
|
requirements: []
|
98
98
|
rubyforge_project:
|
99
|
-
rubygems_version: 2.4.5
|
99
|
+
rubygems_version: 2.4.5.1
|
100
100
|
signing_key:
|
101
101
|
specification_version: 4
|
102
102
|
summary: Official Confy API library client for ruby
|
103
103
|
test_files: []
|
104
|
-
has_rdoc:
|