ndr_error 1.1.2 → 1.1.3

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
  SHA1:
3
- metadata.gz: ddda046dd4b73629785aa7cd51d72348ca08c302
4
- data.tar.gz: 181739df73555edf394803a07140889732154e4f
3
+ metadata.gz: 18c4994bc7ec7b91eb2c3a2d60a6db73cbc054d8
4
+ data.tar.gz: a9b52f7802cd09c0468154a3598c904b7a12cf82
5
5
  SHA512:
6
- metadata.gz: d860f1e9cde5543eb53ee3e22236e781c91c2933abfc1a693560545e5cf5d0a74cbc961c3bb2113ed22ada2d7dc4d1688fcd46828b2e921ff3a45cc603d076d6
7
- data.tar.gz: 30eb0b7d57d45f4827b85db658dd8bb01d54dd6f592bcbc632f833020e22a45d2573c9b012875d50c595bb73cbe0c42e75df6af29cf07be8d886aab86a6e20dd
6
+ metadata.gz: 21698703d3cd2e149b9826420b074f1bfce832da87d22519fca7f801eafebd5a1f5cdaa9819b96683c54bbcf62cb716c7b9dc5ce751cfd4f4545ebb14edeebc2
7
+ data.tar.gz: 8e9c013e9fb0e5e17bc96011281e0358937820c5d3b72c901bd2a09592a75f16d4becc27288baa93efebe1f6aa6a084bdf2950a60488f8e3ad6f0b1074682608
@@ -0,0 +1,13 @@
1
+ @function twbs-font-path($path) {
2
+ @return font-path($path);
3
+ }
4
+
5
+ @function twbs-image-path($path) {
6
+ @return image-path($path);
7
+ }
8
+
9
+ // Use the above functions where required:
10
+ $bootstrap-sass-asset-helper: true;
11
+
12
+ // Look for fonts in the ndr_error namespace:
13
+ $icon-font-path: 'ndr_error/bootstrap/';
@@ -1,7 +1,3 @@
1
- //= depend_on "bootstrap/glyphicons-halflings-regular.eot"
2
- //= depend_on "bootstrap/glyphicons-halflings-regular.svg"
3
- //= depend_on "bootstrap/glyphicons-halflings-regular.ttf"
4
- //= depend_on "bootstrap/glyphicons-halflings-regular.woff"
5
1
  //
6
2
  // Glyphicons for Bootstrap
7
3
  //
@@ -1,7 +1,3 @@
1
- // a flag to toggle asset pipeline / compass integration
2
- // defaults to true if twbs-font-path function is present (no function => twbs-font-path('') parsed as string == right side)
3
- // in Sass 3.3 this can be improved with: function-exists(twbs-font-path)
4
- $bootstrap-sass-asset-helper: (twbs-font-path("") != unquote('twbs-font-path("")')) !default;
5
1
  //
6
2
  // Variables
7
3
  // --------------------------------------------------
@@ -1,3 +1,6 @@
1
+ // First thing: Ensure asset pipeline compatibility:
2
+ @import "bootstrap-sprockets.scss";
3
+
1
4
  // Core variables and mixins
2
5
  @import "variables";
3
6
  @import "mixins";
@@ -14,17 +14,13 @@ module NdrError
14
14
  end
15
15
 
16
16
  def show
17
- @error =
18
- if (id = params[:log_id])
19
- @fingerprint.error_logs.find(id)
20
- else
21
- @fingerprint.error_logs.first
22
- end
17
+ logs = @fingerprint.error_logs.not_deleted
18
+ @error = (id = params[:log_id]) ? logs.find_by(error_logid: id) : logs.first
23
19
 
24
- return unless @error.nil?
25
-
26
- flash[:error] = 'No matching Logs exist for that Fingerprint!'
27
- redirect_to error_fingerprints_url(q: @fingerprint.to_param)
20
+ if @error.nil?
21
+ flash[:error] = 'No matching Logs exist for that Fingerprint!'
22
+ redirect_to error_fingerprints_url(q: @fingerprint.to_param)
23
+ end
28
24
  end
29
25
 
30
26
  def edit
@@ -3,7 +3,7 @@ module NdrError
3
3
  module ErrorsHelper
4
4
  def search_matches(string, keywords)
5
5
  return string if keywords.blank?
6
- highlight(string, keywords, highlighter: '<strong class="text-danger">\1</strong>')
6
+ highlight(string.to_s, keywords, highlighter: '<strong class="text-danger">\1</strong>')
7
7
  end
8
8
 
9
9
  def highlighted_trace_for(error)
@@ -81,7 +81,7 @@ module NdrError
81
81
  def previous_button_for(error)
82
82
  css = 'btn btn-default'
83
83
  css << ' disabled' if error.nil?
84
- text = glyphicon_tag('chevron-left') + h('previous occurrence')
84
+ text = glyphicon_tag('chevron-left') + h('Previous Occurrence')
85
85
  path = error.nil? ? '#' : error_fingerprint_path(error.error_fingerprint, log_id: error)
86
86
 
87
87
  link_to(text, path, class: css)
@@ -90,7 +90,7 @@ module NdrError
90
90
  def next_button_for(error)
91
91
  css = 'btn btn-default'
92
92
  css << ' disabled' if error.nil?
93
- text = h('next occurrence') + glyphicon_tag('chevron-right')
93
+ text = h('Next Occurrence') + glyphicon_tag('chevron-right')
94
94
  path = error.nil? ? '#' : error_fingerprint_path(error.error_fingerprint, log_id: error)
95
95
 
96
96
  link_to(text, path, class: css)
@@ -7,15 +7,16 @@ module NdrError
7
7
  self.primary_key = 'error_fingerprintid'
8
8
 
9
9
  has_many :error_logs,
10
+ -> { latest_first },
10
11
  autosave: true,
11
12
  class_name: 'NdrError::Log',
12
13
  foreign_key: 'error_fingerprintid'
13
14
 
14
15
  validate :ensure_ticket_url_matched_a_supplied_format
15
16
 
16
- default_scope do
17
+ scope :latest_first, lambda {
17
18
  order("#{table_name}.updated_at DESC, #{table_name}.error_fingerprintid DESC")
18
- end
19
+ }
19
20
 
20
21
  def self.filter_by_keywords(keywords)
21
22
  md5_match = keywords.map do |part|
@@ -73,7 +74,7 @@ module NdrError
73
74
  # have been loaded by rails internally
74
75
  # and won't have default scoping applied.
75
76
  def first_occurrence
76
- @_first ||= error_logs.reload.last
77
+ error_logs.last
77
78
  end
78
79
 
79
80
  # Returns the record corresponding to the
@@ -82,7 +83,7 @@ module NdrError
82
83
  # have been loaded by rails internally
83
84
  # and won't have default scoping applied.
84
85
  def latest_occurrence
85
- @_latest ||= error_logs.reload.first
86
+ error_logs.first
86
87
  end
87
88
  end
88
89
  end
@@ -19,10 +19,10 @@ module NdrError
19
19
  class_name: 'NdrError::Fingerprint',
20
20
  foreign_key: 'error_fingerprintid'
21
21
 
22
- default_scope do
23
- scope = where("(status is null) or (status not like 'deleted%')")
24
- scope.order('created_at DESC, error_logid DESC')
25
- end
22
+ scope :deleted, -> { where("status like 'deleted%'") }
23
+ scope :not_deleted, -> { where("(status is null) or (status not like 'deleted%')") }
24
+
25
+ scope :latest_first, -> { order('created_at DESC, error_logid DESC') }
26
26
 
27
27
  validates :error_fingerprintid, presence: true
28
28
  validates :description, presence: true
@@ -50,21 +50,12 @@ module NdrError
50
50
  where(name_match)
51
51
  end
52
52
 
53
- # Make explicit when circumventing the default scope
54
- def self.including_deleted_logs(&block)
55
- unscoped(&block)
56
- end
57
-
58
53
  # Deletes all those errors that have been flagged for
59
54
  # deletion and whose soft-delete grace period has ended.
60
55
  #
61
56
  # Returns true if any records were deleted.
62
57
  def self.perform_cleanup!
63
- records = including_deleted_logs do
64
- where("status like 'deleted%'")
65
- end
66
-
67
- destroys = records.map do |record|
58
+ destroys = deleted.map do |record|
68
59
  stamp_string = record.status.sub(/^[^\d]+/, '')
69
60
  record.destroy if Time.zone.parse(stamp_string) < NdrError.log_grace_period.ago
70
61
  end
@@ -75,7 +66,7 @@ module NdrError
75
66
  # Finds gets all errors that share an MD5 hash
76
67
  # (including _error_).
77
68
  def self.similar_to(error)
78
- error.error_fingerprint.error_logs
69
+ error.error_fingerprint.error_logs.not_deleted
79
70
  end
80
71
 
81
72
  # Gets similar errors.
@@ -26,7 +26,7 @@
26
26
  </div>
27
27
 
28
28
  <div class="container">
29
- <div class="row">
29
+ <div>
30
30
  <% if flash[:notice] %>
31
31
  <div class="alert alert-info"><%= flash[:notice] %></div>
32
32
  <% end %>
@@ -1,4 +1,4 @@
1
- <div class="container">
1
+ <div>
2
2
  <div class="pull-right">
3
3
  <div class="btn-group">
4
4
  <%= ticket_link_for(@fingerprint) if @fingerprint.ticket_url.present? %>
@@ -14,7 +14,7 @@
14
14
 
15
15
  <div class="btn-group">
16
16
  <a class="btn btn-default dropdown-toggle" data-toggle="dropdown" href="#">
17
- <%= pluralize(@error.similar_errors.length, 'similar error') %> stored
17
+ <%= pluralize(@error.similar_errors.length, 'Similar Error') %> Stored
18
18
  <span class="caret"></span>
19
19
  </a>
20
20
  <ul class="dropdown-menu">
@@ -1,5 +1,5 @@
1
1
  # Adds complete ERROR_FINGERPRINT table to schema
2
- class CreateErrorFingerprints < ActiveRecord::Migration
2
+ class CreateErrorFingerprints < NdrError.migration_class
3
3
  def change
4
4
  create_table :error_fingerprints, id: false do |t|
5
5
  t.string :error_fingerprintid, primary_key: true
@@ -1,5 +1,5 @@
1
1
  # Adds partial ERROR_LOG table to schema (see README).
2
- class CreateErrorLogs < ActiveRecord::Migration
2
+ class CreateErrorLogs < NdrError.migration_class
3
3
  def change
4
4
  create_table :error_logs, id: false do |t|
5
5
  t.string :error_logid, primary_key: true
@@ -2,14 +2,14 @@ module NdrError
2
2
  # Module to help with searching through fingerprints / logs.
3
3
  module Finder
4
4
  def search(keywords)
5
- scope = Fingerprint.includes(:error_logs)
5
+ scope = Fingerprint.latest_first
6
6
  return scope unless keywords && keywords.any?
7
7
 
8
8
  # Fetch the collection of fingerprint matches:
9
9
  records = scope.filter_by_keywords(keywords).to_a
10
10
 
11
11
  # Add to that fingerprints with log records that matched the search:
12
- log_print_ids = Log.filter_by_keywords(keywords).pluck(:error_fingerprintid)
12
+ log_print_ids = Log.not_deleted.filter_by_keywords(keywords).pluck(:error_fingerprintid)
13
13
  records.concat scope.find(log_print_ids)
14
14
 
15
15
  order(records)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
  # Contains the version of NdrError. Sourced by the gemspec.
3
3
  module NdrError
4
- VERSION = '1.1.2'.freeze
4
+ VERSION = '1.1.3'.freeze
5
5
  end
data/lib/ndr_error.rb CHANGED
@@ -89,4 +89,12 @@ module NdrError
89
89
  def self.table_name_prefix
90
90
  'error_'
91
91
  end
92
+
93
+ # Rails 5 uses versioned migrations (required as of 5.1). This helper method returns an
94
+ # appropriate migration superclass for the Rails version of the host application. Note that the
95
+ # 4.2 compatability layer is targetted since all the bundled migrations were written prior to
96
+ # Rails 5.
97
+ def self.migration_class
98
+ Rails::VERSION::MAJOR < 5 ? ActiveRecord::Migration : ActiveRecord::Migration[4.2]
99
+ end
92
100
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ndr_error
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2
4
+ version: 1.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - NCRS Development Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-05-10 00:00:00.000000000 Z
11
+ date: 2017-11-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -19,7 +19,7 @@ dependencies:
19
19
  version: '4.1'
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
- version: '5.1'
22
+ version: '5.2'
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
@@ -29,7 +29,7 @@ dependencies:
29
29
  version: '4.1'
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
- version: '5.1'
32
+ version: '5.2'
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: will_paginate
35
35
  requirement: !ruby/object:Gem::Requirement
@@ -189,6 +189,7 @@ files:
189
189
  - app/assets/javascripts/ndr_error/ndr_error.js
190
190
  - app/assets/stylesheets/ndr_error/bootstrap/_alerts.scss
191
191
  - app/assets/stylesheets/ndr_error/bootstrap/_badges.scss
192
+ - app/assets/stylesheets/ndr_error/bootstrap/_bootstrap-sprockets.scss
192
193
  - app/assets/stylesheets/ndr_error/bootstrap/_breadcrumbs.scss
193
194
  - app/assets/stylesheets/ndr_error/bootstrap/_button-groups.scss
194
195
  - app/assets/stylesheets/ndr_error/bootstrap/_buttons.scss
@@ -301,7 +302,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
301
302
  version: '0'
302
303
  requirements: []
303
304
  rubyforge_project:
304
- rubygems_version: 2.5.2
305
+ rubygems_version: 2.6.14
305
306
  signing_key:
306
307
  specification_version: 4
307
308
  summary: Rails exception logging