gumiho 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.README.md.swp +0 -0
- data/Gemfile +5 -0
- data/Gemfile.lock +21 -0
- data/LICENSE.txt +22 -0
- data/README.md +19 -0
- data/Rakefile +1 -0
- data/bin/gumiho-export +11 -0
- data/gumiho.gemspec +25 -0
- data/lib/config.yml +20 -0
- data/lib/generate_doc.rb +80 -0
- data/lib/gumiho/command_line_params.rb +76 -0
- data/lib/gumiho/generate_response.rb +54 -0
- data/lib/gumiho/path_config.rb +23 -0
- data/lib/gumiho/route_methods.rb +107 -0
- data/lib/gumiho/template/javascript/template_script.js +68 -0
- data/lib/gumiho/template/style/template_style.css +84 -0
- data/lib/gumiho/template/template.html.erb +64 -0
- data/lib/gumiho/version.rb +3 -0
- data/pkg/generate_doc-0.0.1.gem +0 -0
- metadata +107 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 421a54bca859b8958330490d21fb78d2827f4b3f
|
4
|
+
data.tar.gz: 1b48177a716cf8aee17805ffe010d4dee80cc619
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 5316f7fb5e2a5b346a1314302540374567f50b1b6fc353c8b1936576bf346caf6fc2ee5903d50b006b5df5d5302f2e46d3b6b566328e26396d3b5a1091a86227
|
7
|
+
data.tar.gz: a7e2d82593e1142821d0ce71894ed85152ad929e17d0235255c8e028a074b6be0062f2364b0e846e831a31f8b9493c1070b0a184df3f923126dd5ff54b3a99bc
|
data/.README.md.swp
ADDED
Binary file
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
gumiho (0.0.1)
|
5
|
+
choice (~> 0.1.6)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
awesome_print (1.2.0)
|
11
|
+
choice (0.1.6)
|
12
|
+
rake (10.1.0)
|
13
|
+
|
14
|
+
PLATFORMS
|
15
|
+
ruby
|
16
|
+
|
17
|
+
DEPENDENCIES
|
18
|
+
awesome_print
|
19
|
+
bundler (~> 1.3)
|
20
|
+
gumiho!
|
21
|
+
rake
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 IvaDobreva
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# Gumiho
|
2
|
+
|
3
|
+
Easily create RESTful API documentation
|
4
|
+
|
5
|
+
##Table of contents
|
6
|
+
- [Installation] (#instalattion)
|
7
|
+
- [Usage](#usage)
|
8
|
+
-[Settings](#settings)
|
9
|
+
|
10
|
+
## Installation
|
11
|
+
|
12
|
+
$ gem install gumiho
|
13
|
+
|
14
|
+
## Usage
|
15
|
+
|
16
|
+
After installing gumiho you need to have running API.
|
17
|
+
|
18
|
+
##Settings
|
19
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/gumiho-export
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'generate_doc'
|
4
|
+
require_relative '../lib/gumiho/command_line_params'
|
5
|
+
|
6
|
+
module Gumiho
|
7
|
+
|
8
|
+
command_line = get_cl_params
|
9
|
+
export_dir = command_line[:export]
|
10
|
+
document = Gumiho::generate_documentation(command_line, export_dir)
|
11
|
+
end
|
data/gumiho.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'gumiho/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "gumiho"
|
8
|
+
spec.version = '0.0.2'
|
9
|
+
spec.authors = ["IvaDobreva"]
|
10
|
+
spec.email = ["iva95dobreva@gmail.com"]
|
11
|
+
spec.description = %q{Ruby gem for creating online RESTful API documentation with possibility to test different HTTP requests}
|
12
|
+
spec.summary = %q{Create API documentation}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = 'gumiho-export'
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
|
24
|
+
spec.add_runtime_dependency "choice", "~> 0.1.6"
|
25
|
+
end
|
data/lib/config.yml
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# http | list
|
2
|
+
generate_strategy: 'http'
|
3
|
+
|
4
|
+
methods: [ 'GET', 'POST', 'DELETE', 'PUT' ]
|
5
|
+
|
6
|
+
http:
|
7
|
+
hostname: '0.0.0.0'
|
8
|
+
port: '4000'
|
9
|
+
path: '/v1/routes'
|
10
|
+
|
11
|
+
#
|
12
|
+
# http://0.0.0.0:3000/v1
|
13
|
+
|
14
|
+
report:
|
15
|
+
document_headers: false
|
16
|
+
document_status: true
|
17
|
+
|
18
|
+
template:
|
19
|
+
'/home/iva/GEM/lib/generate_doc/template.html.erb'
|
20
|
+
|
data/lib/generate_doc.rb
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
$:.unshift File.dirname(__FILE__)
|
2
|
+
require 'gumiho/route_methods'
|
3
|
+
require 'gumiho/path_config'
|
4
|
+
require 'gumiho/generate_response.rb'
|
5
|
+
require 'yaml'
|
6
|
+
|
7
|
+
module Gumiho
|
8
|
+
|
9
|
+
extend self
|
10
|
+
|
11
|
+
def generate_documentation(params, export_dir)
|
12
|
+
#Checks for command line parameters and load them
|
13
|
+
|
14
|
+
#Check for config file
|
15
|
+
if params[:config]
|
16
|
+
|
17
|
+
if File.file?(params[:config])
|
18
|
+
#parses yaml config file and creates PathConfig
|
19
|
+
yaml = YAML.load_file(params[:config])
|
20
|
+
|
21
|
+
path_conf = PathConfig.new(yaml['generate_strategy'],
|
22
|
+
yaml['http']['hostname'],
|
23
|
+
yaml['http']['port'],
|
24
|
+
yaml['http']['path'])
|
25
|
+
template_file = yaml['template']
|
26
|
+
else
|
27
|
+
|
28
|
+
abort('Wrong file')
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
else
|
33
|
+
|
34
|
+
#Creates new PathConfig object with following params
|
35
|
+
path_conf = PathConfig.new(params[:protocol], params[:hostname],
|
36
|
+
params[:port], params[:route])
|
37
|
+
|
38
|
+
template_file = params[:template]
|
39
|
+
end
|
40
|
+
|
41
|
+
routes_hash = routes_get(path_conf.build_path)
|
42
|
+
response = []
|
43
|
+
|
44
|
+
routes_hash.each do |route|
|
45
|
+
|
46
|
+
if route_filter(route['path'])==false
|
47
|
+
path = path_conf.build_path(route['path'])
|
48
|
+
|
49
|
+
params[:methods].each do |method|
|
50
|
+
case method
|
51
|
+
when 'GET'
|
52
|
+
response << { :method => 'GET',
|
53
|
+
:url => path,
|
54
|
+
:response => get_method(path)
|
55
|
+
} if route['method'].downcase == 'get'
|
56
|
+
when 'POST'
|
57
|
+
response << { :method => 'POST',
|
58
|
+
:url => path,
|
59
|
+
:response => post_method(path)
|
60
|
+
} if route['method'].downcase == 'post'
|
61
|
+
when 'PUT'
|
62
|
+
response << { :method => 'PUT',
|
63
|
+
:url => path,
|
64
|
+
:response => put_method(path)
|
65
|
+
} if route['method'].downcase == 'put'
|
66
|
+
when 'DELETE'
|
67
|
+
response << { :method => 'DELETE',
|
68
|
+
:url => path,
|
69
|
+
:response => delete_method(path)
|
70
|
+
} if route['method'].downcase == 'delete'
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
76
|
+
|
77
|
+
generate_response(response, template_file, export_dir)
|
78
|
+
|
79
|
+
end
|
80
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
require 'choice'
|
2
|
+
|
3
|
+
module Gumiho
|
4
|
+
|
5
|
+
def get_cl_params
|
6
|
+
|
7
|
+
spec = Gem::Specification.find_by_name("gumiho")
|
8
|
+
gem_root = spec.gem_dir
|
9
|
+
template = gem_root + "/lib/gumiho/template/template.html.erb"
|
10
|
+
|
11
|
+
Choice.options do
|
12
|
+
header ''
|
13
|
+
header 'Specific options:'
|
14
|
+
|
15
|
+
option :config do
|
16
|
+
short '-c'
|
17
|
+
long '--config'
|
18
|
+
desc 'Add config file'
|
19
|
+
default nil
|
20
|
+
end
|
21
|
+
|
22
|
+
option :methods do
|
23
|
+
short '-m'
|
24
|
+
long '--method'
|
25
|
+
desc 'Add GET, POST, PUT, DELETE methods'
|
26
|
+
default ['GET', 'POST', 'PUT', 'DELETE']
|
27
|
+
end
|
28
|
+
|
29
|
+
option :protocol do
|
30
|
+
short '-pr'
|
31
|
+
long '--protocol'
|
32
|
+
desc 'Change current protocol'
|
33
|
+
default 'http'
|
34
|
+
end
|
35
|
+
|
36
|
+
option :hostname do
|
37
|
+
short '-h'
|
38
|
+
long '--host'
|
39
|
+
desc 'Change current hostname'
|
40
|
+
default '0.0.0.0'
|
41
|
+
end
|
42
|
+
|
43
|
+
option :port do
|
44
|
+
short '-p'
|
45
|
+
long '--port'
|
46
|
+
desc 'Change current port'
|
47
|
+
default '4000'
|
48
|
+
end
|
49
|
+
|
50
|
+
option :route do
|
51
|
+
short '-r'
|
52
|
+
long '--route'
|
53
|
+
desc 'Change current route'
|
54
|
+
default '/v1/routes'
|
55
|
+
end
|
56
|
+
|
57
|
+
option :template do
|
58
|
+
short '-t'
|
59
|
+
long '--template'
|
60
|
+
desc 'Add report template file'
|
61
|
+
default template
|
62
|
+
end
|
63
|
+
|
64
|
+
option :export do
|
65
|
+
short '-e'
|
66
|
+
long '--export'
|
67
|
+
desc 'Export path'
|
68
|
+
default './report.html'
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
Choice.choices
|
73
|
+
end
|
74
|
+
|
75
|
+
|
76
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'awesome_print'
|
2
|
+
require 'erb'
|
3
|
+
require 'json'
|
4
|
+
|
5
|
+
module Gumiho
|
6
|
+
|
7
|
+
def generate_response(response, template_file, export_dir)
|
8
|
+
template = File.open(template_file, 'r').read
|
9
|
+
erb = ERB.new(template)
|
10
|
+
File.open(File.join(File.dirname(export_dir), File.basename(export_dir)), 'w+') {
|
11
|
+
|file| file.write(erb.result(binding))
|
12
|
+
}
|
13
|
+
end
|
14
|
+
|
15
|
+
###Methods used in the template file
|
16
|
+
def parse_response(response, template_param)
|
17
|
+
params = template_param.split('.')
|
18
|
+
result = response
|
19
|
+
params.each do |param|
|
20
|
+
result = result[param] if result.class == Hash
|
21
|
+
end
|
22
|
+
|
23
|
+
result
|
24
|
+
end
|
25
|
+
|
26
|
+
######CHECK HTTTP REQUEST STATUS !!!!!
|
27
|
+
def check_status(response, template_param)
|
28
|
+
status = parse_response(response, template_param)
|
29
|
+
end
|
30
|
+
######
|
31
|
+
|
32
|
+
def map_array(response, template_param)
|
33
|
+
result = Array.new
|
34
|
+
data = parse_response(response, template_param)
|
35
|
+
|
36
|
+
#Checks for wrong or empty array
|
37
|
+
if data.class == Array and data.empty? == false
|
38
|
+
result.push(data)
|
39
|
+
end
|
40
|
+
|
41
|
+
result.each do |param|
|
42
|
+
# ap param
|
43
|
+
param.each do |one_param|
|
44
|
+
yield one_param
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
|
50
|
+
def map_string(response, template_param)
|
51
|
+
data = parse_response(response, template_param)
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
|
2
|
+
module Gumiho
|
3
|
+
|
4
|
+
class PathConfig
|
5
|
+
|
6
|
+
attr_reader :hostname, :port, :protocol
|
7
|
+
|
8
|
+
def initialize(protocol, hostname, port, path)
|
9
|
+
@protocol = protocol
|
10
|
+
@hostname = hostname
|
11
|
+
@port = port
|
12
|
+
@path = path
|
13
|
+
end
|
14
|
+
|
15
|
+
#Builds path from given params
|
16
|
+
def build_path(other=nil)
|
17
|
+
return @route = "#{@protocol}://#{@hostname}:#{@port}#{@path}" if other==nil
|
18
|
+
return @route = "#{@protocol}://#{@hostname}:#{@port}#{other}"
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
@@ -0,0 +1,107 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
require 'json'
|
3
|
+
require 'awesome_print'
|
4
|
+
|
5
|
+
module JSON
|
6
|
+
def self.is_json?(foo)
|
7
|
+
begin
|
8
|
+
return false unless foo.is_a?(String)
|
9
|
+
JSON.parse(foo).all?
|
10
|
+
rescue JSON::ParserError
|
11
|
+
false
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
|
17
|
+
module Gumiho
|
18
|
+
|
19
|
+
def print_processing_url_method(url, method)
|
20
|
+
puts "Processing URL: #{url} via method #{method}"
|
21
|
+
end
|
22
|
+
|
23
|
+
def check_if_json(response_body)
|
24
|
+
if JSON.is_json?(response_body)
|
25
|
+
json_data = JSON.parse(response_body)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
#Without doc true
|
30
|
+
def routes_get(path)
|
31
|
+
uri = URI(path)
|
32
|
+
|
33
|
+
# uri.query = URI.encode_www_form()
|
34
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
35
|
+
|
36
|
+
print_processing_url_method(uri, 'GET')
|
37
|
+
|
38
|
+
response = http.get(uri)
|
39
|
+
|
40
|
+
#Checks if JSON response is right
|
41
|
+
check_if_json(response.body)
|
42
|
+
end
|
43
|
+
|
44
|
+
# GET request
|
45
|
+
def get_method(path)
|
46
|
+
uri = URI(path)
|
47
|
+
|
48
|
+
uri.query = URI.encode_www_form({ :doc => true })
|
49
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
50
|
+
|
51
|
+
print_processing_url_method(uri, 'GET')
|
52
|
+
|
53
|
+
response = http.get(uri)
|
54
|
+
|
55
|
+
#Checks if JSON response is right
|
56
|
+
check_if_json(response.body)
|
57
|
+
|
58
|
+
end
|
59
|
+
|
60
|
+
#POST request
|
61
|
+
def post_method(path)
|
62
|
+
|
63
|
+
uri = URI(path)
|
64
|
+
|
65
|
+
request = Net::HTTP::Post.new(uri.path)
|
66
|
+
|
67
|
+
request.set_form_data({:doc=>true})
|
68
|
+
|
69
|
+
response = Net::HTTP.start(uri.hostname, uri.port) do |http|
|
70
|
+
http.request(request)
|
71
|
+
end
|
72
|
+
print_processing_url_method(uri, 'POST')
|
73
|
+
check_if_json(response.body)
|
74
|
+
end
|
75
|
+
|
76
|
+
#PUT request
|
77
|
+
def put_method(path)
|
78
|
+
uri = URI(path)
|
79
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
80
|
+
|
81
|
+
print_processing_url_method(uri, 'PUT')
|
82
|
+
|
83
|
+
request = Net::HTTP::Put.new(path)
|
84
|
+
request.set_form_data({:doc=>true })
|
85
|
+
response = http.request(request)
|
86
|
+
|
87
|
+
check_if_json(response.body)
|
88
|
+
end
|
89
|
+
|
90
|
+
#DELETE request
|
91
|
+
def delete_method(path)
|
92
|
+
uri = URI(path)
|
93
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
94
|
+
|
95
|
+
print_processing_url_method(uri, 'DELETE')
|
96
|
+
|
97
|
+
response = http.delete(path)
|
98
|
+
|
99
|
+
check_if_json(response.body)
|
100
|
+
end
|
101
|
+
|
102
|
+
#Example filter for routes containing given substring used in generate_doc
|
103
|
+
def route_filter(path)
|
104
|
+
path.include? 'time'
|
105
|
+
end
|
106
|
+
|
107
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
|
2
|
+
toggleResult = function(button) {
|
3
|
+
form.find('.result').toggle('slow')
|
4
|
+
|
5
|
+
if($(button).html() == 'Hide') {
|
6
|
+
$(button).html('Show')
|
7
|
+
} else {
|
8
|
+
$(button).html('Hide')
|
9
|
+
}
|
10
|
+
}
|
11
|
+
|
12
|
+
tryMe = function(method, url, button){
|
13
|
+
form = $(button).parent()
|
14
|
+
inputs = form.find('input')
|
15
|
+
data = {}
|
16
|
+
param_url = url
|
17
|
+
inputs.each(function(index) {
|
18
|
+
|
19
|
+
if(url.indexOf(':' + $(this).attr('name')) >= 0) {
|
20
|
+
url=url.replace(':' + $(this).attr('name'), $(this).val())
|
21
|
+
} else {
|
22
|
+
data[$(this).attr('name')] = $(this).val()
|
23
|
+
}
|
24
|
+
|
25
|
+
})
|
26
|
+
|
27
|
+
|
28
|
+
$.ajax({
|
29
|
+
type: method,
|
30
|
+
url: url,
|
31
|
+
data: data,
|
32
|
+
dataType: 'json',
|
33
|
+
crossDomain: true,
|
34
|
+
|
35
|
+
success: function( data, textStatus, jqXHR ){
|
36
|
+
console.log(data);
|
37
|
+
str = JSON.stringify(data, undefined, 4)
|
38
|
+
form.find('.result').show()
|
39
|
+
form.find('.requested_url').html(url)
|
40
|
+
form.find('.response_box').html(str)
|
41
|
+
form.find('.response_headers').html(jqXHR.getAllResponseHeaders())
|
42
|
+
form.find('.response_code').html(jqXHR.status)
|
43
|
+
|
44
|
+
if(form.find('button[onclick="toggleResult(this)"]').length==0) {
|
45
|
+
form.append('<button onclick="toggleResult(this)" type="button">Hide</button>')
|
46
|
+
}
|
47
|
+
},
|
48
|
+
error: function(data) {
|
49
|
+
inputs.each(function(index){
|
50
|
+
if(param_url.indexOf(':' + $(this).attr('name'))>=0) {
|
51
|
+
input_name = 'input[name='+$(this).attr('name')+']'
|
52
|
+
form.find(input_name).val('required').css('color', 'red')
|
53
|
+
}
|
54
|
+
})
|
55
|
+
|
56
|
+
inputs.focus(function() {
|
57
|
+
if($(this).val()=='required') {
|
58
|
+
$(this).animate({color:'red'}, 100, function() {
|
59
|
+
$(this).val('').css('color', 'black')
|
60
|
+
})
|
61
|
+
}
|
62
|
+
})
|
63
|
+
|
64
|
+
}
|
65
|
+
})
|
66
|
+
|
67
|
+
}
|
68
|
+
|
@@ -0,0 +1,84 @@
|
|
1
|
+
|
2
|
+
div.main {
|
3
|
+
width: 1000px;
|
4
|
+
margin: auto;}
|
5
|
+
|
6
|
+
.box {
|
7
|
+
display: block;
|
8
|
+
padding: 10px 10px;
|
9
|
+
font-size: 14px;
|
10
|
+
color: #1a2f43;
|
11
|
+
margin: 25px;
|
12
|
+
background-color:#dddddd;
|
13
|
+
border-color: black;
|
14
|
+
border-radius: 5px;}
|
15
|
+
|
16
|
+
.method {
|
17
|
+
background-color:#6fc717;
|
18
|
+
padding: 10px 10px;
|
19
|
+
border-radius: 5px;
|
20
|
+
padding: 10px 10px;
|
21
|
+
color: #fff;
|
22
|
+
font-weight:bold;}
|
23
|
+
|
24
|
+
.response_box {
|
25
|
+
display: block;
|
26
|
+
padding: 10px;
|
27
|
+
background-color: white;
|
28
|
+
height: 250px;
|
29
|
+
overflow: auto;
|
30
|
+
border-radius: 5px;}
|
31
|
+
|
32
|
+
.params {
|
33
|
+
border-collapse: collapse;
|
34
|
+
width: 100%;
|
35
|
+
border-bottom: 1px solid #889098;}
|
36
|
+
|
37
|
+
.params td, th {border-top: 1px solid #889098;}
|
38
|
+
|
39
|
+
.failed {
|
40
|
+
font-weight:bold;
|
41
|
+
color: #bb132a;
|
42
|
+
font-size: 16px;}
|
43
|
+
|
44
|
+
.method_failed {
|
45
|
+
background-color:#bb132a;
|
46
|
+
padding: 10px 10px;
|
47
|
+
border-radius: 5px;
|
48
|
+
padding: 10px 10px;
|
49
|
+
color: #fff;
|
50
|
+
font-weight:bold;}
|
51
|
+
|
52
|
+
.requested_url {
|
53
|
+
background-color: white;
|
54
|
+
height: 20px;
|
55
|
+
border-radius: 5px;
|
56
|
+
padding: 10px;
|
57
|
+
overflow: auto;
|
58
|
+
display: block;}
|
59
|
+
|
60
|
+
.description {
|
61
|
+
display: block;
|
62
|
+
padding: 12px 0px;}
|
63
|
+
|
64
|
+
.response_headers {
|
65
|
+
background-color: white;
|
66
|
+
padding: 10px;
|
67
|
+
height: 100px;
|
68
|
+
overflow: auto;
|
69
|
+
border-radius: 5px;
|
70
|
+
display: block;}
|
71
|
+
|
72
|
+
.result {
|
73
|
+
display: none;}
|
74
|
+
|
75
|
+
.response_h {
|
76
|
+
font-weight: bold;}
|
77
|
+
|
78
|
+
.response_code {
|
79
|
+
display: block;
|
80
|
+
background-color: white;
|
81
|
+
padding: 10px;
|
82
|
+
height: 20px;
|
83
|
+
overflow: auto;
|
84
|
+
border-radius: 5px;}
|
@@ -0,0 +1,64 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>Generated Documentation</title>
|
5
|
+
|
6
|
+
<link rel="stylesheet" type="text/css" href=<%=Gem::Specification.find_by_name("gumiho").gem_dir + "/lib/generate_doc/style/template_style.css" %>>
|
7
|
+
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
|
8
|
+
<script type="text/javascript" src=<%=Gem::Specification.find_by_name("gumiho").gem_dir + "/lib/generate_doc/javascript/template_script.js" %>> </script>
|
9
|
+
</head>
|
10
|
+
|
11
|
+
<body>
|
12
|
+
<br>
|
13
|
+
<div class="main">
|
14
|
+
<ul class="items">
|
15
|
+
<% response.each do |res| %>
|
16
|
+
<% if check_status(res[:response], 'metadata.status') == 'ok' %>
|
17
|
+
<li class="box">
|
18
|
+
<span class="method"><%= res[:method] %></span>
|
19
|
+
<span class="url"><b><%= res[:url] %> </b></span>
|
20
|
+
<span class="description"><b>Description:</b> <%= map_string(res[:response], 'data.description') %> </span>
|
21
|
+
<form>
|
22
|
+
<table class ="params">
|
23
|
+
<tr>
|
24
|
+
<th><b>Name</b></th>
|
25
|
+
<th><b>Value</b></th>
|
26
|
+
<th><b>Require</b></th>
|
27
|
+
<th><b>Type</b></th>
|
28
|
+
<th><b>Description</b></th>
|
29
|
+
</tr>
|
30
|
+
<% map_array(res[:response], 'data.params') do |param_data| %>
|
31
|
+
<tr>
|
32
|
+
<td><%= name = map_string(param_data,'name') %></td>
|
33
|
+
<td><input type="text" name=<%= name %> ></td>
|
34
|
+
<td><%= map_string(param_data,'required') %></td>
|
35
|
+
<td><%= map_string(param_data,'type') %></td>
|
36
|
+
<td><%= map_string(param_data,'desc') %></td>
|
37
|
+
</tr>
|
38
|
+
<% end %>
|
39
|
+
</table>
|
40
|
+
<div class="result">
|
41
|
+
<span class="response_h">Requested url</span>
|
42
|
+
<pre class="requested_url"></pre>
|
43
|
+
<span class="response_h">Response body</span>
|
44
|
+
<pre class="response_box" ></pre>
|
45
|
+
<span class="response_h">Response headers</span>
|
46
|
+
<pre class="response_headers"></pre>
|
47
|
+
<span class="response_h">Response status</span>
|
48
|
+
<pre class='response_code'></pre>
|
49
|
+
</div>
|
50
|
+
<button onclick="tryMe('<%= res[:method] %>', '<%= res[:url] %>', this)" type="button">Try it out</button>
|
51
|
+
</form>
|
52
|
+
</li>
|
53
|
+
<% else %>
|
54
|
+
<li class="box">
|
55
|
+
<span class="method_failed"><%= res[:method] %></span>
|
56
|
+
<span class="url"><b><%= res[:url] %> </b></span>
|
57
|
+
<p class="failed">Request FAILED.</p>
|
58
|
+
</li>
|
59
|
+
<% end %>
|
60
|
+
<% end %>
|
61
|
+
</ul>
|
62
|
+
</div>
|
63
|
+
</body>
|
64
|
+
</html>
|
Binary file
|
metadata
ADDED
@@ -0,0 +1,107 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: gumiho
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- IvaDobreva
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-08-29 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.3'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: choice
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 0.1.6
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.1.6
|
55
|
+
description: Ruby gem for creating online RESTful API documentation with possibility
|
56
|
+
to test different HTTP requests
|
57
|
+
email:
|
58
|
+
- iva95dobreva@gmail.com
|
59
|
+
executables:
|
60
|
+
- gumiho-export
|
61
|
+
extensions: []
|
62
|
+
extra_rdoc_files: []
|
63
|
+
files:
|
64
|
+
- ".README.md.swp"
|
65
|
+
- Gemfile
|
66
|
+
- Gemfile.lock
|
67
|
+
- LICENSE.txt
|
68
|
+
- README.md
|
69
|
+
- Rakefile
|
70
|
+
- bin/gumiho-export
|
71
|
+
- gumiho.gemspec
|
72
|
+
- lib/config.yml
|
73
|
+
- lib/generate_doc.rb
|
74
|
+
- lib/gumiho/command_line_params.rb
|
75
|
+
- lib/gumiho/generate_response.rb
|
76
|
+
- lib/gumiho/path_config.rb
|
77
|
+
- lib/gumiho/route_methods.rb
|
78
|
+
- lib/gumiho/template/javascript/template_script.js
|
79
|
+
- lib/gumiho/template/style/template_style.css
|
80
|
+
- lib/gumiho/template/template.html.erb
|
81
|
+
- lib/gumiho/version.rb
|
82
|
+
- pkg/generate_doc-0.0.1.gem
|
83
|
+
homepage: ''
|
84
|
+
licenses:
|
85
|
+
- MIT
|
86
|
+
metadata: {}
|
87
|
+
post_install_message:
|
88
|
+
rdoc_options: []
|
89
|
+
require_paths:
|
90
|
+
- lib
|
91
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - ">="
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '0'
|
96
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
97
|
+
requirements:
|
98
|
+
- - ">="
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: '0'
|
101
|
+
requirements: []
|
102
|
+
rubyforge_project:
|
103
|
+
rubygems_version: 2.2.2
|
104
|
+
signing_key:
|
105
|
+
specification_version: 4
|
106
|
+
summary: Create API documentation
|
107
|
+
test_files: []
|