hummer-client 0.0.2 → 0.1.0
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/hummer-client.gemspec +1 -0
- data/lib/hummer/client.rb +1 -1
- data/lib/hummer/client/command.rb +72 -53
- data/lib/hummer/client/model.rb +5 -0
- data/lib/hummer/client/model/base.rb +46 -0
- data/lib/hummer/client/model/feature.rb +4 -0
- data/lib/hummer/client/model/project.rb +7 -0
- data/lib/hummer/client/model/suite.rb +18 -0
- data/lib/hummer/client/version.rb +1 -1
- metadata +21 -3
- data/lib/hummer/client/api.rb +0 -29
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c9a1ce8193cbeaf1076d8406935558b5b9f03bd9
|
4
|
+
data.tar.gz: e13d5a293af67e24946b05adedc1a1716601e1ea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4a922452a387805059e369646a8481c1f8d9b7fc6f78457168f1931605d2adfbe4e3460a9893c25b3c610b1e410917dee2ed523e33cca4245e715bb576ab45b4
|
7
|
+
data.tar.gz: 01f4a8ca1039cf3b878660e2d778be746495082aa464ddf61c4ee3150d3f51ba0196319c087db4b67ff57aed5af4b08ca55d03bbeb72277f3b00cf6f7c07fc72
|
data/hummer-client.gemspec
CHANGED
@@ -21,6 +21,7 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.add_development_dependency "bundler", "~> 1.3"
|
22
22
|
spec.add_development_dependency "rake"
|
23
23
|
spec.add_dependency "terminal-table"
|
24
|
+
spec.add_dependency "json"
|
24
25
|
spec.add_dependency "mime-types", "<2.0"
|
25
26
|
spec.add_dependency "rest-client"
|
26
27
|
end
|
data/lib/hummer/client.rb
CHANGED
@@ -3,11 +3,16 @@ require 'optparse'
|
|
3
3
|
require 'yaml'
|
4
4
|
require 'readline'
|
5
5
|
|
6
|
+
require 'hummer/client/model'
|
7
|
+
|
6
8
|
module Hummer::Client
|
7
9
|
class Command
|
10
|
+
include Hummer::Client::Model
|
8
11
|
def initialize(config = nil)
|
9
12
|
@options = {
|
10
|
-
|
13
|
+
:server => "http://0.0.0.0:3000",
|
14
|
+
:user => "00000000-0000-0000-0000-000000000000",
|
15
|
+
:token => ""
|
11
16
|
}
|
12
17
|
if config
|
13
18
|
config = File.expand_path(config)
|
@@ -25,7 +30,7 @@ module Hummer::Client
|
|
25
30
|
parser = OptionParser.new do|opts|
|
26
31
|
opts.banner = "Usage: hummer [options] [command]"
|
27
32
|
opts.separator ""
|
28
|
-
opts.separator "
|
33
|
+
opts.separator "Commands: projects suites features post"
|
29
34
|
opts.separator ""
|
30
35
|
opts.separator "Specific options:"
|
31
36
|
opts.on('--help', 'Display help' ) do
|
@@ -46,15 +51,28 @@ module Hummer::Client
|
|
46
51
|
opts.on('--suite ID', 'Suite ID' ) do |id|
|
47
52
|
@options[:suite] = id
|
48
53
|
end
|
54
|
+
opts.on('--features NAMEs', 'Feature name, separeted by \',\'' ) do |features|
|
55
|
+
@options[:features] = features
|
56
|
+
end
|
57
|
+
opts.on('--build name', 'Build for new post' ) do |build|
|
58
|
+
@options[:build] = build
|
59
|
+
end
|
49
60
|
opts.on('--json', 'Output in JSON format' ) do
|
50
61
|
@options[:json] = true
|
51
62
|
end
|
52
63
|
opts.on('--file FILE', 'XML file with test results') do |file|
|
53
64
|
@options[:file] = file
|
54
65
|
end
|
66
|
+
opts.on('--version', 'Display version') do
|
67
|
+
@options[:version] = true
|
68
|
+
end
|
55
69
|
end
|
56
70
|
begin
|
57
71
|
parser.parse ARGV
|
72
|
+
if @options[:version]
|
73
|
+
puts "Version: #{Hummer::Client::VERSION}"
|
74
|
+
exit(0)
|
75
|
+
end
|
58
76
|
if @options[:help] or ARGV.empty?
|
59
77
|
puts parser
|
60
78
|
exit(0)
|
@@ -63,64 +81,65 @@ module Hummer::Client
|
|
63
81
|
puts e.message
|
64
82
|
end
|
65
83
|
end
|
84
|
+
def display(objects, titles)
|
85
|
+
objects = objects.kind_of?(Array) ? objects : objects.to_a
|
86
|
+
rows = []
|
87
|
+
rows << titles.collect{|_,title| title }
|
88
|
+
rows << :separator
|
89
|
+
objects.each do |object|
|
90
|
+
values = []
|
91
|
+
titles.collect{|key,_| key}.each do |attribute|
|
92
|
+
value = object.send(attribute)
|
93
|
+
if value.kind_of?(Array)
|
94
|
+
values << value.join(", ")
|
95
|
+
else
|
96
|
+
values << value
|
97
|
+
end
|
98
|
+
end
|
99
|
+
rows << values
|
100
|
+
end
|
101
|
+
puts Terminal::Table.new :rows => rows
|
102
|
+
end
|
66
103
|
def run
|
67
|
-
|
104
|
+
Base.configure(@options)
|
68
105
|
command = ARGV.first
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
rows << :separator
|
81
|
-
@projects.each do |project|
|
82
|
-
rows << [project["id"],project["name"],project["feature_list"].join(", "),project["owner_name"]]
|
106
|
+
case command
|
107
|
+
when "features" then
|
108
|
+
display Feature.all, [[:id,"ID"],[:name, "Name"]]
|
109
|
+
when "projects" then
|
110
|
+
display Project.all, [[:id,"ID"],[:name,"Name"],[:feature_list,"Features"],[:owner_name,"Owner"]]
|
111
|
+
when "suites" then
|
112
|
+
if @options[:project]
|
113
|
+
project = Project.find(@options[:project])
|
114
|
+
suites = project.suites
|
115
|
+
else
|
116
|
+
suites = Suite.all
|
83
117
|
end
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
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)
|
118
|
+
display suites, [[:id,"ID"],[:build,"Build"],[:feature_list,"Features"],[:user_name,"User"],[:total_tests, "Tests"],[:total_errors, "Errors"],[:total_failures, "Failures"],[:total_skip,"Skip"],[:total_passed,"Passed"]]
|
119
|
+
when "post" then
|
120
|
+
project = @options[:project]
|
121
|
+
unless project
|
122
|
+
project = Readline.readline('Project> ')
|
123
|
+
project = Project.find(project.strip)
|
107
124
|
end
|
108
|
-
|
109
|
-
|
110
|
-
|
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
|
125
|
+
build = @options[:build]
|
126
|
+
unless build
|
127
|
+
build = Readline.readline('Build> ')
|
119
128
|
end
|
129
|
+
features = @options[:features]
|
130
|
+
unless features
|
131
|
+
puts "Already exists features: #{Feature.all.collect{|f| f.name}.join(", ")}"
|
132
|
+
puts "Default features: #{project.feature_list.join(", ")}"
|
133
|
+
features = Readline.readline('Features> ')
|
134
|
+
end
|
135
|
+
file = @options[:file]
|
136
|
+
unless file
|
137
|
+
file = Readline.readline('File> ')
|
138
|
+
end
|
139
|
+
Suite.save(project.id, build, features, file)
|
120
140
|
else
|
121
|
-
puts "
|
141
|
+
puts "Unknown command: #{command}"
|
122
142
|
exit(1)
|
123
|
-
end
|
124
143
|
end
|
125
144
|
end
|
126
145
|
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'json'
|
2
|
+
require 'rest_client'
|
3
|
+
|
4
|
+
module Hummer::Client::Model
|
5
|
+
class Base
|
6
|
+
def self.configure(options)
|
7
|
+
@@server = RestClient::Resource.new(options[:server],
|
8
|
+
:headers => {
|
9
|
+
"X-User-ID" => options[:user],
|
10
|
+
"X-User-Token" => options[:token],
|
11
|
+
"Accept" => "application/json"
|
12
|
+
}
|
13
|
+
)
|
14
|
+
end
|
15
|
+
def self.resource res
|
16
|
+
@resource = res
|
17
|
+
end
|
18
|
+
def self.attributes *args
|
19
|
+
@attributes = []
|
20
|
+
args.each do |arg|
|
21
|
+
@attributes << arg
|
22
|
+
self.class_eval("def #{arg};@#{arg};end")
|
23
|
+
self.class_eval("def #{arg}=(val);@#{arg}=val;end")
|
24
|
+
end
|
25
|
+
end
|
26
|
+
def self.find(id, resource = nil)
|
27
|
+
new(JSON(@@server[resource || @resource][id].get))
|
28
|
+
rescue => e
|
29
|
+
puts "API error: #{e.message}"
|
30
|
+
exit(1)
|
31
|
+
end
|
32
|
+
def self.all(resource = nil)
|
33
|
+
JSON(@@server[resource || @resource].get).collect do |params|
|
34
|
+
new(params)
|
35
|
+
end
|
36
|
+
rescue => e
|
37
|
+
puts "API error: #{e.message}"
|
38
|
+
exit(1)
|
39
|
+
end
|
40
|
+
def initialize(params = {})
|
41
|
+
params.each do |key, value|
|
42
|
+
send("#{key}=", value) if respond_to? "#{key}="
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
class Hummer::Client::Model::Suite < Hummer::Client::Model::Base
|
2
|
+
attributes :id, :project_id, :build, :total_tests, :total_errors, :total_failures, :total_skip, :total_passed, :feature_list, :user_name
|
3
|
+
resource "suites"
|
4
|
+
def project
|
5
|
+
Hummer::Client::Model::Project.find(project_id)
|
6
|
+
end
|
7
|
+
def self.save(project, build, feature_list, file)
|
8
|
+
@@server["projects/#{project}/suites"].post({
|
9
|
+
:tempest => File.open(file),
|
10
|
+
:build => build,
|
11
|
+
:feature_list => feature_list,
|
12
|
+
:multipart => true
|
13
|
+
})
|
14
|
+
rescue => e
|
15
|
+
puts "API error: #{e.message}"
|
16
|
+
exit(1)
|
17
|
+
end
|
18
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hummer-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- 'Evgeniy Shurmin '
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-11-
|
11
|
+
date: 2013-11-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - '>='
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: json
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: mime-types
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -97,8 +111,12 @@ files:
|
|
97
111
|
- hummer-client.gemspec
|
98
112
|
- hummer.yml
|
99
113
|
- lib/hummer/client.rb
|
100
|
-
- lib/hummer/client/api.rb
|
101
114
|
- lib/hummer/client/command.rb
|
115
|
+
- lib/hummer/client/model.rb
|
116
|
+
- lib/hummer/client/model/base.rb
|
117
|
+
- lib/hummer/client/model/feature.rb
|
118
|
+
- lib/hummer/client/model/project.rb
|
119
|
+
- lib/hummer/client/model/suite.rb
|
102
120
|
- lib/hummer/client/version.rb
|
103
121
|
homepage: ''
|
104
122
|
licenses:
|
data/lib/hummer/client/api.rb
DELETED
@@ -1,29 +0,0 @@
|
|
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
|