kongkit 0.1.2 → 0.2.0

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: 3ac2d8acd874c49c8f51d2ee7cfebf7d695839be
4
- data.tar.gz: a8d7a6106ab1c094de1a22315a9079fd2dc76cf7
3
+ metadata.gz: db763514c1f32625e9e630d8057eb5f9d4c65d66
4
+ data.tar.gz: 3942dfd42fbc24a7a89dde9e34c1e8d6c0beaa94
5
5
  SHA512:
6
- metadata.gz: ca8d5fbc0ee6d7a7d5c01cf5b122a01ffd2c9e252849c0ca769e4880f468033410ebc512bb3dd9f1610b786ea67d5e22e737a11243b63b15d962ca784e34884e
7
- data.tar.gz: 4313e4706c4313182c02d278ae189091ad853803f3f6985e1ba9b0cabbe90c9543fcea2650bdd576658ec4f004d5f50f3c8249995a0867ab4acf32626de14769
6
+ metadata.gz: 1bd31d999c8ba8e73290b8af3ce4abb154be3bb0e2f6cd11ee073ba3fc623ea0b80da9dfe8929caeaef23c17da3083b9efc02ae77409c9981aed6a7cefacd840
7
+ data.tar.gz: 943a2aa6f20c647aab03c7c14607002730413a2f41ce19e03b4dda6c4606031745b2a22a3dd668a56c1519cdfb05de26ed2c29bd836a4a09f99b23bad25c5cf7
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Kongkit
2
2
 
3
- Ruby library for the Kong API.
3
+ Ruby library for the Kong API. See [documentation](http://www.rubydoc.info/github/maveonair/kongkit) for details.
4
4
 
5
5
  ## Installation
6
6
 
@@ -36,7 +36,7 @@ client = Kongkit::Client.new('https://kong.enterprise.io:8001')
36
36
  client.add_api(name: 'mockbin', request_host: 'mockbin.com', upstream_url: 'http://mockbin.com', preserve_host: true)
37
37
 
38
38
  # Add Plugin
39
- client.add_plugin('mockbin', name: 'rate-limiting', config.minute: 20, config.hour: 500)
39
+ client.add_plugin('mockbin', name: 'rate-limiting', 'config.minute': 20, 'config.hour': 500)
40
40
  ```
41
41
 
42
42
  ### Pagination
@@ -20,15 +20,19 @@ module Kongkit
20
20
  include Node
21
21
  include Request
22
22
 
23
- def initialize(url = 'http://localhost:8001')
24
- @url = url
23
+ def initialize(configuration)
24
+ @configuration = configuration
25
25
 
26
- self.class.base_uri(@url)
26
+ self.class.base_uri(configuration.url)
27
27
  self.class.headers('Accept' => 'application/json')
28
28
  end
29
29
 
30
30
  def same_url?(url)
31
- @url == url
31
+ configuration.url == url
32
32
  end
33
+
34
+ private
35
+
36
+ attr_reader :configuration
33
37
  end
34
38
  end
@@ -0,0 +1,9 @@
1
+ module Kongkit
2
+ class Configuration
3
+ attr_accessor :url
4
+
5
+ def initialize
6
+ @url = 'http://localhost:8001'
7
+ end
8
+ end
9
+ end
@@ -1,3 +1,3 @@
1
1
  module Kongkit
2
- VERSION = "0.1.2"
2
+ VERSION = "0.2.0"
3
3
  end
data/lib/kongkit.rb CHANGED
@@ -1,16 +1,31 @@
1
1
  require 'kongkit/client'
2
+ require 'kongkit/configuration'
2
3
  require 'kongkit/version'
3
4
 
4
5
  module Kongkit
5
6
  class << self
7
+ attr_accessor :configuration
8
+
9
+ def configuration
10
+ @@configuration ||= Kongkit::Configuration.new
11
+ end
12
+
6
13
  # API client
7
14
  #
8
15
  # @param url [String] Kong admin url
9
16
  # @return [Kongkit::Client] API wrapper
10
17
  def client(url = 'http://localhost:8001')
18
+ configure do |config|
19
+ config.url = url
20
+ end
21
+
11
22
  return @client if defined?(@client) && @client.same_url?(url)
12
23
 
13
- @client = Kongkit::Client.new(url)
24
+ @client = Kongkit::Client.new(configuration)
25
+ end
26
+
27
+ def configure
28
+ yield(configuration)
14
29
  end
15
30
 
16
31
  private
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kongkit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fabian Mettler
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-08-17 00:00:00.000000000 Z
11
+ date: 2016-08-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -148,6 +148,7 @@ files:
148
148
  - lib/kongkit/client/plugin_object.rb
149
149
  - lib/kongkit/client/request.rb
150
150
  - lib/kongkit/client/resource.rb
151
+ - lib/kongkit/configuration.rb
151
152
  - lib/kongkit/version.rb
152
153
  homepage: https://github.com/maveonair/kongkit
153
154
  licenses: