firetail 0.0.0 → 1.0.1
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/.github/pull_request_template.md +11 -0
- data/.github/workflows/main.yml +40 -0
- data/.gitignore +28 -0
- data/Gemfile +5 -0
- data/Gemfile.lock +74 -0
- data/LICENSE +165 -0
- data/LICENSE.txt +165 -21
- data/README.md +24 -10
- data/examples/rails/.gitattributes +8 -0
- data/examples/rails/.gitignore +31 -0
- data/examples/rails/.rspec +1 -0
- data/examples/rails/.ruby-version +1 -0
- data/examples/rails/Gemfile +44 -0
- data/examples/rails/Gemfile.lock +240 -0
- data/examples/rails/README.md +24 -0
- data/examples/rails/Rakefile +6 -0
- data/examples/rails/app/channels/application_cable/channel.rb +4 -0
- data/examples/rails/app/channels/application_cable/connection.rb +4 -0
- data/examples/rails/app/controllers/application_controller.rb +2 -0
- data/examples/rails/app/controllers/comments_controller.rb +52 -0
- data/examples/rails/app/controllers/concerns/.keep +0 -0
- data/examples/rails/app/controllers/posts_controller.rb +51 -0
- data/examples/rails/app/jobs/application_job.rb +7 -0
- data/examples/rails/app/mailers/application_mailer.rb +4 -0
- data/examples/rails/app/models/application_record.rb +3 -0
- data/examples/rails/app/models/comment.rb +4 -0
- data/examples/rails/app/models/concerns/.keep +0 -0
- data/examples/rails/app/models/post.rb +5 -0
- data/examples/rails/app/views/layouts/mailer.html.erb +13 -0
- data/examples/rails/app/views/layouts/mailer.text.erb +1 -0
- data/examples/rails/bin/bundle +114 -0
- data/examples/rails/bin/rails +5 -0
- data/examples/rails/bin/rake +5 -0
- data/examples/rails/bin/setup +33 -0
- data/examples/rails/bin/spring +14 -0
- data/examples/rails/config/application.rb +41 -0
- data/examples/rails/config/boot.rb +4 -0
- data/examples/rails/config/cable.yml +10 -0
- data/examples/rails/config/credentials.yml.enc +1 -0
- data/examples/rails/config/database.yml +25 -0
- data/examples/rails/config/environment.rb +5 -0
- data/examples/rails/config/environments/development.rb +66 -0
- data/examples/rails/config/environments/production.rb +113 -0
- data/examples/rails/config/environments/test.rb +60 -0
- data/examples/rails/config/firetail.yml +2 -0
- data/examples/rails/config/initializers/application_controller_renderer.rb +8 -0
- data/examples/rails/config/initializers/backtrace_silencers.rb +8 -0
- data/examples/rails/config/initializers/cors.rb +16 -0
- data/examples/rails/config/initializers/filter_parameter_logging.rb +6 -0
- data/examples/rails/config/initializers/inflections.rb +16 -0
- data/examples/rails/config/initializers/mime_types.rb +4 -0
- data/examples/rails/config/initializers/wrap_parameters.rb +14 -0
- data/examples/rails/config/locales/en.yml +33 -0
- data/examples/rails/config/puma.rb +43 -0
- data/examples/rails/config/routes.rb +6 -0
- data/examples/rails/config/schema.json +431 -0
- data/examples/rails/config/spring.rb +6 -0
- data/examples/rails/config/storage.yml +34 -0
- data/examples/rails/config.ru +6 -0
- data/examples/rails/db/migrate/20230730163722_create_posts.rb +8 -0
- data/examples/rails/db/migrate/20230730163741_create_comments.rb +9 -0
- data/examples/rails/db/migrate/20230730164121_add_fields_to_post.rb +6 -0
- data/examples/rails/db/migrate/20230730164214_add_fields_to_comments.rb +6 -0
- data/examples/rails/db/schema.rb +30 -0
- data/examples/rails/db/seeds.rb +7 -0
- data/examples/rails/lib/tasks/.keep +0 -0
- data/examples/rails/log/.keep +0 -0
- data/examples/rails/public/robots.txt +1 -0
- data/examples/rails/spec/models/comment_spec.rb +5 -0
- data/examples/rails/spec/models/post_spec.rb +5 -0
- data/examples/rails/spec/rails_helper.rb +63 -0
- data/examples/rails/spec/requests/comments_spec.rb +127 -0
- data/examples/rails/spec/requests/posts_spec.rb +127 -0
- data/examples/rails/spec/routing/comments_routing_spec.rb +30 -0
- data/examples/rails/spec/routing/posts_routing_spec.rb +30 -0
- data/examples/rails/spec/spec_helper.rb +94 -0
- data/examples/rails/storage/.keep +0 -0
- data/examples/rails/test/channels/application_cable/connection_test.rb +11 -0
- data/examples/rails/test/controllers/.keep +0 -0
- data/examples/rails/test/fixtures/files/.keep +0 -0
- data/examples/rails/test/integration/.keep +0 -0
- data/examples/rails/test/mailers/.keep +0 -0
- data/examples/rails/test/models/.keep +0 -0
- data/examples/rails/test/test_helper.rb +13 -0
- data/examples/rails/tmp/.keep +0 -0
- data/examples/rails/tmp/pids/.keep +0 -0
- data/examples/rails/vendor/.keep +0 -0
- data/firetail.gemspec +8 -1
- data/lib/backend.rb +34 -0
- data/lib/background_tasks.rb +43 -0
- data/lib/case_sensitive_headers.rb +29 -0
- data/lib/firetail/version.rb +1 -1
- data/lib/firetail.rb +264 -1
- data/lib/generators/firetail/install/templates/README +15 -0
- data/lib/generators/firetail/install/templates/firetail.yml +2 -0
- data/lib/generators/firetail/install/templates/schema.json +108 -0
- data/lib/generators/firetail/install_generator.rb +26 -0
- data/lib/railtie.rb +29 -0
- metadata +169 -8
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
source 'https://rubygems.org'
|
|
2
|
+
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
|
|
3
|
+
|
|
4
|
+
ruby '3.2.3'
|
|
5
|
+
|
|
6
|
+
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails', branch: 'main'
|
|
7
|
+
gem 'rails', '~> 6.1.7', '>= 6.1.7.4'
|
|
8
|
+
# Use sqlite3 as the database for Active Record
|
|
9
|
+
gem 'sqlite3', '~> 1.4'
|
|
10
|
+
# Use Puma as the app server
|
|
11
|
+
gem 'puma', '~> 5.0'
|
|
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.4', require: false
|
|
24
|
+
|
|
25
|
+
# Use Rack CORS for handling Cross-Origin Resource Sharing (CORS), making cross-origin AJAX possible
|
|
26
|
+
# gem 'rack-cors'
|
|
27
|
+
|
|
28
|
+
group :development, :test do
|
|
29
|
+
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
|
|
30
|
+
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
|
|
31
|
+
gem "rspec", "= 3.12"
|
|
32
|
+
gem "rspec-rails"
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
group :development do
|
|
36
|
+
gem 'listen', '~> 3.3'
|
|
37
|
+
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
|
|
38
|
+
gem 'spring'
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
|
|
42
|
+
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
|
|
43
|
+
|
|
44
|
+
gem "firetail", "~> 1.0.1"
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: ../..
|
|
3
|
+
specs:
|
|
4
|
+
firetail (0.0.1.pre.alpha)
|
|
5
|
+
async (~> 1.30.3)
|
|
6
|
+
committee_firetail (~> 5.0.1)
|
|
7
|
+
json-schema (~> 3.0.0)
|
|
8
|
+
jwt (~> 2.5)
|
|
9
|
+
|
|
10
|
+
GEM
|
|
11
|
+
remote: https://rubygems.org/
|
|
12
|
+
specs:
|
|
13
|
+
actioncable (6.1.7.4)
|
|
14
|
+
actionpack (= 6.1.7.4)
|
|
15
|
+
activesupport (= 6.1.7.4)
|
|
16
|
+
nio4r (~> 2.0)
|
|
17
|
+
websocket-driver (>= 0.6.1)
|
|
18
|
+
actionmailbox (6.1.7.4)
|
|
19
|
+
actionpack (= 6.1.7.4)
|
|
20
|
+
activejob (= 6.1.7.4)
|
|
21
|
+
activerecord (= 6.1.7.4)
|
|
22
|
+
activestorage (= 6.1.7.4)
|
|
23
|
+
activesupport (= 6.1.7.4)
|
|
24
|
+
mail (>= 2.7.1)
|
|
25
|
+
actionmailer (6.1.7.4)
|
|
26
|
+
actionpack (= 6.1.7.4)
|
|
27
|
+
actionview (= 6.1.7.4)
|
|
28
|
+
activejob (= 6.1.7.4)
|
|
29
|
+
activesupport (= 6.1.7.4)
|
|
30
|
+
mail (~> 2.5, >= 2.5.4)
|
|
31
|
+
rails-dom-testing (~> 2.0)
|
|
32
|
+
actionpack (6.1.7.4)
|
|
33
|
+
actionview (= 6.1.7.4)
|
|
34
|
+
activesupport (= 6.1.7.4)
|
|
35
|
+
rack (~> 2.0, >= 2.0.9)
|
|
36
|
+
rack-test (>= 0.6.3)
|
|
37
|
+
rails-dom-testing (~> 2.0)
|
|
38
|
+
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
|
39
|
+
actiontext (6.1.7.4)
|
|
40
|
+
actionpack (= 6.1.7.4)
|
|
41
|
+
activerecord (= 6.1.7.4)
|
|
42
|
+
activestorage (= 6.1.7.4)
|
|
43
|
+
activesupport (= 6.1.7.4)
|
|
44
|
+
nokogiri (>= 1.8.5)
|
|
45
|
+
actionview (6.1.7.4)
|
|
46
|
+
activesupport (= 6.1.7.4)
|
|
47
|
+
builder (~> 3.1)
|
|
48
|
+
erubi (~> 1.4)
|
|
49
|
+
rails-dom-testing (~> 2.0)
|
|
50
|
+
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
|
51
|
+
activejob (6.1.7.4)
|
|
52
|
+
activesupport (= 6.1.7.4)
|
|
53
|
+
globalid (>= 0.3.6)
|
|
54
|
+
activemodel (6.1.7.4)
|
|
55
|
+
activesupport (= 6.1.7.4)
|
|
56
|
+
activerecord (6.1.7.4)
|
|
57
|
+
activemodel (= 6.1.7.4)
|
|
58
|
+
activesupport (= 6.1.7.4)
|
|
59
|
+
activestorage (6.1.7.4)
|
|
60
|
+
actionpack (= 6.1.7.4)
|
|
61
|
+
activejob (= 6.1.7.4)
|
|
62
|
+
activerecord (= 6.1.7.4)
|
|
63
|
+
activesupport (= 6.1.7.4)
|
|
64
|
+
marcel (~> 1.0)
|
|
65
|
+
mini_mime (>= 1.1.0)
|
|
66
|
+
activesupport (6.1.7.4)
|
|
67
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
|
68
|
+
i18n (>= 1.6, < 2)
|
|
69
|
+
minitest (>= 5.1)
|
|
70
|
+
tzinfo (~> 2.0)
|
|
71
|
+
zeitwerk (~> 2.3)
|
|
72
|
+
addressable (2.8.6)
|
|
73
|
+
public_suffix (>= 2.0.2, < 6.0)
|
|
74
|
+
async (1.30.3)
|
|
75
|
+
console (~> 1.10)
|
|
76
|
+
nio4r (~> 2.3)
|
|
77
|
+
timers (~> 4.1)
|
|
78
|
+
base64 (0.2.0)
|
|
79
|
+
bootsnap (1.16.0)
|
|
80
|
+
msgpack (~> 1.2)
|
|
81
|
+
builder (3.2.4)
|
|
82
|
+
byebug (11.1.3)
|
|
83
|
+
committee_firetail (5.0.1)
|
|
84
|
+
json_schema (~> 0.14, >= 0.14.3)
|
|
85
|
+
openapi_parser (~> 2.1.0)
|
|
86
|
+
rack (>= 1.5)
|
|
87
|
+
concurrent-ruby (1.2.2)
|
|
88
|
+
console (1.24.0)
|
|
89
|
+
fiber-annotation
|
|
90
|
+
fiber-local
|
|
91
|
+
json
|
|
92
|
+
crass (1.0.6)
|
|
93
|
+
date (3.3.3)
|
|
94
|
+
diff-lcs (1.5.0)
|
|
95
|
+
erubi (1.12.0)
|
|
96
|
+
ffi (1.15.5)
|
|
97
|
+
fiber-annotation (0.2.0)
|
|
98
|
+
fiber-local (1.0.0)
|
|
99
|
+
globalid (1.1.0)
|
|
100
|
+
activesupport (>= 5.0)
|
|
101
|
+
i18n (1.14.1)
|
|
102
|
+
concurrent-ruby (~> 1.0)
|
|
103
|
+
json (2.7.2)
|
|
104
|
+
json-schema (3.0.0)
|
|
105
|
+
addressable (>= 2.8)
|
|
106
|
+
json_schema (0.21.0)
|
|
107
|
+
jwt (2.8.1)
|
|
108
|
+
base64
|
|
109
|
+
listen (3.8.0)
|
|
110
|
+
rb-fsevent (~> 0.10, >= 0.10.3)
|
|
111
|
+
rb-inotify (~> 0.9, >= 0.9.10)
|
|
112
|
+
loofah (2.21.3)
|
|
113
|
+
crass (~> 1.0.2)
|
|
114
|
+
nokogiri (>= 1.12.0)
|
|
115
|
+
mail (2.8.1)
|
|
116
|
+
mini_mime (>= 0.1.1)
|
|
117
|
+
net-imap
|
|
118
|
+
net-pop
|
|
119
|
+
net-smtp
|
|
120
|
+
marcel (1.0.2)
|
|
121
|
+
method_source (1.0.0)
|
|
122
|
+
mini_mime (1.1.2)
|
|
123
|
+
mini_portile2 (2.8.4)
|
|
124
|
+
minitest (5.19.0)
|
|
125
|
+
msgpack (1.7.2)
|
|
126
|
+
net-imap (0.3.7)
|
|
127
|
+
date
|
|
128
|
+
net-protocol
|
|
129
|
+
net-pop (0.1.2)
|
|
130
|
+
net-protocol
|
|
131
|
+
net-protocol (0.2.1)
|
|
132
|
+
timeout
|
|
133
|
+
net-smtp (0.3.3)
|
|
134
|
+
net-protocol
|
|
135
|
+
nio4r (2.5.9)
|
|
136
|
+
nokogiri (1.15.3)
|
|
137
|
+
mini_portile2 (~> 2.8.2)
|
|
138
|
+
racc (~> 1.4)
|
|
139
|
+
openapi_parser (2.1.0)
|
|
140
|
+
public_suffix (5.0.5)
|
|
141
|
+
puma (5.6.6)
|
|
142
|
+
nio4r (~> 2.0)
|
|
143
|
+
racc (1.7.1)
|
|
144
|
+
rack (2.2.7)
|
|
145
|
+
rack-test (2.1.0)
|
|
146
|
+
rack (>= 1.3)
|
|
147
|
+
rails (6.1.7.4)
|
|
148
|
+
actioncable (= 6.1.7.4)
|
|
149
|
+
actionmailbox (= 6.1.7.4)
|
|
150
|
+
actionmailer (= 6.1.7.4)
|
|
151
|
+
actionpack (= 6.1.7.4)
|
|
152
|
+
actiontext (= 6.1.7.4)
|
|
153
|
+
actionview (= 6.1.7.4)
|
|
154
|
+
activejob (= 6.1.7.4)
|
|
155
|
+
activemodel (= 6.1.7.4)
|
|
156
|
+
activerecord (= 6.1.7.4)
|
|
157
|
+
activestorage (= 6.1.7.4)
|
|
158
|
+
activesupport (= 6.1.7.4)
|
|
159
|
+
bundler (>= 1.15.0)
|
|
160
|
+
railties (= 6.1.7.4)
|
|
161
|
+
sprockets-rails (>= 2.0.0)
|
|
162
|
+
rails-dom-testing (2.1.1)
|
|
163
|
+
activesupport (>= 5.0.0)
|
|
164
|
+
minitest
|
|
165
|
+
nokogiri (>= 1.6)
|
|
166
|
+
rails-html-sanitizer (1.6.0)
|
|
167
|
+
loofah (~> 2.21)
|
|
168
|
+
nokogiri (~> 1.14)
|
|
169
|
+
railties (6.1.7.4)
|
|
170
|
+
actionpack (= 6.1.7.4)
|
|
171
|
+
activesupport (= 6.1.7.4)
|
|
172
|
+
method_source
|
|
173
|
+
rake (>= 12.2)
|
|
174
|
+
thor (~> 1.0)
|
|
175
|
+
rake (13.0.6)
|
|
176
|
+
rb-fsevent (0.11.2)
|
|
177
|
+
rb-inotify (0.10.1)
|
|
178
|
+
ffi (~> 1.0)
|
|
179
|
+
rspec (3.12.0)
|
|
180
|
+
rspec-core (~> 3.12.0)
|
|
181
|
+
rspec-expectations (~> 3.12.0)
|
|
182
|
+
rspec-mocks (~> 3.12.0)
|
|
183
|
+
rspec-core (3.12.2)
|
|
184
|
+
rspec-support (~> 3.12.0)
|
|
185
|
+
rspec-expectations (3.12.3)
|
|
186
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
187
|
+
rspec-support (~> 3.12.0)
|
|
188
|
+
rspec-mocks (3.12.6)
|
|
189
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
190
|
+
rspec-support (~> 3.12.0)
|
|
191
|
+
rspec-rails (6.0.3)
|
|
192
|
+
actionpack (>= 6.1)
|
|
193
|
+
activesupport (>= 6.1)
|
|
194
|
+
railties (>= 6.1)
|
|
195
|
+
rspec-core (~> 3.12)
|
|
196
|
+
rspec-expectations (~> 3.12)
|
|
197
|
+
rspec-mocks (~> 3.12)
|
|
198
|
+
rspec-support (~> 3.12)
|
|
199
|
+
rspec-support (3.12.1)
|
|
200
|
+
spring (4.1.1)
|
|
201
|
+
sprockets (4.2.0)
|
|
202
|
+
concurrent-ruby (~> 1.0)
|
|
203
|
+
rack (>= 2.2.4, < 4)
|
|
204
|
+
sprockets-rails (3.4.2)
|
|
205
|
+
actionpack (>= 5.2)
|
|
206
|
+
activesupport (>= 5.2)
|
|
207
|
+
sprockets (>= 3.0.0)
|
|
208
|
+
sqlite3 (1.6.3)
|
|
209
|
+
mini_portile2 (~> 2.8.0)
|
|
210
|
+
thor (1.2.2)
|
|
211
|
+
timeout (0.4.0)
|
|
212
|
+
timers (4.3.5)
|
|
213
|
+
tzinfo (2.0.6)
|
|
214
|
+
concurrent-ruby (~> 1.0)
|
|
215
|
+
websocket-driver (0.7.6)
|
|
216
|
+
websocket-extensions (>= 0.1.0)
|
|
217
|
+
websocket-extensions (0.1.5)
|
|
218
|
+
zeitwerk (2.6.9)
|
|
219
|
+
|
|
220
|
+
PLATFORMS
|
|
221
|
+
ruby
|
|
222
|
+
|
|
223
|
+
DEPENDENCIES
|
|
224
|
+
bootsnap (>= 1.4.4)
|
|
225
|
+
byebug
|
|
226
|
+
firetail!
|
|
227
|
+
listen (~> 3.3)
|
|
228
|
+
puma (~> 5.0)
|
|
229
|
+
rails (~> 6.1.7, >= 6.1.7.4)
|
|
230
|
+
rspec (= 3.12)
|
|
231
|
+
rspec-rails
|
|
232
|
+
spring
|
|
233
|
+
sqlite3 (~> 1.4)
|
|
234
|
+
tzinfo-data
|
|
235
|
+
|
|
236
|
+
RUBY VERSION
|
|
237
|
+
ruby 3.2.3p157
|
|
238
|
+
|
|
239
|
+
BUNDLED WITH
|
|
240
|
+
2.1.4
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# README
|
|
2
|
+
|
|
3
|
+
This README would normally document whatever steps are necessary to get the
|
|
4
|
+
application up and running.
|
|
5
|
+
|
|
6
|
+
Things you may want to cover:
|
|
7
|
+
|
|
8
|
+
* Ruby version
|
|
9
|
+
|
|
10
|
+
* System dependencies
|
|
11
|
+
|
|
12
|
+
* Configuration
|
|
13
|
+
|
|
14
|
+
* Database creation
|
|
15
|
+
|
|
16
|
+
* Database initialization
|
|
17
|
+
|
|
18
|
+
* How to run the test suite
|
|
19
|
+
|
|
20
|
+
* Services (job queues, cache servers, search engines, etc.)
|
|
21
|
+
|
|
22
|
+
* Deployment instructions
|
|
23
|
+
|
|
24
|
+
* ...
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
class CommentsController < ApplicationController
|
|
2
|
+
before_action :set_comment, only: [:show, :update, :destroy]
|
|
3
|
+
|
|
4
|
+
# GET /comments
|
|
5
|
+
def index
|
|
6
|
+
@comments = Comment.all
|
|
7
|
+
|
|
8
|
+
render json: @comments
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
# GET /comments/1
|
|
12
|
+
def show
|
|
13
|
+
render json: @comment
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# POST /comments
|
|
17
|
+
def create
|
|
18
|
+
@post = Post.find(params[:post_id])
|
|
19
|
+
@comment = @post.comments.new(comment_params)
|
|
20
|
+
|
|
21
|
+
if @comment.save
|
|
22
|
+
render json: @comment, status: :created
|
|
23
|
+
else
|
|
24
|
+
render json: @comment.errors, status: :unprocessable_entity
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
# PATCH/PUT /comments/1
|
|
29
|
+
def update
|
|
30
|
+
if @comment.update(comment_params)
|
|
31
|
+
render json: @comment
|
|
32
|
+
else
|
|
33
|
+
render json: @comment.errors, status: :unprocessable_entity
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
# DELETE /comments/1
|
|
38
|
+
def destroy
|
|
39
|
+
@comment.destroy
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
private
|
|
43
|
+
# Use callbacks to share common setup or constraints between actions.
|
|
44
|
+
def set_comment
|
|
45
|
+
@comment = Comment.find(params[:id])
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
# Only allow a list of trusted parameters through.
|
|
49
|
+
def comment_params
|
|
50
|
+
params.require(:comment).permit(:message, :post_id)
|
|
51
|
+
end
|
|
52
|
+
end
|
|
File without changes
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
class PostsController < ApplicationController
|
|
2
|
+
before_action :set_post, only: [:show, :update, :destroy]
|
|
3
|
+
|
|
4
|
+
# GET /posts
|
|
5
|
+
def index
|
|
6
|
+
@posts = Post.all
|
|
7
|
+
|
|
8
|
+
render json: @posts
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
# GET /posts/1
|
|
12
|
+
def show
|
|
13
|
+
render json: @post
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# POST /posts
|
|
17
|
+
def create
|
|
18
|
+
@post = Post.new(post_params)
|
|
19
|
+
|
|
20
|
+
if @post.save
|
|
21
|
+
render json: @post, status: :created, location: @post
|
|
22
|
+
else
|
|
23
|
+
render json: @post.errors, status: :unprocessable_entity
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# PATCH/PUT /posts/1
|
|
28
|
+
def update
|
|
29
|
+
if @post.update(post_params)
|
|
30
|
+
render json: @post
|
|
31
|
+
else
|
|
32
|
+
render json: @post.errors, status: :unprocessable_entity
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# DELETE /posts/1
|
|
37
|
+
def destroy
|
|
38
|
+
@post.destroy
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
private
|
|
42
|
+
# Use callbacks to share common setup or constraints between actions.
|
|
43
|
+
def set_post
|
|
44
|
+
@post = Post.find(params[:id])
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
# Only allow a list of trusted parameters through.
|
|
48
|
+
def post_params
|
|
49
|
+
params.require(:post).permit(:title, :content, comments: [:message])
|
|
50
|
+
end
|
|
51
|
+
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
|
|
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,33 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
require "fileutils"
|
|
3
|
+
|
|
4
|
+
# path to your application root.
|
|
5
|
+
APP_ROOT = File.expand_path('..', __dir__)
|
|
6
|
+
|
|
7
|
+
def system!(*args)
|
|
8
|
+
system(*args) || abort("\n== Command #{args} failed ==")
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
FileUtils.chdir APP_ROOT do
|
|
12
|
+
# This script is a way to set up or update your development environment automatically.
|
|
13
|
+
# This script is idempotent, so that you can run it at any time and get an expectable outcome.
|
|
14
|
+
# Add necessary setup steps to this file.
|
|
15
|
+
|
|
16
|
+
puts '== Installing dependencies =='
|
|
17
|
+
system! 'gem install bundler --conservative'
|
|
18
|
+
system('bundle check') || system!('bundle install')
|
|
19
|
+
|
|
20
|
+
# puts "\n== Copying sample files =="
|
|
21
|
+
# unless File.exist?('config/database.yml')
|
|
22
|
+
# FileUtils.cp 'config/database.yml.sample', 'config/database.yml'
|
|
23
|
+
# end
|
|
24
|
+
|
|
25
|
+
puts "\n== Preparing database =="
|
|
26
|
+
system! 'bin/rails db:prepare'
|
|
27
|
+
|
|
28
|
+
puts "\n== Removing old logs and tempfiles =="
|
|
29
|
+
system! 'bin/rails log:clear tmp:clear'
|
|
30
|
+
|
|
31
|
+
puts "\n== Restarting application server =="
|
|
32
|
+
system! 'bin/rails restart'
|
|
33
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
if !defined?(Spring) && [nil, "development", "test"].include?(ENV["RAILS_ENV"])
|
|
3
|
+
gem "bundler"
|
|
4
|
+
require "bundler"
|
|
5
|
+
|
|
6
|
+
# Load Spring without loading other gems in the Gemfile, for speed.
|
|
7
|
+
Bundler.locked_gems&.specs&.find { |spec| spec.name == "spring" }&.tap do |spring|
|
|
8
|
+
Gem.use_paths Gem.dir, Bundler.bundle_path.to_s, *Gem.path
|
|
9
|
+
gem "spring", spring.version
|
|
10
|
+
require "spring/binstub"
|
|
11
|
+
rescue Gem::LoadError
|
|
12
|
+
# Ignore when Spring is not installed.
|
|
13
|
+
end
|
|
14
|
+
end
|