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.
Files changed (153) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +49 -0
  3. data/CHANGELOG.md +5 -0
  4. data/README.md +233 -2
  5. data/example/rails-demo/.gitignore +33 -0
  6. data/example/rails-demo/.ruby-version +1 -0
  7. data/example/rails-demo/Gemfile +43 -0
  8. data/example/{rails5 → rails-demo}/README.md +0 -0
  9. data/example/rails-demo/Rakefile +6 -0
  10. data/example/rails-demo/app/channels/application_cable/channel.rb +4 -0
  11. data/example/rails-demo/app/channels/application_cable/connection.rb +4 -0
  12. data/example/rails-demo/app/controllers/application_controller.rb +2 -0
  13. data/example/rails-demo/app/controllers/books_controller.rb +48 -0
  14. data/example/{rails5/test/integration → rails-demo/app/controllers/concerns}/.keep +0 -0
  15. data/example/rails-demo/app/jobs/application_job.rb +7 -0
  16. data/example/rails-demo/app/mailers/application_mailer.rb +4 -0
  17. data/example/rails-demo/app/models/application_record.rb +3 -0
  18. data/example/rails-demo/app/models/book.rb +2 -0
  19. data/example/rails-demo/app/models/concerns/.keep +0 -0
  20. data/example/rails-demo/app/parameters/column.yml +5 -0
  21. data/example/rails-demo/app/views/layouts/mailer.html.erb +13 -0
  22. data/example/rails-demo/app/views/layouts/mailer.text.erb +1 -0
  23. data/example/rails-demo/bin/bundle +114 -0
  24. data/example/rails-demo/bin/rails +9 -0
  25. data/example/rails-demo/bin/rake +9 -0
  26. data/example/rails-demo/bin/setup +33 -0
  27. data/example/rails-demo/bin/spring +17 -0
  28. data/example/rails-demo/config/application.rb +37 -0
  29. data/example/rails-demo/config/boot.rb +4 -0
  30. data/example/rails-demo/config/cable.yml +10 -0
  31. data/example/rails-demo/config/credentials.yml.enc +1 -0
  32. data/example/rails-demo/config/database.yml +25 -0
  33. data/example/rails-demo/config/environment.rb +5 -0
  34. data/example/rails-demo/config/environments/development.rb +52 -0
  35. data/example/rails-demo/config/environments/production.rb +105 -0
  36. data/example/rails-demo/config/environments/test.rb +49 -0
  37. data/example/rails-demo/config/initializers/application_controller_renderer.rb +8 -0
  38. data/example/rails-demo/config/initializers/backtrace_silencers.rb +7 -0
  39. data/example/rails-demo/config/initializers/cors.rb +16 -0
  40. data/example/rails-demo/config/initializers/filter_parameter_logging.rb +4 -0
  41. data/example/rails-demo/config/initializers/inflections.rb +16 -0
  42. data/example/rails-demo/config/initializers/mime_types.rb +4 -0
  43. data/example/rails-demo/config/initializers/wrap_parameters.rb +14 -0
  44. data/example/rails-demo/config/locales/en.yml +33 -0
  45. data/example/rails-demo/config/puma.rb +38 -0
  46. data/example/rails-demo/config/routes.rb +5 -0
  47. data/example/rails-demo/config/spring.rb +6 -0
  48. data/example/rails-demo/config/storage.yml +34 -0
  49. data/example/rails-demo/config.ru +5 -0
  50. data/example/rails-demo/db/migrate/20211101020803_create_books.rb +11 -0
  51. data/example/rails-demo/db/schema.rb +31 -0
  52. data/example/rails-demo/db/seeds.rb +7 -0
  53. data/example/rails-demo/lib/tasks/.keep +0 -0
  54. data/example/rails-demo/log/.keep +0 -0
  55. data/example/rails-demo/public/robots.txt +1 -0
  56. data/example/rails-demo/storage/.keep +0 -0
  57. data/example/rails-demo/test/channels/application_cable/connection_test.rb +11 -0
  58. data/example/rails-demo/test/controllers/.keep +0 -0
  59. data/example/rails-demo/test/controllers/books_controller_test.rb +38 -0
  60. data/example/rails-demo/test/fixtures/.keep +0 -0
  61. data/example/rails-demo/test/fixtures/books.yml +11 -0
  62. data/example/rails-demo/test/fixtures/files/.keep +0 -0
  63. data/example/rails-demo/test/models/.keep +0 -0
  64. data/example/rails-demo/test/models/book_test.rb +7 -0
  65. data/example/rails-demo/test/test_helper.rb +13 -0
  66. data/example/rails-demo/tmp/.keep +0 -0
  67. data/example/rails-demo/tmp/pids/.keep +0 -0
  68. data/example/rails5/Gemfile +1 -1
  69. data/example/rails5/app/controllers/books_controller.rb +3 -5
  70. data/example/rails5/app/controllers/people_controller.rb +1 -1
  71. data/example/rails5/db/migrate/{20211031043641_create_people.rb → 20211031170917_create_people.rb} +2 -2
  72. data/example/rails5/db/schema.rb +3 -3
  73. data/example/rails5/test/controllers/books_controller_test.rb +2 -14
  74. data/example/rails5/test/controllers/people_controller_test.rb +2 -14
  75. data/example/rails5/test/fixtures/books.yml +8 -7
  76. data/example/rails5/test/fixtures/people.yml +8 -7
  77. data/example/rails6.0.0/.gitignore +33 -0
  78. data/example/rails6.0.0/.ruby-version +1 -0
  79. data/example/rails6.0.0/Gemfile +43 -0
  80. data/example/rails6.0.0/README.md +24 -0
  81. data/example/rails6.0.0/Rakefile +6 -0
  82. data/example/rails6.0.0/app/channels/application_cable/channel.rb +4 -0
  83. data/example/rails6.0.0/app/channels/application_cable/connection.rb +4 -0
  84. data/example/rails6.0.0/app/controllers/application_controller.rb +2 -0
  85. data/example/rails6.0.0/app/controllers/books_controller.rb +53 -0
  86. data/example/rails6.0.0/app/controllers/concerns/.keep +0 -0
  87. data/example/rails6.0.0/app/controllers/people_controller.rb +55 -0
  88. data/example/rails6.0.0/app/jobs/application_job.rb +7 -0
  89. data/example/rails6.0.0/app/mailers/application_mailer.rb +4 -0
  90. data/example/rails6.0.0/app/models/application_record.rb +3 -0
  91. data/example/rails6.0.0/app/models/book.rb +2 -0
  92. data/example/rails6.0.0/app/models/concerns/.keep +0 -0
  93. data/example/rails6.0.0/app/models/person.rb +2 -0
  94. data/example/rails6.0.0/app/parameters/column.yml +15 -0
  95. data/example/rails6.0.0/app/views/layouts/mailer.html.erb +13 -0
  96. data/example/rails6.0.0/app/views/layouts/mailer.text.erb +1 -0
  97. data/example/rails6.0.0/bin/bundle +114 -0
  98. data/example/rails6.0.0/bin/rails +9 -0
  99. data/example/rails6.0.0/bin/rake +9 -0
  100. data/example/rails6.0.0/bin/setup +33 -0
  101. data/example/rails6.0.0/bin/spring +17 -0
  102. data/example/rails6.0.0/config/application.rb +37 -0
  103. data/example/rails6.0.0/config/boot.rb +4 -0
  104. data/example/rails6.0.0/config/cable.yml +10 -0
  105. data/example/rails6.0.0/config/credentials.yml.enc +1 -0
  106. data/example/rails6.0.0/config/database.yml +25 -0
  107. data/example/rails6.0.0/config/environment.rb +5 -0
  108. data/example/rails6.0.0/config/environments/development.rb +52 -0
  109. data/example/rails6.0.0/config/environments/production.rb +105 -0
  110. data/example/rails6.0.0/config/environments/test.rb +49 -0
  111. data/example/rails6.0.0/config/initializers/application_controller_renderer.rb +8 -0
  112. data/example/rails6.0.0/config/initializers/backtrace_silencers.rb +7 -0
  113. data/example/rails6.0.0/config/initializers/cors.rb +16 -0
  114. data/example/rails6.0.0/config/initializers/filter_parameter_logging.rb +4 -0
  115. data/example/rails6.0.0/config/initializers/inflections.rb +16 -0
  116. data/example/rails6.0.0/config/initializers/mime_types.rb +4 -0
  117. data/example/rails6.0.0/config/initializers/wrap_parameters.rb +14 -0
  118. data/example/rails6.0.0/config/locales/en.yml +33 -0
  119. data/example/rails6.0.0/config/puma.rb +38 -0
  120. data/example/rails6.0.0/config/routes.rb +5 -0
  121. data/example/rails6.0.0/config/spring.rb +6 -0
  122. data/example/rails6.0.0/config/storage.yml +34 -0
  123. data/example/rails6.0.0/config.ru +5 -0
  124. data/example/rails6.0.0/db/migrate/20211031165333_create_people.rb +11 -0
  125. data/example/rails6.0.0/db/migrate/20211031165612_create_books.rb +11 -0
  126. data/example/rails6.0.0/db/schema.rb +31 -0
  127. data/example/rails6.0.0/db/seeds.rb +7 -0
  128. data/example/rails6.0.0/lib/tasks/.keep +0 -0
  129. data/example/rails6.0.0/log/.keep +0 -0
  130. data/example/rails6.0.0/public/robots.txt +1 -0
  131. data/example/rails6.0.0/storage/.keep +0 -0
  132. data/example/rails6.0.0/test/channels/application_cable/connection_test.rb +11 -0
  133. data/example/rails6.0.0/test/controllers/.keep +0 -0
  134. data/example/rails6.0.0/test/controllers/books_controller_test.rb +38 -0
  135. data/example/rails6.0.0/test/controllers/people_controller_test.rb +38 -0
  136. data/example/rails6.0.0/test/fixtures/.keep +0 -0
  137. data/example/rails6.0.0/test/fixtures/books.yml +11 -0
  138. data/example/rails6.0.0/test/fixtures/files/.keep +0 -0
  139. data/example/rails6.0.0/test/fixtures/people.yml +11 -0
  140. data/example/rails6.0.0/test/integration/.keep +0 -0
  141. data/example/rails6.0.0/test/test_helper.rb +13 -0
  142. data/example/rails6.0.0/tmp/.keep +0 -0
  143. data/example/rails6.0.0/tmp/pids/.keep +0 -0
  144. data/lib/yamls/helpers/config.rb +6 -0
  145. data/lib/yamls/helpers/yaml_load.rb +19 -0
  146. data/lib/yamls/parameters.rb +6 -6
  147. data/lib/yamls/support/parameters.rb +13 -1
  148. data/lib/yamls/support.rb +8 -0
  149. data/lib/yamls/version.rb +1 -1
  150. data/lib/yamls.rb +3 -2
  151. metadata +136 -7
  152. data/lib/yamls/config.rb +0 -4
  153. data/lib/yamls/yaml_load.rb +0 -17
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 183fe67e715399097c4512be7c0d62763c4704f8000fec7b87cbede246cea17e
4
- data.tar.gz: 1c95933c487b318623f39e1acd4eb6054883deb2131395962bc537683e3599ad
3
+ metadata.gz: 95135382a783cffc3c5095e2d464749065409c9f5aa06fe1e10b49aaf1ab22d3
4
+ data.tar.gz: '0618a4f351da6238b969b8919fbf65a906d1de9f5c63cce51b4d89a00ff70e31'
5
5
  SHA512:
6
- metadata.gz: eed6e4d64f7da2ace01abe30755cf5beae02bdb0d462eba55fed83089a6c299cf05a8150f5c33c0a8724e1b37840881a688e8edcb6744c813fc94d54845ee651
7
- data.tar.gz: 7a572b43cd5b08835d126c0a481e572183f8e66a066b776231e91df2e8ce97ce7f0a54f7024cebc0ddae8126fc77e621a14ca05acbedf53df79c5ecd556cc06b
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
@@ -3,3 +3,8 @@
3
3
  ## [0.1.0] - 2021-10-28
4
4
 
5
5
  - Initial release
6
+
7
+ ## [0.2.0] - 2021-11-1
8
+
9
+ - Add support function
10
+ - Add that can be include Yamls::Support::Parameters
data/README.md CHANGED
@@ -1,10 +1,11 @@
1
1
  # Yamls
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/yamls.svg)](https://badge.fury.io/rb/yamls)
3
4
  [![CircleCI](https://circleci.com/gh/TsuMakoto/yamls/tree/main.svg?style=svg)](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
- TODO: Delete this and the text above, and describe your gem
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
- TODO: Write usage instructions here
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,6 @@
1
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
2
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
+
4
+ require_relative 'config/application'
5
+
6
+ Rails.application.load_tasks
@@ -0,0 +1,4 @@
1
+ module ApplicationCable
2
+ class Channel < ActionCable::Channel::Base
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module ApplicationCable
2
+ class Connection < ActionCable::Connection::Base
3
+ end
4
+ end
@@ -0,0 +1,2 @@
1
+ class ApplicationController < ActionController::API
2
+ end
@@ -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
@@ -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
@@ -0,0 +1,4 @@
1
+ class ApplicationMailer < ActionMailer::Base
2
+ default from: 'from@example.com'
3
+ layout 'mailer'
4
+ end
@@ -0,0 +1,3 @@
1
+ class ApplicationRecord < ActiveRecord::Base
2
+ self.abstract_class = true
3
+ end
@@ -0,0 +1,2 @@
1
+ class Book < ApplicationRecord
2
+ end
File without changes
@@ -0,0 +1,5 @@
1
+ book:
2
+ create:
3
+ - name
4
+ - label
5
+ - value
@@ -0,0 +1,13 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5
+ <style>
6
+ /* Email styles need to be inline */
7
+ </style>
8
+ </head>
9
+
10
+ <body>
11
+ <%= yield %>
12
+ </body>
13
+ </html>
@@ -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'
@@ -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
+ require_relative '../config/boot'
8
+ require 'rake'
9
+ Rake.application.run