gems-status 0.49.0 → 0.50.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,272 +0,0 @@
1
- require 'rubygems'
2
- require 'gems-status/gems_status_metadata'
3
- require 'gems-status/utils'
4
-
5
- module GemsStatus
6
-
7
- class HTMLView
8
-
9
- def initialize()
10
- @patched = []
11
- @outdated = []
12
- @up_to_date = []
13
- end
14
-
15
-
16
- def print_description(ids)
17
- puts "
18
- <h1>gems-status</h1>
19
- <p>This is a comparison between different gem sources:</p>
20
- <ul>"
21
- ids.each { |id| puts "<li>#{id}</li>" }
22
- puts "</ul>
23
- </p>
24
- <p>The following table gives you an overview of:</p>
25
- <ul>
26
- <li>
27
- <span class='alert'>patched</span>: gems that have same version but different md5sums
28
- </li>
29
- <li>
30
- <span class='warning'>outdated</span>: gems that have different versions on the different sources
31
- </li>
32
- <li>
33
- <span class='info'>up to date</span>: gems that are up to date in all the sources</span>
34
- </li>
35
- </ul>
36
- <p>
37
- Note that gems can be patched and outdated at the same time.
38
- </p>
39
- <p>
40
- This information should help you decide which should be your next steps.
41
- </p>
42
- <ol>
43
- <li> Maintain those gems that have been patched but are not outdated
44
- </li>
45
- <li> Update those gems that have been patched and are outdated
46
- </li>
47
- <li> Update those gems that are outdated
48
- </li>
49
- </ol>
50
- <p>
51
- After the comparison there are some checks that have been performed, errors related and comments. Look those results as they imply there is some kind of work to do
52
- </p>
53
- <p> At the end there are the errors, checks and comments that do not apply to any of the gems. Look them carefully.
54
- </p>
55
- <p>
56
- There is a summary at the end.
57
- </p>
58
- You should run gems-status periodically until the lists of errors, patched, outdated and checks are gone.
59
- </p>
60
- "
61
- end
62
-
63
- def update_summary(gem_name, status)
64
- if status == "alert"
65
- @patched << gem_name
66
- elsif status == "warning"
67
- @outdated << gem_name
68
- else
69
- @up_to_date << gem_name
70
- end
71
- end
72
-
73
- def print_results(k, results, target, checker_results, comments)
74
- puts "<p>"
75
- puts "<table width='100%' class='table_results'>"
76
- version = results[target][k][0].version
77
- md5 = results[target][k][0].md5
78
- name_color = "info"
79
- html_string = ""
80
- results.each do |key, result|
81
- if !result[k]
82
- next
83
- end
84
- v_color = "info"
85
- md5_color = "info"
86
- result[k].each do |gem|
87
- html_string << "<tr>"
88
- html_string << "<td>"
89
- html_string << "#{gem.origin}"
90
- html_string << "</td>"
91
- html_string << "<td>"
92
- if gem.from_git? then
93
- md5_color = name_color = "alert"
94
- end
95
- if version != gem.version then
96
- v_color = "warning"
97
- name_color = "warning" if name_color != "alert"
98
- else
99
- if !gem.md5 || md5 != gem.md5 then
100
- md5_color = name_color = "alert"
101
- end
102
- end
103
- html_string << "<span class='#{v_color}'>"
104
- if !version then
105
- html_string << "error: look error log"
106
- end
107
- html_string << "#{gem.version}"
108
- html_string << "</span>"
109
- html_string << "</td>"
110
- html_string << "<td>"
111
- html_string << "<span class='#{md5_color}'>"
112
- if !gem.md5 || gem.md5.empty? then
113
- if gem.from_git? then
114
- html_string << "this comes from #{gem.gems_url}"
115
- else
116
- html_string << "error: look error log"
117
- end
118
- end
119
- html_string << "#{gem.md5}"
120
- html_string << "</span>"
121
- html_string << "</td>"
122
- html_string << "</tr>"
123
- version = gem.version
124
- md5 = gem.md5
125
- end
126
- end
127
- puts "<tr><td width='50%'><span class='#{name_color}'><a name=\"#{k}\" />#{k}</span></td><td width='10%'>version</td><td width='40%'>md5</td></tr>"
128
- puts html_string
129
- update_summary(k, name_color)
130
- puts "</table>"
131
- puts "</p>"
132
- if checker_results
133
- puts "<p> <span class='check'>checks:"
134
- puts "<br/>#{checker_results}</span>"
135
- puts "</p>"
136
- end
137
- if Utils::errors[k]
138
- puts "<p><span class='errors'>errors: "
139
- puts "<br/>#{Utils::errors[k]}</span>"
140
- Utils.errors.delete(k)
141
- puts "</p>"
142
- end
143
- if comments
144
- puts "<p><span class='comment'>comments: "
145
- puts "<br/>#{comments}</span>"
146
- puts "</p>"
147
- end
148
- end
149
-
150
- def print_head
151
- puts "<html>
152
- <head>
153
- <style>
154
- body
155
- {
156
- font-size: 90%;
157
- }
158
- h1
159
- {
160
- font-size: 110%;
161
- font-weight: bold;
162
- }
163
- h2
164
- {
165
- font-size: 100%;
166
- font-style: italic;
167
- font-weight: normal;
168
- }
169
- .gem_name
170
- {
171
- color: #000000;
172
- font-weight: bold;
173
- }
174
- .alert
175
- {
176
- color: #ff0000;
177
- }
178
- .warning
179
- {
180
- color: #ffaa00;
181
- }
182
- .info
183
- {
184
- color: #000000;
185
- }
186
- .info
187
- {
188
- color: #000000;
189
- }
190
- .footer
191
- {
192
- color: #aaaaaa;
193
- font-size: 60%;
194
- }
195
- .errors
196
- {
197
- color: #ff0000;
198
- font-size: 100%;
199
- font-style: italic;
200
- }
201
- .check
202
- {
203
- color: #a0a0a0;
204
- font-size: 100%;
205
- font-style: italic;
206
- }
207
- .comment
208
- {
209
- color: #a0a0a0;
210
- font-size: 100%;
211
- font-style: italic;
212
- }
213
- .table_results
214
- {
215
- font-size: 80%;
216
- }
217
- </style>
218
- </head>
219
- <body>"
220
- end
221
-
222
- def print_hash(desc, data, style, anchor = false)
223
- return if !data or data.length == 0
224
- puts "<p>"
225
- puts "<h2>#{desc}: #{data.length}</h2>"
226
- data.each do |k,v|
227
- if anchor
228
- puts "<a href=\"\##{k}\"><span class='#{style}'>#{k}</span></a>"
229
- else
230
- puts "<span class='#{style}'>#{k}</span>"
231
- end
232
- puts "<span class='#{style}'> #{v}</span><br/>"
233
-
234
- end
235
- puts "</p>"
236
- end
237
-
238
- def print_summary
239
- puts "<a name='summary'/><h1>Summary</h1>"
240
- puts "<p><h2>patched/errored #{@patched.length}</h2>"
241
- puts "<ul>"
242
- @patched.each do |p|
243
- puts "<li><a href=\"\##{p}\">#{p}</a>"
244
- end
245
- puts "</ul></p>"
246
- puts "<p><h2>outdated #{@outdated.length}</h2>"
247
- @outdated.each do |p|
248
- puts "<li><a href=\"\##{p}\">#{p}</a>"
249
- end
250
- puts "</ul></p>"
251
- puts "<p> <h2>up-to-date #{@up_to_date.length}</h2>"
252
- @up_to_date.each do |p|
253
- puts "<li><a href=\"\##{p}\">#{p}</a>"
254
- end
255
- puts "</ul></p>"
256
- end
257
-
258
- def print_tail(checker_results, comments)
259
- puts "<h1>Others</h1>"
260
- print_hash("comments", comments, "comment")
261
- print_hash("errors", Utils::errors, "errors")
262
- print_summary
263
- print_hash("checks", checker_results, "summary", true)
264
- puts "<a href='error.txt'>Check log</a>"
265
- date = Time.now.strftime('%a %b %d %H:%M:%S %Z %Y')
266
- puts "<p class='footer'>run by <a href=\"https://github.com/jordimassaguerpla/gems-status\">gems-status</a> - #{date} - version: #{GemsStatus::VERSION}</p>
267
- </body>
268
- </html>"
269
- end
270
-
271
- end
272
- end
@@ -1,112 +0,0 @@
1
- require "rubygems"
2
- require "xmlsimple"
3
- require "open-uri"
4
-
5
- require "gems-status/gem_simple"
6
- require "gems-status/gems_command"
7
- require "gems-status/utils"
8
-
9
- module GemsStatus
10
-
11
- class OBSGems < GemsCommand
12
- FILES_TO_IGNORE = /(\w(\.gem|\.spec|\.changes|\.rpmlintrc|-rpm-lintrc|-rpmlintrc))|README.SuSE/
13
- def initialize(conf)
14
- Utils::check_parameters('OBSGems', conf, ["id", "username", "password", "url", "obs_repo"])
15
- @result = {}
16
- @username = conf['username']
17
- @password = conf['password']
18
- @obs_url = conf['url']
19
- @repo = conf['obs_repo']
20
- @ident = conf['id']
21
-
22
- end
23
-
24
- def parse_link(linkinfo)
25
- if linkinfo.length > 1 then
26
- Utils::log_error("?", "There is more than one linkinfo element")
27
- return
28
- end
29
- if !linkinfo[0]["project"] then
30
- Utils::log_error("?", "Project element does not exists in linkinfo")
31
- return
32
- end
33
- if !linkinfo[0]["package"] then
34
- Utils::log_error("?", "Package element does not exists in linkinfo")
35
- return
36
- end
37
- repo = linkinfo[0]["project"]
38
- package = linkinfo[0]["package"]
39
- if linkinfo[0]["rev"] then
40
- rev = linkinfo[0]["rev"]
41
- Utils::log_debug "Revision in link: #{rev}."
42
- package = package + "?rev=" + rev
43
- end
44
- Utils::log_debug "follow link to project: #{repo} package: #{package}"
45
- parse_rpm_data(repo, package)
46
- end
47
-
48
- def get_data(package, url)
49
- data = ""
50
- begin
51
- data = open(url, :http_basic_authentication => [@username, @password]).read
52
- rescue
53
- Utils::log_error(package.sub("rubygem-",""), "There was a problem opening #{url} ")
54
- end
55
- return data
56
- end
57
-
58
- def parse_rpm_data(project, package)
59
- url = @obs_url + "/" + project
60
- rpm_url = url + "/" + package
61
- response = get_data(package, rpm_url)
62
- if response.empty? then
63
- return
64
- end
65
- data = XmlSimple.xml_in(response)
66
- if data["linkinfo"] then
67
- Utils::log_debug "#{data["name"]} is a link."
68
- if data["entry"].length != 1
69
- msg = " "
70
- data["entry"].each {|e| msg << " " << e["name"]}
71
- Utils::log_error(package.sub("rubygem-",""), "when parsing the link for #{project} : #{package}. There are more entries than expected. That may be a patched link and the result may not be correct:" + msg)
72
- end
73
- parse_link(data["linkinfo"])
74
- return
75
- end
76
- if !data["entry"] then
77
- Utils::log_error(package.sub("rubygem-",""), "something went wrong retrieving info from #{project} : #{package}")
78
- return
79
- end
80
- data["entry"].each do |entry|
81
- if !(entry["name"] =~ OBSGems::FILES_TO_IGNORE)
82
- Utils::log_error(package.sub("rubygem-",""), "when parsing data for #{project} : #{package}. Entry not expected. That may be a patched rpm and the result may not be correct. #{entry["name"]} ")
83
- end
84
- if entry["name"].end_with?(".gem") then
85
- name = gem_name(entry['name'])
86
- version = Gem::Version.new(gem_version(entry['name']))
87
- md5 = entry['md5']
88
- if !@result[name] || @result[name][0].version < version
89
- @result[name] = [GemSimple.new(name, version, md5, url)]
90
- end
91
- end
92
- end
93
- end
94
-
95
- def execute
96
- url = @obs_url + "/" + @repo
97
- response = get_data("?", url)
98
- if response.empty? then
99
- return
100
- end
101
- data = XmlSimple.xml_in(response)
102
- data["entry"].each do |entry|
103
- entry.each do |k,v|
104
- if k == "name" and v.start_with?("rubygem-") then
105
- parse_rpm_data(@repo, v)
106
- end
107
- end
108
- end
109
- end
110
-
111
- end
112
- end
@@ -1,51 +0,0 @@
1
- require "rubygems"
2
- require "xmlsimple"
3
- require "open-uri"
4
- require "zlib"
5
-
6
- require "gems-status/sources/ruby_gems_gems_gem_simple"
7
- require "gems-status/gems_command"
8
- require "gems-status/utils"
9
-
10
- module GemsStatus
11
-
12
- class RubyGemsGems < GemsCommand
13
-
14
- def initialize(conf)
15
- Utils::check_parameters('RubyGemsGems', conf, ["id", "url", "specs"])
16
- @url = conf['url']
17
- @specs = conf['specs']
18
- @result = {}
19
- @ident = conf['id']
20
-
21
- end
22
-
23
- def get_data
24
- specs_url = @url + "/" + @specs
25
- begin
26
- source = open(specs_url)
27
- gz = Zlib::GzipReader.new(source)
28
- return gz.read
29
- rescue
30
- Utils::log_error "?", "There was a problem opening #{specs_url} "
31
- end
32
- return ""
33
- end
34
-
35
-
36
- def execute
37
- response = get_data
38
- if response.empty? then
39
- return
40
- end
41
- data = Marshal.load(response)
42
- data.each do |line|
43
- name = line[0]
44
- version = Gem::Version.new(line[1])
45
- gems_url = "#{@url}/gems"
46
- @result[name] = [RubyGemsGems_GemSimple.new(name, version,'' , @url, gems_url)]
47
- end
48
- end
49
-
50
- end
51
- end
@@ -1,56 +0,0 @@
1
- require './test/test-helper.rb'
2
- $:.unshift File.join(File.dirname(__FILE__), "..", "lib")
3
- require 'rubygems'
4
- require 'test/unit'
5
- require 'gems-status'
6
-
7
- module GemsStatus
8
-
9
- class TestNotRailsChecker < Test::Unit::TestCase
10
- def test_gem_with_no_deps
11
- gem = GemSimple.new("name", Gem::Version.new("1.2.3"), nil, nil, nil, nil)
12
- check = NotRailsChecker.new nil
13
- result = check.check?(gem)
14
- assert(!result)
15
- end
16
- def test_gem_with_no_deps_2
17
- gem = GemSimple.new("name", Gem::Version.new("1.2.3"), nil, nil, nil, [])
18
- check = NotRailsChecker.new nil
19
- result = check.check?(gem)
20
- assert(result)
21
- end
22
- def test_gem_with_rail_dep
23
- deps = [
24
- Gem::Dependency.new("rails", Gem::Requirement.new("> 0.0.0")),
25
- Gem::Dependency.new("foo", Gem::Requirement.new("> 0.0.0"))
26
- ]
27
-
28
- gem = GemSimple.new("name", Gem::Version.new("1.2.3"), nil, nil, nil, deps)
29
- check = NotRailsChecker.new nil
30
- result = check.check?(gem)
31
- assert(!result)
32
- end
33
- def test_gem_with_no_rail_dep
34
- deps = [
35
- Gem::Dependency.new("norails", Gem::Requirement.new("> 0.0.0")),
36
- Gem::Dependency.new("foo", Gem::Requirement.new("> 0.0.0"))
37
- ]
38
-
39
- gem = GemSimple.new("name", Gem::Version.new("1.2.3"), nil, nil, nil, deps)
40
- check = NotRailsChecker.new nil
41
- result = check.check?(gem)
42
- assert(result)
43
- end
44
- def test_gem_with_railties_dep
45
- deps = [
46
- Gem::Dependency.new("railties", Gem::Requirement.new("> 0.0.0")),
47
- Gem::Dependency.new("foo", Gem::Requirement.new("> 0.0.0"))
48
- ]
49
-
50
- gem = GemSimple.new("name", Gem::Version.new("1.2.3"), nil, nil, nil, deps)
51
- check = NotRailsChecker.new nil
52
- result = check.check?(gem)
53
- assert(!result)
54
- end
55
- end
56
- end