modular_routes 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.editorconfig +10 -0
- data/.github/workflows/ci.yml +27 -0
- data/.github/workflows/coverage.yml +24 -0
- data/.github/workflows/rubocop.yml +22 -0
- data/.gitignore +12 -0
- data/.rspec +3 -0
- data/.rubocop.yml +41 -0
- data/CHANGELOG.md +5 -0
- data/CODE_OF_CONDUCT.md +84 -0
- data/Gemfile +5 -0
- data/LICENSE +190 -0
- data/README.md +349 -0
- data/Rakefile +12 -0
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/lib/modular_routes.rb +14 -0
- data/lib/modular_routes/builder.rb +45 -0
- data/lib/modular_routes/extension.rb +12 -0
- data/lib/modular_routes/options.rb +50 -0
- data/lib/modular_routes/route/non_restful.rb +48 -0
- data/lib/modular_routes/route/restful.rb +31 -0
- data/lib/modular_routes/version.rb +5 -0
- data/modular_routes.gemspec +44 -0
- metadata +182 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 954ed3363ece12cbe51eca5df6783f6066d49b3b5320dbcf7e9e10d0acf4bc05
|
4
|
+
data.tar.gz: 80fd6d08afa02b8502999c5ed5d37ca6104b64ef4714464f6adb0407d00fb364
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 8415af3f02b945890d14770c4e92d1bb2dfb3779773bdff86f6a87aa3e1417cb1c67fb6710c581b33031dc6bdf350fce97e15aa245c2fb7f07327e031c942397
|
7
|
+
data.tar.gz: 6aad4a4706157f87818541122dc520f83eb22eca43167d08162b40eb575546c82e674c90d83d0882be7aa1d98e82f09429e922aa1aaac4dfbc514710f878c73e
|
data/.editorconfig
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
name: CI
|
2
|
+
|
3
|
+
on: [push, pull_request]
|
4
|
+
|
5
|
+
jobs:
|
6
|
+
tests:
|
7
|
+
runs-on: ubuntu-latest
|
8
|
+
strategy:
|
9
|
+
matrix:
|
10
|
+
ruby: ["2.7", "3.0"]
|
11
|
+
steps:
|
12
|
+
- name: Clone
|
13
|
+
uses: actions/checkout@v2
|
14
|
+
- name: Set up Ruby ${{ matrix.ruby }}
|
15
|
+
uses: ruby/setup-ruby@v1
|
16
|
+
with:
|
17
|
+
ruby-version: ${{ matrix.ruby }}
|
18
|
+
bundler-cache: true
|
19
|
+
- name: Install gems
|
20
|
+
run: |
|
21
|
+
gem install bundler -v 2.2.15
|
22
|
+
bundle install
|
23
|
+
- name: Run the specs task
|
24
|
+
env:
|
25
|
+
COVERAGE: "true"
|
26
|
+
run: |
|
27
|
+
bundle exec rake spec
|
@@ -0,0 +1,24 @@
|
|
1
|
+
name: Coverage
|
2
|
+
|
3
|
+
on: [push, pull_request]
|
4
|
+
|
5
|
+
jobs:
|
6
|
+
run:
|
7
|
+
runs-on: ubuntu-latest
|
8
|
+
steps:
|
9
|
+
- name: Clone
|
10
|
+
uses: actions/checkout@v2
|
11
|
+
- name: Set up Ruby ${{ matrix.ruby }}
|
12
|
+
uses: ruby/setup-ruby@v1
|
13
|
+
with:
|
14
|
+
ruby-version: 3.0
|
15
|
+
bundler-cache: true
|
16
|
+
- name: Install gems
|
17
|
+
run: |
|
18
|
+
gem install bundler -v 2.2.15
|
19
|
+
bundle install
|
20
|
+
- name: Run the coverage task
|
21
|
+
env:
|
22
|
+
COVERAGE: "true"
|
23
|
+
run: |
|
24
|
+
bundle exec rake spec
|
@@ -0,0 +1,22 @@
|
|
1
|
+
name: RuboCop
|
2
|
+
|
3
|
+
on: [push, pull_request]
|
4
|
+
|
5
|
+
jobs:
|
6
|
+
run:
|
7
|
+
runs-on: ubuntu-latest
|
8
|
+
steps:
|
9
|
+
- name: Clone
|
10
|
+
uses: actions/checkout@v2
|
11
|
+
- name: Set up Ruby
|
12
|
+
uses: ruby/setup-ruby@v1
|
13
|
+
with:
|
14
|
+
ruby-version: 3.0
|
15
|
+
bundler-cache: true
|
16
|
+
- name: Install gems
|
17
|
+
run: |
|
18
|
+
gem install bundler -v 2.2.15
|
19
|
+
bundle install
|
20
|
+
- name: Run the rubocop task
|
21
|
+
run: |
|
22
|
+
bundle exec rake rubocop
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
inherit_gem:
|
2
|
+
rubocop-shopify: rubocop.yml
|
3
|
+
|
4
|
+
require:
|
5
|
+
- rubocop-performance
|
6
|
+
|
7
|
+
AllCops:
|
8
|
+
TargetRubyVersion: 2.7
|
9
|
+
NewCops: enable
|
10
|
+
# Metrics/BlockLength:
|
11
|
+
# Exclude:
|
12
|
+
# - "**/*_spec.rb"
|
13
|
+
# - "**/spec/**/*.rb"
|
14
|
+
|
15
|
+
# Metrics/AbcSize:
|
16
|
+
# Max: 18
|
17
|
+
# Exclude:
|
18
|
+
# - "**/*_spec.rb"
|
19
|
+
# - "**/spec/**/*.rb"
|
20
|
+
|
21
|
+
# Metrics/ModuleLength:
|
22
|
+
# Exclude:
|
23
|
+
# - "**/*_spec.rb"
|
24
|
+
# - "**/spec/**/*.rb"
|
25
|
+
|
26
|
+
# RSpec/MultipleExpectations:
|
27
|
+
# Exclude:
|
28
|
+
# - "**/requests/**/*_spec.rb"
|
29
|
+
|
30
|
+
# RSpec/AnyInstance:
|
31
|
+
# Exclude:
|
32
|
+
# - spec/support/**.rb
|
33
|
+
|
34
|
+
# Style/AccessorGrouping:
|
35
|
+
# EnforcedStyle: separated
|
36
|
+
|
37
|
+
# Style/SymbolArray:
|
38
|
+
# EnforcedStyle: brackets
|
39
|
+
|
40
|
+
# Style/AccessModifierDeclarations:
|
41
|
+
# EnforcedStyle: inline
|
data/CHANGELOG.md
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
|
6
|
+
|
7
|
+
We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
|
8
|
+
|
9
|
+
## Our Standards
|
10
|
+
|
11
|
+
Examples of behavior that contributes to a positive environment for our community include:
|
12
|
+
|
13
|
+
* Demonstrating empathy and kindness toward other people
|
14
|
+
* Being respectful of differing opinions, viewpoints, and experiences
|
15
|
+
* Giving and gracefully accepting constructive feedback
|
16
|
+
* Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
|
17
|
+
* Focusing on what is best not just for us as individuals, but for the overall community
|
18
|
+
|
19
|
+
Examples of unacceptable behavior include:
|
20
|
+
|
21
|
+
* The use of sexualized language or imagery, and sexual attention or
|
22
|
+
advances of any kind
|
23
|
+
* Trolling, insulting or derogatory comments, and personal or political attacks
|
24
|
+
* Public or private harassment
|
25
|
+
* Publishing others' private information, such as a physical or email
|
26
|
+
address, without their explicit permission
|
27
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
28
|
+
professional setting
|
29
|
+
|
30
|
+
## Enforcement Responsibilities
|
31
|
+
|
32
|
+
Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
|
33
|
+
|
34
|
+
Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
|
35
|
+
|
36
|
+
## Scope
|
37
|
+
|
38
|
+
This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
|
39
|
+
|
40
|
+
## Enforcement
|
41
|
+
|
42
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at contact@vitoravelino.me. All complaints will be reviewed and investigated promptly and fairly.
|
43
|
+
|
44
|
+
All community leaders are obligated to respect the privacy and security of the reporter of any incident.
|
45
|
+
|
46
|
+
## Enforcement Guidelines
|
47
|
+
|
48
|
+
Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
|
49
|
+
|
50
|
+
### 1. Correction
|
51
|
+
|
52
|
+
**Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
|
53
|
+
|
54
|
+
**Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
|
55
|
+
|
56
|
+
### 2. Warning
|
57
|
+
|
58
|
+
**Community Impact**: A violation through a single incident or series of actions.
|
59
|
+
|
60
|
+
**Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
|
61
|
+
|
62
|
+
### 3. Temporary Ban
|
63
|
+
|
64
|
+
**Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
|
65
|
+
|
66
|
+
**Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
|
67
|
+
|
68
|
+
### 4. Permanent Ban
|
69
|
+
|
70
|
+
**Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
|
71
|
+
|
72
|
+
**Consequence**: A permanent ban from any sort of public interaction within the community.
|
73
|
+
|
74
|
+
## Attribution
|
75
|
+
|
76
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
|
77
|
+
available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
|
78
|
+
|
79
|
+
Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
|
80
|
+
|
81
|
+
[homepage]: https://www.contributor-covenant.org
|
82
|
+
|
83
|
+
For answers to common questions about this code of conduct, see the FAQ at
|
84
|
+
https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,190 @@
|
|
1
|
+
Apache License
|
2
|
+
Version 2.0, January 2004
|
3
|
+
http://www.apache.org/licenses/
|
4
|
+
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
6
|
+
|
7
|
+
1. Definitions.
|
8
|
+
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
11
|
+
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
13
|
+
the copyright owner that is granting the License.
|
14
|
+
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
16
|
+
other entities that control, are controlled by, or are under common
|
17
|
+
control with that entity. For the purposes of this definition,
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
19
|
+
direction or management of such entity, whether by contract or
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
22
|
+
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
24
|
+
exercising permissions granted by this License.
|
25
|
+
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
27
|
+
including but not limited to software source code, documentation
|
28
|
+
source, and configuration files.
|
29
|
+
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
31
|
+
transformation or translation of a Source form, including but
|
32
|
+
not limited to compiled object code, generated documentation,
|
33
|
+
and conversions to other media types.
|
34
|
+
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
36
|
+
Object form, made available under the License, as indicated by a
|
37
|
+
copyright notice that is included in or attached to the work
|
38
|
+
(an example is provided in the Appendix below).
|
39
|
+
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
46
|
+
the Work and Derivative Works thereof.
|
47
|
+
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
49
|
+
the original version of the Work and any modifications or additions
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
61
|
+
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
64
|
+
subsequently incorporated within the Work.
|
65
|
+
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
72
|
+
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
78
|
+
where such license applies only to those patent claims licensable
|
79
|
+
by such Contributor that are necessarily infringed by their
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
82
|
+
institute patent litigation against any entity (including a
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
85
|
+
or contributory patent infringement, then any patent licenses
|
86
|
+
granted to You under this License for that Work shall terminate
|
87
|
+
as of the date such litigation is filed.
|
88
|
+
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
91
|
+
modifications, and in Source or Object form, provided that You
|
92
|
+
meet the following conditions:
|
93
|
+
|
94
|
+
(a) You must give any other recipients of the Work or
|
95
|
+
Derivative Works a copy of this License; and
|
96
|
+
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
98
|
+
stating that You changed the files; and
|
99
|
+
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
102
|
+
attribution notices from the Source form of the Work,
|
103
|
+
excluding those notices that do not pertain to any part of
|
104
|
+
the Derivative Works; and
|
105
|
+
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
108
|
+
include a readable copy of the attribution notices contained
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
111
|
+
of the following places: within a NOTICE text file distributed
|
112
|
+
as part of the Derivative Works; within the Source form or
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
114
|
+
within a display generated by the Derivative Works, if and
|
115
|
+
wherever such third-party notices normally appear. The contents
|
116
|
+
of the NOTICE file are for informational purposes only and
|
117
|
+
do not modify the License. You may add Your own attribution
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
120
|
+
that such additional attribution notices cannot be construed
|
121
|
+
as modifying the License.
|
122
|
+
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
124
|
+
may provide additional or different license terms and conditions
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
128
|
+
the conditions stated in this License.
|
129
|
+
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
133
|
+
this License, without any additional terms or conditions.
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
135
|
+
the terms of any separate license agreement you may have executed
|
136
|
+
with Licensor regarding such Contributions.
|
137
|
+
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
140
|
+
except as required for reasonable and customary use in describing the
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
142
|
+
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
152
|
+
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
158
|
+
incidental, or consequential damages of any character arising as a
|
159
|
+
result of this License or out of the use or inability to use the
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
162
|
+
other commercial damages or losses), even if such Contributor
|
163
|
+
has been advised of the possibility of such damages.
|
164
|
+
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
168
|
+
or other liability obligations and/or rights consistent with this
|
169
|
+
License. However, in accepting such obligations, You may act only
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
174
|
+
of your accepting any such warranty or additional liability.
|
175
|
+
|
176
|
+
END OF TERMS AND CONDITIONS
|
177
|
+
|
178
|
+
Copyright 2021 Vítor Avelino
|
179
|
+
|
180
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
181
|
+
you may not use this file except in compliance with the License.
|
182
|
+
You may obtain a copy of the License at
|
183
|
+
|
184
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
185
|
+
|
186
|
+
Unless required by applicable law or agreed to in writing, software
|
187
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
188
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
189
|
+
See the License for the specific language governing permissions and
|
190
|
+
limitations under the License.
|
data/README.md
ADDED
@@ -0,0 +1,349 @@
|
|
1
|
+
[gem]: https://rubygems.org/gems/modular_routes
|
2
|
+
[ci]: https://github.com/vitoravelino/modular_routes/actions/workflows/ci.yml
|
3
|
+
[coverage]: https://github.com/vitoravelino/modular_routes/actions/workflows/coverage.yml
|
4
|
+
[codeclimate]: https://codeclimate.com/github/vitoravelino/modular_routes
|
5
|
+
|
6
|
+
# Modular Routes
|
7
|
+
|
8
|
+
_A simple way of having dedicated controllers for each of your route actions in Rails._
|
9
|
+
|
10
|
+
[![gem version](https://img.shields.io/gem/v/modular_routes)][gem]
|
11
|
+
[![CI](https://github.com/vitoravelino/modular_routes/actions/workflows/ci.yml/badge.svg)][ci]
|
12
|
+
[![Coverage](https://github.com/vitoravelino/modular_routes/actions/workflows/coverage.yml/badge.svg)][coverage]
|
13
|
+
[![Maintainability](https://img.shields.io/codeclimate/maintainability/vitoravelino/modular_routes)][codeclimate]
|
14
|
+
|
15
|
+
If you've ever used [Hanami routes](https://guides.hanamirb.org/v1.3/routing/restful-resources/) or already use dedicated controllers for each route action, this gem might be useful.
|
16
|
+
|
17
|
+
Disclaimer: There's no better/worse nor right/wrong approach, it's up to you to decide how you prefer to organize the controllers and routes of your application.
|
18
|
+
|
19
|
+
## Motivation
|
20
|
+
|
21
|
+
Let's imagine that you have to design a full RESTful resource named `articles` with some custom routes like the table below
|
22
|
+
|
23
|
+
| HTTP Verb | Path |
|
24
|
+
| --------- | --------------------- |
|
25
|
+
| GET | /articles |
|
26
|
+
| GET | /articles/new |
|
27
|
+
| POST | /articles |
|
28
|
+
| GET | /articles/:id |
|
29
|
+
| GET | /articles/:id/edit |
|
30
|
+
| PATCH/PUT | /articles/:id |
|
31
|
+
| DELETE | /articles/:id |
|
32
|
+
| GET | /articles/stats |
|
33
|
+
| POST | /articles/:id/archive |
|
34
|
+
|
35
|
+
How would you organize the controllers and routes of this application?
|
36
|
+
|
37
|
+
The most common approach is to have all the actions (RESTful and customs) in the same controller.
|
38
|
+
|
39
|
+
```ruby
|
40
|
+
# routes.rb
|
41
|
+
|
42
|
+
resources :articles do
|
43
|
+
get :stats, on: :collection
|
44
|
+
post :archive, on: :member
|
45
|
+
end
|
46
|
+
|
47
|
+
# articles_controller.rb
|
48
|
+
|
49
|
+
class ArticlesController
|
50
|
+
def index
|
51
|
+
# ...
|
52
|
+
end
|
53
|
+
|
54
|
+
def create
|
55
|
+
# ...
|
56
|
+
end
|
57
|
+
|
58
|
+
# other actions...
|
59
|
+
|
60
|
+
def stats
|
61
|
+
# ...
|
62
|
+
end
|
63
|
+
|
64
|
+
def archive
|
65
|
+
# ...
|
66
|
+
end
|
67
|
+
end
|
68
|
+
```
|
69
|
+
|
70
|
+
The reason I don't like this approach is that you can end up with a lot of code that are not related to each other in the same file. You can still have it all organized but I believe that it could be better.
|
71
|
+
|
72
|
+
[DHH](http://jeromedalbert.com/how-dhh-organizes-his-rails-controllers/) prefers to keep the RESTful actions (index, new, edit, show, create, update, destroy) inside the same controller and the custom ones in dedicated controllers.
|
73
|
+
|
74
|
+
One way of representing that would be
|
75
|
+
|
76
|
+
```ruby
|
77
|
+
# routes.rb
|
78
|
+
|
79
|
+
resources :articles do
|
80
|
+
get :stats, on: :collection, controller: 'articles/stats'
|
81
|
+
post :archive, on: :member, controller: 'articles/archive'
|
82
|
+
end
|
83
|
+
|
84
|
+
# articles_controller.rb
|
85
|
+
|
86
|
+
class ArticlesController
|
87
|
+
def index
|
88
|
+
# ...
|
89
|
+
end
|
90
|
+
|
91
|
+
def create
|
92
|
+
# ...
|
93
|
+
end
|
94
|
+
|
95
|
+
# other actions...
|
96
|
+
end
|
97
|
+
|
98
|
+
# articles/archive_controller.rb
|
99
|
+
|
100
|
+
class Articles::ArchiveController
|
101
|
+
def archive
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
# articles/stats_controller.rb
|
106
|
+
|
107
|
+
class Articles::StatsController
|
108
|
+
def stats
|
109
|
+
end
|
110
|
+
end
|
111
|
+
```
|
112
|
+
|
113
|
+
This approach is better than the previous one because it restricts the main controller file to contain only the RESTful actions. Additional routes would require you to create a dedicated controller to handle that individually.
|
114
|
+
|
115
|
+
Another approach (and what I personally prefer) is to have one controller per route. What it was done for `archive` and `stats` routes would also be applied to all the RESTful routes.
|
116
|
+
|
117
|
+
The files would be organized inside `articles/` folder that would act as a namespace
|
118
|
+
|
119
|
+
```
|
120
|
+
app/
|
121
|
+
└── controllers/
|
122
|
+
└── articles/
|
123
|
+
├── archive_controller.rb
|
124
|
+
├── create_controller.rb
|
125
|
+
├── destroy_controller.rb
|
126
|
+
├── edit_controller.rb
|
127
|
+
├── index_controller.rb
|
128
|
+
├── new_controller.rb
|
129
|
+
├── show_controller.rb
|
130
|
+
├── stats_controller.rb
|
131
|
+
└── update_controller.rb
|
132
|
+
```
|
133
|
+
|
134
|
+
And the controllers would have one single action named `call` like
|
135
|
+
|
136
|
+
```ruby
|
137
|
+
# articles/index_controller.rb
|
138
|
+
|
139
|
+
class Articles::IndexController
|
140
|
+
def call
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
# articles/archive_controller.rb
|
145
|
+
|
146
|
+
class Articles::ArchiveController
|
147
|
+
def call
|
148
|
+
end
|
149
|
+
end
|
150
|
+
```
|
151
|
+
|
152
|
+
Here are two ways of representing what was explained above:
|
153
|
+
|
154
|
+
```ruby
|
155
|
+
scope module: :articles, path: '/articles' do
|
156
|
+
get '/', to: 'index#call', as: 'articles'
|
157
|
+
post '/', to: 'create#call'
|
158
|
+
|
159
|
+
get 'new', to: 'new#call', as: 'new_article'
|
160
|
+
get ':id/edit', to: 'edit#call', as: 'edit_article'
|
161
|
+
get ':id', to: 'show#call', as: 'article'
|
162
|
+
patch ':id', to: 'update#call'
|
163
|
+
put ':id', to: 'update#call'
|
164
|
+
delete ':id', to: 'destroy#call'
|
165
|
+
|
166
|
+
post 'stats', to: 'stats#call', as: 'stats_articles'
|
167
|
+
post ':id/archive', to: 'archive#call', as: 'archive_article'
|
168
|
+
end
|
169
|
+
```
|
170
|
+
|
171
|
+
or
|
172
|
+
|
173
|
+
```ruby
|
174
|
+
resources :articles, module: :articles, only: [] do
|
175
|
+
collection do
|
176
|
+
get :index, to: 'index#call'
|
177
|
+
post :create, to: 'create#call'
|
178
|
+
post :stats, to: 'stats#call'
|
179
|
+
end
|
180
|
+
|
181
|
+
new do
|
182
|
+
get :new, to: 'new#call'
|
183
|
+
end
|
184
|
+
|
185
|
+
member do
|
186
|
+
get :edit, to: 'edit#call'
|
187
|
+
get :show, to: 'show#call'
|
188
|
+
patch :update, to: 'update#call'
|
189
|
+
put :update, to: 'update#call'
|
190
|
+
delete :destroy, to: 'destroy#call'
|
191
|
+
post :archive, to: 'archive#call'
|
192
|
+
end
|
193
|
+
end
|
194
|
+
```
|
195
|
+
|
196
|
+
This is the best approach in my opinion because your controller will contain only code related to that specific route action. It will also be easier to test and maintain the code.
|
197
|
+
|
198
|
+
If you've decided to go with the last approach, unless you organizes your routes in [separated files](https://guides.rubyonrails.org/routing.html#breaking-up-very-large-route-file-into-multiple-small-ones), your `config/routes.rb` might get really messy as your application grows due to verbosity.
|
199
|
+
|
200
|
+
So, what if we had a simpler way of doing all of that? Let's take a look at how modular routes can help us.
|
201
|
+
|
202
|
+
## Installation
|
203
|
+
|
204
|
+
Add this line to your application's Gemfile:
|
205
|
+
|
206
|
+
```ruby
|
207
|
+
gem "modular_routes"
|
208
|
+
```
|
209
|
+
|
210
|
+
And then execute:
|
211
|
+
|
212
|
+
$ bundle install
|
213
|
+
|
214
|
+
Or install it yourself as:
|
215
|
+
|
216
|
+
$ gem install modular_routes
|
217
|
+
|
218
|
+
## Usage
|
219
|
+
|
220
|
+
`modular_route` uses `resource` and `resources` route helpers behind the scenes. So you can pretty much use almost everything you already use with them except for a few [limitations](#limitations) that will be explained later.
|
221
|
+
|
222
|
+
For the same example used in the [motivation](#motivation) section, using modular routes we now have
|
223
|
+
|
224
|
+
```ruby
|
225
|
+
# routes.rb
|
226
|
+
|
227
|
+
modular_route resources: :articles, all: true do
|
228
|
+
collection do
|
229
|
+
post :stats
|
230
|
+
end
|
231
|
+
|
232
|
+
member do
|
233
|
+
post :archive
|
234
|
+
end
|
235
|
+
end
|
236
|
+
```
|
237
|
+
|
238
|
+
or to be shorter
|
239
|
+
|
240
|
+
```ruby
|
241
|
+
# routes.rb
|
242
|
+
|
243
|
+
modular_route resources: :articles, all: true do
|
244
|
+
post :stats, on: :collection
|
245
|
+
post :archive, on: :member
|
246
|
+
end
|
247
|
+
```
|
248
|
+
|
249
|
+
The only mandatory option to use `modular_route` helper is to pass `:resources` or `:resource` as key with the following resource name.
|
250
|
+
|
251
|
+
To generate all RESTful routes, you must pass `all: true`. Otherwise nothing will happen unless you pass a block with additional routes.
|
252
|
+
|
253
|
+
The output routes for the code above would be
|
254
|
+
|
255
|
+
| HTTP Verb | Path | Controller#Action | Named Route Helper |
|
256
|
+
| --------- | --------------------- | --------------------- | ------------------------- |
|
257
|
+
| GET | /articles | articles/index#call | articles_path |
|
258
|
+
| GET | /articles/new | articles/new#call | new_article_path |
|
259
|
+
| POST | /articles | articles/create#call | articles_path |
|
260
|
+
| GET | /articles/:id | articles/show#call | articles_path(:id) |
|
261
|
+
| GET | /articles/:id/edit | articles/edit#call | edit_articles_path(:id) |
|
262
|
+
| PATCH/PUT | /articles/:id | articles/update#call | articles_path(:id) |
|
263
|
+
| DELETE | /articles/:id | articles/destroy#call | articles_path(:id) |
|
264
|
+
| POST | /articles/stats | articles/stats#call | stats_articles_path(:id) |
|
265
|
+
| POST | /articles/:id/archive | articles/archive#call | archive_article_path(:id) |
|
266
|
+
|
267
|
+
### Restricting routes
|
268
|
+
|
269
|
+
You can restrict the routes for the RESTful with `:only` and `:except` similar to what you can do in Rails by default.
|
270
|
+
|
271
|
+
```ruby
|
272
|
+
modular_route resources: :articles, only: [:index, :show]
|
273
|
+
```
|
274
|
+
|
275
|
+
```ruby
|
276
|
+
modular_route resources: :articles, except: [:destroy]
|
277
|
+
```
|
278
|
+
|
279
|
+
### Renaming paths
|
280
|
+
|
281
|
+
As in Rails you can simply use `:path` attribute.
|
282
|
+
|
283
|
+
```ruby
|
284
|
+
modular_route resources: :articles, all: true, path: 'posts'
|
285
|
+
```
|
286
|
+
|
287
|
+
is going to produce
|
288
|
+
|
289
|
+
| HTTP Verb | Path | Controller#Action | Named Route Helper |
|
290
|
+
| --------- | --------------- | --------------------- | ---------------------- |
|
291
|
+
| GET | /posts | articles/index#call | articles_path |
|
292
|
+
| GET | /posts/new | articles/new#call | new_article_path |
|
293
|
+
| POST | /posts | articles/create#call | articles_path |
|
294
|
+
| GET | /posts/:id | articles/show#call | article_path(:id) |
|
295
|
+
| GET | /posts/:id/edit | articles/edit#call | edit_article_path(:id) |
|
296
|
+
| PATCH/PUT | /posts/:id | articles/update#call | article_path(:id) |
|
297
|
+
| DELETE | /posts/:id | articles/destroy#call | article_path(:id) |
|
298
|
+
|
299
|
+
### API mode
|
300
|
+
|
301
|
+
If your Rails app is with API only mode, then `:edit` and `:new` actions won't be applied.
|
302
|
+
|
303
|
+
### Limitations
|
304
|
+
|
305
|
+
Some of the restrictions are:
|
306
|
+
|
307
|
+
- `concerns` won't work
|
308
|
+
- `constraints` only as option and not block
|
309
|
+
- no support for nesting
|
310
|
+
|
311
|
+
#### Nesting
|
312
|
+
|
313
|
+
Even without nesting support you can emulate what the expected behaviour would be mixing `namespace` and `path` as detailed below
|
314
|
+
|
315
|
+
```ruby
|
316
|
+
namespace :books, path: 'books/:book_id' do
|
317
|
+
modular_route resources: :reviews, all: true
|
318
|
+
end
|
319
|
+
```
|
320
|
+
|
321
|
+
The output routes for that would be
|
322
|
+
|
323
|
+
| HTTP Verb | Path | Controller#Action | Named Route Helper |
|
324
|
+
| --------- | -------------------------------- | -------------------------- | ------------------------------- |
|
325
|
+
| GET | /books/:book_id/reviews | books/reviews/index#call | books_reviews_path |
|
326
|
+
| GET | /books/:book_id/reviews/new | books/reviews/new#call | new_articles_reviews_path |
|
327
|
+
| POST | /books/:book_id/reviews | books/reviews/create#call | books_reviews_path |
|
328
|
+
| GET | /books/:book_id/reviews/:id | books/reviews/show#call | books_reviews_path(:id) |
|
329
|
+
| GET | /books/:book_id/reviews/:id/edit | books/reviews/edit#call | edit_articles_reviews_path(:id) |
|
330
|
+
| PATCH/PUT | /books/:book_id/reviews/:id | books/reviews/update#call | books_reviews_path(:id) |
|
331
|
+
| DELETE | /books/:book_id/reviews/:id | books/reviews/destroy#call | books_reviews_path(:id) |
|
332
|
+
|
333
|
+
## Development
|
334
|
+
|
335
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
336
|
+
|
337
|
+
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 the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
338
|
+
|
339
|
+
## Contributing
|
340
|
+
|
341
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/vitoravelino/modular_routes. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/vitoravelino/modular_routes/blob/master/CODE_OF_CONDUCT.md).
|
342
|
+
|
343
|
+
## Code of Conduct
|
344
|
+
|
345
|
+
Everyone interacting in the ModularRoutes project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/vitoravelino/modular_routes/blob/master/CODE_OF_CONDUCT.md).
|
346
|
+
|
347
|
+
## Licensing
|
348
|
+
|
349
|
+
Modular Routes is licensed under the Apache License, Version 2.0. See [LICENSE](https://github.com/vitoravelino/modular_routes/blob/master/LICENSE) for the full license text.
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require "bundler/setup"
|
5
|
+
require "modular_routes"
|
6
|
+
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
9
|
+
|
10
|
+
# (If you use this, don"t forget to add pry to your Gemfile!)
|
11
|
+
# require "pry"
|
12
|
+
# Pry.start
|
13
|
+
|
14
|
+
require "irb"
|
15
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "action_dispatch"
|
4
|
+
|
5
|
+
require_relative "modular_routes/builder"
|
6
|
+
require_relative "modular_routes/extension"
|
7
|
+
require_relative "modular_routes/options"
|
8
|
+
require_relative "modular_routes/route/non_restful"
|
9
|
+
require_relative "modular_routes/route/restful"
|
10
|
+
require_relative "modular_routes/version"
|
11
|
+
|
12
|
+
module ModularRoutes
|
13
|
+
ActionDispatch::Routing::Mapper.include(Extension)
|
14
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ModularRoutes
|
4
|
+
class Builder
|
5
|
+
HTTP_METHODS = [:post, :get, :put, :patch, :delete].freeze
|
6
|
+
|
7
|
+
attr_reader :routes
|
8
|
+
|
9
|
+
def initialize(route_options)
|
10
|
+
@route_options = route_options
|
11
|
+
@routes = build_resource_routes
|
12
|
+
end
|
13
|
+
|
14
|
+
HTTP_METHODS.each do |method|
|
15
|
+
define_method(method) do |action, options = {}|
|
16
|
+
mutable_options = { on: @on }
|
17
|
+
merged_options = mutable_options.merge(options)
|
18
|
+
|
19
|
+
@routes.unshift(Route::NonRestful.new(method, action, merged_options, @route_options))
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def collection
|
24
|
+
@on = :collection
|
25
|
+
yield
|
26
|
+
ensure
|
27
|
+
@on = nil
|
28
|
+
end
|
29
|
+
|
30
|
+
def member
|
31
|
+
@on = :member
|
32
|
+
yield
|
33
|
+
ensure
|
34
|
+
@on = nil
|
35
|
+
end
|
36
|
+
|
37
|
+
private def build_resource_routes
|
38
|
+
@route_options.actions.map { |action| build_resource_route(action) }
|
39
|
+
end
|
40
|
+
|
41
|
+
private def build_resource_route(action)
|
42
|
+
Route::Restful.new(@route_options, action)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ModularRoutes
|
4
|
+
module Extension
|
5
|
+
def modular_route(options, &block)
|
6
|
+
route_options = Options.new(options.merge(api_only: api_only?))
|
7
|
+
route_builder = Builder.new(route_options)
|
8
|
+
route_builder.instance_eval(&block) if block
|
9
|
+
route_builder.routes.each { |route| route.apply(self) }
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ModularRoutes
|
4
|
+
class Options
|
5
|
+
attr_reader :method
|
6
|
+
attr_reader :module
|
7
|
+
attr_reader :resource
|
8
|
+
attr_reader :options
|
9
|
+
|
10
|
+
def initialize(options)
|
11
|
+
@options = options
|
12
|
+
@method = extract_resource_method
|
13
|
+
@resource = @options.delete(@method)
|
14
|
+
@module = @options.fetch(:module, @resource)
|
15
|
+
@api = @options.delete(:api_only) { false }
|
16
|
+
|
17
|
+
@only = @options.delete(:only)
|
18
|
+
@except = @options.delete(:except)
|
19
|
+
@all = @options.delete(:all)
|
20
|
+
end
|
21
|
+
|
22
|
+
def singular?
|
23
|
+
method == :resource
|
24
|
+
end
|
25
|
+
|
26
|
+
def actions
|
27
|
+
return default_actions if @all
|
28
|
+
|
29
|
+
return default_actions - Array(@except) if @except
|
30
|
+
|
31
|
+
Array(@only)
|
32
|
+
end
|
33
|
+
|
34
|
+
private def default_actions
|
35
|
+
actions = [:index, :create, :new, :edit, :show, :update, :destroy]
|
36
|
+
|
37
|
+
actions -= [:index] if singular?
|
38
|
+
actions -= [:edit, :new] if @api
|
39
|
+
|
40
|
+
actions
|
41
|
+
end
|
42
|
+
|
43
|
+
private def extract_resource_method
|
44
|
+
return :resource if options.include?(:resource)
|
45
|
+
return :resources if options.include?(:resources)
|
46
|
+
|
47
|
+
raise ArgumentError, "you must specify :resource or :resources for `modular_route`"
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ModularRoutes
|
4
|
+
module Route
|
5
|
+
class NonRestful
|
6
|
+
attr_reader :http_method
|
7
|
+
attr_reader :action
|
8
|
+
|
9
|
+
def initialize(http_method, action, options, scope_options)
|
10
|
+
@http_method = http_method
|
11
|
+
@action = action
|
12
|
+
@options = options
|
13
|
+
@scope_options = scope_options
|
14
|
+
|
15
|
+
unless @options.fetch(:on, nil)
|
16
|
+
raise ArgumentError,
|
17
|
+
"Non-RESTful route should be declared inside `member`/`collection` block or using `:on` key"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def apply(mapper)
|
22
|
+
method = @scope_options.method
|
23
|
+
resource = @scope_options.resource
|
24
|
+
|
25
|
+
mapper.public_send(method, resource, resource_options) do
|
26
|
+
mapper.public_send(http_method, action, options)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
private def resource_options
|
31
|
+
immutable_options = {
|
32
|
+
only: [],
|
33
|
+
module: @scope_options.module,
|
34
|
+
}
|
35
|
+
|
36
|
+
@scope_options.options.merge(immutable_options)
|
37
|
+
end
|
38
|
+
|
39
|
+
private def options
|
40
|
+
mutable_options = {
|
41
|
+
to: "#{action}#call",
|
42
|
+
}
|
43
|
+
|
44
|
+
mutable_options.merge(@options)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ModularRoutes
|
4
|
+
module Route
|
5
|
+
class Restful
|
6
|
+
def initialize(route_options, action)
|
7
|
+
@module = route_options.module
|
8
|
+
@resource = route_options.resource
|
9
|
+
@options = route_options.options
|
10
|
+
@method = route_options.method
|
11
|
+
@action = action
|
12
|
+
end
|
13
|
+
|
14
|
+
def apply(mapper)
|
15
|
+
mapper.public_send(@method, @resource, resource_options)
|
16
|
+
end
|
17
|
+
|
18
|
+
private def resource_options
|
19
|
+
immutable_options = {
|
20
|
+
controller: @action,
|
21
|
+
only: @action,
|
22
|
+
action: :call,
|
23
|
+
}
|
24
|
+
|
25
|
+
mutable_options = { module: @module }
|
26
|
+
|
27
|
+
mutable_options.merge(@options).merge(immutable_options)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "lib/modular_routes/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "modular_routes"
|
7
|
+
spec.version = ModularRoutes::VERSION
|
8
|
+
spec.authors = ["Vítor Avelino"]
|
9
|
+
spec.email = ["contact@vitoravelino.me"]
|
10
|
+
|
11
|
+
spec.summary = "A simple way of having dedicated controllers for each of your route actions in Rails"
|
12
|
+
spec.description = spec.summary
|
13
|
+
spec.homepage = "https://github.com/vitoravelino/modular_routes"
|
14
|
+
|
15
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.7.0")
|
16
|
+
|
17
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
18
|
+
spec.metadata["source_code_uri"] = spec.homepage
|
19
|
+
spec.metadata["changelog_uri"] = spec.homepage
|
20
|
+
|
21
|
+
# Specify which files should be added to the gem when it is released.
|
22
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
23
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
24
|
+
%x(git ls-files -z).split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
|
25
|
+
end
|
26
|
+
spec.bindir = "exe"
|
27
|
+
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
28
|
+
spec.require_paths = ["lib"]
|
29
|
+
|
30
|
+
# Uncomment to register a new dependency of your gem
|
31
|
+
# spec.add_dependency "example-gem", "~> 1.0"
|
32
|
+
spec.add_dependency("rails")
|
33
|
+
|
34
|
+
spec.add_development_dependency("combustion")
|
35
|
+
spec.add_development_dependency("rspec-rails")
|
36
|
+
spec.add_development_dependency("rubocop-performance")
|
37
|
+
spec.add_development_dependency("rubocop-rspec")
|
38
|
+
spec.add_development_dependency("rubocop-shopify")
|
39
|
+
spec.add_development_dependency("rubycritic")
|
40
|
+
spec.add_development_dependency("sqlite3")
|
41
|
+
|
42
|
+
# For more information and examples about making a new gem, checkout our
|
43
|
+
# guide at: https://bundler.io/guides/creating_gem.html
|
44
|
+
end
|
metadata
ADDED
@@ -0,0 +1,182 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: modular_routes
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Vítor Avelino
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2021-07-15 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rails
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: combustion
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec-rails
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rubocop-performance
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rubocop-rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rubocop-shopify
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rubycritic
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: sqlite3
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
description: A simple way of having dedicated controllers for each of your route actions
|
126
|
+
in Rails
|
127
|
+
email:
|
128
|
+
- contact@vitoravelino.me
|
129
|
+
executables: []
|
130
|
+
extensions: []
|
131
|
+
extra_rdoc_files: []
|
132
|
+
files:
|
133
|
+
- ".editorconfig"
|
134
|
+
- ".github/workflows/ci.yml"
|
135
|
+
- ".github/workflows/coverage.yml"
|
136
|
+
- ".github/workflows/rubocop.yml"
|
137
|
+
- ".gitignore"
|
138
|
+
- ".rspec"
|
139
|
+
- ".rubocop.yml"
|
140
|
+
- CHANGELOG.md
|
141
|
+
- CODE_OF_CONDUCT.md
|
142
|
+
- Gemfile
|
143
|
+
- LICENSE
|
144
|
+
- README.md
|
145
|
+
- Rakefile
|
146
|
+
- bin/console
|
147
|
+
- bin/setup
|
148
|
+
- lib/modular_routes.rb
|
149
|
+
- lib/modular_routes/builder.rb
|
150
|
+
- lib/modular_routes/extension.rb
|
151
|
+
- lib/modular_routes/options.rb
|
152
|
+
- lib/modular_routes/route/non_restful.rb
|
153
|
+
- lib/modular_routes/route/restful.rb
|
154
|
+
- lib/modular_routes/version.rb
|
155
|
+
- modular_routes.gemspec
|
156
|
+
homepage: https://github.com/vitoravelino/modular_routes
|
157
|
+
licenses: []
|
158
|
+
metadata:
|
159
|
+
homepage_uri: https://github.com/vitoravelino/modular_routes
|
160
|
+
source_code_uri: https://github.com/vitoravelino/modular_routes
|
161
|
+
changelog_uri: https://github.com/vitoravelino/modular_routes
|
162
|
+
post_install_message:
|
163
|
+
rdoc_options: []
|
164
|
+
require_paths:
|
165
|
+
- lib
|
166
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
167
|
+
requirements:
|
168
|
+
- - ">="
|
169
|
+
- !ruby/object:Gem::Version
|
170
|
+
version: 2.7.0
|
171
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
172
|
+
requirements:
|
173
|
+
- - ">="
|
174
|
+
- !ruby/object:Gem::Version
|
175
|
+
version: '0'
|
176
|
+
requirements: []
|
177
|
+
rubygems_version: 3.2.15
|
178
|
+
signing_key:
|
179
|
+
specification_version: 4
|
180
|
+
summary: A simple way of having dedicated controllers for each of your route actions
|
181
|
+
in Rails
|
182
|
+
test_files: []
|