bicho 0.0.9 → 0.0.10
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 +7 -0
- data/.rubocop.yml +117 -0
- data/README.rdoc +45 -4
- data/bicho.gemspec +2 -0
- data/bin/bicho +1 -1
- data/lib/bicho/bug.rb +5 -0
- data/lib/bicho/cli/commands/show.rb +7 -2
- data/lib/bicho/cli/commands/version.rb +35 -0
- data/lib/bicho/client.rb +55 -15
- data/lib/bicho/history.rb +9 -1
- data/lib/bicho/plugins/aliases.rb +16 -0
- data/lib/bicho/plugins/novell.rb +11 -2
- data/lib/bicho/plugins/user.rb +49 -0
- data/lib/bicho/version.rb +1 -1
- data/test/test_history.rb +3 -0
- data/test/test_novell_plugin.rb +4 -5
- data/test/test_query.rb +4 -0
- data/test/test_user_plugin.rb +36 -0
- data/test/test_version.rb +21 -0
- metadata +27 -28
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: c310b39555e503cc2b2499c20dc1bf39305448e0
|
|
4
|
+
data.tar.gz: 7c75e72001d044b19ae518903739d61199895a50
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: e9e7ad0a98e5dfdaf9ab6fd038927b8f4256e415b6841f236d8574db19636bf8db052dbb581d850bd1362e1981b874e7a3cd1535caa1f0ca6e46064755e0a991
|
|
7
|
+
data.tar.gz: f10639f87f15b62b106150b11321e7b840bd69c487ec46212b795578cabb4db47c626f8dfefdce18cb43a9707bb296a45bfa842696d421934e74d2fbfdf27ea4
|
data/.rubocop.yml
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
# This configuration was generated by `rubocop --auto-gen-config`
|
|
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:
|
|
11
|
+
Enabled: false
|
|
12
|
+
|
|
13
|
+
# Offense count: 1
|
|
14
|
+
Lint/RescueException:
|
|
15
|
+
Enabled: false
|
|
16
|
+
|
|
17
|
+
# Offense count: 3
|
|
18
|
+
Lint/UselessAssignment:
|
|
19
|
+
Enabled: false
|
|
20
|
+
|
|
21
|
+
# Offense count: 8
|
|
22
|
+
Metrics/AbcSize:
|
|
23
|
+
Max: 43
|
|
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.
|
|
32
|
+
Metrics/LineLength:
|
|
33
|
+
Max: 356
|
|
34
|
+
|
|
35
|
+
# Offense count: 13
|
|
36
|
+
# Configuration parameters: CountComments.
|
|
37
|
+
Metrics/MethodLength:
|
|
38
|
+
Enabled: false
|
|
39
|
+
|
|
40
|
+
# Offense count: 1
|
|
41
|
+
# Cop supports --auto-correct.
|
|
42
|
+
Style/BlockComments:
|
|
43
|
+
Enabled: false
|
|
44
|
+
|
|
45
|
+
# Offense count: 2
|
|
46
|
+
Style/ClassAndModuleCamelCase:
|
|
47
|
+
Enabled: false
|
|
48
|
+
|
|
49
|
+
# Offense count: 5
|
|
50
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
|
51
|
+
Style/ClassAndModuleChildren:
|
|
52
|
+
Enabled: false
|
|
53
|
+
|
|
54
|
+
# Offense count: 17
|
|
55
|
+
Style/Documentation:
|
|
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
|
|
68
|
+
|
|
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
|
+
Style/GuardClause:
|
|
78
|
+
Enabled: false
|
|
79
|
+
|
|
80
|
+
# Offense count: 4
|
|
81
|
+
# Configuration parameters: MaxLineLength.
|
|
82
|
+
Style/IfUnlessModifier:
|
|
83
|
+
Enabled: false
|
|
84
|
+
|
|
85
|
+
# Offense count: 1
|
|
86
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
|
87
|
+
Style/MethodName:
|
|
88
|
+
Enabled: false
|
|
89
|
+
|
|
90
|
+
# Offense count: 7
|
|
91
|
+
# Cop supports --auto-correct.
|
|
92
|
+
Style/NumericLiterals:
|
|
93
|
+
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/README.rdoc
CHANGED
|
@@ -62,14 +62,55 @@ to set the Bicho common client:
|
|
|
62
62
|
|
|
63
63
|
bicho -b http://bugzilla.gnome.org show 127043
|
|
64
64
|
|
|
65
|
-
bicho -b
|
|
65
|
+
bicho -b gnome history 127043
|
|
66
66
|
|
|
67
|
-
bicho -b
|
|
67
|
+
bicho -b gnome search --summary "crash"
|
|
68
68
|
|
|
69
|
-
bicho -b
|
|
69
|
+
bicho -b gnome search --help
|
|
70
|
+
|
|
71
|
+
== Authentication
|
|
72
|
+
|
|
73
|
+
For SUSE/Novell Bugzilla, a plugin loads the credentials from '~/.oscrc'.
|
|
74
|
+
|
|
75
|
+
Otherwise, use the 'username:password@' part of the API URL.
|
|
76
|
+
|
|
77
|
+
== Customizing Bicho: the user.rb plugin.
|
|
78
|
+
|
|
79
|
+
Plugins are included that provide shortcuts for the most common bugzilla sites.
|
|
80
|
+
|
|
81
|
+
There is a "user" plugin that does some of these shortcuts from a configuration file.
|
|
82
|
+
|
|
83
|
+
The settings are read from '.config/bicho/config.yml'. There you can specify the default
|
|
84
|
+
bugzilla site to use when none is specified and custom aliases.
|
|
85
|
+
|
|
86
|
+
aliases:
|
|
87
|
+
mysite: http://bugzilla.site.com
|
|
88
|
+
default: mysite
|
|
70
89
|
|
|
71
90
|
== Extending Bicho
|
|
72
91
|
|
|
92
|
+
=== Plugins
|
|
93
|
+
|
|
94
|
+
Plugins are classes in the module Bicho::Plugins. They can implement hooks that are
|
|
95
|
+
called at different points of execution.
|
|
96
|
+
|
|
97
|
+
* default_site_url_hook
|
|
98
|
+
|
|
99
|
+
If no site url is provided the last one provided by a plugin will be used.
|
|
100
|
+
|
|
101
|
+
* transform_site_url_hook
|
|
102
|
+
|
|
103
|
+
This hook is called to modify the main site url (eg: http://bugzilla.suse.com).
|
|
104
|
+
Use it when a plugin wants to provide an alternative url to a well-known bugzilla or
|
|
105
|
+
a shortcut (eg: bnc) that will be expanded into a site url.
|
|
106
|
+
Plugin order is not defined so make sure your plugin focuses in one type of shortcut
|
|
107
|
+
as another plugin can also change your returned value in their hooks.
|
|
108
|
+
|
|
109
|
+
* transform_api_url_hook
|
|
110
|
+
|
|
111
|
+
The API url is derived from the site url, however some bugzilla installations may have
|
|
112
|
+
different servers or endpoints.
|
|
113
|
+
|
|
73
114
|
=== Commands
|
|
74
115
|
|
|
75
116
|
See the +Command+ class to implement more commands.
|
|
@@ -91,6 +132,6 @@ http://www.bugzilla.org/docs/tip/en/html/api/Bugzilla/WebService/Bug.html, I int
|
|
|
91
132
|
|
|
92
133
|
== License
|
|
93
134
|
|
|
94
|
-
Copyright (c) 2011 SUSE
|
|
135
|
+
Copyright (c) 2011-2015 SUSE LLC
|
|
95
136
|
|
|
96
137
|
Bicho is licensed under the MIT license. See MIT-LICENSE for details.
|
data/bicho.gemspec
CHANGED
|
@@ -10,6 +10,7 @@ Gem::Specification.new do |s|
|
|
|
10
10
|
s.homepage = 'http://github.com/dmacvicar/bicho'
|
|
11
11
|
s.summary = 'Library to access bugzilla'
|
|
12
12
|
s.description = 'Library to access bugzilla'
|
|
13
|
+
s.licenses = ['MIT']
|
|
13
14
|
|
|
14
15
|
s.add_dependency('inifile', ['~> 0.4.1'])
|
|
15
16
|
s.add_dependency('trollop', ['>= 1.16'])
|
|
@@ -22,4 +23,5 @@ Gem::Specification.new do |s|
|
|
|
22
23
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
|
23
24
|
s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
|
|
24
25
|
s.require_paths = ['lib']
|
|
26
|
+
s.required_ruby_version = '>= 1.9.3'
|
|
25
27
|
end
|
data/bin/bicho
CHANGED
|
@@ -68,7 +68,7 @@ begin
|
|
|
68
68
|
EOS
|
|
69
69
|
opt :config, 'Read FILE as configuration file.', type: :io
|
|
70
70
|
opt :debug, 'Show debug messages', default: false
|
|
71
|
-
opt :bugzilla, 'Bugzilla URL or alias',
|
|
71
|
+
opt :bugzilla, 'Bugzilla URL or alias', type: :string
|
|
72
72
|
stop_on SUB_COMMANDS
|
|
73
73
|
end
|
|
74
74
|
|
data/lib/bicho/bug.rb
CHANGED
|
@@ -86,5 +86,10 @@ module Bicho
|
|
|
86
86
|
@client.get_history(id).first
|
|
87
87
|
end
|
|
88
88
|
|
|
89
|
+
# @param format_string For Kernel#sprintf; named params supplied by the bug
|
|
90
|
+
def format(format_string)
|
|
91
|
+
sym_data = Hash[@data.to_a.map { |k, v| [k.to_sym, v]}]
|
|
92
|
+
sprintf(format_string, sym_data)
|
|
93
|
+
end
|
|
89
94
|
end
|
|
90
95
|
end
|
|
@@ -29,12 +29,17 @@ require 'bicho/client'
|
|
|
29
29
|
module Bicho::CLI::Commands
|
|
30
30
|
class Show < ::Bicho::CLI::Command
|
|
31
31
|
options do
|
|
32
|
+
opt :format, "Format string, eg. '%{id}:%{priority}:%{summary}'", :type => :string
|
|
32
33
|
end
|
|
33
34
|
|
|
34
|
-
def do(global_opts,
|
|
35
|
+
def do(global_opts, opts, args)
|
|
35
36
|
client = ::Bicho::Client.new(global_opts[:bugzilla])
|
|
36
37
|
client.get_bugs(*args).each do |bug|
|
|
37
|
-
|
|
38
|
+
if opts[:format]
|
|
39
|
+
t.say(bug.format(opts[:format]))
|
|
40
|
+
else
|
|
41
|
+
t.say("#{t.color(bug.id.to_s, :headline)} #{bug.summary}")
|
|
42
|
+
end
|
|
38
43
|
end
|
|
39
44
|
0
|
|
40
45
|
end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
#--
|
|
2
|
+
# Copyright (c) 2011 SUSE LINUX Products GmbH
|
|
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
|
+
|
|
26
|
+
require 'bicho/cli/command'
|
|
27
|
+
|
|
28
|
+
module Bicho::CLI::Commands
|
|
29
|
+
class Version < ::Bicho::CLI::Command
|
|
30
|
+
def do(_global_opts, _opts, _args)
|
|
31
|
+
t.say(Bicho::VERSION)
|
|
32
|
+
0
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
data/lib/bicho/client.rb
CHANGED
|
@@ -90,31 +90,43 @@ module Bicho
|
|
|
90
90
|
|
|
91
91
|
# @param [String] site_url Bugzilla installation site url
|
|
92
92
|
def initialize(site_url)
|
|
93
|
-
|
|
94
|
-
|
|
93
|
+
@plugins = []
|
|
94
|
+
load_plugins!
|
|
95
|
+
instantiate_plugins!
|
|
95
96
|
|
|
96
|
-
|
|
97
|
-
|
|
97
|
+
if site_url.nil?
|
|
98
|
+
@plugins.each do |pl_instance|
|
|
99
|
+
if pl_instance.respond_to?(:default_site_url_hook)
|
|
100
|
+
default = pl_instance.default_site_url_hook(logger)
|
|
101
|
+
site_url = default unless default.nil?
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
end
|
|
98
105
|
|
|
99
|
-
#
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
106
|
+
# If the default url is still null, we can't continue
|
|
107
|
+
fail ArgumentError, 'missing bugzilla site' if site_url.nil?
|
|
108
|
+
|
|
109
|
+
@plugins.each do |pl_instance|
|
|
110
|
+
if pl_instance.respond_to?(:transform_site_url_hook)
|
|
111
|
+
site_url = pl_instance.transform_site_url_hook(site_url, logger)
|
|
112
|
+
end
|
|
104
113
|
end
|
|
105
114
|
|
|
106
|
-
#
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
115
|
+
# Don't modify the original url
|
|
116
|
+
@site_url = site_url.is_a?(URI) ? site_url.clone : URI.parse(site_url)
|
|
117
|
+
|
|
118
|
+
api_url = @site_url.clone
|
|
119
|
+
api_url.path = '/xmlrpc.cgi'
|
|
111
120
|
|
|
121
|
+
@plugins.each do |pl_instance|
|
|
112
122
|
# Modify API url
|
|
113
123
|
if pl_instance.respond_to?(:transform_api_url_hook)
|
|
114
|
-
|
|
124
|
+
api_url = pl_instance.transform_api_url_hook(api_url, logger)
|
|
115
125
|
end
|
|
116
126
|
end
|
|
117
127
|
|
|
128
|
+
@api_url = api_url.is_a?(URI) ? api_url.clone : URI.parse(api_url)
|
|
129
|
+
|
|
118
130
|
@client = XMLRPC::Client.new_from_uri(@api_url.to_s, nil, 900)
|
|
119
131
|
@client.set_debug
|
|
120
132
|
|
|
@@ -126,6 +138,28 @@ module Bicho
|
|
|
126
138
|
end
|
|
127
139
|
end
|
|
128
140
|
|
|
141
|
+
# ruby-load all the files in the plugins directory
|
|
142
|
+
def load_plugins!
|
|
143
|
+
# Scan plugins
|
|
144
|
+
plugin_glob = File.join(File.dirname(__FILE__), 'plugins', '*.rb')
|
|
145
|
+
Dir.glob(plugin_glob).each do |plugin|
|
|
146
|
+
logger.debug("Loading file: #{plugin}")
|
|
147
|
+
load plugin
|
|
148
|
+
end
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
# instantiate all plugin classes in the Bicho::Plugins
|
|
152
|
+
# module and add them to the list of known plugins
|
|
153
|
+
def instantiate_plugins!
|
|
154
|
+
# instantiate plugins
|
|
155
|
+
::Bicho::Plugins.constants.each do |cnt|
|
|
156
|
+
pl_class = ::Bicho::Plugins.const_get(cnt)
|
|
157
|
+
pl_instance = pl_class.new
|
|
158
|
+
logger.debug("Loaded: #{pl_instance}")
|
|
159
|
+
@plugins << pl_instance
|
|
160
|
+
end
|
|
161
|
+
end
|
|
162
|
+
|
|
129
163
|
def cookie
|
|
130
164
|
@client.cookie
|
|
131
165
|
end
|
|
@@ -138,6 +172,12 @@ module Bicho
|
|
|
138
172
|
end
|
|
139
173
|
end
|
|
140
174
|
|
|
175
|
+
# Return Bugzilla API version
|
|
176
|
+
def version
|
|
177
|
+
ret = @client.call('Bugzilla.version')
|
|
178
|
+
handle_faults(ret)
|
|
179
|
+
ret["version"]
|
|
180
|
+
end
|
|
141
181
|
# Search for a bug
|
|
142
182
|
#
|
|
143
183
|
# +query+ has to be either a +Query+ object or
|
data/lib/bicho/history.rb
CHANGED
|
@@ -52,6 +52,14 @@ module Bicho
|
|
|
52
52
|
end
|
|
53
53
|
|
|
54
54
|
class ChangeSet
|
|
55
|
+
|
|
56
|
+
include Enumerable
|
|
57
|
+
|
|
58
|
+
def date
|
|
59
|
+
warn 'Deprecated. Use timestamp instead'
|
|
60
|
+
timestamp
|
|
61
|
+
end
|
|
62
|
+
|
|
55
63
|
# return [Date] The date the bug activity/change happened.
|
|
56
64
|
def date
|
|
57
65
|
@data['when'].to_date
|
|
@@ -130,7 +138,7 @@ module Bicho
|
|
|
130
138
|
def to_s
|
|
131
139
|
buffer = StringIO.new
|
|
132
140
|
buffer << "#{bug_id}\n"
|
|
133
|
-
|
|
141
|
+
changesets.each do |cs|
|
|
134
142
|
buffer << "#{cs}\n"
|
|
135
143
|
end
|
|
136
144
|
buffer.string
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
module Bicho
|
|
2
|
+
module Plugins
|
|
3
|
+
|
|
4
|
+
class Aliases
|
|
5
|
+
def transform_site_url_hook(url, _logger)
|
|
6
|
+
case url.to_s
|
|
7
|
+
when 'bko', 'kernel' then 'https://bugzilla.kernel.org'
|
|
8
|
+
when 'bgo', 'gnome' then 'https://bugzilla.gnome.org'
|
|
9
|
+
when 'kde' then 'https://bugzilla.kde.org'
|
|
10
|
+
else url
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
end
|
|
16
|
+
end
|
data/lib/bicho/plugins/novell.rb
CHANGED
|
@@ -37,8 +37,8 @@ module Bicho
|
|
|
37
37
|
# your oscrc.
|
|
38
38
|
#
|
|
39
39
|
class Novell
|
|
40
|
-
OSCRC_CREDENTIALS = 'https://api.opensuse.org'
|
|
41
|
-
DEFAULT_OSCRC_PATH = File.join(ENV['HOME'], '.oscrc')
|
|
40
|
+
OSCRC_CREDENTIALS = 'https://api.opensuse.org' unless defined? OSCRC_CREDENTIALS
|
|
41
|
+
DEFAULT_OSCRC_PATH = File.join(ENV['HOME'], '.oscrc') unless defined? DEFAULT_OSCRC_PATH
|
|
42
42
|
|
|
43
43
|
class << self
|
|
44
44
|
attr_writer :oscrc_path
|
|
@@ -67,6 +67,15 @@ module Bicho
|
|
|
67
67
|
fail "No valid .oscrc credentials for Novell/SUSE bugzilla (#{oscrc_path})"
|
|
68
68
|
end
|
|
69
69
|
|
|
70
|
+
def transform_site_url_hook(url, _logger)
|
|
71
|
+
case url.to_s
|
|
72
|
+
when 'bnc', 'novell' then 'https://bugzilla.novell.com'
|
|
73
|
+
when 'bsc', 'suse' then 'https://bugzilla.suse.com'
|
|
74
|
+
when 'boo', 'opensuse' then 'https://bugzilla.opensuse.org'
|
|
75
|
+
else url
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
|
|
70
79
|
def transform_api_url_hook(url, logger)
|
|
71
80
|
domains = ['bugzilla.novell.com', 'bugzilla.suse.com']
|
|
72
81
|
return url unless domains.map { |domain| url.host.include?(domain) }.any?
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
require 'yaml'
|
|
2
|
+
|
|
3
|
+
module Bicho
|
|
4
|
+
module Plugins
|
|
5
|
+
|
|
6
|
+
class User
|
|
7
|
+
|
|
8
|
+
DEFAULT_CONFIG_PATH = File.join(ENV['HOME'], '.config', 'bicho', 'config.yml') unless defined? DEFAULT_CONFIG_PATH
|
|
9
|
+
|
|
10
|
+
class << self
|
|
11
|
+
attr_writer :config_path
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def self.config_path
|
|
15
|
+
@config_path ||= DEFAULT_CONFIG_PATH
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def initialize
|
|
19
|
+
@config = {}
|
|
20
|
+
if File.exist?(Bicho::Plugins::User.config_path)
|
|
21
|
+
@config = YAML.load_file(Bicho::Plugins::User.config_path)
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def default_site_url_hook(logger)
|
|
26
|
+
if @config.key?('default')
|
|
27
|
+
ret = @config['default']
|
|
28
|
+
logger.debug "Default url set to '#{ret}'"
|
|
29
|
+
ret
|
|
30
|
+
else
|
|
31
|
+
logger.warn 'Use .config/bicho/config.yaml to setup a default bugzilla site'
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def transform_site_url_hook(url, logger)
|
|
36
|
+
if @config['aliases'] && @config['aliases'].key?(url.to_s)
|
|
37
|
+
ret = @config['aliases'][url.to_s]
|
|
38
|
+
logger.debug "Transformed '#{url}' to '#{ret}'"
|
|
39
|
+
ret
|
|
40
|
+
else
|
|
41
|
+
url
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
end
|
|
49
|
+
end
|
data/lib/bicho/version.rb
CHANGED
data/test/test_history.rb
CHANGED
data/test/test_novell_plugin.rb
CHANGED
|
@@ -2,16 +2,15 @@ require File.join(File.dirname(__FILE__), 'helper')
|
|
|
2
2
|
require 'bicho/plugins/novell'
|
|
3
3
|
require 'tmpdir'
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
# Test for the plugin supporting the
|
|
6
|
+
# Novell/SUSE bugzilla authentication
|
|
7
|
+
class NovellPluginTest < Test::Unit::TestCase
|
|
6
8
|
def test_urls_are_correct
|
|
7
9
|
%w(novell suse).each do |domain|
|
|
8
10
|
client = Bicho::Client.new("https://bugzilla.#{domain}.com")
|
|
9
11
|
assert_raises NoMethodError do
|
|
10
12
|
client.url
|
|
11
13
|
end
|
|
12
|
-
|
|
13
|
-
# assert_equal "https://apibugzilla.#{domain}.com/xmlrpc.cgi", "#{client.api_url.scheme}://#{client.api_url.host}#{client.api_url.path}"
|
|
14
|
-
# assert_equal "https://bugzilla.#{domain}.com", "#{client.site_url.scheme}://#{client.site_url.host}#{client.site_url.path}"
|
|
15
14
|
end
|
|
16
15
|
end
|
|
17
16
|
|
|
@@ -29,7 +28,7 @@ EOS
|
|
|
29
28
|
def test_oscrc_parsing
|
|
30
29
|
Dir.mktmpdir do |tmp|
|
|
31
30
|
fake_oscrc = File.join(tmp, 'oscrc')
|
|
32
|
-
|
|
31
|
+
NovellPluginTest.write_fake_oscrc(fake_oscrc)
|
|
33
32
|
Bicho::Plugins::Novell.oscrc_path = fake_oscrc
|
|
34
33
|
plugin = Bicho::Plugins::Novell.new
|
|
35
34
|
credentials = Bicho::Plugins::Novell.oscrc_credentials
|
data/test/test_query.rb
CHANGED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
require_relative 'helper'
|
|
2
|
+
require 'bicho/plugins/user'
|
|
3
|
+
require 'tmpdir'
|
|
4
|
+
|
|
5
|
+
# Test for the plugin implementing user
|
|
6
|
+
# preferences
|
|
7
|
+
class UserPluginTest < Test::Unit::TestCase
|
|
8
|
+
|
|
9
|
+
def self.write_fake_config(path)
|
|
10
|
+
File.open(path, 'w') do |f|
|
|
11
|
+
f.write(<<EOS)
|
|
12
|
+
default: foobar
|
|
13
|
+
aliases:
|
|
14
|
+
shazam: http://bugzilla.foobar.com
|
|
15
|
+
EOS
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def test_aliases_and_defaults
|
|
20
|
+
Dir.mktmpdir do |tmp|
|
|
21
|
+
fake_config = File.join(tmp, 'config.yml')
|
|
22
|
+
UserPluginTest.write_fake_config(fake_config)
|
|
23
|
+
Bicho::Plugins::User.config_path = fake_config
|
|
24
|
+
plugin = Bicho::Plugins::User.new
|
|
25
|
+
|
|
26
|
+
logger = Logger.new($stdout)
|
|
27
|
+
|
|
28
|
+
assert_equal 'foobar', plugin.default_site_url_hook(logger)
|
|
29
|
+
|
|
30
|
+
assert_equal 'unknown', plugin.transform_site_url_hook('unknown', logger)
|
|
31
|
+
assert_equal 'http://bugzilla.foobar.com', plugin.transform_site_url_hook('shazam', logger)
|
|
32
|
+
|
|
33
|
+
Bicho::Plugins::User.config_path = nil
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
require File.join(File.dirname(__FILE__), 'helper')
|
|
2
|
+
|
|
3
|
+
#
|
|
4
|
+
# Test getting the version of the Bugzilla API
|
|
5
|
+
#
|
|
6
|
+
class Version_test < Test::Unit::TestCase
|
|
7
|
+
def test_version_gnome
|
|
8
|
+
Bicho.client = Bicho::Client.new('https://bugzilla.gnome.org')
|
|
9
|
+
|
|
10
|
+
ret = Bicho::client.version
|
|
11
|
+
assert ret =~ /3.4/ # https://bugzilla.gnome.org/ is at 3.4.13 as of Jan/2015
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def test_version_suse
|
|
15
|
+
Bicho.client = Bicho::Client.new('https://bugzilla.suse.com')
|
|
16
|
+
|
|
17
|
+
ret = Bicho::client.version
|
|
18
|
+
assert ret =~ /4.4/ #https://bugzilla.suse.com is at 4.4.6 as of Jan/2015
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
end
|
metadata
CHANGED
|
@@ -1,78 +1,69 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: bicho
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
5
|
-
prerelease:
|
|
4
|
+
version: 0.0.10
|
|
6
5
|
platform: ruby
|
|
7
6
|
authors:
|
|
8
7
|
- Duncan Mac-Vicar P.
|
|
9
8
|
autorequire:
|
|
10
9
|
bindir: bin
|
|
11
10
|
cert_chain: []
|
|
12
|
-
date:
|
|
11
|
+
date: 2015-05-20 00:00:00.000000000 Z
|
|
13
12
|
dependencies:
|
|
14
13
|
- !ruby/object:Gem::Dependency
|
|
15
14
|
name: inifile
|
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
|
17
|
-
none: false
|
|
18
16
|
requirements:
|
|
19
|
-
- - ~>
|
|
17
|
+
- - "~>"
|
|
20
18
|
- !ruby/object:Gem::Version
|
|
21
19
|
version: 0.4.1
|
|
22
20
|
type: :runtime
|
|
23
21
|
prerelease: false
|
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
25
|
-
none: false
|
|
26
23
|
requirements:
|
|
27
|
-
- - ~>
|
|
24
|
+
- - "~>"
|
|
28
25
|
- !ruby/object:Gem::Version
|
|
29
26
|
version: 0.4.1
|
|
30
27
|
- !ruby/object:Gem::Dependency
|
|
31
28
|
name: trollop
|
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
|
33
|
-
none: false
|
|
34
30
|
requirements:
|
|
35
|
-
- -
|
|
31
|
+
- - ">="
|
|
36
32
|
- !ruby/object:Gem::Version
|
|
37
33
|
version: '1.16'
|
|
38
34
|
type: :runtime
|
|
39
35
|
prerelease: false
|
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
|
41
|
-
none: false
|
|
42
37
|
requirements:
|
|
43
|
-
- -
|
|
38
|
+
- - ">="
|
|
44
39
|
- !ruby/object:Gem::Version
|
|
45
40
|
version: '1.16'
|
|
46
41
|
- !ruby/object:Gem::Dependency
|
|
47
42
|
name: highline
|
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
|
49
|
-
none: false
|
|
50
44
|
requirements:
|
|
51
|
-
- - ~>
|
|
45
|
+
- - "~>"
|
|
52
46
|
- !ruby/object:Gem::Version
|
|
53
47
|
version: 1.6.2
|
|
54
48
|
type: :runtime
|
|
55
49
|
prerelease: false
|
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
|
57
|
-
none: false
|
|
58
51
|
requirements:
|
|
59
|
-
- - ~>
|
|
52
|
+
- - "~>"
|
|
60
53
|
- !ruby/object:Gem::Version
|
|
61
54
|
version: 1.6.2
|
|
62
55
|
- !ruby/object:Gem::Dependency
|
|
63
56
|
name: nokogiri
|
|
64
57
|
requirement: !ruby/object:Gem::Requirement
|
|
65
|
-
none: false
|
|
66
58
|
requirements:
|
|
67
|
-
- -
|
|
59
|
+
- - ">="
|
|
68
60
|
- !ruby/object:Gem::Version
|
|
69
61
|
version: '0'
|
|
70
62
|
type: :runtime
|
|
71
63
|
prerelease: false
|
|
72
64
|
version_requirements: !ruby/object:Gem::Requirement
|
|
73
|
-
none: false
|
|
74
65
|
requirements:
|
|
75
|
-
- -
|
|
66
|
+
- - ">="
|
|
76
67
|
- !ruby/object:Gem::Version
|
|
77
68
|
version: '0'
|
|
78
69
|
description: Library to access bugzilla
|
|
@@ -83,7 +74,8 @@ executables:
|
|
|
83
74
|
extensions: []
|
|
84
75
|
extra_rdoc_files: []
|
|
85
76
|
files:
|
|
86
|
-
- .gitignore
|
|
77
|
+
- ".gitignore"
|
|
78
|
+
- ".rubocop.yml"
|
|
87
79
|
- Gemfile
|
|
88
80
|
- MIT-LICENSE
|
|
89
81
|
- README.rdoc
|
|
@@ -96,45 +88,52 @@ files:
|
|
|
96
88
|
- lib/bicho/cli/commands/history.rb
|
|
97
89
|
- lib/bicho/cli/commands/search.rb
|
|
98
90
|
- lib/bicho/cli/commands/show.rb
|
|
91
|
+
- lib/bicho/cli/commands/version.rb
|
|
99
92
|
- lib/bicho/client.rb
|
|
100
93
|
- lib/bicho/common_client.rb
|
|
101
94
|
- lib/bicho/ext/logger_colors.rb
|
|
102
95
|
- lib/bicho/history.rb
|
|
103
96
|
- lib/bicho/logging.rb
|
|
97
|
+
- lib/bicho/plugins/aliases.rb
|
|
104
98
|
- lib/bicho/plugins/novell.rb
|
|
99
|
+
- lib/bicho/plugins/user.rb
|
|
105
100
|
- lib/bicho/query.rb
|
|
106
101
|
- lib/bicho/version.rb
|
|
107
102
|
- test/helper.rb
|
|
108
103
|
- test/test_history.rb
|
|
109
104
|
- test/test_novell_plugin.rb
|
|
110
105
|
- test/test_query.rb
|
|
106
|
+
- test/test_user_plugin.rb
|
|
107
|
+
- test/test_version.rb
|
|
111
108
|
homepage: http://github.com/dmacvicar/bicho
|
|
112
|
-
licenses:
|
|
109
|
+
licenses:
|
|
110
|
+
- MIT
|
|
111
|
+
metadata: {}
|
|
113
112
|
post_install_message:
|
|
114
113
|
rdoc_options: []
|
|
115
114
|
require_paths:
|
|
116
115
|
- lib
|
|
117
116
|
required_ruby_version: !ruby/object:Gem::Requirement
|
|
118
|
-
none: false
|
|
119
117
|
requirements:
|
|
120
|
-
- -
|
|
118
|
+
- - ">="
|
|
121
119
|
- !ruby/object:Gem::Version
|
|
122
|
-
version:
|
|
120
|
+
version: 1.9.3
|
|
123
121
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
124
|
-
none: false
|
|
125
122
|
requirements:
|
|
126
|
-
- -
|
|
123
|
+
- - ">="
|
|
127
124
|
- !ruby/object:Gem::Version
|
|
128
125
|
version: '0'
|
|
129
126
|
requirements: []
|
|
130
127
|
rubyforge_project: bicho
|
|
131
|
-
rubygems_version:
|
|
128
|
+
rubygems_version: 2.4.5
|
|
132
129
|
signing_key:
|
|
133
|
-
specification_version:
|
|
130
|
+
specification_version: 4
|
|
134
131
|
summary: Library to access bugzilla
|
|
135
132
|
test_files:
|
|
136
133
|
- test/helper.rb
|
|
137
134
|
- test/test_history.rb
|
|
138
135
|
- test/test_novell_plugin.rb
|
|
139
136
|
- test/test_query.rb
|
|
137
|
+
- test/test_user_plugin.rb
|
|
138
|
+
- test/test_version.rb
|
|
140
139
|
has_rdoc:
|