doggy 0.1.2 → 0.1.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
  SHA1:
3
- metadata.gz: c078fe1cd41a67218030af967b4052c03f1692fc
4
- data.tar.gz: d7f7dc138b23c9eaab154068073eb7088b31c184
3
+ metadata.gz: 4a08db9823ee6c5ed48f47766bfd0efbea67b6ed
4
+ data.tar.gz: dbd6aa580574f14850b44d1b9ceea5038171127b
5
5
  SHA512:
6
- metadata.gz: eddaf209c49fca2842d44d450d3f8a42760e89fe2598c280572cdf9e78c81342eb02f498b6e0877b3cd4e5f0745bfceecdf637c48e90709c23f3a8a7b29155e6
7
- data.tar.gz: e433e52c43906207be52c56209f695446b69964190440e15e5ae37cc2a4c818200120286e3a468aeaf6e5b3eeb0593bdc832bf7777375b21607307dedd64d59e
6
+ metadata.gz: 2a14f340fe533e1169ea5ad4612fcaca875c6a903a4a9d8c7b3c82ef59cbfefa5d500426e59c1767553aef7de07249a8cdf742d3841abdc0fb91b998df0b29ca
7
+ data.tar.gz: 9a9917fd410dd1d4648a574d6b8f2f1371e9b5d43b8834af9ab33e1b49c3be9d0637dff54e0a4a928089b43460aa99f2208609a62f9b385fea1bf1c7fc54e124
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- doggy (0.1.2)
4
+ doggy (0.1.3)
5
5
  dogapi (~> 1.17)
6
6
  ejson (~> 1.0)
7
7
  thor (~> 0.19)
@@ -51,8 +51,8 @@ module Doggy
51
51
 
52
52
  def raw
53
53
  @raw ||= begin
54
- result = Doggy.client.dog.get_dashboard(@id)
55
- result && result[1]['dash'] && result[1]['dash'].sort.to_h || {}
54
+ status, result = Doggy.client.dog.get_dashboard(@id)
55
+ result && result['dash'] && result['dash'].sort.to_h || {}
56
56
  end
57
57
  end
58
58
 
@@ -62,9 +62,10 @@ module Doggy
62
62
  end
63
63
 
64
64
  def save
65
- return if raw['errors'] # do now download an item if it doesn't exist
66
- return if raw['title'] =~ Doggy::DOG_SKIP_REGEX
67
- return if raw.empty?
65
+ return if raw.nil? || raw.empty? # do not save if it's empty
66
+ return if raw['errors'] # do not save if there are any errors
67
+ return if raw['title'] =~ Doggy::DOG_SKIP_REGEX # do not save if it had skip tag in title
68
+
68
69
  File.write(path, Doggy.serializer.dump(raw))
69
70
  end
70
71
 
@@ -57,11 +57,16 @@ module Doggy
57
57
 
58
58
  def raw
59
59
  @raw ||= begin
60
- alert = Doggy.client.dog.get_monitor(@id)[1]
60
+ status, alert = Doggy.client.dog.get_monitor(@id)
61
+
62
+ return if status != '200'
63
+
61
64
  alert.delete('state') # delete unnecessary state
62
65
  alert.delete('overall_state') # delete unnecessary state
63
- alert['options'] && alert['options'].delete('silenced') # delete unnecessary state
64
- alert['options'] = alert['options'] && alert['options'].sort.to_h # sort option keys; DataDog response is not ordered
66
+ if alert['options']
67
+ alert['options'].delete('silenced') # delete unnecessary state
68
+ alert['options'] = alert['options'].sort.to_h # sort option keys; DataDog response is not ordered
69
+ end
65
70
  alert && alert.sort.to_h
66
71
  end
67
72
  end
@@ -72,9 +77,10 @@ module Doggy
72
77
  end
73
78
 
74
79
  def save
75
- return if raw['errors'] # do now download an item if it doesn't exist
76
- return if raw['name'] =~ Doggy::DOG_SKIP_REGEX
77
- return if raw.empty?
80
+ return if raw.nil? || raw.empty? # do not save if it's empty
81
+ return if raw['errors'] # do not save if there are any errors
82
+ return if raw['name'] =~ Doggy::DOG_SKIP_REGEX # do not save if it had skip tag in title
83
+
78
84
  File.write(path, Doggy.serializer.dump(raw))
79
85
  end
80
86
 
@@ -38,8 +38,8 @@ module Doggy
38
38
 
39
39
  def raw
40
40
  @raw ||= begin
41
- result = Doggy.client.dog.get_screenboard(@id)
42
- result && result[1] && result[1].sort.to_h
41
+ status, result = Doggy.client.dog.get_screenboard(@id)
42
+ result && result.sort.to_h
43
43
  end
44
44
  end
45
45
 
data/lib/doggy/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Doggy
2
- VERSION = '0.1.2'
2
+ VERSION = '0.1.3'
3
3
  end
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: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vlad Gorodetsky