doggy 2.0.32 → 2.0.33
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +12 -2
- data/doggy.gemspec +1 -0
- data/lib/doggy/cli/edit.rb +2 -22
- data/lib/doggy/cli/mute.rb +7 -2
- data/lib/doggy/cli/push.rb +1 -1
- data/lib/doggy/cli.rb +3 -0
- data/lib/doggy/duration.rb +32 -0
- data/lib/doggy/model.rb +13 -1
- data/lib/doggy/models/monitor.rb +5 -2
- data/lib/doggy/version.rb +1 -1
- metadata +17 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ad95ff43f9450ce4693867914f128764349d6991
|
4
|
+
data.tar.gz: 4485a4866920cf37e7ce892106d06f801170b6de
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ce49b0f7c12fe19c9a718c449f0a42d824908106e2c80ae7a7d89cc87f6dbb9e351ee9347f8d27a3a135f33d0249d73661cbf46f06d027ddb6529bbfec6ca501
|
7
|
+
data.tar.gz: 11ae2964ed41c5d2652b7b6bfd5c5afa93fa47f43491443091626ad21966a60a9672354414b6c11979a12ca7b5113c1c5418e47776578cab93c6b6fee02bd527
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
doggy (2.0.
|
4
|
+
doggy (2.0.33)
|
5
|
+
activesupport (~> 4)
|
5
6
|
json (~> 1.8.3)
|
6
7
|
parallel (~> 1.6.1)
|
7
8
|
rugged (~> 0.23.2)
|
@@ -11,6 +12,12 @@ PATH
|
|
11
12
|
GEM
|
12
13
|
remote: https://rubygems.org/
|
13
14
|
specs:
|
15
|
+
activesupport (4.2.7.1)
|
16
|
+
i18n (~> 0.7)
|
17
|
+
json (~> 1.7, >= 1.7.7)
|
18
|
+
minitest (~> 5.1)
|
19
|
+
thread_safe (~> 0.3, >= 0.3.4)
|
20
|
+
tzinfo (~> 1.1)
|
14
21
|
addressable (2.5.0)
|
15
22
|
public_suffix (~> 2.0, >= 2.0.2)
|
16
23
|
axiom-types (0.1.1)
|
@@ -25,6 +32,7 @@ GEM
|
|
25
32
|
thread_safe (~> 0.3, >= 0.3.1)
|
26
33
|
equalizer (0.0.11)
|
27
34
|
hashdiff (0.2.3)
|
35
|
+
i18n (0.7.0)
|
28
36
|
ice_nine (0.11.2)
|
29
37
|
json (1.8.3)
|
30
38
|
metaclass (0.0.4)
|
@@ -36,8 +44,10 @@ GEM
|
|
36
44
|
rake (10.5.0)
|
37
45
|
rugged (0.23.3)
|
38
46
|
safe_yaml (1.0.4)
|
39
|
-
thor (0.19.
|
47
|
+
thor (0.19.4)
|
40
48
|
thread_safe (0.3.5)
|
49
|
+
tzinfo (1.2.2)
|
50
|
+
thread_safe (~> 0.1)
|
41
51
|
virtus (1.0.5)
|
42
52
|
axiom-types (~> 0.1)
|
43
53
|
coercible (~> 1.0)
|
data/doggy.gemspec
CHANGED
@@ -26,6 +26,7 @@ Gem::Specification.new do |spec|
|
|
26
26
|
spec.add_dependency "thor", "~> 0.19.1"
|
27
27
|
spec.add_dependency "virtus", "~> 1.0.5"
|
28
28
|
spec.add_dependency "rugged", "~> 0.23.2"
|
29
|
+
spec.add_dependency 'activesupport', '~> 4'
|
29
30
|
|
30
31
|
spec.add_development_dependency "bundler", "~> 1.10"
|
31
32
|
spec.add_development_dependency "rake", "~> 10.0"
|
data/lib/doggy/cli/edit.rb
CHANGED
@@ -8,7 +8,7 @@ module Doggy
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def run
|
11
|
-
resource =
|
11
|
+
resource = Doggy::Model.find_local(@param)
|
12
12
|
return Doggy.ui.error("Could not find resource with #{ @param }") unless resource
|
13
13
|
|
14
14
|
forked_resource = fork(resource)
|
@@ -31,26 +31,7 @@ module Doggy
|
|
31
31
|
forked_resource.destroy
|
32
32
|
end
|
33
33
|
|
34
|
-
|
35
|
-
|
36
|
-
def resource_by_param
|
37
|
-
resources = Doggy::Model.all_local_resources
|
38
|
-
if @param =~ /^[0-9]+$/ then
|
39
|
-
id = @param.to_i
|
40
|
-
return resources.find { |res| res.id == id }
|
41
|
-
elsif @param =~ /^http/ then
|
42
|
-
id = case @param
|
43
|
-
when /com\/dash/ then Integer(@param[/dash\/(\d+)/i, 1])
|
44
|
-
when /com\/screen/ then Integer(@param[/screen\/(\d+)/i, 1])
|
45
|
-
when /com\/monitors/ then Integer(@param[/monitors#(\d+)/i, 1])
|
46
|
-
else raise StandardError.new('Unknown resource type, cannot edit.')
|
47
|
-
end
|
48
|
-
return resources.find { |res| res.id == id }
|
49
|
-
else
|
50
|
-
full_path = File.expand_path(@param.gsub('objects/', ''), Doggy.object_root)
|
51
|
-
return resources.find { |res| res.path == full_path }
|
52
|
-
end
|
53
|
-
end
|
34
|
+
private
|
54
35
|
|
55
36
|
def wait_for_edit
|
56
37
|
while !Doggy.ui.yes?('Are you done editing?(Y/N)') do
|
@@ -82,4 +63,3 @@ module Doggy
|
|
82
63
|
end
|
83
64
|
end
|
84
65
|
end
|
85
|
-
|
data/lib/doggy/cli/mute.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
+
require 'doggy/duration'
|
4
|
+
|
3
5
|
module Doggy
|
4
6
|
class CLI::Mute
|
5
7
|
def initialize(options, ids)
|
@@ -9,8 +11,11 @@ module Doggy
|
|
9
11
|
|
10
12
|
def run
|
11
13
|
monitors = @ids.map { |id| Doggy::Models::Monitor.find(id) }
|
12
|
-
|
14
|
+
body = {}
|
15
|
+
if @options['duration']
|
16
|
+
body[:end] = Time.now.utc.to_i + Duration.parse(@options['duration']).to_i
|
17
|
+
end
|
18
|
+
monitors.each { |monitor| monitor.toggle_mute!('mute', JSON.dump(body)) }
|
13
19
|
end
|
14
20
|
end
|
15
21
|
end
|
16
|
-
|
data/lib/doggy/cli/push.rb
CHANGED
@@ -29,7 +29,7 @@ module Doggy
|
|
29
29
|
return
|
30
30
|
end
|
31
31
|
Doggy::Model.all_local_resources.each do |resource|
|
32
|
-
next if ids && !ids.include?(resource.id.to_s)
|
32
|
+
next if ids.any? && !ids.include?(resource.id.to_s)
|
33
33
|
Doggy.ui.say "Pushing #{resource.path}, with id #{resource.id}"
|
34
34
|
resource.ensure_read_only!
|
35
35
|
resource.save
|
data/lib/doggy/cli.rb
CHANGED
@@ -43,8 +43,11 @@ module Doggy
|
|
43
43
|
desc "mute IDs", "Mutes given monitors indefinitely"
|
44
44
|
long_desc <<-D
|
45
45
|
IDs is a space separated list of item IDs.
|
46
|
+
If `--duration` is not given, item will be muted indefinitely.
|
46
47
|
D
|
47
48
|
|
49
|
+
method_option "duration", type: :string, desc: 'Mute only for the given period of time.'
|
50
|
+
|
48
51
|
def mute(*ids)
|
49
52
|
CLI::Mute.new(options.dup, ids).run
|
50
53
|
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# Copied from https://github.com/Shopify/spy/blob/ac7bfb9550bfd7bafd191bc31f1bcd9dc4ce9ee6/lib/spy/duration.rb
|
2
|
+
# and edited accordingly
|
3
|
+
|
4
|
+
require 'active_support/core_ext/module'
|
5
|
+
require 'active_support/core_ext/integer'
|
6
|
+
|
7
|
+
module Duration
|
8
|
+
DURATION_FORMAT = /
|
9
|
+
\A
|
10
|
+
(?<days>\d+d)?
|
11
|
+
(?<hours>\d+h)?
|
12
|
+
(?<minutes>\d+m)?
|
13
|
+
(?<seconds>\d+s)?
|
14
|
+
\z
|
15
|
+
/x
|
16
|
+
DURATION_UNITS = {
|
17
|
+
's' => :seconds,
|
18
|
+
'm' => :minutes,
|
19
|
+
'h' => :hours,
|
20
|
+
'd' => :days,
|
21
|
+
}
|
22
|
+
|
23
|
+
def self.parse(value)
|
24
|
+
unless match = DURATION_FORMAT.match(value)
|
25
|
+
raise ArgumentError, "not a duration: #{value.inspect}, "\
|
26
|
+
"use digits followed by a unit (#{DURATION_UNITS.map { |k, v| "#{k} for #{v}" }.join(', ')})"
|
27
|
+
end
|
28
|
+
DURATION_UNITS.values.inject(0) do |sum, unit|
|
29
|
+
sum + match[unit].to_i.public_send(unit)
|
30
|
+
end.seconds
|
31
|
+
end
|
32
|
+
end
|
data/lib/doggy/model.rb
CHANGED
@@ -31,8 +31,20 @@ module Doggy
|
|
31
31
|
resource
|
32
32
|
end
|
33
33
|
|
34
|
+
def find_local(param)
|
35
|
+
resources = Doggy::Model.all_local_resources
|
36
|
+
if (id = param).is_a?(Integer) || (param =~ /^[0-9]+$/ && id = Integer(param)) then
|
37
|
+
return resources.find { |res| res.id == id }
|
38
|
+
end
|
39
|
+
if id = param[/(dash\/|screen\/|monitors#)(\d+)/i, 2]
|
40
|
+
return resources.find { |res| res.id == Integer(id) }
|
41
|
+
end
|
42
|
+
full_path = File.expand_path(param.gsub('objects/', ''), Doggy.object_root)
|
43
|
+
resources.find { |res| res.path == full_path }
|
44
|
+
end
|
45
|
+
|
34
46
|
def all_local_resources
|
35
|
-
|
47
|
+
@@all_local_resources ||= Parallel.map(Dir[Doggy.object_root.join("**/*.json")]) do |file|
|
36
48
|
raw = File.read(file, encoding: 'utf-8')
|
37
49
|
begin
|
38
50
|
attributes = JSON.parse(raw)
|
data/lib/doggy/models/monitor.rb
CHANGED
@@ -68,13 +68,16 @@ module Doggy
|
|
68
68
|
ensure_renotify_interval_valid
|
69
69
|
end
|
70
70
|
|
71
|
-
def toggle_mute!(action)
|
71
|
+
def toggle_mute!(action, body=nil)
|
72
72
|
return unless ['mute', 'unmute'].include?(action) && id
|
73
|
-
attributes = request(:post, "#{ resource_url(id) }/#{action}")
|
73
|
+
attributes = request(:post, "#{ resource_url(id) }/#{action}", body)
|
74
74
|
if message = attributes['errors']
|
75
75
|
Doggy.ui.error(message)
|
76
76
|
else
|
77
77
|
self.attributes = attributes
|
78
|
+
if local_version = Doggy::Model.find_local(id)
|
79
|
+
self.path = local_version.path
|
80
|
+
end
|
78
81
|
save_local
|
79
82
|
end
|
80
83
|
end
|
data/lib/doggy/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: doggy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.33
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vlad Gorodetsky
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-12-
|
12
|
+
date: 2016-12-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: json
|
@@ -81,6 +81,20 @@ dependencies:
|
|
81
81
|
- - "~>"
|
82
82
|
- !ruby/object:Gem::Version
|
83
83
|
version: 0.23.2
|
84
|
+
- !ruby/object:Gem::Dependency
|
85
|
+
name: activesupport
|
86
|
+
requirement: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - "~>"
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '4'
|
91
|
+
type: :runtime
|
92
|
+
prerelease: false
|
93
|
+
version_requirements: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - "~>"
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '4'
|
84
98
|
- !ruby/object:Gem::Dependency
|
85
99
|
name: bundler
|
86
100
|
requirement: !ruby/object:Gem::Requirement
|
@@ -153,6 +167,7 @@ files:
|
|
153
167
|
- lib/doggy/cli/pull.rb
|
154
168
|
- lib/doggy/cli/push.rb
|
155
169
|
- lib/doggy/cli/unmute.rb
|
170
|
+
- lib/doggy/duration.rb
|
156
171
|
- lib/doggy/model.rb
|
157
172
|
- lib/doggy/models/dashboard.rb
|
158
173
|
- lib/doggy/models/monitor.rb
|