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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8c3293eb8eefc93cf9a64b2e2851da7cb5c364f0
4
- data.tar.gz: 2db137846716c95614976ba46ed6d3d86b560ddc
3
+ metadata.gz: 6ca163007e1cc40a05ddb7d54bcedb07e092d6ae
4
+ data.tar.gz: 4bdd0c412bbe5f0830e7171f007e41249a518060
5
5
  SHA512:
6
- metadata.gz: da6534c89f52d0304370501edad3b0a3a3dabaefea1c53daf26771c81239bb3b9862852eeb2a596b9f08bccee317d9e6587b707bf78ba161dfa67d2f7860a5d2
7
- data.tar.gz: '019e919f98c4eb89b63d19ea457fe63eff12b6c9d26367f18aa5dd0985a24e7cda635613997f500e49f14928e01981d2f25109d54e195f0d7dd3267d1b0fe533'
6
+ metadata.gz: 0f62704c5d7e8ed9bdc1a1fc1bdff82358467013dd6ddcf8ceda4d8582adeaab37b6e70198c4cbcdd63378f9f90abce55724e5d35ee403208526407a3f7c2a86
7
+ data.tar.gz: 2bf01d9d49175e5175736775c626b1239913a25b6c54585740ad247c8dbf059a784d2f334e50fb0a573ce4fc11b7761fe01f7d9a1faecae15b596c74550cbe92
data/.hound.yml ADDED
@@ -0,0 +1,2 @@
1
+ ruby:
2
+ config_file: .rubocop.yml
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
- language: ruby
4
- rvm:
5
- - 2.3.2
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
@@ -1,3 +1,11 @@
1
+ ### NEXT
2
+
3
+ ### 0.3.0
4
+
5
+ - adds redoc oapi documentation viewer
6
+ - default rake task now only spec, rubocop would be done via hound
7
+ - adds hound ci service
8
+
1
9
  ### 0.2.4
2
10
 
3
11
  - fix: add mount point to api base
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
@@ -11,4 +11,4 @@ RSpec::Core::RakeTask.new(:spec)
11
11
  require 'rubocop/rake_task'
12
12
  RuboCop::RakeTask.new(:rubocop)
13
13
 
14
- task default: [:rubocop, :spec]
14
+ task default: [:spec]
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.call!(resource, builder_options)
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(' ')}`
@@ -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 call!(resource, options = {})
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
 
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Starter
3
- VERSION = '0.2.4'
3
+ VERSION = '0.3.0'
4
4
  end
data/template/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # adept it to your needs
2
2
 
3
- # Grape API on Rack
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 grape:routes
55
+ rake routes
56
56
  ```
57
57
 
58
58
  #### OpenApi Documentation and Validation
59
59
 
60
- -> see [`grape-swagger` Rake Tasks](https://github.com/ruby-grape/grape-swagger#rake-tasks)
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
@@ -11,6 +11,7 @@ module Api
11
11
  info: {
12
12
  title: 'Starter API'
13
13
  },
14
+ mount_path: '/oapi',
14
15
  models: [
15
16
  Entities::ApiError
16
17
  ]
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.2.4
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-14 00:00:00.000000000 Z
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