rollbar-notification-rules-generator 0.2.2 → 0.2.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
  SHA256:
3
- metadata.gz: b69971ea33eb831637b2fbc7170b01dd6cce53e45f02d6f0b2c45c019900ed5a
4
- data.tar.gz: 43b362b542727d83795bbc5efd0f9f219a224e0f2030d3579be755e97477f111
3
+ metadata.gz: 95d4d2186d8360cf8577ed75ab8037ddcd90ac998b77cb7b7c5803a8e78c6e64
4
+ data.tar.gz: 95e31245d3c6d273b1888e82ec84c75fc05628d03b7cbbd53d401d1d0b47b617
5
5
  SHA512:
6
- metadata.gz: f61baf0e620d426b92f9bcd5ea00709969d1b183febcbfe0f4cc8b9f288f2f23e33d4aea71d8e4a0357eb441b4a111ebbdfd40b45e54d37df971ff475df061ec
7
- data.tar.gz: 0baee819bff11502752157d296a978a5a50e48f2e9efcaac4593a9820e192fe3801c2cafa1566857f12dc2b2df98fcd8e570fd17c8b760548a1c893effd48bc4
6
+ metadata.gz: 0e3d15a47f9fe36caf190a0e859f75ef8bcb7ee799db31a77c55afbd3823d0caaebda20664d35df57f10c4c5bd52862048c7160118bca6e6cd3b4b2ce7659ca9
7
+ data.tar.gz: 2a71e00cdc373796f676d93e26d9b3c5b9166d805d6c7cf3037e426e3b9133e957953b6e6fd77abdb2f8e7ad9f8c2d4eac1930ec8ed9afec7d2877c57ef345c6
data/Gemfile CHANGED
@@ -8,3 +8,7 @@ gemspec
8
8
  gem "rake", "~> 13.0"
9
9
 
10
10
  gem "rspec", "~> 3.0"
11
+
12
+ # For generating sig/defs.rbs
13
+ gem "yard"
14
+ gem "sord"
data/README.md CHANGED
@@ -161,7 +161,7 @@ See the YAML files in [spec/files/yaml](spec/files/yaml). Their output files are
161
161
 
162
162
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
163
163
 
164
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `rollbar-notification-rules-generator.gemspec`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
164
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `exe/rollbar-notification-rules-generator`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
165
165
 
166
166
  ## Contributing
167
167
 
data/Rakefile CHANGED
@@ -6,3 +6,8 @@ require "rspec/core/rake_task"
6
6
  RSpec::Core::RakeTask.new(:spec)
7
7
 
8
8
  task default: :spec
9
+
10
+ task :generate_rbs do
11
+ sh "sord sig/defs.rbs"
12
+ sh %q{sed -i$([ $(uname) = "Darwin" ] && echo ' ""') '1s/^/# This file was generated by "rake generate_rbs"\n/' sig/defs.rbs}
13
+ end
@@ -3,6 +3,7 @@ require "optparse"
3
3
 
4
4
  require "rollbar/notification"
5
5
 
6
+ Version = "0.2.3"
6
7
  FORMATS = %w[terraform text]
7
8
 
8
9
  opts = { format: "terraform" }
@@ -4,13 +4,14 @@ require "rollbar/notification/trigger"
4
4
  module Rollbar
5
5
  class Notification
6
6
  class Channel
7
+ # @return [Hash{String => String}]
7
8
  CHANNEL_TO_TEXT = {
8
9
  "slack" => "Slack",
9
10
  "pagerduty" => "PagerDuty",
10
11
  }
11
12
 
12
13
  # @param channel [String]
13
- # @param triggers [Hash{String => Array<Hash>}]
14
+ # @param triggers [Hash{String => Array<Hash{String => Object}>}]
14
15
  # @param variables [Hash{String => String}]
15
16
  def initialize(channel, triggers, variables)
16
17
  unless CHANNEL_TO_TEXT.include?(channel)
@@ -28,7 +29,9 @@ module Rollbar
28
29
  "# #{CHANNEL_TO_TEXT.fetch(@channel)}\n#{@triggers.map(&:to_s).join.chomp}"
29
30
  end
30
31
 
31
- # @param provider [String]
32
+ # @param provider [String, nil]
33
+ # @param namespace [String, nil]
34
+ # @return [String]
32
35
  def to_tf(provider, namespace)
33
36
  @triggers.map { |t| t.to_tf(provider, namespace) }.join("\n")
34
37
  end
@@ -3,6 +3,12 @@
3
3
  module Rollbar
4
4
  class Notification
5
5
  module Condition
6
+ # @!attribute [r] type
7
+ # @return [String]
8
+ # @!attribute [r] operation
9
+ # @return [String]
10
+ # @!attribute [r] value
11
+ # @return [String]
6
12
  class Base
7
13
  attr_reader :type, :operation, :value
8
14
 
@@ -27,10 +33,12 @@ module Rollbar
27
33
  end
28
34
  alias :eql? :==
29
35
 
36
+ # @return [Integer]
30
37
  def hash
31
38
  [self.class, type, operation, value].hash
32
39
  end
33
40
 
41
+ # @return [String]
34
42
  def to_tf
35
43
  <<~TF
36
44
  filters {
@@ -41,7 +49,7 @@ module Rollbar
41
49
  TF
42
50
  end
43
51
 
44
- # @param other [Base]
52
+ # @param other [Base, Rate]
45
53
  # @return [Boolean]
46
54
  def redundant_to?(other)
47
55
  self.class == other.class &&
@@ -5,6 +5,7 @@ module Rollbar
5
5
  class Notification
6
6
  module Condition
7
7
  class Environment < Base
8
+ # @return [Array<String>]
8
9
  SUPPORTED_OPERATIONS = %w[eq neq]
9
10
 
10
11
  def initialize(operation, value)
@@ -5,6 +5,7 @@ module Rollbar
5
5
  class Notification
6
6
  module Condition
7
7
  class Framework < Base
8
+ # @return [Array<String>]
8
9
  SUPPORTED_OPERATIONS = %w[eq]
9
10
 
10
11
  def initialize(operation, value)
@@ -4,14 +4,21 @@ require "rollbar/notification/condition/base"
4
4
  module Rollbar
5
5
  class Notification
6
6
  module Condition
7
+ # @!attribute [r] level
8
+ # @return [Integer]
7
9
  class Level < Base
10
+ # @return [Array<String>]
8
11
  SUPPORTED_OPERATIONS = %w[eq gte]
12
+ # @return [Array<String>]
9
13
  SUPPORTED_VALUES = %w[debug info warning error critical]
10
14
 
11
15
  # @param lowest_target_level [Integer]
12
16
  # @return [Array<Level>]
13
17
  def self.build_eq_conditions_from(lowest_target_level)
14
- SUPPORTED_VALUES[lowest_target_level..].map do |value|
18
+ target_level_values = SUPPORTED_VALUES[lowest_target_level..]
19
+ raise "lowest_target_level is out of range" if target_level_values.nil?
20
+
21
+ target_level_values.map do |value|
15
22
  new("eq", value)
16
23
  end
17
24
  end
@@ -24,10 +31,11 @@ module Rollbar
24
31
  super
25
32
  @type = "level"
26
33
 
27
- @level = SUPPORTED_VALUES.index(value)
28
- unless @level
34
+ level = SUPPORTED_VALUES.index(value)
35
+ unless level
29
36
  raise ArgumentError, "Unsupported value: #{value}"
30
37
  end
38
+ @level = level
31
39
  end
32
40
 
33
41
  # @return [String]
@@ -37,7 +45,8 @@ module Rollbar
37
45
 
38
46
  # @return [Array<String>]
39
47
  def target_level_values
40
- @operation == "eq" ? [@value] : SUPPORTED_VALUES[@level..]
48
+ # NOTE: `SUPPORTED_VALUES[@level..]` cannot be nil but `|| []` is required to suppress the warning "Incompatible nilability"
49
+ @operation == "eq" ? [@value] : SUPPORTED_VALUES[@level..] || []
41
50
  end
42
51
  end
43
52
  end
@@ -4,8 +4,12 @@ require "rollbar/notification/condition/base"
4
4
  module Rollbar
5
5
  class Notification
6
6
  module Condition
7
+ # @!attribute [r] path
8
+ # @return [String]
7
9
  class Path < Base
10
+ # @return [Array<String>]
8
11
  SUPPORTED_OPERATIONS = %w[eq neq within nwithin regex nregex exists nexists]
12
+ # @return [Hash{String => String}]
9
13
  OPERATION_TO_TEXT = {
10
14
  "eq" => "==",
11
15
  "neq" => "!=",
@@ -35,11 +39,12 @@ module Rollbar
35
39
  end
36
40
  alias :eql? :==
37
41
 
42
+ # @return [Integer]
38
43
  def hash
39
44
  [self.class, type, operation, value, path].hash
40
45
  end
41
46
 
42
-
47
+ # @return [String]
43
48
  def to_tf
44
49
  <<~TF
45
50
  filters {
@@ -62,6 +67,7 @@ module Rollbar
62
67
  self.class.new(@path, new_operation, @value)
63
68
  end
64
69
 
70
+ # @param other [Base, Rate]
65
71
  # @return [Boolean]
66
72
  def redundant_to?(other)
67
73
  super && @path == other.path
@@ -3,7 +3,10 @@
3
3
  module Rollbar
4
4
  class Notification
5
5
  module Condition
6
+ # @!attribute [r] type
7
+ # @return [String]
6
8
  class Rate
9
+ # @return [Hash{Integer => String}]
7
10
  PERIOD_TO_TEXT = {
8
11
  60 => "1 minute",
9
12
  300 => "5 minutes",
@@ -27,6 +30,7 @@ module Rollbar
27
30
  "At least #{@count} occurrences within #{PERIOD_TO_TEXT[@period]}"
28
31
  end
29
32
 
33
+ # @return [String]
30
34
  def to_tf
31
35
  <<~TF
32
36
  filters {
@@ -37,7 +41,7 @@ module Rollbar
37
41
  TF
38
42
  end
39
43
 
40
- # @param other [Base]
44
+ # @param other [Base, Rate]
41
45
  # @return [Boolean]
42
46
  def redundant_to?(other)
43
47
  false
@@ -5,7 +5,9 @@ module Rollbar
5
5
  class Notification
6
6
  module Condition
7
7
  class Title < Base
8
+ # @return [Array<String>]
8
9
  SUPPORTED_OPERATIONS = %w[within nwithin regex nregex]
10
+ # @return [Hash{String => String}]
9
11
  OPERATION_TO_TEXT = {
10
12
  "within" => "contains substring",
11
13
  "nwithin" => "does not contain substring",
@@ -23,6 +25,7 @@ module Rollbar
23
25
  %Q{#{@type} #{OPERATION_TO_TEXT[@operation]} "#{@value}"}
24
26
  end
25
27
 
28
+ # @return [Title]
26
29
  def build_complement_condition
27
30
  new_operation = @operation.start_with?("n") ? @operation.delete_prefix("n") : "n#{@operation}"
28
31
  self.class.new(new_operation, @value)
@@ -8,10 +8,26 @@ require "rollbar/notification/condition/title"
8
8
 
9
9
  module Rollbar
10
10
  class Notification
11
+ # @!attribute [r] conditions
12
+ # @return [Array<Condition::Base, Condition::Rate>]
13
+ # @!attribute [r] configs
14
+ # @return [Array<Hash{String => Object}>]
11
15
  class Rule
16
+ # @param conditions [Array<Condition::Base, Condition::Rate>]
17
+ # @return [Boolean]
18
+ def self.never_met?(conditions)
19
+ conditions.each.with_index.any? do |condition, i|
20
+ # NOTE: `@conditions[i + 1 ..]` cannot be nil but `|| []` is required to suppress the warning "'any?' may produce 'NoMethodError'"
21
+ (conditions[i + 1 ..] || []).any? do |other|
22
+ next false unless condition.respond_to?(:build_complement_condition)
23
+ other == condition.build_complement_condition
24
+ end
25
+ end
26
+ end
27
+
12
28
  attr_reader :conditions, :configs
13
29
 
14
- # @param rule [Hash]
30
+ # @param rule [Hash{String => Array<Object>}]
15
31
  def initialize(rule)
16
32
  @conditions = rule.fetch("conditions").map do |condition|
17
33
  case condition.fetch("type")
@@ -34,6 +50,8 @@ module Rollbar
34
50
  @configs = rule.fetch("configs", [{}])
35
51
  end
36
52
 
53
+ # @param original [Rule]
54
+ # @return [void]
37
55
  def initialize_dup(original)
38
56
  @conditions = original.conditions.dup
39
57
  remove_instance_variable(:@level_condition)
@@ -58,12 +76,7 @@ module Rollbar
58
76
  end
59
77
 
60
78
  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
79
+ self.class.never_met?(@conditions)
67
80
  end
68
81
 
69
82
  # @param old_condition [Condition::Base]
@@ -130,26 +143,31 @@ module Rollbar
130
143
  conditions_with_complement = @conditions.select { |c| c.respond_to?(:build_complement_condition) }
131
144
  return {} if conditions_with_complement.empty?
132
145
 
146
+ # Build set of conditions for the complement condition
147
+ # e.g.
148
+ # [cond1, cond2]
149
+ # => [[not-cond1], [cond1, not-cond2]]
150
+ #
133
151
  # [cond1, cond2, cond3]
152
+ # => [[not-cond1], [cond1, not-cond2], [cond1, cond2, not-cond3]]
153
+ #
154
+ # [cond1, cond2, cond3, cond4]
134
155
  # => [
135
- # [cond1, cond2, not-cond3],
136
- # [cond1, not-cond2, cond3],
137
- # [cond1, not-cond2, not-cond3],
138
- # [not-cond1, cond2, cond3],
139
- # [not-cond1, cond2, not-cond3],
140
- # [not-cond1, not-cond2, cond3],
141
- # [not-cond1, not-cond2, not-cond3],
142
- # ]
143
- first_cond, *other_conds = conditions_with_complement.map do |condition|
144
- [condition, condition.build_complement_condition]
156
+ # [not-cond1],
157
+ # [cond1, not-cond2],
158
+ # [cond1, cond2, not-cond3],
159
+ # [cond1, cond2, cond3, not-cond4],
160
+ # ]
161
+ additional_conditions_set = conditions_with_complement.map.with_index do |cond, i|
162
+ [*conditions_with_complement[... i], cond.build_complement_condition]
145
163
  end
146
- additional_conditions_set = first_cond.product(*other_conds) - [conditions_with_complement]
147
164
 
148
165
  target_levels.zip([additional_conditions_set].cycle).to_h
149
166
  end
150
167
 
151
168
  private
152
169
 
170
+ # @return [Condition::Level, nil]
153
171
  def level_condition
154
172
  return @level_condition if defined?(@level_condition)
155
173
  @level_condition = @conditions.find { |c| c.type == "level" }
@@ -6,6 +6,7 @@ require "rollbar/notification/rule"
6
6
  module Rollbar
7
7
  class Notification
8
8
  class Trigger
9
+ # @return [Hash{String => String}]
9
10
  TRIGGER_TO_TEXT = {
10
11
  "deploy" => "Deploy",
11
12
  "exp_repeat_item" => "10^nth Occurrence",
@@ -17,6 +18,7 @@ module Rollbar
17
18
  "resolved_item" => "Item Resolved",
18
19
  }
19
20
 
21
+ # @return [ERB]
20
22
  TEXT_TEMPLATE = ERB.new(<<~TEXT)
21
23
  conditions:
22
24
  <%= conditions.map { |condition| condition.to_s.gsub(/^/, " ") }.join("\n").chomp %><% unless config.empty? %><% max_key_len = config.keys.map(&:size).max %>
@@ -25,6 +27,7 @@ module Rollbar
25
27
  <%= config.compact.map { |key, value| ' %-*s = %s' % [max_key_len, key, value.inspect] }.join("\n") %><% end %>
26
28
  TEXT
27
29
 
30
+ # @return [ERB]
28
31
  TF_TEMPLATE = ERB.new(<<~TF)
29
32
  resource "rollbar_notification" "<%= resource_name %>" {<% if provider %>
30
33
  provider = <%= provider %>
@@ -43,7 +46,8 @@ module Rollbar
43
46
 
44
47
  # @param channel [String]
45
48
  # @param name [String]
46
- # @param rules [Array<Hash>]
49
+ # @param rules [Array<Hash{String => Object}>]
50
+ # @param variables [Hash{String => String}]
47
51
  def initialize(channel, name, rules, variables)
48
52
  @channel = channel
49
53
  @name = name
@@ -53,6 +57,7 @@ module Rollbar
53
57
  @variables = variables
54
58
  end
55
59
 
60
+ # @return [String]
56
61
  def to_s
57
62
  str = +"## #{TRIGGER_TO_TEXT.fetch(@name)}\n"
58
63
  i = -1
@@ -71,6 +76,9 @@ module Rollbar
71
76
  str
72
77
  end
73
78
 
79
+ # @param provider [String, nil]
80
+ # @param namespace [String, nil]
81
+ # @return [String]
74
82
  def to_tf(provider, namespace)
75
83
  i = -1
76
84
  build_mutually_exclusive_rules.flat_map do |rule|
@@ -117,14 +125,9 @@ module Rollbar
117
125
  highest_lowest_target_level = lowest_target_level
118
126
  end
119
127
  level_value_to_additional_conditions_set.merge!(rule.build_additional_conditions_set_for_subsequent_rules) do |_, v1, v2|
128
+ # @type [Array<Array<Condition::Base>>]
120
129
  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
-
130
+ additional_conditions_set.reject!(&Rule.method(:never_met?))
128
131
  additional_conditions_set
129
132
  end
130
133
  end
@@ -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.2"
5
+ spec.version = `ruby -Ilib exe/rollbar-notification-rules-generator --version`.split(" ").last.chomp
6
6
  spec.authors = ["abicky"]
7
7
  spec.email = ["takeshi.arabiki@gmail.com"]
8
8
 
data/sig/array.rbs ADDED
@@ -0,0 +1,5 @@
1
+ # TODO: Delete this file after https://github.com/ruby/rbs/pull/1187 is merged
2
+ class Array[unchecked out Elem] < Object
3
+ def zip: [T] (::Enumerator[T] arg) -> ::Array[[ Elem, T? ]]
4
+ | ...
5
+ end
data/sig/defs.rbs ADDED
@@ -0,0 +1,248 @@
1
+ # This file was generated by "rake generate_rbs"
2
+ module Rollbar
3
+ class Notification
4
+ # _@param_ `config_file`
5
+ def initialize: (String config_file) -> void
6
+
7
+ def to_s: () -> String
8
+
9
+ def to_tf: () -> String
10
+
11
+ # @!attribute [r] conditions
12
+ # @return [Array<Condition::Base, Condition::Rate>]
13
+ # @!attribute [r] configs
14
+ # @return [Array<Hash{String => Object}>]
15
+ class Rule
16
+ # _@param_ `conditions`
17
+ def self.never_met?: (::Array[(Condition::Base | Condition::Rate)] conditions) -> bool
18
+
19
+ # _@param_ `rule`
20
+ def initialize: (::Hash[String, ::Array[Object]] rule) -> void
21
+
22
+ # _@param_ `original`
23
+ def initialize_dup: (Rule original) -> void
24
+
25
+ # _@param_ `other`
26
+ def ==: (Object other) -> bool
27
+
28
+ def remove_redundant_conditions!: () -> Rule
29
+
30
+ def never_met?: () -> bool
31
+
32
+ # _@param_ `old_condition`
33
+ #
34
+ # _@param_ `new_condition`
35
+ def replace_condition!: (Condition::Base old_condition, Condition::Base new_condition) -> Rule
36
+
37
+ def lowest_target_level: () -> Integer
38
+
39
+ def lowest_target_level_value: () -> String
40
+
41
+ # Splits rules if necessary.
42
+ # Assuming the following two rules:
43
+ # level = critical, title contains substring "bar"
44
+ # level >= error, title contains substring "baz"
45
+ # the second rule will be split into two rules with "eq" operation:
46
+ # level = critical, title contains substring "bar"
47
+ # level = critical, title contains substring "baz"
48
+ # level = error, title contains substring "baz"
49
+ # whereas assuming the following two rules:
50
+ # level = warning, title contains substring "bar"
51
+ # level >= error, title contains substring "baz"
52
+ # this method doesn't split the second rule because each rule
53
+ # is already mutually exclusive.
54
+ #
55
+ # _@param_ `highest_lowest_target_level` — the highest lowest_target_level among the preceding rules.
56
+ def split_rules: (Integer highest_lowest_target_level) -> ::Array[Rule]
57
+
58
+ # _@param_ `new_conditions`
59
+ def add_conditions!: ((Condition::Base | ::Array[Condition::Base]) new_conditions) -> Rule
60
+
61
+ def build_additional_conditions_set_for_subsequent_rules: () -> ::Hash[String, ::Array[::Array[Condition::Base]]]
62
+
63
+ def level_condition: () -> Condition::Level?
64
+
65
+ attr_reader conditions: ::Array[(Condition::Base | Condition::Rate)]
66
+
67
+ attr_reader configs: ::Array[::Hash[String, Object]]
68
+ end
69
+
70
+ class Channel
71
+ CHANNEL_TO_TEXT: ::Hash[String, String]
72
+
73
+ # _@param_ `channel`
74
+ #
75
+ # _@param_ `triggers`
76
+ #
77
+ # _@param_ `variables`
78
+ def initialize: (String channel, ::Hash[String, ::Array[::Hash[String, Object]]] triggers, ::Hash[String, String] variables) -> void
79
+
80
+ def to_s: () -> String
81
+
82
+ # _@param_ `provider`
83
+ #
84
+ # _@param_ `namespace`
85
+ def to_tf: (String? provider, String? namespace) -> String
86
+ end
87
+
88
+ class Trigger
89
+ TRIGGER_TO_TEXT: ::Hash[String, String]
90
+ TEXT_TEMPLATE: ERB
91
+ TF_TEMPLATE: ERB
92
+
93
+ # _@param_ `channel`
94
+ #
95
+ # _@param_ `name`
96
+ #
97
+ # _@param_ `rules`
98
+ #
99
+ # _@param_ `variables`
100
+ def initialize: (
101
+ String channel,
102
+ String name,
103
+ ::Array[::Hash[String, Object]] rules,
104
+ ::Hash[String, String] variables
105
+ ) -> void
106
+
107
+ def to_s: () -> String
108
+
109
+ # _@param_ `provider`
110
+ #
111
+ # _@param_ `namespace`
112
+ def to_tf: (String? provider, String? namespace) -> String
113
+
114
+ def build_mutually_exclusive_rules: () -> ::Array[Rule]
115
+ end
116
+
117
+ module Condition
118
+ # @!attribute [r] type
119
+ # @return [String]
120
+ # @!attribute [r] operation
121
+ # @return [String]
122
+ # @!attribute [r] value
123
+ # @return [String]
124
+ class Base
125
+ # _@param_ `operation`
126
+ #
127
+ # _@param_ `value`
128
+ def initialize: (String operation, String value) -> void
129
+
130
+ # _@param_ `other`
131
+ def ==: (Object other) -> bool
132
+
133
+ def hash: () -> Integer
134
+
135
+ def to_tf: () -> String
136
+
137
+ # _@param_ `other`
138
+ def redundant_to?: ((Base | Rate) other) -> bool
139
+
140
+ attr_reader type: String
141
+
142
+ attr_reader operation: String
143
+
144
+ attr_reader value: String
145
+ end
146
+
147
+ # @!attribute [r] path
148
+ # @return [String]
149
+ class Path < Rollbar::Notification::Condition::Base
150
+ SUPPORTED_OPERATIONS: ::Array[String]
151
+ OPERATION_TO_TEXT: ::Hash[String, String]
152
+
153
+ # _@param_ `path`
154
+ #
155
+ # _@param_ `operation`
156
+ #
157
+ # _@param_ `value`
158
+ def initialize: (String path, String operation, String value) -> void
159
+
160
+ # _@param_ `other`
161
+ def ==: (Object other) -> bool
162
+
163
+ def hash: () -> Integer
164
+
165
+ def to_tf: () -> String
166
+
167
+ def to_s: () -> String
168
+
169
+ def build_complement_condition: () -> Path
170
+
171
+ # _@param_ `other`
172
+ def redundant_to?: ((Base | Rate) other) -> bool
173
+
174
+ attr_reader path: String
175
+ end
176
+
177
+ # @!attribute [r] type
178
+ # @return [String]
179
+ class Rate
180
+ PERIOD_TO_TEXT: ::Hash[Integer, String]
181
+
182
+ # _@param_ `count`
183
+ #
184
+ # _@param_ `period`
185
+ def initialize: (Integer count, Integer period) -> void
186
+
187
+ def to_s: () -> String
188
+
189
+ def to_tf: () -> String
190
+
191
+ # _@param_ `other`
192
+ def redundant_to?: ((Base | Rate) other) -> bool
193
+
194
+ attr_reader type: String
195
+ end
196
+
197
+ # @!attribute [r] level
198
+ # @return [Integer]
199
+ class Level < Rollbar::Notification::Condition::Base
200
+ SUPPORTED_OPERATIONS: ::Array[String]
201
+ SUPPORTED_VALUES: ::Array[String]
202
+
203
+ # _@param_ `lowest_target_level`
204
+ def self.build_eq_conditions_from: (Integer lowest_target_level) -> ::Array[Level]
205
+
206
+ # _@param_ `operation`
207
+ #
208
+ # _@param_ `value`
209
+ def initialize: (String operation, String value) -> void
210
+
211
+ def to_s: () -> String
212
+
213
+ def target_level_values: () -> ::Array[String]
214
+
215
+ attr_reader level: Integer
216
+ end
217
+
218
+ class Title < Rollbar::Notification::Condition::Base
219
+ SUPPORTED_OPERATIONS: ::Array[String]
220
+ OPERATION_TO_TEXT: ::Hash[String, String]
221
+
222
+ def initialize: (String operation, String value) -> void
223
+
224
+ def to_s: () -> String
225
+
226
+ def build_complement_condition: () -> Title
227
+ end
228
+
229
+ class Framework < Rollbar::Notification::Condition::Base
230
+ SUPPORTED_OPERATIONS: ::Array[String]
231
+
232
+ def initialize: (String operation, String value) -> void
233
+
234
+ def to_s: () -> String
235
+ end
236
+
237
+ class Environment < Rollbar::Notification::Condition::Base
238
+ SUPPORTED_OPERATIONS: ::Array[String]
239
+
240
+ def initialize: (String operation, String value) -> void
241
+
242
+ def to_s: () -> String
243
+
244
+ def build_complement_condition: () -> Environment
245
+ end
246
+ end
247
+ end
248
+ end
@@ -0,0 +1,8 @@
1
+ module Rollbar
2
+ class Notification
3
+ class Channel
4
+ @channel: String
5
+ @triggers: Array[Trigger]
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,10 @@
1
+ module Rollbar
2
+ class Notification
3
+ module Condition
4
+ class Rate
5
+ @count: Integer
6
+ @period: Integer
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,7 @@
1
+ module Rollbar
2
+ class Notification
3
+ class Rule
4
+ @level_condition: Condition::Level?
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,10 @@
1
+ module Rollbar
2
+ class Notification
3
+ class Trigger
4
+ @channel: String
5
+ @name: String
6
+ @rules: Array[Rollbar::Notification::Rule]
7
+ @variables: Hash[String, String]
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,6 @@
1
+ module Rollbar
2
+ class Notification
3
+ @config: Hash[String, untyped]
4
+ @channel: Channel
5
+ end
6
+ end
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.2
4
+ version: 0.2.3
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-20 00:00:00.000000000 Z
11
+ date: 2022-12-26 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.
@@ -37,6 +37,13 @@ files:
37
37
  - lib/rollbar/notification/rule.rb
38
38
  - lib/rollbar/notification/trigger.rb
39
39
  - rollbar-notification-rules-generator.gemspec
40
+ - sig/array.rbs
41
+ - sig/defs.rbs
42
+ - sig/rollbar/notification.rbs
43
+ - sig/rollbar/notification/channel.rbs
44
+ - sig/rollbar/notification/condition/rate.rbs
45
+ - sig/rollbar/notification/rule.rbs
46
+ - sig/rollbar/notification/trigger.rbs
40
47
  homepage: https://github.com/abicky/rollbar-notification-rules-generator
41
48
  licenses:
42
49
  - MIT