grape-starter 1.2.3 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +14 -0
- data/.github/workflows/rubocop.yml +20 -0
- data/.github/workflows/ruby.yml +26 -0
- data/.gitignore +1 -0
- data/.rubocop.yml +8 -9
- data/.travis.yml +12 -8
- data/CHANGELOG.md +32 -1
- data/Gemfile +5 -5
- data/README.md +2 -3
- data/grape-starter.gemspec +5 -5
- data/lib/starter/builder.rb +6 -3
- data/lib/starter/builder/names.rb +2 -0
- data/lib/starter/builder/orms.rb +7 -5
- data/lib/starter/builder/templates/activerecord.rb +21 -9
- data/lib/starter/builder/templates/endpoints.rb +15 -5
- data/lib/starter/builder/templates/sequel.rb +1 -1
- data/lib/starter/rake/grape_tasks.rb +5 -8
- data/lib/starter/version.rb +1 -1
- data/template/.rubocop.yml +8 -4
- data/template/Gemfile +1 -1
- data/template/api/endpoints/root.rb +4 -3
- data/template/config/boot.rb +4 -4
- data/template/spec/spec_helper.rb +1 -2
- metadata +20 -24
- data/template/.rubocop_todo.yml +0 -18
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 65275de01798dbfd5b58469ffa92d549d78ad71423fd68e59be09e00d4d90348
|
|
4
|
+
data.tar.gz: 4ceeba3b548341b2f570951e58aa84e86345a64a916ae75f9b5c6a6681bff3d1
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2ce822016665ae28ff18fe3faa533195ad4018f66ff0728d85ebbcebecb870f09bcb4fdf0989447bf90134ef74f8f38a3c6b866e64d45883b1abd2f767b4a2a6
|
|
7
|
+
data.tar.gz: fa49ce2bc02ceb2a915ea8af26d73869b8ff4a918a50f29252bee3bf1914098c80d29d7379380b4d21844210123c8b681b1ff0587596dc1ab4bdacde6d6f1966
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# To get started with Dependabot version updates, you'll need to specify which
|
|
2
|
+
# package ecosystems to update and where the package manifests are located.
|
|
3
|
+
# Please see the documentation for all configuration options:
|
|
4
|
+
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
|
|
5
|
+
|
|
6
|
+
version: 2
|
|
7
|
+
updates:
|
|
8
|
+
- package-ecosystem: "bundler" # See documentation for possible values
|
|
9
|
+
directory: "/" # Location of package manifests
|
|
10
|
+
schedule:
|
|
11
|
+
interval: "weekly"
|
|
12
|
+
day: "friday"
|
|
13
|
+
assignees:
|
|
14
|
+
- "LeFnord"
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
name: Rubocop
|
|
2
|
+
|
|
3
|
+
on: push
|
|
4
|
+
|
|
5
|
+
jobs:
|
|
6
|
+
rubocop:
|
|
7
|
+
name: Rubocop
|
|
8
|
+
runs-on: ubuntu-latest
|
|
9
|
+
steps:
|
|
10
|
+
- uses: actions/checkout@v2
|
|
11
|
+
- uses: actions/setup-ruby@v1
|
|
12
|
+
with:
|
|
13
|
+
ruby-version: '3.0'
|
|
14
|
+
- run: gem install rubocop --no-doc
|
|
15
|
+
- run: rubocop --format progress --format json --out rubocop.json
|
|
16
|
+
id: rubocop
|
|
17
|
+
- uses: duderman/rubocop-annotate-action@v0.1.0
|
|
18
|
+
with:
|
|
19
|
+
path: rubocop.json
|
|
20
|
+
if: ${{ failure() }}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
name: Ruby
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches:
|
|
6
|
+
- '*'
|
|
7
|
+
pull_request:
|
|
8
|
+
branches:
|
|
9
|
+
- '*'
|
|
10
|
+
|
|
11
|
+
jobs:
|
|
12
|
+
spec:
|
|
13
|
+
runs-on: ubuntu-latest
|
|
14
|
+
strategy:
|
|
15
|
+
matrix:
|
|
16
|
+
ruby-version: ['2.6', '2.7', '3.0', head]
|
|
17
|
+
|
|
18
|
+
steps:
|
|
19
|
+
- uses: actions/checkout@v2
|
|
20
|
+
- name: Set up Ruby
|
|
21
|
+
uses: ruby/setup-ruby@v1
|
|
22
|
+
with:
|
|
23
|
+
ruby-version: ${{ matrix.ruby-version }}
|
|
24
|
+
bundler-cache: true
|
|
25
|
+
- name: Run rspec
|
|
26
|
+
run: bundle exec rspec
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
|
@@ -5,24 +5,26 @@ AllCops:
|
|
|
5
5
|
- '**/bin/**/*'
|
|
6
6
|
- '**/tmp/**/*'
|
|
7
7
|
- '**/script/**/*'
|
|
8
|
-
# - '**/template/**/*'
|
|
9
8
|
- '**/template/api/**'
|
|
10
9
|
- grape-starter.gemspec
|
|
10
|
+
- template/spec/spec-helper.rb
|
|
11
11
|
UseCache: true
|
|
12
|
-
|
|
12
|
+
NewCops: enable
|
|
13
|
+
TargetRubyVersion: 3.0
|
|
14
|
+
SuggestExtensions: false
|
|
13
15
|
|
|
14
16
|
Layout/IndentationWidth:
|
|
15
17
|
Exclude:
|
|
16
18
|
- 'lib/starter/builder/templates/files.rb'
|
|
17
19
|
- 'lib/starter/builder/templates/endpoints.rb'
|
|
18
20
|
|
|
21
|
+
Layout/LineLength:
|
|
22
|
+
Max: 120
|
|
23
|
+
|
|
19
24
|
Metrics/BlockLength:
|
|
20
25
|
Exclude:
|
|
21
26
|
- 'spec/**/*'
|
|
22
27
|
|
|
23
|
-
Metrics/LineLength:
|
|
24
|
-
Max: 120
|
|
25
|
-
|
|
26
28
|
Metrics/AbcSize:
|
|
27
29
|
Max: 20
|
|
28
30
|
|
|
@@ -38,7 +40,4 @@ Style/AsciiComments:
|
|
|
38
40
|
Enabled: false
|
|
39
41
|
|
|
40
42
|
Style/Documentation:
|
|
41
|
-
|
|
42
|
-
- 'template/**/*'
|
|
43
|
-
- 'lib/**/*'
|
|
44
|
-
- 'spec/**/*'
|
|
43
|
+
Enabled: false
|
data/.travis.yml
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
language: ruby
|
|
2
|
-
|
|
2
|
+
os: linux
|
|
3
3
|
sudo: false
|
|
4
4
|
|
|
5
5
|
before_install:
|
|
@@ -7,14 +7,18 @@ before_install:
|
|
|
7
7
|
|
|
8
8
|
rvm:
|
|
9
9
|
- ruby-head
|
|
10
|
-
- 2.7.
|
|
11
|
-
- 2.6.
|
|
12
|
-
- 2.5.
|
|
10
|
+
- 2.7.2
|
|
11
|
+
- 2.6.6
|
|
12
|
+
- 2.5.8
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
jobs:
|
|
15
15
|
fast_finish: true
|
|
16
|
+
include:
|
|
17
|
+
- rvm: truffleruby-head
|
|
18
|
+
env:
|
|
19
|
+
script: bundle exec rake spec
|
|
16
20
|
|
|
17
21
|
allow_failures:
|
|
18
|
-
- rvm:
|
|
19
|
-
|
|
20
|
-
|
|
22
|
+
- rvm: 3.0.0-preview1
|
|
23
|
+
- rvm: ruby-head
|
|
24
|
+
- rvm: truffleruby-head
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,36 @@
|
|
|
1
1
|
### NEXT
|
|
2
2
|
|
|
3
|
+
- your contributions
|
|
4
|
+
|
|
5
|
+
### v1.4.0 / 2021-04-08
|
|
6
|
+
|
|
7
|
+
- Removes `standalone_migration` in favour of AR tasks. [LeFnord](https://github.com/LeFnord)
|
|
8
|
+
- Minor README improvements. [LeFnord](https://github.com/LeFnord)
|
|
9
|
+
- Adds GH actions for rspec and rubocop. [LeFnord](https://github.com/LeFnord)
|
|
10
|
+
|
|
11
|
+
### v1.3.0 / 2020-09-15
|
|
12
|
+
|
|
13
|
+
- Fixes migration name. [LeFnord](https://github.com/LeFnord)
|
|
14
|
+
- Fixes rubocop new cops handling. [LeFnord](https://github.com/LeFnord)
|
|
15
|
+
|
|
16
|
+
### v1.2.4–v1.2.6 / 2020-01-18–2020-08-13
|
|
17
|
+
|
|
18
|
+
- Prepapre releaase 1.2.6 [LeFnord](https://github.com/LeFnord)
|
|
19
|
+
- Updates used default rails deps versions. [LeFnord](https://github.com/LeFnord)
|
|
20
|
+
- Create dependabot.yml [peter scholz](https://github.com/LeFnord)
|
|
21
|
+
- Prepare release 1.2.5 [LeFnord](https://github.com/LeFnord)
|
|
22
|
+
- Minor improvements. [LeFnord](https://github.com/LeFnord)
|
|
23
|
+
- Lets run GH actions again. [LeFnord](https://github.com/LeFnord)
|
|
24
|
+
- Minor template improvements. [LeFnord](https://github.com/LeFnord)
|
|
25
|
+
- Changes ruby.yml to use 2.7 [LeFnord](https://github.com/LeFnord)
|
|
26
|
+
- Prepare release 1.2.4 [LeFnord](https://github.com/LeFnord)
|
|
27
|
+
- Respects froozen string stuff. [LeFnord](https://github.com/LeFnord)
|
|
28
|
+
- Updates Ruby and deps. (#23) [LeFnord](https://github.com/LeFnord)
|
|
29
|
+
- Create ruby.yml [LeFnord](https://github.com/LeFnord)
|
|
30
|
+
|
|
31
|
+
- Fixes gems for sequel. [LeFnord](https://github.com/LeFnord)
|
|
32
|
+
- Minor template improvements. [LeFnord](https://github.com/LeFnord)
|
|
33
|
+
|
|
3
34
|
### v1.2.3 / 2019-12-15
|
|
4
35
|
|
|
5
36
|
- Removes require pry. [LeFnord](LeFnord) closes [!21](https://github.com/LeFnord/grape-starter/issues/21)
|
|
@@ -7,7 +38,7 @@
|
|
|
7
38
|
|
|
8
39
|
### v1.2.2 / 2019-02-28
|
|
9
40
|
|
|
10
|
-
- Fixes loading of `
|
|
41
|
+
- Fixes loading of `aplication` instead of `environment` in `config.ru`
|
|
11
42
|
- [#19](https://github.com/LeFnord/grape-starter/pull/19) - Adds a module under lib as namespace. [LeFnord](https://github.com/LeFnord)
|
|
12
43
|
|
|
13
44
|
### v1.2.1 / 2019-02-24
|
data/Gemfile
CHANGED
|
@@ -5,12 +5,12 @@ source 'http://rubygems.org'
|
|
|
5
5
|
gemspec
|
|
6
6
|
|
|
7
7
|
group :development, :test do
|
|
8
|
-
gem 'grape', '~> 1.
|
|
9
|
-
gem 'pry',
|
|
10
|
-
gem 'pry-byebug',
|
|
8
|
+
gem 'grape', '~> 1.5'
|
|
9
|
+
gem 'pry', require: false
|
|
10
|
+
gem 'pry-byebug', require: false
|
|
11
11
|
gem 'rack-cors', require: false
|
|
12
12
|
gem 'rack-test', require: false
|
|
13
|
-
gem 'rake', '~>
|
|
14
|
-
gem 'rspec', '~> 3.
|
|
13
|
+
gem 'rake', '~> 13.0'
|
|
14
|
+
gem 'rspec', '~> 3.10'
|
|
15
15
|
gem 'rspec-command'
|
|
16
16
|
end
|
data/README.md
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+

|
|
2
2
|
[](https://badge.fury.io/rb/grape-starter)
|
|
3
|
-
[](http://inch-ci.org/github/LeFnord/grape-starter)
|
|
4
3
|
|
|
5
4
|
|
|
6
5
|
# Grape Starter
|
|
@@ -83,7 +82,7 @@ To run it, go into awesome_api folder, start the server
|
|
|
83
82
|
$ cd awesome_api
|
|
84
83
|
$ ./script/server *port
|
|
85
84
|
```
|
|
86
|
-
the API is now accessible under: [http://localhost:9292/api/v1/root](http://localhost:9292/api/v1/root)
|
|
85
|
+
the API is now accessible under: [http://localhost:9292/api/v1/root](http://localhost:9292/api/v1/root)
|
|
87
86
|
the documentation of it under: [http://localhost:9292/doc](http://localhost:9292/doc).
|
|
88
87
|
|
|
89
88
|
More could be found in [README](template/README.md).
|
data/grape-starter.gemspec
CHANGED
|
@@ -22,10 +22,10 @@ Gem::Specification.new do |spec|
|
|
|
22
22
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
|
23
23
|
spec.require_paths = ['lib']
|
|
24
24
|
|
|
25
|
-
spec.required_ruby_version = '>= 2.
|
|
25
|
+
spec.required_ruby_version = '>= 2.6'
|
|
26
26
|
|
|
27
|
-
spec.add_dependency 'gli', '~> 2.
|
|
28
|
-
spec.add_dependency 'activesupport', '
|
|
29
|
-
spec.add_dependency 'rubocop', '~>
|
|
30
|
-
spec.add_dependency 'awesome_print', '~> 1.
|
|
27
|
+
spec.add_dependency 'gli', '~> 2.19'
|
|
28
|
+
spec.add_dependency 'activesupport', '~> 6.0'
|
|
29
|
+
spec.add_dependency 'rubocop', '~> 1.12'
|
|
30
|
+
spec.add_dependency 'awesome_print', '~> 1.8'
|
|
31
31
|
end
|
data/lib/starter/builder.rb
CHANGED
|
@@ -18,6 +18,7 @@ module Starter
|
|
|
18
18
|
|
|
19
19
|
class << self
|
|
20
20
|
attr_reader :prefix, :resource, :set, :force, :entity, :destination, :orm
|
|
21
|
+
|
|
21
22
|
#
|
|
22
23
|
# public methods
|
|
23
24
|
#
|
|
@@ -41,8 +42,10 @@ module Starter
|
|
|
41
42
|
config_static.each do |config|
|
|
42
43
|
replace_static(File.join(config[:file]), config[:pattern])
|
|
43
44
|
end
|
|
45
|
+
|
|
44
46
|
add_namespace_with_version
|
|
45
|
-
|
|
47
|
+
|
|
48
|
+
Orms.build(name, destination, options[:orm]) if options[:orm]
|
|
46
49
|
|
|
47
50
|
Starter::Config.save(
|
|
48
51
|
dest: destination,
|
|
@@ -125,9 +128,9 @@ module Starter
|
|
|
125
128
|
#
|
|
126
129
|
# replace something in static files
|
|
127
130
|
def replace_static(file, replacement)
|
|
128
|
-
|
|
131
|
+
file_path = File.join(destination, file)
|
|
129
132
|
|
|
130
|
-
FileFoo.call!(
|
|
133
|
+
FileFoo.call!(file_path) { |content| content.gsub!('{{{grape-starter}}}', replacement.to_s) }
|
|
131
134
|
end
|
|
132
135
|
|
|
133
136
|
# #add! a new resource releated helper methods
|
|
@@ -24,9 +24,11 @@ module Starter
|
|
|
24
24
|
end
|
|
25
25
|
end
|
|
26
26
|
|
|
27
|
+
# rubocop:disable Style/StringConcatenation
|
|
27
28
|
def base_file_name
|
|
28
29
|
@resource.tr('/', '-').downcase + '.rb'
|
|
29
30
|
end
|
|
31
|
+
# rubocop:enable Style/StringConcatenation
|
|
30
32
|
|
|
31
33
|
def base_spec_name
|
|
32
34
|
base_file_name.gsub(/.rb$/, '_spec.rb')
|
data/lib/starter/builder/orms.rb
CHANGED
|
@@ -3,10 +3,12 @@
|
|
|
3
3
|
module Starter
|
|
4
4
|
class Orms
|
|
5
5
|
class << self
|
|
6
|
-
def build(dest, orm)
|
|
6
|
+
def build(name, dest, orm)
|
|
7
7
|
load_orm(orm: orm)
|
|
8
8
|
return if @orm.nil?
|
|
9
9
|
|
|
10
|
+
@name = name
|
|
11
|
+
|
|
10
12
|
if @orm == 'ar' || @orm == 'activerecord'
|
|
11
13
|
# Fixes pooling
|
|
12
14
|
add_middleware(dest, 'ActiveRecord::Rack::ConnectionManagement')
|
|
@@ -35,21 +37,21 @@ module Starter
|
|
|
35
37
|
encoding: unicode
|
|
36
38
|
timeout: 5000
|
|
37
39
|
user: postgres
|
|
38
|
-
database:
|
|
40
|
+
database: #{@name}_development
|
|
39
41
|
|
|
40
42
|
test:
|
|
41
43
|
adapter: #{adapter}
|
|
42
44
|
encoding: unicode
|
|
43
45
|
timeout: 5000
|
|
44
46
|
user: postgres
|
|
45
|
-
database:
|
|
47
|
+
database: #{@name}_test
|
|
46
48
|
|
|
47
49
|
production:
|
|
48
50
|
adapter: #{adapter}
|
|
49
51
|
encoding: unicode
|
|
50
52
|
timeout: 5000
|
|
51
53
|
user: postgres
|
|
52
|
-
database:
|
|
54
|
+
database: #{@name}_production
|
|
53
55
|
FILE
|
|
54
56
|
end
|
|
55
57
|
|
|
@@ -57,7 +59,7 @@ module Starter
|
|
|
57
59
|
load_orm
|
|
58
60
|
return if @orm.nil?
|
|
59
61
|
|
|
60
|
-
file_name = "#{Time.now.strftime('%Y%m%d%H%m%S')}
|
|
62
|
+
file_name = "#{Time.now.strftime('%Y%m%d%H%m%S')}_create_#{klass_name.downcase}.rb"
|
|
61
63
|
migration_dest = File.join(Dir.pwd, 'db', 'migrate', file_name)
|
|
62
64
|
FileFoo.write_file(migration_dest, migration(klass_name, resource))
|
|
63
65
|
end
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require 'active_record'
|
|
4
|
+
|
|
3
5
|
module Starter
|
|
4
6
|
module Templates
|
|
5
7
|
module ActiveRecord
|
|
@@ -9,6 +11,8 @@ module Starter
|
|
|
9
11
|
|
|
10
12
|
def initializer
|
|
11
13
|
<<-FILE.strip_heredoc
|
|
14
|
+
# frozen_string_literal: true
|
|
15
|
+
|
|
12
16
|
require 'yaml'
|
|
13
17
|
require 'erb'
|
|
14
18
|
require 'active_record'
|
|
@@ -25,7 +29,7 @@ module Starter
|
|
|
25
29
|
FileUtils.mkdir(log_dir) unless Dir.exist?(log_dir)
|
|
26
30
|
Logger.new(File.open(log_file, 'a'))
|
|
27
31
|
else
|
|
28
|
-
Logger.new(
|
|
32
|
+
Logger.new($stdout)
|
|
29
33
|
end
|
|
30
34
|
|
|
31
35
|
ActiveRecord::Base.logger = logger
|
|
@@ -58,27 +62,35 @@ module Starter
|
|
|
58
62
|
|
|
59
63
|
def rakefile
|
|
60
64
|
<<-FILE.strip_heredoc
|
|
61
|
-
|
|
62
65
|
# ActiveRecord migration tasks
|
|
63
|
-
require '
|
|
64
|
-
|
|
66
|
+
require 'active_record'
|
|
67
|
+
include ActiveRecord::Tasks
|
|
68
|
+
config_dir = File.expand_path('../config', __FILE__)
|
|
69
|
+
config_content = File.join(config_dir, 'database.yml')
|
|
70
|
+
DatabaseTasks.env = ENV['RACK_ENV'] || 'development'
|
|
71
|
+
DatabaseTasks.database_configuration = YAML.load_file(config_content)
|
|
72
|
+
DatabaseTasks.db_dir = 'db'
|
|
73
|
+
DatabaseTasks.migrations_paths = File.join('db', 'migrate')
|
|
74
|
+
|
|
75
|
+
ActiveRecord::Base.configurations = DatabaseTasks.database_configuration
|
|
76
|
+
ActiveRecord::Base.establish_connection DatabaseTasks.env.to_sym
|
|
77
|
+
|
|
78
|
+
load 'active_record/railties/databases.rake'
|
|
65
79
|
FILE
|
|
66
80
|
end
|
|
67
81
|
|
|
68
82
|
def gemfile
|
|
69
83
|
<<-FILE.strip_heredoc
|
|
70
|
-
# BE stuff
|
|
71
|
-
gem 'standalone_migrations'
|
|
72
|
-
|
|
73
84
|
# DB stuff
|
|
74
|
-
gem 'activerecord', '
|
|
85
|
+
gem 'activerecord', '>= 6'
|
|
75
86
|
gem 'pg'
|
|
76
87
|
FILE
|
|
77
88
|
end
|
|
78
89
|
|
|
79
90
|
def migration(klass_name, resource)
|
|
91
|
+
version = "#{::ActiveRecord::VERSION::MAJOR}.#{::ActiveRecord::VERSION::MINOR}"
|
|
80
92
|
<<-FILE.strip_heredoc
|
|
81
|
-
class Create#{klass_name} < ActiveRecord::Migration[
|
|
93
|
+
class Create#{klass_name} < ActiveRecord::Migration[#{version}]
|
|
82
94
|
def change
|
|
83
95
|
create_table :#{resource} do |t|
|
|
84
96
|
|
|
@@ -29,7 +29,9 @@ module Starter
|
|
|
29
29
|
# POST
|
|
30
30
|
def post
|
|
31
31
|
"
|
|
32
|
-
desc 'create #{resource.singularize}'
|
|
32
|
+
desc 'create #{resource.singularize}' do
|
|
33
|
+
tags %w[#{resource.singularize}]
|
|
34
|
+
end
|
|
33
35
|
params do
|
|
34
36
|
# TODO: specify the parameters
|
|
35
37
|
end
|
|
@@ -41,17 +43,22 @@ module Starter
|
|
|
41
43
|
# GET
|
|
42
44
|
def get_all
|
|
43
45
|
"
|
|
44
|
-
desc 'get all of #{resource.pluralize}'
|
|
45
|
-
|
|
46
|
+
desc 'get all of #{resource.pluralize}' do
|
|
47
|
+
is_array true
|
|
48
|
+
tags %w[#{resource.singularize}]
|
|
49
|
+
end
|
|
46
50
|
get do
|
|
47
51
|
# your code goes here
|
|
48
52
|
end"
|
|
49
53
|
end
|
|
50
54
|
|
|
55
|
+
# rubocop:disable Style/CombinableLoops
|
|
51
56
|
%w[get put patch delete].each do |verb|
|
|
52
57
|
define_method(:"#{verb}_one") do
|
|
53
58
|
"
|
|
54
|
-
desc '#{verb} #{resource.singularize}'
|
|
59
|
+
desc '#{verb} #{resource.singularize}' do
|
|
60
|
+
tags %w[#{resource.singularize}]
|
|
61
|
+
end
|
|
55
62
|
#{verb} do
|
|
56
63
|
# your code goes here
|
|
57
64
|
end"
|
|
@@ -61,7 +68,9 @@ module Starter
|
|
|
61
68
|
%w[get put patch delete].each do |verb|
|
|
62
69
|
define_method(:"#{verb}_specific") do
|
|
63
70
|
"
|
|
64
|
-
desc '#{verb} specific #{resource.singularize}'
|
|
71
|
+
desc '#{verb} specific #{resource.singularize}' do
|
|
72
|
+
tags %w[#{resource.singularize}]
|
|
73
|
+
end
|
|
65
74
|
params do
|
|
66
75
|
requires :id
|
|
67
76
|
end
|
|
@@ -70,6 +79,7 @@ module Starter
|
|
|
70
79
|
end"
|
|
71
80
|
end
|
|
72
81
|
end
|
|
82
|
+
# rubocop:enable Style/CombinableLoops
|
|
73
83
|
|
|
74
84
|
# request specs shared examples
|
|
75
85
|
#
|
|
@@ -11,8 +11,7 @@ module Starter
|
|
|
11
11
|
class GrapeTasks < ::Rake::TaskLib
|
|
12
12
|
include Rack::Test::Methods
|
|
13
13
|
|
|
14
|
-
attr_reader :resource
|
|
15
|
-
attr_reader :api_class
|
|
14
|
+
attr_reader :resource, :api_class
|
|
16
15
|
|
|
17
16
|
def initialize(api_class = nil)
|
|
18
17
|
super()
|
|
@@ -52,16 +51,14 @@ module Starter
|
|
|
52
51
|
def build_path(route)
|
|
53
52
|
path = route.path
|
|
54
53
|
|
|
55
|
-
path.sub
|
|
56
|
-
path.sub
|
|
54
|
+
path = path.sub(/\(\.\w+?\)$/, '')
|
|
55
|
+
path = path.sub('(.:format)', '')
|
|
57
56
|
|
|
58
57
|
if route.version
|
|
59
|
-
path.sub
|
|
58
|
+
path.sub(':version', route.version.to_s)
|
|
60
59
|
else
|
|
61
|
-
path.sub
|
|
60
|
+
path.sub('/:version', '')
|
|
62
61
|
end
|
|
63
|
-
|
|
64
|
-
path
|
|
65
62
|
end
|
|
66
63
|
|
|
67
64
|
def app
|
data/lib/starter/version.rb
CHANGED
data/template/.rubocop.yml
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
inherit_from: .rubocop_todo.yml
|
|
2
|
-
|
|
3
1
|
AllCops:
|
|
4
2
|
Exclude:
|
|
5
3
|
- '**/tmp/**/*'
|
|
@@ -7,16 +5,22 @@ AllCops:
|
|
|
7
5
|
- Rakefile
|
|
8
6
|
- Gemfile
|
|
9
7
|
UseCache: true
|
|
10
|
-
|
|
8
|
+
NewCops: enable
|
|
11
9
|
|
|
12
|
-
|
|
10
|
+
Layout/LineLength:
|
|
13
11
|
Max: 120
|
|
14
12
|
|
|
15
13
|
Metrics/AbcSize:
|
|
16
14
|
Max: 20
|
|
17
15
|
|
|
16
|
+
Metrics/BlockLength:
|
|
17
|
+
Exclude:
|
|
18
|
+
- 'api/endpoints/**/*'
|
|
18
19
|
Metrics/MethodLength:
|
|
19
20
|
Max: 20
|
|
20
21
|
|
|
21
22
|
Style/AsciiComments:
|
|
22
23
|
Enabled: false
|
|
24
|
+
|
|
25
|
+
Style/Documentation:
|
|
26
|
+
Enabled: false
|
data/template/Gemfile
CHANGED
|
@@ -6,9 +6,10 @@ module Api
|
|
|
6
6
|
module Endpoints
|
|
7
7
|
class Root < Grape::API
|
|
8
8
|
namespace :root do
|
|
9
|
-
desc 'Exposes all routes'
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
desc 'Exposes all routes' do
|
|
10
|
+
success Entities::Route
|
|
11
|
+
is_array true
|
|
12
|
+
end
|
|
12
13
|
get do
|
|
13
14
|
api_routes = Starter::Rake::GrapeTasks.new(::Api::Base).api_routes
|
|
14
15
|
|
data/template/config/boot.rb
CHANGED
|
@@ -9,18 +9,18 @@ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
|
|
9
9
|
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'api'))
|
|
10
10
|
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
|
11
11
|
|
|
12
|
-
Dir[File.expand_path('../config/initializers/*.rb', __dir__)].each do |initializer|
|
|
12
|
+
Dir[File.expand_path('../config/initializers/*.rb', __dir__)].sort.each do |initializer|
|
|
13
13
|
require initializer
|
|
14
14
|
end
|
|
15
15
|
|
|
16
|
-
Dir[File.expand_path('../lib/**/*.rb', __dir__)].each do |lib|
|
|
16
|
+
Dir[File.expand_path('../lib/**/*.rb', __dir__)].sort.each do |lib|
|
|
17
17
|
require lib
|
|
18
18
|
end
|
|
19
19
|
|
|
20
|
-
Dir[File.expand_path('../api/entities/*.rb', __dir__)].each do |entity|
|
|
20
|
+
Dir[File.expand_path('../api/entities/*.rb', __dir__)].sort.each do |entity|
|
|
21
21
|
require entity
|
|
22
22
|
end
|
|
23
23
|
|
|
24
|
-
Dir[File.expand_path('../api/endpoints/*.rb', __dir__)].each do |endpoint|
|
|
24
|
+
Dir[File.expand_path('../api/endpoints/*.rb', __dir__)].sort.each do |endpoint|
|
|
25
25
|
require endpoint
|
|
26
26
|
end
|
|
@@ -6,8 +6,7 @@ require 'rack/test'
|
|
|
6
6
|
require File.expand_path('../config/application', __dir__)
|
|
7
7
|
|
|
8
8
|
grape_starter_gem = Gem::Specification.find_by_name('grape-starter').gem_dir
|
|
9
|
-
|
|
10
|
-
Dir[grape_starter_gem + '/lib/starter/rspec/**/*.rb'].each { |f| require f }
|
|
9
|
+
Dir["#{grape_starter_gem}/lib/starter/rspec/**/*.rb"].sort.each { |f| require f }
|
|
11
10
|
|
|
12
11
|
RSpec.configure do |config|
|
|
13
12
|
include Rack::Test::Methods
|
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: 1.
|
|
4
|
+
version: 1.4.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- LeFnord
|
|
8
|
-
autorequire:
|
|
8
|
+
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2021-04-08 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: gli
|
|
@@ -16,62 +16,56 @@ dependencies:
|
|
|
16
16
|
requirements:
|
|
17
17
|
- - "~>"
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
|
-
version: '2.
|
|
19
|
+
version: '2.19'
|
|
20
20
|
type: :runtime
|
|
21
21
|
prerelease: false
|
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
23
|
requirements:
|
|
24
24
|
- - "~>"
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
|
-
version: '2.
|
|
26
|
+
version: '2.19'
|
|
27
27
|
- !ruby/object:Gem::Dependency
|
|
28
28
|
name: activesupport
|
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
|
30
30
|
requirements:
|
|
31
|
-
- - "
|
|
32
|
-
- !ruby/object:Gem::Version
|
|
33
|
-
version: 5.0.0
|
|
34
|
-
- - "<"
|
|
31
|
+
- - "~>"
|
|
35
32
|
- !ruby/object:Gem::Version
|
|
36
|
-
version: '
|
|
33
|
+
version: '6.0'
|
|
37
34
|
type: :runtime
|
|
38
35
|
prerelease: false
|
|
39
36
|
version_requirements: !ruby/object:Gem::Requirement
|
|
40
37
|
requirements:
|
|
41
|
-
- - "
|
|
42
|
-
- !ruby/object:Gem::Version
|
|
43
|
-
version: 5.0.0
|
|
44
|
-
- - "<"
|
|
38
|
+
- - "~>"
|
|
45
39
|
- !ruby/object:Gem::Version
|
|
46
|
-
version: '
|
|
40
|
+
version: '6.0'
|
|
47
41
|
- !ruby/object:Gem::Dependency
|
|
48
42
|
name: rubocop
|
|
49
43
|
requirement: !ruby/object:Gem::Requirement
|
|
50
44
|
requirements:
|
|
51
45
|
- - "~>"
|
|
52
46
|
- !ruby/object:Gem::Version
|
|
53
|
-
version: '
|
|
47
|
+
version: '1.12'
|
|
54
48
|
type: :runtime
|
|
55
49
|
prerelease: false
|
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
|
57
51
|
requirements:
|
|
58
52
|
- - "~>"
|
|
59
53
|
- !ruby/object:Gem::Version
|
|
60
|
-
version: '
|
|
54
|
+
version: '1.12'
|
|
61
55
|
- !ruby/object:Gem::Dependency
|
|
62
56
|
name: awesome_print
|
|
63
57
|
requirement: !ruby/object:Gem::Requirement
|
|
64
58
|
requirements:
|
|
65
59
|
- - "~>"
|
|
66
60
|
- !ruby/object:Gem::Version
|
|
67
|
-
version: '1.
|
|
61
|
+
version: '1.8'
|
|
68
62
|
type: :runtime
|
|
69
63
|
prerelease: false
|
|
70
64
|
version_requirements: !ruby/object:Gem::Requirement
|
|
71
65
|
requirements:
|
|
72
66
|
- - "~>"
|
|
73
67
|
- !ruby/object:Gem::Version
|
|
74
|
-
version: '1.
|
|
68
|
+
version: '1.8'
|
|
75
69
|
description: CLI to create a API skeleton based on Grape and Rack
|
|
76
70
|
email:
|
|
77
71
|
- pscholz.le@gmail.com
|
|
@@ -80,6 +74,9 @@ executables:
|
|
|
80
74
|
extensions: []
|
|
81
75
|
extra_rdoc_files: []
|
|
82
76
|
files:
|
|
77
|
+
- ".github/dependabot.yml"
|
|
78
|
+
- ".github/workflows/rubocop.yml"
|
|
79
|
+
- ".github/workflows/ruby.yml"
|
|
83
80
|
- ".gitignore"
|
|
84
81
|
- ".inch.yml"
|
|
85
82
|
- ".rspec"
|
|
@@ -110,7 +107,6 @@ files:
|
|
|
110
107
|
- lib/starter/version.rb
|
|
111
108
|
- template/.gitignore
|
|
112
109
|
- template/.rubocop.yml
|
|
113
|
-
- template/.rubocop_todo.yml
|
|
114
110
|
- template/Dockerfile
|
|
115
111
|
- template/Gemfile
|
|
116
112
|
- template/LICENSE
|
|
@@ -142,7 +138,7 @@ homepage: https://github.com/LeFnord/grape-starter
|
|
|
142
138
|
licenses:
|
|
143
139
|
- MIT
|
|
144
140
|
metadata: {}
|
|
145
|
-
post_install_message:
|
|
141
|
+
post_install_message:
|
|
146
142
|
rdoc_options: []
|
|
147
143
|
require_paths:
|
|
148
144
|
- lib
|
|
@@ -150,15 +146,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
150
146
|
requirements:
|
|
151
147
|
- - ">="
|
|
152
148
|
- !ruby/object:Gem::Version
|
|
153
|
-
version: '2.
|
|
149
|
+
version: '2.6'
|
|
154
150
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
155
151
|
requirements:
|
|
156
152
|
- - ">="
|
|
157
153
|
- !ruby/object:Gem::Version
|
|
158
154
|
version: '0'
|
|
159
155
|
requirements: []
|
|
160
|
-
rubygems_version: 3.
|
|
161
|
-
signing_key:
|
|
156
|
+
rubygems_version: 3.2.15
|
|
157
|
+
signing_key:
|
|
162
158
|
specification_version: 4
|
|
163
159
|
summary: Creates a Grape Rack skeleton
|
|
164
160
|
test_files: []
|
data/template/.rubocop_todo.yml
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
# This configuration was generated by
|
|
2
|
-
# `rubocop --auto-gen-config`
|
|
3
|
-
# on 2016-10-18 20:40:59 +0200 using RuboCop version 0.44.1.
|
|
4
|
-
# The point is for the user to remove these configuration records
|
|
5
|
-
# one by one as the offenses are removed from the code base.
|
|
6
|
-
# Note that changes in the inspected code, or installation of new
|
|
7
|
-
# versions of RuboCop, may require this file to be generated again.
|
|
8
|
-
|
|
9
|
-
# Offense count: 1
|
|
10
|
-
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes.
|
|
11
|
-
# URISchemes: http, https
|
|
12
|
-
|
|
13
|
-
# Offense count: 6
|
|
14
|
-
Style/Documentation:
|
|
15
|
-
Exclude:
|
|
16
|
-
- 'spec/**/*'
|
|
17
|
-
- 'api/**/*'
|
|
18
|
-
- 'lib/**/*'
|