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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5fd7431c1a4ef8cba9d3433e9c4ef99150ce312e
4
- data.tar.gz: 78bb4402d7fdd2ee04a28640f876238e6381debe
3
+ metadata.gz: 9d466b03d28285650e9e80343a13c2937cdd8687
4
+ data.tar.gz: bd36651baf560be5a54148460b4b1ec1d7a47a2d
5
5
  SHA512:
6
- metadata.gz: b376e89a5cabcc44b96c3c781d0df82e6af0c1c083224dbb525f85918a01f4dfd3714ce2d18bb81971d158ff5c9e5f734dcd5010894ce849746a98d984adddfb
7
- data.tar.gz: 68e760d526d57c1ea3fbd88390c9f22308013db711e380f91ae9ee819bd606f00e870ebdfb902b7a249ef308419e77e096e764ff1274dd9e1329f52a53fd6503
6
+ metadata.gz: 72e27c2761c148dfc0a36a7a5e5da119458451077dfc9cd07a4ebd55184d49112afead1396a542b3bd1a1b6fd7ec54709fd78f09868d188e4108eb996789d00f
7
+ data.tar.gz: fd41e4bcd217adc3db9652c2ef8eec2e83618a307cf8889ef3171fc6abc52fb3b44f85cc10ae16282b9e3a0ee5221b7e20e3dc4eb58b2163e7d4a6f9d5f4266b
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- gris (0.4.0)
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.12.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.7)
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.13)
168
+ uber (0.0.14)
169
169
  uri_template (0.7.0)
170
170
  virtus (1.0.5)
171
171
  axiom-types (~> 0.1)
@@ -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
- content = @rack_static.call(env.merge('PATH_INFO' => "/errors/#{response[0]}.html"))
37
- [response[0], content[1], content[2]]
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.underscore.tableize %> = <%= name.classify %>.where(conditions)
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 %>.'
@@ -7,6 +7,7 @@ gem 'activerecord', '~> 4.2.0', require: 'active_record'
7
7
  gem 'json'
8
8
 
9
9
  gem 'gris'
10
+ gem 'gris_paginator'
10
11
 
11
12
  gem 'roar'
12
13
  gem 'grape-roar', '~> 0.3.0'
@@ -9,16 +9,16 @@ module Gris
9
9
  last_response.body
10
10
  end
11
11
 
12
- def parsed_response
13
- Hashie::Mash.new(JSON.parse(last_response.body))
12
+ def parsed_response_body
13
+ Hashie::Mash.new JSON.parse(response_body)
14
14
  end
15
15
 
16
16
  def result
17
- parsed_response
17
+ parsed_response_body
18
18
  end
19
19
 
20
20
  def embedded_results(klass)
21
- parsed_response[:_embedded][klass.name.tableize.to_sym]
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
- parsed_response['_links']
41
+ parsed_response_body['_links']
42
42
  end
43
43
 
44
44
  def link_to_self
@@ -1,5 +1,5 @@
1
1
  module Gris
2
- VERSION = '0.4.0'
2
+ VERSION = '0.4.2'
3
3
 
4
4
  class Version
5
5
  class << self
@@ -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.0
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-06 00:00:00.000000000 Z
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
@@ -1,16 +0,0 @@
1
- module Gris
2
- class Application
3
- class Configuration
4
- attr_accessor :use_app_monitor
5
-
6
- def initialize(*)
7
- super
8
- @use_app_monitor = false
9
- end
10
-
11
- def app_monitor
12
- puts "@use_app_monitor: #{@use_app_monitor}"
13
- end
14
- end
15
- end
16
- end
@@ -1,11 +0,0 @@
1
- <html>
2
- <head>
3
- <title>Page Not Found</title>
4
- </head>
5
- <body>
6
- <h1>Ooops...</h1>
7
- <p>
8
- This page could not be found.
9
- </p>
10
- </body>
11
- </html>
@@ -1,11 +0,0 @@
1
- <html>
2
- <head>
3
- <title>Unexpected Error</title>
4
- </head>
5
- <body>
6
- <h1>Ouch...</h1>
7
- <p>
8
- Something went terribly wrong.
9
- </p>
10
- </body>
11
- </html>