rollbar-notification-rules-generator 0.2.1 → 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: ce56e1023a93951426676ff62816edb599695be468306635a129a2632a72caec
4
- data.tar.gz: 21d676802ff8a98c601feebc951768f4ff4272b354d05408ec3d389178953cd8
3
+ metadata.gz: 95d4d2186d8360cf8577ed75ab8037ddcd90ac998b77cb7b7c5803a8e78c6e64
4
+ data.tar.gz: 95e31245d3c6d273b1888e82ec84c75fc05628d03b7cbbd53d401d1d0b47b617
5
5
  SHA512:
6
- metadata.gz: a20f5505d0561574e10d6f7faa1d281b41fd44f0d4d540fb64e931df814bb90575b97a05dc89c47978e5d05257efccbb3ae827e984c3b074c88d48d16bcc9af8
7
- data.tar.gz: 5fee029c6a281b1ba9633eaa0f143fa65e21f45192d492a4b20daa55b61c7337af64ccec3614047326e84ff9a67b9432040161b502325a9c69dd08165ee21cf7
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
 
@@ -25,6 +31,14 @@ module Rollbar
25
31
  operation == other.operation &&
26
32
  value == other.value
27
33
  end
34
+ alias :eql? :==
35
+
36
+ # @return [Integer]
37
+ def hash
38
+ [self.class, type, operation, value].hash
39
+ end
40
+
41
+ # @return [String]
28
42
  def to_tf
29
43
  <<~TF
30
44
  filters {
@@ -35,7 +49,7 @@ module Rollbar
35
49
  TF
36
50
  end
37
51
 
38
- # @param other [Base]
52
+ # @param other [Base, Rate]
39
53
  # @return [Boolean]
40
54
  def redundant_to?(other)
41
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" => "!=",
@@ -33,7 +37,14 @@ module Rollbar
33
37
  def ==(other)
34
38
  super && path == other.path
35
39
  end
40
+ alias :eql? :==
36
41
 
42
+ # @return [Integer]
43
+ def hash
44
+ [self.class, type, operation, value, path].hash
45
+ end
46
+
47
+ # @return [String]
37
48
  def to_tf
38
49
  <<~TF
39
50
  filters {
@@ -56,6 +67,7 @@ module Rollbar
56
67
  self.class.new(@path, new_operation, @value)
57
68
  end
58
69
 
70
+ # @param other [Base, Rate]
59
71
  # @return [Boolean]
60
72
  def redundant_to?(other)
61
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)
@@ -50,12 +68,17 @@ module Rollbar
50
68
 
51
69
  # @return [Rule]
52
70
  def remove_redundant_conditions!
71
+ @conditions.uniq!
53
72
  @conditions.delete_if do |condition|
54
73
  @conditions.any? { |other| condition.redundant_to?(other) }
55
74
  end
56
75
  self
57
76
  end
58
77
 
78
+ def never_met?
79
+ self.class.never_met?(@conditions)
80
+ end
81
+
59
82
  # @param old_condition [Condition::Base]
60
83
  # @param new_condition [Condition::Base]
61
84
  # @return [Rule]
@@ -120,26 +143,31 @@ module Rollbar
120
143
  conditions_with_complement = @conditions.select { |c| c.respond_to?(:build_complement_condition) }
121
144
  return {} if conditions_with_complement.empty?
122
145
 
146
+ # Build set of conditions for the complement condition
147
+ # e.g.
148
+ # [cond1, cond2]
149
+ # => [[not-cond1], [cond1, not-cond2]]
150
+ #
123
151
  # [cond1, cond2, cond3]
152
+ # => [[not-cond1], [cond1, not-cond2], [cond1, cond2, not-cond3]]
153
+ #
154
+ # [cond1, cond2, cond3, cond4]
124
155
  # => [
125
- # [cond1, cond2, not-cond3],
126
- # [cond1, not-cond2, cond3],
127
- # [cond1, not-cond2, not-cond3],
128
- # [not-cond1, cond2, cond3],
129
- # [not-cond1, cond2, not-cond3],
130
- # [not-cond1, not-cond2, cond3],
131
- # [not-cond1, not-cond2, not-cond3],
132
- # ]
133
- first_cond, *other_conds = conditions_with_complement.map do |condition|
134
- [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]
135
163
  end
136
- additional_conditions_set = first_cond.product(*other_conds) - [conditions_with_complement]
137
164
 
138
165
  target_levels.zip([additional_conditions_set].cycle).to_h
139
166
  end
140
167
 
141
168
  private
142
169
 
170
+ # @return [Condition::Level, nil]
143
171
  def level_condition
144
172
  return @level_condition if defined?(@level_condition)
145
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|
@@ -102,9 +110,12 @@ module Rollbar
102
110
  new_rules << new_rule
103
111
  else
104
112
  additional_conditions_set.each do |additional_conditions|
105
- new_rules << new_rule.dup
106
- .add_conditions!(additional_conditions)
107
- .remove_redundant_conditions!
113
+ new_rule_with_additional_conds = new_rule.dup
114
+ .add_conditions!(additional_conditions)
115
+ .remove_redundant_conditions!
116
+ unless new_rule_with_additional_conds.never_met?
117
+ new_rules << new_rule_with_additional_conds
118
+ end
108
119
  end
109
120
  end
110
121
  end
@@ -114,7 +125,10 @@ module Rollbar
114
125
  highest_lowest_target_level = lowest_target_level
115
126
  end
116
127
  level_value_to_additional_conditions_set.merge!(rule.build_additional_conditions_set_for_subsequent_rules) do |_, v1, v2|
117
- v1.product(v2).map(&:flatten)
128
+ # @type [Array<Array<Condition::Base>>]
129
+ additional_conditions_set = v1.product(v2).map(&:flatten)
130
+ additional_conditions_set.reject!(&Rule.method(:never_met?))
131
+ additional_conditions_set
118
132
  end
119
133
  end
120
134
 
@@ -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 = `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.1
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-18 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