doggy 2.0.15 → 2.0.17

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: d1a5d235c5e0d8ef358ef0fb74e8fdff03f5ea01
4
- data.tar.gz: 3783e29d01e4dcdd5c4b7a5b4333ddb3d40c6886
3
+ metadata.gz: bb97cb24320519a7bba30b15a873051f5948728c
4
+ data.tar.gz: 327e1a6e44d4fcec59eccca3ad057587a6000604
5
5
  SHA512:
6
- metadata.gz: 5b37a7aa0cf6f8598d7c18ac550ab9271fc85a4753fd1a160dd7f461c4adbbf3c0b265d70c8bbb8d10cc0773108c96477fefb7cc631705ee9a5502903fa2a7d1
7
- data.tar.gz: 5e872fc853661cc5b9c3e4a33bb23c8ab4c41952ca376ed780a16c78c24d34c12c7208accfbe8276103e092d3807324b3a1fcb1ddafe549f2f09034f2940205f
6
+ metadata.gz: 07b2acceb8064210cb05db56b6544155a2228f7d2bc679dcbd6c773346dc436e91ad93c2400ffa344db0ab4c59ee4d9c395b93e547f29e90ccbf1bb1916e2e71
7
+ data.tar.gz: f0beada455921ce51d6b4b5a387654bcf352edef0b0810988a88b91428aebc08584340f1ffa13cafedb20b8a100698bb4f3fb08946a7cbd8d5d276dfad6d87b7
data/.gitignore CHANGED
@@ -6,3 +6,4 @@
6
6
  /pkg/
7
7
  /spec/reports/
8
8
  /tmp/
9
+ *.gem
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- doggy (2.0.15)
4
+ doggy (2.0.16)
5
5
  json (~> 1.8.3)
6
6
  parallel (~> 1.6.1)
7
7
  rugged (~> 0.23.2)
data/doggy.gemspec CHANGED
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
19
19
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
20
  spec.require_paths = ["lib"]
21
21
 
22
- spec.required_ruby_version = '~> 2.1'
22
+ spec.required_ruby_version = '~> 2.0'
23
23
 
24
24
  spec.add_dependency "json", "~> 1.8.3"
25
25
  spec.add_dependency "parallel", "~> 1.6.1"
data/lib/doggy/cli.rb CHANGED
@@ -18,7 +18,7 @@ module Doggy
18
18
  method_option "all", type: :boolean, desc: 'Pull everything', aliases: '-a'
19
19
 
20
20
  def pull(*ids)
21
- CLI::Pull.new(ids: ids, options: options.dup).run
21
+ CLI::Pull.new(options.dup, ids).run
22
22
  end
23
23
 
24
24
  desc "push", "Pushes objects to Datadog"
@@ -48,6 +48,14 @@ module Doggy
48
48
  if @param =~ /^[0-9]+$/ then
49
49
  id = @param.to_i
50
50
  return resources.find { |res| res.id == id }
51
+ elsif @param =~ /^http/ then
52
+ id = case @param
53
+ when /com\/dash/ then Integer(@param[/dash\/(\d+)/i, 1])
54
+ when /com\/screen/ then Integer(@param[/screen\/(\d+)/i, 1])
55
+ when /com\/monitors/ then Integer(@param[/monitors#(\d+)/i, 1])
56
+ else raise StandardError.new('Unknown resource type, cannot edit.')
57
+ end
58
+ return resources.find { |res| res.id == id }
51
59
  else
52
60
  full_path = File.expand_path(@param, Doggy.object_root)
53
61
  return resources.find { |res| res.path == full_path }
@@ -2,9 +2,9 @@
2
2
 
3
3
  module Doggy
4
4
  class CLI::Pull
5
- def initialize(ids:, options:)
6
- @ids = ids
7
- @options = options
5
+ def initialize(options, ids)
6
+ @options = options
7
+ @ids = ids
8
8
  @updated_by_last_action = false
9
9
  end
10
10
 
data/lib/doggy/model.rb CHANGED
@@ -138,12 +138,22 @@ module Doggy
138
138
  }.to_json)
139
139
  end
140
140
 
141
+ def sort_by_key(hash, &block)
142
+ hash.keys.sort(&block).reduce({}) do |seed, key|
143
+ seed[key] = hash[key]
144
+ if seed[key].is_a?(Hash)
145
+ seed[key] = Doggy::Model.sort_by_key(seed[key], &block)
146
+ end
147
+ seed
148
+ end
149
+ end
150
+
141
151
  protected
142
152
 
143
153
  def resource_url(id = nil)
144
154
  raise NotImplementedError, "#resource_url has to be implemented."
145
155
  end
146
- end
156
+ end # class << self
147
157
 
148
158
  def initialize(attributes = nil)
149
159
  root_key = self.class.root
@@ -160,6 +170,10 @@ module Doggy
160
170
  File.open(@path, 'w') { |f| f.write(JSON.pretty_generate(to_h)) }
161
171
  end
162
172
 
173
+ def to_h
174
+ Doggy::Model.sort_by_key(super)
175
+ end
176
+
163
177
  def save
164
178
  ensure_managed_emoji!
165
179
 
data/lib/doggy/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  module Doggy
4
- VERSION = "2.0.15"
4
+ VERSION = "2.0.17"
5
5
  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: 2.0.15
4
+ version: 2.0.17
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: 2015-10-14 00:00:00.000000000 Z
12
+ date: 2015-10-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: json
@@ -168,7 +168,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
168
168
  requirements:
169
169
  - - "~>"
170
170
  - !ruby/object:Gem::Version
171
- version: '2.1'
171
+ version: '2.0'
172
172
  required_rubygems_version: !ruby/object:Gem::Requirement
173
173
  requirements:
174
174
  - - ">="