ruby-kong 0.1.0a
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.codeclimate.yml +40 -0
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/.rubocop.yml +99 -0
- data/.travis.yml +8 -0
- data/Gemfile +8 -0
- data/Gemfile.lock +71 -0
- data/LICENSE.txt +21 -0
- data/README.md +12 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/ruby-kong.rb +12 -0
- data/lib/ruby-kong/api.rb +47 -0
- data/lib/ruby-kong/consumer.rb +43 -0
- data/lib/ruby-kong/kong.rb +7 -0
- data/lib/ruby-kong/node.rb +15 -0
- data/lib/ruby-kong/plugin.rb +70 -0
- data/lib/ruby-kong/request.rb +31 -0
- data/lib/ruby-kong/request/api.rb +150 -0
- data/lib/ruby-kong/request/consumer.rb +142 -0
- data/lib/ruby-kong/request/node.rb +70 -0
- data/lib/ruby-kong/request/plugin.rb +280 -0
- data/lib/ruby-kong/spec.rb +42 -0
- data/lib/ruby-kong/stub.rb +28 -0
- data/lib/ruby-kong/utils.rb +9 -0
- data/lib/ruby-kong/version.rb +3 -0
- data/ruby-kong.gemspec +37 -0
- metadata +156 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 38da78f7fbf5b4b7e64f9ca4317aa0f0ac1b707e
|
4
|
+
data.tar.gz: 5fe527e25b2d3e1697b5f65e6324196da0fdfe4c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a72a54f57878ed063f423eedba18613782cde6cec7cf335d3723097bdd03ef5c1cd05470b5af58f9065e34a709dbf9ed6175977ec536896c9cfa898d06099632
|
7
|
+
data.tar.gz: 71bd1d46bfe5c2839796c83ac5c952b76d4b7d9b7d1f0702d7e1de9bc0d85f43dc904a1667e5c55b4aee6b338e146a75589d1e12d1afc5a97df29ad62b54ccba
|
data/.codeclimate.yml
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
---
|
2
|
+
engines:
|
3
|
+
bundler-audit:
|
4
|
+
enabled: true
|
5
|
+
duplication:
|
6
|
+
enabled: false
|
7
|
+
config:
|
8
|
+
languages:
|
9
|
+
- ruby
|
10
|
+
- javascript
|
11
|
+
- python
|
12
|
+
- php
|
13
|
+
fixme:
|
14
|
+
enabled: true
|
15
|
+
rubocop:
|
16
|
+
enabled: true
|
17
|
+
checks:
|
18
|
+
Rubocop/Metrics/ClassLength:
|
19
|
+
enabled: false
|
20
|
+
Rubocop/Style/NumericLiterals:
|
21
|
+
enabled: false
|
22
|
+
Rubocop/Style/FrozenStringLiteralComment:
|
23
|
+
enabled: false
|
24
|
+
Rubocop/Metrics/LineLength:
|
25
|
+
enabled: false
|
26
|
+
Rubocop/Metrics/MethodLength:
|
27
|
+
enabled: false
|
28
|
+
|
29
|
+
ratings:
|
30
|
+
paths:
|
31
|
+
- Gemfile.lock
|
32
|
+
- "**.inc"
|
33
|
+
- "**.js"
|
34
|
+
- "**.jsx"
|
35
|
+
- "**.module"
|
36
|
+
- "**.php"
|
37
|
+
- "**.py"
|
38
|
+
- "**.rb"
|
39
|
+
exclude_paths:
|
40
|
+
- spec/
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,99 @@
|
|
1
|
+
#
|
2
|
+
# Overrides
|
3
|
+
#
|
4
|
+
AbcSize:
|
5
|
+
Severity: refactor
|
6
|
+
AlignHash:
|
7
|
+
EnforcedHashRocketStyle: table
|
8
|
+
EnforcedColonStyle: table
|
9
|
+
BlockNesting:
|
10
|
+
Severity: refactor
|
11
|
+
ClassLength:
|
12
|
+
Severity: refactor
|
13
|
+
ClassCheck:
|
14
|
+
EnforcedStyle: kind_of?
|
15
|
+
CollectionMethods:
|
16
|
+
PreferredMethods:
|
17
|
+
find: detect
|
18
|
+
find_all: select
|
19
|
+
map: collect
|
20
|
+
reduce: inject
|
21
|
+
CyclomaticComplexity:
|
22
|
+
Severity: refactor
|
23
|
+
FormatString:
|
24
|
+
EnforcedStyle: percent
|
25
|
+
HashSyntax:
|
26
|
+
EnforcedStyle: hash_rockets
|
27
|
+
LineLength:
|
28
|
+
Max: 80
|
29
|
+
Severity: refactor
|
30
|
+
MethodLength:
|
31
|
+
Max: 25
|
32
|
+
Severity: refactor
|
33
|
+
ParameterLists:
|
34
|
+
Severity: refactor
|
35
|
+
PerceivedComplexity:
|
36
|
+
Severity: refactor
|
37
|
+
RedundantReturn:
|
38
|
+
AllowMultipleReturnValues: true
|
39
|
+
SignalException:
|
40
|
+
EnforcedStyle: only_raise
|
41
|
+
SingleLineMethods:
|
42
|
+
AllowIfMethodIsEmpty: false
|
43
|
+
SpaceInsideHashLiteralBraces:
|
44
|
+
EnforcedStyle: no_space
|
45
|
+
TrivialAccessors:
|
46
|
+
AllowPredicates: true
|
47
|
+
AllCops:
|
48
|
+
TargetRubyVersion: 2.3
|
49
|
+
#
|
50
|
+
# Enabled/Disabled
|
51
|
+
#
|
52
|
+
ClassAndModuleChildren:
|
53
|
+
Enabled: false
|
54
|
+
DefEndAlignment:
|
55
|
+
AutoCorrect: true
|
56
|
+
Documentation:
|
57
|
+
Enabled: false
|
58
|
+
Encoding:
|
59
|
+
Enabled: false
|
60
|
+
EndAlignment:
|
61
|
+
AutoCorrect: true
|
62
|
+
ExtraSpacing:
|
63
|
+
AutoCorrect: false # https://github.com/bbatsov/rubocop/issues/2280
|
64
|
+
FindEach:
|
65
|
+
Enabled: false
|
66
|
+
GuardClause:
|
67
|
+
Enabled: false
|
68
|
+
IfUnlessModifier:
|
69
|
+
Enabled: false
|
70
|
+
NumericLiterals:
|
71
|
+
AutoCorrect: false
|
72
|
+
ParallelAssignment:
|
73
|
+
Enabled: false
|
74
|
+
PerlBackrefs:
|
75
|
+
Enabled: false
|
76
|
+
ReadWriteAttribute:
|
77
|
+
AutoCorrect: false
|
78
|
+
RescueModifier:
|
79
|
+
AutoCorrect: false
|
80
|
+
SingleLineBlockParams:
|
81
|
+
Enabled: false
|
82
|
+
SpaceBeforeFirstArg:
|
83
|
+
Enabled: false
|
84
|
+
SpecialGlobalVars:
|
85
|
+
AutoCorrect: false
|
86
|
+
StringLiterals:
|
87
|
+
Enabled: false
|
88
|
+
StringLiteralsInInterpolation:
|
89
|
+
Enabled: false
|
90
|
+
TrailingCommaInLiteral:
|
91
|
+
Enabled: false
|
92
|
+
WhileUntilModifier:
|
93
|
+
Enabled: false
|
94
|
+
WordArray:
|
95
|
+
AutoCorrect: false
|
96
|
+
Style/AccessorMethodName:
|
97
|
+
Enabled: false
|
98
|
+
Style/FileName:
|
99
|
+
Enabled: false
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
ruby-kong (0.1.0)
|
5
|
+
unirest (= 1.1.2)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
addressable (2.3.8)
|
11
|
+
codeclimate-test-reporter (0.5.0)
|
12
|
+
simplecov (>= 0.7.1, < 1.0.0)
|
13
|
+
coderay (1.1.1)
|
14
|
+
crack (0.4.3)
|
15
|
+
safe_yaml (~> 1.0.0)
|
16
|
+
diff-lcs (1.2.5)
|
17
|
+
docile (1.1.5)
|
18
|
+
hashdiff (0.3.0)
|
19
|
+
json (1.8.3)
|
20
|
+
method_source (0.8.2)
|
21
|
+
mime-types (1.25.1)
|
22
|
+
pry (0.10.3)
|
23
|
+
coderay (~> 1.1.0)
|
24
|
+
method_source (~> 0.8.1)
|
25
|
+
slop (~> 3.4)
|
26
|
+
rake (10.5.0)
|
27
|
+
rest-client (1.6.9)
|
28
|
+
mime-types (~> 1.16)
|
29
|
+
rspec (3.4.0)
|
30
|
+
rspec-core (~> 3.4.0)
|
31
|
+
rspec-expectations (~> 3.4.0)
|
32
|
+
rspec-mocks (~> 3.4.0)
|
33
|
+
rspec-core (3.4.4)
|
34
|
+
rspec-support (~> 3.4.0)
|
35
|
+
rspec-expectations (3.4.0)
|
36
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
37
|
+
rspec-support (~> 3.4.0)
|
38
|
+
rspec-mocks (3.4.1)
|
39
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
40
|
+
rspec-support (~> 3.4.0)
|
41
|
+
rspec-support (3.4.1)
|
42
|
+
safe_yaml (1.0.4)
|
43
|
+
simplecov (0.11.2)
|
44
|
+
docile (~> 1.1.0)
|
45
|
+
json (~> 1.8)
|
46
|
+
simplecov-html (~> 0.10.0)
|
47
|
+
simplecov-html (0.10.0)
|
48
|
+
slop (3.6.0)
|
49
|
+
unirest (1.1.2)
|
50
|
+
addressable (~> 2.3.5)
|
51
|
+
json (~> 1.8.1)
|
52
|
+
rest-client (~> 1.6.7)
|
53
|
+
webmock (1.24.2)
|
54
|
+
addressable (>= 2.3.6)
|
55
|
+
crack (>= 0.3.2)
|
56
|
+
hashdiff
|
57
|
+
|
58
|
+
PLATFORMS
|
59
|
+
ruby
|
60
|
+
|
61
|
+
DEPENDENCIES
|
62
|
+
bundler (~> 1.11)
|
63
|
+
codeclimate-test-reporter
|
64
|
+
pry
|
65
|
+
rake
|
66
|
+
rspec (~> 3.0)
|
67
|
+
ruby-kong!
|
68
|
+
webmock (= 1.24.2)
|
69
|
+
|
70
|
+
BUNDLED WITH
|
71
|
+
1.11.2
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Dang Tung Lam
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
ruby-kong
|
2
|
+
=========
|
3
|
+
|
4
|
+
[![Build Status](https://travis-ci.org/tunglam14/ruby-kong.svg?branch=master)](https://travis-ci.org/tunglam14/ruby-kong)
|
5
|
+
[![Code Climate](https://codeclimate.com/github/tunglam14/ruby-kong/badges/gpa.svg)](https://codeclimate.com/github/tunglam14/ruby-kong)
|
6
|
+
[![Test Coverage](https://codeclimate.com/github/tunglam14/ruby-kong/badges/coverage.svg)](https://codeclimate.com/github/tunglam14/ruby-kong/coverage)
|
7
|
+
[![Dependency Status](https://gemnasium.com/tunglam14/ruby-kong.svg)](https://gemnasium.com/tunglam14/ruby-kong)
|
8
|
+
|
9
|
+
|
10
|
+
```
|
11
|
+
Under development... check it out later
|
12
|
+
```
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "ruby/kong"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
data/lib/ruby-kong.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'pry'
|
2
|
+
|
3
|
+
require 'ruby-kong/version'
|
4
|
+
require 'ruby-kong/spec'
|
5
|
+
require 'ruby-kong/utils'
|
6
|
+
require 'ruby-kong/stub'
|
7
|
+
require 'ruby-kong/request'
|
8
|
+
require 'ruby-kong/kong'
|
9
|
+
require 'ruby-kong/node'
|
10
|
+
require 'ruby-kong/api'
|
11
|
+
require 'ruby-kong/consumer'
|
12
|
+
require 'ruby-kong/plugin'
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'ruby-kong/request/api'
|
2
|
+
|
3
|
+
module RubyKong
|
4
|
+
module Api
|
5
|
+
class << self
|
6
|
+
# Params: upstream_url:, request_host: nil, request_path: nil, name: nil,
|
7
|
+
# preserve_host: false, strip_request_path: false
|
8
|
+
#
|
9
|
+
# Usage: RubyKong::Api.create upstream_url: 'https://api.shipit.vn/v1/',
|
10
|
+
# request_host: 'api.shipit.vn',
|
11
|
+
# name: 'shipit'
|
12
|
+
def create(*args)
|
13
|
+
RubyKong::Request::Api.create args[0]
|
14
|
+
end
|
15
|
+
|
16
|
+
# Params: id, name, request_host, request_path, upstream_url, size, offset
|
17
|
+
#
|
18
|
+
# Usage: RubyKong::Api.list
|
19
|
+
def list(*args)
|
20
|
+
RubyKong::Request::Api.list args[0]
|
21
|
+
end
|
22
|
+
|
23
|
+
# Params: id, name
|
24
|
+
#
|
25
|
+
# Usage: RubyKong::Api.retrieve name: 'shipit'
|
26
|
+
def retrieve(*args)
|
27
|
+
RubyKong::Request::Api.retrieve args[0]
|
28
|
+
end
|
29
|
+
|
30
|
+
# Params: id, name
|
31
|
+
#
|
32
|
+
# Usage: RubyKong::Api.update name: 'shipit',
|
33
|
+
# upstream_url: 'https://api.shipit.vn/v2/'
|
34
|
+
def update(*args)
|
35
|
+
RubyKong::Request::Api.update args[0]
|
36
|
+
end
|
37
|
+
|
38
|
+
# Params: id, name
|
39
|
+
#
|
40
|
+
# Usage: RubyKong::Api.update name: 'shipit',
|
41
|
+
# upstream_url: 'https://api.shipit.vn/v2/'
|
42
|
+
def delete(*args)
|
43
|
+
RubyKong::Request::Api.delete args[0]
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'ruby-kong/request/consumer'
|
2
|
+
|
3
|
+
module RubyKong
|
4
|
+
module Consumer
|
5
|
+
class << self
|
6
|
+
# Params: username, custom_id
|
7
|
+
#
|
8
|
+
# Usage: RubyKong::Consumer.create username: 'lamdt'
|
9
|
+
def create(*args)
|
10
|
+
RubyKong::Request::Consumer.create args[0]
|
11
|
+
end
|
12
|
+
|
13
|
+
# Params: id, username, custom_id, size, offset
|
14
|
+
#
|
15
|
+
# Usage: RubyKong::Consumer.list
|
16
|
+
def list(*args)
|
17
|
+
RubyKong::Request::Consumer.list args[0]
|
18
|
+
end
|
19
|
+
|
20
|
+
# Params: id, username
|
21
|
+
#
|
22
|
+
# Usage: RubyKong::Consumer.retrieve username: 'lamdt'
|
23
|
+
def retrieve(*args)
|
24
|
+
RubyKong::Request::Consumer.retrieve args[0]
|
25
|
+
end
|
26
|
+
|
27
|
+
# Params: custom_id, username
|
28
|
+
#
|
29
|
+
# Usage: RubyKong::Consumer.update username: 'lamdt',
|
30
|
+
# custom_id: 123
|
31
|
+
def update(*args)
|
32
|
+
RubyKong::Request::Consumer.update args[0]
|
33
|
+
end
|
34
|
+
|
35
|
+
# Params: id, username
|
36
|
+
#
|
37
|
+
# Usage: RubyKong::Consumer.delete username: 'lamdt'
|
38
|
+
def delete(*args)
|
39
|
+
RubyKong::Request::Consumer.delete args[0]
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|