doggy 2.0.25 → 2.0.26
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/doggy/cli/pull.rb +24 -9
- data/lib/doggy/model.rb +7 -1
- data/lib/doggy/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 34c9e3abbc694a088709003978294cc500338c8e
|
4
|
+
data.tar.gz: 1cc97bcb81bb1198f1bd936d1080a9ee0307b7bd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bb54356ef11e5bc7f23cdf192f06870546390725959898294fb1d70b4a5315764ad311fb5e42467192722033de2e6b48583815f17c49993812ee479e7eb07cca
|
7
|
+
data.tar.gz: 54c8b8957a0590a66bfbd365fd00477a012032658f59e4bd069a310354312fbc626b194806519d37360f5326e5d9fd5518012a1752dad5e10fd993c224449aea
|
data/Gemfile.lock
CHANGED
data/lib/doggy/cli/pull.rb
CHANGED
@@ -28,17 +28,32 @@ module Doggy
|
|
28
28
|
private
|
29
29
|
|
30
30
|
def pull_by_id(id)
|
31
|
-
|
32
|
-
if !local_resource
|
33
|
-
remote_resource = [Models::Dashboard, Models::Monitor, Models::Screen].map do |klass|
|
34
|
-
klass.find(id)
|
35
|
-
end.compact.first
|
31
|
+
local_resources = @local_resources.find_all { |l| l.id == id }
|
36
32
|
|
37
|
-
|
33
|
+
remote_resources = [Models::Dashboard, Models::Monitor, Models::Screen].map do |klass|
|
34
|
+
klass.find(id)
|
35
|
+
end.compact
|
36
|
+
|
37
|
+
if local_resources.size != remote_resources.size
|
38
|
+
normalized_remote_resources = remote_resources.map { |remote_resource| [ remote_resource.class.name, remote_resource.id ] }
|
39
|
+
normalized_local_resources = local_resources.map { |local_resource| [ local_resource.class.name, local_resource.id ] }
|
40
|
+
normalized_resource_diff = Hash[normalized_remote_resources - normalized_local_resources]
|
41
|
+
|
42
|
+
# Here we traverse `remote_resources` to find remote resource with matching class name and id.
|
43
|
+
# We cannot subtract `local_resources` from `remote_resources` because those are different kind of objects.
|
44
|
+
remote_resources_to_be_saved = normalized_resource_diff.map do |klass, id|
|
45
|
+
remote_resources.find do |rr|
|
46
|
+
rr.class.name == klass && rr.id == id
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
remote_resources_to_be_saved.each(&:save_local)
|
38
51
|
else
|
39
|
-
|
40
|
-
|
41
|
-
|
52
|
+
local_resources.each do |local_resource|
|
53
|
+
remote_resource = local_resource.class.find(local_resource.id)
|
54
|
+
remote_resource.path = local_resource.path
|
55
|
+
remote_resource.save_local
|
56
|
+
end
|
42
57
|
end
|
43
58
|
end
|
44
59
|
|
data/lib/doggy/model.rb
CHANGED
@@ -173,7 +173,13 @@ module Doggy
|
|
173
173
|
end
|
174
174
|
|
175
175
|
def save_local
|
176
|
-
|
176
|
+
prefix = case self.class.name
|
177
|
+
when 'Doggy::Models::Dashboard' then 'dash'
|
178
|
+
when 'Doggy::Models::Monitor' then 'monitor'
|
179
|
+
when 'Doggy::Models::Screen' then 'screen'
|
180
|
+
end
|
181
|
+
|
182
|
+
@path ||= Doggy.object_root.join("#{prefix}-#{id}.json")
|
177
183
|
File.open(@path, 'w') { |f| f.write(JSON.pretty_generate(to_h)) }
|
178
184
|
end
|
179
185
|
|
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.26
|
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-06-
|
12
|
+
date: 2016-06-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: json
|
@@ -176,7 +176,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
176
176
|
version: '0'
|
177
177
|
requirements: []
|
178
178
|
rubyforge_project:
|
179
|
-
rubygems_version: 2.6.
|
179
|
+
rubygems_version: 2.6.5
|
180
180
|
signing_key:
|
181
181
|
specification_version: 4
|
182
182
|
summary: Syncs DataDog dashboards, alerts, screenboards, and monitors.
|