grape-starter 0.2.4 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.hound.yml +2 -0
- data/.travis.yml +16 -3
- data/CHANGELOG.md +8 -0
- data/README.md +9 -1
- data/Rakefile +1 -1
- data/bin/grape-starter +1 -1
- data/lib/starter/builder.rb +1 -2
- data/lib/starter/version.rb +1 -1
- data/template/README.md +8 -4
- data/template/api/base.rb +1 -0
- data/template/config.ru +4 -0
- data/template/public/redoc.html +22 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6ca163007e1cc40a05ddb7d54bcedb07e092d6ae
|
4
|
+
data.tar.gz: 4bdd0c412bbe5f0830e7171f007e41249a518060
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0f62704c5d7e8ed9bdc1a1fc1bdff82358467013dd6ddcf8ceda4d8582adeaab37b6e70198c4cbcdd63378f9f90abce55724e5d35ee403208526407a3f7c2a86
|
7
|
+
data.tar.gz: 2bf01d9d49175e5175736775c626b1239913a25b6c54585740ad247c8dbf059a784d2f334e50fb0a573ce4fc11b7761fe01f7d9a1faecae15b596c74550cbe92
|
data/.hound.yml
ADDED
data/.travis.yml
CHANGED
@@ -1,5 +1,18 @@
|
|
1
|
+
language: ruby
|
2
|
+
|
1
3
|
sudo: false
|
4
|
+
before_install:
|
5
|
+
- gem install bundler
|
2
6
|
|
3
|
-
|
4
|
-
|
5
|
-
|
7
|
+
matrix:
|
8
|
+
include:
|
9
|
+
- rvm: 2.4.0-rc1
|
10
|
+
- rvm: 2.3.3
|
11
|
+
- rvm: 2.2.6
|
12
|
+
- rvm: ruby-head
|
13
|
+
- rvm: jruby-9.1.6.0
|
14
|
+
- rvm: jruby-head
|
15
|
+
allow_failures:
|
16
|
+
- rvm: ruby-head
|
17
|
+
- rvm: jruby-9.1.6.0
|
18
|
+
- rvm: jruby-head
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -6,9 +6,15 @@
|
|
6
6
|
# Grape Starter
|
7
7
|
|
8
8
|
Is a tool to help you to build up a skeleton for a [Grape](http://github.com/ruby-grape/grape) API mounted on [Rack](https://github.com/rack/rack) ready to run.
|
9
|
-
[grape-swagger](http://github.com/ruby-grape/grape-swagger) would be used to generate a [OAPI](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md) compatible documentation.
|
9
|
+
[grape-swagger](http://github.com/ruby-grape/grape-swagger) would be used to generate a [OAPI](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md) compatible documentation, which could be shown with [ReDoc](https://github.com/Rebilly/ReDoc).
|
10
10
|
|
11
11
|
|
12
|
+
## Why the next one?
|
13
|
+
|
14
|
+
- build up a playground for your ideas, prototypes, testing behaviour, whatever …
|
15
|
+
(I use it to implement specific behaviour and get specs of for [grape-swagger](http://github.com/ruby-grape/grape-swagger))
|
16
|
+
- no assumtions about a backend/ORM, ergo no restrictions, only a pure grape/rack skeleton
|
17
|
+
|
12
18
|
## Usage
|
13
19
|
|
14
20
|
#### Install it
|
@@ -39,6 +45,8 @@ This command creates a folder named `awesome_api` containing the skeleton. With
|
|
39
45
|
│ ├── api
|
40
46
|
│ │ └── version.rb
|
41
47
|
│ └── api.rb
|
48
|
+
├── public # for serving static files
|
49
|
+
│ └── redoc.html # provides the ReDoc generated oapi documentation
|
42
50
|
├── script # setup / server / test etc.
|
43
51
|
│ └── …
|
44
52
|
└── spec # RSpec
|
data/Rakefile
CHANGED
data/bin/grape-starter
CHANGED
@@ -67,7 +67,7 @@ command :add do |c|
|
|
67
67
|
|
68
68
|
begin
|
69
69
|
builder_options = global_options.merge(set: set).merge(options)
|
70
|
-
Starter::Builder.
|
70
|
+
Starter::Builder.add!(resource, builder_options)
|
71
71
|
created_files = Starter::Builder.save
|
72
72
|
|
73
73
|
`bundle exec rubocop -a #{created_files.join(' ')}`
|
data/lib/starter/builder.rb
CHANGED
@@ -21,7 +21,7 @@ module Starter
|
|
21
21
|
# (default: nil, possible: post, get, put, patch, delete)
|
22
22
|
# :force - A Boolean, if given existent files should be overwriten (default: nil -> false)
|
23
23
|
# :entity - A Boolean, if given an entity file would be created (default: nil -> false)
|
24
|
-
def
|
24
|
+
def add!(resource, options = {})
|
25
25
|
@resource = resource
|
26
26
|
@set = options[:set]
|
27
27
|
@force = options[:force]
|
@@ -100,7 +100,6 @@ module Starter
|
|
100
100
|
def save_file(new_file)
|
101
101
|
new_file_name = "#{new_file}_name"
|
102
102
|
should_raise?(send(new_file_name))
|
103
|
-
|
104
103
|
write_file(send(new_file_name), send(new_file.strip_heredoc))
|
105
104
|
end
|
106
105
|
|
data/lib/starter/version.rb
CHANGED
data/template/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# adept it to your needs
|
2
2
|
|
3
|
-
|
3
|
+
## Your awesome API
|
4
4
|
|
5
5
|
A [Grape](http://github.com/ruby-grape/grape) API mounted on [Rack](https://github.com/rack/rack), starting point for API development with Grape. It also includes [grape-swagger](http://github.com/ruby-grape/grape-swagger) for documentation generating.
|
6
6
|
|
@@ -26,6 +26,7 @@ $ ./script/test
|
|
26
26
|
```
|
27
27
|
$ ./script/server
|
28
28
|
```
|
29
|
+
and go to: [http://localhost:9292](http://localhost:9292)
|
29
30
|
|
30
31
|
or for production, set `RACK_ENV=production`
|
31
32
|
```
|
@@ -46,18 +47,21 @@ $ ./script/update
|
|
46
47
|
$ ./script/stop
|
47
48
|
```
|
48
49
|
|
49
|
-
|
50
50
|
## Rake Tasks
|
51
51
|
|
52
52
|
#### List Routes
|
53
53
|
|
54
54
|
```
|
55
|
-
rake
|
55
|
+
rake routes
|
56
56
|
```
|
57
57
|
|
58
58
|
#### OpenApi Documentation and Validation
|
59
59
|
|
60
|
-
|
60
|
+
```
|
61
|
+
rake oapi:fetch
|
62
|
+
rake oapi:validate
|
63
|
+
```
|
64
|
+
comming from: [`grape-swagger` Rake Tasks](https://github.com/ruby-grape/grape-swagger#rake-tasks)
|
61
65
|
|
62
66
|
|
63
67
|
## Contributing
|
data/template/api/base.rb
CHANGED
data/template/config.ru
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
require 'rack/cors'
|
3
4
|
use Rack::Cors do
|
4
5
|
allow do
|
@@ -7,6 +8,9 @@ use Rack::Cors do
|
|
7
8
|
end
|
8
9
|
end
|
9
10
|
|
11
|
+
require 'rack/static'
|
12
|
+
use Rack::Static, urls: '/', root: 'public', index: 'redoc.html'
|
13
|
+
|
10
14
|
require File.expand_path('../config/application', __FILE__)
|
11
15
|
|
12
16
|
run Api::Base
|
@@ -0,0 +1,22 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>ReDoc</title>
|
5
|
+
<!-- needed for adaptive design -->
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
7
|
+
|
8
|
+
<!--
|
9
|
+
ReDoc doesn't change outer page styles
|
10
|
+
-->
|
11
|
+
<style>
|
12
|
+
body {
|
13
|
+
margin: 0;
|
14
|
+
padding: 0;
|
15
|
+
}
|
16
|
+
</style>
|
17
|
+
</head>
|
18
|
+
<body>
|
19
|
+
<redoc spec-url='http://localhost:9292/api/v1/oapi.json'></redoc>
|
20
|
+
<script src="https://rebilly.github.io/ReDoc/releases/latest/redoc.min.js"> </script>
|
21
|
+
</body>
|
22
|
+
</html>
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: grape-starter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- LeFnord
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-12-
|
11
|
+
date: 2016-12-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gli
|
@@ -145,6 +145,7 @@ extensions: []
|
|
145
145
|
extra_rdoc_files: []
|
146
146
|
files:
|
147
147
|
- ".gitignore"
|
148
|
+
- ".hound.yml"
|
148
149
|
- ".inch.yml"
|
149
150
|
- ".rubocop.yml"
|
150
151
|
- ".rubocop_todo.yml"
|
@@ -180,6 +181,7 @@ files:
|
|
180
181
|
- template/config/environment.rb
|
181
182
|
- template/lib/api.rb
|
182
183
|
- template/lib/api/version.rb
|
184
|
+
- template/public/redoc.html
|
183
185
|
- template/script/console
|
184
186
|
- template/script/server
|
185
187
|
- template/script/setup
|