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 +4 -4
- data/README.md +2 -2
- data/lib/kongkit/client.rb +8 -4
- data/lib/kongkit/configuration.rb +9 -0
- data/lib/kongkit/version.rb +1 -1
- data/lib/kongkit.rb +16 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: db763514c1f32625e9e630d8057eb5f9d4c65d66
|
4
|
+
data.tar.gz: 3942dfd42fbc24a7a89dde9e34c1e8d6c0beaa94
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
data/lib/kongkit/client.rb
CHANGED
@@ -20,15 +20,19 @@ module Kongkit
|
|
20
20
|
include Node
|
21
21
|
include Request
|
22
22
|
|
23
|
-
def initialize(
|
24
|
-
@
|
23
|
+
def initialize(configuration)
|
24
|
+
@configuration = configuration
|
25
25
|
|
26
|
-
self.class.base_uri(
|
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
|
-
|
31
|
+
configuration.url == url
|
32
32
|
end
|
33
|
+
|
34
|
+
private
|
35
|
+
|
36
|
+
attr_reader :configuration
|
33
37
|
end
|
34
38
|
end
|
data/lib/kongkit/version.rb
CHANGED
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(
|
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.
|
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-
|
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:
|