grape-app 0.8.6 → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/test.yml +24 -0
- data/.rubocop.yml +9 -3
- data/Gemfile.lock +81 -83
- data/Gemfile.rails6 +6 -0
- data/Gemfile.rails6.lock +150 -0
- data/grape-app.gemspec +6 -4
- data/lib/grape/app/initializers/post.rb +0 -7
- data/lib/grape/app/initializers/pre.rb +66 -0
- data/lib/grape/app/middleware/connection_management.rb +12 -0
- data/lib/grape/app/middleware.rb +5 -0
- data/lib/grape/app/templates/app/api/v1.rb +2 -1
- data/lib/grape/app/templates/config/environments/production.rb +12 -5
- data/lib/grape/app/templates/spec/spec_helper.rb +1 -1
- data/lib/grape/app.rb +17 -4
- data/spec/grape/app/helpers/caching_spec.rb +42 -10
- data/spec/grape/app/helpers/params_spec.rb +20 -4
- data/spec/grape/app/middleware/connection_management_spec.rb +22 -0
- data/spec/grape/app_spec.rb +41 -10
- data/spec/scenario/config/environments/test.rb +1 -0
- data/spec/spec_helper.rb +9 -62
- metadata +35 -14
- data/.travis.yml +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a02f28a09a9bf9ac9f5222de88c553958c3984017e2b589dd0ad2f1850503513
|
4
|
+
data.tar.gz: 869efcb8480678cff8924d6001cf3342cf0ae9558577a7d856ed572e8d3e2eef
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b989f27b49f52f4247518dc5bb485de10d08149ca7da7eb912a53b8e6875bc68d82f8798bbd4d7e086e934b73523fbb384ff1359bc193153fe8f9baf59fa6180
|
7
|
+
data.tar.gz: 01d7a80d34def80bf67e85b55ebd47b274c16b0acb384bd86ea41fca9b5fa99da305966d700824a1113e900e4cc11b03907f28c13e0751baf23ecfec17fca8bb
|
@@ -0,0 +1,24 @@
|
|
1
|
+
name: Test
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches: [main]
|
6
|
+
pull_request:
|
7
|
+
branches: [main]
|
8
|
+
|
9
|
+
jobs:
|
10
|
+
test:
|
11
|
+
runs-on: ubuntu-latest
|
12
|
+
strategy:
|
13
|
+
matrix:
|
14
|
+
ruby-version: ["2.7", "3.0", "3.1"]
|
15
|
+
gemfiles: ["Gemfile", "Gemfile.rails6"]
|
16
|
+
env:
|
17
|
+
BUNDLE_GEMFILE: ${{ matrix.gemfile }}
|
18
|
+
steps:
|
19
|
+
- uses: actions/checkout@v2
|
20
|
+
- uses: ruby/setup-ruby@v1
|
21
|
+
with:
|
22
|
+
ruby-version: ${{ matrix.ruby-version }}
|
23
|
+
bundler-cache: true
|
24
|
+
- run: bundle exec rake
|
data/.rubocop.yml
CHANGED
@@ -1,8 +1,14 @@
|
|
1
|
-
|
2
|
-
-
|
1
|
+
inherit_gem:
|
2
|
+
rubocop-bsm:
|
3
|
+
- default.yml
|
4
|
+
inherit_mode:
|
5
|
+
merge:
|
6
|
+
- Exclude
|
3
7
|
|
4
8
|
AllCops:
|
5
|
-
TargetRubyVersion: "2.
|
9
|
+
TargetRubyVersion: "2.7"
|
6
10
|
Metrics/ParameterLists:
|
7
11
|
Exclude:
|
8
12
|
- lib/grape/app/helpers/caching.rb
|
13
|
+
Rake/Desc:
|
14
|
+
Enabled: false
|
data/Gemfile.lock
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
grape-app (0.
|
4
|
+
grape-app (0.10.0)
|
5
5
|
activesupport
|
6
6
|
grape (>= 1.2)
|
7
7
|
grape-entity
|
8
|
+
openssl
|
8
9
|
rack-cors (>= 1.1)
|
9
10
|
rack-ssl-enforcer
|
10
11
|
thor
|
@@ -13,73 +14,64 @@ PATH
|
|
13
14
|
GEM
|
14
15
|
remote: https://rubygems.org/
|
15
16
|
specs:
|
16
|
-
|
17
|
-
activesupport (=
|
18
|
-
|
19
|
-
|
20
|
-
activesupport (=
|
21
|
-
|
17
|
+
activejob (7.0.1)
|
18
|
+
activesupport (= 7.0.1)
|
19
|
+
globalid (>= 0.3.6)
|
20
|
+
activemodel (7.0.1)
|
21
|
+
activesupport (= 7.0.1)
|
22
|
+
activerecord (7.0.1)
|
23
|
+
activemodel (= 7.0.1)
|
24
|
+
activesupport (= 7.0.1)
|
25
|
+
activesupport (7.0.1)
|
22
26
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
23
|
-
i18n (>=
|
24
|
-
minitest (
|
25
|
-
tzinfo (~>
|
26
|
-
|
27
|
-
ast (2.4.1)
|
28
|
-
axiom-types (0.1.1)
|
29
|
-
descendants_tracker (~> 0.0.4)
|
30
|
-
ice_nine (~> 0.11.0)
|
31
|
-
thread_safe (~> 0.3, >= 0.3.1)
|
27
|
+
i18n (>= 1.6, < 2)
|
28
|
+
minitest (>= 5.1)
|
29
|
+
tzinfo (~> 2.0)
|
30
|
+
ast (2.4.2)
|
32
31
|
builder (3.2.4)
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
descendants_tracker (0.0.4)
|
37
|
-
thread_safe (~> 0.3, >= 0.3.1)
|
38
|
-
diff-lcs (1.4.4)
|
39
|
-
dry-configurable (0.11.6)
|
32
|
+
concurrent-ruby (1.1.9)
|
33
|
+
diff-lcs (1.5.0)
|
34
|
+
dry-configurable (0.14.0)
|
40
35
|
concurrent-ruby (~> 1.0)
|
41
|
-
dry-core (~> 0.
|
42
|
-
|
43
|
-
dry-container (0.7.2)
|
36
|
+
dry-core (~> 0.6)
|
37
|
+
dry-container (0.9.0)
|
44
38
|
concurrent-ruby (~> 1.0)
|
45
|
-
dry-configurable (~> 0.
|
46
|
-
dry-core (0.
|
39
|
+
dry-configurable (~> 0.13, >= 0.13.0)
|
40
|
+
dry-core (0.7.1)
|
47
41
|
concurrent-ruby (~> 1.0)
|
48
|
-
dry-
|
49
|
-
dry-
|
50
|
-
dry-logic (1.0.6)
|
42
|
+
dry-inflector (0.2.1)
|
43
|
+
dry-logic (1.2.0)
|
51
44
|
concurrent-ruby (~> 1.0)
|
52
|
-
dry-core (~> 0.
|
53
|
-
|
54
|
-
dry-types (1.4.0)
|
45
|
+
dry-core (~> 0.5, >= 0.5)
|
46
|
+
dry-types (1.5.1)
|
55
47
|
concurrent-ruby (~> 1.0)
|
56
48
|
dry-container (~> 0.3)
|
57
|
-
dry-core (~> 0.
|
58
|
-
dry-equalizer (~> 0.3)
|
49
|
+
dry-core (~> 0.5, >= 0.5)
|
59
50
|
dry-inflector (~> 0.1, >= 0.1.2)
|
60
51
|
dry-logic (~> 1.0, >= 1.0.2)
|
61
|
-
|
62
|
-
|
52
|
+
globalid (1.0.0)
|
53
|
+
activesupport (>= 5.0)
|
54
|
+
grape (1.6.2)
|
63
55
|
activesupport
|
64
56
|
builder
|
65
57
|
dry-types (>= 1.1)
|
66
58
|
mustermann-grape (~> 1.0.0)
|
67
59
|
rack (>= 1.3.0)
|
68
60
|
rack-accept
|
69
|
-
grape-entity (0.
|
61
|
+
grape-entity (0.10.1)
|
70
62
|
activesupport (>= 3.0.0)
|
71
63
|
multi_json (>= 1.3.2)
|
72
|
-
i18n (1.
|
64
|
+
i18n (1.9.1)
|
73
65
|
concurrent-ruby (~> 1.0)
|
74
|
-
|
75
|
-
|
76
|
-
multi_json (1.14.1)
|
66
|
+
minitest (5.15.0)
|
67
|
+
multi_json (1.15.0)
|
77
68
|
mustermann (1.1.1)
|
78
69
|
ruby2_keywords (~> 0.0.1)
|
79
70
|
mustermann-grape (1.0.1)
|
80
71
|
mustermann (>= 1.0.0)
|
81
|
-
|
82
|
-
|
72
|
+
openssl (3.0.0)
|
73
|
+
parallel (1.21.0)
|
74
|
+
parser (3.1.0.0)
|
83
75
|
ast (~> 2.4.1)
|
84
76
|
rack (2.2.3)
|
85
77
|
rack-accept (0.4.5)
|
@@ -89,62 +81,68 @@ GEM
|
|
89
81
|
rack-ssl-enforcer (0.2.9)
|
90
82
|
rack-test (1.1.0)
|
91
83
|
rack (>= 1.0, < 3)
|
92
|
-
rainbow (3.
|
93
|
-
rake (13.0.
|
94
|
-
regexp_parser (
|
95
|
-
rexml (3.2.
|
96
|
-
rspec (3.
|
97
|
-
rspec-core (~> 3.
|
98
|
-
rspec-expectations (~> 3.
|
99
|
-
rspec-mocks (~> 3.
|
100
|
-
rspec-core (3.
|
101
|
-
rspec-support (~> 3.
|
102
|
-
rspec-expectations (3.
|
84
|
+
rainbow (3.1.1)
|
85
|
+
rake (13.0.6)
|
86
|
+
regexp_parser (2.2.0)
|
87
|
+
rexml (3.2.5)
|
88
|
+
rspec (3.10.0)
|
89
|
+
rspec-core (~> 3.10.0)
|
90
|
+
rspec-expectations (~> 3.10.0)
|
91
|
+
rspec-mocks (~> 3.10.0)
|
92
|
+
rspec-core (3.10.2)
|
93
|
+
rspec-support (~> 3.10.0)
|
94
|
+
rspec-expectations (3.10.2)
|
103
95
|
diff-lcs (>= 1.2.0, < 2.0)
|
104
|
-
rspec-support (~> 3.
|
105
|
-
rspec-mocks (3.
|
96
|
+
rspec-support (~> 3.10.0)
|
97
|
+
rspec-mocks (3.10.3)
|
106
98
|
diff-lcs (>= 1.2.0, < 2.0)
|
107
|
-
rspec-support (~> 3.
|
108
|
-
rspec-support (3.
|
109
|
-
rubocop (
|
99
|
+
rspec-support (~> 3.10.0)
|
100
|
+
rspec-support (3.10.3)
|
101
|
+
rubocop (1.25.1)
|
110
102
|
parallel (~> 1.10)
|
111
|
-
parser (>=
|
103
|
+
parser (>= 3.1.0.0)
|
112
104
|
rainbow (>= 2.2.2, < 4.0)
|
113
|
-
regexp_parser (>= 1.
|
105
|
+
regexp_parser (>= 1.8, < 3.0)
|
114
106
|
rexml
|
115
|
-
rubocop-ast (>=
|
107
|
+
rubocop-ast (>= 1.15.1, < 2.0)
|
116
108
|
ruby-progressbar (~> 1.7)
|
117
|
-
unicode-display_width (>= 1.4.0, <
|
118
|
-
rubocop-ast (
|
119
|
-
parser (>=
|
120
|
-
|
121
|
-
|
109
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
110
|
+
rubocop-ast (1.15.1)
|
111
|
+
parser (>= 3.0.1.1)
|
112
|
+
rubocop-bsm (0.6.0)
|
113
|
+
rubocop (~> 1.0)
|
114
|
+
rubocop-performance
|
115
|
+
rubocop-rake
|
116
|
+
rubocop-rspec
|
117
|
+
rubocop-performance (1.13.2)
|
118
|
+
rubocop (>= 1.7.0, < 2.0)
|
119
|
+
rubocop-ast (>= 0.4.0)
|
120
|
+
rubocop-rake (0.6.0)
|
121
|
+
rubocop (~> 1.0)
|
122
|
+
rubocop-rspec (2.8.0)
|
123
|
+
rubocop (~> 1.19)
|
124
|
+
ruby-progressbar (1.11.0)
|
125
|
+
ruby2_keywords (0.0.5)
|
122
126
|
sqlite3 (1.4.2)
|
123
|
-
thor (1.
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
virtus (1.0.5)
|
129
|
-
axiom-types (~> 0.1)
|
130
|
-
coercible (~> 1.0)
|
131
|
-
descendants_tracker (~> 0.0, >= 0.0.3)
|
132
|
-
equalizer (~> 0.0, >= 0.0.9)
|
133
|
-
zeitwerk (2.3.1)
|
127
|
+
thor (1.2.1)
|
128
|
+
tzinfo (2.0.4)
|
129
|
+
concurrent-ruby (~> 1.0)
|
130
|
+
unicode-display_width (2.1.0)
|
131
|
+
zeitwerk (2.5.4)
|
134
132
|
|
135
133
|
PLATFORMS
|
136
134
|
ruby
|
137
135
|
|
138
136
|
DEPENDENCIES
|
137
|
+
activejob
|
139
138
|
activerecord
|
140
139
|
bundler
|
141
140
|
grape-app!
|
142
141
|
rack-test
|
143
142
|
rake
|
144
143
|
rspec
|
145
|
-
rubocop
|
144
|
+
rubocop-bsm
|
146
145
|
sqlite3
|
147
|
-
virtus
|
148
146
|
|
149
147
|
BUNDLED WITH
|
150
|
-
2.
|
148
|
+
2.3.4
|
data/Gemfile.rails6
ADDED
data/Gemfile.rails6.lock
ADDED
@@ -0,0 +1,150 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
grape-app (0.10.0)
|
5
|
+
activesupport
|
6
|
+
grape (>= 1.2)
|
7
|
+
grape-entity
|
8
|
+
openssl
|
9
|
+
rack-cors (>= 1.1)
|
10
|
+
rack-ssl-enforcer
|
11
|
+
thor
|
12
|
+
zeitwerk (>= 2.1)
|
13
|
+
|
14
|
+
GEM
|
15
|
+
remote: https://rubygems.org/
|
16
|
+
specs:
|
17
|
+
activejob (6.1.4.4)
|
18
|
+
activesupport (= 6.1.4.4)
|
19
|
+
globalid (>= 0.3.6)
|
20
|
+
activemodel (6.1.4.4)
|
21
|
+
activesupport (= 6.1.4.4)
|
22
|
+
activerecord (6.1.4.4)
|
23
|
+
activemodel (= 6.1.4.4)
|
24
|
+
activesupport (= 6.1.4.4)
|
25
|
+
activesupport (6.1.4.4)
|
26
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
27
|
+
i18n (>= 1.6, < 2)
|
28
|
+
minitest (>= 5.1)
|
29
|
+
tzinfo (~> 2.0)
|
30
|
+
zeitwerk (~> 2.3)
|
31
|
+
ast (2.4.2)
|
32
|
+
builder (3.2.4)
|
33
|
+
concurrent-ruby (1.1.9)
|
34
|
+
diff-lcs (1.5.0)
|
35
|
+
dry-configurable (0.14.0)
|
36
|
+
concurrent-ruby (~> 1.0)
|
37
|
+
dry-core (~> 0.6)
|
38
|
+
dry-container (0.9.0)
|
39
|
+
concurrent-ruby (~> 1.0)
|
40
|
+
dry-configurable (~> 0.13, >= 0.13.0)
|
41
|
+
dry-core (0.7.1)
|
42
|
+
concurrent-ruby (~> 1.0)
|
43
|
+
dry-inflector (0.2.1)
|
44
|
+
dry-logic (1.2.0)
|
45
|
+
concurrent-ruby (~> 1.0)
|
46
|
+
dry-core (~> 0.5, >= 0.5)
|
47
|
+
dry-types (1.5.1)
|
48
|
+
concurrent-ruby (~> 1.0)
|
49
|
+
dry-container (~> 0.3)
|
50
|
+
dry-core (~> 0.5, >= 0.5)
|
51
|
+
dry-inflector (~> 0.1, >= 0.1.2)
|
52
|
+
dry-logic (~> 1.0, >= 1.0.2)
|
53
|
+
globalid (1.0.0)
|
54
|
+
activesupport (>= 5.0)
|
55
|
+
grape (1.6.2)
|
56
|
+
activesupport
|
57
|
+
builder
|
58
|
+
dry-types (>= 1.1)
|
59
|
+
mustermann-grape (~> 1.0.0)
|
60
|
+
rack (>= 1.3.0)
|
61
|
+
rack-accept
|
62
|
+
grape-entity (0.10.1)
|
63
|
+
activesupport (>= 3.0.0)
|
64
|
+
multi_json (>= 1.3.2)
|
65
|
+
i18n (1.9.1)
|
66
|
+
concurrent-ruby (~> 1.0)
|
67
|
+
minitest (5.15.0)
|
68
|
+
multi_json (1.15.0)
|
69
|
+
mustermann (1.1.1)
|
70
|
+
ruby2_keywords (~> 0.0.1)
|
71
|
+
mustermann-grape (1.0.1)
|
72
|
+
mustermann (>= 1.0.0)
|
73
|
+
openssl (3.0.0)
|
74
|
+
parallel (1.21.0)
|
75
|
+
parser (3.1.0.0)
|
76
|
+
ast (~> 2.4.1)
|
77
|
+
rack (2.2.3)
|
78
|
+
rack-accept (0.4.5)
|
79
|
+
rack (>= 0.4)
|
80
|
+
rack-cors (1.1.1)
|
81
|
+
rack (>= 2.0.0)
|
82
|
+
rack-ssl-enforcer (0.2.9)
|
83
|
+
rack-test (1.1.0)
|
84
|
+
rack (>= 1.0, < 3)
|
85
|
+
rainbow (3.1.1)
|
86
|
+
rake (13.0.6)
|
87
|
+
regexp_parser (2.2.0)
|
88
|
+
rexml (3.2.5)
|
89
|
+
rspec (3.10.0)
|
90
|
+
rspec-core (~> 3.10.0)
|
91
|
+
rspec-expectations (~> 3.10.0)
|
92
|
+
rspec-mocks (~> 3.10.0)
|
93
|
+
rspec-core (3.10.2)
|
94
|
+
rspec-support (~> 3.10.0)
|
95
|
+
rspec-expectations (3.10.2)
|
96
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
97
|
+
rspec-support (~> 3.10.0)
|
98
|
+
rspec-mocks (3.10.3)
|
99
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
100
|
+
rspec-support (~> 3.10.0)
|
101
|
+
rspec-support (3.10.3)
|
102
|
+
rubocop (1.25.1)
|
103
|
+
parallel (~> 1.10)
|
104
|
+
parser (>= 3.1.0.0)
|
105
|
+
rainbow (>= 2.2.2, < 4.0)
|
106
|
+
regexp_parser (>= 1.8, < 3.0)
|
107
|
+
rexml
|
108
|
+
rubocop-ast (>= 1.15.1, < 2.0)
|
109
|
+
ruby-progressbar (~> 1.7)
|
110
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
111
|
+
rubocop-ast (1.15.1)
|
112
|
+
parser (>= 3.0.1.1)
|
113
|
+
rubocop-bsm (0.6.0)
|
114
|
+
rubocop (~> 1.0)
|
115
|
+
rubocop-performance
|
116
|
+
rubocop-rake
|
117
|
+
rubocop-rspec
|
118
|
+
rubocop-performance (1.13.2)
|
119
|
+
rubocop (>= 1.7.0, < 2.0)
|
120
|
+
rubocop-ast (>= 0.4.0)
|
121
|
+
rubocop-rake (0.6.0)
|
122
|
+
rubocop (~> 1.0)
|
123
|
+
rubocop-rspec (2.8.0)
|
124
|
+
rubocop (~> 1.19)
|
125
|
+
ruby-progressbar (1.11.0)
|
126
|
+
ruby2_keywords (0.0.5)
|
127
|
+
sqlite3 (1.4.2)
|
128
|
+
thor (1.2.1)
|
129
|
+
tzinfo (2.0.4)
|
130
|
+
concurrent-ruby (~> 1.0)
|
131
|
+
unicode-display_width (2.1.0)
|
132
|
+
zeitwerk (2.5.4)
|
133
|
+
|
134
|
+
PLATFORMS
|
135
|
+
x86_64-linux
|
136
|
+
|
137
|
+
DEPENDENCIES
|
138
|
+
activejob (~> 6.1)
|
139
|
+
activerecord (~> 6.1)
|
140
|
+
activesupport (~> 6.1)
|
141
|
+
bundler
|
142
|
+
grape-app!
|
143
|
+
rack-test
|
144
|
+
rake
|
145
|
+
rspec
|
146
|
+
rubocop-bsm
|
147
|
+
sqlite3
|
148
|
+
|
149
|
+
BUNDLED WITH
|
150
|
+
2.3.4
|
data/grape-app.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'grape-app'
|
3
|
-
s.version = '0.
|
3
|
+
s.version = '0.10.0'
|
4
4
|
s.authors = ['Black Square Media Ltd']
|
5
5
|
s.email = ['info@blacksquaremedia.com']
|
6
6
|
s.summary = %(Standalone Grape API apps)
|
@@ -12,22 +12,24 @@ Gem::Specification.new do |s|
|
|
12
12
|
s.test_files = `git ls-files -z -- spec/*`.split("\x0")
|
13
13
|
s.executables = ['grape-app']
|
14
14
|
s.require_paths = ['lib']
|
15
|
-
s.required_ruby_version = '>= 2.
|
15
|
+
s.required_ruby_version = '>= 2.7'
|
16
16
|
|
17
17
|
s.add_dependency 'activesupport'
|
18
18
|
s.add_dependency 'grape', '>= 1.2'
|
19
19
|
s.add_dependency 'grape-entity'
|
20
|
+
s.add_dependency 'openssl'
|
20
21
|
s.add_dependency 'rack-cors', '>= 1.1'
|
21
22
|
s.add_dependency 'rack-ssl-enforcer'
|
22
23
|
s.add_dependency 'thor'
|
23
24
|
s.add_dependency 'zeitwerk', '>= 2.1'
|
24
25
|
|
26
|
+
s.add_development_dependency 'activejob'
|
25
27
|
s.add_development_dependency 'activerecord'
|
26
28
|
s.add_development_dependency 'bundler'
|
27
29
|
s.add_development_dependency 'rack-test'
|
28
30
|
s.add_development_dependency 'rake'
|
29
31
|
s.add_development_dependency 'rspec'
|
30
|
-
s.add_development_dependency 'rubocop'
|
32
|
+
s.add_development_dependency 'rubocop-bsm'
|
31
33
|
s.add_development_dependency 'sqlite3'
|
32
|
-
s.
|
34
|
+
s.metadata['rubygems_mfa_required'] = 'true'
|
33
35
|
end
|
@@ -1,8 +1,3 @@
|
|
1
|
-
if Grape::App.config.raise_on_missing_translations
|
2
|
-
handler = ->(exception, *) { exception = exception.to_exception if exception.respond_to?(:to_exception); raise exception }
|
3
|
-
I18n.exception_handler = handler
|
4
|
-
end
|
5
|
-
|
6
1
|
if defined?(ActiveRecord)
|
7
2
|
require 'yaml'
|
8
3
|
require 'erb'
|
@@ -12,9 +7,7 @@ if defined?(ActiveRecord)
|
|
12
7
|
configurations[Grape::App.env.to_s] ||= {}
|
13
8
|
configurations[Grape::App.env.to_s]['url'] ||= ENV['DATABASE_URL']
|
14
9
|
end
|
15
|
-
|
16
10
|
ActiveRecord::Base.configurations = configurations
|
17
|
-
ActiveRecord::Base.default_timezone = :utc
|
18
11
|
ActiveRecord::Base.establish_connection(Grape::App.env.to_sym)
|
19
12
|
|
20
13
|
Grape::App.middleware.use ActiveRecord::ConnectionAdapters::ConnectionManagement if defined?(ActiveRecord::ConnectionAdapters::ConnectionManagement)
|
@@ -1,6 +1,72 @@
|
|
1
|
+
# Configure ActiveSupport defaults
|
2
|
+
# https://github.com/rails/rails/blob/main/railties/lib/rails/application/configuration.rb
|
3
|
+
ActiveSupport.tap do |c|
|
4
|
+
c.to_time_preserves_timezone = true
|
5
|
+
c.utc_to_local_returns_utc_offset_times = true
|
6
|
+
end
|
7
|
+
ActiveSupport::Digest.hash_digest_class = OpenSSL::Digest::SHA256
|
8
|
+
ActiveSupport::KeyGenerator.hash_digest_class = OpenSSL::Digest::SHA256 if ActiveSupport::KeyGenerator.respond_to?(:hash_digest_class=)
|
9
|
+
ActiveSupport::MessageEncryptor.use_authenticated_message_encryption = true
|
10
|
+
ActiveSupport::IsolatedExecutionState.isolation_level = :thread if defined?(ActiveSupport::IsolatedExecutionState)
|
11
|
+
Digest::UUID.use_rfc4122_namespaced_uuids = true if Digest::UUID.respond_to?(:use_rfc4122_namespaced_uuids=)
|
12
|
+
|
1
13
|
# Set default time-zone
|
14
|
+
begin
|
15
|
+
TZInfo::DataSource.get
|
16
|
+
rescue TZInfo::DataSourceNotFound => e
|
17
|
+
raise e.exception "tzinfo-data is not present. Please add gem 'tzinfo-data' to your Gemfile and run bundle install"
|
18
|
+
end
|
19
|
+
require 'active_support/core_ext/time/zones'
|
2
20
|
Time.zone_default = Time.find_zone!('UTC')
|
3
21
|
|
4
22
|
# Add default I18n paths and set default locale
|
5
23
|
I18n.load_path += Dir[Grape::App.root.join('config', 'locales', '*.{rb,yml}').to_s]
|
6
24
|
I18n.default_locale = :en
|
25
|
+
|
26
|
+
if Grape::App.config.raise_on_missing_translations
|
27
|
+
handler = Class.new(I18n::ExceptionHandler) do
|
28
|
+
def call(exception, *)
|
29
|
+
raise exception.to_exception if exception.is_a?(I18n::MissingTranslation)
|
30
|
+
|
31
|
+
super
|
32
|
+
end
|
33
|
+
end
|
34
|
+
I18n.exception_handler = handler.new
|
35
|
+
end
|
36
|
+
|
37
|
+
# Configure ActiveRecord defaults
|
38
|
+
# https://github.com/rails/rails/blob/main/railties/lib/rails/application/configuration.rb
|
39
|
+
if defined?(ActiveRecord)
|
40
|
+
if ActiveRecord.respond_to?(:default_timezone=)
|
41
|
+
ActiveRecord.default_timezone = :utc
|
42
|
+
else
|
43
|
+
ActiveRecord::Base.default_timezone = :utc
|
44
|
+
end
|
45
|
+
|
46
|
+
if ActiveRecord.respond_to?(:legacy_connection_handling=)
|
47
|
+
ActiveRecord.legacy_connection_handling = false
|
48
|
+
else
|
49
|
+
ActiveRecord::Base.legacy_connection_handling = false
|
50
|
+
end
|
51
|
+
|
52
|
+
ActiveRecord.tap do |c|
|
53
|
+
c.verify_foreign_keys_for_fixtures = true if c.respond_to?(:verify_foreign_keys_for_fixtures=)
|
54
|
+
end
|
55
|
+
|
56
|
+
ActiveRecord::Base.tap do |c|
|
57
|
+
c.belongs_to_required_by_default = true
|
58
|
+
c.cache_versioning = true
|
59
|
+
c.collection_cache_versioning = true
|
60
|
+
c.has_many_inversing = true
|
61
|
+
c.partial_inserts = false if c.respond_to?(:partial_inserts=)
|
62
|
+
c.automatic_scope_inversing = true if c.respond_to?(:automatic_scope_inversing=)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
# Configure ActiveJob defaults
|
67
|
+
# https://github.com/rails/rails/blob/main/railties/lib/rails/application/configuration.rb
|
68
|
+
if defined?(ActiveJob)
|
69
|
+
ActiveJob::Base.tap do |c|
|
70
|
+
c.retry_jitter = 0.15
|
71
|
+
end
|
72
|
+
end
|
@@ -1,6 +1,16 @@
|
|
1
1
|
Grape::App.configure do |config|
|
2
|
-
#
|
3
|
-
#
|
2
|
+
# Eager load code on boot. This eager loads most of your application in
|
3
|
+
# memory, allowing both threaded web servers and those relying on copy on
|
4
|
+
# write to perform better.
|
5
|
+
config.eager_load = true
|
6
|
+
|
7
|
+
# Don't raise errors on missing translations
|
8
|
+
# config.raise_on_missing_translations = false
|
9
|
+
|
10
|
+
# Force SSL, please see https://github.com/tobmatth/rack-ssl-enforcer
|
11
|
+
# for configuration options.
|
12
|
+
#
|
13
|
+
# config.force_ssl = { strict: true }
|
4
14
|
|
5
15
|
# CORS is disabled by default, please see https://github.com/cyu/rack-cors
|
6
16
|
# for configuration options.
|
@@ -18,7 +28,4 @@ Grape::App.configure do |config|
|
|
18
28
|
# use Rack::ETag
|
19
29
|
# insert_before Rack::Cors, Rack::ContentLength
|
20
30
|
# end
|
21
|
-
|
22
|
-
# Don't raise errors on missing translations
|
23
|
-
# config.raise_on_missing_translations = false
|
24
31
|
end
|
data/lib/grape/app.rb
CHANGED
@@ -1,13 +1,16 @@
|
|
1
1
|
require 'bundler/setup'
|
2
2
|
require 'pathname'
|
3
|
+
require 'openssl'
|
3
4
|
require 'grape'
|
4
|
-
require 'active_support/string_inquirer'
|
5
|
-
require 'active_support/configurable'
|
6
|
-
require 'active_support/core_ext/time/zones'
|
7
5
|
require 'rack/cors'
|
8
6
|
require 'rack/ssl-enforcer'
|
9
7
|
require 'zeitwerk'
|
10
8
|
|
9
|
+
ENV['RAILS_DISABLE_DEPRECATED_TO_S_CONVERSION'] ||= 'true'
|
10
|
+
require 'active_support/all'
|
11
|
+
require 'active_support/string_inquirer'
|
12
|
+
require 'active_support/configurable'
|
13
|
+
|
11
14
|
class Grape::App < Grape::API
|
12
15
|
class << self
|
13
16
|
# Run initializers
|
@@ -35,6 +38,7 @@ class Grape::App < Grape::API
|
|
35
38
|
|
36
39
|
# Load app
|
37
40
|
require_one 'app', 'api'
|
41
|
+
Zeitwerk::Loader.eager_load_all if Grape::App.config.eager_load
|
38
42
|
end
|
39
43
|
|
40
44
|
# @return [Grape::App::Configuration] the configuration
|
@@ -72,11 +76,19 @@ class Grape::App < Grape::API
|
|
72
76
|
config = self.config
|
73
77
|
@middleware ||= Rack::Builder.new do
|
74
78
|
use Rack::Cors, &config.cors if config.cors
|
75
|
-
|
79
|
+
|
80
|
+
if config.force_ssl.is_a?(Hash)
|
81
|
+
use Rack::SslEnforcer, **config.force_ssl
|
82
|
+
elsif config.force_ssl
|
83
|
+
use Rack::SslEnforcer
|
84
|
+
end
|
85
|
+
|
76
86
|
config.middleware.each do |block|
|
77
87
|
instance_eval(&block)
|
78
88
|
end
|
79
89
|
|
90
|
+
use Grape::App::Middleware::ConnectionManagement if defined?(ActiveRecord)
|
91
|
+
|
80
92
|
run Grape::App
|
81
93
|
end
|
82
94
|
end
|
@@ -102,3 +114,4 @@ end
|
|
102
114
|
require 'grape/app/configuration'
|
103
115
|
require 'grape/app/helpers'
|
104
116
|
require 'grape/app/inflector'
|
117
|
+
require 'grape/app/middleware'
|
@@ -3,14 +3,46 @@ require 'spec_helper'
|
|
3
3
|
RSpec.describe Grape::App::Helpers::Caching do
|
4
4
|
include Rack::Test::Methods
|
5
5
|
|
6
|
-
let
|
6
|
+
let :app do
|
7
|
+
helper = described_class
|
8
|
+
Class.new(Grape::API) do
|
9
|
+
format :json
|
7
10
|
|
8
|
-
|
11
|
+
helpers helper
|
12
|
+
|
13
|
+
get '/articles' do
|
14
|
+
scope = Article.order(:id)
|
15
|
+
opts = params[:public] ? { public: params[:public] } : {}
|
16
|
+
fresh_when(scope, **opts)
|
17
|
+
scope.to_a
|
18
|
+
end
|
19
|
+
|
20
|
+
get '/articles/never_updated' do
|
21
|
+
article = Article.first
|
22
|
+
article.updated_at = nil
|
23
|
+
|
24
|
+
fresh_when(article, last_modified_field: :created_at)
|
25
|
+
end
|
26
|
+
|
27
|
+
get '/articles/:id' do
|
28
|
+
article = Article.first
|
29
|
+
article if stale?(article, stale_if_error: 5, extras: { a: 1, b: 2 })
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
let(:created_at) { Time.at(1515151500).utc }
|
34
|
+
|
35
|
+
before do
|
36
|
+
Article.create! title: 'Welcome', created_at: created_at, updated_at: created_at + 10
|
37
|
+
Article.create! title: 'Bye', created_at: created_at, updated_at: created_at + 20
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'handles fresh-when' do
|
9
41
|
get '/articles'
|
10
42
|
expect(last_response.status).to eq(200)
|
11
43
|
expect(last_response.headers).to include(
|
12
44
|
'Content-Type' => 'application/json',
|
13
|
-
'ETag' => '
|
45
|
+
'ETag' => 'a5f6c4b024510c9835d8d70cbd3ed00c',
|
14
46
|
'Last-Modified' => 'Fri, 05 Jan 2018 11:25:20 GMT',
|
15
47
|
)
|
16
48
|
expect(JSON.parse(last_response.body).size).to eq(2)
|
@@ -30,7 +62,7 @@ RSpec.describe Grape::App::Helpers::Caching do
|
|
30
62
|
expect(last_response.status).to eq(200)
|
31
63
|
end
|
32
64
|
|
33
|
-
it '
|
65
|
+
it 'handles fresh_when for records that were never updated' do
|
34
66
|
get '/articles/never_updated'
|
35
67
|
expect(last_response.status).to eq(200)
|
36
68
|
expect(last_response.headers).to include(
|
@@ -38,7 +70,7 @@ RSpec.describe Grape::App::Helpers::Caching do
|
|
38
70
|
)
|
39
71
|
end
|
40
72
|
|
41
|
-
it '
|
73
|
+
it 'supports cache-control' do
|
42
74
|
get '/articles?public=true'
|
43
75
|
expect(last_response.status).to eq(200)
|
44
76
|
expect(last_response.headers).to include(
|
@@ -46,27 +78,27 @@ RSpec.describe Grape::App::Helpers::Caching do
|
|
46
78
|
)
|
47
79
|
end
|
48
80
|
|
49
|
-
it '
|
81
|
+
it 'handles stale? (with cache-control)' do
|
50
82
|
get '/articles/1'
|
51
83
|
expect(last_response.status).to eq(200)
|
52
84
|
expect(last_response.headers).to include(
|
53
85
|
'Cache-Control' => 'private, stale-if-error=5, a=1, b=2',
|
54
86
|
'Content-Type' => 'application/json',
|
55
|
-
'ETag' => '
|
87
|
+
'ETag' => '0154407bafc97186a494a05e0652ff61',
|
56
88
|
'Last-Modified' => 'Fri, 05 Jan 2018 11:25:10 GMT',
|
57
89
|
)
|
58
90
|
expect(JSON.parse(last_response.body)).to eq(
|
59
91
|
'id' => 1,
|
60
92
|
'title' => 'Welcome',
|
61
|
-
'updated_at' => '2018-01-
|
62
|
-
'created_at' => '2018-01-
|
93
|
+
'updated_at' => '2018-01-05T11:25:10.000Z',
|
94
|
+
'created_at' => '2018-01-05T11:25:00.000Z',
|
63
95
|
)
|
64
96
|
|
65
97
|
get '/articles/1', {}, 'HTTP_IF_NONE_MATCH' => last_response.headers['ETag']
|
66
98
|
expect(last_response.status).to eq(304)
|
67
99
|
expect(last_response.headers).to include(
|
68
100
|
'Cache-Control' => 'private, stale-if-error=5, a=1, b=2',
|
69
|
-
'ETag' => '
|
101
|
+
'ETag' => '0154407bafc97186a494a05e0652ff61',
|
70
102
|
'Last-Modified' => 'Fri, 05 Jan 2018 11:25:10 GMT',
|
71
103
|
)
|
72
104
|
end
|
@@ -3,16 +3,32 @@ require 'spec_helper'
|
|
3
3
|
RSpec.describe Grape::App::Helpers::Params do
|
4
4
|
include Rack::Test::Methods
|
5
5
|
|
6
|
-
let
|
6
|
+
let :app do
|
7
|
+
helper = described_class
|
8
|
+
Class.new(Grape::API) do
|
9
|
+
format :json
|
7
10
|
|
8
|
-
|
9
|
-
|
11
|
+
helpers helper
|
12
|
+
|
13
|
+
params do
|
14
|
+
optional :title
|
15
|
+
end
|
16
|
+
post '/articles' do
|
17
|
+
attrs = { id: 9, updated_at: Time.at(1515151515).utc }
|
18
|
+
attrs.update(declared_params)
|
19
|
+
Article.new(attrs)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'limits params' do
|
25
|
+
post '/articles', title: 'Today', id: 1234, updated_at: Time.now
|
10
26
|
expect(last_response.status).to eq(201)
|
11
27
|
expect(JSON.parse(last_response.body)).to eq(
|
12
28
|
'created_at' => nil,
|
13
29
|
'id' => 9,
|
14
30
|
'title' => 'Today',
|
15
|
-
'updated_at' => '2018-01-
|
31
|
+
'updated_at' => '2018-01-05T11:25:15.000Z',
|
16
32
|
)
|
17
33
|
end
|
18
34
|
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe Grape::App::Middleware::ConnectionManagement do
|
4
|
+
include Rack::Test::Methods
|
5
|
+
|
6
|
+
let :app do
|
7
|
+
failing = ->(_) { raise(ActiveRecord::StatementInvalid) }
|
8
|
+
middleware = described_class
|
9
|
+
Rack::Builder.new do
|
10
|
+
use middleware
|
11
|
+
run failing
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'clears active connections' do
|
16
|
+
ActiveRecord::Base.connection
|
17
|
+
expect(ActiveRecord::Base.connection_handler).to be_active_connections
|
18
|
+
|
19
|
+
expect { get '/' }.to raise_error(ActiveRecord::StatementInvalid)
|
20
|
+
expect(ActiveRecord::Base.connection_handler).not_to be_active_connections
|
21
|
+
end
|
22
|
+
end
|
data/spec/grape/app_spec.rb
CHANGED
@@ -4,37 +4,68 @@ RSpec.describe Grape::App do
|
|
4
4
|
include Rack::Test::Methods
|
5
5
|
|
6
6
|
subject { described_class }
|
7
|
+
|
7
8
|
before { subject.init! File.expand_path('../scenario', __dir__) }
|
8
9
|
|
9
10
|
def app
|
10
11
|
subject.middleware
|
11
12
|
end
|
12
13
|
|
13
|
-
it '
|
14
|
+
it 'has an env' do
|
14
15
|
expect(subject.env).to be_instance_of(ActiveSupport::StringInquirer)
|
15
16
|
expect(subject.env).to eq('test')
|
16
17
|
end
|
17
18
|
|
18
|
-
it '
|
19
|
+
it 'has an root' do
|
19
20
|
expect(subject.root).to be_instance_of(Pathname)
|
20
21
|
end
|
21
22
|
|
22
|
-
it '
|
23
|
+
it 'is an API instance' do
|
23
24
|
expect(subject).to be < Grape::API
|
24
25
|
end
|
25
26
|
|
26
|
-
it '
|
27
|
+
it 'inits with default time zone' do
|
27
28
|
expect(Time.zone.name).to eq('UTC')
|
28
29
|
expect(Thread.new { Time.zone }.value.name).to eq('UTC')
|
29
30
|
end
|
30
31
|
|
31
|
-
it '
|
32
|
+
it 'configures i18n' do
|
32
33
|
expect(I18n.load_path).to include(subject.root.join('config', 'locales', 'en.yml').to_s)
|
33
34
|
expect(I18n.default_locale).to eq(:en)
|
34
|
-
expect(I18n.exception_handler).to
|
35
|
+
expect(I18n.exception_handler).to be_a(I18n::ExceptionHandler)
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'configures ActiveSupport' do
|
39
|
+
expect(ActiveSupport.to_time_preserves_timezone).to be(true)
|
40
|
+
expect(ActiveSupport.utc_to_local_returns_utc_offset_times).to be(true)
|
41
|
+
expect(ActiveSupport::Digest.hash_digest_class).to be(OpenSSL::Digest::SHA256)
|
42
|
+
expect(ActiveSupport::MessageEncryptor.use_authenticated_message_encryption).to be(true)
|
43
|
+
if ActiveSupport::VERSION::MAJOR >= 7
|
44
|
+
expect(ActiveSupport::KeyGenerator.hash_digest_class).to be(OpenSSL::Digest::SHA256)
|
45
|
+
expect(ActiveSupport::IsolatedExecutionState.isolation_level).to be(:thread)
|
46
|
+
expect(Digest::UUID.use_rfc4122_namespaced_uuids).to be(true)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
it 'configures ActiveRecord' do
|
51
|
+
if ActiveRecord::VERSION::MAJOR >= 7
|
52
|
+
expect(ActiveRecord.default_timezone).to be(:utc)
|
53
|
+
expect(ActiveRecord.legacy_connection_handling).to be(false)
|
54
|
+
expect(ActiveRecord.verify_foreign_keys_for_fixtures).to be(true)
|
55
|
+
expect(ActiveRecord::Base.partial_inserts).to be(false)
|
56
|
+
expect(ActiveRecord::Base.automatic_scope_inversing).to be(true)
|
57
|
+
end
|
58
|
+
expect(ActiveRecord::Base.belongs_to_required_by_default).to be(true)
|
59
|
+
expect(ActiveRecord::Base.cache_versioning).to be(true)
|
60
|
+
expect(ActiveRecord::Base.collection_cache_versioning).to be(true)
|
61
|
+
expect(ActiveRecord::Base.has_many_inversing).to be(true)
|
62
|
+
end
|
63
|
+
|
64
|
+
it 'configures ActiveJob' do
|
65
|
+
expect(ActiveJob::Base.retry_jitter).to eq(0.15)
|
35
66
|
end
|
36
67
|
|
37
|
-
it '
|
68
|
+
it 'reads env specific initializers' do
|
38
69
|
expect(subject.config).to include(
|
39
70
|
:test_specific,
|
40
71
|
:raise_on_missing_translations,
|
@@ -43,13 +74,13 @@ RSpec.describe Grape::App do
|
|
43
74
|
)
|
44
75
|
end
|
45
76
|
|
46
|
-
it '
|
77
|
+
it 'prepares middleware' do
|
47
78
|
expect(subject.middleware).to be_instance_of(Rack::Builder)
|
48
|
-
expect(subject.middleware.send(:instance_variable_get, :@use).size).to eq(
|
79
|
+
expect(subject.middleware.send(:instance_variable_get, :@use).size).to eq(3)
|
49
80
|
expect(subject.middleware.send(:instance_variable_get, :@run)).to be(subject)
|
50
81
|
end
|
51
82
|
|
52
|
-
it '
|
83
|
+
it 'applies middleware' do
|
53
84
|
header 'Origin', 'test.host'
|
54
85
|
get '/v1/ok'
|
55
86
|
expect(last_response).to be_ok
|
data/spec/spec_helper.rb
CHANGED
@@ -1,70 +1,17 @@
|
|
1
1
|
ENV['RACK_ENV'] ||= 'test'
|
2
2
|
require 'grape-app'
|
3
3
|
require 'rack/test'
|
4
|
-
require '
|
4
|
+
require 'active_record'
|
5
|
+
require 'active_job'
|
5
6
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
def maximum(*)
|
13
|
-
map(&:updated_at).max
|
14
|
-
end
|
15
|
-
|
16
|
-
def each
|
17
|
-
yield Article.new(id: 1, title: 'Welcome', updated_at: Time.at(1515151510).utc, created_at: Time.at(1515151500).utc)
|
18
|
-
yield Article.new(id: 2, title: 'Bye', updated_at: Time.at(1515151520).utc, created_at: Time.at(1515151500).utc)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
def self.all
|
23
|
-
Scope.new
|
24
|
-
end
|
25
|
-
|
26
|
-
attribute :id
|
27
|
-
attribute :title
|
28
|
-
attribute :updated_at
|
29
|
-
attribute :created_at
|
30
|
-
|
31
|
-
def to_param
|
32
|
-
id.to_s
|
7
|
+
ActiveRecord::Base.configurations = { 'test' => { 'adapter' => 'sqlite3', 'database' => ':memory:' } }
|
8
|
+
ActiveRecord::Base.establish_connection :test
|
9
|
+
ActiveRecord::Base.connection.instance_eval do
|
10
|
+
create_table :articles do |t|
|
11
|
+
t.string :title
|
12
|
+
t.timestamps
|
33
13
|
end
|
34
14
|
end
|
35
15
|
|
36
|
-
class
|
37
|
-
format :json
|
38
|
-
|
39
|
-
helpers Grape::App::Helpers::Caching
|
40
|
-
helpers Grape::App::Helpers::Params
|
41
|
-
|
42
|
-
get '/articles' do
|
43
|
-
scope = Article.all
|
44
|
-
opts = params[:public] ? { public: params[:public] } : {}
|
45
|
-
fresh_when(scope, **opts)
|
46
|
-
scope.map(&:to_hash)
|
47
|
-
end
|
48
|
-
|
49
|
-
get '/articles/never_updated' do
|
50
|
-
article = Article.all.first
|
51
|
-
article.updated_at = nil
|
52
|
-
|
53
|
-
fresh_when(article, last_modified_field: :created_at)
|
54
|
-
end
|
55
|
-
|
56
|
-
get '/articles/:id' do
|
57
|
-
article = Article.all.first
|
58
|
-
article.to_hash if stale?(article, stale_if_error: 5, extras: { a: 1, b: 2 })
|
59
|
-
end
|
60
|
-
|
61
|
-
params do
|
62
|
-
requires :title
|
63
|
-
optional :fresh
|
64
|
-
end
|
65
|
-
post '/articles' do
|
66
|
-
attrs = { id: 9, updated_at: Time.at(1515151515).utc }
|
67
|
-
attrs.update(declared_params)
|
68
|
-
Article.new(attrs).to_hash
|
69
|
-
end
|
16
|
+
class Article < ActiveRecord::Base
|
70
17
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: grape-app
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.10.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Black Square Media Ltd
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-02-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: openssl
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: rack-cors
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -109,7 +123,7 @@ dependencies:
|
|
109
123
|
- !ruby/object:Gem::Version
|
110
124
|
version: '2.1'
|
111
125
|
- !ruby/object:Gem::Dependency
|
112
|
-
name:
|
126
|
+
name: activejob
|
113
127
|
requirement: !ruby/object:Gem::Requirement
|
114
128
|
requirements:
|
115
129
|
- - ">="
|
@@ -123,7 +137,7 @@ dependencies:
|
|
123
137
|
- !ruby/object:Gem::Version
|
124
138
|
version: '0'
|
125
139
|
- !ruby/object:Gem::Dependency
|
126
|
-
name:
|
140
|
+
name: activerecord
|
127
141
|
requirement: !ruby/object:Gem::Requirement
|
128
142
|
requirements:
|
129
143
|
- - ">="
|
@@ -137,7 +151,7 @@ dependencies:
|
|
137
151
|
- !ruby/object:Gem::Version
|
138
152
|
version: '0'
|
139
153
|
- !ruby/object:Gem::Dependency
|
140
|
-
name:
|
154
|
+
name: bundler
|
141
155
|
requirement: !ruby/object:Gem::Requirement
|
142
156
|
requirements:
|
143
157
|
- - ">="
|
@@ -151,7 +165,7 @@ dependencies:
|
|
151
165
|
- !ruby/object:Gem::Version
|
152
166
|
version: '0'
|
153
167
|
- !ruby/object:Gem::Dependency
|
154
|
-
name:
|
168
|
+
name: rack-test
|
155
169
|
requirement: !ruby/object:Gem::Requirement
|
156
170
|
requirements:
|
157
171
|
- - ">="
|
@@ -165,7 +179,7 @@ dependencies:
|
|
165
179
|
- !ruby/object:Gem::Version
|
166
180
|
version: '0'
|
167
181
|
- !ruby/object:Gem::Dependency
|
168
|
-
name:
|
182
|
+
name: rake
|
169
183
|
requirement: !ruby/object:Gem::Requirement
|
170
184
|
requirements:
|
171
185
|
- - ">="
|
@@ -179,7 +193,7 @@ dependencies:
|
|
179
193
|
- !ruby/object:Gem::Version
|
180
194
|
version: '0'
|
181
195
|
- !ruby/object:Gem::Dependency
|
182
|
-
name:
|
196
|
+
name: rspec
|
183
197
|
requirement: !ruby/object:Gem::Requirement
|
184
198
|
requirements:
|
185
199
|
- - ">="
|
@@ -193,7 +207,7 @@ dependencies:
|
|
193
207
|
- !ruby/object:Gem::Version
|
194
208
|
version: '0'
|
195
209
|
- !ruby/object:Gem::Dependency
|
196
|
-
name:
|
210
|
+
name: rubocop-bsm
|
197
211
|
requirement: !ruby/object:Gem::Requirement
|
198
212
|
requirements:
|
199
213
|
- - ">="
|
@@ -207,7 +221,7 @@ dependencies:
|
|
207
221
|
- !ruby/object:Gem::Version
|
208
222
|
version: '0'
|
209
223
|
- !ruby/object:Gem::Dependency
|
210
|
-
name:
|
224
|
+
name: sqlite3
|
211
225
|
requirement: !ruby/object:Gem::Requirement
|
212
226
|
requirements:
|
213
227
|
- - ">="
|
@@ -229,11 +243,13 @@ extensions: []
|
|
229
243
|
extra_rdoc_files: []
|
230
244
|
files:
|
231
245
|
- ".editorconfig"
|
246
|
+
- ".github/workflows/test.yml"
|
232
247
|
- ".gitignore"
|
233
248
|
- ".rubocop.yml"
|
234
|
-
- ".travis.yml"
|
235
249
|
- Gemfile
|
236
250
|
- Gemfile.lock
|
251
|
+
- Gemfile.rails6
|
252
|
+
- Gemfile.rails6.lock
|
237
253
|
- LICENSE
|
238
254
|
- README.md
|
239
255
|
- Rakefile
|
@@ -250,6 +266,8 @@ files:
|
|
250
266
|
- lib/grape/app/inflector.rb
|
251
267
|
- lib/grape/app/initializers/post.rb
|
252
268
|
- lib/grape/app/initializers/pre.rb
|
269
|
+
- lib/grape/app/middleware.rb
|
270
|
+
- lib/grape/app/middleware/connection_management.rb
|
253
271
|
- lib/grape/app/tasks.rb
|
254
272
|
- lib/grape/app/tasks/core.rake
|
255
273
|
- lib/grape/app/tasks/databases.rake
|
@@ -269,6 +287,7 @@ files:
|
|
269
287
|
- lib/grape_app.rb
|
270
288
|
- spec/grape/app/helpers/caching_spec.rb
|
271
289
|
- spec/grape/app/helpers/params_spec.rb
|
290
|
+
- spec/grape/app/middleware/connection_management_spec.rb
|
272
291
|
- spec/grape/app_spec.rb
|
273
292
|
- spec/scenario/Gemfile
|
274
293
|
- spec/scenario/app/api.rb
|
@@ -282,7 +301,8 @@ files:
|
|
282
301
|
homepage: https://github.com/bsm/grape-app
|
283
302
|
licenses:
|
284
303
|
- MIT
|
285
|
-
metadata:
|
304
|
+
metadata:
|
305
|
+
rubygems_mfa_required: 'true'
|
286
306
|
post_install_message:
|
287
307
|
rdoc_options: []
|
288
308
|
require_paths:
|
@@ -291,20 +311,21 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
291
311
|
requirements:
|
292
312
|
- - ">="
|
293
313
|
- !ruby/object:Gem::Version
|
294
|
-
version: '2.
|
314
|
+
version: '2.7'
|
295
315
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
296
316
|
requirements:
|
297
317
|
- - ">="
|
298
318
|
- !ruby/object:Gem::Version
|
299
319
|
version: '0'
|
300
320
|
requirements: []
|
301
|
-
rubygems_version: 3.
|
321
|
+
rubygems_version: 3.3.3
|
302
322
|
signing_key:
|
303
323
|
specification_version: 4
|
304
324
|
summary: Standalone Grape API apps
|
305
325
|
test_files:
|
306
326
|
- spec/grape/app/helpers/caching_spec.rb
|
307
327
|
- spec/grape/app/helpers/params_spec.rb
|
328
|
+
- spec/grape/app/middleware/connection_management_spec.rb
|
308
329
|
- spec/grape/app_spec.rb
|
309
330
|
- spec/scenario/Gemfile
|
310
331
|
- spec/scenario/app/api.rb
|