yamls 0.1.3 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.circleci/config.yml +49 -0
- data/CHANGELOG.md +5 -0
- data/README.md +233 -2
- data/example/rails-demo/.gitignore +33 -0
- data/example/rails-demo/.ruby-version +1 -0
- data/example/rails-demo/Gemfile +43 -0
- data/example/{rails5 → rails-demo}/README.md +0 -0
- data/example/rails-demo/Rakefile +6 -0
- data/example/rails-demo/app/channels/application_cable/channel.rb +4 -0
- data/example/rails-demo/app/channels/application_cable/connection.rb +4 -0
- data/example/rails-demo/app/controllers/application_controller.rb +2 -0
- data/example/rails-demo/app/controllers/books_controller.rb +48 -0
- data/example/{rails5/test/integration → rails-demo/app/controllers/concerns}/.keep +0 -0
- data/example/rails-demo/app/jobs/application_job.rb +7 -0
- data/example/rails-demo/app/mailers/application_mailer.rb +4 -0
- data/example/rails-demo/app/models/application_record.rb +3 -0
- data/example/rails-demo/app/models/book.rb +2 -0
- data/example/rails-demo/app/models/concerns/.keep +0 -0
- data/example/rails-demo/app/parameters/column.yml +5 -0
- data/example/rails-demo/app/views/layouts/mailer.html.erb +13 -0
- data/example/rails-demo/app/views/layouts/mailer.text.erb +1 -0
- data/example/rails-demo/bin/bundle +114 -0
- data/example/rails-demo/bin/rails +9 -0
- data/example/rails-demo/bin/rake +9 -0
- data/example/rails-demo/bin/setup +33 -0
- data/example/rails-demo/bin/spring +17 -0
- data/example/rails-demo/config/application.rb +37 -0
- data/example/rails-demo/config/boot.rb +4 -0
- data/example/rails-demo/config/cable.yml +10 -0
- data/example/rails-demo/config/credentials.yml.enc +1 -0
- data/example/rails-demo/config/database.yml +25 -0
- data/example/rails-demo/config/environment.rb +5 -0
- data/example/rails-demo/config/environments/development.rb +52 -0
- data/example/rails-demo/config/environments/production.rb +105 -0
- data/example/rails-demo/config/environments/test.rb +49 -0
- data/example/rails-demo/config/initializers/application_controller_renderer.rb +8 -0
- data/example/rails-demo/config/initializers/backtrace_silencers.rb +7 -0
- data/example/rails-demo/config/initializers/cors.rb +16 -0
- data/example/rails-demo/config/initializers/filter_parameter_logging.rb +4 -0
- data/example/rails-demo/config/initializers/inflections.rb +16 -0
- data/example/rails-demo/config/initializers/mime_types.rb +4 -0
- data/example/rails-demo/config/initializers/wrap_parameters.rb +14 -0
- data/example/rails-demo/config/locales/en.yml +33 -0
- data/example/rails-demo/config/puma.rb +38 -0
- data/example/rails-demo/config/routes.rb +5 -0
- data/example/rails-demo/config/spring.rb +6 -0
- data/example/rails-demo/config/storage.yml +34 -0
- data/example/rails-demo/config.ru +5 -0
- data/example/rails-demo/db/migrate/20211101020803_create_books.rb +11 -0
- data/example/rails-demo/db/schema.rb +31 -0
- data/example/rails-demo/db/seeds.rb +7 -0
- data/example/rails-demo/lib/tasks/.keep +0 -0
- data/example/rails-demo/log/.keep +0 -0
- data/example/rails-demo/public/robots.txt +1 -0
- data/example/rails-demo/storage/.keep +0 -0
- data/example/rails-demo/test/channels/application_cable/connection_test.rb +11 -0
- data/example/rails-demo/test/controllers/.keep +0 -0
- data/example/rails-demo/test/controllers/books_controller_test.rb +38 -0
- data/example/rails-demo/test/fixtures/.keep +0 -0
- data/example/rails-demo/test/fixtures/books.yml +11 -0
- data/example/rails-demo/test/fixtures/files/.keep +0 -0
- data/example/rails-demo/test/models/.keep +0 -0
- data/example/rails-demo/test/models/book_test.rb +7 -0
- data/example/rails-demo/test/test_helper.rb +13 -0
- data/example/rails-demo/tmp/.keep +0 -0
- data/example/rails-demo/tmp/pids/.keep +0 -0
- data/example/rails5/Gemfile +1 -1
- data/example/rails5/app/controllers/books_controller.rb +3 -5
- data/example/rails5/app/controllers/people_controller.rb +1 -1
- data/example/rails5/db/migrate/{20211031043641_create_people.rb → 20211031170917_create_people.rb} +2 -2
- data/example/rails5/db/schema.rb +3 -3
- data/example/rails5/test/controllers/books_controller_test.rb +2 -14
- data/example/rails5/test/controllers/people_controller_test.rb +2 -14
- data/example/rails5/test/fixtures/books.yml +8 -7
- data/example/rails5/test/fixtures/people.yml +8 -7
- data/example/rails6.0.0/.gitignore +33 -0
- data/example/rails6.0.0/.ruby-version +1 -0
- data/example/rails6.0.0/Gemfile +43 -0
- data/example/rails6.0.0/README.md +24 -0
- data/example/rails6.0.0/Rakefile +6 -0
- data/example/rails6.0.0/app/channels/application_cable/channel.rb +4 -0
- data/example/rails6.0.0/app/channels/application_cable/connection.rb +4 -0
- data/example/rails6.0.0/app/controllers/application_controller.rb +2 -0
- data/example/rails6.0.0/app/controllers/books_controller.rb +53 -0
- data/example/rails6.0.0/app/controllers/concerns/.keep +0 -0
- data/example/rails6.0.0/app/controllers/people_controller.rb +55 -0
- data/example/rails6.0.0/app/jobs/application_job.rb +7 -0
- data/example/rails6.0.0/app/mailers/application_mailer.rb +4 -0
- data/example/rails6.0.0/app/models/application_record.rb +3 -0
- data/example/rails6.0.0/app/models/book.rb +2 -0
- data/example/rails6.0.0/app/models/concerns/.keep +0 -0
- data/example/rails6.0.0/app/models/person.rb +2 -0
- data/example/rails6.0.0/app/parameters/column.yml +15 -0
- data/example/rails6.0.0/app/views/layouts/mailer.html.erb +13 -0
- data/example/rails6.0.0/app/views/layouts/mailer.text.erb +1 -0
- data/example/rails6.0.0/bin/bundle +114 -0
- data/example/rails6.0.0/bin/rails +9 -0
- data/example/rails6.0.0/bin/rake +9 -0
- data/example/rails6.0.0/bin/setup +33 -0
- data/example/rails6.0.0/bin/spring +17 -0
- data/example/rails6.0.0/config/application.rb +37 -0
- data/example/rails6.0.0/config/boot.rb +4 -0
- data/example/rails6.0.0/config/cable.yml +10 -0
- data/example/rails6.0.0/config/credentials.yml.enc +1 -0
- data/example/rails6.0.0/config/database.yml +25 -0
- data/example/rails6.0.0/config/environment.rb +5 -0
- data/example/rails6.0.0/config/environments/development.rb +52 -0
- data/example/rails6.0.0/config/environments/production.rb +105 -0
- data/example/rails6.0.0/config/environments/test.rb +49 -0
- data/example/rails6.0.0/config/initializers/application_controller_renderer.rb +8 -0
- data/example/rails6.0.0/config/initializers/backtrace_silencers.rb +7 -0
- data/example/rails6.0.0/config/initializers/cors.rb +16 -0
- data/example/rails6.0.0/config/initializers/filter_parameter_logging.rb +4 -0
- data/example/rails6.0.0/config/initializers/inflections.rb +16 -0
- data/example/rails6.0.0/config/initializers/mime_types.rb +4 -0
- data/example/rails6.0.0/config/initializers/wrap_parameters.rb +14 -0
- data/example/rails6.0.0/config/locales/en.yml +33 -0
- data/example/rails6.0.0/config/puma.rb +38 -0
- data/example/rails6.0.0/config/routes.rb +5 -0
- data/example/rails6.0.0/config/spring.rb +6 -0
- data/example/rails6.0.0/config/storage.yml +34 -0
- data/example/rails6.0.0/config.ru +5 -0
- data/example/rails6.0.0/db/migrate/20211031165333_create_people.rb +11 -0
- data/example/rails6.0.0/db/migrate/20211031165612_create_books.rb +11 -0
- data/example/rails6.0.0/db/schema.rb +31 -0
- data/example/rails6.0.0/db/seeds.rb +7 -0
- data/example/rails6.0.0/lib/tasks/.keep +0 -0
- data/example/rails6.0.0/log/.keep +0 -0
- data/example/rails6.0.0/public/robots.txt +1 -0
- data/example/rails6.0.0/storage/.keep +0 -0
- data/example/rails6.0.0/test/channels/application_cable/connection_test.rb +11 -0
- data/example/rails6.0.0/test/controllers/.keep +0 -0
- data/example/rails6.0.0/test/controllers/books_controller_test.rb +38 -0
- data/example/rails6.0.0/test/controllers/people_controller_test.rb +38 -0
- data/example/rails6.0.0/test/fixtures/.keep +0 -0
- data/example/rails6.0.0/test/fixtures/books.yml +11 -0
- data/example/rails6.0.0/test/fixtures/files/.keep +0 -0
- data/example/rails6.0.0/test/fixtures/people.yml +11 -0
- data/example/rails6.0.0/test/integration/.keep +0 -0
- data/example/rails6.0.0/test/test_helper.rb +13 -0
- data/example/rails6.0.0/tmp/.keep +0 -0
- data/example/rails6.0.0/tmp/pids/.keep +0 -0
- data/lib/yamls/helpers/config.rb +6 -0
- data/lib/yamls/helpers/yaml_load.rb +19 -0
- data/lib/yamls/parameters.rb +6 -6
- data/lib/yamls/support/parameters.rb +13 -1
- data/lib/yamls/support.rb +8 -0
- data/lib/yamls/version.rb +1 -1
- data/lib/yamls.rb +3 -2
- metadata +136 -7
- data/lib/yamls/config.rb +0 -4
- data/lib/yamls/yaml_load.rb +0 -17
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 95135382a783cffc3c5095e2d464749065409c9f5aa06fe1e10b49aaf1ab22d3
|
|
4
|
+
data.tar.gz: '0618a4f351da6238b969b8919fbf65a906d1de9f5c63cce51b4d89a00ff70e31'
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2c8f84381f2d76891a2a4c3e62cd52b5a441ee5dc23f5ed4253dabc30469fa73fd3926940a88694f188b44c3fef27e05c673c176ad52709017b5af54ac7590ec
|
|
7
|
+
data.tar.gz: 12692960dc0e66af945b5576a1fb5620ffbbfa81c040e4a1859d0383f0ca7c41ee64f0380f3feabc0efb4f3a7be09a67286781021c181015ca9bd2b550de463c
|
data/.circleci/config.yml
CHANGED
|
@@ -48,6 +48,49 @@ jobs:
|
|
|
48
48
|
name: Run test
|
|
49
49
|
command: cd example/rails5 && bundle exec rake test
|
|
50
50
|
|
|
51
|
+
test_rails6_0_0:
|
|
52
|
+
docker:
|
|
53
|
+
- image: cimg/ruby:3.0.2-node
|
|
54
|
+
executor: ruby/default
|
|
55
|
+
steps:
|
|
56
|
+
- checkout
|
|
57
|
+
- run:
|
|
58
|
+
name: Install dependencies
|
|
59
|
+
command: sudo apt-get update -y && sudo apt-get install -y libsqlite3-dev
|
|
60
|
+
- run:
|
|
61
|
+
name: Which bundler?
|
|
62
|
+
command: bundle -v
|
|
63
|
+
- run:
|
|
64
|
+
name: Bundle install
|
|
65
|
+
command: cd example/rails6.0.0 && bundle install --path vendor/bundle
|
|
66
|
+
- run:
|
|
67
|
+
name: Setup db
|
|
68
|
+
command: cd example/rails6.0.0 && bundle exec rails db:migrate
|
|
69
|
+
- run:
|
|
70
|
+
name: Run test
|
|
71
|
+
command: cd example/rails6.0.0 && bundle exec rake test
|
|
72
|
+
|
|
73
|
+
test_rails_demo:
|
|
74
|
+
docker:
|
|
75
|
+
- image: cimg/ruby:3.0.2-node
|
|
76
|
+
executor: ruby/default
|
|
77
|
+
steps:
|
|
78
|
+
- checkout
|
|
79
|
+
- run:
|
|
80
|
+
name: Install dependencies
|
|
81
|
+
command: sudo apt-get update -y && sudo apt-get install -y libsqlite3-dev
|
|
82
|
+
- run:
|
|
83
|
+
name: Which bundler?
|
|
84
|
+
command: bundle -v
|
|
85
|
+
- run:
|
|
86
|
+
name: Bundle install
|
|
87
|
+
command: cd example/rails-demo && bundle install --path vendor/bundle
|
|
88
|
+
- run:
|
|
89
|
+
name: Setup db
|
|
90
|
+
command: cd example/rails-demo && bundle exec rails db:migrate
|
|
91
|
+
- run:
|
|
92
|
+
name: Run test
|
|
93
|
+
command: cd example/rails-demo && bundle exec rake test
|
|
51
94
|
|
|
52
95
|
# Invoke jobs via workflows
|
|
53
96
|
# See: https://circleci.com/docs/2.0/configuration-reference/#workflows
|
|
@@ -59,3 +102,9 @@ workflows:
|
|
|
59
102
|
- test_rails5:
|
|
60
103
|
requires:
|
|
61
104
|
- build
|
|
105
|
+
- test_rails6_0_0:
|
|
106
|
+
requires:
|
|
107
|
+
- build
|
|
108
|
+
- test_rails_demo:
|
|
109
|
+
requires:
|
|
110
|
+
- build
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
# Yamls
|
|
2
2
|
|
|
3
|
+
[](https://badge.fury.io/rb/yamls)
|
|
3
4
|
[](https://circleci.com/gh/TsuMakoto/yamls/tree/main)
|
|
4
5
|
|
|
5
6
|
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/yamls`. To experiment with that code, run `bin/console` for an interactive prompt.
|
|
6
7
|
|
|
7
|
-
|
|
8
|
+
A gem that simplifies strong parameters that lengthen the code in Rails.
|
|
8
9
|
|
|
9
10
|
## Installation
|
|
10
11
|
|
|
@@ -24,7 +25,237 @@ Or install it yourself as:
|
|
|
24
25
|
|
|
25
26
|
## Usage
|
|
26
27
|
|
|
27
|
-
|
|
28
|
+
In ActionController:
|
|
29
|
+
|
|
30
|
+
Before:
|
|
31
|
+
|
|
32
|
+
```ruby
|
|
33
|
+
def person_params
|
|
34
|
+
params
|
|
35
|
+
.require(:person)
|
|
36
|
+
.permit(
|
|
37
|
+
:name,
|
|
38
|
+
:email,
|
|
39
|
+
:first_name,
|
|
40
|
+
:last_name,
|
|
41
|
+
:age,
|
|
42
|
+
:role,
|
|
43
|
+
# ....other
|
|
44
|
+
)
|
|
45
|
+
end
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Use gem:
|
|
49
|
+
|
|
50
|
+
```ruby
|
|
51
|
+
def person_params
|
|
52
|
+
Yamls::Parameters.new(
|
|
53
|
+
params,
|
|
54
|
+
model: :person,
|
|
55
|
+
action: :post
|
|
56
|
+
).permit
|
|
57
|
+
end
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
In Yaml file (default: app/parameters/column.yml):
|
|
61
|
+
|
|
62
|
+
```yml
|
|
63
|
+
person:
|
|
64
|
+
post:
|
|
65
|
+
- name
|
|
66
|
+
- email
|
|
67
|
+
- first_name
|
|
68
|
+
- last_name
|
|
69
|
+
- age
|
|
70
|
+
- role
|
|
71
|
+
# ... other
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### Include support function
|
|
75
|
+
|
|
76
|
+
If action_name and controller_name(with singularize) are the same as yaml configuration, it can be described below.
|
|
77
|
+
|
|
78
|
+
```ruby
|
|
79
|
+
class BooksController < ApplicationController
|
|
80
|
+
include Yamls::Support::Parameters
|
|
81
|
+
|
|
82
|
+
def action_name_1
|
|
83
|
+
params = yamls
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
def action_name_2
|
|
87
|
+
params = yamls
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
def action_name_3
|
|
91
|
+
params = yamls
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
In Yaml file:
|
|
97
|
+
|
|
98
|
+
```yml
|
|
99
|
+
book:
|
|
100
|
+
action_name_1:
|
|
101
|
+
# set columns
|
|
102
|
+
action_name_2:
|
|
103
|
+
# set columns
|
|
104
|
+
action_name_3:
|
|
105
|
+
# set columns
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
Define method:
|
|
109
|
+
|
|
110
|
+
```ruby
|
|
111
|
+
class BooksController < ApplicationController
|
|
112
|
+
include Yamls::Support::Parameters
|
|
113
|
+
|
|
114
|
+
def action_name_1
|
|
115
|
+
params = book_action_name_1_params # {controller_name.singularize}_{action_name}_params
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
def action_name_2
|
|
119
|
+
params = book_action_name_2_params
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
def action_name_3
|
|
123
|
+
params = book_action_name_3_params
|
|
124
|
+
end
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
### Initialize configuration
|
|
130
|
+
|
|
131
|
+
1) If you want to specify a file:
|
|
132
|
+
|
|
133
|
+
```ruby
|
|
134
|
+
Yamls::Parameters.new(
|
|
135
|
+
params,
|
|
136
|
+
file_path: "path/to/column.yml"
|
|
137
|
+
)
|
|
138
|
+
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
2) Nested parameters:
|
|
142
|
+
|
|
143
|
+
In Yaml file:
|
|
144
|
+
|
|
145
|
+
```yml
|
|
146
|
+
main:
|
|
147
|
+
nested1:
|
|
148
|
+
nested2:
|
|
149
|
+
nested3:
|
|
150
|
+
- name
|
|
151
|
+
- label
|
|
152
|
+
- values:
|
|
153
|
+
- a_site
|
|
154
|
+
- b_site
|
|
155
|
+
- c_site
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
Request params:
|
|
159
|
+
|
|
160
|
+
```json
|
|
161
|
+
|
|
162
|
+
{
|
|
163
|
+
"books": {
|
|
164
|
+
"name": "Books name",
|
|
165
|
+
"label": "Books label",
|
|
166
|
+
"values": {
|
|
167
|
+
"a_site": 1000,
|
|
168
|
+
"b_site": 2000,
|
|
169
|
+
"c_site": 3000
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
In controller:
|
|
177
|
+
|
|
178
|
+
```ruby
|
|
179
|
+
Yamls::Parameters.new(
|
|
180
|
+
params,
|
|
181
|
+
required: :book,
|
|
182
|
+
nested: %i[main nested1 nested2 nested3]
|
|
183
|
+
)
|
|
184
|
+
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
3) Model specification only:
|
|
188
|
+
|
|
189
|
+
If the parameters of create and update are the same, you want to combine them into one.
|
|
190
|
+
|
|
191
|
+
```yml
|
|
192
|
+
book:
|
|
193
|
+
- name
|
|
194
|
+
- label
|
|
195
|
+
- value
|
|
196
|
+
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
```ruby
|
|
200
|
+
Yamls::Parameters.new(
|
|
201
|
+
params,
|
|
202
|
+
model: :book,
|
|
203
|
+
)
|
|
204
|
+
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
4) If you don't need a require method chain:
|
|
208
|
+
|
|
209
|
+
```yml
|
|
210
|
+
book:
|
|
211
|
+
- name
|
|
212
|
+
- label
|
|
213
|
+
- value
|
|
214
|
+
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
Request params:
|
|
218
|
+
|
|
219
|
+
```json
|
|
220
|
+
|
|
221
|
+
{
|
|
222
|
+
"name": "Books name",
|
|
223
|
+
"label": "Books label",
|
|
224
|
+
"value": 1000
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
In controller:
|
|
230
|
+
|
|
231
|
+
```ruby
|
|
232
|
+
Yamls::Parameters.new(
|
|
233
|
+
params,
|
|
234
|
+
nested: %i[book] # if you have a yaml with multi level
|
|
235
|
+
)
|
|
236
|
+
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
or
|
|
240
|
+
|
|
241
|
+
```ruby
|
|
242
|
+
Yamls::Parameters.new(
|
|
243
|
+
params,
|
|
244
|
+
model: :book,
|
|
245
|
+
required: nil
|
|
246
|
+
)
|
|
247
|
+
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
```ruby
|
|
251
|
+
Yamls::Parameters.new(
|
|
252
|
+
params,
|
|
253
|
+
action: :book,
|
|
254
|
+
required: nil
|
|
255
|
+
)
|
|
256
|
+
|
|
257
|
+
```
|
|
258
|
+
|
|
28
259
|
|
|
29
260
|
## Development
|
|
30
261
|
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# See https://help.github.com/articles/ignoring-files for more about ignoring files.
|
|
2
|
+
#
|
|
3
|
+
# If you find yourself ignoring temporary files generated by your text editor
|
|
4
|
+
# or operating system, you probably want to add a global ignore instead:
|
|
5
|
+
# git config --global core.excludesfile '~/.gitignore_global'
|
|
6
|
+
|
|
7
|
+
# Ignore bundler config.
|
|
8
|
+
/.bundle
|
|
9
|
+
|
|
10
|
+
# Ignore the default SQLite database.
|
|
11
|
+
/db/*.sqlite3
|
|
12
|
+
/db/*.sqlite3-journal
|
|
13
|
+
/db/*.sqlite3-*
|
|
14
|
+
|
|
15
|
+
# Ignore all logfiles and tempfiles.
|
|
16
|
+
/log/*
|
|
17
|
+
/tmp/*
|
|
18
|
+
!/log/.keep
|
|
19
|
+
!/tmp/.keep
|
|
20
|
+
|
|
21
|
+
# Ignore pidfiles, but keep the directory.
|
|
22
|
+
/tmp/pids/*
|
|
23
|
+
!/tmp/pids/
|
|
24
|
+
!/tmp/pids/.keep
|
|
25
|
+
|
|
26
|
+
# Ignore uploaded files in development.
|
|
27
|
+
/storage/*
|
|
28
|
+
!/storage/.keep
|
|
29
|
+
.byebug_history
|
|
30
|
+
|
|
31
|
+
# Ignore master key for decrypting credentials and more.
|
|
32
|
+
/config/master.key
|
|
33
|
+
/vendor/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
3.0.2
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
source 'https://rubygems.org'
|
|
2
|
+
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
|
|
3
|
+
|
|
4
|
+
ruby '3.0.2'
|
|
5
|
+
|
|
6
|
+
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails', branch: 'main'
|
|
7
|
+
gem 'rails', '~> 6.0.4', '>= 6.0.4.1'
|
|
8
|
+
# Use sqlite3 as the database for Active Record
|
|
9
|
+
gem 'sqlite3', '~> 1.4'
|
|
10
|
+
# Use Puma as the app server
|
|
11
|
+
gem 'puma', '~> 4.1'
|
|
12
|
+
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
|
|
13
|
+
# gem 'jbuilder', '~> 2.7'
|
|
14
|
+
# Use Redis adapter to run Action Cable in production
|
|
15
|
+
# gem 'redis', '~> 4.0'
|
|
16
|
+
# Use Active Model has_secure_password
|
|
17
|
+
# gem 'bcrypt', '~> 3.1.7'
|
|
18
|
+
|
|
19
|
+
# Use Active Storage variant
|
|
20
|
+
# gem 'image_processing', '~> 1.2'
|
|
21
|
+
|
|
22
|
+
# Reduces boot times through caching; required in config/boot.rb
|
|
23
|
+
gem 'bootsnap', '>= 1.4.2', require: false
|
|
24
|
+
|
|
25
|
+
gem 'yamls', path: "../../"
|
|
26
|
+
|
|
27
|
+
# Use Rack CORS for handling Cross-Origin Resource Sharing (CORS), making cross-origin AJAX possible
|
|
28
|
+
# gem 'rack-cors'
|
|
29
|
+
|
|
30
|
+
group :development, :test do
|
|
31
|
+
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
|
|
32
|
+
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
group :development do
|
|
36
|
+
gem 'listen', '~> 3.2'
|
|
37
|
+
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
|
|
38
|
+
gem 'spring'
|
|
39
|
+
gem 'spring-watcher-listen', '~> 2.0.0'
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
|
|
43
|
+
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
|
|
File without changes
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
class BooksController < ApplicationController
|
|
2
|
+
before_action :set_book, only: [:show, :update, :destroy]
|
|
3
|
+
|
|
4
|
+
include Yamls::Support::Parameters
|
|
5
|
+
|
|
6
|
+
# GET /books
|
|
7
|
+
def index
|
|
8
|
+
@books = Book.all
|
|
9
|
+
|
|
10
|
+
render json: @books
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
# GET /books/1
|
|
14
|
+
def show
|
|
15
|
+
render json: @book
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
# POST /books
|
|
19
|
+
def create
|
|
20
|
+
@book = Book.new(book_create_params)
|
|
21
|
+
|
|
22
|
+
if @book.save
|
|
23
|
+
render json: @book, status: :created, location: @book
|
|
24
|
+
else
|
|
25
|
+
render json: @book.errors, status: :unprocessable_entity
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
# PATCH/PUT /books/1
|
|
30
|
+
def update
|
|
31
|
+
if @book.update(book_update_params)
|
|
32
|
+
render json: @book
|
|
33
|
+
else
|
|
34
|
+
render json: @book.errors, status: :unprocessable_entity
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
# DELETE /books/1
|
|
39
|
+
def destroy
|
|
40
|
+
@book.destroy
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
private
|
|
44
|
+
# Use callbacks to share common setup or constraints between actions.
|
|
45
|
+
def set_book
|
|
46
|
+
@book = Book.find(params[:id])
|
|
47
|
+
end
|
|
48
|
+
end
|
|
File without changes
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
class ApplicationJob < ActiveJob::Base
|
|
2
|
+
# Automatically retry jobs that encountered a deadlock
|
|
3
|
+
# retry_on ActiveRecord::Deadlocked
|
|
4
|
+
|
|
5
|
+
# Most jobs are safe to ignore if the underlying records are no longer available
|
|
6
|
+
# discard_on ActiveJob::DeserializationError
|
|
7
|
+
end
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<%= yield %>
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
#
|
|
5
|
+
# This file was generated by Bundler.
|
|
6
|
+
#
|
|
7
|
+
# The application 'bundle' is installed as part of a gem, and
|
|
8
|
+
# this file is here to facilitate running it.
|
|
9
|
+
#
|
|
10
|
+
|
|
11
|
+
require "rubygems"
|
|
12
|
+
|
|
13
|
+
m = Module.new do
|
|
14
|
+
module_function
|
|
15
|
+
|
|
16
|
+
def invoked_as_script?
|
|
17
|
+
File.expand_path($0) == File.expand_path(__FILE__)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def env_var_version
|
|
21
|
+
ENV["BUNDLER_VERSION"]
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def cli_arg_version
|
|
25
|
+
return unless invoked_as_script? # don't want to hijack other binstubs
|
|
26
|
+
return unless "update".start_with?(ARGV.first || " ") # must be running `bundle update`
|
|
27
|
+
bundler_version = nil
|
|
28
|
+
update_index = nil
|
|
29
|
+
ARGV.each_with_index do |a, i|
|
|
30
|
+
if update_index && update_index.succ == i && a =~ Gem::Version::ANCHORED_VERSION_PATTERN
|
|
31
|
+
bundler_version = a
|
|
32
|
+
end
|
|
33
|
+
next unless a =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/
|
|
34
|
+
bundler_version = $1
|
|
35
|
+
update_index = i
|
|
36
|
+
end
|
|
37
|
+
bundler_version
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def gemfile
|
|
41
|
+
gemfile = ENV["BUNDLE_GEMFILE"]
|
|
42
|
+
return gemfile if gemfile && !gemfile.empty?
|
|
43
|
+
|
|
44
|
+
File.expand_path("../../Gemfile", __FILE__)
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def lockfile
|
|
48
|
+
lockfile =
|
|
49
|
+
case File.basename(gemfile)
|
|
50
|
+
when "gems.rb" then gemfile.sub(/\.rb$/, gemfile)
|
|
51
|
+
else "#{gemfile}.lock"
|
|
52
|
+
end
|
|
53
|
+
File.expand_path(lockfile)
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def lockfile_version
|
|
57
|
+
return unless File.file?(lockfile)
|
|
58
|
+
lockfile_contents = File.read(lockfile)
|
|
59
|
+
return unless lockfile_contents =~ /\n\nBUNDLED WITH\n\s{2,}(#{Gem::Version::VERSION_PATTERN})\n/
|
|
60
|
+
Regexp.last_match(1)
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def bundler_version
|
|
64
|
+
@bundler_version ||=
|
|
65
|
+
env_var_version || cli_arg_version ||
|
|
66
|
+
lockfile_version
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def bundler_requirement
|
|
70
|
+
return "#{Gem::Requirement.default}.a" unless bundler_version
|
|
71
|
+
|
|
72
|
+
bundler_gem_version = Gem::Version.new(bundler_version)
|
|
73
|
+
|
|
74
|
+
requirement = bundler_gem_version.approximate_recommendation
|
|
75
|
+
|
|
76
|
+
return requirement unless Gem::Version.new(Gem::VERSION) < Gem::Version.new("2.7.0")
|
|
77
|
+
|
|
78
|
+
requirement += ".a" if bundler_gem_version.prerelease?
|
|
79
|
+
|
|
80
|
+
requirement
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def load_bundler!
|
|
84
|
+
ENV["BUNDLE_GEMFILE"] ||= gemfile
|
|
85
|
+
|
|
86
|
+
activate_bundler
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
def activate_bundler
|
|
90
|
+
gem_error = activation_error_handling do
|
|
91
|
+
gem "bundler", bundler_requirement
|
|
92
|
+
end
|
|
93
|
+
return if gem_error.nil?
|
|
94
|
+
require_error = activation_error_handling do
|
|
95
|
+
require "bundler/version"
|
|
96
|
+
end
|
|
97
|
+
return if require_error.nil? && Gem::Requirement.new(bundler_requirement).satisfied_by?(Gem::Version.new(Bundler::VERSION))
|
|
98
|
+
warn "Activating bundler (#{bundler_requirement}) failed:\n#{gem_error.message}\n\nTo install the version of bundler this project requires, run `gem install bundler -v '#{bundler_requirement}'`"
|
|
99
|
+
exit 42
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
def activation_error_handling
|
|
103
|
+
yield
|
|
104
|
+
nil
|
|
105
|
+
rescue StandardError, LoadError => e
|
|
106
|
+
e
|
|
107
|
+
end
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
m.load_bundler!
|
|
111
|
+
|
|
112
|
+
if m.invoked_as_script?
|
|
113
|
+
load Gem.bin_path("bundler", "bundle")
|
|
114
|
+
end
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
begin
|
|
3
|
+
load File.expand_path('../spring', __FILE__)
|
|
4
|
+
rescue LoadError => e
|
|
5
|
+
raise unless e.message.include?('spring')
|
|
6
|
+
end
|
|
7
|
+
APP_PATH = File.expand_path('../config/application', __dir__)
|
|
8
|
+
require_relative '../config/boot'
|
|
9
|
+
require 'rails/commands'
|