aide 0.1.2 → 0.1.3

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: 3c043d43637e3f55212d711c95e6c51c93175046
4
- data.tar.gz: bb167436a72f43028c86e5b35040518586b675ff
3
+ metadata.gz: e62e5574eb4be798be2b64c74f863433333b4ef9
4
+ data.tar.gz: a9ce9a94d7e96b7b92da3cd48bb9238761c24549
5
5
  SHA512:
6
- metadata.gz: 0771cec971854081388548595aa690868b72dd6cb4a651145a1c52597132d58cb63bbe7b8f1d2fd0bbde2677cb17593ad2afef2c898f6e002a886656c4bd4e27
7
- data.tar.gz: 1a90c4c28588e9aa95f5f860d6a6a4c42025b253b8729e4657ecd9efc6228d31f8841788c0098fcf91be0b089ab5901d70c1ae1c12f42fc9879d679afdf099af
6
+ metadata.gz: ee154898d957e27ee14ee1e54c2299b80f5c015d06e661e25fe6d3747e3325c17ddd71d5df1079397b228cdaf892825fb26bfcc3b08d2c4956d56c7a3bd1aa80
7
+ data.tar.gz: becca1c51d0c3d22cdca74934ac115f05916836763134aab4e301b3223c2aef4ab597b73ff0a57115a4e24f636529be4a4eca37130a25db7e0efe118236f3d0d
data/lib/aide/config.rb CHANGED
@@ -1,12 +1,31 @@
1
1
  module Aide
2
2
  class Config
3
- attr_accessor :services
3
+ attr_accessor :services,
4
+ :service_address_key,
5
+ :service_address_method
6
+
7
+ ADDRESS_KEY = '.Address'.freeze
8
+ ADDRESS_METHOD = :Address
9
+ SERVICE_ADDRESS_KEY = '.ServiceAddress'.freeze
10
+ SERVICE_ADDRESS_METHOD = :ServiceAddress
4
11
 
5
12
  def initialize
6
13
  @services = {}
14
+ @service_address_key = ADDRESS_KEY
15
+ @service_address_method = ADDRESS_METHOD
16
+ end
17
+
18
+ def use_address!
19
+ self.service_address_key = ADDRESS_KEY
20
+ self.service_address_method = ADDRESS_METHOD
21
+ end
22
+
23
+ def use_service_address!
24
+ self.service_address_key = SERVICE_ADDRESS_KEY
25
+ self.service_address_method = SERVICE_ADDRESS_METHOD
7
26
  end
8
27
 
9
- def add_service(name:, url:)
28
+ def add_service(name:, url:nil)
10
29
  services[name] = {
11
30
  name: name,
12
31
  url: url
data/lib/aide/service.rb CHANGED
@@ -8,6 +8,12 @@ module Aide
8
8
 
9
9
  delegate :Address, :ServiceAddress, :ServicePort, to: :service
10
10
 
11
+ def address
12
+ send(Aide.config.service_address_method)
13
+ end
14
+
15
+ alias port ServicePort
16
+
11
17
  def url
12
18
  return if empty?
13
19
 
@@ -15,9 +21,11 @@ module Aide
15
21
  return if template.nil?
16
22
 
17
23
  template = template.dup
24
+ template.gsub!(/{{\.address}}/, self.address.to_s)
18
25
  template.gsub!(/{{\.Address}}/, self.Address.to_s)
19
26
  template.gsub!(/{{\.ServiceAddress}}/, self.ServiceAddress.to_s)
20
27
  template.gsub!(/{{\.ServicePort}}/, self.ServicePort.to_s)
28
+ template.gsub!(/{{\.port}}/, self.port.to_s)
21
29
 
22
30
  template
23
31
  end
data/lib/aide/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Aide
2
- VERSION = '0.1.2'
2
+ VERSION = '0.1.3'
3
3
  end
data/lib/aide.rb CHANGED
@@ -21,5 +21,21 @@ module Aide
21
21
  def configure(&block)
22
22
  self.config.instance_eval(&block)
23
23
  end
24
+
25
+ def display_services
26
+ load_services
27
+
28
+ puts "Aide Services (Using #{config.service_address_key}):"
29
+ self.services.each do |name, service|
30
+ puts "==> #{name}: #{service.address}#{service.port.nil? ? '' : ":#{service.port}"} #{service.url}".strip
31
+ end
32
+ end
33
+
34
+ private
35
+ def load_services
36
+ self.config.services.keys.each do |name|
37
+ service(name)
38
+ end
39
+ end
24
40
  end
25
41
  end
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.2
4
+ version: 0.1.3
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-02-18 00:00:00.000000000 Z
11
+ date: 2016-03-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler