grape-app 0.5.3 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -6
- data/.travis.yml +3 -4
- data/Gemfile.lock +36 -34
- data/bin/grape-app +1 -1
- data/grape-app.gemspec +2 -2
- data/lib/grape/app.rb +1 -1
- data/lib/grape/app/cli.rb +4 -4
- data/lib/grape/app/tasks/core.rake +2 -2
- data/lib/grape/app/tasks/databases.rake +4 -4
- data/spec/grape/app_spec.rb +11 -12
- data/spec/scenario/app/api/v1.rb +1 -1
- data/spec/spec_helper.rb +2 -2
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 11a8672b13362989bb3faea02cbcc61de91d035d8a77aed324a4b7cf1b07e303
|
4
|
+
data.tar.gz: b26a1e9ff4856e6ea6c6b1bb5227e77e182af9f6ac3a4952652e854d444be83e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 60572498effa35b2d85cece7c4dc4c6de23e5ac9d0df358284cb27db5b618cbdc797efe65b589175255eb408a8e3ae4511fedfa3f2a06b3d7c6baabec1e1cffd
|
7
|
+
data.tar.gz: 71accc244d0d64d9d72cce6a47a1440b305aac917b47e1aa991b1f52f48437dab2e9e58c086e545b6c3daa17cec175578ab5b5f64f73e1fdd0edfa347861c4df
|
data/.rubocop.yml
CHANGED
data/.travis.yml
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
grape-app (0.
|
4
|
+
grape-app (0.6.0)
|
5
5
|
activesupport
|
6
|
-
grape (>= 1.
|
6
|
+
grape (>= 1.2.0)
|
7
7
|
grape-entity
|
8
8
|
rack-cors
|
9
9
|
rack-ssl-enforcer
|
@@ -12,13 +12,13 @@ PATH
|
|
12
12
|
GEM
|
13
13
|
remote: https://rubygems.org/
|
14
14
|
specs:
|
15
|
-
activemodel (5.2.
|
16
|
-
activesupport (= 5.2.
|
17
|
-
activerecord (5.2.
|
18
|
-
activemodel (= 5.2.
|
19
|
-
activesupport (= 5.2.
|
15
|
+
activemodel (5.2.1.1)
|
16
|
+
activesupport (= 5.2.1.1)
|
17
|
+
activerecord (5.2.1.1)
|
18
|
+
activemodel (= 5.2.1.1)
|
19
|
+
activesupport (= 5.2.1.1)
|
20
20
|
arel (>= 9.0)
|
21
|
-
activesupport (5.2.
|
21
|
+
activesupport (5.2.1.1)
|
22
22
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
23
23
|
i18n (>= 0.7, < 2)
|
24
24
|
minitest (~> 5.1)
|
@@ -32,12 +32,12 @@ GEM
|
|
32
32
|
builder (3.2.3)
|
33
33
|
coercible (1.0.0)
|
34
34
|
descendants_tracker (~> 0.0.1)
|
35
|
-
concurrent-ruby (1.
|
35
|
+
concurrent-ruby (1.1.3)
|
36
36
|
descendants_tracker (0.0.4)
|
37
37
|
thread_safe (~> 0.3, >= 0.3.1)
|
38
38
|
diff-lcs (1.3)
|
39
39
|
equalizer (0.0.11)
|
40
|
-
grape (1.0
|
40
|
+
grape (1.2.0)
|
41
41
|
activesupport
|
42
42
|
builder
|
43
43
|
mustermann-grape (~> 1.0.0)
|
@@ -47,54 +47,56 @@ GEM
|
|
47
47
|
grape-entity (0.7.1)
|
48
48
|
activesupport (>= 4.0)
|
49
49
|
multi_json (>= 1.3.2)
|
50
|
-
i18n (1.
|
50
|
+
i18n (1.1.1)
|
51
51
|
concurrent-ruby (~> 1.0)
|
52
52
|
ice_nine (0.11.2)
|
53
|
+
jaro_winkler (1.5.1)
|
53
54
|
minitest (5.11.3)
|
54
55
|
multi_json (1.13.1)
|
55
|
-
mustermann (1.0.
|
56
|
+
mustermann (1.0.3)
|
56
57
|
mustermann-grape (1.0.0)
|
57
58
|
mustermann (~> 1.0.0)
|
58
59
|
parallel (1.12.1)
|
59
|
-
parser (2.5.
|
60
|
+
parser (2.5.3.0)
|
60
61
|
ast (~> 2.4.0)
|
61
|
-
powerpack (0.1.
|
62
|
-
rack (2.0.
|
62
|
+
powerpack (0.1.2)
|
63
|
+
rack (2.0.6)
|
63
64
|
rack-accept (0.4.5)
|
64
65
|
rack (>= 0.4)
|
65
66
|
rack-cors (1.0.2)
|
66
67
|
rack-ssl-enforcer (0.2.9)
|
67
|
-
rack-test (1.
|
68
|
+
rack-test (1.1.0)
|
68
69
|
rack (>= 1.0, < 3)
|
69
70
|
rainbow (3.0.0)
|
70
71
|
rake (12.3.1)
|
71
|
-
rspec (3.
|
72
|
-
rspec-core (~> 3.
|
73
|
-
rspec-expectations (~> 3.
|
74
|
-
rspec-mocks (~> 3.
|
75
|
-
rspec-core (3.
|
76
|
-
rspec-support (~> 3.
|
77
|
-
rspec-expectations (3.
|
72
|
+
rspec (3.8.0)
|
73
|
+
rspec-core (~> 3.8.0)
|
74
|
+
rspec-expectations (~> 3.8.0)
|
75
|
+
rspec-mocks (~> 3.8.0)
|
76
|
+
rspec-core (3.8.0)
|
77
|
+
rspec-support (~> 3.8.0)
|
78
|
+
rspec-expectations (3.8.2)
|
78
79
|
diff-lcs (>= 1.2.0, < 2.0)
|
79
|
-
rspec-support (~> 3.
|
80
|
-
rspec-mocks (3.
|
80
|
+
rspec-support (~> 3.8.0)
|
81
|
+
rspec-mocks (3.8.0)
|
81
82
|
diff-lcs (>= 1.2.0, < 2.0)
|
82
|
-
rspec-support (~> 3.
|
83
|
-
rspec-support (3.
|
84
|
-
rubocop (0.
|
83
|
+
rspec-support (~> 3.8.0)
|
84
|
+
rspec-support (3.8.0)
|
85
|
+
rubocop (0.60.0)
|
86
|
+
jaro_winkler (~> 1.5.1)
|
85
87
|
parallel (~> 1.10)
|
86
|
-
parser (>= 2.5)
|
88
|
+
parser (>= 2.5, != 2.5.1.1)
|
87
89
|
powerpack (~> 0.1)
|
88
90
|
rainbow (>= 2.2.2, < 4.0)
|
89
91
|
ruby-progressbar (~> 1.7)
|
90
|
-
unicode-display_width (~> 1.
|
91
|
-
ruby-progressbar (1.
|
92
|
+
unicode-display_width (~> 1.4.0)
|
93
|
+
ruby-progressbar (1.10.0)
|
92
94
|
sqlite3 (1.3.13)
|
93
|
-
thor (0.20.
|
95
|
+
thor (0.20.3)
|
94
96
|
thread_safe (0.3.6)
|
95
97
|
tzinfo (1.2.5)
|
96
98
|
thread_safe (~> 0.1)
|
97
|
-
unicode-display_width (1.
|
99
|
+
unicode-display_width (1.4.0)
|
98
100
|
virtus (1.0.5)
|
99
101
|
axiom-types (~> 0.1)
|
100
102
|
coercible (~> 1.0)
|
@@ -115,4 +117,4 @@ DEPENDENCIES
|
|
115
117
|
sqlite3
|
116
118
|
|
117
119
|
BUNDLED WITH
|
118
|
-
1.16.
|
120
|
+
1.16.4
|
data/bin/grape-app
CHANGED
data/grape-app.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s| # rubocop:disable Metrics/BlockLength
|
2
2
|
s.name = 'grape-app'
|
3
|
-
s.version = '0.
|
3
|
+
s.version = '0.6.0'
|
4
4
|
s.authors = ['Black Square Media Ltd']
|
5
5
|
s.email = ['info@blacksquaremedia.com']
|
6
6
|
s.summary = %(Stanalone Grape API apps)
|
@@ -15,7 +15,7 @@ Gem::Specification.new do |s| # rubocop:disable Metrics/BlockLength
|
|
15
15
|
s.required_ruby_version = '>= 2.2'
|
16
16
|
|
17
17
|
s.add_dependency 'activesupport'
|
18
|
-
s.add_dependency 'grape', '>= 1.
|
18
|
+
s.add_dependency 'grape', '>= 1.2.0'
|
19
19
|
s.add_dependency 'grape-entity'
|
20
20
|
s.add_dependency 'rack-cors'
|
21
21
|
s.add_dependency 'rack-ssl-enforcer'
|
data/lib/grape/app.rb
CHANGED
data/lib/grape/app/cli.rb
CHANGED
@@ -11,24 +11,24 @@ module Grape::App::CLI
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def copy_templates
|
14
|
-
prefix = File.join(self.class.source_root,
|
14
|
+
prefix = File.join(self.class.source_root, '')
|
15
15
|
|
16
16
|
Dir[File.join(self.class.source_root, '**', '*')].each do |file|
|
17
17
|
next if File.directory?(file)
|
18
18
|
|
19
|
-
file.sub! prefix,
|
19
|
+
file.sub! prefix, ''
|
20
20
|
copy_file file, File.join(name, file)
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
24
|
def init_lib
|
25
|
-
empty_directory File.join(name,
|
25
|
+
empty_directory File.join(name, 'lib', name)
|
26
26
|
end
|
27
27
|
|
28
28
|
end
|
29
29
|
|
30
30
|
class Runner < Thor
|
31
|
-
register Builder, :new,
|
31
|
+
register Builder, :new, 'new NAME', 'create a new application'
|
32
32
|
|
33
33
|
desc 'console ENV', 'Launch console'
|
34
34
|
def console(env='development')
|
@@ -1,5 +1,5 @@
|
|
1
1
|
task :environment do
|
2
|
-
require Bundler.root.join(
|
2
|
+
require Bundler.root.join('config', 'environment').to_s
|
3
3
|
end
|
4
4
|
|
5
5
|
desc 'Launch console'
|
@@ -16,7 +16,7 @@ desc 'List all routes'
|
|
16
16
|
task routes: :environment do
|
17
17
|
Grape::App.routes.each do |route|
|
18
18
|
method = route.request_method.ljust(7)
|
19
|
-
path = route.path.sub(
|
19
|
+
path = route.path.sub(':version', route.version.to_s)
|
20
20
|
puts " #{method} #{path}"
|
21
21
|
end
|
22
22
|
end
|
@@ -22,13 +22,13 @@ namespace :db do # rubocop:disable Metrics/BlockLength
|
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
|
-
desc
|
25
|
+
desc 'Create a new migration using NAME'
|
26
26
|
task migration: :environment do
|
27
|
-
abort
|
27
|
+
abort 'No NAME specified. Example usage: `rake db:migration NAME=create_widgets`' unless ENV['NAME']
|
28
28
|
|
29
29
|
migrations_path = ActiveRecord::Migrator.migrations_paths.first
|
30
30
|
|
31
|
-
name = ENV[
|
31
|
+
name = ENV['NAME']
|
32
32
|
path = File.join(migrations_path, "#{Time.now.utc.strftime('%Y%m%d%H%M%S')}_#{name}.rb")
|
33
33
|
|
34
34
|
ar_version = [ActiveRecord::VERSION::MAJOR, ActiveRecord::VERSION::MINOR].join('.')
|
@@ -44,7 +44,7 @@ namespace :db do # rubocop:disable Metrics/BlockLength
|
|
44
44
|
end
|
45
45
|
|
46
46
|
namespace :test do
|
47
|
-
desc
|
47
|
+
desc 'Prepare test DB'
|
48
48
|
task :prepare
|
49
49
|
end
|
50
50
|
|
data/spec/grape/app_spec.rb
CHANGED
@@ -12,24 +12,24 @@ RSpec.describe Grape::App do
|
|
12
12
|
|
13
13
|
it 'should have an env' do
|
14
14
|
expect(subject.env).to be_instance_of(ActiveSupport::StringInquirer)
|
15
|
-
expect(subject.env).to eq(
|
15
|
+
expect(subject.env).to eq('test')
|
16
16
|
end
|
17
17
|
|
18
18
|
it 'should have an root' do
|
19
19
|
expect(subject.root).to be_instance_of(Pathname)
|
20
20
|
end
|
21
21
|
|
22
|
-
it 'should be an API' do
|
23
|
-
expect(subject).to be < Grape::API
|
22
|
+
it 'should be an API instance' do
|
23
|
+
expect(subject).to be < Grape::API::Instance
|
24
24
|
end
|
25
25
|
|
26
26
|
it 'should init with default time zone' do
|
27
|
-
expect(Time.zone.name).to eq(
|
28
|
-
expect(Thread.new { Time.zone }.value.name).to eq(
|
27
|
+
expect(Time.zone.name).to eq('UTC')
|
28
|
+
expect(Thread.new { Time.zone }.value.name).to eq('UTC')
|
29
29
|
end
|
30
30
|
|
31
31
|
it 'should configure i18n' do
|
32
|
-
expect(I18n.load_path).to include(subject.root.join(
|
32
|
+
expect(I18n.load_path).to include(subject.root.join('config', 'locales', 'en.yml').to_s)
|
33
33
|
expect(I18n.default_locale).to eq(:en)
|
34
34
|
expect(I18n.exception_handler).to be_instance_of(Proc)
|
35
35
|
end
|
@@ -46,7 +46,7 @@ RSpec.describe Grape::App do
|
|
46
46
|
it 'should prepare middleware' do
|
47
47
|
expect(subject.middleware).to be_instance_of(Rack::Builder)
|
48
48
|
expect(subject.middleware.send(:instance_variable_get, :@use).size).to eq(2)
|
49
|
-
expect(subject.middleware.send(:instance_variable_get, :@run)).to
|
49
|
+
expect(subject.middleware.send(:instance_variable_get, :@run)).to be(subject)
|
50
50
|
end
|
51
51
|
|
52
52
|
it 'should apply middleware' do
|
@@ -55,8 +55,8 @@ RSpec.describe Grape::App do
|
|
55
55
|
expect(last_response).to be_ok
|
56
56
|
expect(last_response.body).to eq(%({"status":"OK"}))
|
57
57
|
expect(last_response.headers).to include(
|
58
|
-
|
59
|
-
|
58
|
+
'Access-Control-Allow-Origin' => '*',
|
59
|
+
'X-MyApp' => 'true',
|
60
60
|
)
|
61
61
|
|
62
62
|
header 'Origin', 'test.host'
|
@@ -64,9 +64,8 @@ RSpec.describe Grape::App do
|
|
64
64
|
expect(last_response).to be_bad_request
|
65
65
|
expect(last_response.body).to eq(%({"error":"bad request"}))
|
66
66
|
expect(last_response.headers).to include(
|
67
|
-
|
68
|
-
|
67
|
+
'Access-Control-Allow-Origin' => '*',
|
68
|
+
'X-MyApp' => 'true',
|
69
69
|
)
|
70
70
|
end
|
71
|
-
|
72
71
|
end
|
data/spec/scenario/app/api/v1.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
ENV['RACK_ENV'] ||=
|
1
|
+
ENV['RACK_ENV'] ||= 'test'
|
2
2
|
require 'grape-app'
|
3
|
-
require
|
3
|
+
require 'rack/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.
|
4
|
+
version: 0.6.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: 2018-
|
11
|
+
date: 2018-11-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 1.
|
33
|
+
version: 1.2.0
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 1.
|
40
|
+
version: 1.2.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: grape-entity
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -268,7 +268,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
268
268
|
version: '0'
|
269
269
|
requirements: []
|
270
270
|
rubyforge_project:
|
271
|
-
rubygems_version: 2.7.
|
271
|
+
rubygems_version: 2.7.6
|
272
272
|
signing_key:
|
273
273
|
specification_version: 4
|
274
274
|
summary: Stanalone Grape API apps
|