apitest 0.1.8 → 0.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +5 -2
- data/app/assets/javascripts/apitest/application.coffee +3 -4
- data/app/controllers/apitest/apitest_controller.rb +8 -10
- data/lib/apitest/version.rb +1 -1
- data/lib/apitest.rb +8 -7
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b0633ebdeafbf793f850ec77c572c6e10687c1aa
|
4
|
+
data.tar.gz: c8a24eb02574bf285718e4b2a1ea651168e11193
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4f9234362ef3cb83cc44be3368aee0a21c8d6c82bbf1d1d2d5a67b28ffb010090372e4858aab9749071d7b719de690bfab6a3c36e7d60279200d386fc0a2f994
|
7
|
+
data.tar.gz: b96dc2f3036ffd72dec49ab2744cd491ffab60b8f92e059b361e268801c35e78588ba419248d1b71a197029fc75ba7d8b0f9235ecff95239070255642414ba5f
|
data/README.md
CHANGED
@@ -45,25 +45,24 @@ $(document).on "turbolinks:load" , ->
|
|
45
45
|
elm = $(e.target).parents('.api')
|
46
46
|
result = elm.find('.result')
|
47
47
|
result_pre = elm.find('.result_pre')
|
48
|
-
path = elm.find('.path').val()
|
48
|
+
path = elm.find('.path').val().replace ':id' , elm.find('.params[name=":id"]').val()
|
49
49
|
method = elm.find('.method').text()
|
50
50
|
postData = {}
|
51
51
|
|
52
52
|
elm.find('.params').each ->
|
53
|
-
|
53
|
+
|
54
|
+
postData[$(this).attr('name')] = $(this).val() unless $(this).attr('name').indexOf(':id') >= 0
|
54
55
|
|
55
56
|
$.ajax
|
56
57
|
url : path
|
57
58
|
type : method
|
58
59
|
data : postData
|
59
60
|
success : (data) =>
|
60
|
-
# result.val JSON.stringify(data , null , 4)
|
61
61
|
result_pre.jsonViewer(data)
|
62
62
|
error : (data) =>
|
63
63
|
result.val data.responseText
|
64
64
|
|
65
65
|
clear_result : (e) ->
|
66
|
-
# $(e.target).parents('.api').find('.result').val('')
|
67
66
|
$(e.target).parents('.api').find('.result_pre').html('')
|
68
67
|
|
69
68
|
log_scroll : ->
|
@@ -42,17 +42,12 @@ module Apitest
|
|
42
42
|
class_match = File.open(path).read.match(/class (.*) </)
|
43
43
|
controller_class = class_match[1].constantize if class_match && class_match[1]
|
44
44
|
if defined? controller_class::APIDOC
|
45
|
-
token_need = {
|
46
|
-
token: {
|
47
|
-
text: 'token' ,
|
48
|
-
required: true ,
|
49
|
-
}
|
50
|
-
}
|
51
45
|
doc = controller_class::APIDOC
|
52
46
|
doc[:sort] = 99 if doc[:sort].blank?
|
53
47
|
doc[:apis].each do |k,v|
|
54
|
-
|
55
|
-
|
48
|
+
d = doc[:apis][k]
|
49
|
+
d = public_required d unless Apitest::public_required.blank?
|
50
|
+
d[:params] = {':id' => { required: true }}.merge d[:params] if d[:path].include? ':id'
|
56
51
|
end
|
57
52
|
|
58
53
|
docs[doc[:type]] = [] if docs[doc[:type]].blank?
|
@@ -62,8 +57,11 @@ module Apitest
|
|
62
57
|
end
|
63
58
|
docs
|
64
59
|
end
|
65
|
-
def
|
66
|
-
|
60
|
+
def public_required(api)
|
61
|
+
Apitest::public_required.reverse.each do |need|
|
62
|
+
api[:params] = need.merge api[:params] if api[need.keys.first.to_sym] != false
|
63
|
+
end
|
64
|
+
api
|
67
65
|
end
|
68
66
|
end
|
69
67
|
end
|
data/lib/apitest/version.rb
CHANGED
data/lib/apitest.rb
CHANGED
@@ -13,7 +13,7 @@ module Apitest
|
|
13
13
|
@api_dir
|
14
14
|
@theme
|
15
15
|
@default_types
|
16
|
-
@
|
16
|
+
@public_required
|
17
17
|
class << self
|
18
18
|
def api_dir(dir = nil)
|
19
19
|
@api_dir = dir if dir
|
@@ -34,13 +34,14 @@ module Apitest
|
|
34
34
|
@default_types
|
35
35
|
end
|
36
36
|
|
37
|
-
def
|
38
|
-
return @
|
39
|
-
@
|
40
|
-
|
41
|
-
|
37
|
+
def public_required(public_required = [])
|
38
|
+
return @public_required if public_required.blank?
|
39
|
+
@public_required = []
|
40
|
+
public_required.each do |need|
|
41
|
+
n = { need => {required: true }}
|
42
|
+
@public_required.push n
|
42
43
|
end
|
43
|
-
@
|
44
|
+
@public_required
|
44
45
|
end
|
45
46
|
|
46
47
|
def start_server_log_listen
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: apitest
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kyuubi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-04-
|
11
|
+
date: 2017-04-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|