yumrepo 0.2 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Changelog +10 -0
- data/Gemfile +2 -0
- data/Gemfile.lock +6 -0
- data/lib/yumrepo.rb +72 -25
- data/spec/yumrepo_spec.rb +9 -0
- data/yumrepo.gemspec +11 -4
- metadata +41 -18
data/Changelog
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
* Wed Jan 04 2012 - 0.2.1
|
2
|
+
- @mstump: fixing tempfile leak for long running processes, exposed repo
|
3
|
+
metadata (https://github.com/rubiojr/yumrepo/pull/4)
|
4
|
+
|
5
|
+
* Thu Nov 10 2011 - 0.2
|
6
|
+
- Beefier than ever thanks to @mstump
|
7
|
+
- Tests now cover most of the code
|
8
|
+
- yumrepo catching code bugfixes
|
9
|
+
- Improved ruby 1.9 compatibility
|
10
|
+
- New methods and classes added to cover missing functionality
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,11 +1,15 @@
|
|
1
1
|
GEM
|
2
2
|
remote: http://rubygems.org/
|
3
3
|
specs:
|
4
|
+
active_support (3.0.0)
|
5
|
+
activesupport (= 3.0.0)
|
6
|
+
activesupport (3.0.0)
|
4
7
|
diff-lcs (1.1.3)
|
5
8
|
fakeweb (1.3.0)
|
6
9
|
git (1.2.5)
|
7
10
|
guard (0.8.4)
|
8
11
|
thor (~> 0.14.6)
|
12
|
+
i18n (0.6.0)
|
9
13
|
jeweler (1.5.2)
|
10
14
|
bundler (~> 1.0.0)
|
11
15
|
git (>= 1.2.5)
|
@@ -32,9 +36,11 @@ PLATFORMS
|
|
32
36
|
ruby
|
33
37
|
|
34
38
|
DEPENDENCIES
|
39
|
+
active_support
|
35
40
|
bundler (~> 1.0.0)
|
36
41
|
fakeweb
|
37
42
|
guard
|
43
|
+
i18n
|
38
44
|
jeweler (~> 1.5.2)
|
39
45
|
nokogiri (~> 1.5.0)
|
40
46
|
rspec (~> 2.6)
|
data/lib/yumrepo.rb
CHANGED
@@ -9,10 +9,11 @@ require 'digest/md5'
|
|
9
9
|
require 'fileutils'
|
10
10
|
require 'logger'
|
11
11
|
require 'tempfile'
|
12
|
+
require 'active_support/core_ext'
|
12
13
|
|
13
14
|
module YumRepo
|
14
15
|
|
15
|
-
VERSION = '0.2'
|
16
|
+
VERSION = '0.2.1'
|
16
17
|
|
17
18
|
def self.bench(msg)
|
18
19
|
if defined? $yumrepo_perf_debug
|
@@ -117,17 +118,39 @@ module YumRepo
|
|
117
118
|
pl << File.join(@url, p['href'])
|
118
119
|
end
|
119
120
|
|
120
|
-
@primary_xml
|
121
|
+
if not @primary_xml or @primary_xml.closed?
|
122
|
+
@primary_xml = _open_file("primary.xml.gz", @url_digest, pl.first)
|
123
|
+
end
|
121
124
|
@primary_xml
|
122
125
|
end
|
123
126
|
|
127
|
+
def meta
|
128
|
+
def to_sym(h)
|
129
|
+
h.inject({}) { |result, (key, value)|
|
130
|
+
new_key = case key
|
131
|
+
when String then key.to_sym
|
132
|
+
else key
|
133
|
+
end
|
134
|
+
new_value = case value
|
135
|
+
when Hash then to_sym(value)
|
136
|
+
else value
|
137
|
+
end
|
138
|
+
result[new_key] = new_value
|
139
|
+
result
|
140
|
+
}
|
141
|
+
end
|
142
|
+
Hash[Hash.from_xml(@repomd.to_s)["repomd"]["data"].map {|h| [h["type"].to_sym, to_sym(h)] }]
|
143
|
+
end
|
144
|
+
|
124
145
|
def other
|
125
146
|
pl = []
|
126
147
|
@repomd.xpath("/xmlns:repomd/xmlns:data[@type=\"other\"]/xmlns:location").each do |p|
|
127
148
|
pl << File.join(@url, p['href'])
|
128
149
|
end
|
129
150
|
|
130
|
-
@other_xml
|
151
|
+
if not @other_xml or @other_xml.closed?
|
152
|
+
@other_xml = _open_file("other.xml.gz", @url_digest, pl.first)
|
153
|
+
end
|
131
154
|
@other_xml
|
132
155
|
end
|
133
156
|
|
@@ -141,8 +164,13 @@ module YumRepo
|
|
141
164
|
end
|
142
165
|
|
143
166
|
FileUtils.mkdir_p File.join(@settings.cache_path, cache_dir_name) if @settings.cache_enabled
|
144
|
-
|
145
|
-
|
167
|
+
if @settings.cache_enabled
|
168
|
+
f = File.open(cache_file_name, "w+")
|
169
|
+
else
|
170
|
+
f = Tempfile.new(filename)
|
171
|
+
f.unlink # see tempfile documentation
|
172
|
+
end
|
173
|
+
|
146
174
|
f.binmode
|
147
175
|
@settings.log.debug "Caching #{filename} for #{data_url} at #{f.path}"
|
148
176
|
f.puts open(data_url).read
|
@@ -156,22 +184,32 @@ module YumRepo
|
|
156
184
|
|
157
185
|
def initialize(url)
|
158
186
|
@url = url
|
159
|
-
@xml_file = Repomd.new(url).primary
|
160
187
|
@packages = []
|
188
|
+
xml_file = Repomd.new(url).primary
|
161
189
|
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
190
|
+
begin
|
191
|
+
buf = ''
|
192
|
+
YumRepo.bench("Zlib::GzipReader.read") do
|
193
|
+
buf = Zlib::GzipReader.new(xml_file).read
|
194
|
+
end
|
166
195
|
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
196
|
+
YumRepo.bench("Building Package Objects") do
|
197
|
+
d = Nokogiri::XML::Reader(buf)
|
198
|
+
d.each do |n|
|
199
|
+
if n.name == 'package' and not n.node_type == Nokogiri::XML::Reader::TYPE_END_ELEMENT
|
200
|
+
@packages << Package.new(n.outer_xml)
|
201
|
+
end
|
172
202
|
end
|
173
203
|
end
|
204
|
+
|
205
|
+
ensure
|
206
|
+
if xml_file.respond_to?(:close!)
|
207
|
+
xml_file.close!
|
208
|
+
else
|
209
|
+
xml_file.close
|
210
|
+
end
|
174
211
|
end
|
212
|
+
|
175
213
|
end
|
176
214
|
|
177
215
|
def each
|
@@ -258,21 +296,30 @@ module YumRepo
|
|
258
296
|
class PackageChangelogList
|
259
297
|
def initialize(url)
|
260
298
|
@url = url
|
261
|
-
@xml_file = Repomd.new(url).other
|
262
299
|
@changelogs = []
|
300
|
+
xml_file = Repomd.new(url).other
|
263
301
|
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
302
|
+
begin
|
303
|
+
buf = ''
|
304
|
+
YumRepo.bench("Zlib::GzipReader.read") do
|
305
|
+
buf = Zlib::GzipReader.new(xml_file).read
|
306
|
+
end
|
268
307
|
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
308
|
+
YumRepo.bench("Building PackageChangelog Objects") do
|
309
|
+
d = Nokogiri::XML::Reader(buf)
|
310
|
+
d.each do |n|
|
311
|
+
if n.name == 'package' and not n.node_type == Nokogiri::XML::Reader::TYPE_END_ELEMENT
|
312
|
+
@changelogs << PackageChangelog.new(n.outer_xml)
|
313
|
+
end
|
274
314
|
end
|
275
315
|
end
|
316
|
+
|
317
|
+
ensure
|
318
|
+
if xml_file.respond_to?(:close!)
|
319
|
+
xml_file.close!
|
320
|
+
else
|
321
|
+
xml_file.close
|
322
|
+
end
|
276
323
|
end
|
277
324
|
end
|
278
325
|
|
data/spec/yumrepo_spec.rb
CHANGED
@@ -10,6 +10,15 @@ describe YumRepo do
|
|
10
10
|
YumRepo::Settings.instance.log_level = :error
|
11
11
|
YumRepo::Settings.instance.cache_enabled = false
|
12
12
|
|
13
|
+
|
14
|
+
describe "meta" do
|
15
|
+
it "make sure we get a hash whose keys are symbols" do
|
16
|
+
repo = YumRepo::Repomd.new "http://centos.mirror.freedomvoice.com/6.0/os/SRPMS"
|
17
|
+
repo.meta[:primary].should_not == nil
|
18
|
+
repo.meta[:primary][:checksum].should == "7ae73bdcb5961b03a0ca22419bd8da19ddc8c241"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
13
22
|
describe "package list" do
|
14
23
|
it "for test_data should have 5 entries" do
|
15
24
|
pl = YumRepo::PackageList.new "http://centos.mirror.freedomvoice.com/6.0/os/SRPMS"
|
data/yumrepo.gemspec
CHANGED
@@ -5,25 +5,26 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "yumrepo"
|
8
|
-
s.version = "0.2"
|
8
|
+
s.version = "0.2.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Sergio Rubio"]
|
12
|
-
s.date = "
|
12
|
+
s.date = "2012-01-04"
|
13
13
|
s.description = "YUM Repository Metadata handling library"
|
14
14
|
s.email = "rubiojr@frameos.org"
|
15
15
|
s.extra_rdoc_files = [
|
16
16
|
"LICENSE.txt",
|
17
|
-
"README.
|
17
|
+
"README.md"
|
18
18
|
]
|
19
19
|
s.files = [
|
20
20
|
".document",
|
21
21
|
".rspec",
|
22
|
+
"Changelog",
|
22
23
|
"Gemfile",
|
23
24
|
"Gemfile.lock",
|
24
25
|
"Guardfile",
|
25
26
|
"LICENSE.txt",
|
26
|
-
"README.
|
27
|
+
"README.md",
|
27
28
|
"Rakefile",
|
28
29
|
"examples/basic.rb",
|
29
30
|
"lib/yumrepo.rb",
|
@@ -47,6 +48,8 @@ Gem::Specification.new do |s|
|
|
47
48
|
s.add_development_dependency(%q<nokogiri>, ["~> 1.5.0"])
|
48
49
|
s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
|
49
50
|
s.add_development_dependency(%q<jeweler>, ["~> 1.5.2"])
|
51
|
+
s.add_development_dependency(%q<i18n>, [">= 0"])
|
52
|
+
s.add_development_dependency(%q<active_support>, [">= 0"])
|
50
53
|
s.add_development_dependency(%q<guard>, [">= 0"])
|
51
54
|
s.add_runtime_dependency(%q<nokogiri>, [">= 0"])
|
52
55
|
s.add_development_dependency(%q<rspec>, [">= 0"])
|
@@ -56,6 +59,8 @@ Gem::Specification.new do |s|
|
|
56
59
|
s.add_dependency(%q<nokogiri>, ["~> 1.5.0"])
|
57
60
|
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
58
61
|
s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
|
62
|
+
s.add_dependency(%q<i18n>, [">= 0"])
|
63
|
+
s.add_dependency(%q<active_support>, [">= 0"])
|
59
64
|
s.add_dependency(%q<guard>, [">= 0"])
|
60
65
|
s.add_dependency(%q<nokogiri>, [">= 0"])
|
61
66
|
s.add_dependency(%q<rspec>, [">= 0"])
|
@@ -66,6 +71,8 @@ Gem::Specification.new do |s|
|
|
66
71
|
s.add_dependency(%q<nokogiri>, ["~> 1.5.0"])
|
67
72
|
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
68
73
|
s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
|
74
|
+
s.add_dependency(%q<i18n>, [">= 0"])
|
75
|
+
s.add_dependency(%q<active_support>, [">= 0"])
|
69
76
|
s.add_dependency(%q<guard>, [">= 0"])
|
70
77
|
s.add_dependency(%q<nokogiri>, [">= 0"])
|
71
78
|
s.add_dependency(%q<rspec>, [">= 0"])
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yumrepo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 0.2.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2012-01-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: nokogiri
|
16
|
-
requirement: &
|
16
|
+
requirement: &23700700 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 1.5.0
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *23700700
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: bundler
|
27
|
-
requirement: &
|
27
|
+
requirement: &23698180 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 1.0.0
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *23698180
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: jeweler
|
38
|
-
requirement: &
|
38
|
+
requirement: &23696620 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,10 +43,32 @@ dependencies:
|
|
43
43
|
version: 1.5.2
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *23696620
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: i18n
|
49
|
+
requirement: &23693060 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
type: :development
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *23693060
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: active_support
|
60
|
+
requirement: &23692100 !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ! '>='
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '0'
|
66
|
+
type: :development
|
67
|
+
prerelease: false
|
68
|
+
version_requirements: *23692100
|
47
69
|
- !ruby/object:Gem::Dependency
|
48
70
|
name: guard
|
49
|
-
requirement: &
|
71
|
+
requirement: &23691400 !ruby/object:Gem::Requirement
|
50
72
|
none: false
|
51
73
|
requirements:
|
52
74
|
- - ! '>='
|
@@ -54,10 +76,10 @@ dependencies:
|
|
54
76
|
version: '0'
|
55
77
|
type: :development
|
56
78
|
prerelease: false
|
57
|
-
version_requirements: *
|
79
|
+
version_requirements: *23691400
|
58
80
|
- !ruby/object:Gem::Dependency
|
59
81
|
name: nokogiri
|
60
|
-
requirement: &
|
82
|
+
requirement: &23690340 !ruby/object:Gem::Requirement
|
61
83
|
none: false
|
62
84
|
requirements:
|
63
85
|
- - ! '>='
|
@@ -65,10 +87,10 @@ dependencies:
|
|
65
87
|
version: '0'
|
66
88
|
type: :runtime
|
67
89
|
prerelease: false
|
68
|
-
version_requirements: *
|
90
|
+
version_requirements: *23690340
|
69
91
|
- !ruby/object:Gem::Dependency
|
70
92
|
name: rspec
|
71
|
-
requirement: &
|
93
|
+
requirement: &23689520 !ruby/object:Gem::Requirement
|
72
94
|
none: false
|
73
95
|
requirements:
|
74
96
|
- - ! '>='
|
@@ -76,10 +98,10 @@ dependencies:
|
|
76
98
|
version: '0'
|
77
99
|
type: :development
|
78
100
|
prerelease: false
|
79
|
-
version_requirements: *
|
101
|
+
version_requirements: *23689520
|
80
102
|
- !ruby/object:Gem::Dependency
|
81
103
|
name: simplecov
|
82
|
-
requirement: &
|
104
|
+
requirement: &23688660 !ruby/object:Gem::Requirement
|
83
105
|
none: false
|
84
106
|
requirements:
|
85
107
|
- - ! '>='
|
@@ -87,10 +109,10 @@ dependencies:
|
|
87
109
|
version: '0'
|
88
110
|
type: :development
|
89
111
|
prerelease: false
|
90
|
-
version_requirements: *
|
112
|
+
version_requirements: *23688660
|
91
113
|
- !ruby/object:Gem::Dependency
|
92
114
|
name: fakeweb
|
93
|
-
requirement: &
|
115
|
+
requirement: &23688000 !ruby/object:Gem::Requirement
|
94
116
|
none: false
|
95
117
|
requirements:
|
96
118
|
- - ! '>='
|
@@ -98,7 +120,7 @@ dependencies:
|
|
98
120
|
version: '0'
|
99
121
|
type: :development
|
100
122
|
prerelease: false
|
101
|
-
version_requirements: *
|
123
|
+
version_requirements: *23688000
|
102
124
|
description: YUM Repository Metadata handling library
|
103
125
|
email: rubiojr@frameos.org
|
104
126
|
executables: []
|
@@ -109,6 +131,7 @@ extra_rdoc_files:
|
|
109
131
|
files:
|
110
132
|
- .document
|
111
133
|
- .rspec
|
134
|
+
- Changelog
|
112
135
|
- Gemfile
|
113
136
|
- Gemfile.lock
|
114
137
|
- Guardfile
|