grape-starter 0.5.0 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +0 -1
- data/README.md +3 -0
- data/bin/grape-starter +2 -2
- data/lib/starter/builder/base_file.rb +3 -0
- data/lib/starter/builder.rb +3 -3
- data/lib/starter/rspec/request_specs.rb +4 -8
- data/lib/starter/version.rb +1 -1
- data/template/config/application.rb +1 -16
- data/template/config/boot.rb +14 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 164f340aa6d4ebf40aa1a945709dc36595a248d6
|
4
|
+
data.tar.gz: 94bfc0f2c8812351e4ec03279734c48d7a634d02
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8314f133d894585b535f37aeb6d0e33ac80e74625b338e0e9a47b92d8cec5c4aa3e89599eccc315138fdce3943ff1b6f1cf1da026e562e62d992cad4a216045d
|
7
|
+
data.tar.gz: cc65647505f297c99c3040df09f3c73d5a5b6f8103c03c694adc6573729f5082de3c7878ca84a9a308d34e0a7f4c52f2f46881f4f9f5af41118492b9c72db445
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -91,3 +91,6 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/LeFnor
|
|
91
91
|
The gem is available as open source under the terms of the [MIT License](LICENSE).
|
92
92
|
|
93
93
|
### ToDos
|
94
|
+
|
95
|
+
- [ ] make usage of [grape_oauth2](https://github.com/nbulaj/grape_oauth2) available
|
96
|
+
- usage of Rack middleware as plug-in system
|
data/bin/grape-starter
CHANGED
@@ -24,7 +24,7 @@ arg_name 'awesome_api'
|
|
24
24
|
command :new do |c|
|
25
25
|
c.flag [:p, :prefix],
|
26
26
|
default_value: 'api',
|
27
|
-
desc: 'sets the prefix of the API
|
27
|
+
desc: 'sets the prefix of the API'
|
28
28
|
|
29
29
|
c.action do |global_options, options, args|
|
30
30
|
dest = args.empty? ? nil : File.join(Dir.getwd, args.first)
|
@@ -45,7 +45,7 @@ command :new do |c|
|
|
45
45
|
FileUtils.cd(dest) do
|
46
46
|
$stdout.puts `bundle install`
|
47
47
|
$stdout.puts `bundle exec rubocop -a`
|
48
|
-
$stdout.puts `git init`
|
48
|
+
$stdout.puts `git init; git add .; git commit -m 'initial commit'`
|
49
49
|
end
|
50
50
|
end
|
51
51
|
end
|
@@ -23,18 +23,21 @@ module Starter
|
|
23
23
|
file.sub!(mount_point, '')
|
24
24
|
end
|
25
25
|
|
26
|
+
# parses out the prefix from base api file
|
26
27
|
def base_prefix
|
27
28
|
base_file
|
28
29
|
|
29
30
|
base_file.scan(/prefix\s+(:.+)\n/).first.first.delete!(':')
|
30
31
|
end
|
31
32
|
|
33
|
+
# parses out the version from base api file
|
32
34
|
def base_version
|
33
35
|
base_file
|
34
36
|
|
35
37
|
base_file.scan(/version\s+(.+),/).first.first.delete!("'")
|
36
38
|
end
|
37
39
|
|
40
|
+
# get api base file as string
|
38
41
|
def base_file
|
39
42
|
file = File.join(Dir.getwd, 'api', 'base.rb')
|
40
43
|
FileFoo.read_file(file)
|
data/lib/starter/builder.rb
CHANGED
@@ -124,9 +124,9 @@ module Starter
|
|
124
124
|
#
|
125
125
|
# saves new resource files
|
126
126
|
def save_file(new_file)
|
127
|
-
new_file_name = "#{new_file}_name"
|
128
|
-
should_raise?(
|
129
|
-
FileFoo.write_file(
|
127
|
+
new_file_name = send("#{new_file}_name")
|
128
|
+
should_raise?(new_file_name)
|
129
|
+
FileFoo.write_file(new_file_name, send(new_file.strip_heredoc))
|
130
130
|
end
|
131
131
|
|
132
132
|
#
|
@@ -51,32 +51,28 @@ end
|
|
51
51
|
# plural forms
|
52
52
|
#
|
53
53
|
RSpec.shared_examples 'GET specific' do |key: nil|
|
54
|
-
let(:
|
55
|
-
let(:specific_route) { "#{route}/#{key}" }
|
54
|
+
let(:specific_route) { "#{route_from_description}/#{key}" }
|
56
55
|
|
57
56
|
subject { get specific_route }
|
58
57
|
specify { expect(subject.status).to eql 200 }
|
59
58
|
end
|
60
59
|
|
61
60
|
RSpec.shared_examples 'PUT specific' do |key: nil, params: {}|
|
62
|
-
let(:
|
63
|
-
let(:specific_route) { "#{route}/#{key}" }
|
61
|
+
let(:specific_route) { "#{route_from_description}/#{key}" }
|
64
62
|
|
65
63
|
subject { put specific_route, params }
|
66
64
|
specify { expect(subject.status).to eql 200 }
|
67
65
|
end
|
68
66
|
|
69
67
|
RSpec.shared_examples 'PATCH specific' do |key: nil, params: {}|
|
70
|
-
let(:
|
71
|
-
let(:specific_route) { "#{route}/#{key}" }
|
68
|
+
let(:specific_route) { "#{route_from_description}/#{key}" }
|
72
69
|
|
73
70
|
subject { patch specific_route, params }
|
74
71
|
specify { expect(subject.status).to eql 200 }
|
75
72
|
end
|
76
73
|
|
77
74
|
RSpec.shared_examples 'DELETE specific' do |key: nil|
|
78
|
-
let(:
|
79
|
-
let(:specific_route) { "#{route}/#{key}" }
|
75
|
+
let(:specific_route) { "#{route_from_description}/#{key}" }
|
80
76
|
|
81
77
|
subject { delete specific_route }
|
82
78
|
specify { expect(subject.status).to eql 204 }
|
data/lib/starter/version.rb
CHANGED
@@ -4,24 +4,9 @@ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'api'))
|
|
4
4
|
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
5
5
|
|
6
6
|
require 'boot'
|
7
|
-
|
8
|
-
Bundler.require :default, ENV['RACK_ENV']
|
9
|
-
|
10
|
-
Dir[File.expand_path('../../lib/**/*.rb', __FILE__)].each do |lib|
|
11
|
-
require lib
|
12
|
-
end
|
13
|
-
|
14
|
-
Dir[File.expand_path('../../api/entities/*.rb', __FILE__)].each do |entity|
|
15
|
-
require entity
|
16
|
-
end
|
17
|
-
|
18
|
-
Dir[File.expand_path('../../api/endpoints/*.rb', __FILE__)].each do |endpoint|
|
19
|
-
require endpoint
|
20
|
-
end
|
21
|
-
|
22
7
|
require 'base'
|
23
|
-
|
24
8
|
require 'rack'
|
9
|
+
|
25
10
|
# provides the documentation of the API
|
26
11
|
class DocApp
|
27
12
|
attr_reader :env
|
data/template/config/boot.rb
CHANGED
@@ -1,3 +1,17 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
require 'rubygems'
|
3
3
|
require 'bundler/setup'
|
4
|
+
|
5
|
+
Bundler.require :default, ENV['RACK_ENV']
|
6
|
+
|
7
|
+
Dir[File.expand_path('../../lib/**/*.rb', __FILE__)].each do |lib|
|
8
|
+
require lib
|
9
|
+
end
|
10
|
+
|
11
|
+
Dir[File.expand_path('../../api/entities/*.rb', __FILE__)].each do |entity|
|
12
|
+
require entity
|
13
|
+
end
|
14
|
+
|
15
|
+
Dir[File.expand_path('../../api/endpoints/*.rb', __FILE__)].each do |endpoint|
|
16
|
+
require endpoint
|
17
|
+
end
|
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.5.
|
4
|
+
version: 0.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- LeFnord
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-01-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gli
|