ducksboard_json 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/bin/ducksboard_json +12 -4
- data/lib/ducksboard_json/version.rb +1 -1
- data/lib/ducksboard_json.rb +3 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 430666c7a1654fc7d586539d104a61998b210479
|
4
|
+
data.tar.gz: db50b1a7d04ac6baed130fe4b284f48b9f9968ad
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a7940241fb4372563d97b1b01c6a0496cf4839f4647a37012c3c3d36614ba4e18087657e7b768a5798ff9bb459851f09c666c91161d0b7c86e6ae0b9bf8fe649
|
7
|
+
data.tar.gz: 03250e933c48a770fb25cee66c48a1b740f7448970fcd07ac18343aeb84051052333c9925a85c2a38f50d4dc22d563dc4c3cd775171c7c5f6adb8a590e4e82ce
|
data/bin/ducksboard_json
CHANGED
@@ -26,24 +26,27 @@ def parse_opts
|
|
26
26
|
opts = Trollop::options do
|
27
27
|
banner strip_heredoc(<<-EOS)
|
28
28
|
Create a JSON file which showing the result of a particular job. The
|
29
|
-
resulting file will be /tmp/ducksboard_json/<job_name>.json
|
29
|
+
resulting file will be /tmp/ducksboard_json/<job_name>.json (or whatever
|
30
|
+
directory is specified by --dir)
|
30
31
|
|
31
32
|
This will be used to populate a dashboard.
|
32
33
|
|
33
34
|
Options:
|
34
35
|
EOS
|
35
|
-
opt :application, '
|
36
|
-
opt :job, 'The job that ran', :type => :string
|
36
|
+
opt :application, 'Name of the application that ran', :type => :string, :required => true
|
37
|
+
opt :job, 'The specific job that ran (defaults to value for --application)', :type => :string
|
37
38
|
opt :ok, 'Success/failure value will be set to 0'
|
38
39
|
opt :error, 'Success/failure value will be set to 1'
|
39
40
|
opt :warning, 'Success/failure value will be set to 2'
|
40
41
|
opt :unknown, 'Success/failure value will be set to 3'
|
42
|
+
opt :dir, 'Directory where the JSON file is saved', :type => :string
|
41
43
|
conflicts :ok, :error, :warning, :unknown
|
42
44
|
end
|
43
45
|
|
44
46
|
unless opts[:ok] || opts[:error] || opts[:warning] || opts[:unknown]
|
45
47
|
Trollop::die :ok, 'or one of the other success/failure flags must be used'
|
46
48
|
end
|
49
|
+
opts[:job] = opts[:application] unless opts[:job]
|
47
50
|
opts
|
48
51
|
end
|
49
52
|
|
@@ -52,5 +55,10 @@ if $0 == __FILE__
|
|
52
55
|
opts = parse_opts
|
53
56
|
value = parse_value(opts)
|
54
57
|
|
55
|
-
DucksboardJson::DucksboardJson.new(
|
58
|
+
DucksboardJson::DucksboardJson.new(
|
59
|
+
opts[:application],
|
60
|
+
opts[:job],
|
61
|
+
value,
|
62
|
+
:dir => opts[:dir],
|
63
|
+
).write
|
56
64
|
end
|
data/lib/ducksboard_json.rb
CHANGED
@@ -5,8 +5,9 @@ module DucksboardJson
|
|
5
5
|
class DucksboardJson
|
6
6
|
|
7
7
|
def initialize(application, job, value, options={})
|
8
|
-
@application = application
|
9
8
|
@job = job
|
9
|
+
@dir = options.fetch(:dir, nil)
|
10
|
+
@dir ||= "/tmp/ducksboard_json/#{application}"
|
10
11
|
|
11
12
|
@json = {
|
12
13
|
'value' => value,
|
@@ -16,7 +17,7 @@ module DucksboardJson
|
|
16
17
|
end
|
17
18
|
|
18
19
|
def write
|
19
|
-
filename = "
|
20
|
+
filename = "#{@dir}/#{@job}.json"
|
20
21
|
FileUtils.mkdir_p(File.dirname(filename))
|
21
22
|
|
22
23
|
File.open(filename, 'w') do |f|
|