grape-rails-routes 1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +35 -0
- data/Gemfile +3 -0
- data/LICENSE +21 -0
- data/README.md +29 -0
- data/app/views/layouts/grape-rails-routes.html.erb +36 -0
- data/app/views/rails/info/routes_with_grape.html.erb +9 -0
- data/grape-rails-routes.gemspec +24 -0
- data/lib/grape-rails-routes.rb +13 -0
- data/lib/rails/info_controller.rb +25 -0
- data/lib/rails/tasks/routes_with_grape.rake +18 -0
- metadata +72 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 333c53a37298f761e30085fb216b6cbcdae16836
|
4
|
+
data.tar.gz: 3bf7f5fb7344474be9d52889ef24685cf64860f6
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f6ef3b13dca5bf9298005e1c1d01575a24f0027740888654d3bcaec6274f9638bbafe6db885bb9c4bde93a8dbec99e8ee69224e8bd376ecf33ca7307e7e94ac4
|
7
|
+
data.tar.gz: ba112c4567b4c9101d13a86ab89ea4b65ce469ff5b7d778c2413f62d641679f4b27fe5112aafb6830a9d6465731958df2a168255b462709dd8cc564ad3c0335f
|
data/.gitignore
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
/.config
|
4
|
+
/coverage/
|
5
|
+
/InstalledFiles
|
6
|
+
/pkg/
|
7
|
+
/spec/reports/
|
8
|
+
/test/tmp/
|
9
|
+
/test/version_tmp/
|
10
|
+
/tmp/
|
11
|
+
|
12
|
+
## Specific to RubyMotion:
|
13
|
+
.dat*
|
14
|
+
.repl_history
|
15
|
+
build/
|
16
|
+
|
17
|
+
## Documentation cache and generated files:
|
18
|
+
/.yardoc/
|
19
|
+
/_yardoc/
|
20
|
+
/doc/
|
21
|
+
/rdoc/
|
22
|
+
|
23
|
+
## Environment normalisation:
|
24
|
+
/.bundle/
|
25
|
+
/lib/bundler/man/
|
26
|
+
|
27
|
+
# for a library or gem, you might want to ignore these files since the code is
|
28
|
+
# intended to run in multiple environments; otherwise, check them in:
|
29
|
+
# Gemfile.lock
|
30
|
+
# .ruby-version
|
31
|
+
# .ruby-gemset
|
32
|
+
|
33
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
34
|
+
.rvmrc
|
35
|
+
.DS_Store
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2014 ピエスヴィアール(P.S.V.R)
|
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 all
|
13
|
+
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 THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# grape-rails-routes
|
2
|
+
|
3
|
+
After you mount Grape API routes into Rails, Grape API routes would normally not be printed in `rake routes` or `/rails/info/routes`.
|
4
|
+
|
5
|
+
This gem adds routes printing functionalities for Grape into Rails.
|
6
|
+
|
7
|
+
## Usage
|
8
|
+
|
9
|
+
Add this line to your `Gemfile`
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'grape-rails-routes'
|
13
|
+
```
|
14
|
+
|
15
|
+
Then review your routes via
|
16
|
+
|
17
|
+
```bash
|
18
|
+
rake routes_with_grape
|
19
|
+
```
|
20
|
+
|
21
|
+
Or (recommended) access
|
22
|
+
|
23
|
+
```
|
24
|
+
http://localhost:3000/rails/info/routes_with_grape
|
25
|
+
```
|
26
|
+
|
27
|
+
to get a HTML table view of all your routes.
|
28
|
+
|
29
|
+
Enjoy :P
|
@@ -0,0 +1,36 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html lang="en">
|
3
|
+
<head>
|
4
|
+
<meta charset="utf-8" />
|
5
|
+
<title><%= @page_title %></title>
|
6
|
+
<style>
|
7
|
+
body { background-color: #fff; color: #333; }
|
8
|
+
|
9
|
+
body, p, ol, ul, td {
|
10
|
+
font-family: helvetica, verdana, arial, sans-serif;
|
11
|
+
font-size: 13px;
|
12
|
+
line-height: 18px;
|
13
|
+
}
|
14
|
+
|
15
|
+
pre {
|
16
|
+
background-color: #eee;
|
17
|
+
padding: 10px;
|
18
|
+
font-size: 11px;
|
19
|
+
white-space: pre-wrap;
|
20
|
+
}
|
21
|
+
|
22
|
+
a { color: #000; }
|
23
|
+
a:visited { color: #666; }
|
24
|
+
a:hover { color: #fff; background-color:#000; }
|
25
|
+
|
26
|
+
h2 { padding-left: 10px; }
|
27
|
+
|
28
|
+
<%= yield :style %>
|
29
|
+
</style>
|
30
|
+
</head>
|
31
|
+
<body>
|
32
|
+
|
33
|
+
<%= yield %>
|
34
|
+
|
35
|
+
</body>
|
36
|
+
</html>
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = 'grape-rails-routes'
|
5
|
+
s.version = '1.0'
|
6
|
+
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
|
+
s.authors = ["P.S.V.R"]
|
9
|
+
s.date = `git log --pretty="%ai" -n 1`.split(" ").first
|
10
|
+
s.description = "After you mount Grape API routes into Rails, Grape API routes would normally not be printed via `rake routes` or `/rails/info/routes`. This gem adds routes printing for Grape with Rails."
|
11
|
+
s.email = ['pmq2001@gmail.com']
|
12
|
+
s.executables = []
|
13
|
+
s.extensions = []
|
14
|
+
s.files = `git ls-files`.split($/)
|
15
|
+
s.homepage = "https://github.com/pmq20/grape-rails-routes"
|
16
|
+
s.license = "MIT"
|
17
|
+
s.rdoc_options = []
|
18
|
+
s.require_paths = ["lib"]
|
19
|
+
s.required_ruby_version = Gem::Requirement.new(">= 1.8.7")
|
20
|
+
s.rubygems_version = "1.8.25"
|
21
|
+
s.summary = "After you mount Grape API routes into Rails, Grape API routes would normally not be printed via `rake routes` or `/rails/info/routes`. This gem adds routes printing for Grape with Rails."
|
22
|
+
|
23
|
+
s.add_dependency('rails', [">= 4.1.4"])
|
24
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
class GrapeRailsRoutes < Rails::Railtie
|
2
|
+
rake_tasks do
|
3
|
+
Dir[File.join(File.dirname(__FILE__), 'rails/tasks/*.rake')].each { |f| load f }
|
4
|
+
end
|
5
|
+
|
6
|
+
initializer 'GrapeRailsRoutes.initializer' do
|
7
|
+
require File.join(File.dirname(__FILE__), 'rails/info_controller')
|
8
|
+
|
9
|
+
Rails.application.routes.append do
|
10
|
+
get '/rails/info/routes_with_grape' => 'rails/info#routes_with_grape'
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'rails/info_controller'
|
2
|
+
|
3
|
+
class Rails::InfoController < Rails::ApplicationController # :nodoc:
|
4
|
+
prepend_view_path ActionDispatch::DebugExceptions::RESCUES_TEMPLATE_PATH
|
5
|
+
prepend_view_path File.expand_path('../../../app/views', __FILE__)
|
6
|
+
|
7
|
+
def routes_with_grape
|
8
|
+
all_routes = _routes.routes
|
9
|
+
grape_klasses = ObjectSpace.each_object(Class).select { |klass| klass < Grape::API }
|
10
|
+
app = all_routes.first.app
|
11
|
+
grape_klasses.each do |klass|
|
12
|
+
klass.compile
|
13
|
+
klass.routes.each do |route|
|
14
|
+
path = ActionDispatch::Journey::Path::Pattern.new route.route_path
|
15
|
+
all_routes.add_route(klass, path, {
|
16
|
+
request_method: %r{^#{route.route_method}$}
|
17
|
+
}, {}, route.route_description)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
@routes_inspector = ActionDispatch::Routing::RoutesInspector.new(all_routes)
|
22
|
+
@page_title = 'Routes with grape'
|
23
|
+
render layout: 'grape-rails-routes'
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
desc 'Print out all defined routes, with grape routes, in match order, with names. Target specific controller with CONTROLLER=x.'
|
2
|
+
task routes_with_grape: :environment do
|
3
|
+
all_routes = Rails.application.routes.routes
|
4
|
+
grape_klasses = ObjectSpace.each_object(Class).select { |klass| klass < Grape::API }
|
5
|
+
app = all_routes.first.app
|
6
|
+
grape_klasses.each do |klass|
|
7
|
+
klass.compile
|
8
|
+
klass.routes.each do |route|
|
9
|
+
path = ActionDispatch::Journey::Path::Pattern.new route.route_path
|
10
|
+
all_routes.add_route(klass, path, {
|
11
|
+
request_method: %r{^#{route.route_method}$}
|
12
|
+
}, {}, route.route_description)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
require 'action_dispatch/routing/inspector'
|
16
|
+
inspector = ActionDispatch::Routing::RoutesInspector.new(all_routes)
|
17
|
+
puts inspector.format(ActionDispatch::Routing::ConsoleFormatter.new, ENV['CONTROLLER'])
|
18
|
+
end
|
metadata
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: grape-rails-routes
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: '1.0'
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- P.S.V.R
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-07-24 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rails
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 4.1.4
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 4.1.4
|
27
|
+
description: After you mount Grape API routes into Rails, Grape API routes would normally
|
28
|
+
not be printed via `rake routes` or `/rails/info/routes`. This gem adds routes printing
|
29
|
+
for Grape with Rails.
|
30
|
+
email:
|
31
|
+
- pmq2001@gmail.com
|
32
|
+
executables: []
|
33
|
+
extensions: []
|
34
|
+
extra_rdoc_files: []
|
35
|
+
files:
|
36
|
+
- ".gitignore"
|
37
|
+
- Gemfile
|
38
|
+
- LICENSE
|
39
|
+
- README.md
|
40
|
+
- app/views/layouts/grape-rails-routes.html.erb
|
41
|
+
- app/views/rails/info/routes_with_grape.html.erb
|
42
|
+
- grape-rails-routes.gemspec
|
43
|
+
- lib/grape-rails-routes.rb
|
44
|
+
- lib/rails/info_controller.rb
|
45
|
+
- lib/rails/tasks/routes_with_grape.rake
|
46
|
+
homepage: https://github.com/pmq20/grape-rails-routes
|
47
|
+
licenses:
|
48
|
+
- MIT
|
49
|
+
metadata: {}
|
50
|
+
post_install_message:
|
51
|
+
rdoc_options: []
|
52
|
+
require_paths:
|
53
|
+
- lib
|
54
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
55
|
+
requirements:
|
56
|
+
- - ">="
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
version: 1.8.7
|
59
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - ">="
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: '0'
|
64
|
+
requirements: []
|
65
|
+
rubyforge_project:
|
66
|
+
rubygems_version: 2.2.2
|
67
|
+
signing_key:
|
68
|
+
specification_version: 4
|
69
|
+
summary: After you mount Grape API routes into Rails, Grape API routes would normally
|
70
|
+
not be printed via `rake routes` or `/rails/info/routes`. This gem adds routes printing
|
71
|
+
for Grape with Rails.
|
72
|
+
test_files: []
|