ditty 0.3.3 → 0.4.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
- SHA1:
3
- metadata.gz: a55bb96414dd9974ba6f8ce44aadacbc340967e4
4
- data.tar.gz: c529f7ac183eedfc9530d7c8703660d9a8894093
2
+ SHA256:
3
+ metadata.gz: 2fea055fdddd9b21951527617015b2926b064191dfda753fd930037738122c50
4
+ data.tar.gz: b8d1cc9f9430ff39d3f345719a0988f51bc03f4a7f718fabe78a69d314e5762a
5
5
  SHA512:
6
- metadata.gz: 759f21f4031b46c3f486081f238d8846402c0c1d7c85dab75fc6f19d096757150020e217531772e5cfca88c6a32031663a8fb71692a046c2956010d63c70cd24
7
- data.tar.gz: b821ad004ff984706263355b5408ae66d33f0f230fe22057fefd28dc075308a7c74928f11b68ab08fa3540220b042fb386f82caded9400fe9847222aced3366c
6
+ metadata.gz: eafbcf7aaadabc7e9458f403cf2252b3311dc9a716f08884c1651055426864e796866e60f7c3986be4405cc83d3d0552d49fca43e2764e516066884a56e7c4ea
7
+ data.tar.gz: f2f3b62750d7711bdd59ee7e0df4630ec89992cda013d5e5e96736aa541a5a2cd55ff096de65b774bef4ab74c90e0983a7a3826d30a498e3a3a474bd1cdfc1cf
@@ -6,19 +6,24 @@ rvm:
6
6
  - 2.2.6
7
7
  gemfile: Gemfile.ci
8
8
  env:
9
- - DATABASE_URL="sqlite::memory:" RACK_ENV=test
9
+ global:
10
+ - CC_TEST_REPORTER_ID=289860573c6284a8e277de86848caba84d840be49e35f3601bcd672ab40d1e35
11
+ matrix:
12
+ - DATABASE_URL="sqlite::memory:" RACK_ENV=test
10
13
  before_install:
11
- - gem install bundler -v 1.12.5
14
+ - gem install bundler -v 1.12.5
12
15
  before_script:
13
- - bundle exec rake ditty:prep
16
+ - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
17
+ - chmod +x ./cc-test-reporter
18
+ - ./cc-test-reporter before-build
19
+ - bundle exec rake ditty:prep
14
20
  script:
15
- - bundle exec rake
16
- - bundle exec rubocop --fail-level W lib views
17
- addons:
18
- code_climate:
19
- repo_token: 289860573c6284a8e277de86848caba84d840be49e35f3601bcd672ab40d1e35
21
+ - bundle exec rake
22
+ - bundle exec rubocop --fail-level W lib views
23
+ after_script:
24
+ - ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
20
25
  after_success:
21
- - bundle exec codeclimate-test-reporter
26
+ - bundle exec codeclimate-test-reporter
22
27
  deploy:
23
28
  provider: rubygems
24
29
  api_key:
@@ -22,7 +22,7 @@ Gem::Specification.new do |spec|
22
22
 
23
23
  spec.add_development_dependency 'bundler', '~> 1.12'
24
24
  spec.add_development_dependency 'database_cleaner'
25
- spec.add_development_dependency 'factory_girl'
25
+ spec.add_development_dependency 'factory_bot'
26
26
  spec.add_development_dependency 'rack-test'
27
27
  spec.add_development_dependency 'racksh'
28
28
  spec.add_development_dependency 'rspec', '~> 3.0'
@@ -52,47 +52,70 @@ module Ditty
52
52
 
53
53
  not_found do
54
54
  respond_to do |format|
55
+ status 404
55
56
  format.html do
56
57
  haml :'404', locals: { title: '4 oh 4' }
57
58
  end
58
59
  format.json do
59
- [404, { 'Content-Type' => 'application/json' }, [{ code: 404, errors: ['Not Found'] }.to_json]]
60
+ json code: 404, errors: ['Not Found']
60
61
  end
61
62
  end
62
63
  end
63
64
 
64
- error do
65
- error = env['sinatra.error']
66
- broadcast(:application_error, error)
65
+ error Helpers::NotAuthenticated, ::Pundit::NotAuthorizedError do
67
66
  respond_to do |format|
67
+ status 401
68
68
  format.html do
69
- haml :error, locals: { title: 'Something went wrong', error: error }
69
+ flash[:warning] = 'Please log in first.'
70
+ redirect "#{settings.map_path}/auth/identity"
70
71
  end
71
72
  format.json do
72
- [500, { 'Content-Type' => 'application/json' }, [{ code: 500, errors: ['Something went wrong'] }.to_json]]
73
+ json code: 401, errors: ['Not Authenticated']
73
74
  end
74
75
  end
75
76
  end
76
77
 
77
- error Helpers::NotAuthenticated, ::Pundit::NotAuthorizedError do
78
+ error Sequel::ValidationFailed do
78
79
  respond_to do |format|
80
+ entity = env['sinatra.error'].model
81
+ errors = env['sinatra.error'].errors
82
+ status 400
79
83
  format.html do
80
- flash[:warning] = 'Please log in first.'
81
- redirect "#{settings.map_path}/auth/identity"
84
+ action = entity.id ? :edit : :new
85
+ haml :"#{view_location}/#{action}", locals: { entity: entity, title: heading(action) }
82
86
  end
83
87
  format.json do
84
- [401, { 'Content-Type' => 'application/json' }, [{ code: 401, errors: ['Not Authenticated'] }.to_json]]
88
+ json code: 400, errors: errors
85
89
  end
86
90
  end
87
91
  end
88
92
 
89
93
  error ::Sequel::ForeignKeyConstraintViolation do
94
+ error = env['sinatra.error']
95
+ broadcast(:application_error, error)
96
+ ::Ditty::Services::Logger.instance.error error
97
+ respond_to do |format|
98
+ status 400
99
+ format.html do
100
+ haml :error, locals: { title: 'Something went wrong', error: error }
101
+ end
102
+ format.json do
103
+ json code: 400, errors: ['Invalid Relation Specified']
104
+ end
105
+ end
106
+ end
107
+
108
+ error do
109
+ error = env['sinatra.error']
110
+ broadcast(:application_error, error)
111
+ ::Ditty::Services::Logger.instance.error error
90
112
  respond_to do |format|
113
+ status 500
91
114
  format.html do
92
115
  haml :error, locals: { title: 'Something went wrong', error: error }
93
116
  end
94
117
  format.json do
95
- [400, { 'Content-Type' => 'application/json' }, [{ code: 400, errors: ['Invalid Relation Specified'] }.to_json]]
118
+ json code: 500, errors: ['Something went wrong']
96
119
  end
97
120
  end
98
121
  end
@@ -89,20 +89,5 @@ module Ditty
89
89
  log_action("#{dehumanized}_delete".to_sym) if settings.track_actions
90
90
  delete_response(entity)
91
91
  end
92
-
93
- error Sequel::ValidationFailed do
94
- respond_to do |format|
95
- entity = env['sinatra.error'].model
96
- errors = env['sinatra.error'].errors
97
- status 400
98
- format.html do
99
- action = entity.id ? :edit : :new
100
- haml :"#{view_location}/#{action}", locals: { entity: entity, title: heading(action) }
101
- end
102
- format.json do
103
- json [400, { errors: errors }]
104
- end
105
- end
106
- end
107
92
  end
108
93
  end
@@ -1,4 +1,7 @@
1
1
  # frozen_string_literal: true
2
+ require 'ditty/models/user'
3
+ require 'ditty/models/role'
4
+ require 'ditty/models/identity'
2
5
 
3
6
  module Ditty
4
7
  module Helpers
@@ -46,15 +46,19 @@ module Ditty
46
46
  haml :'partials/delete_form', locals: locals
47
47
  end
48
48
 
49
+ def query_string(add = {})
50
+ qs = params.clone.merge(add)
51
+ qs.delete('captures')
52
+ Rack::Utils.build_query qs
53
+ end
54
+
49
55
  def pagination(list, base_path, qp = {})
50
56
  return unless list.respond_to? :pagination_record_count
51
- qs = params.clone.merge(qp)
52
- qs.delete('captures')
53
57
  locals = {
54
- first_link: "#{base_path}?#{Rack::Utils.build_query(qs.merge('page' => 1))}",
55
- next_link: list.last_page? ? '#' : "#{base_path}?#{Rack::Utils.build_query(qs.merge('page' => list.next_page))}",
56
- prev_link: list.first_page? ? '#' : "#{base_path}?#{Rack::Utils.build_query(qs.merge('page' => list.prev_page))}",
57
- last_link: "#{base_path}?#{Rack::Utils.build_query(qs.merge('page' => list.page_count))}",
58
+ first_link: "#{base_path}?" + query_string(qp.merge(page: 1)),
59
+ next_link: list.last_page? ? '#' : "#{base_path}?" + query_string(qp.merge(page: list.next_page)),
60
+ prev_link: list.first_page? ? '#' : "#{base_path}?" + query_string(qp.merge(page: list.prev_page)),
61
+ last_link: "#{base_path}?" + query_string(qp.merge(page: list.page_count)),
58
62
  base_path: base_path,
59
63
  list: list
60
64
  }
@@ -1,3 +1,5 @@
1
+ require 'ditty/services/logger'
2
+
1
3
  module Ditty
2
4
  module Middleware
3
5
  class ErrorCatchall
@@ -11,7 +13,9 @@ module Ditty
11
13
  @env = env
12
14
  begin
13
15
  @app.call env
14
- rescue StandardError
16
+ rescue StandardError => e
17
+ ::Ditty::Services::Logger.instance.error "Ditty Catchall: #{e.class}"
18
+ ::Ditty::Services::Logger.instance.error e
15
19
  [500, {}, ['Unknown Error']]
16
20
  end
17
21
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Ditty
4
- VERSION = '0.3.3'.freeze
4
+ VERSION = '0.4.0'.freeze
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ditty
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.3
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jurgens du Toit
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-01-10 00:00:00.000000000 Z
11
+ date: 2018-02-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -39,7 +39,7 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: factory_girl
42
+ name: factory_bot
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - ">="
@@ -430,7 +430,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
430
430
  version: '0'
431
431
  requirements: []
432
432
  rubyforge_project:
433
- rubygems_version: 2.6.13
433
+ rubygems_version: 2.7.4
434
434
  signing_key:
435
435
  specification_version: 4
436
436
  summary: Sinatra Based Application Framework