diplomat 0.9.0 → 0.9.1

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: 88a912b85c1348113d9b8e5f941bb652295dbac8
4
- data.tar.gz: 64c21697ea68210e172293afc90b0bc894a238cc
3
+ metadata.gz: 1acdbd2886416cb3307f284fd3ebeecd6cd66852
4
+ data.tar.gz: 6b23b7466aa7155f5a2f434f947810d83fe7f6aa
5
5
  SHA512:
6
- metadata.gz: e17459f8b810a4213ffa6a1e87aa4e4a91391f289c954526ed06a4601a754d9e3d230d5666bf9b5775f053627258a45dd163d1cb327f27424588e08c959d1b95
7
- data.tar.gz: 0b0300f116e79dafb2fd26a2b123962e0ccecfabb7733dfacf034f9ee69b15c728f3da15a07a1974a17591fb0cc5237da60e8ffa176594310d3c252134c57945
6
+ metadata.gz: be17ae2b3b8c6f3cb6ec2c7a5f389b7a125eb7ffedc9b4bc0d81b8ebe2ffa139ea0415023b792c38db7939d68696a416ef0ce0fed02d6d13fb73ce4b4127a037
7
+ data.tar.gz: 32396d3ee97ad0e0451e59cf41b1785f90ad4f2361fa165619575f7493e54e3ae0cb5e7e92bba48931d687231b349ef4667798c6dc09ad781bc87b19d991e83b
data/lib/diplomat.rb CHANGED
@@ -8,6 +8,7 @@ module Diplomat
8
8
 
9
9
  # Internal: Requires internal Faraday libraries.
10
10
  # @param *libs One or more relative String names to Faraday classes.
11
+ # @return [nil]
11
12
  def require_libs(*libs)
12
13
  libs.each do |lib|
13
14
  require "#{lib_path}/#{lib}"
@@ -26,6 +27,7 @@ module Diplomat
26
27
  class << self
27
28
 
28
29
  # Build optional configuration by yielding a block to configure
30
+ # @yield [Diplomat::Configuration]
29
31
  def configure
30
32
  self.configuration ||= Diplomat::Configuration.new
31
33
  yield(configuration)
@@ -33,6 +35,12 @@ module Diplomat
33
35
 
34
36
  private
35
37
 
38
+ # Send all other unknown commands to Diplomat::Kv
39
+ # @deprecated Please use Diplomat::Kv instead.
40
+ # @param name [Symbol] Method to send to Kv
41
+ # @param *args List of arguments to send to Kv
42
+ # @param &block block to send to Kv
43
+ # @return [Object]
36
44
  def method_missing(name, *args, &block)
37
45
  Diplomat::Kv.new.send(name, *args, &block)
38
46
  end
@@ -41,15 +41,19 @@ module Diplomat
41
41
  return ret.status == 200
42
42
  end
43
43
 
44
+ # Register a TTL check
45
+ # @param check_id [String] the unique id of the check
46
+ # @param name [String] the name
47
+ # @param notes [String] notes about the check
48
+ # @param ttl [String] time (with units) to mark a check down
49
+ # @return [Boolean] Success
44
50
  def register_ttl check_id, name, notes, ttl
45
- json = JSON.generate(
46
- {
47
- "ID" => check_id,
48
- "Name" => name,
51
+ json = JSON.generate({
52
+ "ID" => check_id,
53
+ "Name" => name,
49
54
  "Notes" => notes,
50
- "TTL" => ttl,
51
- }
52
- )
55
+ "TTL" => ttl,
56
+ })
53
57
 
54
58
  ret = @conn.put do |req|
55
59
  req.url "/v1/agent/check/register"
@@ -3,12 +3,17 @@ module Diplomat
3
3
  attr_accessor :middleware
4
4
  attr_accessor :url, :acl_token
5
5
 
6
+ # Override defaults for configuration
7
+ # @param url [String] consul's connection URL
8
+ # @param acl_token [String] a connection token used when making requests to consul
6
9
  def initialize(url="http://localhost:8500", acl_token=nil)
7
10
  @middleware = []
8
11
  @url = url
9
12
  @acl_token = acl_token
10
13
  end
11
14
 
15
+ # Define a middleware for Faraday
16
+ # @param middleware [Class] Faraday Middleware class
12
17
  def middleware=(middleware)
13
18
  return @middleware = middleware if middleware.is_a? Array
14
19
  @middleware = [middleware]
@@ -6,14 +6,23 @@ module Diplomat
6
6
 
7
7
  @access_methods = []
8
8
 
9
+ # Initialize the fadaray connection
10
+ # @param api_connection [Faraday::Connection,nil] supply mock API Connection
9
11
  def initialize api_connection=nil
10
12
  start_connection api_connection
11
13
  end
12
14
 
15
+ # Format url parameters into strings correctly
16
+ # @param name [String] the name of the parameter
17
+ # @param value [String] the value of the parameter
18
+ # @return [Array] the resultant parameter string inside an array.
13
19
  def use_named_parameter(name, value)
14
20
  if value then ["#{name}=#{value}"] else [] end
15
21
  end
16
22
 
23
+ # Assemble a url from an array of parts.
24
+ # @param parts [Array] the url chunks to be assembled
25
+ # @return [String] the resultant url string
17
26
  def concat_url parts
18
27
  if parts.length > 1 then
19
28
  parts.first + '?' + parts.drop(1).join('&')
@@ -24,12 +33,17 @@ module Diplomat
24
33
 
25
34
  class << self
26
35
 
27
- def access_method? methId
28
- @access_methods.include? methId
36
+ def access_method? meth_id
37
+ @access_methods.include? meth_id
29
38
  end
30
39
 
31
- def method_missing(methId, *args)
32
- access_method?(methId) ? new.send(methId, *args) : super
40
+ # Allow certain methods to be accessed
41
+ # without defining "new".
42
+ # @param meth_id [Symbol] symbol defining method requested
43
+ # @param *args Arguments list
44
+ # @return [Boolean]
45
+ def method_missing(meth_id, *args)
46
+ access_method?(meth_id) ? new.send(meth_id, *args) : super
33
47
  end
34
48
 
35
49
  end
@@ -1,3 +1,3 @@
1
1
  module Diplomat
2
- VERSION = "0.9.0"
2
+ VERSION = "0.9.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: diplomat
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Hamelink