dashdog 0.1.0 → 0.1.1

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: f1eefccd09176d0addebdde251de690ca71b65d9
4
- data.tar.gz: f24304db6a985c943ecb73adf359c415593b20d8
3
+ metadata.gz: 5bd9f5b8483bb4fc4ab8b73b881f6dcb61e4044a
4
+ data.tar.gz: bbda047cb690cb840671b4a67f3609f7ebb49cab
5
5
  SHA512:
6
- metadata.gz: 9a259f0e6f87135a4034508a08277c2929c371d911e4820d433af8ec4cda8441f29513b078e8690fcf3f3768a3138af2d304d658d701a7db9bf08b7d164a7d21
7
- data.tar.gz: 24febc08fc6944bfbfd7864d50be38377c4546e562b93d57e66f7bd86092064bd7842af28397505ef253331b43668f5ed7f56c2ee69eb85475547f24082b708f
6
+ metadata.gz: ec7c47d5d7cee288898c25d011fe61a5dab41a21182693bef17bbf5fd229aab910b4833d056b182120044b49a1ba31a746a0c6ded30955d71615d04b043356a2
7
+ data.tar.gz: 5595e13d9e51c71daf046e80e26c22363a86516e193a62a13c67b29ab8f9d15d956d1d1c374c2ed445b008f8589c1389bc3937bdafbb83168cf6990f14a9bd84
@@ -0,0 +1,16 @@
1
+ ## 0.1.1
2
+
3
+ - Add color option / check stdout tty [#3][] ([@winebarrel][])
4
+ - Use parallel for speeding up [#2][] ([@winebarrel][])
5
+ - Bugfix: Error occurs when widgets is nil. [#1][] ([@winebarrel][])
6
+ - Fix strange diff colorize
7
+
8
+ ## 0.1.0
9
+
10
+ - Initial release
11
+
12
+ <!--- The following link definition list is generated by PimpMyChangelog --->
13
+ [#1]: https://github.com/serverworks/dashdog/issues/1
14
+ [#2]: https://github.com/serverworks/dashdog/issues/2
15
+ [#3]: https://github.com/serverworks/dashdog/issues/3
16
+ [@winebarrel]: https://github.com/winebarrel
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # Dashdog
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/dashdog.svg)](https://badge.fury.io/rb/dashdog)
4
+
3
5
  Datadog dashboards management tool with Ruby DSL.
4
6
 
5
7
  ## Installation
@@ -38,6 +40,8 @@ Commands:
38
40
  Options:
39
41
  -f, [--file=FILE] # Configuration file
40
42
  # Default: Boardfile
43
+ [--color], [--no-color] # Disable colorize
44
+ # Default: true
41
45
  ```
42
46
 
43
47
  ## Commands
@@ -53,6 +57,8 @@ Options:
53
57
  -w, [--write], [--no-write] # Write the configuration to the file
54
58
  -f, [--file=FILE] # Configuration file
55
59
  # Default: Boardfile
60
+ [--color], [--no-color] # Disable colorize
61
+ # Default: true
56
62
  ```
57
63
 
58
64
  ### apply
@@ -24,6 +24,7 @@ Gem::Specification.new do |spec|
24
24
  spec.add_dependency "thor", "~> 0.19.1"
25
25
  spec.add_dependency "coderay"
26
26
  spec.add_dependency "diffy"
27
+ spec.add_dependency "parallel"
27
28
 
28
29
  spec.add_development_dependency "bundler", "~> 1.12"
29
30
  spec.add_development_dependency "rake", "~> 10.0"
@@ -13,7 +13,7 @@ module Dashdog
13
13
  def export(options)
14
14
  dsl = @converter.timeboards_to_dsl(@client.get_timeboards)
15
15
  dsl << @converter.screenboards_to_dsl(@client.get_screenboards)
16
- Dashdog::Utils.print_ruby(dsl)
16
+ Dashdog::Utils.print_ruby(dsl, color: options[:color])
17
17
  File.write(options['file'], dsl) if options['write']
18
18
  end
19
19
 
@@ -38,7 +38,8 @@ module Dashdog
38
38
  if l == r
39
39
  info("#{dry_run}No changes '#{l['title']}'")
40
40
  else
41
- warn("#{dry_run}Update the timeboard\n#{Dashdog::Utils.diff(r, l)}")
41
+ warn("#{dry_run}Update the timeboard '#{l['title']}'")
42
+ STDERR.puts Dashdog::Utils.diff(r, l)
42
43
  @client.update_timeboard(l) if dry_run.empty?
43
44
  end
44
45
  end
@@ -71,7 +72,8 @@ module Dashdog
71
72
  if l == r
72
73
  info("#{dry_run}No changes '#{l['board_title']}'")
73
74
  else
74
- warn("#{dry_run}Update the screenboard '#{l['board_title']}'\n#{Dashdog::Utils.diff(r, l)}")
75
+ warn("#{dry_run}Update the screenboard '#{l['board_title']}'")
76
+ STDERR.puts Dashdog::Utils.diff(r, l)
75
77
  @client.update_screenboard(l) if dry_run.empty?
76
78
  end
77
79
  end
@@ -3,6 +3,7 @@ require 'thor'
3
3
  module Dashdog
4
4
  class Cli < Thor
5
5
  class_option :file, aliases: '-f', desc: 'Configuration file', type: :string, default: 'Boardfile'
6
+ class_option :color, desc: 'Disable colorize', type: :boolean, default: $stdout.tty?
6
7
 
7
8
  def initialize(*args)
8
9
  @actions = Dashdog::Actions.new
@@ -1,4 +1,5 @@
1
1
  require 'dogapi'
2
+ require 'parallel'
2
3
 
3
4
  module Dashdog
4
5
  class Client
@@ -9,7 +10,7 @@ module Dashdog
9
10
 
10
11
  def get_timeboards
11
12
  ret = []
12
- @api.get_dashboards[1]['dashes'].each do |bd|
13
+ Parallel.each(@api.get_dashboards[1]['dashes'], in_threads: 8) do |bd|
13
14
  ret << @api.get_dashboard(bd['id'])[1]['dash']
14
15
  end
15
16
  return ret
@@ -17,7 +18,7 @@ module Dashdog
17
18
 
18
19
  def get_screenboards
19
20
  ret = []
20
- @api.get_all_screenboards[1]['screenboards'].each do |bd|
21
+ Parallel.each(@api.get_all_screenboards[1]['screenboards'], in_threads: 8) do |bd|
21
22
  ret << @api.get_screenboard(bd['id'])[1]
22
23
  end
23
24
  return ret
@@ -40,7 +40,7 @@ EOS
40
40
  screenboards.each do |sb|
41
41
  title = sb['board_title']
42
42
  DELETE_KEYS.each {|k| sb.delete(k) }
43
- widgets = sb['widgets']
43
+ widgets = sb['widgets'] || []
44
44
  sb['widgets'] = []
45
45
  widgets.each do |wd|
46
46
  wd.delete('board_id')
@@ -20,8 +20,12 @@ module Dashdog
20
20
  puts CodeRay.scan(yaml, :yaml).terminal
21
21
  end
22
22
 
23
- def self.print_ruby(ruby)
24
- puts CodeRay.scan(ruby, :ruby).terminal
23
+ def self.print_ruby(ruby, options = {})
24
+ if options[:color]
25
+ puts CodeRay.scan(ruby, :ruby).terminal
26
+ else
27
+ puts ruby
28
+ end
25
29
  end
26
30
 
27
31
  def self.print_json(json)
@@ -1,3 +1,3 @@
1
1
  module Dashdog
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dashdog
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Serverworks Co.,Ltd.
@@ -80,6 +80,20 @@ dependencies:
80
80
  - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: parallel
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
83
97
  - !ruby/object:Gem::Dependency
84
98
  name: bundler
85
99
  requirement: !ruby/object:Gem::Requirement
@@ -133,7 +147,7 @@ files:
133
147
  - ".gitignore"
134
148
  - ".rspec"
135
149
  - ".travis.yml"
136
- - Boardfile
150
+ - CHANGELOG.md
137
151
  - Gemfile
138
152
  - LICENSE.txt
139
153
  - README.md
data/Boardfile DELETED
@@ -1,117 +0,0 @@
1
- timeboard "terui's TimeBoard 5 Aug 2016 11:46" do
2
- read_only false
3
- description "created by terui@serverworks.co.jp"
4
- title "terui's TimeBoard 5 Aug 2016 11:46"
5
- graphs do |*|
6
- definition do
7
- viz "timeseries"
8
- requests do |*|
9
- q "avg:system.load.1{*}"
10
- aggregator "avg"
11
- conditional_formats []
12
- type "line"
13
- end
14
- end
15
- title "Avg of system.load.1 over *"
16
- end
17
- graphs do |*|
18
- definition do
19
- style do
20
- palette "green_to_orange"
21
- paletteFlip false
22
- end
23
- group nil
24
- noMetricHosts true
25
- viz "hostmap"
26
- scope nil
27
- requests do |*|
28
- q "avg:collection_timestamp{*} by {host}"
29
- type "fill"
30
- end
31
- noGroupHosts true
32
- end
33
- title "Avg of collection_timestamp over * by host"
34
- end
35
- graphs do |*|
36
- definition do
37
- viz "query_value"
38
- requests do |*|
39
- q "avg:system.cpu.user{*}"
40
- conditional_formats do |*|
41
- palette "white_on_green"
42
- comparator "<="
43
- value "50"
44
- end
45
- conditional_formats do |*|
46
- palette "white_on_yellow"
47
- comparator ">"
48
- value "50"
49
- end
50
- conditional_formats do |*|
51
- palette "white_on_red"
52
- comparator ">"
53
- value "80"
54
- end
55
- end
56
- end
57
- title "Avg of system.cpu.user over *"
58
- end
59
- graphs do |*|
60
- definition do
61
- viz "timeseries"
62
- requests do |*|
63
- q "avg:aws.ebs.volume_write_ops{host:default-amazon-linux}"
64
- end
65
- events []
66
- end
67
- title "aws.ebs.volume_write_ops"
68
- end
69
- end
70
-
71
- screenboard "terui's ScreenBoard 15 Aug 2016 15:39 test" do
72
- read_only false
73
- board_bgtype "board_graph"
74
- original_title ""
75
- height 80
76
- width "100%"
77
- template_variables []
78
- widgets do |*|
79
- title_size 16
80
- title true
81
- color "#4d4d4d"
82
- text "Text Widget 2"
83
- title_align "left"
84
- text_align "left"
85
- title_text ""
86
- height 6
87
- width 24
88
- y 4
89
- x 8
90
- font_size "auto"
91
- type "free_text"
92
- end
93
- widgets do |*|
94
- title_size 16
95
- title true
96
- title_align "left"
97
- title_text ""
98
- height 13
99
- tile_def do
100
- viz "timeseries"
101
- requests do |*|
102
- q "avg:system.cpu.user{*}"
103
- conditional_formats []
104
- type "line"
105
- end
106
- end
107
- width 47
108
- timeframe "1h"
109
- y 4
110
- x 52
111
- legend_size "0"
112
- type "timeseries"
113
- legend false
114
- end
115
- shared false
116
- title_edited false
117
- end