pkgwat 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/pkgwat.rb +70 -0
- data/lib/pkgwat/version.rb +1 -1
- data/pkgwat.gemspec +1 -0
- metadata +20 -4
data/lib/pkgwat.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require "pkgwat/version"
|
2
2
|
require 'net/https'
|
3
3
|
require 'json'
|
4
|
+
require 'sanitize'
|
4
5
|
|
5
6
|
module Pkgwat
|
6
7
|
require 'pkgwat/railtie' if defined?(Rails)
|
@@ -13,6 +14,11 @@ module Pkgwat
|
|
13
14
|
DEFAULT_DISTROS = [F17, F16, EPEL6]
|
14
15
|
PACKAGE_NAME = "rubygem-:gem"
|
15
16
|
PACKAGES_URL = "https://apps.fedoraproject.org/packages/fcomm_connector/bodhi/query/query_active_releases"
|
17
|
+
PACKAGES_URL_LIST = "https://apps.fedoraproject.org/packages/fcomm_connector/xapian/query/search_packages"
|
18
|
+
BUGS_URL = "https://apps.fedoraproject.org/packages/fcomm_connector/bugzilla/query/query_bugs"
|
19
|
+
BUILDS_URL = "https://apps.fedoraproject.org/packages/fcomm_connector/koji/query/query_builds"
|
20
|
+
KOJI_BUILD_STATES = ["all" => "", "f17" =>"17", "f16" => "16", "f15" => "15", "e16" => "16", "e15" => "15"]
|
21
|
+
BUGZILLA_RELEASEA = ["all" => "", "building" =>"0", "success" => "1", "failed" => "2", "cancelled" => "3", "deleted" => "4"]
|
16
22
|
|
17
23
|
def self.check_gem(name, version, distros = DEFAULT_DISTROS, throw_ex = false)
|
18
24
|
puts "Checking #{name} #{version}...\n"
|
@@ -41,6 +47,54 @@ module Pkgwat
|
|
41
47
|
PACKAGE_NAME.gsub(":gem", gem)
|
42
48
|
end
|
43
49
|
|
50
|
+
# this function queries and returns the specified number of packages starting
|
51
|
+
# at the specified row
|
52
|
+
def self.get_packages(pattern, start=0, num=nil)
|
53
|
+
num ||= total_rows(pattern, "packages", PACKAGES_URL_LIST)
|
54
|
+
query = {"filters"=>{"search"=>pattern}, "rows_per_page"=>num, "start_row"=>start}
|
55
|
+
url = PACKAGES_URL_LIST + "/" + query.to_json
|
56
|
+
uri = URI.parse(URI.escape(url))
|
57
|
+
response = submit_request(uri)
|
58
|
+
clean_response = Sanitize.clean(response.body)
|
59
|
+
parse_results(clean_response)
|
60
|
+
end
|
61
|
+
|
62
|
+
# this function just queries for and returns a single package
|
63
|
+
def self.get_package(pattern)
|
64
|
+
get_packages(pattern, 0, 1).first
|
65
|
+
end
|
66
|
+
|
67
|
+
#this function queries for and returns a list of then open BUGS
|
68
|
+
def self.get_bugs(pattern, version='all', num=nil, start =0)
|
69
|
+
if BUGZILLA_RELEASEA[0][version].nil?
|
70
|
+
version = BUGZILLA_RELEASEA[0]['all']
|
71
|
+
else
|
72
|
+
version = BUGZILLA_RELEASEA[0][version]
|
73
|
+
end
|
74
|
+
num ||= total_rows(pattern, "bugs", BUGS_URL)
|
75
|
+
|
76
|
+
query = {"filters"=> {"package"=> pattern, "version"=> version}, "rows_per_page"=> num, "start_row"=> start}
|
77
|
+
url = BUGS_URL + "/" + query.to_json
|
78
|
+
uri = URI.parse(URI.escape(url))
|
79
|
+
response = submit_request(uri)
|
80
|
+
parse_results(response.body)
|
81
|
+
end
|
82
|
+
|
83
|
+
#this function queries for and returns a list of the BUILDS
|
84
|
+
def self.get_builds(pattern, state='all', num=nil, start =0)
|
85
|
+
if KOJI_BUILD_STATES[0][state].nil?
|
86
|
+
state = KOJI_BUILD_STATES[0]['all']
|
87
|
+
else
|
88
|
+
state = KOJI_BUILD_STATES[0][state]
|
89
|
+
end
|
90
|
+
num ||= total_rows(pattern, "builds", BUILDS_URL)
|
91
|
+
query = {"rows_per_page"=> num, "start_row"=> start, "filters"=> {"state"=> state, "package"=> pattern}}
|
92
|
+
url = BUILDS_URL + "/" + query.to_json
|
93
|
+
uri = URI.parse(URI.escape(url))
|
94
|
+
response = submit_request(uri)
|
95
|
+
parse_results(response.body)
|
96
|
+
end
|
97
|
+
|
44
98
|
def self.search_params(gem)
|
45
99
|
filters = { :package => package_name(gem) }
|
46
100
|
{ :filters => filters }
|
@@ -65,4 +119,20 @@ module Pkgwat
|
|
65
119
|
results["rows"]
|
66
120
|
end
|
67
121
|
|
122
|
+
private
|
123
|
+
|
124
|
+
def self.total_rows(pattern, type, type_url)
|
125
|
+
if type == "packages"
|
126
|
+
query = {"filters"=>{"search"=>pattern}, "rows_per_page"=>10, "start_row"=>0}
|
127
|
+
elsif type == "builds"
|
128
|
+
query = {"rows_per_page"=> 10, "start_row"=> 0, "filters"=> {"state"=> "", "package"=> pattern}}
|
129
|
+
elsif type == "bugs"
|
130
|
+
query = {"filters"=> {"package"=> pattern, "version"=> ""}, "rows_per_page"=> 10, "start_row"=> 0}
|
131
|
+
end
|
132
|
+
url = type_url + "/" + query.to_json
|
133
|
+
uri = URI.parse(URI.escape(url))
|
134
|
+
response = submit_request(uri)
|
135
|
+
JSON.parse(response.body)["total_rows"]
|
136
|
+
end
|
137
|
+
|
68
138
|
end
|
data/lib/pkgwat/version.rb
CHANGED
data/pkgwat.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pkgwat
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-01-02 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: nokogiri
|
@@ -75,6 +75,22 @@ dependencies:
|
|
75
75
|
- - '='
|
76
76
|
- !ruby/object:Gem::Version
|
77
77
|
version: 1.6.5
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: sanitize
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
type: :runtime
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
78
94
|
- !ruby/object:Gem::Dependency
|
79
95
|
name: debugger
|
80
96
|
requirement: !ruby/object:Gem::Requirement
|
@@ -123,7 +139,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
123
139
|
version: '0'
|
124
140
|
segments:
|
125
141
|
- 0
|
126
|
-
hash: -
|
142
|
+
hash: -806542677671798657
|
127
143
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
128
144
|
none: false
|
129
145
|
requirements:
|
@@ -132,7 +148,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
132
148
|
version: '0'
|
133
149
|
segments:
|
134
150
|
- 0
|
135
|
-
hash: -
|
151
|
+
hash: -806542677671798657
|
136
152
|
requirements: []
|
137
153
|
rubyforge_project: pkgwat
|
138
154
|
rubygems_version: 1.8.24
|