pkgwat 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +3 -3
- data/lib/pkgwat.rb +16 -19
- data/lib/pkgwat/tasks.rb +18 -1
- data/lib/pkgwat/version.rb +1 -1
- data/test/fixtures/vcr/pkgwat_check_gem.yml +36 -38
- data/test/pkgwat_test.rb +10 -11
- data/test/test_helper.rb +1 -0
- metadata +1 -1
data/README.md
CHANGED
@@ -29,7 +29,7 @@ Inside your code, simply require rubygems and pkgwat. Then you use it like so:
|
|
29
29
|
Pkgwat.get_versions("rails")
|
30
30
|
|
31
31
|
# this will return true or false if the package exists
|
32
|
-
Pkgwat.check_gem("pry", "0.9.10", [
|
32
|
+
Pkgwat.check_gem("pry", "0.9.10", ["Fedora EPEL 6", "Fedora 19", "Rawhide"])
|
33
33
|
```
|
34
34
|
|
35
35
|
### Rake Tasks
|
@@ -64,8 +64,8 @@ Then just fire up irb:
|
|
64
64
|
|
65
65
|
```
|
66
66
|
irb -Ilib -rpkgwat
|
67
|
-
>> Pkgwat
|
68
|
-
=> "
|
67
|
+
>> Pkgwat.get_versions("runcible")
|
68
|
+
=> [{"release"=>"Rawhide", ...
|
69
69
|
```
|
70
70
|
|
71
71
|
### Testing
|
data/lib/pkgwat.rb
CHANGED
@@ -6,12 +6,6 @@ require 'sanitize'
|
|
6
6
|
module Pkgwat
|
7
7
|
require 'pkgwat/railtie' if defined?(Rails)
|
8
8
|
|
9
|
-
F17 = "Fedora 17"
|
10
|
-
F16 = "Fedora 16"
|
11
|
-
F18 = "Fedora 18"
|
12
|
-
EPEL6 = "Fedora EPEL 6"
|
13
|
-
EPEL5 = "Fedora EPEL 5"
|
14
|
-
DEFAULT_DISTROS = [F17, F16, EPEL6]
|
15
9
|
PACKAGE_NAME = "rubygem-:gem"
|
16
10
|
PACKAGES_URL = "https://apps.fedoraproject.org/packages/fcomm_connector/bodhi/query/query_active_releases"
|
17
11
|
PACKAGES_URL_LIST = "https://apps.fedoraproject.org/packages/fcomm_connector/xapian/query/search_packages"
|
@@ -20,31 +14,34 @@ module Pkgwat
|
|
20
14
|
CHANGELOG_URL = "https://apps.fedoraproject.org/packages/fcomm_connector/koji/query/query_changelogs"
|
21
15
|
CONTENT_URL = "https://apps.fedoraproject.org/packages/fcomm_connector/yum/get_file_tree"
|
22
16
|
UPDATES_URL = "https://apps.fedoraproject.org/packages/fcomm_connector/bodhi/query/query_updates"
|
23
|
-
KOJI_BUILD_STATES = ["all" => "", "
|
17
|
+
KOJI_BUILD_STATES = ["all" => "", "f19" =>"19", "f18" => "18", "f20" => "20", "e16" => "16", "e15" => "15"]
|
24
18
|
BUGZILLA_RELEASEA = ["all" => "", "building" =>"0", "success" => "1", "failed" => "2", "cancelled" => "3", "deleted" => "4"]
|
25
|
-
BODHI_REALEASE = ["all", "
|
19
|
+
BODHI_REALEASE = ["all", "f19", "f18", "f20", "e16", "e15"]
|
26
20
|
BODHI_ARCH = ["x86_64", "i686"]
|
27
21
|
|
28
22
|
class << self
|
29
23
|
attr_accessor :debug
|
30
24
|
end
|
31
25
|
|
32
|
-
def self.check_gem(name, version, distros
|
33
|
-
puts "Checking #{name} #{version}...\n" if self.debug
|
26
|
+
def self.check_gem(name, version, distros, throw_ex = false)
|
34
27
|
versions = get_versions(name)
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
28
|
+
distros = Array(distros) # convert distros to an array if not already
|
29
|
+
|
30
|
+
matches = distros.each_with_object([]) do |distro, results|
|
31
|
+
distro_match = versions.detect { |v| v["release"] == distro }
|
32
|
+
if distro_match
|
33
|
+
distro_version = distro_match["stable_version"][/\A(\S+)-.*\z/, 1] # get the actual gem version
|
34
|
+
match = compare_versions(version, distro_version)
|
35
|
+
results << distro_match["release"] if match
|
36
|
+
end
|
40
37
|
end
|
41
|
-
puts "#{name} is available in the following distros: #{matches.join(",")}" if self.debug
|
42
38
|
|
43
|
-
matches.any?
|
39
|
+
matches.any? ? matches : false
|
44
40
|
end
|
45
41
|
|
46
|
-
def self.compare_versions(
|
47
|
-
|
42
|
+
def self.compare_versions(version1, version2)
|
43
|
+
return false if version1.nil? || version1.to_s.length < 1 || version2.nil? || version2.to_s.length < 1
|
44
|
+
Gem::Version.new(version1) == Gem::Version.new(version2)
|
48
45
|
end
|
49
46
|
|
50
47
|
def self.get_versions(gem_name)
|
data/lib/pkgwat/tasks.rb
CHANGED
@@ -1,12 +1,29 @@
|
|
1
1
|
require 'rake'
|
2
2
|
require 'pkgwat'
|
3
3
|
|
4
|
+
DISTRO_ERROR_MESSAGE = <<-EOS
|
5
|
+
ERROR: Distros not supplied. Please call this task with distros (e.g. rake pkgwat:check DISTROS="Fedora 19, Fedora EPEL 6, Rawhide")
|
6
|
+
EOS
|
7
|
+
|
8
|
+
def gem_output(gem)
|
9
|
+
"#{gem.name} #{gem.version}"
|
10
|
+
end
|
11
|
+
|
4
12
|
namespace :pkgwat do
|
5
13
|
desc "Check the Gemfile.lock for packages"
|
6
14
|
task :check do
|
15
|
+
distros = ENV['DISTROS']
|
16
|
+
raise DISTRO_ERROR_MESSAGE if distros.nil? || distros.length < 1
|
17
|
+
distros = distros.split(",")
|
18
|
+
|
7
19
|
lockfile = Bundler::LockfileParser.new(Bundler.read_file("Gemfile.lock"))
|
8
20
|
lockfile.specs.each do |gem|
|
9
|
-
|
21
|
+
puts "Checking gem (#{gem_output(gem)})"
|
22
|
+
if rel = Pkgwat.check_gem(gem.name, gem.version, distros)
|
23
|
+
puts " OK: #{gem_output(gem)} available in #{rel.join(", ")}"
|
24
|
+
else
|
25
|
+
puts " FAIL: #{gem_output(gem)} not in #{distros.join(", ")}"
|
26
|
+
end
|
10
27
|
end
|
11
28
|
end
|
12
29
|
end
|
data/lib/pkgwat/version.rb
CHANGED
@@ -17,36 +17,36 @@ http_interactions:
|
|
17
17
|
message: OK
|
18
18
|
headers:
|
19
19
|
Date:
|
20
|
-
-
|
20
|
+
- Sat, 27 Jul 2013 16:16:41 GMT
|
21
21
|
Server:
|
22
22
|
- Apache/2.2.15 (Red Hat)
|
23
23
|
Content-Length:
|
24
|
-
- '
|
24
|
+
- '561'
|
25
25
|
Apptime:
|
26
|
-
- D=
|
26
|
+
- D=4908
|
27
27
|
Appserver:
|
28
|
-
-
|
28
|
+
- packages01.phx2.fedoraproject.org
|
29
29
|
Vary:
|
30
30
|
- Accept-Encoding
|
31
31
|
Content-Type:
|
32
32
|
- text/html; charset=UTF-8
|
33
33
|
Proxytime:
|
34
|
-
- D=
|
34
|
+
- D=146264
|
35
35
|
Proxyserver:
|
36
|
-
-
|
36
|
+
- proxy04.fedoraproject.org
|
37
37
|
body:
|
38
38
|
encoding: US-ASCII
|
39
|
-
string: ! '{"
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
6","testing_version":"None"
|
44
|
-
EPEL 5","testing_version":"None"}],"rows_per_page":10,"visible_rows":6}'
|
39
|
+
string: ! '{"rows":[{"release":"Rawhide","testing_version":"None","stable_version":"3.2.13-1.fc20"},{"release":"Fedora
|
40
|
+
19","testing_version":"None","stable_version":"3.2.13-1.fc19"},{"release":"Fedora
|
41
|
+
18","testing_version":"None","stable_version":"3.2.8-1.fc18"},{"release":"Fedora
|
42
|
+
17","testing_version":"None","stable_version":"3.0.11-1.fc17"},{"release":"Fedora
|
43
|
+
EPEL 6","testing_version":"None","stable_version":"None"},{"release":"Fedora
|
44
|
+
EPEL 5","testing_version":"None","stable_version":"2.1.1-2.el5"}],"rows_per_page":10,"start_row":0,"visible_rows":6,"total_rows":6}'
|
45
45
|
http_version:
|
46
|
-
recorded_at:
|
46
|
+
recorded_at: Sat, 27 Jul 2013 16:16:42 GMT
|
47
47
|
- request:
|
48
48
|
method: get
|
49
|
-
uri: https://apps.fedoraproject.org/packages/fcomm_connector/bodhi/query/query_active_releases/%7B%22filters%22:%7B%22package%22:%22rubygem-
|
49
|
+
uri: https://apps.fedoraproject.org/packages/fcomm_connector/bodhi/query/query_active_releases/%7B%22filters%22:%7B%22package%22:%22rubygem-this-gem-doesnt-exist%22%7D%7D
|
50
50
|
body:
|
51
51
|
encoding: US-ASCII
|
52
52
|
string: ''
|
@@ -61,13 +61,13 @@ http_interactions:
|
|
61
61
|
message: OK
|
62
62
|
headers:
|
63
63
|
Date:
|
64
|
-
-
|
64
|
+
- Sat, 27 Jul 2013 16:16:41 GMT
|
65
65
|
Server:
|
66
66
|
- Apache/2.2.15 (Red Hat)
|
67
67
|
Content-Length:
|
68
|
-
- '
|
68
|
+
- '519'
|
69
69
|
Apptime:
|
70
|
-
- D=
|
70
|
+
- D=3366
|
71
71
|
Appserver:
|
72
72
|
- packages02.phx2.fedoraproject.org
|
73
73
|
Vary:
|
@@ -75,23 +75,21 @@ http_interactions:
|
|
75
75
|
Content-Type:
|
76
76
|
- text/html; charset=UTF-8
|
77
77
|
Proxytime:
|
78
|
-
- D=
|
78
|
+
- D=144030
|
79
79
|
Proxyserver:
|
80
80
|
- proxy04.fedoraproject.org
|
81
81
|
body:
|
82
82
|
encoding: US-ASCII
|
83
|
-
string: ! '{"
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
6"},{"stable_version":"2.1.1-2.el5","testing_version":"None","release":"Fedora
|
89
|
-
EPEL 5"}],"rows_per_page":10}'
|
83
|
+
string: ! '{"rows_per_page":10,"total_rows":6,"start_row":0,"rows":[{"release":"Rawhide","testing_version":"None","stable_version":"None"},{"release":"Fedora
|
84
|
+
19","testing_version":"None","stable_version":"None"},{"release":"Fedora 18","testing_version":"None","stable_version":"None"},{"release":"Fedora
|
85
|
+
17","testing_version":"None","stable_version":"None"},{"release":"Fedora EPEL
|
86
|
+
6","testing_version":"None","stable_version":"None"},{"release":"Fedora EPEL
|
87
|
+
5","testing_version":"None","stable_version":"None"}],"visible_rows":6}'
|
90
88
|
http_version:
|
91
|
-
recorded_at:
|
89
|
+
recorded_at: Sat, 27 Jul 2013 16:16:42 GMT
|
92
90
|
- request:
|
93
91
|
method: get
|
94
|
-
uri: https://apps.fedoraproject.org/packages/fcomm_connector/bodhi/query/query_active_releases/%7B%22filters%22:%7B%22package%22:%22rubygem-
|
92
|
+
uri: https://apps.fedoraproject.org/packages/fcomm_connector/bodhi/query/query_active_releases/%7B%22filters%22:%7B%22package%22:%22rubygem-rails%22%7D%7D
|
95
93
|
body:
|
96
94
|
encoding: US-ASCII
|
97
95
|
string: ''
|
@@ -106,13 +104,13 @@ http_interactions:
|
|
106
104
|
message: OK
|
107
105
|
headers:
|
108
106
|
Date:
|
109
|
-
-
|
107
|
+
- Sat, 27 Jul 2013 16:16:42 GMT
|
110
108
|
Server:
|
111
109
|
- Apache/2.2.15 (Red Hat)
|
112
110
|
Content-Length:
|
113
|
-
- '
|
111
|
+
- '561'
|
114
112
|
Apptime:
|
115
|
-
- D=
|
113
|
+
- D=7796
|
116
114
|
Appserver:
|
117
115
|
- packages01.phx2.fedoraproject.org
|
118
116
|
Vary:
|
@@ -120,17 +118,17 @@ http_interactions:
|
|
120
118
|
Content-Type:
|
121
119
|
- text/html; charset=UTF-8
|
122
120
|
Proxytime:
|
123
|
-
- D=
|
121
|
+
- D=148018
|
124
122
|
Proxyserver:
|
125
123
|
- proxy04.fedoraproject.org
|
126
124
|
body:
|
127
125
|
encoding: US-ASCII
|
128
|
-
string: ! '{"
|
129
|
-
|
130
|
-
18"
|
131
|
-
|
132
|
-
6"
|
133
|
-
5"}]}'
|
126
|
+
string: ! '{"rows":[{"release":"Rawhide","testing_version":"None","stable_version":"3.2.13-1.fc20"},{"release":"Fedora
|
127
|
+
19","testing_version":"None","stable_version":"3.2.13-1.fc19"},{"release":"Fedora
|
128
|
+
18","testing_version":"None","stable_version":"3.2.8-1.fc18"},{"release":"Fedora
|
129
|
+
17","testing_version":"None","stable_version":"3.0.11-1.fc17"},{"release":"Fedora
|
130
|
+
EPEL 6","testing_version":"None","stable_version":"None"},{"release":"Fedora
|
131
|
+
EPEL 5","testing_version":"None","stable_version":"2.1.1-2.el5"}],"start_row":0,"rows_per_page":10,"visible_rows":6,"total_rows":6}'
|
134
132
|
http_version:
|
135
|
-
recorded_at:
|
133
|
+
recorded_at: Sat, 27 Jul 2013 16:16:42 GMT
|
136
134
|
recorded_with: VCR 2.4.0
|
data/test/pkgwat_test.rb
CHANGED
@@ -2,10 +2,6 @@ require 'test_helper'
|
|
2
2
|
|
3
3
|
describe "Pkgwat" do
|
4
4
|
|
5
|
-
it "has a Fedora 17 constant" do
|
6
|
-
Pkgwat::F17.must_equal "Fedora 17"
|
7
|
-
end
|
8
|
-
|
9
5
|
describe "#check_gem" do
|
10
6
|
before do
|
11
7
|
VCR.insert_cassette('pkgwat_check_gem')
|
@@ -16,21 +12,24 @@ describe "Pkgwat" do
|
|
16
12
|
end
|
17
13
|
|
18
14
|
it "returns false for a non-existing gem" do
|
19
|
-
Pkgwat.check_gem("this-gem-doesnt-exist", "0.0.1").must_equal false
|
15
|
+
Pkgwat.check_gem("this-gem-doesnt-exist", "0.0.1", ["Rawhide"]).must_equal false
|
20
16
|
end
|
21
17
|
|
22
18
|
it "returns true for existing gem" do
|
23
|
-
Pkgwat.check_gem("rails", "3.2.
|
19
|
+
(!!Pkgwat.check_gem("rails", "3.2.13", "Fedora 19")).must_equal true
|
24
20
|
end
|
25
21
|
|
26
22
|
it "returns false for non-existing version" do
|
27
|
-
Pkgwat.check_gem("rails", "3.
|
28
|
-
Pkgwat.check_gem("rails", "3.
|
23
|
+
Pkgwat.check_gem("rails", "3.1.1", ["Rawhide"]).must_equal false
|
24
|
+
Pkgwat.check_gem("rails", "3.0.7", "Fedora 16").must_equal false
|
25
|
+
end
|
26
|
+
|
27
|
+
it "returns distros that have the gem" do
|
28
|
+
Pkgwat.check_gem("rails", "3.2.8", ["Fedora 18", "Rawhide"]).must_equal ["Fedora 18"]
|
29
29
|
end
|
30
30
|
|
31
|
-
it "returns false
|
32
|
-
|
33
|
-
Pkgwat.check_gem("rails", "3.2.8", [Pkgwat::F17, Pkgwat::F18]).must_equal false
|
31
|
+
it "returns false if the distro doesn't exist" do
|
32
|
+
Pkgwat.check_gem("rails", "3.2.8", ["Ubuntu"]).must_equal false
|
34
33
|
end
|
35
34
|
end
|
36
35
|
end
|
data/test/test_helper.rb
CHANGED