gris 0.4.0 → 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +4 -4
- data/lib/gris/application.rb +2 -7
- data/lib/gris/generators/templates/api/app/endpoints/%name_tableize%_endpoint.rb.tt +1 -2
- data/lib/gris/generators/templates/scaffold/Gemfile.tt +1 -0
- data/lib/gris/rspec_extensions/response_helpers.rb +5 -5
- data/lib/gris/version.rb +1 -1
- data/spec/generators/api_generator_spec.rb +6 -0
- data/spec/generators/scaffold_generator_spec.rb +5 -0
- metadata +2 -5
- data/lib/gris/application/configuration.rb +0 -16
- data/lib/gris/public/errors/404.html +0 -11
- data/lib/gris/public/errors/500.html +0 -11
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9d466b03d28285650e9e80343a13c2937cdd8687
|
|
4
|
+
data.tar.gz: bd36651baf560be5a54148460b4b1ec1d7a47a2d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 72e27c2761c148dfc0a36a7a5e5da119458451077dfc9cd07a4ebd55184d49112afead1396a542b3bd1a1b6fd7ec54709fd78f09868d188e4108eb996789d00f
|
|
7
|
+
data.tar.gz: fd41e4bcd217adc3db9652c2ef8eec2e83618a307cf8889ef3171fc6abc52fb3b44f85cc10ae16282b9e3a0ee5221b7e20e3dc4eb58b2163e7d4a6f9d5f4266b
|
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
gris (0.4.
|
|
4
|
+
gris (0.4.2)
|
|
5
5
|
activesupport (~> 4.2, >= 4.2.0)
|
|
6
6
|
chronic (~> 0.10.0)
|
|
7
7
|
dalli (~> 2.7)
|
|
@@ -74,7 +74,7 @@ GEM
|
|
|
74
74
|
ffi (1.9.8)
|
|
75
75
|
futuroscope (0.1.11)
|
|
76
76
|
git (1.2.9.1)
|
|
77
|
-
grape (0.
|
|
77
|
+
grape (0.13.0)
|
|
78
78
|
activesupport
|
|
79
79
|
builder
|
|
80
80
|
hashie (>= 2.1.0)
|
|
@@ -84,7 +84,7 @@ GEM
|
|
|
84
84
|
rack-accept
|
|
85
85
|
rack-mount
|
|
86
86
|
virtus (>= 1.0.0)
|
|
87
|
-
grape-entity (0.4.
|
|
87
|
+
grape-entity (0.4.8)
|
|
88
88
|
activesupport
|
|
89
89
|
multi_json (>= 1.3.2)
|
|
90
90
|
grape-roar (0.3.0)
|
|
@@ -165,7 +165,7 @@ GEM
|
|
|
165
165
|
thread_safe (0.3.5)
|
|
166
166
|
tzinfo (1.2.2)
|
|
167
167
|
thread_safe (~> 0.1)
|
|
168
|
-
uber (0.0.
|
|
168
|
+
uber (0.0.14)
|
|
169
169
|
uri_template (0.7.0)
|
|
170
170
|
virtus (1.0.5)
|
|
171
171
|
axiom-types (~> 0.1)
|
data/lib/gris/application.rb
CHANGED
|
@@ -8,11 +8,6 @@ module Gris
|
|
|
8
8
|
def initialize
|
|
9
9
|
Gris::Deprecations.initialization_checks
|
|
10
10
|
@filenames = ['', '.html', 'index.html', '/index.html']
|
|
11
|
-
@rack_static = ::Rack::Static.new(
|
|
12
|
-
-> { [404, {}, []] },
|
|
13
|
-
root: File.expand_path('../public', __FILE__),
|
|
14
|
-
urls: ['/']
|
|
15
|
-
)
|
|
16
11
|
end
|
|
17
12
|
|
|
18
13
|
def self.instance(config = {})
|
|
@@ -33,8 +28,8 @@ module Gris
|
|
|
33
28
|
# Render error pages or return API response
|
|
34
29
|
case response[0]
|
|
35
30
|
when 404, 500
|
|
36
|
-
|
|
37
|
-
[response[0],
|
|
31
|
+
body = { code: response[0], message: response[2] }.to_json
|
|
32
|
+
[response[0], response[1], body]
|
|
38
33
|
else
|
|
39
34
|
response
|
|
40
35
|
end
|
|
@@ -7,8 +7,7 @@ class <%= name.classify.pluralize %>Endpoint < Grape::API
|
|
|
7
7
|
end
|
|
8
8
|
get do
|
|
9
9
|
conditions = {}
|
|
10
|
-
<%= name.
|
|
11
|
-
present Kaminari.paginate_array(<%= name.underscore.tableize %>).page(params[:page]).per(params[:size]), with: <%= name.classify.pluralize %>Presenter
|
|
10
|
+
paginate <%= name.classify %>, conditions: conditions, with: <%= name.classify.pluralize %>Presenter
|
|
12
11
|
end
|
|
13
12
|
|
|
14
13
|
desc 'Create new <%= name.underscore %>.'
|
|
@@ -9,16 +9,16 @@ module Gris
|
|
|
9
9
|
last_response.body
|
|
10
10
|
end
|
|
11
11
|
|
|
12
|
-
def
|
|
13
|
-
Hashie::Mash.new
|
|
12
|
+
def parsed_response_body
|
|
13
|
+
Hashie::Mash.new JSON.parse(response_body)
|
|
14
14
|
end
|
|
15
15
|
|
|
16
16
|
def result
|
|
17
|
-
|
|
17
|
+
parsed_response_body
|
|
18
18
|
end
|
|
19
19
|
|
|
20
20
|
def embedded_results(klass)
|
|
21
|
-
|
|
21
|
+
parsed_response_body[:_embedded][klass.name.tableize.to_sym]
|
|
22
22
|
end
|
|
23
23
|
|
|
24
24
|
def embedded_results_count(klass)
|
|
@@ -38,7 +38,7 @@ module Gris
|
|
|
38
38
|
end
|
|
39
39
|
|
|
40
40
|
def links
|
|
41
|
-
|
|
41
|
+
parsed_response_body['_links']
|
|
42
42
|
end
|
|
43
43
|
|
|
44
44
|
def link_to_self
|
data/lib/gris/version.rb
CHANGED
|
@@ -21,6 +21,12 @@ describe Gris::Generators::ApiGenerator do
|
|
|
21
21
|
expect(api_code).to match(/class ArticlesEndpoint/)
|
|
22
22
|
end
|
|
23
23
|
|
|
24
|
+
it 'endpoint class uses GrisPaginator' do
|
|
25
|
+
expected_api_file = File.join(generator_tmp_directory, 'app/endpoints/articles_endpoint.rb')
|
|
26
|
+
api_code = File.read(expected_api_file)
|
|
27
|
+
expect(api_code).to match(/paginate Article, conditions: conditions, with: ArticlesPresenter/)
|
|
28
|
+
end
|
|
29
|
+
|
|
24
30
|
it 'creates a model class' do
|
|
25
31
|
expected_model_file = File.join(generator_tmp_directory, 'app/models/article.rb')
|
|
26
32
|
model_code = File.read(expected_model_file)
|
|
@@ -54,6 +54,11 @@ describe Gris::Generators::ScaffoldGenerator do
|
|
|
54
54
|
expect(gemfile).to match(/gem 'puma'/)
|
|
55
55
|
end
|
|
56
56
|
|
|
57
|
+
it 'adds the gris_paginator gem in the Gemfile' do
|
|
58
|
+
gemfile = File.read("#{app_path}/Gemfile")
|
|
59
|
+
expect(gemfile).to match(/gem 'gris_paginator'/)
|
|
60
|
+
end
|
|
61
|
+
|
|
57
62
|
it 'generates an application endpoint' do
|
|
58
63
|
expect(File).to exist("#{app_path}/app/endpoints/application_endpoint.rb")
|
|
59
64
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: gris
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.4.
|
|
4
|
+
version: 0.4.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Dylan Fareed
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2015-08-
|
|
11
|
+
date: 2015-08-15 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: thor
|
|
@@ -328,7 +328,6 @@ files:
|
|
|
328
328
|
- gris.gemspec
|
|
329
329
|
- lib/gris.rb
|
|
330
330
|
- lib/gris/application.rb
|
|
331
|
-
- lib/gris/application/configuration.rb
|
|
332
331
|
- lib/gris/caching.rb
|
|
333
332
|
- lib/gris/cli.rb
|
|
334
333
|
- lib/gris/deprecations.rb
|
|
@@ -377,8 +376,6 @@ files:
|
|
|
377
376
|
- lib/gris/middleware/health.rb
|
|
378
377
|
- lib/gris/output_formatters/paginated_presenter.rb
|
|
379
378
|
- lib/gris/output_formatters/presenter.rb
|
|
380
|
-
- lib/gris/public/errors/404.html
|
|
381
|
-
- lib/gris/public/errors/500.html
|
|
382
379
|
- lib/gris/rspec_extensions/active_record_shared_connection.rb
|
|
383
380
|
- lib/gris/rspec_extensions/response_helpers.rb
|
|
384
381
|
- lib/gris/setup.rb
|