hummer-client 0.0.2

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: 13da03a90d431a06a5ffc8e6a8d3ba3d35189e5a
4
+ data.tar.gz: 523bbc21d6160174a89194d0e60f4fc568680652
5
+ SHA512:
6
+ metadata.gz: 407a0745f83406bb42a9fde1832700ee108fc806a3587b3848152bcc693e1038c1b5eca363d5fe2019b3f9be7c0b23b0832feb544d64392d37f1c621c52a60f2
7
+ data.tar.gz: eb750a26d1f2d09acb87af448960618fd1f9284824c754de66d34e297d47156c22991174def24201a048dda01f4b29500c63866281e63fa041667a0199874a82
data/.gitignore ADDED
@@ -0,0 +1,17 @@
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
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in hummer-client.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Evgeniy Shurmin
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
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
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # Hummer::Client
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'hummer-client'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install hummer-client
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bin/hummer ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'hummer/client'
4
+
5
+ command = Hummer::Client::Command.new
6
+ command.run
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'hummer/client/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "hummer-client"
8
+ spec.version = Hummer::Client::VERSION
9
+ spec.authors = ["Evgeniy Shurmin "]
10
+ spec.email = ["eshurmin@mirantis.com"]
11
+ spec.description = %q{Client for Hummer server}
12
+ spec.summary = %q{Client for Hummer server}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.3"
22
+ spec.add_development_dependency "rake"
23
+ spec.add_dependency "terminal-table"
24
+ spec.add_dependency "mime-types", "<2.0"
25
+ spec.add_dependency "rest-client"
26
+ end
data/hummer.yml ADDED
@@ -0,0 +1,2 @@
1
+ server:
2
+ url: http://0.0.0.0:9292
@@ -0,0 +1,29 @@
1
+ require 'json'
2
+ require 'net/http'
3
+ require 'rest_client'
4
+
5
+ module Hummer::Client
6
+ class API
7
+ def self.configure(options)
8
+ @server = RestClient::Resource.new(options[:server],
9
+ :headers => {
10
+ "X-User-ID" => options[:user],
11
+ "X-User-Token" => options[:token],
12
+ "Accept" => "application/json"
13
+ }
14
+ )
15
+ end
16
+ def self.get(options = {})
17
+ if options.has_key?(:project) and options.has_key?(:suite)
18
+ JSON @server['projects'][options[:project]]['suites'][options[:suite]].get
19
+ elsif options.has_key?(:project)
20
+ JSON @server['projects'][options[:project]]['suites'].get
21
+ else
22
+ JSON @server['projects'].get
23
+ end
24
+ end
25
+ def self.post(project,file,build,feature_list)
26
+ JSON @server['projects'][project]['suites'].post :tempest => File.open(file), :build => build, :feature_list => feature_list
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,127 @@
1
+ require 'terminal-table'
2
+ require 'optparse'
3
+ require 'yaml'
4
+ require 'readline'
5
+
6
+ module Hummer::Client
7
+ class Command
8
+ def initialize(config = nil)
9
+ @options = {
10
+ :server => "http://0.0.0.0:3000"
11
+ }
12
+ if config
13
+ config = File.expand_path(config)
14
+ unless File.exist? config
15
+ puts "Config file not found: #{config}"
16
+ exit(1)
17
+ end
18
+ @options = YAML.load_file config if File.exist? config
19
+ else
20
+ config = File.expand_path("~/.hummer")
21
+ @options = YAML.load_file config if File.exist? config
22
+ end
23
+ @options = Hash[@options.map{|a| [a.first.to_sym, a.last]}]
24
+
25
+ parser = OptionParser.new do|opts|
26
+ opts.banner = "Usage: hummer [options] [command]"
27
+ opts.separator ""
28
+ opts.separator "Specific commands: projects suites post"
29
+ opts.separator ""
30
+ opts.separator "Specific options:"
31
+ opts.on('--help', 'Display help' ) do
32
+ @options[:help] = true
33
+ end
34
+ opts.on('--user ID', 'User ID' ) do |id|
35
+ @options[:user] = id
36
+ end
37
+ opts.on('--token ID', 'User token' ) do |id|
38
+ @options[:token] = id
39
+ end
40
+ opts.on('--server URL', 'Server URL' ) do |url|
41
+ @options[:server] = url
42
+ end
43
+ opts.on('--project ID', 'Project ID' ) do |id|
44
+ @options[:project] = id
45
+ end
46
+ opts.on('--suite ID', 'Suite ID' ) do |id|
47
+ @options[:suite] = id
48
+ end
49
+ opts.on('--json', 'Output in JSON format' ) do
50
+ @options[:json] = true
51
+ end
52
+ opts.on('--file FILE', 'XML file with test results') do |file|
53
+ @options[:file] = file
54
+ end
55
+ end
56
+ begin
57
+ parser.parse ARGV
58
+ if @options[:help] or ARGV.empty?
59
+ puts parser
60
+ exit(0)
61
+ end
62
+ rescue => e
63
+ puts e.message
64
+ end
65
+ end
66
+ def run
67
+ API.configure(@options)
68
+ command = ARGV.first
69
+ if "projects" == command
70
+ @projects = API.get()
71
+ if @projects.kind_of?(Hash) and @projects.has_key?("error")
72
+ puts @projects["error"]
73
+ exit(1)
74
+ end
75
+ if @options[:json]
76
+ puts @projects.inspect
77
+ else
78
+ rows = []
79
+ rows << ["ID","Name","Features","Owner"]
80
+ rows << :separator
81
+ @projects.each do |project|
82
+ rows << [project["id"],project["name"],project["feature_list"].join(", "),project["owner_name"]]
83
+ end
84
+ table = Terminal::Table.new :rows => rows
85
+ puts table
86
+ end
87
+ elsif "post" == command
88
+ if @options[:project] and @options[:file]
89
+ API.post(@options[:project], @options[:file], Readline.readline('Build: '), Readline.readline('Tags: '))
90
+ else
91
+ puts "Need project and file"
92
+ end
93
+ elsif "upload" == command
94
+ if @options.has_key?(:project) and @options.has_key?(:file)
95
+ @suite = API.post(@options[:project], @options[:file])
96
+ else
97
+ puts "Need project and file"
98
+ exit(1)
99
+ end
100
+
101
+ elsif "suites" == command
102
+ if @options.has_key?(:project)
103
+ @suites = API.get(:project => @options[:project], :suite => nil)
104
+ if @suites.kind_of?(Hash) and @suites.has_key?("error")
105
+ puts @projects["error"]
106
+ exit(1)
107
+ end
108
+ if @options[:json]
109
+ puts @suites.inspect
110
+ else
111
+ rows = []
112
+ rows << ["ID","Build","Tests","Errors","Failures","Skip","Passed","Features","Owner"]
113
+ rows << :separator
114
+ @suites.each do |suite|
115
+ rows << [suite["id"],suite["build"],suite["total_tests"],suite["total_errors"],suite["total_failures"],suite["total_skip"],suite["total_passed"],suite["feature_list"].join(", "),suite["user_name"]]
116
+ end
117
+ table = Terminal::Table.new :rows => rows
118
+ puts table
119
+ end
120
+ else
121
+ puts "Need project"
122
+ exit(1)
123
+ end
124
+ end
125
+ end
126
+ end
127
+ end
@@ -0,0 +1,5 @@
1
+ module Hummer
2
+ module Client
3
+ VERSION = "0.0.2"
4
+ end
5
+ end
@@ -0,0 +1,8 @@
1
+ require "hummer/client/version"
2
+ require "hummer/client/command"
3
+ require "hummer/client/api"
4
+
5
+ module Hummer
6
+ module Client
7
+ end
8
+ end
metadata ADDED
@@ -0,0 +1,127 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: hummer-client
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - 'Evgeniy Shurmin '
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-11-06 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: terminal-table
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: mime-types
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - <
60
+ - !ruby/object:Gem::Version
61
+ version: '2.0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - <
67
+ - !ruby/object:Gem::Version
68
+ version: '2.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rest-client
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: Client for Hummer server
84
+ email:
85
+ - eshurmin@mirantis.com
86
+ executables:
87
+ - hummer
88
+ extensions: []
89
+ extra_rdoc_files: []
90
+ files:
91
+ - .gitignore
92
+ - Gemfile
93
+ - LICENSE.txt
94
+ - README.md
95
+ - Rakefile
96
+ - bin/hummer
97
+ - hummer-client.gemspec
98
+ - hummer.yml
99
+ - lib/hummer/client.rb
100
+ - lib/hummer/client/api.rb
101
+ - lib/hummer/client/command.rb
102
+ - lib/hummer/client/version.rb
103
+ homepage: ''
104
+ licenses:
105
+ - MIT
106
+ metadata: {}
107
+ post_install_message:
108
+ rdoc_options: []
109
+ require_paths:
110
+ - lib
111
+ required_ruby_version: !ruby/object:Gem::Requirement
112
+ requirements:
113
+ - - '>='
114
+ - !ruby/object:Gem::Version
115
+ version: '0'
116
+ required_rubygems_version: !ruby/object:Gem::Requirement
117
+ requirements:
118
+ - - '>='
119
+ - !ruby/object:Gem::Version
120
+ version: '0'
121
+ requirements: []
122
+ rubyforge_project:
123
+ rubygems_version: 2.0.6
124
+ signing_key:
125
+ specification_version: 4
126
+ summary: Client for Hummer server
127
+ test_files: []