grape-app 0.9.0 → 0.10.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 28f6b7de85ab1f92ac5b216e20c087d3ec2bf42d2a1248eb29080b7857b8a84d
4
- data.tar.gz: 9881ddbbf2a478bb08aea7fe96d4b495c40530b50e2d4809e8275d6b354e3b62
3
+ metadata.gz: a02f28a09a9bf9ac9f5222de88c553958c3984017e2b589dd0ad2f1850503513
4
+ data.tar.gz: 869efcb8480678cff8924d6001cf3342cf0ae9558577a7d856ed572e8d3e2eef
5
5
  SHA512:
6
- metadata.gz: 7825c7dfca1769b0e8248ed3e573a3269680f2d223dd33d00e64c955e4d45533baf4892329e9684b31f1ca1657ec45ffe12823908d3feb164cef140b9caeac42
7
- data.tar.gz: 418375f83c0020d081dc40a05bfb92272a1173d06e53a70c14360c6b44ffc045d105c928e65530864add0853b90fac060c7ffa238e800870f47024a2b59e5350
6
+ metadata.gz: b989f27b49f52f4247518dc5bb485de10d08149ca7da7eb912a53b8e6875bc68d82f8798bbd4d7e086e934b73523fbb384ff1359bc193153fe8f9baf59fa6180
7
+ data.tar.gz: 01d7a80d34def80bf67e85b55ebd47b274c16b0acb384bd86ea41fca9b5fa99da305966d700824a1113e900e4cc11b03907f28c13e0751baf23ecfec17fca8bb
@@ -12,6 +12,9 @@ jobs:
12
12
  strategy:
13
13
  matrix:
14
14
  ruby-version: ["2.7", "3.0", "3.1"]
15
+ gemfiles: ["Gemfile", "Gemfile.rails6"]
16
+ env:
17
+ BUNDLE_GEMFILE: ${{ matrix.gemfile }}
15
18
  steps:
16
19
  - uses: actions/checkout@v2
17
20
  - uses: ruby/setup-ruby@v1
data/Gemfile.lock CHANGED
@@ -1,10 +1,11 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- grape-app (0.9.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,6 +14,9 @@ PATH
13
14
  GEM
14
15
  remote: https://rubygems.org/
15
16
  specs:
17
+ activejob (7.0.1)
18
+ activesupport (= 7.0.1)
19
+ globalid (>= 0.3.6)
16
20
  activemodel (7.0.1)
17
21
  activesupport (= 7.0.1)
18
22
  activerecord (7.0.1)
@@ -45,6 +49,8 @@ GEM
45
49
  dry-core (~> 0.5, >= 0.5)
46
50
  dry-inflector (~> 0.1, >= 0.1.2)
47
51
  dry-logic (~> 1.0, >= 1.0.2)
52
+ globalid (1.0.0)
53
+ activesupport (>= 5.0)
48
54
  grape (1.6.2)
49
55
  activesupport
50
56
  builder
@@ -55,7 +61,7 @@ GEM
55
61
  grape-entity (0.10.1)
56
62
  activesupport (>= 3.0.0)
57
63
  multi_json (>= 1.3.2)
58
- i18n (1.9.0)
64
+ i18n (1.9.1)
59
65
  concurrent-ruby (~> 1.0)
60
66
  minitest (5.15.0)
61
67
  multi_json (1.15.0)
@@ -63,6 +69,7 @@ GEM
63
69
  ruby2_keywords (~> 0.0.1)
64
70
  mustermann-grape (1.0.1)
65
71
  mustermann (>= 1.0.0)
72
+ openssl (3.0.0)
66
73
  parallel (1.21.0)
67
74
  parser (3.1.0.0)
68
75
  ast (~> 2.4.1)
@@ -82,16 +89,16 @@ GEM
82
89
  rspec-core (~> 3.10.0)
83
90
  rspec-expectations (~> 3.10.0)
84
91
  rspec-mocks (~> 3.10.0)
85
- rspec-core (3.10.1)
92
+ rspec-core (3.10.2)
86
93
  rspec-support (~> 3.10.0)
87
94
  rspec-expectations (3.10.2)
88
95
  diff-lcs (>= 1.2.0, < 2.0)
89
96
  rspec-support (~> 3.10.0)
90
- rspec-mocks (3.10.2)
97
+ rspec-mocks (3.10.3)
91
98
  diff-lcs (>= 1.2.0, < 2.0)
92
99
  rspec-support (~> 3.10.0)
93
100
  rspec-support (3.10.3)
94
- rubocop (1.25.0)
101
+ rubocop (1.25.1)
95
102
  parallel (~> 1.10)
96
103
  parser (>= 3.1.0.0)
97
104
  rainbow (>= 2.2.2, < 4.0)
@@ -121,12 +128,13 @@ GEM
121
128
  tzinfo (2.0.4)
122
129
  concurrent-ruby (~> 1.0)
123
130
  unicode-display_width (2.1.0)
124
- zeitwerk (2.5.3)
131
+ zeitwerk (2.5.4)
125
132
 
126
133
  PLATFORMS
127
134
  ruby
128
135
 
129
136
  DEPENDENCIES
137
+ activejob
130
138
  activerecord
131
139
  bundler
132
140
  grape-app!
@@ -137,4 +145,4 @@ DEPENDENCIES
137
145
  sqlite3
138
146
 
139
147
  BUNDLED WITH
140
- 2.2.5
148
+ 2.3.4
data/Gemfile.rails6 ADDED
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
3
+
4
+ gem 'activesupport', '~> 6.1'
5
+ gem 'activerecord', '~> 6.1'
6
+ gem 'activejob', '~> 6.1'
@@ -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.9.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)
@@ -17,11 +17,13 @@ Gem::Specification.new do |s|
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'
@@ -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,12 +7,6 @@ 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
- if ActiveRecord.respond_to?(:default_timezone=)
17
- ActiveRecord.default_timezone = :utc
18
- else
19
- ActiveRecord::Base.default_timezone = :utc
20
- end
21
10
  ActiveRecord::Base.configurations = configurations
22
11
  ActiveRecord::Base.establish_connection(Grape::App.env.to_sym)
23
12
 
@@ -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
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
@@ -32,7 +32,37 @@ RSpec.describe Grape::App do
32
32
  it 'configures i18n' do
33
33
  expect(I18n.load_path).to include(subject.root.join('config', 'locales', 'en.yml').to_s)
34
34
  expect(I18n.default_locale).to eq(:en)
35
- expect(I18n.exception_handler).to be_instance_of(Proc)
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)
36
66
  end
37
67
 
38
68
  it 'reads env specific initializers' do
data/spec/spec_helper.rb CHANGED
@@ -2,6 +2,7 @@ ENV['RACK_ENV'] ||= 'test'
2
2
  require 'grape-app'
3
3
  require 'rack/test'
4
4
  require 'active_record'
5
+ require 'active_job'
5
6
 
6
7
  ActiveRecord::Base.configurations = { 'test' => { 'adapter' => 'sqlite3', 'database' => ':memory:' } }
7
8
  ActiveRecord::Base.establish_connection :test
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.9.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: 2022-01-27 00:00:00.000000000 Z
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
@@ -108,6 +122,20 @@ dependencies:
108
122
  - - ">="
109
123
  - !ruby/object:Gem::Version
110
124
  version: '2.1'
125
+ - !ruby/object:Gem::Dependency
126
+ name: activejob
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
111
139
  - !ruby/object:Gem::Dependency
112
140
  name: activerecord
113
141
  requirement: !ruby/object:Gem::Requirement
@@ -220,6 +248,8 @@ files:
220
248
  - ".rubocop.yml"
221
249
  - Gemfile
222
250
  - Gemfile.lock
251
+ - Gemfile.rails6
252
+ - Gemfile.rails6.lock
223
253
  - LICENSE
224
254
  - README.md
225
255
  - Rakefile