swagui 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f19126dd94d0e1eaae42954a99bc0df93c2172e6
4
+ data.tar.gz: 2c794a1596ece50d5681494bdf5c52df26786a4a
5
+ SHA512:
6
+ metadata.gz: 4f0d78480150570e435c3531766ec7e586495821a00979eec91dafab18b0d72bb27fb9e272f78c26ac62d77c0f177608ca5ec4346975802bd3194e7df5270c21
7
+ data.tar.gz: 6fe3be56972e6642577b1bb2842a58ae3997dd6b03ffb99c9af82a3d966c4faed32417f26fbc05c4de9d2f9ea1e14f9fa015ceb1ba30ffc8b77a50d367851036
data/.gitignore ADDED
@@ -0,0 +1,22 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in swagui.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Jack Xu
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,29 @@
1
+ # Swagui
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'swagui'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install swagui
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it ( https://github.com/[my-github-username]/swagui/fork )
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
data/bin/swagui ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'swagui'
4
+
5
+ puts '1'*100
@@ -0,0 +1,41 @@
1
+ require 'rack'
2
+
3
+ module Swagui
4
+
5
+ class Middleware
6
+
7
+ def initialize(app, options={})
8
+ @app = app
9
+
10
+ @url_path = options[:url]
11
+ @doc_path = options[:path] || @url_path
12
+ @url_regex = Regexp.new("^#{@url_path}")
13
+ @assets_url_regex = Regexp.new("^\/swagger-ui")
14
+
15
+ app_doc_dir = File.expand_path(@doc_path, Dir.pwd)
16
+ @app_file_server = Rack::File.new(app_doc_dir)
17
+ swagger_ui_dir = File.expand_path('../../swagger-ui', File.dirname(__FILE__))
18
+ @swagger_ui_file_server = Rack::File.new(swagger_ui_dir)
19
+ end
20
+
21
+ def call(env)
22
+ path = env["PATH_INFO"].strip
23
+
24
+ if !(path =~ @url_regex).nil?
25
+ path = path.gsub(@url_regex, '')
26
+ if path == '' || path == '/'
27
+ env["PATH_INFO"] = 'index.html'
28
+ @swagger_ui_file_server.call(env)
29
+ else
30
+ env["PATH_INFO"] = path
31
+ @app_file_server.call(env)
32
+ end
33
+ elsif !(path =~ @assets_url_regex).nil?
34
+ env["PATH_INFO"] = path.gsub(@assets_url_regex, '')
35
+ @swagger_ui_file_server.call(env)
36
+ else
37
+ @app.call(env)
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,3 @@
1
+ module Swagui
2
+ VERSION = "0.0.1"
3
+ end
data/lib/swagui.rb ADDED
@@ -0,0 +1,6 @@
1
+ require "swagui/version"
2
+ require "swagui/middleware"
3
+
4
+ module Swagui
5
+ # Your code goes here...
6
+ end
@@ -0,0 +1,125 @@
1
+ /* http://meyerweb.com/eric/tools/css/reset/ v2.0 | 20110126 */
2
+ html,
3
+ body,
4
+ div,
5
+ span,
6
+ applet,
7
+ object,
8
+ iframe,
9
+ h1,
10
+ h2,
11
+ h3,
12
+ h4,
13
+ h5,
14
+ h6,
15
+ p,
16
+ blockquote,
17
+ pre,
18
+ a,
19
+ abbr,
20
+ acronym,
21
+ address,
22
+ big,
23
+ cite,
24
+ code,
25
+ del,
26
+ dfn,
27
+ em,
28
+ img,
29
+ ins,
30
+ kbd,
31
+ q,
32
+ s,
33
+ samp,
34
+ small,
35
+ strike,
36
+ strong,
37
+ sub,
38
+ sup,
39
+ tt,
40
+ var,
41
+ b,
42
+ u,
43
+ i,
44
+ center,
45
+ dl,
46
+ dt,
47
+ dd,
48
+ ol,
49
+ ul,
50
+ li,
51
+ fieldset,
52
+ form,
53
+ label,
54
+ legend,
55
+ table,
56
+ caption,
57
+ tbody,
58
+ tfoot,
59
+ thead,
60
+ tr,
61
+ th,
62
+ td,
63
+ article,
64
+ aside,
65
+ canvas,
66
+ details,
67
+ embed,
68
+ figure,
69
+ figcaption,
70
+ footer,
71
+ header,
72
+ hgroup,
73
+ menu,
74
+ nav,
75
+ output,
76
+ ruby,
77
+ section,
78
+ summary,
79
+ time,
80
+ mark,
81
+ audio,
82
+ video {
83
+ margin: 0;
84
+ padding: 0;
85
+ border: 0;
86
+ font-size: 100%;
87
+ font: inherit;
88
+ vertical-align: baseline;
89
+ }
90
+ /* HTML5 display-role reset for older browsers */
91
+ article,
92
+ aside,
93
+ details,
94
+ figcaption,
95
+ figure,
96
+ footer,
97
+ header,
98
+ hgroup,
99
+ menu,
100
+ nav,
101
+ section {
102
+ display: block;
103
+ }
104
+ body {
105
+ line-height: 1;
106
+ }
107
+ ol,
108
+ ul {
109
+ list-style: none;
110
+ }
111
+ blockquote,
112
+ q {
113
+ quotes: none;
114
+ }
115
+ blockquote:before,
116
+ blockquote:after,
117
+ q:before,
118
+ q:after {
119
+ content: '';
120
+ content: none;
121
+ }
122
+ table {
123
+ border-collapse: collapse;
124
+ border-spacing: 0;
125
+ }