rollbar-notification-rules-generator 0.2.1 → 0.2.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
  SHA256:
3
- metadata.gz: ce56e1023a93951426676ff62816edb599695be468306635a129a2632a72caec
4
- data.tar.gz: 21d676802ff8a98c601feebc951768f4ff4272b354d05408ec3d389178953cd8
3
+ metadata.gz: b69971ea33eb831637b2fbc7170b01dd6cce53e45f02d6f0b2c45c019900ed5a
4
+ data.tar.gz: 43b362b542727d83795bbc5efd0f9f219a224e0f2030d3579be755e97477f111
5
5
  SHA512:
6
- metadata.gz: a20f5505d0561574e10d6f7faa1d281b41fd44f0d4d540fb64e931df814bb90575b97a05dc89c47978e5d05257efccbb3ae827e984c3b074c88d48d16bcc9af8
7
- data.tar.gz: 5fee029c6a281b1ba9633eaa0f143fa65e21f45192d492a4b20daa55b61c7337af64ccec3614047326e84ff9a67b9432040161b502325a9c69dd08165ee21cf7
6
+ metadata.gz: f61baf0e620d426b92f9bcd5ea00709969d1b183febcbfe0f4cc8b9f288f2f23e33d4aea71d8e4a0357eb441b4a111ebbdfd40b45e54d37df971ff475df061ec
7
+ data.tar.gz: 0baee819bff11502752157d296a978a5a50e48f2e9efcaac4593a9820e192fe3801c2cafa1566857f12dc2b2df98fcd8e570fd17c8b760548a1c893effd48bc4
@@ -25,6 +25,12 @@ module Rollbar
25
25
  operation == other.operation &&
26
26
  value == other.value
27
27
  end
28
+ alias :eql? :==
29
+
30
+ def hash
31
+ [self.class, type, operation, value].hash
32
+ end
33
+
28
34
  def to_tf
29
35
  <<~TF
30
36
  filters {
@@ -33,6 +33,12 @@ module Rollbar
33
33
  def ==(other)
34
34
  super && path == other.path
35
35
  end
36
+ alias :eql? :==
37
+
38
+ def hash
39
+ [self.class, type, operation, value, path].hash
40
+ end
41
+
36
42
 
37
43
  def to_tf
38
44
  <<~TF
@@ -50,12 +50,22 @@ module Rollbar
50
50
 
51
51
  # @return [Rule]
52
52
  def remove_redundant_conditions!
53
+ @conditions.uniq!
53
54
  @conditions.delete_if do |condition|
54
55
  @conditions.any? { |other| condition.redundant_to?(other) }
55
56
  end
56
57
  self
57
58
  end
58
59
 
60
+ def never_met?
61
+ @conditions.each.with_index.any? do |condition, i|
62
+ @conditions[i + 1 ..].any? do |other|
63
+ next false unless condition.respond_to?(:build_complement_condition)
64
+ other == condition.build_complement_condition
65
+ end
66
+ end
67
+ end
68
+
59
69
  # @param old_condition [Condition::Base]
60
70
  # @param new_condition [Condition::Base]
61
71
  # @return [Rule]
@@ -102,9 +102,12 @@ module Rollbar
102
102
  new_rules << new_rule
103
103
  else
104
104
  additional_conditions_set.each do |additional_conditions|
105
- new_rules << new_rule.dup
106
- .add_conditions!(additional_conditions)
107
- .remove_redundant_conditions!
105
+ new_rule_with_additional_conds = new_rule.dup
106
+ .add_conditions!(additional_conditions)
107
+ .remove_redundant_conditions!
108
+ unless new_rule_with_additional_conds.never_met?
109
+ new_rules << new_rule_with_additional_conds
110
+ end
108
111
  end
109
112
  end
110
113
  end
@@ -114,7 +117,15 @@ module Rollbar
114
117
  highest_lowest_target_level = lowest_target_level
115
118
  end
116
119
  level_value_to_additional_conditions_set.merge!(rule.build_additional_conditions_set_for_subsequent_rules) do |_, v1, v2|
117
- v1.product(v2).map(&:flatten)
120
+ additional_conditions_set = v1.product(v2).map(&:flatten)
121
+
122
+ additional_conditions_set.reject! do |conditions|
123
+ conditions.each.with_index.any? do |condition, i|
124
+ conditions[i + 1 ..].any? { |other| other == condition.build_complement_condition }
125
+ end
126
+ end
127
+
128
+ additional_conditions_set
118
129
  end
119
130
  end
120
131
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = "rollbar-notification-rules-generator"
5
- spec.version = "0.2.1"
5
+ spec.version = "0.2.2"
6
6
  spec.authors = ["abicky"]
7
7
  spec.email = ["takeshi.arabiki@gmail.com"]
8
8
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rollbar-notification-rules-generator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - abicky
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-12-18 00:00:00.000000000 Z
11
+ date: 2022-12-20 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: This tool generates Rollbar notification rules that are mutually exclusive
14
14
  from a simple YAML file.