ducksboard_json 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: a236cd7b3c32651576586f78c4c35f55840bb0e6
4
+ data.tar.gz: 54fa6b52ec79a23d720b50d6193e55687c279d30
5
+ SHA512:
6
+ metadata.gz: 4d4b0917f76657e3e761b5d43f685be922973e2bebc6bca946c60813d98dae7d83e6ff028b3b16a3fdd069fab954b92923694a49b45283eb67cddaec0f7da1df
7
+ data.tar.gz: 8bbd4aec73f51d65d97b086f4048399ef29bf69a5aeda7b630fba453414f46a65a8594af24992372f3494935fe28a5e53db230c18c5d4ca23e433a60ad4f6bd1
data/.gitignore ADDED
@@ -0,0 +1,22 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in jredshift.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,24 @@
1
+ This is free and unencumbered software released into the public domain.
2
+
3
+ Anyone is free to copy, modify, publish, use, compile, sell, or
4
+ distribute this software, either in source code form or as a compiled
5
+ binary, for any purpose, commercial or non-commercial, and by any
6
+ means.
7
+
8
+ In jurisdictions that recognize copyright laws, the author or authors
9
+ of this software dedicate any and all copyright interest in the
10
+ software to the public domain. We make this dedication for the benefit
11
+ of the public at large and to the detriment of our heirs and
12
+ successors. We intend this dedication to be an overt act of
13
+ relinquishment in perpetuity of all present and future rights to this
14
+ software under copyright law.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
+ IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20
+ OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21
+ ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22
+ OTHER DEALINGS IN THE SOFTWARE.
23
+
24
+ For more information, please refer to <http://unlicense.org/>
data/README.md ADDED
@@ -0,0 +1,23 @@
1
+ # ducksboard_json
2
+
3
+ Write JSON that will be used by Ducksboard.
4
+
5
+ This gem produces a very specific format so it may not be useful for many cases.
6
+
7
+ ## Installation
8
+
9
+ Run:
10
+
11
+ $ gem install ducksboard_json
12
+
13
+ ## Usage
14
+
15
+ Some examples:
16
+
17
+ $ ducksboard_json --application my_app --job my_job --ok
18
+ $ cat /tmp/ducksboard_json/my_app/my_job.json
19
+ {"value":0,"completion_time":1418778217,"application":"my_app"}
20
+
21
+ $ ducksboard_json --application my_app --job my_job --error
22
+ $ cat /tmp/ducksboard_json/my_app/my_job.json
23
+ {"value":1,"completion_time":1418778311,"application":"my_app"}
@@ -0,0 +1,56 @@
1
+ #!/usr/bin/env ruby
2
+ require 'trollop'
3
+ require 'ducksboard_json'
4
+
5
+
6
+ def strip_heredoc(doc)
7
+ indent = doc.scan(/^[ \t]*(?=\S)/).min.length
8
+ doc.gsub(/^[ \t]{#{indent}}/, '')
9
+ end
10
+
11
+
12
+ def parse_value(opts)
13
+ if opts[:ok]
14
+ 0
15
+ elsif opts[:error]
16
+ 1
17
+ elsif opts[:warning]
18
+ 2
19
+ elsif opts[:unknown]
20
+ 3
21
+ end
22
+ end
23
+
24
+
25
+ def parse_opts
26
+ opts = Trollop::options do
27
+ banner strip_heredoc(<<-EOS)
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
30
+
31
+ This will be used to populate a dashboard.
32
+
33
+ Options:
34
+ EOS
35
+ opt :application, 'Application that ran the job', :type => :string, :required => true
36
+ opt :job, 'The job that ran', :type => :string, :required => true
37
+ opt :ok, 'Success/failure value will be set to 0'
38
+ opt :error, 'Success/failure value will be set to 1'
39
+ opt :warning, 'Success/failure value will be set to 2'
40
+ opt :unknown, 'Success/failure value will be set to 3'
41
+ conflicts :ok, :error, :warning, :unknown
42
+ end
43
+
44
+ unless opts[:ok] || opts[:error] || opts[:warning] || opts[:unknown]
45
+ Trollop::die :ok, 'or one of the other success/failure flags must be used'
46
+ end
47
+ opts
48
+ end
49
+
50
+
51
+ if $0 == __FILE__
52
+ opts = parse_opts
53
+ value = parse_value(opts)
54
+
55
+ DucksboardJson::DucksboardJson.new(opts[:application], opts[:job], value).write
56
+ end
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'ducksboard_json/version'
5
+
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = 'ducksboard_json'
9
+ spec.version = DucksboardJson::VERSION
10
+ spec.authors = ['Dean Morin']
11
+ spec.email = ['morin.dean@gmail.com']
12
+ spec.summary = 'Write JSON that will be used by Ducksboard.'
13
+ spec.description = <<-EOS
14
+ This gem produces a very specific format so it may not be useful for many cases.
15
+ EOS
16
+ spec.homepage = 'http://github.com/deanmorin/ducksboard_json'
17
+ spec.license = 'The Unlicense'
18
+
19
+ spec.files = `git ls-files -z`.split("\x0")
20
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
21
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
22
+ spec.require_paths = ['lib']
23
+
24
+ spec.add_dependency 'trollop', '~> 2'
25
+ end
@@ -0,0 +1,3 @@
1
+ module DucksboardJson
2
+ VERSION = '0.0.1'
3
+ end
@@ -0,0 +1,27 @@
1
+ require 'json'
2
+
3
+
4
+ module DucksboardJson
5
+ class DucksboardJson
6
+
7
+ def initialize(application, job, value, options={})
8
+ @application = application
9
+ @job = job
10
+
11
+ @json = {
12
+ 'value' => value,
13
+ 'completion_time' => Time.now.to_i,
14
+ 'application' => application
15
+ }.to_json
16
+ end
17
+
18
+ def write
19
+ filename = "/tmp/ducksboard_json/#{@application}/#{@job}.json"
20
+ FileUtils.mkdir_p(File.dirname(filename))
21
+
22
+ File.open(filename, 'w') do |f|
23
+ f.write(@json)
24
+ end
25
+ end
26
+ end
27
+ end
metadata ADDED
@@ -0,0 +1,68 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ducksboard_json
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Dean Morin
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-12-17 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: trollop
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2'
27
+ description: |2
28
+ This gem produces a very specific format so it may not be useful for many cases.
29
+ email:
30
+ - morin.dean@gmail.com
31
+ executables:
32
+ - ducksboard_json
33
+ extensions: []
34
+ extra_rdoc_files: []
35
+ files:
36
+ - ".gitignore"
37
+ - Gemfile
38
+ - LICENSE.txt
39
+ - README.md
40
+ - bin/ducksboard_json
41
+ - ducksboard_json.gemspec
42
+ - lib/ducksboard_json.rb
43
+ - lib/ducksboard_json/version.rb
44
+ homepage: http://github.com/deanmorin/ducksboard_json
45
+ licenses:
46
+ - The Unlicense
47
+ metadata: {}
48
+ post_install_message:
49
+ rdoc_options: []
50
+ require_paths:
51
+ - lib
52
+ required_ruby_version: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: '0'
57
+ required_rubygems_version: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ requirements: []
63
+ rubyforge_project:
64
+ rubygems_version: 2.2.2
65
+ signing_key:
66
+ specification_version: 4
67
+ summary: Write JSON that will be used by Ducksboard.
68
+ test_files: []