ruby-bugzilla 0.3.3 → 0.4.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.
@@ -0,0 +1,141 @@
1
+ # bugzilla.rb
2
+ # Copyright (C) 2010-2012 Red Hat, Inc.
3
+ #
4
+ # Authors:
5
+ # Akira TAGOH <tagoh@redhat.com>
6
+ #
7
+ # This program is free software; you can redistribute it and/or modify
8
+ # it under the terms of the GNU General Public License as published by
9
+ # the Free Software Foundation; either version 2 of the License, or
10
+ # (at your option) any later version.
11
+ #
12
+ # This program is distributed in the hope that it will be useful,
13
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ # GNU General Public License for more details.
16
+ #
17
+ # You should have received a copy of the GNU General Public License
18
+ # along with this program; if not, write to the Free Software
19
+ # Foundation, Inc., 59 Temple Place - Suite 330,
20
+ # Boston, MA 02111-1307, USA.
21
+
22
+ require 'bugzilla/skeleton'
23
+
24
+ module Bugzilla
25
+
26
+ =begin rdoc
27
+
28
+ === Bugzilla::Bugzilla
29
+
30
+ Bugzilla::Bugzilla class is to access the
31
+ Bugzilla::WebService::Bugzilla API that provides functions
32
+ tell you about Bugzilla in general.
33
+
34
+ =end
35
+
36
+ class Bugzilla < Skeleton
37
+
38
+ =begin rdoc
39
+
40
+ ==== Bugzilla::Bugzilla#check_version(version_)
41
+
42
+ Returns Array contains the result of the version check and
43
+ Bugzilla version that is running on.
44
+
45
+ =end
46
+
47
+ def check_version(version_)
48
+ v = version
49
+ f = false
50
+ if v.kind_of?(Hash) && v.include?("version") &&
51
+ v['version'] >= "#{version_}" then
52
+ f = true
53
+ end
54
+
55
+ [f, v['version']]
56
+ end # def check_version
57
+
58
+ =begin rdoc
59
+
60
+ ==== Bugzilla::Bugzilla#requires_version(cmd, version_)
61
+
62
+ Raise an exception if the Bugzilla doesn't satisfy
63
+ the requirement of the _version_.
64
+
65
+ =end
66
+
67
+ def requires_version(cmd, version_)
68
+ v = check_version(version_)
69
+ raise NoMethodError, sprintf("%s is not supported in Bugzilla %s", cmd, v[1]) unless v[0]
70
+ end # def requires_version
71
+
72
+ =begin rdoc
73
+
74
+ ==== Bugzilla::Bugzilla#version
75
+
76
+ Raw Bugzilla API to obtain the Bugzilla version.
77
+
78
+ See http://www.bugzilla.org/docs/tip/en/html/api/Bugzilla/WebService/Bugzilla.html
79
+
80
+ =end
81
+
82
+ =begin rdoc
83
+
84
+ ==== Bugzilla::Bugzilla#extensions
85
+
86
+ Raw Bugzilla API to obtain the information about
87
+ the extensions that are currently installed and enabled in
88
+ the Bugzilla.
89
+
90
+ See http://www.bugzilla.org/docs/tip/en/html/api/Bugzilla/WebService/Bugzilla.html
91
+
92
+ =end
93
+
94
+ =begin rdoc
95
+
96
+ ==== Bugzilla::Bugzilla#timezone
97
+
98
+ Raw Bugzilla API to obtain the timezone that Bugzilla
99
+ expects dates and times in.
100
+
101
+ See http://www.bugzilla.org/docs/tip/en/html/api/Bugzilla/WebService/Bugzilla.html
102
+
103
+ =end
104
+
105
+ =begin rdoc
106
+
107
+ ==== Bugzilla::Bugzilla#time
108
+
109
+ Raw Bugzilla API to obtain the information about what time
110
+ the bugzilla server thinks it is, and what timezone it's
111
+ running on.
112
+
113
+ See http://www.bugzilla.org/docs/tip/en/html/api/Bugzilla/WebService/Bugzilla.html
114
+
115
+ =end
116
+
117
+ protected
118
+
119
+ def _version(cmd, *args)
120
+ @iface.call(cmd)
121
+ end # def _version
122
+
123
+ def _extensions(cmd, *args)
124
+ requires_version(cmd, 3.2)
125
+
126
+ @iface.call(cmd)
127
+ end # def _extensions
128
+
129
+ def _timezone(cmd, *args)
130
+ @iface.call(cmd)
131
+ end # def _timezone
132
+
133
+ def _time(cmd, *args)
134
+ requires_version(cmd, 3.4)
135
+
136
+ @iface.call(cmd)
137
+ end # def _time
138
+
139
+ end # class Bugzilla
140
+
141
+ end # module Bugzilla
@@ -0,0 +1,140 @@
1
+ # skeleton.rb
2
+ # Copyright (C) 2010-2012 Red Hat, Inc.
3
+ #
4
+ # Authors:
5
+ # Akira TAGOH <tagoh@redhat.com>
6
+ #
7
+ # This program is free software; you can redistribute it and/or modify
8
+ # it under the terms of the GNU General Public License as published by
9
+ # the Free Software Foundation; either version 2 of the License, or
10
+ # (at your option) any later version.
11
+ #
12
+ # This program is distributed in the hope that it will be useful,
13
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ # GNU General Public License for more details.
16
+ #
17
+ # You should have received a copy of the GNU General Public License
18
+ # along with this program; if not, write to the Free Software
19
+ # Foundation, Inc., 59 Temple Place - Suite 330,
20
+ # Boston, MA 02111-1307, USA.
21
+
22
+
23
+ module Bugzilla
24
+
25
+ =begin rdoc
26
+
27
+ === Bugzilla::Bugzilla
28
+
29
+ Bugzilla::Bugzilla class is to access the
30
+ Bugzilla::WebService::Bugzilla API that provides functions
31
+ tell you about Bugzilla in general.
32
+
33
+ =end
34
+
35
+ class Bugzilla < Skeleton
36
+
37
+ =begin rdoc
38
+
39
+ ==== Bugzilla::Bugzilla#check_version(version_)
40
+
41
+ Returns Array contains the result of the version check and
42
+ Bugzilla version that is running on.
43
+
44
+ =end
45
+
46
+ def check_version(version_)
47
+ v = version
48
+ f = false
49
+ if v.kind_of?(Hash) && v.include?("version") &&
50
+ v['version'] >= "#{version_}" then
51
+ f = true
52
+ end
53
+
54
+ [f, v['version']]
55
+ end # def check_version
56
+
57
+ =begin rdoc
58
+
59
+ ==== Bugzilla::Bugzilla#requires_version(cmd, version_)
60
+
61
+ Raise an exception if the Bugzilla doesn't satisfy
62
+ the requirement of the _version_.
63
+
64
+ =end
65
+
66
+ def requires_version(cmd, version_)
67
+ v = check_version(version_)
68
+ raise NoMethodError, sprintf("%s is not supported in Bugzilla %s", cmd, v[1]) unless v[0]
69
+ end # def requires_version
70
+
71
+ =begin rdoc
72
+
73
+ ==== Bugzilla::Bugzilla#version
74
+
75
+ Raw Bugzilla API to obtain the Bugzilla version.
76
+
77
+ See http://www.bugzilla.org/docs/tip/en/html/api/Bugzilla/WebService/Bugzilla.html
78
+
79
+ =end
80
+
81
+ =begin rdoc
82
+
83
+ ==== Bugzilla::Bugzilla#extensions
84
+
85
+ Raw Bugzilla API to obtain the information about
86
+ the extensions that are currently installed and enabled in
87
+ the Bugzilla.
88
+
89
+ See http://www.bugzilla.org/docs/tip/en/html/api/Bugzilla/WebService/Bugzilla.html
90
+
91
+ =end
92
+
93
+ =begin rdoc
94
+
95
+ ==== Bugzilla::Bugzilla#timezone
96
+
97
+ Raw Bugzilla API to obtain the timezone that Bugzilla
98
+ expects dates and times in.
99
+
100
+ See http://www.bugzilla.org/docs/tip/en/html/api/Bugzilla/WebService/Bugzilla.html
101
+
102
+ =end
103
+
104
+ =begin rdoc
105
+
106
+ ==== Bugzilla::Bugzilla#time
107
+
108
+ Raw Bugzilla API to obtain the information about what time
109
+ the bugzilla server thinks it is, and what timezone it's
110
+ running on.
111
+
112
+ See http://www.bugzilla.org/docs/tip/en/html/api/Bugzilla/WebService/Bugzilla.html
113
+
114
+ =end
115
+
116
+ protected
117
+
118
+ def _version(cmd, *args)
119
+ @iface.call(cmd)
120
+ end # def _version
121
+
122
+ def _extensions(cmd, *args)
123
+ requires_version(cmd, 3.2)
124
+
125
+ @iface.call(cmd)
126
+ end # def _extensions
127
+
128
+ def _timezone(cmd, *args)
129
+ @iface.call(cmd)
130
+ end # def _timezone
131
+
132
+ def _time(cmd, *args)
133
+ requires_version(cmd, 3.4)
134
+
135
+ @iface.call(cmd)
136
+ end # def _time
137
+
138
+ end # class Bugzilla
139
+
140
+ end # module Bugzilla
@@ -0,0 +1,82 @@
1
+ # plugin.rb
2
+ # Copyright (C) 2010-2012 Red Hat, Inc.
3
+ #
4
+ # Authors:
5
+ # Akira TAGOH <tagoh@redhat.com>
6
+ #
7
+ # This program is free software; you can redistribute it and/or modify
8
+ # it under the terms of the GNU General Public License as published by
9
+ # the Free Software Foundation; either version 2 of the License, or
10
+ # (at your option) any later version.
11
+ #
12
+ # This program is distributed in the hope that it will be useful,
13
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ # GNU General Public License for more details.
16
+ #
17
+ # You should have received a copy of the GNU General Public License
18
+ # along with this program; if not, write to the Free Software
19
+ # Foundation, Inc., 59 Temple Place - Suite 330,
20
+ # Boston, MA 02111-1307, USA.
21
+
22
+
23
+ module Bugzilla
24
+
25
+ =begin rdoc
26
+
27
+ === Bugzilla::Plugin
28
+
29
+ =end
30
+
31
+ module Plugin
32
+
33
+ =begin rdoc
34
+
35
+ ==== Bugzilla::Plugin::Template
36
+
37
+ =end
38
+
39
+ class Template
40
+ @@plugins = []
41
+
42
+ def initialize
43
+ @hostname = nil
44
+ end # def initialize
45
+
46
+ attr_reader :hostname
47
+
48
+ def Template.inherited(subclass)
49
+ @@plugins << subclass
50
+ end # def inherited
51
+
52
+ def run(hook, host, *args)
53
+ @@plugins.each do |k|
54
+ i = k.new
55
+ if i.hostname == host || host.nil? then
56
+ case hook
57
+ when :parser
58
+ i.parserhook(*args)
59
+ when :pre
60
+ i.prehook(*args)
61
+ when :post
62
+ i.posthook(*args)
63
+ else
64
+ end
65
+ end
66
+ end
67
+ end # def run
68
+
69
+ def parserhook(parser, argv, opts)
70
+ end # def parserhook
71
+
72
+ def prehook(cmd, opts)
73
+ end # def prehook
74
+
75
+ def posthook(cmd, opts)
76
+ end # def posthook
77
+
78
+ end # class Template
79
+
80
+ end # module Plugin
81
+
82
+ end # module Bugzilla
@@ -0,0 +1,82 @@
1
+ # plugin.rb
2
+ # Copyright (C) 2010-2012 Red Hat, Inc.
3
+ #
4
+ # Authors:
5
+ # Akira TAGOH <tagoh@redhat.com>
6
+ #
7
+ # This program is free software; you can redistribute it and/or modify
8
+ # it under the terms of the GNU General Public License as published by
9
+ # the Free Software Foundation; either version 2 of the License, or
10
+ # (at your option) any later version.
11
+ #
12
+ # This program is distributed in the hope that it will be useful,
13
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ # GNU General Public License for more details.
16
+ #
17
+ # You should have received a copy of the GNU General Public License
18
+ # along with this program; if not, write to the Free Software
19
+ # Foundation, Inc., 59 Temple Place - Suite 330,
20
+ # Boston, MA 02111-1307, USA.
21
+
22
+
23
+ module Bugzilla
24
+
25
+ =begin rdoc
26
+
27
+ === Bugzilla::Plugin
28
+
29
+ =end
30
+
31
+ module Plugin
32
+
33
+ =begin rdoc
34
+
35
+ ==== Bugzilla::Plugin::Template
36
+
37
+ =end
38
+
39
+ class Template
40
+ @@plugins = []
41
+
42
+ def initialize
43
+ @hostname = nil
44
+ end # def initialize
45
+
46
+ attr_reader :hostname
47
+
48
+ def Template.inherited(subclass)
49
+ @@plugins << subclass
50
+ end # def inherited
51
+
52
+ def run(hook, host, *args)
53
+ @@plugins.each do |k|
54
+ i = k.new
55
+ if i.hostname == host || host.nil? then
56
+ case hook
57
+ when :parser
58
+ i.parserhook(*args)
59
+ when :pre
60
+ i.prehook(*args)
61
+ when :post
62
+ i.posthook(*args)
63
+ else
64
+ end
65
+ end
66
+ end
67
+ end # def run
68
+
69
+ def parserhook(parser, argv, opts)
70
+ end # def parserhook
71
+
72
+ def prehook(cmd, opts)
73
+ end # def prehook
74
+
75
+ def posthook(cmd, opts)
76
+ end # def posthook
77
+
78
+ end # class Template
79
+
80
+ end # module Plugin
81
+
82
+ end # module Bugzilla