elastic_whenever 0.5.0 → 0.5.1

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: 44ac9fe99c9c51c1ee191ab303ce2e5f3d647103544b306c054003b4ecdf1bf6
4
- data.tar.gz: 3877408e457ae24fd0f1f341e6e09ad6603cdf2c67218c651c0b279c4c395ec1
3
+ metadata.gz: f819eb4be8beaf663016106905b28a3f02241793f5ee3965e88b36a0f8f3e4d0
4
+ data.tar.gz: c4ca5aadbd922b26d0671c7a2783c89864dec7b42875bb7df0e044dd3a48cad0
5
5
  SHA512:
6
- metadata.gz: 6921c08998a3e568d522024ee97c277d8d70e0e7e8093e047707f84a3c8bb3b0f6f583111acae84d5ec6eeeba436f8dda1437a97e36fe4b0266261b65e085c8a
7
- data.tar.gz: 5de1bd0c3512ff1dd2cac3192c3894274f6717b93347383610afd2710ae70a1aa0be0d95a7a2753ab69ca35387039799be1afb37fa21ecba5e3c0f9b81f8a5d4
6
+ metadata.gz: f89c03a025d724efedcf843b698459cb0cddefc55cec555c9a9ba67d0ef0a5545650406fef3d37d7b0f4f4565dece24d2790e15d6f8085c6f37c3cc3a3a918b6
7
+ data.tar.gz: 672aa12e9bd8055be8dbb7c76982f93545f71f2bb61475110dcaff77751c10bdaf952231ad6d99c253f4f7720a48cfe387cf59c2d8756831ab542f22a14d2752
@@ -1,3 +1,9 @@
1
+ ## v0.5.1 (2019-10-09)
2
+
3
+ ### Enhancements
4
+
5
+ - [#45](https://github.com/wata727/elastic_whenever/pull/45): Add description to CloudWatch rule ([@tobscher](https://github.com/tobscher))
6
+
1
7
  ## v0.5.0 (2019-09-19)
2
8
 
3
9
  ### Enhancements
@@ -3,6 +3,7 @@ module ElasticWhenever
3
3
  class Rule
4
4
  attr_reader :name
5
5
  attr_reader :expression
6
+ attr_reader :description
6
7
 
7
8
  class UnsupportedOptionException < StandardError; end
8
9
 
@@ -13,6 +14,7 @@ module ElasticWhenever
13
14
  option,
14
15
  name: rule.name,
15
16
  expression: rule.schedule_expression,
17
+ description: rule.description
16
18
  )
17
19
  end
18
20
  end
@@ -21,13 +23,15 @@ module ElasticWhenever
21
23
  self.new(
22
24
  option,
23
25
  name: rule_name(option.identifier, task.expression, task.commands),
24
- expression: task.expression
26
+ expression: task.expression,
27
+ description: rule_description(option.identifier, task.expression, task.commands)
25
28
  )
26
29
  end
27
30
 
28
- def initialize(option, name:, expression:)
31
+ def initialize(option, name:, expression:, description:)
29
32
  @name = name
30
33
  @expression = expression
34
+ @description = description
31
35
  @client = Aws::CloudWatchEvents::Client.new(option.aws_config)
32
36
  end
33
37
 
@@ -35,6 +39,8 @@ module ElasticWhenever
35
39
  client.put_rule(
36
40
  name: name,
37
41
  schedule_expression: expression,
42
+ # See https://docs.aws.amazon.com/eventbridge/latest/APIReference/API_PutRule.html#API_PutRule_RequestSyntax
43
+ description: truncate(description, 512),
38
44
  state: "ENABLED",
39
45
  )
40
46
  end
@@ -51,6 +57,14 @@ module ElasticWhenever
51
57
  "#{identifier}_#{Digest::SHA1.hexdigest([expression, commands.map { |command| command.join("-") }.join("-")].join("-"))}"
52
58
  end
53
59
 
60
+ def self.rule_description(identifier, expression, commands)
61
+ "#{identifier} - #{expression} - #{commands.map { |command| command.join(" ") }.join(" - ")}"
62
+ end
63
+
64
+ def truncate(string, max)
65
+ string.length > max ? string[0...max] : string
66
+ end
67
+
54
68
  attr_reader :client
55
69
  end
56
70
  end
@@ -1,3 +1,3 @@
1
1
  module ElasticWhenever
2
- VERSION = "0.5.0"
2
+ VERSION = "0.5.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: elastic_whenever
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kazuma Watanabe
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-09-18 00:00:00.000000000 Z
11
+ date: 2019-10-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler