aide 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e62e5574eb4be798be2b64c74f863433333b4ef9
4
- data.tar.gz: a9ce9a94d7e96b7b92da3cd48bb9238761c24549
3
+ metadata.gz: 8c01f8d45784fd63a3cdc2b22cf2a8994951e968
4
+ data.tar.gz: 74089e428c739b10404e253119b7a694d6d9d1aa
5
5
  SHA512:
6
- metadata.gz: ee154898d957e27ee14ee1e54c2299b80f5c015d06e661e25fe6d3747e3325c17ddd71d5df1079397b228cdaf892825fb26bfcc3b08d2c4956d56c7a3bd1aa80
7
- data.tar.gz: becca1c51d0c3d22cdca74934ac115f05916836763134aab4e301b3223c2aef4ab597b73ff0a57115a4e24f636529be4a4eca37130a25db7e0efe118236f3d0d
6
+ metadata.gz: 5f93664c613e9d839ec7766bdb164d6f483b737fb38210a867c615c036332df6af635003607fa271013df16939379ecf03e0174a21d570fae75c36c8b086cd6e
7
+ data.tar.gz: dccf0c39e44413b0048532de41fa53f72f906e56e49529b1a29509386470f4cff47eeebb31db08c6fb70777dc1aa4cc9aad2bbac879638069334728c7b631831
data/lib/aide/config.rb CHANGED
@@ -25,10 +25,14 @@ module Aide
25
25
  self.service_address_method = SERVICE_ADDRESS_METHOD
26
26
  end
27
27
 
28
- def add_service(name:, url:nil)
28
+ def add_service(name:, url:nil, auth:nil, user_key:nil, password_key:nil, protocol_key:nil)
29
29
  services[name] = {
30
30
  name: name,
31
- url: url
31
+ url: url,
32
+ auth: auth,
33
+ user_key: user_key,
34
+ password_key: password_key,
35
+ protocol_key: protocol_key
32
36
  }
33
37
  end
34
38
 
data/lib/aide/service.rb CHANGED
@@ -14,18 +14,20 @@ module Aide
14
14
 
15
15
  alias port ServicePort
16
16
 
17
- def url
17
+ def url(filtered: false)
18
18
  return if empty?
19
19
 
20
- template = Aide.config.get_service(name: name)[:url]
20
+ template = config[:url]
21
21
  return if template.nil?
22
22
 
23
23
  template = template.dup
24
+ template.gsub!(/{{\.protocol}}/, self.protocol.to_s)
24
25
  template.gsub!(/{{\.address}}/, self.address.to_s)
25
26
  template.gsub!(/{{\.Address}}/, self.Address.to_s)
26
27
  template.gsub!(/{{\.ServiceAddress}}/, self.ServiceAddress.to_s)
27
28
  template.gsub!(/{{\.ServicePort}}/, self.ServicePort.to_s)
28
29
  template.gsub!(/{{\.port}}/, self.port.to_s)
30
+ template.gsub!(/{{\.auth}}/, self.auth(filtered: filtered).to_s)
29
31
 
30
32
  template
31
33
  end
@@ -36,6 +38,70 @@ module Aide
36
38
  end
37
39
  end
38
40
 
41
+ def auth(filtered: false)
42
+ template = config[:auth]
43
+
44
+ if template.nil? || self.user.nil? || self.password.nil?
45
+ return
46
+ end
47
+
48
+ template = template.dup
49
+ template.gsub!(/{{\.user}}/, self.user.to_s)
50
+
51
+ password = nil
52
+ if filtered
53
+ password = 'PASSWORD'
54
+ else
55
+ password = self.password.to_s
56
+ end
57
+
58
+ template.gsub!(/{{\.password}}/, password)
59
+
60
+ template
61
+ end
62
+
63
+ def user_key
64
+ config[:user_key]
65
+ end
66
+
67
+ def user
68
+ return if user_key.nil?
69
+
70
+ @user ||= begin
71
+ user = Diplomat::Kv.get(user_key, {}, :return)
72
+ user = nil if user == ""
73
+ user
74
+ end
75
+ end
76
+
77
+ def password_key
78
+ config[:password_key]
79
+ end
80
+
81
+ def password
82
+ return if password_key.nil?
83
+
84
+ @password ||= begin
85
+ password = Diplomat::Kv.get(password_key, {}, :return)
86
+ password = nil if password == ""
87
+ password
88
+ end
89
+ end
90
+
91
+ def protocol_key
92
+ config[:protocol_key]
93
+ end
94
+
95
+ def protocol
96
+ return if protocol_key.nil?
97
+
98
+ @protocol ||= begin
99
+ protocol = Diplomat::Kv.get(protocol_key, {}, :return)
100
+ protocol = nil if protocol == ""
101
+ protocol
102
+ end
103
+ end
104
+
39
105
  def empty?
40
106
  service.to_h.empty?
41
107
  end
@@ -44,5 +110,9 @@ module Aide
44
110
  def service
45
111
  @service ||= Diplomat::Service.get(name)
46
112
  end
113
+
114
+ def config
115
+ @config ||= Aide.config.get_service(name: name)
116
+ end
47
117
  end
48
118
  end
data/lib/aide/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Aide
2
- VERSION = '0.1.3'
2
+ VERSION = '0.1.4'
3
3
  end
data/lib/aide.rb CHANGED
@@ -27,7 +27,7 @@ module Aide
27
27
 
28
28
  puts "Aide Services (Using #{config.service_address_key}):"
29
29
  self.services.each do |name, service|
30
- puts "==> #{name}: #{service.address}#{service.port.nil? ? '' : ":#{service.port}"} #{service.url}".strip
30
+ puts "==> #{name}: #{service.address}#{service.port.nil? ? '' : ":#{service.port}"} #{service.url(filtered: true)}".strip
31
31
  end
32
32
  end
33
33
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aide
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Schlesinger
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-03-05 00:00:00.000000000 Z
11
+ date: 2016-06-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler