rollday 0.3.0 → 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
2
  SHA256:
3
- metadata.gz: d2c78b5cc1611bf2a6d2766ffbd66df911882fc62e2fbcf3575450113c71e4b2
4
- data.tar.gz: 2bc833d5d56efe20e819c66ec503074fe058444dc65f7640b393fab268782c04
3
+ metadata.gz: 88eac5b844d6a7cd87818c350d03f96b5d0d470dd8c044f8bab3da9625720595
4
+ data.tar.gz: fe85155acaebfb01238ce3530bde4c3b2b9537c3a24389e36dc8466423857831
5
5
  SHA512:
6
- metadata.gz: 8f6a73ebb75e6854044f29da60c3cb98c68efd6f7dae56b66efbbe66c55847fbfdf08016c6dfacd520e261cec4162c263c7c227802c64303085e8260211cc2bc
7
- data.tar.gz: f80905eebdc8af2e5dcff399dc3ad5ff42de2c3c75fbaf7b20b5139d8cec527237bb0a14acc6b32d90b337ef57b4254c5a7ee8fedf011db0ee9fde709af55373
6
+ metadata.gz: 7249b1d26e10e71c56fca2355fe8d2f609724f476ba62a8663c55207c6fb508ab59ef455cc436a93ab4aa0cb9db5d9967dcbcc1ce4bfd82e5eabedd2f531ea7e
7
+ data.tar.gz: 62b0b30259c81d79c601c50ee5b183939da161fef4460d1d668c50d971697050a7ceccb51a5dd50f4bc5062abda367f96823c62a2f7c61db25f343b994990b70
data/Gemfile.lock CHANGED
@@ -1,7 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rollday (0.1.0)
4
+ rollday (0.4.0)
5
+ class_composer
5
6
  faraday
6
7
  rollbar
7
8
 
@@ -9,6 +10,7 @@ GEM
9
10
  remote: https://rubygems.org/
10
11
  specs:
11
12
  byebug (11.1.3)
13
+ class_composer (1.0.0)
12
14
  coderay (1.1.3)
13
15
  concurrent-ruby (1.1.10)
14
16
  diff-lcs (1.5.0)
@@ -2,9 +2,12 @@
2
2
 
3
3
  require "rollday/use_middleware"
4
4
  require "rollbar"
5
+ require "class_composer"
5
6
 
6
7
  module Rollday
7
8
  class Configuration
9
+ include ClassComposer::Generator
10
+
8
11
  ROLLBAR_LEVELS = [
9
12
  DEBUG = :debug,
10
13
  INFO = :info,
@@ -14,62 +17,21 @@ module Rollday
14
17
  ]
15
18
 
16
19
  DEFAULT_STATUS_CODE_REGEX = /[45]\d\d$/
17
- DEFAULT_MESSAGE_PROC = ->(status, phrase, domain) { "[#{status}]: #{domain}" }
20
+ DEFAULT_MESSAGE_PROC = ->(status, phrase, body, path, domain) { "[#{status}]: #{domain} - #{path}" }
18
21
  DEFAULT_LEVEL_PROC = ->(_status) { WARNING }
19
-
20
- attr_accessor :use_person_scope, :use_params_scope, :params_scope_sanitizer, :use_query_scope, :params_query_sanitizer, :use_message_exception
21
-
22
- def initialize(options = {})
23
- @status_code_regex = DEFAULT_STATUS_CODE_REGEX
24
- @use_person_scope = true
25
-
26
- @use_params_scope = true
27
- @params_scope_sanitizer = []
28
-
29
- @use_query_scope = true
30
- @params_query_sanitizer = []
31
-
32
- @message = DEFAULT_MESSAGE_PROC
33
- @use_message_exception = true
34
-
35
- @rollbar_level = DEFAULT_LEVEL_PROC
36
- end
37
-
38
- def rollbar_level=(level)
39
- raise ConfigError, "level= must be passed a Proc or #{ROLLBAR_LEVELS}. But was passed a #{level} instead"
40
-
41
- @rollbar_level = level
42
- end
43
-
44
- def rollbar_level
45
- @rollbar_level
46
- end
47
-
48
- def message=(message)
49
- raise ConfigError, "message= must be passed a Proc but was passed a #{message.class} instead"
50
-
51
- @message = message
52
- end
53
-
54
- def message
55
- @message
56
- end
57
-
58
- def status_code_regex
59
- @status_code_regex
60
- end
61
-
62
- def status_code_regex=(regex)
63
- raise ConfigError, "status_code_regex= must be passed a regex but was passed a #{regex.class} instead"
64
-
65
- @status_code_regex = regex
66
- end
67
-
68
- def person_scope=(person_scope)
69
- raise ConfigError, "person_scope= must be passed a Proc but was passed a #{person_scope.class} instead"
70
-
71
- @person_scope = person_scope
72
- end
22
+ ROLLBAR_VALIDATOR = Proc.new do |value|
23
+ value.is_a?(Proc) || ROLLBAR_LEVELS.include?(value)
24
+ end
25
+
26
+ add_composer :message, allowed: [Proc, String], default: DEFAULT_MESSAGE_PROC
27
+ add_composer :params_query_sanitizer, allowed: Array, default: []
28
+ add_composer :params_scope_sanitizer, allowed: Array, default: []
29
+ add_composer :status_code_regex, allowed: Regexp, default: DEFAULT_STATUS_CODE_REGEX
30
+ add_composer :use_message_exception, allowed: [TrueClass, FalseClass], default: true
31
+ add_composer :use_params_scope, allowed: [TrueClass, FalseClass], default: true
32
+ add_composer :use_person_scope, allowed: [TrueClass, FalseClass], default: true
33
+ add_composer :use_query_scope, allowed: [TrueClass, FalseClass], default: true
34
+ add_composer :rollbar_level, allowed: [Proc, Symbol], default: DEFAULT_LEVEL_PROC, validator: ROLLBAR_VALIDATOR, invalid_message: -> (val) { "Value must be a Proc or one of #{ROLLBAR_LEVELS}" }
73
35
 
74
36
  def person_scope
75
37
  return -> {} unless @use_person_scope
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Rollday
4
- VERSION = "0.3.0"
4
+ VERSION = "0.4.0"
5
5
  end
data/rollday.gemspec CHANGED
@@ -29,6 +29,7 @@ Gem::Specification.new do |spec|
29
29
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
30
30
  spec.require_paths = ["lib"]
31
31
 
32
+ spec.add_dependency "class_composer"
32
33
  spec.add_dependency "faraday"
33
34
  spec.add_dependency "rollbar"
34
35
 
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rollday
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Taylor
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-06-24 00:00:00.000000000 Z
11
+ date: 2022-07-04 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: class_composer
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: faraday
15
29
  requirement: !ruby/object:Gem::Requirement