grapethor 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (92) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +8 -0
  3. data/.travis.yml +22 -0
  4. data/CHANGELOG.md +13 -0
  5. data/CODE_OF_CONDUCT.md +76 -0
  6. data/Gemfile +3 -0
  7. data/Gemfile.lock +53 -0
  8. data/LICENSE +19 -0
  9. data/README.md +165 -0
  10. data/Rakefile +9 -0
  11. data/_config.yml +1 -0
  12. data/bin/console +14 -0
  13. data/bin/setup +8 -0
  14. data/exe/grapethor +5 -0
  15. data/grapethor.gemspec +47 -0
  16. data/lib/grapethor.rb +10 -0
  17. data/lib/grapethor/generators/api.rb +78 -0
  18. data/lib/grapethor/generators/cli.rb +35 -0
  19. data/lib/grapethor/generators/endpoint.rb +168 -0
  20. data/lib/grapethor/generators/new.rb +161 -0
  21. data/lib/grapethor/generators/resource.rb +89 -0
  22. data/lib/grapethor/templates/api/api/%api_version%/base.rb.tt +19 -0
  23. data/lib/grapethor/templates/api_minitest/test/support/api_%api_version%_test_case.rb.tt +12 -0
  24. data/lib/grapethor/templates/api_rspec/.gitkeep +0 -0
  25. data/lib/grapethor/templates/docker/Dockerfile.tt +18 -0
  26. data/lib/grapethor/templates/docker/docker-compose.yml.tt +43 -0
  27. data/lib/grapethor/templates/endpoint.rb.erb +14 -0
  28. data/lib/grapethor/templates/endpoint/api/%api_version%/%end_resource_plural%.rb.tt +14 -0
  29. data/lib/grapethor/templates/endpoint_minitest.rb.erb +13 -0
  30. data/lib/grapethor/templates/endpoint_minitest/test/api/%api_version%/%end_resource_plural%_test.rb.tt +14 -0
  31. data/lib/grapethor/templates/endpoint_rspec.rb.erb +11 -0
  32. data/lib/grapethor/templates/endpoint_rspec/spec/api/%api_version%/%end_resource_plural%_spec.rb.tt +12 -0
  33. data/lib/grapethor/templates/license/apache2/LICENSE.tt +13 -0
  34. data/lib/grapethor/templates/license/cddl1/LICENSE.tt +316 -0
  35. data/lib/grapethor/templates/license/epl1/LICENSE.tt +200 -0
  36. data/lib/grapethor/templates/license/freebsd/LICENSE.tt +22 -0
  37. data/lib/grapethor/templates/license/gpl2/LICENSE.tt +17 -0
  38. data/lib/grapethor/templates/license/gpl3/LICENSE.tt +16 -0
  39. data/lib/grapethor/templates/license/mit/LICENSE.tt +19 -0
  40. data/lib/grapethor/templates/license/mpl2/LICENSE.tt +5 -0
  41. data/lib/grapethor/templates/license/newbsd/LICENSE.tt +26 -0
  42. data/lib/grapethor/templates/minitest/lib/tasks/test.rake +14 -0
  43. data/lib/grapethor/templates/minitest/test/support/reporters.rb +11 -0
  44. data/lib/grapethor/templates/minitest/test/support/test_case.rb +18 -0
  45. data/lib/grapethor/templates/minitest/test/test_helper.rb +12 -0
  46. data/lib/grapethor/templates/mysql/config/database.yml.tt +33 -0
  47. data/lib/grapethor/templates/new/.gitignore +7 -0
  48. data/lib/grapethor/templates/new/.grapethor.yml.tt +13 -0
  49. data/lib/grapethor/templates/new/Gemfile.tt +44 -0
  50. data/lib/grapethor/templates/new/README.md.tt +138 -0
  51. data/lib/grapethor/templates/new/Rakefile.tt +30 -0
  52. data/lib/grapethor/templates/new/api/base.rb.tt +19 -0
  53. data/lib/grapethor/templates/new/app/exceptions/not_found_error.rb +1 -0
  54. data/lib/grapethor/templates/new/bin/console +13 -0
  55. data/lib/grapethor/templates/new/bin/server.tt +14 -0
  56. data/lib/grapethor/templates/new/bin/setup.tt +8 -0
  57. data/lib/grapethor/templates/new/config.ru.tt +19 -0
  58. data/lib/grapethor/templates/new/config/application.rb.tt +18 -0
  59. data/lib/grapethor/templates/new/config/boot.rb +2 -0
  60. data/lib/grapethor/templates/new/config/environment.rb +3 -0
  61. data/lib/grapethor/templates/new/db/seeds.rb +7 -0
  62. data/lib/grapethor/templates/new/lib/tasks/routes.rake +8 -0
  63. data/lib/grapethor/templates/postgresql/config/database.yml.tt +38 -0
  64. data/lib/grapethor/templates/resource/api/%api_version%/%res_name_plural%.rb.tt +95 -0
  65. data/lib/grapethor/templates/resource/api/entities/%res_name%.rb.tt +10 -0
  66. data/lib/grapethor/templates/resource/app/models/%res_name%.rb.tt +6 -0
  67. data/lib/grapethor/templates/resource/db/migrations/%res_migration%.rb.tt +10 -0
  68. data/lib/grapethor/templates/resource_minitest/test/api/%api_version%/%res_name_plural%_test.rb.tt +82 -0
  69. data/lib/grapethor/templates/resource_minitest/test/fixtures/%res_name_plural%.yml.tt +9 -0
  70. data/lib/grapethor/templates/resource_minitest/test/models/%res_name%_test.rb.tt +17 -0
  71. data/lib/grapethor/templates/resource_rspec/spec/api/%api_version%/%res_name_plural%_spec.rb.tt +91 -0
  72. data/lib/grapethor/templates/resource_rspec/spec/factories/%res_name_plural%.rb.tt +7 -0
  73. data/lib/grapethor/templates/resource_rspec/spec/models/%res_name%_spec.rb.tt +9 -0
  74. data/lib/grapethor/templates/rspec/.rspec +1 -0
  75. data/lib/grapethor/templates/rspec/lib/tasks/spec.rake +4 -0
  76. data/lib/grapethor/templates/rspec/spec/spec_helper.rb +24 -0
  77. data/lib/grapethor/templates/sqlite/config/database.yml.tt +22 -0
  78. data/lib/grapethor/templates/swagger/swagger-ui/favicon-16x16.png +0 -0
  79. data/lib/grapethor/templates/swagger/swagger-ui/favicon-32x32.png +0 -0
  80. data/lib/grapethor/templates/swagger/swagger-ui/index.html.tt +60 -0
  81. data/lib/grapethor/templates/swagger/swagger-ui/oauth2-redirect.html +67 -0
  82. data/lib/grapethor/templates/swagger/swagger-ui/swagger-ui-bundle.js +93 -0
  83. data/lib/grapethor/templates/swagger/swagger-ui/swagger-ui-bundle.js.map +1 -0
  84. data/lib/grapethor/templates/swagger/swagger-ui/swagger-ui-standalone-preset.js +14 -0
  85. data/lib/grapethor/templates/swagger/swagger-ui/swagger-ui-standalone-preset.js.map +1 -0
  86. data/lib/grapethor/templates/swagger/swagger-ui/swagger-ui.css +3 -0
  87. data/lib/grapethor/templates/swagger/swagger-ui/swagger-ui.css.map +1 -0
  88. data/lib/grapethor/templates/swagger/swagger-ui/swagger-ui.js +9 -0
  89. data/lib/grapethor/templates/swagger/swagger-ui/swagger-ui.js.map +1 -0
  90. data/lib/grapethor/utils/utils.rb +116 -0
  91. data/lib/grapethor/version.rb +3 -0
  92. metadata +235 -0
@@ -0,0 +1,200 @@
1
+ Copyright (c) <%= Time.now.year %> <%= app_copyright %>
2
+
3
+ THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC
4
+ LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM
5
+ CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
6
+
7
+ 1. DEFINITIONS
8
+
9
+ "Contribution" means:
10
+
11
+ a) in the case of the initial Contributor, the initial code and documentation
12
+ distributed under this Agreement, and b) in the case of each subsequent
13
+ Contributor: i) changes to the Program, and ii) additions to the Program; where
14
+ such changes and/or additions to the Program originate from and are distributed
15
+ by that particular Contributor. A Contribution 'originates' from a Contributor
16
+ if it was added to the Program by such Contributor itself or anyone acting on
17
+ such Contributor's behalf. Contributions do not include additions to the Program
18
+ which: (i) are separate modules of software distributed in conjunction with the
19
+ Program under their own license agreement, and (ii) are not derivative works of
20
+ the Program.
21
+
22
+
23
+
24
+ "Contributor" means any person or entity that distributes the Program.
25
+
26
+ "Licensed Patents" mean patent claims licensable by a Contributor which are
27
+ "necessarily infringed by the use or sale of its Contribution alone or when
28
+ "combined with the Program.
29
+
30
+ "Program" means the Contributions distributed in accordance with this Agreement.
31
+
32
+ "Recipient" means anyone who receives the Program under this Agreement,
33
+ "including all Contributors.
34
+
35
+ 2. GRANT OF RIGHTS
36
+
37
+ a) Subject to the terms of this Agreement, each Contributor hereby grants
38
+ Recipient a non-exclusive, worldwide, royalty-free copyright license to
39
+ reproduce, prepare derivative works of, publicly display, publicly perform,
40
+ distribute and sublicense the Contribution of such Contributor, if any, and such
41
+ derivative works, in source code and object code form. b) Subject to the terms
42
+ of this Agreement, each Contributor hereby grants Recipient a non-exclusive,
43
+ worldwide, royalty-free patent license under Licensed Patents to make, use,
44
+ sell, offer to sell, import and otherwise transfer the Contribution of such
45
+ Contributor, if any, in source code and object code form. This patent license
46
+ shall apply to the combination of the Contribution and the Program if, at the
47
+ time the Contribution is added by the Contributor, such addition of the
48
+ Contribution causes such combination to be covered by the Licensed Patents. The
49
+ patent license shall not apply to any other combinations which include the
50
+ Contribution. No hardware per se is licensed hereunder. c) Recipient understands
51
+ that although each Contributor grants the licenses to its Contributions set
52
+ forth herein, no assurances are provided by any Contributor that the Program
53
+ does not infringe the patent or other intellectual property rights of any other
54
+ entity. Each Contributor disclaims any liability to Recipient for claims brought
55
+ by any other entity based on infringement of intellectual property rights or
56
+ otherwise. As a condition to exercising the rights and licenses granted
57
+ hereunder, each Recipient hereby assumes sole responsibility to secure any other
58
+ intellectual property rights needed, if any. For example, if a third party
59
+ patent license is required to allow Recipient to distribute the Program, it is
60
+ Recipient's responsibility to acquire that license before distributing the
61
+ Program. d) Each Contributor represents that to its knowledge it has sufficient
62
+ copyright rights in its Contribution, if any, to grant the copyright license set
63
+ forth in this Agreement.
64
+
65
+
66
+
67
+ 3. REQUIREMENTS
68
+
69
+ A Contributor may choose to distribute the Program in object code form under its
70
+ own license agreement, provided that:
71
+
72
+ a) it complies with the terms and conditions of this Agreement; and b) its
73
+ license agreement: i) effectively disclaims on behalf of all Contributors all
74
+ warranties and conditions, express and implied, including warranties or
75
+ conditions of title and non-infringement, and implied warranties or conditions
76
+ of merchantability and fitness for a particular purpose; ii) effectively
77
+ excludes on behalf of all Contributors all liability for damages, including
78
+ direct, indirect, special, incidental and consequential damages, such as lost
79
+ profits; iii) states that any provisions which differ from this Agreement are
80
+ offered by that Contributor alone and not by any other party; and iv) states
81
+ that source code for the Program is available from such Contributor, and informs
82
+ licensees how to obtain it in a reasonable manner on or through a medium
83
+ customarily used for software exchange.
84
+
85
+
86
+
87
+ When the Program is made available in source code form:
88
+
89
+ a) it must be made available under this Agreement; and b) a copy of this
90
+ Agreement must be included with each copy of the Program.
91
+
92
+
93
+
94
+ Contributors may not remove or alter any copyright notices contained within the
95
+ Program.
96
+
97
+ Each Contributor must identify itself as the originator of its Contribution, if
98
+ any, in a manner that reasonably allows subsequent Recipients to identify the
99
+ originator of the Contribution.
100
+
101
+ 4. COMMERCIAL DISTRIBUTION
102
+
103
+ Commercial distributors of software may accept certain responsibilities with
104
+ respect to end users, business partners and the like. While this license is
105
+ intended to facilitate the commercial use of the Program, the Contributor who
106
+ includes the Program in a commercial product offering should do so in a manner
107
+ which does not create potential liability for other Contributors. Therefore, if
108
+ a Contributor includes the Program in a commercial product offering, such
109
+ Contributor ("Commercial Contributor") hereby agrees to defend and indemnify
110
+ every other Contributor ("Indemnified Contributor") against any losses, damages
111
+ and costs (collectively "Losses") arising from claims, lawsuits and other legal
112
+ actions brought by a third party against the Indemnified Contributor to the
113
+ extent caused by the acts or omissions of such Commercial Contributor in
114
+ connection with its distribution of the Program in a commercial product
115
+ offering. The obligations in this section do not apply to any claims or Losses
116
+ relating to any actual or alleged intellectual property infringement. In order
117
+ to qualify, an Indemnified Contributor must: a) promptly notify the Commercial
118
+ Contributor in writing of such claim, and b) allow the Commercial Contributor to
119
+ control, and cooperate with the Commercial Contributor in, the defense and any
120
+ related settlement negotiations. The Indemnified Contributor may participate in
121
+ any such claim at its own expense.
122
+
123
+ For example, a Contributor might include the Program in a commercial product
124
+ offering, Product X. That Contributor is then a Commercial Contributor. If that
125
+ Commercial Contributor then makes performance claims, or offers warranties
126
+ related to Product X, those performance claims and warranties are such
127
+ Commercial Contributor's responsibility alone. Under this section, the
128
+ Commercial Contributor would have to defend claims against the other
129
+ Contributors related to those performance claims and warranties, and if a court
130
+ requires any other Contributor to pay any damages as a result, the Commercial
131
+ Contributor must pay those damages.
132
+
133
+ 5. NO WARRANTY
134
+
135
+ EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN
136
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR
137
+ IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE,
138
+ NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each
139
+ Recipient is solely responsible for determining the appropriateness of using and
140
+ distributing the Program and assumes all risks associated with its exercise of
141
+ rights under this Agreement , including but not limited to the risks and costs
142
+ of program errors, compliance with applicable laws, damage to or loss of data,
143
+ programs or equipment, and unavailability or interruption of operations.
144
+
145
+ 6. DISCLAIMER OF LIABILITY
146
+
147
+ EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY
148
+ CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL,
149
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST
150
+ PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
151
+ STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
152
+ OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS
153
+ GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
154
+
155
+ 7. GENERAL
156
+
157
+ If any provision of this Agreement is invalid or unenforceable under applicable
158
+ law, it shall not affect the validity or enforceability of the remainder of the
159
+ terms of this Agreement, and without further action by the parties hereto, such
160
+ provision shall be reformed to the minimum extent necessary to make such
161
+ provision valid and enforceable.
162
+
163
+ If Recipient institutes patent litigation against any entity (including a
164
+ cross-claim or counterclaim in a lawsuit) alleging that the Program itself
165
+ (excluding combinations of the Program with other software or hardware)
166
+ infringes such Recipient's patent(s), then such Recipient's rights granted under
167
+ Section 2(b) shall terminate as of the date such litigation is filed.
168
+
169
+ All Recipient's rights under this Agreement shall terminate if it fails to
170
+ comply with any of the material terms or conditions of this Agreement and does
171
+ not cure such failure in a reasonable period of time after becoming aware of
172
+ such noncompliance. If all Recipient's rights under this Agreement terminate,
173
+ Recipient agrees to cease use and distribution of the Program as soon as
174
+ reasonably practicable. However, Recipient's obligations under this Agreement
175
+ and any licenses granted by Recipient relating to the Program shall continue and
176
+ survive.
177
+
178
+ Everyone is permitted to copy and distribute copies of this Agreement, but in
179
+ order to avoid inconsistency the Agreement is copyrighted and may only be
180
+ modified in the following manner. The Agreement Steward reserves the right to
181
+ publish new versions (including revisions) of this Agreement from time to time.
182
+ No one other than the Agreement Steward has the right to modify this Agreement.
183
+ The Eclipse Foundation is the initial Agreement Steward. The Eclipse Foundation
184
+ may assign the responsibility to serve as the Agreement Steward to a suitable
185
+ separate entity. Each new version of the Agreement will be given a
186
+ distinguishing version number. The Program (including Contributions) may always
187
+ be distributed subject to the version of the Agreement under which it was
188
+ received. In addition, after a new version of the Agreement is published,
189
+ Contributor may elect to distribute the Program (including its Contributions)
190
+ under the new version. Except as expressly stated in Sections 2(a) and 2(b)
191
+ above, Recipient receives no rights or licenses to the intellectual property of
192
+ any Contributor under this Agreement, whether expressly, by implication,
193
+ estoppel or otherwise. All rights in the Program not expressly granted under
194
+ this Agreement are reserved.
195
+
196
+ This Agreement is governed by the laws of the State of New York and the
197
+ intellectual property laws of the United States of America. No party to this
198
+ Agreement will bring a legal action under this Agreement more than one year
199
+ after the cause of action arose. Each party waives its rights to a jury trial in
200
+ any resulting litigation.
@@ -0,0 +1,22 @@
1
+ Copyright (c) <%= Time.now.year %> <%= app_copyright %>
2
+
3
+ Redistribution and use in source and binary forms, with or without
4
+ modification, are permitted provided that the following conditions are met:
5
+
6
+ 1. Redistributions of source code must retain the above copyright notice, this
7
+ list of conditions and the following disclaimer.
8
+
9
+ 2. Redistributions in binary form must reproduce the above copyright notice,
10
+ this list of conditions and the following disclaimer in the documentation
11
+ and/or other materials provided with the distribution.
12
+
13
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"AND
14
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
15
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
16
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
17
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
19
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
20
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
21
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
22
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,17 @@
1
+ <%= app_name %>
2
+
3
+ Copyright (c) <%= Time.now.year %> <%= app_copyright %>
4
+
5
+ This program is free software; you can redistribute it and/or modify it under
6
+ the terms of the GNU General Public License as published by the Free Software
7
+ Foundation; either version 2 of the License, or (at your option) any later
8
+ version.
9
+
10
+ This program is distributed in the hope that it will be useful, but WITHOUT
11
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12
+ FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
13
+
14
+ You should have received a copy of the GNU General Public License along with
15
+ this program; if not, write to the Free Software Foundation, Inc., 59 Temple
16
+ Place, Suite 330, Boston, MA 02111-1307 USA
17
+
@@ -0,0 +1,16 @@
1
+ <%= app_name %>
2
+
3
+ Copyright (c) <%= Time.now.year %> <%= app_copyright %>
4
+
5
+ This program is free software: you can redistribute it and/or modify it under
6
+ the terms of the GNU General Public License as published by the Free Software
7
+ Foundation, either version 3 of the License, or (at your option) any later
8
+ version.
9
+
10
+ This program is distributed in the hope that it will be useful, but WITHOUT
11
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12
+ FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
13
+ details.
14
+
15
+ You should have received a copy of the GNU General Public License along with
16
+ this program. If not, see <http://www.gnu.org/licenses/>.
@@ -0,0 +1,19 @@
1
+ Copyright (c) <%= Time.now.year %> <%= app_copyright %>
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in all
11
+ copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
+ SOFTWARE.
@@ -0,0 +1,5 @@
1
+ Copyright (c) <%= Time.now.year %> <%= app_copyright %>
2
+
3
+ This Source Code Form is subject to the terms of the Mozilla Public License, v.
4
+ 2.0. If a copy of the MPL was not distributed with this file, You can obtain one
5
+ at https://mozilla.org/MPL/2.0/.
@@ -0,0 +1,26 @@
1
+ Copyright (c) <%= Time.now.year %> <%= app_copyright %>
2
+
3
+ Redistribution and use in source and binary forms, with or without
4
+ modification, are permitted provided that the following conditions are met:
5
+
6
+ 1. Redistributions of source code must retain the above copyright notice, this
7
+ list of conditions and the following disclaimer.
8
+
9
+ 2. Redistributions in binary form must reproduce the above copyright notice,
10
+ this list of conditions and the following disclaimer in the documentation
11
+ and/or other materials provided with the distribution.
12
+
13
+ 3. Neither the name of the copyright holder nor the names of its contributors
14
+ may be used to endorse or promote products derived from this software without
15
+ specific prior written permission.
16
+
17
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"AND
18
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
21
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
23
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
24
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
25
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,14 @@
1
+ require 'rake/testtask'
2
+
3
+ task :environment do
4
+ ENV['RACK_ENV'] ||= 'development'
5
+ require File.expand_path('../../config/environment', __dir__)
6
+ end
7
+
8
+ Rake::TestTask.new do |t|
9
+ t.libs << 'test'
10
+ t.test_files = FileList['test/**/*_test.rb']
11
+ t.warning = false
12
+ end
13
+
14
+ task default: :test
@@ -0,0 +1,11 @@
1
+ require 'minitest/reporters'
2
+
3
+ Minitest::Reporters.use!(
4
+ [
5
+ Minitest::Reporters::DefaultReporter.new(color: true),
6
+ # Minitest::Reporters::SpecReporter.new(color: true),
7
+ # Minitest::Reporters::ProgressReporter.new(color: true),
8
+ # Minitest::Reporters::MeanTimeReporter.new(color: true),
9
+ # Minitest::Reporters::HtmlReporter.new(color: true)
10
+ ]
11
+ )
@@ -0,0 +1,18 @@
1
+ class TestCase < Minitest::Test
2
+ def setup
3
+ DatabaseCleaner.start
4
+ end
5
+
6
+ def teardown
7
+ DatabaseCleaner.clean
8
+ end
9
+
10
+ fixture_names = Dir.glob('./test/fixtures/*.yml').map { |path| File.basename(path).sub(/\.yml$/, '') }
11
+ fixtures = ActiveRecord::FixtureSet.create_fixtures('test/fixtures', fixture_names)
12
+ fixtures.each do |fixture_set|
13
+ define_method fixture_set.name do |record_name|
14
+ id = fixture_set[record_name.to_s]['id']
15
+ fixture_set.model_class.find(id)
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,12 @@
1
+ ENV['RACK_ENV'] = 'test'
2
+
3
+ require 'minitest/autorun'
4
+ require_relative '../config/environment'
5
+ require 'active_record/fixtures'
6
+
7
+ ActiveRecord::Base.logger = nil
8
+ ActiveRecord::Migration.verbose = false
9
+
10
+ DatabaseCleaner.strategy = :transaction
11
+
12
+ require_rel './support/*'
@@ -0,0 +1,33 @@
1
+ default: &default
2
+ adapter: mysql2
3
+ encoding: utf8
4
+ port: 3306
5
+ reconnect: true
6
+
7
+ local: &local
8
+ <<: *default
9
+ username: root
10
+ password:
11
+ host: <% if app_docker? %>db<% else %>localhost<% end %>
12
+
13
+ remote: &remote
14
+ <<: *default
15
+ database: <%%= ENV['DB'] %%>
16
+ username: <%%= ENV['DB_USER'] %%>
17
+ password: <%%= ENV['DB_PASSWORD'] %%>
18
+ host: <%%= ENV['DB_HOST'] %%>
19
+ pool: 5
20
+
21
+ development:
22
+ <<: *local
23
+ database: <%= app_name.downcase %>_development
24
+
25
+ test:
26
+ <<: *local
27
+ database: <%= app_name.downcase %>_test
28
+
29
+ staging:
30
+ <<: *remote
31
+
32
+ production:
33
+ <<: *remote
@@ -0,0 +1,7 @@
1
+ /.bundle/
2
+ /coverage/
3
+ /doc/
4
+ /pkg/
5
+ /tmp/
6
+ /config/database.yml
7
+ *.swp
@@ -0,0 +1,13 @@
1
+ ---
2
+ app_name: <%= app_name %>
3
+ app_path: <%= app_path %>
4
+ app_prefix: <%= app_prefix %>
5
+ app_server: <%= app_server %>
6
+ app_test_framework: <%= app_test_framework %>
7
+ app_db: <%= app_db %>
8
+ app_orm: <%= app_orm %>
9
+ app_docker: <%= app_docker? %>
10
+ app_license: <%= app_license %>
11
+ app_copyright: <%= app_copyright %>
12
+ app_ruby: <%= app_ruby %>
13
+ app_swagger: <%= app_swagger? %>
@@ -0,0 +1,44 @@
1
+ source 'https://rubygems.org'
2
+
3
+ ruby '<%= app_ruby %>'
4
+
5
+ gem 'rack'
6
+ gem 'rack-cors'
7
+ gem 'grape'
8
+ gem 'grape-entity'
9
+ <% if app_swagger? -%>
10
+ gem 'grape-swagger'
11
+ <% end -%>
12
+ gem '<%= app_server %>'
13
+ gem 'require_all'
14
+
15
+ <% case app_db -%>
16
+ <% when 'sqlite' -%>
17
+ gem "sqlite3"<% if app_orm == 'activerecord' %>, '~> 1.3.6' <% end %>
18
+ <% when 'postgresql' -%>
19
+ gem 'pg'
20
+ <% when 'mysql' -%>
21
+ gem 'mysql2'
22
+ <% end -%>
23
+
24
+ <% if app_orm == 'activerecord' -%>
25
+ gem 'activerecord', require: 'active_record'
26
+ gem "otr-activerecord"
27
+ <% end -%>
28
+
29
+ group :development, :test do
30
+ gem 'rake'
31
+ end
32
+
33
+ group :test do
34
+ gem 'rack-test', require: 'rack/test'
35
+ <% case app_test_framework -%>
36
+ <% when 'minitest' -%>
37
+ gem 'minitest'
38
+ gem 'minitest-reporters'
39
+ <% when 'rspec' -%>
40
+ gem 'rspec'
41
+ gem 'factory_bot'
42
+ <% end -%>
43
+ gem 'database_cleaner'
44
+ end