grapethor 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +8 -0
- data/.travis.yml +22 -0
- data/CHANGELOG.md +13 -0
- data/CODE_OF_CONDUCT.md +76 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +53 -0
- data/LICENSE +19 -0
- data/README.md +165 -0
- data/Rakefile +9 -0
- data/_config.yml +1 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/exe/grapethor +5 -0
- data/grapethor.gemspec +47 -0
- data/lib/grapethor.rb +10 -0
- data/lib/grapethor/generators/api.rb +78 -0
- data/lib/grapethor/generators/cli.rb +35 -0
- data/lib/grapethor/generators/endpoint.rb +168 -0
- data/lib/grapethor/generators/new.rb +161 -0
- data/lib/grapethor/generators/resource.rb +89 -0
- data/lib/grapethor/templates/api/api/%api_version%/base.rb.tt +19 -0
- data/lib/grapethor/templates/api_minitest/test/support/api_%api_version%_test_case.rb.tt +12 -0
- data/lib/grapethor/templates/api_rspec/.gitkeep +0 -0
- data/lib/grapethor/templates/docker/Dockerfile.tt +18 -0
- data/lib/grapethor/templates/docker/docker-compose.yml.tt +43 -0
- data/lib/grapethor/templates/endpoint.rb.erb +14 -0
- data/lib/grapethor/templates/endpoint/api/%api_version%/%end_resource_plural%.rb.tt +14 -0
- data/lib/grapethor/templates/endpoint_minitest.rb.erb +13 -0
- data/lib/grapethor/templates/endpoint_minitest/test/api/%api_version%/%end_resource_plural%_test.rb.tt +14 -0
- data/lib/grapethor/templates/endpoint_rspec.rb.erb +11 -0
- data/lib/grapethor/templates/endpoint_rspec/spec/api/%api_version%/%end_resource_plural%_spec.rb.tt +12 -0
- data/lib/grapethor/templates/license/apache2/LICENSE.tt +13 -0
- data/lib/grapethor/templates/license/cddl1/LICENSE.tt +316 -0
- data/lib/grapethor/templates/license/epl1/LICENSE.tt +200 -0
- data/lib/grapethor/templates/license/freebsd/LICENSE.tt +22 -0
- data/lib/grapethor/templates/license/gpl2/LICENSE.tt +17 -0
- data/lib/grapethor/templates/license/gpl3/LICENSE.tt +16 -0
- data/lib/grapethor/templates/license/mit/LICENSE.tt +19 -0
- data/lib/grapethor/templates/license/mpl2/LICENSE.tt +5 -0
- data/lib/grapethor/templates/license/newbsd/LICENSE.tt +26 -0
- data/lib/grapethor/templates/minitest/lib/tasks/test.rake +14 -0
- data/lib/grapethor/templates/minitest/test/support/reporters.rb +11 -0
- data/lib/grapethor/templates/minitest/test/support/test_case.rb +18 -0
- data/lib/grapethor/templates/minitest/test/test_helper.rb +12 -0
- data/lib/grapethor/templates/mysql/config/database.yml.tt +33 -0
- data/lib/grapethor/templates/new/.gitignore +7 -0
- data/lib/grapethor/templates/new/.grapethor.yml.tt +13 -0
- data/lib/grapethor/templates/new/Gemfile.tt +44 -0
- data/lib/grapethor/templates/new/README.md.tt +138 -0
- data/lib/grapethor/templates/new/Rakefile.tt +30 -0
- data/lib/grapethor/templates/new/api/base.rb.tt +19 -0
- data/lib/grapethor/templates/new/app/exceptions/not_found_error.rb +1 -0
- data/lib/grapethor/templates/new/bin/console +13 -0
- data/lib/grapethor/templates/new/bin/server.tt +14 -0
- data/lib/grapethor/templates/new/bin/setup.tt +8 -0
- data/lib/grapethor/templates/new/config.ru.tt +19 -0
- data/lib/grapethor/templates/new/config/application.rb.tt +18 -0
- data/lib/grapethor/templates/new/config/boot.rb +2 -0
- data/lib/grapethor/templates/new/config/environment.rb +3 -0
- data/lib/grapethor/templates/new/db/seeds.rb +7 -0
- data/lib/grapethor/templates/new/lib/tasks/routes.rake +8 -0
- data/lib/grapethor/templates/postgresql/config/database.yml.tt +38 -0
- data/lib/grapethor/templates/resource/api/%api_version%/%res_name_plural%.rb.tt +95 -0
- data/lib/grapethor/templates/resource/api/entities/%res_name%.rb.tt +10 -0
- data/lib/grapethor/templates/resource/app/models/%res_name%.rb.tt +6 -0
- data/lib/grapethor/templates/resource/db/migrations/%res_migration%.rb.tt +10 -0
- data/lib/grapethor/templates/resource_minitest/test/api/%api_version%/%res_name_plural%_test.rb.tt +82 -0
- data/lib/grapethor/templates/resource_minitest/test/fixtures/%res_name_plural%.yml.tt +9 -0
- data/lib/grapethor/templates/resource_minitest/test/models/%res_name%_test.rb.tt +17 -0
- data/lib/grapethor/templates/resource_rspec/spec/api/%api_version%/%res_name_plural%_spec.rb.tt +91 -0
- data/lib/grapethor/templates/resource_rspec/spec/factories/%res_name_plural%.rb.tt +7 -0
- data/lib/grapethor/templates/resource_rspec/spec/models/%res_name%_spec.rb.tt +9 -0
- data/lib/grapethor/templates/rspec/.rspec +1 -0
- data/lib/grapethor/templates/rspec/lib/tasks/spec.rake +4 -0
- data/lib/grapethor/templates/rspec/spec/spec_helper.rb +24 -0
- data/lib/grapethor/templates/sqlite/config/database.yml.tt +22 -0
- data/lib/grapethor/templates/swagger/swagger-ui/favicon-16x16.png +0 -0
- data/lib/grapethor/templates/swagger/swagger-ui/favicon-32x32.png +0 -0
- data/lib/grapethor/templates/swagger/swagger-ui/index.html.tt +60 -0
- data/lib/grapethor/templates/swagger/swagger-ui/oauth2-redirect.html +67 -0
- data/lib/grapethor/templates/swagger/swagger-ui/swagger-ui-bundle.js +93 -0
- data/lib/grapethor/templates/swagger/swagger-ui/swagger-ui-bundle.js.map +1 -0
- data/lib/grapethor/templates/swagger/swagger-ui/swagger-ui-standalone-preset.js +14 -0
- data/lib/grapethor/templates/swagger/swagger-ui/swagger-ui-standalone-preset.js.map +1 -0
- data/lib/grapethor/templates/swagger/swagger-ui/swagger-ui.css +3 -0
- data/lib/grapethor/templates/swagger/swagger-ui/swagger-ui.css.map +1 -0
- data/lib/grapethor/templates/swagger/swagger-ui/swagger-ui.js +9 -0
- data/lib/grapethor/templates/swagger/swagger-ui/swagger-ui.js.map +1 -0
- data/lib/grapethor/utils/utils.rb +116 -0
- data/lib/grapethor/version.rb +3 -0
- metadata +235 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 164d641128293c332e80fac404ec38bf342b56ace1aabb0bb3d6c0712cabde5d
|
4
|
+
data.tar.gz: a4515860d094c657a841e9c0c2d567bfd1c638514fecca774b40e851adfd7f86
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 4062d5ce2cb8efab981226c6341d174354b0761be551c88e768144a179deb66c7ca20540972dcc969617b90d3dc9986f21a1fb37eace453a03f1c6bd6f2672dd
|
7
|
+
data.tar.gz: 82533b288cb77cb834ca36f8c3e96bda71f1e7ff611a3be522ca64e8d46d84be08227205cfcadb2c8413870688dc9359b8847d83b89f8df931524369b7f9597f
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
---
|
2
|
+
sudo: false
|
3
|
+
language: ruby
|
4
|
+
cache: bundler
|
5
|
+
rvm:
|
6
|
+
- 2.5.3
|
7
|
+
before_install: gem install bundler -v 2.0.1
|
8
|
+
branches:
|
9
|
+
only:
|
10
|
+
- master
|
11
|
+
env:
|
12
|
+
global:
|
13
|
+
- CC_TEST_REPORTER_ID=233a454b8b30cc0d8d7d522aa80105fd53930f3f085a4d362b1e2c372b8298c0
|
14
|
+
before_script:
|
15
|
+
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
|
16
|
+
- chmod +x ./cc-test-reporter
|
17
|
+
- ./cc-test-reporter before-build
|
18
|
+
scripts:
|
19
|
+
- bundle exec rake test
|
20
|
+
after_script:
|
21
|
+
- ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
|
22
|
+
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# Grapethor Change Log
|
2
|
+
|
3
|
+
All notable changes to this project will be documented in this file.
|
4
|
+
|
5
|
+
The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/).
|
6
|
+
|
7
|
+
|
8
|
+
## [Unreleased]
|
9
|
+
|
10
|
+
|
11
|
+
## [0.1.0] - 2019-04-10
|
12
|
+
###Added
|
13
|
+
+ migrate source code from rawongithub/graperator gem
|
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, sex characteristics, gender identity and expression,
|
9
|
+
level of experience, education, socio-economic status, nationality, personal
|
10
|
+
appearance, race, religion, or sexual identity and orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at rafal.wrzochol@gmail.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
|
72
|
+
|
73
|
+
[homepage]: https://www.contributor-covenant.org
|
74
|
+
|
75
|
+
For answers to common questions about this code of conduct, see
|
76
|
+
https://www.contributor-covenant.org/faq
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
grapethor (0.2.0)
|
5
|
+
activesupport (~> 5.2)
|
6
|
+
thor (~> 0.20)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
activesupport (5.2.3)
|
12
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
13
|
+
i18n (>= 0.7, < 2)
|
14
|
+
minitest (~> 5.1)
|
15
|
+
tzinfo (~> 1.1)
|
16
|
+
ansi (1.5.0)
|
17
|
+
builder (3.2.3)
|
18
|
+
concurrent-ruby (1.1.5)
|
19
|
+
docile (1.3.1)
|
20
|
+
i18n (1.6.0)
|
21
|
+
concurrent-ruby (~> 1.0)
|
22
|
+
json (2.2.0)
|
23
|
+
minitest (5.11.3)
|
24
|
+
minitest-reporters (1.3.6)
|
25
|
+
ansi
|
26
|
+
builder
|
27
|
+
minitest (>= 5.0)
|
28
|
+
ruby-progressbar
|
29
|
+
rake (10.5.0)
|
30
|
+
ruby-progressbar (1.10.0)
|
31
|
+
simplecov (0.16.1)
|
32
|
+
docile (~> 1.1)
|
33
|
+
json (>= 1.8, < 3)
|
34
|
+
simplecov-html (~> 0.10.0)
|
35
|
+
simplecov-html (0.10.2)
|
36
|
+
thor (0.20.3)
|
37
|
+
thread_safe (0.3.6)
|
38
|
+
tzinfo (1.2.5)
|
39
|
+
thread_safe (~> 0.1)
|
40
|
+
|
41
|
+
PLATFORMS
|
42
|
+
ruby
|
43
|
+
|
44
|
+
DEPENDENCIES
|
45
|
+
bundler (~> 2.0)
|
46
|
+
grapethor!
|
47
|
+
minitest (~> 5.11)
|
48
|
+
minitest-reporters (~> 1.3)
|
49
|
+
rake (~> 10.0)
|
50
|
+
simplecov (~> 0.16)
|
51
|
+
|
52
|
+
BUNDLED WITH
|
53
|
+
2.0.1
|
data/LICENSE
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
Copyright (c) 2019 Rafał Wrzochol <rafal.wrzochol@gmail.com>
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the "Software"),
|
5
|
+
to deal in the Software without restriction, including without limitation
|
6
|
+
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
7
|
+
and/or sell copies of the Software, and to permit persons to whom the Software
|
8
|
+
is furnished to do so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included
|
11
|
+
in all copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
14
|
+
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
16
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
17
|
+
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
18
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
|
19
|
+
OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,165 @@
|
|
1
|
+
[![Gem Version](https://badge.fury.io/rb/grapethor.svg)](https://badge.fury.io/rb/grapethor)
|
2
|
+
[![Build Status](https://travis-ci.org/rawongithub/grapethor.svg?branch=master)](https://travis-ci.org/rawongithub/grapethor)
|
3
|
+
[![Maintainability](https://api.codeclimate.com/v1/badges/15145f8728d14b65b42c/maintainability)](https://codeclimate.com/github/rawongithub/grapethor/maintainability)
|
4
|
+
[![Test Coverage](https://api.codeclimate.com/v1/badges/15145f8728d14b65b42c/test_coverage)](https://codeclimate.com/github/rawongithub/grapethor/test_coverage)
|
5
|
+
|
6
|
+
# GrapeThor
|
7
|
+
|
8
|
+
Grape REST-like API generator based on Thor.
|
9
|
+
|
10
|
+
## Installation
|
11
|
+
|
12
|
+
Install it yourself as:
|
13
|
+
```
|
14
|
+
$ gem install grapethor
|
15
|
+
```
|
16
|
+
|
17
|
+
## Usage
|
18
|
+
|
19
|
+
### Get some help
|
20
|
+
|
21
|
+
```
|
22
|
+
$ grapethor help
|
23
|
+
|
24
|
+
Commands:
|
25
|
+
grapethor api VERSION # Creates new API within application
|
26
|
+
grapethor endpoint RESOURCE [NAME] # Creates new Endpoint within API
|
27
|
+
grapethor help [COMMAND] # Describe available commands or one specific command
|
28
|
+
grapethor new NAME # Creates new Grape application
|
29
|
+
grapethor resource NAME # Creates new Resource within API
|
30
|
+
grapethor version # Displays Grapethor version
|
31
|
+
```
|
32
|
+
|
33
|
+
### Create application
|
34
|
+
```
|
35
|
+
$ grapethor help new
|
36
|
+
|
37
|
+
Usage:
|
38
|
+
grapethor new NAME
|
39
|
+
|
40
|
+
Options:
|
41
|
+
-p, [--path=PATH] # Relative path to place application directory
|
42
|
+
# Default: .
|
43
|
+
-x, [--prefix=PREFIX] # Add Application URL prefix
|
44
|
+
# Default: api
|
45
|
+
-d, [--db=DB] # Use specific database
|
46
|
+
# Default: sqlite
|
47
|
+
# Possible values: sqlite, postgresql, mysql
|
48
|
+
-o, [--orm=ORM] # Use specific ORM
|
49
|
+
# Default: activerecord
|
50
|
+
# Possible values: activerecord
|
51
|
+
-s, [--server=SERVER] # Preconfigure web server
|
52
|
+
# Default: thin
|
53
|
+
# Possible values: thin
|
54
|
+
-t, [--test=TEST] # Use specific test framework
|
55
|
+
# Default: minitest
|
56
|
+
# Possible values: minitest, rspec
|
57
|
+
[--docker], [--no-docker] # Use docker
|
58
|
+
# Default: true
|
59
|
+
-l, [--license=LICENSE] # Add software license information
|
60
|
+
# Default: mit
|
61
|
+
# Possible values: mit, apache2, freebsd, newbsd, gpl2, gpl3, mpl2, cddl1, epl1
|
62
|
+
-c, [--copyright=COPYRIGHT] # Add copyright information within license file
|
63
|
+
-r, [--ruby=RUBY] # Ruby version for application
|
64
|
+
# Default: 2.5.3 (current ruby version)
|
65
|
+
[--swagger], [--no-swagger] # Generate swagger documentation and install swagger-ui
|
66
|
+
# Default: true
|
67
|
+
```
|
68
|
+
License types available for `--license` option:
|
69
|
+
|
70
|
+
- `mit` - [MIT License](http://opensource.org/licenses/MIT)
|
71
|
+
- `apache2` - [Apache-2.0 License](https://opensource.org/licenses/Apache-2.0)
|
72
|
+
- `freebsd` - [FreeBSD License](https://opensource.org/licenses/BSD-2-Clause)
|
73
|
+
- `newbsd` - [New BSD License](https://opensource.org/licenses/BSD-3-Clause)
|
74
|
+
- `gpl2` - [GPL-3.0 License](https://opensource.org/licenses/GPL-2.0)
|
75
|
+
- `gpl3` - [GPL-2.0 License](https://opensource.org/licenses/GPL-3.0)
|
76
|
+
- `mpl2` - [MPL-2.0 License](https://opensource.org/licenses/MPL-2.0)
|
77
|
+
- `cddl1` - [CDDL-1.0 License](https://opensource.org/licenses/CDDL-1.0)
|
78
|
+
- `epl1` - [EPL-1.0 License](https://opensource.org/licenses/EPL-1.0)
|
79
|
+
|
80
|
+
### Create API
|
81
|
+
```
|
82
|
+
$ grapethor help api
|
83
|
+
|
84
|
+
Usage:
|
85
|
+
grapethor api VERSION
|
86
|
+
|
87
|
+
Options:
|
88
|
+
-p, [--path=PATH] # Relative path to application directory
|
89
|
+
# Default: .
|
90
|
+
|
91
|
+
Creates new API within application
|
92
|
+
```
|
93
|
+
Do not forget to ```cd``` into application directory before run this command. Otherwise use ```--path``` option.
|
94
|
+
|
95
|
+
Multiple API versions may be created for single application.
|
96
|
+
|
97
|
+
### Create Resource
|
98
|
+
|
99
|
+
```
|
100
|
+
$ grapethor help resource
|
101
|
+
|
102
|
+
Usage:
|
103
|
+
grapethor resource NAME
|
104
|
+
|
105
|
+
Options:
|
106
|
+
-p, [--path=PATH] # Relative path to application directory
|
107
|
+
# Default: .
|
108
|
+
-v, [--version=VERSION] # API version tag
|
109
|
+
# Default: v1
|
110
|
+
-a, [--attrs=ATTRIBUTE:TYPE] # Model attributes (use proper types or specific ORM)
|
111
|
+
|
112
|
+
Creates new Resource within API
|
113
|
+
```
|
114
|
+
Multiple RESOURCES may be created for single API version
|
115
|
+
|
116
|
+
Note: ':id' request path parameter is implicitly used as primary key. There is no need to include it with '-a' option.
|
117
|
+
|
118
|
+
Model attribute types available specific ORM:
|
119
|
+
|
120
|
+
- activerecord: `bigint, binary, boolean, date, datetime, decimal, float, integer, numeric, string, text, time`
|
121
|
+
|
122
|
+
### Create Endpoint
|
123
|
+
```
|
124
|
+
$ grapethor help endpoint
|
125
|
+
|
126
|
+
Usage:
|
127
|
+
grapethor endpoint RESOURCE [NAME]
|
128
|
+
|
129
|
+
Options:
|
130
|
+
-p, [--path=PATH] # Relative path to application directory
|
131
|
+
# Default: .
|
132
|
+
-v, [--version=VERSION] # API version tag
|
133
|
+
# Default: v1
|
134
|
+
-m, [--method=METHOD] # HTTP request method
|
135
|
+
# Default: GET
|
136
|
+
# Possible values: GET, POST, PUT, DELETE
|
137
|
+
-d, [--desc=DESC] # Endpoint description
|
138
|
+
-a, [--params=key:value] # Request resource (path) param
|
139
|
+
-q, [--query=key:value] # Request query params
|
140
|
+
|
141
|
+
Creates new Endpoint within API
|
142
|
+
```
|
143
|
+
Multiple ENDPOINTS may be created for single API version.
|
144
|
+
|
145
|
+
This command may be also used for an addition into existing RESOURCE CRUD.
|
146
|
+
|
147
|
+
|
148
|
+
## How-To
|
149
|
+
|
150
|
+
[Sample Workflow](https://github.com/rawongithub/grapethor/wiki/Sample-workflow)
|
151
|
+
|
152
|
+
## Development
|
153
|
+
|
154
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
155
|
+
|
156
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
157
|
+
|
158
|
+
## Contributing
|
159
|
+
|
160
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/rawongithub/grapethor.
|
161
|
+
|
162
|
+
|
163
|
+
## License
|
164
|
+
|
165
|
+
The software is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/_config.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
theme: jekyll-theme-cayman
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "grapethor"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/exe/grapethor
ADDED
data/grapethor.gemspec
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path("lib", __dir__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "grapethor/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "grapethor"
|
8
|
+
spec.version = Grapethor::VERSION
|
9
|
+
spec.authors = ["Rafal Wrzochol"]
|
10
|
+
spec.email = ["rafal.wrzochol@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Grape API generator}
|
13
|
+
spec.description = %q{Grape REST-like API application generator based on Thor.}
|
14
|
+
spec.homepage = "https://rawongithub.github.io/grapethor/"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
18
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
19
|
+
if spec.respond_to?(:metadata)
|
20
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
21
|
+
spec.metadata["source_code_uri"] = "https://github.com/rawongithub/grapethor"
|
22
|
+
spec.metadata["changelog_uri"] = "https://github.com/rawongithub/grapethor/blob/master/CHANGELOG.md"
|
23
|
+
else
|
24
|
+
raise "RubyGems 2.0 or newer is required to protect against " \
|
25
|
+
"public gem pushes."
|
26
|
+
end
|
27
|
+
|
28
|
+
spec.required_ruby_version = '>= 2.5.3'
|
29
|
+
|
30
|
+
# Specify which files should be added to the gem when it is released.
|
31
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
32
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
33
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
34
|
+
end
|
35
|
+
spec.bindir = "exe"
|
36
|
+
spec.executables = spec.files.grep(%r{^#{spec.bindir}/}) { |f| File.basename(f) }
|
37
|
+
spec.require_paths = ["lib"]
|
38
|
+
|
39
|
+
spec.add_dependency "thor", "~> 0.20"
|
40
|
+
spec.add_dependency "activesupport", "~> 5.2"
|
41
|
+
|
42
|
+
spec.add_development_dependency "bundler", "~> 2.0"
|
43
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
44
|
+
spec.add_development_dependency "minitest", "~> 5.11"
|
45
|
+
spec.add_development_dependency "minitest-reporters", "~> 1.3"
|
46
|
+
spec.add_development_dependency 'simplecov', "~> 0.16"
|
47
|
+
end
|