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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a236cd7b3c32651576586f78c4c35f55840bb0e6
4
- data.tar.gz: 54fa6b52ec79a23d720b50d6193e55687c279d30
3
+ metadata.gz: 430666c7a1654fc7d586539d104a61998b210479
4
+ data.tar.gz: db50b1a7d04ac6baed130fe4b284f48b9f9968ad
5
5
  SHA512:
6
- metadata.gz: 4d4b0917f76657e3e761b5d43f685be922973e2bebc6bca946c60813d98dae7d83e6ff028b3b16a3fdd069fab954b92923694a49b45283eb67cddaec0f7da1df
7
- data.tar.gz: 8bbd4aec73f51d65d97b086f4048399ef29bf69a5aeda7b630fba453414f46a65a8594af24992372f3494935fe28a5e53db230c18c5d4ca23e433a60ad4f6bd1
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, 'Application that ran the job', :type => :string, :required => true
36
- opt :job, 'The job that ran', :type => :string, :required => true
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(opts[:application], opts[:job], value).write
58
+ DucksboardJson::DucksboardJson.new(
59
+ opts[:application],
60
+ opts[:job],
61
+ value,
62
+ :dir => opts[:dir],
63
+ ).write
56
64
  end
@@ -1,3 +1,3 @@
1
1
  module DucksboardJson
2
- VERSION = '0.0.1'
2
+ VERSION = '0.0.2'
3
3
  end
@@ -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 = "/tmp/ducksboard_json/#{@application}/#{@job}.json"
20
+ filename = "#{@dir}/#{@job}.json"
20
21
  FileUtils.mkdir_p(File.dirname(filename))
21
22
 
22
23
  File.open(filename, 'w') do |f|
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ducksboard_json
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dean Morin