pager_judy 0.2.2 → 0.3.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: 52d2f9ad7cc38c994d770a488563b643dbd568e40a635f912cab9fb32739d708
4
- data.tar.gz: e5190b125b5602cb079fe476090f79fbbac07fb47aa3bdb950f6618db148f904
3
+ metadata.gz: 14e4b53112f40137b435f917ebc2a692616c25863b2f90ea9f7d78c26b9386f0
4
+ data.tar.gz: 6d668eb10ba3e4ca97de5c33decf84b71c701113341851d9ea1a197df1108b31
5
5
  SHA512:
6
- metadata.gz: d2cce233aace32a45888c9c7cae6dab59059032ab2c94b0c808582c209e70ad595bcdbd1b89f68fddc012b59c3af75ee3eca15fd48a03f860677b58b618a0af8
7
- data.tar.gz: 0aeca53e8377f18636b37a317a8c08657b0a4d8721c370c715e3ea384a40fa82a0d2c948608af4b5065dfadb2821f31e05fcd1971dfc6bdcef9dd603c175ac57
6
+ metadata.gz: be237a110f748b9463a11325d926eee6128dabba944aaaf1f31472d95c4b8dc52ef82ffa41670098ebb091171b915fe197262d86bd3b09a4e6338f906ec00b5d
7
+ data.tar.gz: efce178cd54cd9cce9a4dd84a52ef73b8e00b5ee05aa66ef2354990a6373d4b4aebe5c379e8bdfb9bbe0e5519d1b1ef30cb5a9cdf9bebd498228b72b83fe67b6
data/CHANGES.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## 0.3.0 (2019-04-03)
2
+
3
+ * Use Chronic (if available) to parse time in CLI.
4
+ * Add support for "logs".
5
+
1
6
  ## 0.2.2 (2019-03-19)
2
7
 
3
8
  * Add support for "oncalls".
@@ -31,6 +31,10 @@ module PagerJudy
31
31
  collection("incidents")
32
32
  end
33
33
 
34
+ def log_entries
35
+ collection("log_entries")
36
+ end
37
+
34
38
  def notifications
35
39
  collection("notifications")
36
40
  end
@@ -87,6 +87,36 @@ module PagerJudy
87
87
 
88
88
  end
89
89
 
90
+ subcommand ["log-entries", "logs"], "Display log entries" do
91
+
92
+ include TimeFiltering
93
+
94
+ self.default_subcommand = "summary"
95
+
96
+ subcommand ["summary", "s"], "One-line summary" do
97
+
98
+ def execute
99
+ collection.each do |entry|
100
+ ts = Time.parse(entry.fetch("created_at"))
101
+ ts_string = ts.localtime.strftime("%Y-%m-%d %H:%M")
102
+ incident = entry.dig("incident", "summary")
103
+ event = entry.dig("summary")
104
+ puts "#{ts_string}: #{incident} - #{event}"
105
+ end
106
+ end
107
+
108
+ end
109
+
110
+ subcommand ["data", "d"], "Full details" do
111
+ include CollectionBehaviour::DataSubcommand
112
+ end
113
+
114
+ def collection
115
+ client.log_entries.with(time_filters)
116
+ end
117
+
118
+ end
119
+
90
120
  subcommand ["notifications"], "Display notifications" do
91
121
 
92
122
  include TimeFiltering
@@ -103,7 +133,7 @@ module PagerJudy
103
133
 
104
134
  end
105
135
 
106
- subcommand "oncalls", "Display those currently on-call" do
136
+ subcommand ["oncalls", "oncall"], "Display those currently on-call" do
107
137
 
108
138
  include TimeFiltering
109
139
 
@@ -134,12 +164,12 @@ module PagerJudy
134
164
 
135
165
  def format_time_range(from, to)
136
166
  bits = [from.strftime("%Y-%m-%d %H:%M")]
137
- unless to.nil?
138
- if to.to_date == from.to_date
139
- bits << to.strftime("%H:%M")
140
- else
141
- bits << to.strftime("%Y-%m-%d %H:%M")
142
- end
167
+ bits << if to.nil?
168
+ "..."
169
+ elsif to.to_date == from.to_date
170
+ to.strftime("%H:%M")
171
+ else
172
+ to.strftime("%Y-%m-%d %H:%M")
143
173
  end
144
174
  bits.join(" - ")
145
175
  end
@@ -155,6 +185,14 @@ module PagerJudy
155
185
  client.oncalls.with(filters)
156
186
  end
157
187
 
188
+ def default_after
189
+ Time.now
190
+ end
191
+
192
+ def default_before
193
+ Time.now
194
+ end
195
+
158
196
  def other_filters
159
197
  {
160
198
  "user_ids[]" => user_list,
@@ -1,6 +1,7 @@
1
1
  require "clamp"
2
2
  require "time"
3
3
 
4
+
4
5
  module PagerJudy
5
6
  module CLI
6
7
 
@@ -13,6 +14,13 @@ module PagerJudy
13
14
  option %w[-a --after], "DATETIME", "start date/time", default: "24 hours ago", attribute_name: :after
14
15
  option %w[-b --before], "DATETIME", "end date/time", attribute_name: :before
15
16
 
17
+ begin
18
+ require "chronic"
19
+ TimeParser = ::Chronic
20
+ rescue
21
+ TimeParser = ::Time
22
+ end
23
+
16
24
  protected
17
25
 
18
26
  def time_filters
@@ -25,11 +33,11 @@ module PagerJudy
25
33
  private
26
34
 
27
35
  def after=(s)
28
- @after = Time.parse(s)
36
+ @after = TimeParser.parse(s)
29
37
  end
30
38
 
31
39
  def before=(s)
32
- @before = Time.parse(s)
40
+ @before = TimeParser.parse(s)
33
41
  end
34
42
 
35
43
  def default_after
@@ -1,5 +1,5 @@
1
1
  module PagerJudy
2
2
 
3
- VERSION = '0.2.2'
3
+ VERSION = '0.3.0'
4
4
 
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pager_judy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Williams
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-03-19 00:00:00.000000000 Z
11
+ date: 2019-04-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: clamp