bicho 0.0.10 → 0.0.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +21 -93
- data/.travis.yml +7 -0
- data/{README.rdoc → README.md} +58 -42
- data/Rakefile +10 -12
- data/bicho.gemspec +5 -0
- data/bin/bicho +9 -5
- data/lib/bicho.rb +2 -1
- data/lib/bicho/attachment.rb +72 -0
- data/lib/bicho/bug.rb +8 -2
- data/lib/bicho/cli/command.rb +3 -3
- data/lib/bicho/cli/commands/attachments.rb +75 -0
- data/lib/bicho/cli/commands/history.rb +0 -1
- data/lib/bicho/cli/commands/search.rb +1 -0
- data/lib/bicho/cli/commands/show.rb +2 -1
- data/lib/bicho/cli/commands/version.rb +1 -0
- data/lib/bicho/client.rb +36 -13
- data/lib/bicho/common_client.rb +2 -1
- data/lib/bicho/ext/logger_colors.rb +23 -24
- data/lib/bicho/history.rb +12 -6
- data/lib/bicho/logging.rb +1 -0
- data/lib/bicho/plugins/aliases.rb +1 -2
- data/lib/bicho/plugins/novell.rb +15 -13
- data/lib/bicho/plugins/user.rb +4 -8
- data/lib/bicho/query.rb +2 -4
- data/lib/bicho/version.rb +1 -1
- data/test/helper.rb +8 -1
- data/test/test_attachments.rb +30 -0
- data/test/test_history.rb +10 -4
- data/test/test_novell_plugin.rb +26 -24
- data/test/test_query.rb +6 -5
- data/test/test_user_plugin.rb +1 -2
- data/test/test_version.rb +8 -9
- metadata +64 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4a0d062e368708076439568e705310a5434de9ba
|
4
|
+
data.tar.gz: 7bf1e89725b8870dd8d87d5b5f5747b419cbd284
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 12e08de436746cfb6c9453ea300a24571a686848ed15c882c51a49f7fc0d85b8f00d45d51db05b8d28917e36231c9581491ae377e137afb40a4026af922d92f8
|
7
|
+
data.tar.gz: 00bd9161bc8120b63570dd6d8f7d9fdd0fd878bfe4cbbf8a0d415ddbdecb1920f64cd1dc2f4873a2cc5323b69cfb1c7851e53485bd7e6bb7441a9d68827f319e
|
data/.rubocop.yml
CHANGED
@@ -1,117 +1,45 @@
|
|
1
|
-
|
2
|
-
# on 2014-12-19 12:45:53 +0100 using RuboCop version 0.27.1.
|
3
|
-
# The point is for the user to remove these configuration records
|
4
|
-
# one by one as the offenses are removed from the code base.
|
5
|
-
# Note that changes in the inspected code, or installation of new
|
6
|
-
# versions of RuboCop, may require this file to be generated again.
|
7
|
-
|
8
|
-
# Offense count: 1
|
9
|
-
# Configuration parameters: AlignWith, SupportedStyles.
|
10
|
-
Lint/DefEndAlignment:
|
1
|
+
Metrics/AbcSize:
|
11
2
|
Enabled: false
|
3
|
+
Max: 41
|
12
4
|
|
13
|
-
|
14
|
-
Lint/RescueException:
|
5
|
+
Metrics/ClassLength:
|
15
6
|
Enabled: false
|
7
|
+
Max: 182
|
16
8
|
|
17
|
-
|
18
|
-
Lint/UselessAssignment:
|
9
|
+
Metrics/CyclomaticComplexity:
|
19
10
|
Enabled: false
|
11
|
+
Max: 11
|
20
12
|
|
21
|
-
# Offense count:
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
# Offense count: 1
|
26
|
-
# Configuration parameters: CountComments.
|
27
|
-
Metrics/ClassLength:
|
28
|
-
Max: 133
|
29
|
-
|
30
|
-
# Offense count: 41
|
31
|
-
# Configuration parameters: AllowURI, URISchemes.
|
13
|
+
# Offense count: 49
|
14
|
+
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes.
|
15
|
+
# URISchemes: http, https
|
32
16
|
Metrics/LineLength:
|
33
17
|
Max: 356
|
34
18
|
|
35
|
-
# Offense count: 13
|
36
|
-
# Configuration parameters: CountComments.
|
37
19
|
Metrics/MethodLength:
|
38
20
|
Enabled: false
|
39
21
|
|
40
|
-
|
41
|
-
# Cop supports --auto-correct.
|
42
|
-
Style/BlockComments:
|
43
|
-
Enabled: false
|
44
|
-
|
45
|
-
# Offense count: 2
|
46
|
-
Style/ClassAndModuleCamelCase:
|
22
|
+
Metrics/PerceivedComplexity:
|
47
23
|
Enabled: false
|
48
24
|
|
49
|
-
# Offense count: 5
|
50
|
-
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
51
25
|
Style/ClassAndModuleChildren:
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
Enabled: false
|
57
|
-
|
58
|
-
# Offense count: 13
|
59
|
-
# Cop supports --auto-correct.
|
60
|
-
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
61
|
-
Style/EmptyLinesAroundClassBody:
|
62
|
-
Enabled: false
|
63
|
-
|
64
|
-
# Offense count: 2
|
65
|
-
# Cop supports --auto-correct.
|
66
|
-
Style/EmptyLinesAroundMethodBody:
|
67
|
-
Enabled: false
|
26
|
+
Exclude:
|
27
|
+
# CLI plugins
|
28
|
+
- 'lib/bicho/cli/commands/*.rb'
|
29
|
+
- 'lib/bicho/client.rb'
|
68
30
|
|
69
|
-
# Offense count: 2
|
70
|
-
# Cop supports --auto-correct.
|
71
|
-
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
72
|
-
Style/EmptyLinesAroundModuleBody:
|
73
|
-
Enabled: false
|
74
|
-
|
75
|
-
# Offense count: 2
|
76
|
-
# Configuration parameters: MinBodyLength.
|
77
31
|
Style/GuardClause:
|
78
|
-
|
32
|
+
Exclude:
|
33
|
+
- 'lib/bicho/client.rb'
|
79
34
|
|
80
|
-
# Offense count: 4
|
81
|
-
# Configuration parameters: MaxLineLength.
|
82
|
-
Style/IfUnlessModifier:
|
83
|
-
Enabled: false
|
84
|
-
|
85
|
-
# Offense count: 1
|
86
35
|
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
36
|
+
# SupportedStyles: snake_case, camelCase
|
87
37
|
Style/MethodName:
|
88
|
-
|
38
|
+
Exclude:
|
39
|
+
# L3 method
|
40
|
+
- 'lib/bicho/query.rb'
|
89
41
|
|
90
|
-
# Offense count:
|
42
|
+
# Offense count: 3
|
91
43
|
# Cop supports --auto-correct.
|
92
44
|
Style/NumericLiterals:
|
93
45
|
MinDigits: 7
|
94
|
-
|
95
|
-
# Offense count: 1
|
96
|
-
Style/RedundantException:
|
97
|
-
Enabled: false
|
98
|
-
|
99
|
-
# Offense count: 1
|
100
|
-
Style/RescueModifier:
|
101
|
-
Enabled: false
|
102
|
-
|
103
|
-
# Offense count: 6
|
104
|
-
# Cop supports --auto-correct.
|
105
|
-
Style/SpaceInsideBrackets:
|
106
|
-
Enabled: false
|
107
|
-
|
108
|
-
# Offense count: 1
|
109
|
-
# Cop supports --auto-correct.
|
110
|
-
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
111
|
-
Style/StringLiterals:
|
112
|
-
Enabled: false
|
113
|
-
|
114
|
-
# Offense count: 1
|
115
|
-
# Cop supports --auto-correct.
|
116
|
-
Style/TrailingWhitespace:
|
117
|
-
Enabled: true
|
data/.travis.yml
ADDED
data/{README.rdoc → README.md}
RENAMED
@@ -1,15 +1,19 @@
|
|
1
|
-
|
1
|
+
# Bicho
|
2
2
|
|
3
3
|
* http://github.com/dmacvicar/bicho
|
4
4
|
|
5
|
-
|
5
|
+
![stable](https://img.shields.io/badge/stability-stable-green.svg)
|
6
|
+
![maintained](https://img.shields.io/maintenance/yes/2016.svg)
|
7
|
+
[![Build Status](https://travis-ci.org/dmacvicar/bicho.svg?branch=master)](https://travis-ci.org/dmacvicar/bicho)
|
8
|
+
|
9
|
+
## Introduction
|
6
10
|
|
7
11
|
Library to access bugzilla and command line tool.
|
8
12
|
|
9
13
|
Its main goal is to be clean and provide a command line tool
|
10
14
|
that exposes its features.
|
11
15
|
|
12
|
-
|
16
|
+
## Features
|
13
17
|
|
14
18
|
Main use case is report generation, therefore only the following
|
15
19
|
features are implemented right now:
|
@@ -19,62 +23,72 @@ features are implemented right now:
|
|
19
23
|
|
20
24
|
Plugins can be written to deal with specific bugzilla installations.
|
21
25
|
|
22
|
-
|
26
|
+
## Example (API)
|
23
27
|
|
24
|
-
|
28
|
+
### Client API
|
25
29
|
|
26
|
-
|
30
|
+
```ruby
|
31
|
+
require 'bicho'
|
27
32
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
33
|
+
server = Bicho::Client.new('http://bugzilla.gnome.org')
|
34
|
+
server.get_bugs(127043).each do |bug|
|
35
|
+
puts bug.summary
|
36
|
+
puts bug.url
|
32
37
|
|
33
|
-
|
34
|
-
|
38
|
+
puts bug.history
|
39
|
+
end
|
40
|
+
```
|
35
41
|
|
36
42
|
You can give more than one bug or a named query, or both:
|
37
43
|
|
38
|
-
|
39
|
-
|
40
|
-
|
44
|
+
```ruby
|
45
|
+
server.get_bugs(127043, 432423) => [....]
|
46
|
+
server.get_bugs("Named list") => [....]
|
47
|
+
server.get_bugs("Named list", 4423443) => [....]
|
48
|
+
```
|
41
49
|
|
42
|
-
|
50
|
+
### ActiveRecord-like API
|
43
51
|
|
44
52
|
To use the ActiveRecord like interface over the +Bug+ class, you need first
|
45
53
|
to set the Bicho common client:
|
46
54
|
|
47
|
-
|
55
|
+
```ruby
|
56
|
+
require 'bicho'
|
48
57
|
|
49
|
-
|
58
|
+
Bicho.client = Bicho::Client.new('https://bugzilla.gnome.org')
|
50
59
|
|
51
|
-
|
52
|
-
|
53
|
-
|
60
|
+
Bicho::Bug.where(product: 'vala', status: 'resolved').each do |bug|
|
61
|
+
# .. do something with bug
|
62
|
+
end
|
63
|
+
```
|
54
64
|
|
55
|
-
|
65
|
+
Or alternatively:
|
56
66
|
|
57
|
-
|
58
|
-
|
59
|
-
|
67
|
+
```ruby
|
68
|
+
Bicho::Bug.where.product('vala').status('resolved').each do |bug|
|
69
|
+
# .. do something with bug
|
70
|
+
end
|
71
|
+
```
|
60
72
|
|
61
|
-
|
73
|
+
## Example (CLI)
|
62
74
|
|
63
|
-
|
75
|
+
```console
|
76
|
+
bicho -b http://bugzilla.gnome.org show 127043
|
64
77
|
|
65
|
-
|
78
|
+
bicho -b gnome history 127043
|
66
79
|
|
67
|
-
|
80
|
+
bicho -b gnome search --summary "crash"
|
68
81
|
|
69
|
-
|
82
|
+
bicho -b gnome search --help
|
83
|
+
```
|
70
84
|
|
71
|
-
|
85
|
+
## Authentication
|
72
86
|
|
73
87
|
For SUSE/Novell Bugzilla, a plugin loads the credentials from '~/.oscrc'.
|
74
88
|
|
75
89
|
Otherwise, use the 'username:password@' part of the API URL.
|
76
90
|
|
77
|
-
|
91
|
+
## Customizing Bicho: the user.rb plugin.
|
78
92
|
|
79
93
|
Plugins are included that provide shortcuts for the most common bugzilla sites.
|
80
94
|
|
@@ -83,13 +97,15 @@ There is a "user" plugin that does some of these shortcuts from a configuration
|
|
83
97
|
The settings are read from '.config/bicho/config.yml'. There you can specify the default
|
84
98
|
bugzilla site to use when none is specified and custom aliases.
|
85
99
|
|
86
|
-
|
87
|
-
|
88
|
-
|
100
|
+
```yml
|
101
|
+
aliases:
|
102
|
+
mysite: http://bugzilla.site.com
|
103
|
+
default: mysite
|
104
|
+
```
|
89
105
|
|
90
|
-
|
106
|
+
## Extending Bicho
|
91
107
|
|
92
|
-
|
108
|
+
### Plugins
|
93
109
|
|
94
110
|
Plugins are classes in the module Bicho::Plugins. They can implement hooks that are
|
95
111
|
called at different points of execution.
|
@@ -111,26 +127,26 @@ called at different points of execution.
|
|
111
127
|
The API url is derived from the site url, however some bugzilla installations may have
|
112
128
|
different servers or endpoints.
|
113
129
|
|
114
|
-
|
130
|
+
### Commands
|
115
131
|
|
116
132
|
See the +Command+ class to implement more commands.
|
117
133
|
|
118
|
-
|
134
|
+
## Known issues
|
119
135
|
|
120
136
|
* For now bugs respond to the bugs attributtes described in
|
121
137
|
http://www.bugzilla.org/docs/tip/en/html/api/Bugzilla/WebService/Bug.html, I intend to make those real attributes.
|
122
138
|
* There is no check if an API is supported on the server side
|
123
139
|
|
124
|
-
|
140
|
+
## Roadmap
|
125
141
|
|
126
142
|
* Define the plugin hooks, right now there is one :-)
|
127
143
|
* Shortcuts for the bugzilla URL (bicho -b bko search ..), a plugin?
|
128
144
|
|
129
|
-
|
145
|
+
## Authors
|
130
146
|
|
131
147
|
* Duncan Mac-Vicar P. <dmacvicar@suse.de>
|
132
148
|
|
133
|
-
|
149
|
+
## License
|
134
150
|
|
135
151
|
Copyright (c) 2011-2015 SUSE LLC
|
136
152
|
|
data/Rakefile
CHANGED
@@ -8,10 +8,8 @@ extra_docs = ['README*', 'TODO*', 'CHANGELOG*']
|
|
8
8
|
task default: [:test]
|
9
9
|
|
10
10
|
Rake::TestTask.new do |t|
|
11
|
-
t.
|
12
|
-
t.
|
13
|
-
t.test_files = FileList['test/test*.rb']
|
14
|
-
t.verbose = true
|
11
|
+
t.test_files = Dir.glob(File.join(Dir.pwd, '/test/test_*.rb'))
|
12
|
+
t.verbose = true if ENV['DEBUG']
|
15
13
|
end
|
16
14
|
|
17
15
|
begin
|
@@ -20,12 +18,12 @@ begin
|
|
20
18
|
t.files = ['lib/**/*.rb', *extra_docs]
|
21
19
|
t.options = ['--no-private']
|
22
20
|
end
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
21
|
+
rescue LoadError
|
22
|
+
STDERR.puts 'Install yard if you want prettier docs'
|
23
|
+
require 'rdoc/task'
|
24
|
+
Rake::RDocTask.new(:doc) do |rdoc|
|
25
|
+
rdoc.rdoc_dir = 'doc'
|
26
|
+
rdoc.title = "bicho #{Bicho::VERSION}"
|
27
|
+
extra_docs.each { |ex| rdoc.rdoc_files.include ex }
|
28
|
+
end
|
31
29
|
end
|
data/bicho.gemspec
CHANGED
@@ -17,6 +17,11 @@ Gem::Specification.new do |s|
|
|
17
17
|
s.add_dependency('highline', ['~> 1.6.2'])
|
18
18
|
s.add_dependency('nokogiri')
|
19
19
|
|
20
|
+
s.add_development_dependency('rake')
|
21
|
+
s.add_development_dependency('minitest')
|
22
|
+
s.add_development_dependency('minitest-reporters')
|
23
|
+
s.add_development_dependency('rubocop')
|
24
|
+
|
20
25
|
s.rubyforge_project = 'bicho'
|
21
26
|
|
22
27
|
s.files = `git ls-files`.split("\n")
|
data/bin/bicho
CHANGED
@@ -34,9 +34,9 @@ ft = HighLine::ColorScheme.new do |cs|
|
|
34
34
|
cs[:even_row] = [:green]
|
35
35
|
cs[:odd_row] = [:magenta]
|
36
36
|
cs[:error] = [:red]
|
37
|
-
cs[:remove]
|
38
|
-
cs[:add]
|
39
|
-
cs[:changeset]
|
37
|
+
cs[:remove] = [:red]
|
38
|
+
cs[:add] = [:green]
|
39
|
+
cs[:changeset] = [:blue]
|
40
40
|
end
|
41
41
|
|
42
42
|
HighLine.color_scheme = ft
|
@@ -75,7 +75,11 @@ EOS
|
|
75
75
|
Bicho::Logging.logger.level = Logger::DEBUG if global_opts[:debug]
|
76
76
|
|
77
77
|
# get the subcommand
|
78
|
-
cmd =
|
78
|
+
cmd = begin
|
79
|
+
ARGV.shift
|
80
|
+
rescue
|
81
|
+
nil
|
82
|
+
end
|
79
83
|
|
80
84
|
if !cmd || !SUB_COMMANDS.include?(cmd)
|
81
85
|
Trollop.die "available subcommands: #{SUB_COMMANDS.join(' ')}"
|
@@ -88,7 +92,7 @@ EOS
|
|
88
92
|
opts = cmd_instance.parse_options
|
89
93
|
|
90
94
|
ret = cmd_instance.do(global_opts, opts, ARGV)
|
91
|
-
rescue
|
95
|
+
rescue StandardError => e
|
92
96
|
Bicho::Logging.logger.error e.message
|
93
97
|
Bicho::Logging.logger.error e.backtrace
|
94
98
|
t.say("#{t.color('ERROR: ', :error)} #{t.color(e.message, :bold)}")
|
data/lib/bicho.rb
CHANGED
@@ -29,6 +29,7 @@ require 'bicho/logging'
|
|
29
29
|
require 'bicho/client'
|
30
30
|
require 'bicho/bug'
|
31
31
|
|
32
|
+
# All classes of the Bicho library belong to this module.
|
32
33
|
module Bicho
|
33
34
|
SEARCH_FIELDS = [
|
34
35
|
# name, type, description, multi
|
@@ -55,5 +56,5 @@ module Bicho
|
|
55
56
|
[:version, :strings, 'The Version field of a bug.', true],
|
56
57
|
[:votes, :ints, 'Searches for bugs with this many votes or greater', false],
|
57
58
|
[:whiteboard, :strings, "Search the 'Status Whiteboard' field on bugs for a substring.", true]
|
58
|
-
]
|
59
|
+
].freeze
|
59
60
|
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2016 SUSE LLC
|
3
|
+
#
|
4
|
+
# Author: Duncan Mac-Vicar P. <dmacvicar@suse.de>
|
5
|
+
#
|
6
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
7
|
+
# a copy of this software and associated documentation files (the
|
8
|
+
# "Software"), to deal in the Software without restriction, including
|
9
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
10
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
11
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
12
|
+
# the following conditions:
|
13
|
+
#
|
14
|
+
# The above copyright notice and this permission notice shall be
|
15
|
+
# included in all copies or substantial portions of the Software.
|
16
|
+
#
|
17
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
18
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
19
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
20
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
21
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
22
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
23
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
24
|
+
#++
|
25
|
+
require 'stringio'
|
26
|
+
|
27
|
+
module Bicho
|
28
|
+
# Represents an attachment object for a given bug
|
29
|
+
class Attachment
|
30
|
+
attr_reader :props
|
31
|
+
|
32
|
+
def initialize(client, xmlrpc_client, props)
|
33
|
+
@client = client
|
34
|
+
@xmlrpc_client = xmlrpc_client
|
35
|
+
@props = props
|
36
|
+
end
|
37
|
+
|
38
|
+
# @return [Fixnum] attachment id
|
39
|
+
def id
|
40
|
+
props['id'].to_i
|
41
|
+
end
|
42
|
+
|
43
|
+
# @return [Fixnum] attachment bug id
|
44
|
+
def bug_id
|
45
|
+
props['bug_id'].to_i
|
46
|
+
end
|
47
|
+
|
48
|
+
# @return [String] attachment content type
|
49
|
+
def content_type
|
50
|
+
props['content_type']
|
51
|
+
end
|
52
|
+
|
53
|
+
# @return [Fixnum] attachment size
|
54
|
+
def size
|
55
|
+
props['size'].to_i
|
56
|
+
end
|
57
|
+
|
58
|
+
# @return [String] attachment summary
|
59
|
+
def summary
|
60
|
+
props['summary']
|
61
|
+
end
|
62
|
+
|
63
|
+
# @return [StringIO] attachmentdata
|
64
|
+
# This will be loaded lazyly every time called
|
65
|
+
def data
|
66
|
+
ret = @xmlrpc_client.call('Bug.attachments',
|
67
|
+
attachment_ids: [id], include_fields: ['data'])
|
68
|
+
@client.handle_faults(ret)
|
69
|
+
StringIO.new(ret['attachments'][id.to_s]['data'])
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|