nxt_error_registry 0.1.6 → 0.2.4

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
  SHA256:
3
- metadata.gz: e90b9c5755bebb707489b4b5c270bcf26c8703f721279a923e4042a448e8c758
4
- data.tar.gz: bd0a76e88555845710bc574d3e2a5dada933762749e2b07c1f27abef477d282e
3
+ metadata.gz: 6fdb9fc409f6e36422e85053f4063a55e2765a4340eb7d89e9b4f5f019fe1b0e
4
+ data.tar.gz: 1f7b8eaac20431fb3a9005aaa27ed834814fcf6c85f77210523ecb237dffe412
5
5
  SHA512:
6
- metadata.gz: 0605b0b3be701bddc74c2c7ab06a69fb9c99d6ec34fdc4e31ef631111a03677d732eaa414ec098213f3287a2a7ef153d901dfbe51cd3bb6e55837ea36695e794
7
- data.tar.gz: 8519e511e66c6708d040b38c237061d6864f2afe80486135d35b0b3d06f8d7d320575beded9b360a76a0cb03d60c88886c26d550314f0b9215d062f500305479
6
+ metadata.gz: 5c2a3b5970c9c7c3f3b024937c380ea670f9a9e14562f75046cd12a6b941496632298959cb434620fa3169b6bc5129d653ce74d62f4d204c0e34a6196f6b489d
7
+ data.tar.gz: 3ef377dde9c837bf3cef437b37e27aec2f1b20f4fa20cc63b87fffaea5c4ed7371e6cd6b6ba83b06b7641ec0930e868ca4bab070da73be5ac364668225677490
data/.circleci/config.yml CHANGED
@@ -4,7 +4,7 @@ jobs:
4
4
  build:
5
5
  working_directory: /home/circleci/app
6
6
  docker:
7
- - image: circleci/ruby:2.6.2-node
7
+ - image: circleci/ruby:2.7.2-node
8
8
  environment:
9
9
  RACK_ENV: test
10
10
  RAILS_ENV: test
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.6.5
1
+ 2.7.2
data/CHANGELOG.md ADDED
@@ -0,0 +1,35 @@
1
+ # v0.2.4 2021-03-26
2
+
3
+ ### Updated
4
+
5
+ - Switched Rails dependency to railties
6
+
7
+ # v0.2.3 2021-01-05
8
+
9
+ ### Updated
10
+
11
+ - Loosen Rails and ActiveSupport version constraint to allow 6.1
12
+
13
+ # v0.2.2 2020-12-28
14
+
15
+ ### Changed
16
+
17
+ - Updated dependencies
18
+
19
+ [Compare v0.2.1...v0.2.2](https://github.com/nxt-insurance/nxt_error_registry/compare/v0.2.1...v0.2.2)
20
+
21
+ # v0.2.1 2020-08-28
22
+
23
+ ### Fixed
24
+
25
+ - Allow legacy codes of format /\A\d{3}\.\d{3}\z/
26
+
27
+ [Compare v0.2.0...v0.2.1](https://github.com/nxt-insurance/nxt_error_registry/compare/v0.2.0...v0.2.1)
28
+
29
+ # v0.2.0 2020-08-25
30
+
31
+ ### Added
32
+
33
+ - Use uuids as codes instead of numeric codes in sequence
34
+
35
+ [Compare v0.1.6...v0.2.0](https://github.com/nxt-insurance/nxt_error_registry/compare/v0.1.6...v0.2.0)
data/Gemfile.lock CHANGED
@@ -1,156 +1,87 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- nxt_error_registry (0.1.6)
5
- activesupport (< 6.1)
6
- rails (< 6.1)
4
+ nxt_error_registry (0.2.4)
5
+ activesupport (~> 6.0)
6
+ railties (~> 6.0)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- actioncable (6.0.3.2)
12
- actionpack (= 6.0.3.2)
13
- nio4r (~> 2.0)
14
- websocket-driver (>= 0.6.1)
15
- actionmailbox (6.0.3.2)
16
- actionpack (= 6.0.3.2)
17
- activejob (= 6.0.3.2)
18
- activerecord (= 6.0.3.2)
19
- activestorage (= 6.0.3.2)
20
- activesupport (= 6.0.3.2)
21
- mail (>= 2.7.1)
22
- actionmailer (6.0.3.2)
23
- actionpack (= 6.0.3.2)
24
- actionview (= 6.0.3.2)
25
- activejob (= 6.0.3.2)
26
- mail (~> 2.5, >= 2.5.4)
27
- rails-dom-testing (~> 2.0)
28
- actionpack (6.0.3.2)
29
- actionview (= 6.0.3.2)
30
- activesupport (= 6.0.3.2)
31
- rack (~> 2.0, >= 2.0.8)
11
+ actionpack (6.1.3)
12
+ actionview (= 6.1.3)
13
+ activesupport (= 6.1.3)
14
+ rack (~> 2.0, >= 2.0.9)
32
15
  rack-test (>= 0.6.3)
33
16
  rails-dom-testing (~> 2.0)
34
17
  rails-html-sanitizer (~> 1.0, >= 1.2.0)
35
- actiontext (6.0.3.2)
36
- actionpack (= 6.0.3.2)
37
- activerecord (= 6.0.3.2)
38
- activestorage (= 6.0.3.2)
39
- activesupport (= 6.0.3.2)
40
- nokogiri (>= 1.8.5)
41
- actionview (6.0.3.2)
42
- activesupport (= 6.0.3.2)
18
+ actionview (6.1.3)
19
+ activesupport (= 6.1.3)
43
20
  builder (~> 3.1)
44
21
  erubi (~> 1.4)
45
22
  rails-dom-testing (~> 2.0)
46
23
  rails-html-sanitizer (~> 1.1, >= 1.2.0)
47
- activejob (6.0.3.2)
48
- activesupport (= 6.0.3.2)
49
- globalid (>= 0.3.6)
50
- activemodel (6.0.3.2)
51
- activesupport (= 6.0.3.2)
52
- activerecord (6.0.3.2)
53
- activemodel (= 6.0.3.2)
54
- activesupport (= 6.0.3.2)
55
- activestorage (6.0.3.2)
56
- actionpack (= 6.0.3.2)
57
- activejob (= 6.0.3.2)
58
- activerecord (= 6.0.3.2)
59
- marcel (~> 0.3.1)
60
- activesupport (6.0.3.2)
24
+ activesupport (6.1.3)
61
25
  concurrent-ruby (~> 1.0, >= 1.0.2)
62
- i18n (>= 0.7, < 2)
63
- minitest (~> 5.1)
64
- tzinfo (~> 1.1)
65
- zeitwerk (~> 2.2, >= 2.2.2)
26
+ i18n (>= 1.6, < 2)
27
+ minitest (>= 5.1)
28
+ tzinfo (~> 2.0)
29
+ zeitwerk (~> 2.3)
66
30
  builder (3.2.4)
67
- coderay (1.1.2)
68
- concurrent-ruby (1.1.6)
31
+ coderay (1.1.3)
32
+ concurrent-ruby (1.1.8)
69
33
  crass (1.0.6)
70
- diff-lcs (1.3)
71
- erubi (1.9.0)
72
- globalid (0.4.2)
73
- activesupport (>= 4.2.0)
74
- i18n (1.8.3)
34
+ diff-lcs (1.4.4)
35
+ erubi (1.10.0)
36
+ i18n (1.8.9)
75
37
  concurrent-ruby (~> 1.0)
76
- loofah (2.6.0)
38
+ loofah (2.9.0)
77
39
  crass (~> 1.0.2)
78
40
  nokogiri (>= 1.5.9)
79
- mail (2.7.1)
80
- mini_mime (>= 0.1.1)
81
- marcel (0.3.3)
82
- mimemagic (~> 0.3.2)
83
41
  method_source (1.0.0)
84
- mimemagic (0.3.5)
85
- mini_mime (1.0.2)
86
- mini_portile2 (2.4.0)
87
- minitest (5.14.1)
88
- nio4r (2.5.2)
89
- nokogiri (1.10.10)
90
- mini_portile2 (~> 2.4.0)
91
- pry (0.13.1)
42
+ mini_portile2 (2.5.0)
43
+ minitest (5.14.4)
44
+ nokogiri (1.11.2)
45
+ mini_portile2 (~> 2.5.0)
46
+ racc (~> 1.4)
47
+ pry (0.14.0)
92
48
  coderay (~> 1.1)
93
49
  method_source (~> 1.0)
50
+ racc (1.5.2)
94
51
  rack (2.2.3)
95
52
  rack-test (1.1.0)
96
53
  rack (>= 1.0, < 3)
97
- rails (6.0.3.2)
98
- actioncable (= 6.0.3.2)
99
- actionmailbox (= 6.0.3.2)
100
- actionmailer (= 6.0.3.2)
101
- actionpack (= 6.0.3.2)
102
- actiontext (= 6.0.3.2)
103
- actionview (= 6.0.3.2)
104
- activejob (= 6.0.3.2)
105
- activemodel (= 6.0.3.2)
106
- activerecord (= 6.0.3.2)
107
- activestorage (= 6.0.3.2)
108
- activesupport (= 6.0.3.2)
109
- bundler (>= 1.3.0)
110
- railties (= 6.0.3.2)
111
- sprockets-rails (>= 2.0.0)
112
54
  rails-dom-testing (2.0.3)
113
55
  activesupport (>= 4.2.0)
114
56
  nokogiri (>= 1.6)
115
57
  rails-html-sanitizer (1.3.0)
116
58
  loofah (~> 2.3)
117
- railties (6.0.3.2)
118
- actionpack (= 6.0.3.2)
119
- activesupport (= 6.0.3.2)
59
+ railties (6.1.3)
60
+ actionpack (= 6.1.3)
61
+ activesupport (= 6.1.3)
120
62
  method_source
121
63
  rake (>= 0.8.7)
122
- thor (>= 0.20.3, < 2.0)
123
- rake (13.0.1)
124
- rspec (3.9.0)
125
- rspec-core (~> 3.9.0)
126
- rspec-expectations (~> 3.9.0)
127
- rspec-mocks (~> 3.9.0)
128
- rspec-core (3.9.0)
129
- rspec-support (~> 3.9.0)
130
- rspec-expectations (3.9.0)
64
+ thor (~> 1.0)
65
+ rake (13.0.3)
66
+ rspec (3.10.0)
67
+ rspec-core (~> 3.10.0)
68
+ rspec-expectations (~> 3.10.0)
69
+ rspec-mocks (~> 3.10.0)
70
+ rspec-core (3.10.1)
71
+ rspec-support (~> 3.10.0)
72
+ rspec-expectations (3.10.1)
131
73
  diff-lcs (>= 1.2.0, < 2.0)
132
- rspec-support (~> 3.9.0)
133
- rspec-mocks (3.9.0)
74
+ rspec-support (~> 3.10.0)
75
+ rspec-mocks (3.10.2)
134
76
  diff-lcs (>= 1.2.0, < 2.0)
135
- rspec-support (~> 3.9.0)
136
- rspec-support (3.9.0)
77
+ rspec-support (~> 3.10.0)
78
+ rspec-support (3.10.2)
137
79
  rspec_junit_formatter (0.4.1)
138
80
  rspec-core (>= 2, < 4, != 2.12.0)
139
- sprockets (4.0.2)
81
+ thor (1.1.0)
82
+ tzinfo (2.0.4)
140
83
  concurrent-ruby (~> 1.0)
141
- rack (> 1, < 3)
142
- sprockets-rails (3.2.1)
143
- actionpack (>= 4.0)
144
- activesupport (>= 4.0)
145
- sprockets (>= 3.0.0)
146
- thor (1.0.1)
147
- thread_safe (0.3.6)
148
- tzinfo (1.2.7)
149
- thread_safe (~> 0.1)
150
- websocket-driver (0.7.2)
151
- websocket-extensions (>= 0.1.0)
152
- websocket-extensions (0.1.5)
153
- zeitwerk (2.3.1)
84
+ zeitwerk (2.4.2)
154
85
 
155
86
  PLATFORMS
156
87
  ruby
data/README.md CHANGED
@@ -25,9 +25,9 @@ Or install it yourself as:
25
25
  ```ruby
26
26
  class LevelOne
27
27
  extend NxtErrorRegistry
28
- register_error :LevelOneError, type: StandardError, code: '100.100'
28
+ register_error :LevelOneError, type: StandardError, code: '84b67c94-efb4-48e8-a5e9-ed1fa1beb988'
29
29
  # This will set the LevelOne::LevelOneError constant that you can raise anywhere
30
- register_error :LevelTwoError, type: LevelOneError, code: '100.101', capture: true, reraise: false
30
+ register_error :LevelTwoError, type: LevelOneError, code: 'a7fc9a8c-9f83-4a2d-8808-75dbef8e376f', capture: true, reraise: false
31
31
  # You can also pass in additional options when registering your errors. These will be available on you error class
32
32
 
33
33
  def raise_level_one_error
@@ -48,7 +48,7 @@ All arguments are optional and will be set to a placeholder if not provided
48
48
 
49
49
  ```ruby
50
50
  rails g register_error --name NewErrorName --type SomeKindOfError
51
- # => register_error :NewErrorName, type: SomeKindOfError, code: '100.000'
51
+ # => register_error :NewErrorName, type: SomeKindOfError, code: 'fa7afa83-6c68-4186-ada4-a573b6a72bd9'
52
52
  ```
53
53
 
54
54
  ### Or use the rake task instead.
@@ -57,7 +57,7 @@ All arguments are optional and will be set to a placeholder if not provided
57
57
 
58
58
  ```ruby
59
59
  rake nxt_error_registry:generate_code\[ErrorName,ParentType\]
60
- # => register_error :ErrorName, type: ParentType, code: '100.000'
60
+ # => register_error :ErrorName, type: ParentType, code: '5c8152cd-b8b9-4fb0-a5fe-5c11d200affc'
61
61
  ```
62
62
  ## Development
63
63
 
@@ -2,43 +2,28 @@ require 'singleton'
2
2
 
3
3
  module NxtErrorRegistry
4
4
  class CodesHarness
5
+ CodeAlreadyRegistered = Class.new(StandardError)
5
6
  include Singleton
6
7
 
7
8
  def generate_code
8
- puts "WARNING: Codes are not in sequence: #{codes_not_in_sequence}" if codes_not_in_sequence.any?
9
-
10
- last_id = codes_as_ids.last
11
- return '100.000' unless last_id
12
-
13
- next_id = last_id + 1
14
- id_to_code(next_id)
9
+ generate_next_code
10
+ rescue CodeAlreadyRegistered
11
+ retry
15
12
  end
16
13
 
17
- def codes_not_in_sequence
18
- previous_id = nil
19
-
20
- codes_as_ids.inject([]) do |acc, id|
21
- if !previous_id || previous_id + 1 == id
22
- previous_id = id
23
- acc
24
- else
25
- acc << [previous_id, id]
26
- previous_id = id
27
- acc
28
- end
29
- end
30
- end
14
+ def generate_next_code
15
+ new_code = SecureRandom.uuid
16
+ return new_code unless registered_codes.include?(new_code)
31
17
 
32
- def codes_as_ids
33
- registry.codes.map { |code| Integer(code.delete('.')) }.sort
18
+ raise CodeAlreadyRegistered, "#{new_code} already registered"
34
19
  end
35
20
 
36
- def id_to_code(code)
37
- "#{code.to_s[0..2]}.#{code.to_s[3..-1]}"
21
+ def registered_codes
22
+ registry.codes
38
23
  end
39
24
 
40
25
  def registry
41
26
  NxtErrorRegistry::Registry.instance
42
27
  end
43
28
  end
44
- end
29
+ end
@@ -3,7 +3,8 @@ module NxtErrorRegistry
3
3
  CodeAlreadyTakenError = Class.new(StandardError)
4
4
  InvalidCodeFormatError = Class.new(StandardError)
5
5
 
6
- FORMAT = /\A\d{3}\.\d{3}\z/
6
+ LEGACY_FORMAT = /\A\d{3}\.\d{3}\z/
7
+ FORMAT = /\A[a-zA-Z0-9-]{36}|#{LEGACY_FORMAT}\z/
7
8
 
8
9
  def initialize(name, type, code, context)
9
10
  @name = name
@@ -25,11 +26,12 @@ module NxtErrorRegistry
25
26
 
26
27
  def validate_code_format
27
28
  return if code =~ FORMAT
29
+
28
30
  raise InvalidCodeFormatError, "Code #{code} for name #{name} violates format #{FORMAT} in context: #{context}"
29
31
  end
30
32
 
31
33
  def validate_code_uniqueness
32
- duplicates = registry.duplicate_codes
34
+ duplicates = registry.duplicated_codes
33
35
  return if duplicates.empty?
34
36
 
35
37
  raise CodeAlreadyTakenError, "The following codes are duplicated: #{duplicates.keys.join(',')}"
@@ -39,4 +41,4 @@ module NxtErrorRegistry
39
41
  NxtErrorRegistry::Registry.instance
40
42
  end
41
43
  end
42
- end
44
+ end
@@ -32,8 +32,8 @@ module NxtErrorRegistry
32
32
  end
33
33
  end
34
34
 
35
- def duplicate_codes
35
+ def duplicated_codes
36
36
  entries_by_codes.select { |_, v| v.size > 1 }
37
37
  end
38
38
  end
39
- end
39
+ end
@@ -1,3 +1,3 @@
1
1
  module NxtErrorRegistry
2
- VERSION = "0.1.6".freeze
2
+ VERSION = "0.2.4".freeze
3
3
  end
@@ -5,11 +5,10 @@ require "nxt_error_registry/version"
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "nxt_error_registry"
7
7
  spec.version = NxtErrorRegistry::VERSION
8
- spec.authors = ["Andreas Robecke", "Nils Sommer", "Raphael Kallensee"]
8
+ spec.authors = ["Andreas Robecke", "Nils Sommer", "Raphael Kallensee", "Akihiko Ito"]
9
9
  spec.email = ["a.robecke@getsafe.de"]
10
10
 
11
- spec.summary = %q{Write a short summary, because RubyGems requires one.}
12
- spec.description = %q{Write a longer description or delete this line.}
11
+ spec.summary = %q{Registry to register errors with unique codes and more.}
13
12
  spec.homepage = "https://github.com/nxt-insurance"
14
13
  spec.license = "MIT"
15
14
 
@@ -20,6 +19,7 @@ Gem::Specification.new do |spec|
20
19
 
21
20
  spec.metadata["homepage_uri"] = spec.homepage
22
21
  spec.metadata["source_code_uri"] = "https://github.com/nxt-insurance/nxt_error_registry"
22
+ spec.metadata["changelog_uri"] = "https://github.com/nxt-insurance/nxt_error_registry/CHANGELOG.md"
23
23
  else
24
24
  raise "RubyGems 2.0 or newer is required to protect against " \
25
25
  "public gem pushes."
@@ -39,6 +39,6 @@ Gem::Specification.new do |spec|
39
39
  spec.add_development_dependency "rspec", "~> 3.0"
40
40
  spec.add_development_dependency "rspec_junit_formatter", "~> 0.4.1"
41
41
  spec.add_development_dependency "pry"
42
- spec.add_dependency "activesupport", "< 6.1"
43
- spec.add_dependency "rails", "< 6.1"
42
+ spec.add_dependency 'activesupport', '~> 6.0'
43
+ spec.add_dependency "railties", "~> 6.0"
44
44
  end
metadata CHANGED
@@ -1,16 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nxt_error_registry
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andreas Robecke
8
8
  - Nils Sommer
9
9
  - Raphael Kallensee
10
+ - Akihiko Ito
10
11
  autorequire:
11
12
  bindir: exe
12
13
  cert_chain: []
13
- date: 2020-07-09 00:00:00.000000000 Z
14
+ date: 2021-03-26 00:00:00.000000000 Z
14
15
  dependencies:
15
16
  - !ruby/object:Gem::Dependency
16
17
  name: bundler
@@ -86,31 +87,31 @@ dependencies:
86
87
  name: activesupport
87
88
  requirement: !ruby/object:Gem::Requirement
88
89
  requirements:
89
- - - "<"
90
+ - - "~>"
90
91
  - !ruby/object:Gem::Version
91
- version: '6.1'
92
+ version: '6.0'
92
93
  type: :runtime
93
94
  prerelease: false
94
95
  version_requirements: !ruby/object:Gem::Requirement
95
96
  requirements:
96
- - - "<"
97
+ - - "~>"
97
98
  - !ruby/object:Gem::Version
98
- version: '6.1'
99
+ version: '6.0'
99
100
  - !ruby/object:Gem::Dependency
100
- name: rails
101
+ name: railties
101
102
  requirement: !ruby/object:Gem::Requirement
102
103
  requirements:
103
- - - "<"
104
+ - - "~>"
104
105
  - !ruby/object:Gem::Version
105
- version: '6.1'
106
+ version: '6.0'
106
107
  type: :runtime
107
108
  prerelease: false
108
109
  version_requirements: !ruby/object:Gem::Requirement
109
110
  requirements:
110
- - - "<"
111
+ - - "~>"
111
112
  - !ruby/object:Gem::Version
112
- version: '6.1'
113
- description: Write a longer description or delete this line.
113
+ version: '6.0'
114
+ description:
114
115
  email:
115
116
  - a.robecke@getsafe.de
116
117
  executables: []
@@ -121,6 +122,7 @@ files:
121
122
  - ".gitignore"
122
123
  - ".rspec"
123
124
  - ".ruby-version"
125
+ - CHANGELOG.md
124
126
  - Gemfile
125
127
  - Gemfile.lock
126
128
  - LICENSE.txt
@@ -144,6 +146,7 @@ metadata:
144
146
  allowed_push_host: https://rubygems.org
145
147
  homepage_uri: https://github.com/nxt-insurance
146
148
  source_code_uri: https://github.com/nxt-insurance/nxt_error_registry
149
+ changelog_uri: https://github.com/nxt-insurance/nxt_error_registry/CHANGELOG.md
147
150
  post_install_message:
148
151
  rdoc_options: []
149
152
  require_paths:
@@ -159,8 +162,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
159
162
  - !ruby/object:Gem::Version
160
163
  version: '0'
161
164
  requirements: []
162
- rubygems_version: 3.0.3
165
+ rubygems_version: 3.1.4
163
166
  signing_key:
164
167
  specification_version: 4
165
- summary: Write a short summary, because RubyGems requires one.
168
+ summary: Registry to register errors with unique codes and more.
166
169
  test_files: []