grape-starter 1.2.1 → 1.2.6
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/ruby.yml +21 -0
- data/.gitignore +1 -3
- data/.inch.yml +1 -0
- data/.rubocop.yml +84 -9
- data/.travis.yml +7 -7
- data/CHANGELOG.md +17 -69
- data/Gemfile +2 -2
- data/bin/grape-starter +0 -1
- data/grape-starter.gemspec +5 -5
- data/lib/starter/builder.rb +19 -7
- data/lib/starter/builder/names.rb +2 -0
- data/lib/starter/builder/orms.rb +6 -4
- data/lib/starter/builder/templates/activerecord.rb +4 -2
- data/lib/starter/builder/templates/endpoints.rb +13 -5
- data/lib/starter/builder/templates/files.rb +10 -0
- data/lib/starter/builder/templates/sequel.rb +1 -1
- data/lib/starter/rake/grape_tasks.rb +4 -6
- data/lib/starter/version.rb +1 -1
- data/template/.rubocop.yml +86 -4
- data/template/Gemfile +1 -1
- data/template/api/endpoints/root.rb +4 -3
- data/template/config.ru +1 -1
- data/template/config/boot.rb +4 -4
- data/template/spec/lib/models/.keep +0 -0
- data/template/spec/spec_helper.rb +1 -2
- metadata +18 -17
- data/template/.rubocop_todo.yml +0 -18
- data/template/spec/lib/models/version_spec.rb +0 -9
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b0319aad1d8c7ee2391228d9406510f7154c20bc1499ad236747f3296bdd60e1
|
|
4
|
+
data.tar.gz: d7c5675719b83d4b00c1c6a79c18be5548cfa9c03e02d20d0951547d384a9add
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a9fd4c6a7b26fa0cbe7243d389446a2f7076e5fdc2ea2363d20283c10998bf8963544a86f7fa57cb1d77f169d2cda8a22e70d9726f3f685b30e07388f58a789c
|
|
7
|
+
data.tar.gz: eac255d57b207a70a02782f3ddcb3d4adddee53c794b9886a2cea4d00688910e25700af1fc5c456f7b382c201ebbff5585fe429498f305b00a0bca728a9b4c8a
|
|
@@ -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,21 @@
|
|
|
1
|
+
name: Ruby
|
|
2
|
+
|
|
3
|
+
on: [push]
|
|
4
|
+
|
|
5
|
+
jobs:
|
|
6
|
+
build:
|
|
7
|
+
|
|
8
|
+
runs-on: ubuntu-latest
|
|
9
|
+
|
|
10
|
+
steps:
|
|
11
|
+
- uses: actions/checkout@v1
|
|
12
|
+
- name: Set up Ruby 2.7
|
|
13
|
+
uses: actions/setup-ruby@v1
|
|
14
|
+
with:
|
|
15
|
+
ruby-version: 2.7.1
|
|
16
|
+
- name: Build and test with Rake
|
|
17
|
+
run: |
|
|
18
|
+
gem install bundler
|
|
19
|
+
bundle install --jobs 4 --retry 3
|
|
20
|
+
bundle exec rspec
|
|
21
|
+
bundle exec rubocop
|
data/.gitignore
CHANGED
data/.inch.yml
CHANGED
data/.rubocop.yml
CHANGED
|
@@ -5,24 +5,24 @@ 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
|
-
TargetRubyVersion: 2.
|
|
12
|
+
TargetRubyVersion: 2.7
|
|
13
13
|
|
|
14
14
|
Layout/IndentationWidth:
|
|
15
15
|
Exclude:
|
|
16
16
|
- 'lib/starter/builder/templates/files.rb'
|
|
17
17
|
- 'lib/starter/builder/templates/endpoints.rb'
|
|
18
18
|
|
|
19
|
+
Layout/LineLength:
|
|
20
|
+
Max: 120
|
|
21
|
+
|
|
19
22
|
Metrics/BlockLength:
|
|
20
23
|
Exclude:
|
|
21
24
|
- 'spec/**/*'
|
|
22
25
|
|
|
23
|
-
Metrics/LineLength:
|
|
24
|
-
Max: 120
|
|
25
|
-
|
|
26
26
|
Metrics/AbcSize:
|
|
27
27
|
Max: 20
|
|
28
28
|
|
|
@@ -38,7 +38,82 @@ Style/AsciiComments:
|
|
|
38
38
|
Enabled: false
|
|
39
39
|
|
|
40
40
|
Style/Documentation:
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
41
|
+
Enabled: false
|
|
42
|
+
|
|
43
|
+
# introduced in 0.88
|
|
44
|
+
Layout/EmptyLinesAroundAttributeAccessor:
|
|
45
|
+
Enabled: true
|
|
46
|
+
Layout/SpaceAroundMethodCallOperator:
|
|
47
|
+
Enabled: true
|
|
48
|
+
Lint/DeprecatedOpenSSLConstant:
|
|
49
|
+
Enabled: true
|
|
50
|
+
Lint/MixedRegexpCaptureTypes:
|
|
51
|
+
Enabled: true
|
|
52
|
+
Lint/RaiseException:
|
|
53
|
+
Enabled: true
|
|
54
|
+
Lint/StructNewOverride:
|
|
55
|
+
Enabled: true
|
|
56
|
+
Style/ExponentialNotation:
|
|
57
|
+
Enabled: true
|
|
58
|
+
Style/HashEachMethods:
|
|
59
|
+
Enabled: true
|
|
60
|
+
Style/HashTransformKeys:
|
|
61
|
+
Enabled: true
|
|
62
|
+
Style/HashTransformValues:
|
|
63
|
+
Enabled: true
|
|
64
|
+
Style/RedundantFetchBlock:
|
|
65
|
+
Enabled: true
|
|
66
|
+
Style/RedundantRegexpCharacterClass:
|
|
67
|
+
Enabled: true
|
|
68
|
+
Style/RedundantRegexpEscape:
|
|
69
|
+
Enabled: true
|
|
70
|
+
Style/SlicingWithRange:
|
|
71
|
+
Enabled: true
|
|
72
|
+
|
|
73
|
+
# introduced in 0.89
|
|
74
|
+
Lint/BinaryOperatorWithIdenticalOperands:
|
|
75
|
+
Enabled: true
|
|
76
|
+
Lint/DuplicateElsifCondition:
|
|
77
|
+
Enabled: true
|
|
78
|
+
Lint/DuplicateRescueException:
|
|
79
|
+
Enabled: true
|
|
80
|
+
Lint/EmptyConditionalBody:
|
|
81
|
+
Enabled: true
|
|
82
|
+
Lint/FloatComparison:
|
|
83
|
+
Enabled: true
|
|
84
|
+
Lint/MissingSuper:
|
|
85
|
+
Enabled: true
|
|
86
|
+
Lint/OutOfRangeRegexpRef:
|
|
87
|
+
Enabled: true
|
|
88
|
+
Lint/SelfAssignment:
|
|
89
|
+
Enabled: true
|
|
90
|
+
Lint/TopLevelReturnWithArgument:
|
|
91
|
+
Enabled: true
|
|
92
|
+
Lint/UnreachableLoop:
|
|
93
|
+
Enabled: true
|
|
94
|
+
Style/AccessorGrouping:
|
|
95
|
+
Enabled: false
|
|
96
|
+
Style/ArrayCoercion:
|
|
97
|
+
Enabled: true
|
|
98
|
+
Style/BisectedAttrAccessor:
|
|
99
|
+
Enabled: true
|
|
100
|
+
Style/CaseLikeIf:
|
|
101
|
+
Enabled: true
|
|
102
|
+
Style/ExplicitBlockArgument:
|
|
103
|
+
Enabled: true
|
|
104
|
+
Style/GlobalStdStream:
|
|
105
|
+
Enabled: true
|
|
106
|
+
Style/HashAsLastArrayItem:
|
|
107
|
+
Enabled: true
|
|
108
|
+
Style/HashLikeCase:
|
|
109
|
+
Enabled: true
|
|
110
|
+
Style/OptionalBooleanParameter:
|
|
111
|
+
Enabled: true
|
|
112
|
+
Style/RedundantAssignment:
|
|
113
|
+
Enabled: true
|
|
114
|
+
Style/RedundantFileExtensionInRequire:
|
|
115
|
+
Enabled: true
|
|
116
|
+
Style/SingleArgumentDig:
|
|
117
|
+
Enabled: true
|
|
118
|
+
Style/StringConcatenation:
|
|
119
|
+
Enabled: true
|
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,13 +7,13 @@ before_install:
|
|
|
7
7
|
|
|
8
8
|
rvm:
|
|
9
9
|
- ruby-head
|
|
10
|
-
- 2.
|
|
11
|
-
- 2.5
|
|
12
|
-
- 2.
|
|
10
|
+
- 2.7.0
|
|
11
|
+
- 2.6.5
|
|
12
|
+
- 2.5.7
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
jobs:
|
|
15
15
|
fast_finish: true
|
|
16
16
|
|
|
17
17
|
allow_failures:
|
|
18
|
-
- rvm:
|
|
19
|
-
|
|
18
|
+
- rvm:
|
|
19
|
+
- ruby-head
|
data/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,23 @@
|
|
|
1
1
|
### NEXT
|
|
2
2
|
|
|
3
|
-
-
|
|
3
|
+
- Fixes gems for sequel. [LeFnord](https://github.com/LeFnord)
|
|
4
|
+
- Minor template improvements. [LeFnord](https://github.com/LeFnord)
|
|
4
5
|
|
|
5
|
-
###
|
|
6
|
+
### v1.2.3 / 2019-12-15
|
|
6
7
|
|
|
7
|
-
- [!
|
|
8
|
+
- Removes require pry. [LeFnord](LeFnord) closes [!21](https://github.com/LeFnord/grape-starter/issues/21)
|
|
9
|
+
- [#22](https://github.com/LeFnord/grape-starter/pull/22) - accomodate activerecord 6.0 (#22) [Ignacio Carrera](https://github.com/nachokb)
|
|
8
10
|
|
|
9
|
-
###
|
|
11
|
+
### v1.2.2 / 2019-02-28
|
|
12
|
+
|
|
13
|
+
- Fixes loading of `aplication` instead of `environment` in `config.ru`
|
|
14
|
+
- [#19](https://github.com/LeFnord/grape-starter/pull/19) - Adds a module under lib as namespace. [LeFnord](https://github.com/LeFnord)
|
|
15
|
+
|
|
16
|
+
### v1.2.1 / 2019-02-24
|
|
17
|
+
|
|
18
|
+
- [#17](https://github.com/LeFnord/grape-starter/pull/17) - Fix script/server shebang for ubuntu. [rawongithub](https://github.com/rawongithub)
|
|
19
|
+
|
|
20
|
+
### v1.2.0 / 2019-02-24
|
|
10
21
|
|
|
11
22
|
- Code improvements, now `environment`, `application` and `boot` are used in a more expected way.
|
|
12
23
|
|
|
@@ -18,69 +29,6 @@
|
|
|
18
29
|
- prepare release 1.0.2
|
|
19
30
|
- Cleans up travis ci.
|
|
20
31
|
|
|
21
|
-
###
|
|
22
|
-
- [00993](https://github.com/LeFnord/grape-starter/commit/6fef3812fd587ea61c29b9eacde1fb856ad00993) - adds a rudimentary Dockerfile as starting point
|
|
23
|
-
|
|
24
|
-
### 1.0.0
|
|
25
|
-
|
|
26
|
-
- [67a5f](https://github.com/LeFnord/grape-starter/commit/b1f32801844ed9a98bc4d5f7c938451ef7667a5f) - supports creating a migration file
|
|
27
|
-
- [de26b](https://github.com/LeFnord/grape-starter/commit/22ad2170176b9602cff2239a7d0469c823cde26b) - ci adoptions
|
|
28
|
-
- [7ad69](https://github.com/LeFnord/grape-starter/commit/925fa5fb161c8cc26c96834e185d8299a207ad69) - spec improvements
|
|
29
|
-
|
|
30
|
-
### 0.8.7
|
|
31
|
-
|
|
32
|
-
- [c7cb2](https://github.com/LeFnord/grape-starter/commit/4be5bd9b7c06611e096d6eaa23d7168136bc7cb2) - updates dependencies; makes rubocop happy
|
|
33
|
-
- [d9c6f](https://github.com/LeFnord/grape-starter/commit/2f97247767c3e76c4c33da50eec2ad160bed9c6f) - minor dependencies updates
|
|
34
|
-
|
|
35
|
-
### 0.8.6
|
|
36
|
-
|
|
37
|
-
- [362c9](https://github.com/LeFnord/grape-starter/commit/56035384befacb877e89e8a04f7bc62c9e7362c9) - fixes a sequel configuration bug with sqlite3
|
|
38
|
-
- [21892](https://github.com/LeFnord/grape-starter/commit/4e249978af71abba35e00b0d4e85ec6ffaa21892) - upgrades minimum ruby version to 2.3
|
|
39
|
-
|
|
40
|
-
### 0.8.5
|
|
41
|
-
|
|
42
|
-
- [cbea8](https://github.com/LeFnord/grape-starter/commit/fa5edb5dc7e0883ff099e297e9cbd5bd5ebcbea8) - DRYs up template code; passes rubocop 0.51.0
|
|
43
|
-
|
|
44
|
-
- [6bbe7](https://github.com/LeFnord/grape-starter/commit/a224b5d8dfa001cb1e8dec3b1a1e28fc9826bbe7) - avoids overriding of dev db by running specs; fixes syntox error
|
|
45
|
-
|
|
46
|
-
### 0.8.4
|
|
47
|
-
|
|
48
|
-
- [d8e13](https://github.com/LeFnord/grape-starter/commit/1f5faef958799704163b7db25db07c569cad8e13) -
|
|
49
|
-
fixes error on configuration
|
|
50
|
-
|
|
51
|
-
- [6baba](https://github.com/LeFnord/grape-starter/commit/e00433dee97509e71c1685a0da9134ce2a66baba) -
|
|
52
|
-
minor re-working of Rakefile and initializer templates
|
|
53
|
-
|
|
54
|
-
### 0.8.3
|
|
55
|
-
|
|
56
|
-
- [3fe13](https://github.com/LeFnord/grape-starter/commit/3fe134c6ce0666dfd86165b5d2c1a219a4629862) - improves sequel rake tasks
|
|
57
|
-
|
|
58
|
-
### 0.8.2
|
|
59
|
-
|
|
60
|
-
- [48458…](https://github.com/LeFnord/grape-starter/commit/48458938a341660453052660448a058aee0f8e81) - handles Sequel deprecation warning
|
|
61
|
-
|
|
62
|
-
### 0.8.1
|
|
63
|
-
|
|
64
|
-
- [6b16c…](https://github.com/LeFnord/grape-starter/commit/6b16c0bf38e4cad8d486e805269157dcbaefbb64) - removes default ORM value, minor corrections
|
|
65
|
-
|
|
66
|
-
### 0.8.0
|
|
67
|
-
|
|
68
|
-
- [#15](https://github.com/LeFnord/grape-starter/pull/15), [2af09…](https://github.com/LeFnord/grape-starter/commit/2af09dddf97f756e96c80c745ee68aad5ab4ccc3) **breaking change** prefix option on create is optional, no default
|
|
69
|
-
- [#12](https://github.com/LeFnord/grape-starter/pull/12) - Add base configuration for ActiveRecord - ([@terry90](https://github.com/terry90))
|
|
70
|
-
|
|
71
|
-
### 0.7.0
|
|
72
|
-
|
|
73
|
-
- [212e6…](https://github.com/LeFnord/grape-starter/commit/212e6245e10598efe286143dac39f46134c58c54) - makes mounting of doc more secure
|
|
74
|
-
- [f3bb6…](https://github.com/LeFnord/grape-starter/commit/f3bb63fdee79df4552316524b1ac3adaebab811a) - adds orm option so that the `add` resource command can optional use configured ORM
|
|
75
|
-
- [af138…](https://github.com/LeFnord/grape-starter/commit/af1388ae6479b81646c56ac55f856ea275dc9817) - resource respects configured orm
|
|
76
|
-
- [5ac74…](https://github.com/LeFnord/grape-starter/commit/5ac747a7fb44d97eedbeba1e7a11e475846d7743) - improve README
|
|
77
|
-
- [eb33c…](https://github.com/LeFnord/grape-starter/commit/eb33c910c623b34db54ccb64ee59af4c639029e4) - adds base storing of configuration
|
|
78
|
-
- [751aa…](https://github.com/LeFnord/grape-starter/commit/751aa8ae929bed0ff66ac9830468279238bec252) - adding option to add Sequel support
|
|
79
|
-
- [354e6…](https://github.com/LeFnord/grape-starter/commit/354e63abd77751fe0f3a1b405bb49ab754ab1522) - re-organizing of template files
|
|
80
|
-
- [6e33e…](https://github.com/LeFnord/grape-starter/commit/6e33e8137aa293eef66913c50010c53d284a0d8d) - Add awesome_print dependency ([@terry90](https://github.com/terry90))
|
|
81
|
-
|
|
82
|
-
### 0.6.0
|
|
32
|
+
### before
|
|
83
33
|
|
|
84
|
-
|
|
85
|
-
- `lib/api.rb` -> `lib/models.rb`
|
|
86
|
-
- `lib/api/` -> `lib/models/`
|
|
34
|
+
many things done …
|
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.
|
|
8
|
+
gem 'grape', '~> 1.4'
|
|
9
9
|
gem 'pry', platforms: [:mri]
|
|
10
10
|
gem 'pry-byebug', platforms: [:mri]
|
|
11
11
|
gem 'rack-cors', require: false
|
|
12
12
|
gem 'rack-test', require: false
|
|
13
|
-
gem 'rake', '~>
|
|
13
|
+
gem 'rake', '~> 13.0'
|
|
14
14
|
gem 'rspec', '~> 3.8'
|
|
15
15
|
gem 'rspec-command'
|
|
16
16
|
end
|
data/bin/grape-starter
CHANGED
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.5'
|
|
26
26
|
|
|
27
|
-
spec.add_dependency 'gli', '~> 2.
|
|
28
|
-
spec.add_dependency 'activesupport', '~>
|
|
29
|
-
spec.add_dependency 'rubocop', '~> 0.
|
|
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', '~> 0.89'
|
|
30
|
+
spec.add_dependency 'awesome_print', '~> 1.8'
|
|
31
31
|
end
|
data/lib/starter/builder.rb
CHANGED
|
@@ -18,13 +18,15 @@ 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
|
#
|
|
24
25
|
#
|
|
25
26
|
# would be called from new command
|
|
26
27
|
#
|
|
27
|
-
# name - A String as project name
|
|
28
|
+
# name - A String as project name,
|
|
29
|
+
# it will also be the namespace in the lib folder
|
|
28
30
|
# source - A String which provides the template path
|
|
29
31
|
# destination - A String which provides the new project path
|
|
30
32
|
# options - A Hash to provide some optional arguments (default: {})
|
|
@@ -41,13 +43,15 @@ module Starter
|
|
|
41
43
|
replace_static(File.join(config[:file]), config[:pattern])
|
|
42
44
|
end
|
|
43
45
|
|
|
46
|
+
add_namespace_with_version
|
|
47
|
+
|
|
48
|
+
Orms.build(name, destination, options[:orm]) if options[:orm]
|
|
49
|
+
|
|
44
50
|
Starter::Config.save(
|
|
45
51
|
dest: destination,
|
|
46
52
|
content: { prefix: prefix, orm: options[:orm].to_s }
|
|
47
53
|
)
|
|
48
54
|
|
|
49
|
-
Orms.build(destination, options[:orm]) if options[:orm]
|
|
50
|
-
|
|
51
55
|
self
|
|
52
56
|
end
|
|
53
57
|
|
|
@@ -55,6 +59,7 @@ module Starter
|
|
|
55
59
|
#
|
|
56
60
|
# resource - A String as name
|
|
57
61
|
# options - A Hash to provide some optional arguments (default: {})
|
|
62
|
+
# :resource - the name of the resource to create
|
|
58
63
|
# :set – Whitespace separated list of http verbs
|
|
59
64
|
# (default: nil, possible: post get put patch delete)
|
|
60
65
|
# :force - A Boolean, if given existent files should be overwriten (default: false)
|
|
@@ -82,8 +87,8 @@ module Starter
|
|
|
82
87
|
|
|
83
88
|
file_list.map { |x| send("#{x}_name") }.each do |file_to_remove|
|
|
84
89
|
FileUtils.rm file_to_remove
|
|
85
|
-
rescue StandardError =>
|
|
86
|
-
$stdout.puts
|
|
90
|
+
rescue StandardError => e
|
|
91
|
+
$stdout.puts e.to_s
|
|
87
92
|
end
|
|
88
93
|
|
|
89
94
|
remove_mount_point
|
|
@@ -113,12 +118,19 @@ module Starter
|
|
|
113
118
|
]
|
|
114
119
|
end
|
|
115
120
|
|
|
121
|
+
#
|
|
122
|
+
# creates a new file in lib folder as namespace, includind the version
|
|
123
|
+
def add_namespace_with_version
|
|
124
|
+
new_lib = File.join(destination, 'lib', base_file_name)
|
|
125
|
+
FileFoo.write_file(new_lib, base_namespace_file.strip_heredoc)
|
|
126
|
+
end
|
|
127
|
+
|
|
116
128
|
#
|
|
117
129
|
# replace something in static files
|
|
118
130
|
def replace_static(file, replacement)
|
|
119
|
-
|
|
131
|
+
file_path = File.join(destination, file)
|
|
120
132
|
|
|
121
|
-
FileFoo.call!(
|
|
133
|
+
FileFoo.call!(file_path) { |content| content.gsub!('{{{grape-starter}}}', replacement.to_s) }
|
|
122
134
|
end
|
|
123
135
|
|
|
124
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
|
|
|
@@ -9,6 +9,8 @@ module Starter
|
|
|
9
9
|
|
|
10
10
|
def initializer
|
|
11
11
|
<<-FILE.strip_heredoc
|
|
12
|
+
# frozen_string_literal: true
|
|
13
|
+
|
|
12
14
|
require 'yaml'
|
|
13
15
|
require 'erb'
|
|
14
16
|
require 'active_record'
|
|
@@ -71,14 +73,14 @@ module Starter
|
|
|
71
73
|
gem 'standalone_migrations'
|
|
72
74
|
|
|
73
75
|
# DB stuff
|
|
74
|
-
gem 'activerecord', '
|
|
76
|
+
gem 'activerecord', '>= 6'
|
|
75
77
|
gem 'pg'
|
|
76
78
|
FILE
|
|
77
79
|
end
|
|
78
80
|
|
|
79
81
|
def migration(klass_name, resource)
|
|
80
82
|
<<-FILE.strip_heredoc
|
|
81
|
-
class Create#{klass_name} < ActiveRecord::Migration[
|
|
83
|
+
class Create#{klass_name} < ActiveRecord::Migration[6.0]
|
|
82
84
|
def change
|
|
83
85
|
create_table :#{resource} do |t|
|
|
84
86
|
|
|
@@ -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,8 +43,10 @@ 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"
|
|
@@ -51,7 +55,9 @@ module Starter
|
|
|
51
55
|
%w[get put patch delete].each do |verb|
|
|
52
56
|
define_method(:"#{verb}_one") do
|
|
53
57
|
"
|
|
54
|
-
desc '#{verb} #{resource.singularize}'
|
|
58
|
+
desc '#{verb} #{resource.singularize}' do
|
|
59
|
+
tags %w[#{resource.singularize}]
|
|
60
|
+
end
|
|
55
61
|
#{verb} do
|
|
56
62
|
# your code goes here
|
|
57
63
|
end"
|
|
@@ -61,7 +67,9 @@ module Starter
|
|
|
61
67
|
%w[get put patch delete].each do |verb|
|
|
62
68
|
define_method(:"#{verb}_specific") do
|
|
63
69
|
"
|
|
64
|
-
desc '#{verb} specific #{resource.singularize}'
|
|
70
|
+
desc '#{verb} specific #{resource.singularize}' do
|
|
71
|
+
tags %w[#{resource.singularize}]
|
|
72
|
+
end
|
|
65
73
|
params do
|
|
66
74
|
requires :id
|
|
67
75
|
end
|
|
@@ -36,6 +36,16 @@ module Starter
|
|
|
36
36
|
end
|
|
37
37
|
|
|
38
38
|
# LIB template for resource
|
|
39
|
+
def base_namespace_file
|
|
40
|
+
<<-FILE.strip_heredoc
|
|
41
|
+
# frozen_string_literal: true
|
|
42
|
+
|
|
43
|
+
module #{klass_name}
|
|
44
|
+
VERSION = '0.1.0'
|
|
45
|
+
end
|
|
46
|
+
FILE
|
|
47
|
+
end
|
|
48
|
+
|
|
39
49
|
def lib_file
|
|
40
50
|
<<-FILE.strip_heredoc
|
|
41
51
|
# frozen_string_literal: true
|
|
@@ -52,16 +52,14 @@ module Starter
|
|
|
52
52
|
def build_path(route)
|
|
53
53
|
path = route.path
|
|
54
54
|
|
|
55
|
-
path.sub
|
|
56
|
-
path.sub
|
|
55
|
+
path = path.sub(/\(\.\w+?\)$/, '')
|
|
56
|
+
path = path.sub('(.:format)', '')
|
|
57
57
|
|
|
58
58
|
if route.version
|
|
59
|
-
path.sub
|
|
59
|
+
path.sub(':version', route.version.to_s)
|
|
60
60
|
else
|
|
61
|
-
path.sub
|
|
61
|
+
path.sub('/:version', '')
|
|
62
62
|
end
|
|
63
|
-
|
|
64
|
-
path
|
|
65
63
|
end
|
|
66
64
|
|
|
67
65
|
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,100 @@ AllCops:
|
|
|
7
5
|
- Rakefile
|
|
8
6
|
- Gemfile
|
|
9
7
|
UseCache: true
|
|
10
|
-
TargetRubyVersion: 2.
|
|
8
|
+
TargetRubyVersion: 2.7
|
|
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
|
|
27
|
+
|
|
28
|
+
# introduced in 0.88
|
|
29
|
+
Layout/EmptyLinesAroundAttributeAccessor:
|
|
30
|
+
Enabled: true
|
|
31
|
+
Layout/SpaceAroundMethodCallOperator:
|
|
32
|
+
Enabled: true
|
|
33
|
+
Lint/DeprecatedOpenSSLConstant:
|
|
34
|
+
Enabled: true
|
|
35
|
+
Lint/MixedRegexpCaptureTypes:
|
|
36
|
+
Enabled: true
|
|
37
|
+
Lint/RaiseException:
|
|
38
|
+
Enabled: true
|
|
39
|
+
Lint/StructNewOverride:
|
|
40
|
+
Enabled: true
|
|
41
|
+
Style/ExponentialNotation:
|
|
42
|
+
Enabled: true
|
|
43
|
+
Style/HashEachMethods:
|
|
44
|
+
Enabled: true
|
|
45
|
+
Style/HashTransformKeys:
|
|
46
|
+
Enabled: true
|
|
47
|
+
Style/HashTransformValues:
|
|
48
|
+
Enabled: true
|
|
49
|
+
Style/RedundantFetchBlock:
|
|
50
|
+
Enabled: true
|
|
51
|
+
Style/RedundantRegexpCharacterClass:
|
|
52
|
+
Enabled: true
|
|
53
|
+
Style/RedundantRegexpEscape:
|
|
54
|
+
Enabled: true
|
|
55
|
+
Style/SlicingWithRange:
|
|
56
|
+
Enabled: true
|
|
57
|
+
|
|
58
|
+
# introduced in 0.89
|
|
59
|
+
Lint/BinaryOperatorWithIdenticalOperands:
|
|
60
|
+
Enabled: true
|
|
61
|
+
Lint/DuplicateElsifCondition:
|
|
62
|
+
Enabled: true
|
|
63
|
+
Lint/DuplicateRescueException:
|
|
64
|
+
Enabled: true
|
|
65
|
+
Lint/EmptyConditionalBody:
|
|
66
|
+
Enabled: true
|
|
67
|
+
Lint/FloatComparison:
|
|
68
|
+
Enabled: true
|
|
69
|
+
Lint/MissingSuper:
|
|
70
|
+
Enabled: true
|
|
71
|
+
Lint/OutOfRangeRegexpRef:
|
|
72
|
+
Enabled: true
|
|
73
|
+
Lint/SelfAssignment:
|
|
74
|
+
Enabled: true
|
|
75
|
+
Lint/TopLevelReturnWithArgument:
|
|
76
|
+
Enabled: true
|
|
77
|
+
Lint/UnreachableLoop:
|
|
78
|
+
Enabled: true
|
|
79
|
+
Style/AccessorGrouping:
|
|
80
|
+
Enabled: false
|
|
81
|
+
Style/ArrayCoercion:
|
|
82
|
+
Enabled: true
|
|
83
|
+
Style/BisectedAttrAccessor:
|
|
84
|
+
Enabled: true
|
|
85
|
+
Style/CaseLikeIf:
|
|
86
|
+
Enabled: true
|
|
87
|
+
Style/ExplicitBlockArgument:
|
|
88
|
+
Enabled: true
|
|
89
|
+
Style/GlobalStdStream:
|
|
90
|
+
Enabled: true
|
|
91
|
+
Style/HashAsLastArrayItem:
|
|
92
|
+
Enabled: true
|
|
93
|
+
Style/HashLikeCase:
|
|
94
|
+
Enabled: true
|
|
95
|
+
Style/OptionalBooleanParameter:
|
|
96
|
+
Enabled: true
|
|
97
|
+
Style/RedundantAssignment:
|
|
98
|
+
Enabled: true
|
|
99
|
+
Style/RedundantFileExtensionInRequire:
|
|
100
|
+
Enabled: true
|
|
101
|
+
Style/SingleArgumentDig:
|
|
102
|
+
Enabled: true
|
|
103
|
+
Style/StringConcatenation:
|
|
104
|
+
Enabled: true
|
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.ru
CHANGED
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
|
|
File without changes
|
|
@@ -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.2.
|
|
4
|
+
version: 1.2.6
|
|
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: 2020-08-12 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: gli
|
|
@@ -16,56 +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
31
|
- - "~>"
|
|
32
32
|
- !ruby/object:Gem::Version
|
|
33
|
-
version: '
|
|
33
|
+
version: '6.0'
|
|
34
34
|
type: :runtime
|
|
35
35
|
prerelease: false
|
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
|
37
37
|
requirements:
|
|
38
38
|
- - "~>"
|
|
39
39
|
- !ruby/object:Gem::Version
|
|
40
|
-
version: '
|
|
40
|
+
version: '6.0'
|
|
41
41
|
- !ruby/object:Gem::Dependency
|
|
42
42
|
name: rubocop
|
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
|
44
44
|
requirements:
|
|
45
45
|
- - "~>"
|
|
46
46
|
- !ruby/object:Gem::Version
|
|
47
|
-
version: '0.
|
|
47
|
+
version: '0.89'
|
|
48
48
|
type: :runtime
|
|
49
49
|
prerelease: false
|
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
|
51
51
|
requirements:
|
|
52
52
|
- - "~>"
|
|
53
53
|
- !ruby/object:Gem::Version
|
|
54
|
-
version: '0.
|
|
54
|
+
version: '0.89'
|
|
55
55
|
- !ruby/object:Gem::Dependency
|
|
56
56
|
name: awesome_print
|
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
|
58
58
|
requirements:
|
|
59
59
|
- - "~>"
|
|
60
60
|
- !ruby/object:Gem::Version
|
|
61
|
-
version: '1.
|
|
61
|
+
version: '1.8'
|
|
62
62
|
type: :runtime
|
|
63
63
|
prerelease: false
|
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
|
65
65
|
requirements:
|
|
66
66
|
- - "~>"
|
|
67
67
|
- !ruby/object:Gem::Version
|
|
68
|
-
version: '1.
|
|
68
|
+
version: '1.8'
|
|
69
69
|
description: CLI to create a API skeleton based on Grape and Rack
|
|
70
70
|
email:
|
|
71
71
|
- pscholz.le@gmail.com
|
|
@@ -74,6 +74,8 @@ executables:
|
|
|
74
74
|
extensions: []
|
|
75
75
|
extra_rdoc_files: []
|
|
76
76
|
files:
|
|
77
|
+
- ".github/dependabot.yml"
|
|
78
|
+
- ".github/workflows/ruby.yml"
|
|
77
79
|
- ".gitignore"
|
|
78
80
|
- ".inch.yml"
|
|
79
81
|
- ".rspec"
|
|
@@ -104,7 +106,6 @@ files:
|
|
|
104
106
|
- lib/starter/version.rb
|
|
105
107
|
- template/.gitignore
|
|
106
108
|
- template/.rubocop.yml
|
|
107
|
-
- template/.rubocop_todo.yml
|
|
108
109
|
- template/Dockerfile
|
|
109
110
|
- template/Gemfile
|
|
110
111
|
- template/LICENSE
|
|
@@ -128,7 +129,7 @@ files:
|
|
|
128
129
|
- template/script/stop
|
|
129
130
|
- template/script/test
|
|
130
131
|
- template/script/update
|
|
131
|
-
- template/spec/lib/models
|
|
132
|
+
- template/spec/lib/models/.keep
|
|
132
133
|
- template/spec/requests/documentation_spec.rb
|
|
133
134
|
- template/spec/requests/root_spec.rb
|
|
134
135
|
- template/spec/spec_helper.rb
|
|
@@ -136,7 +137,7 @@ homepage: https://github.com/LeFnord/grape-starter
|
|
|
136
137
|
licenses:
|
|
137
138
|
- MIT
|
|
138
139
|
metadata: {}
|
|
139
|
-
post_install_message:
|
|
140
|
+
post_install_message:
|
|
140
141
|
rdoc_options: []
|
|
141
142
|
require_paths:
|
|
142
143
|
- lib
|
|
@@ -144,15 +145,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
144
145
|
requirements:
|
|
145
146
|
- - ">="
|
|
146
147
|
- !ruby/object:Gem::Version
|
|
147
|
-
version: '2.
|
|
148
|
+
version: '2.5'
|
|
148
149
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
149
150
|
requirements:
|
|
150
151
|
- - ">="
|
|
151
152
|
- !ruby/object:Gem::Version
|
|
152
153
|
version: '0'
|
|
153
154
|
requirements: []
|
|
154
|
-
rubygems_version: 3.
|
|
155
|
-
signing_key:
|
|
155
|
+
rubygems_version: 3.1.4
|
|
156
|
+
signing_key:
|
|
156
157
|
specification_version: 4
|
|
157
158
|
summary: Creates a Grape Rack skeleton
|
|
158
159
|
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/**/*'
|