pkgwat 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,19 @@
1
+ *.gem
2
+ Gemfile.lock
3
+ *.rbc
4
+ .bundle
5
+ .config
6
+ coverage
7
+ InstalledFiles
8
+ lib/bundler/man
9
+ pkg
10
+ rdoc
11
+ spec/reports
12
+ test/tmp
13
+ test/version_tmp
14
+ tmp
15
+
16
+ # YARD artifacts
17
+ .yardoc
18
+ _yardoc
19
+ doc/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in pkgwat.gemspec
4
+ gemspec
@@ -0,0 +1,34 @@
1
+ pkgwat
2
+ ======
3
+
4
+ Pkgwat is a gem for querying gem versions from RPM repos. It's based off of
5
+ [pkgwat.cli](git://github.com/ralphbean/pkgwat.cli.git) and it uses
6
+ [apps.fedoraproject.org/packages](https://apps.fedoraproject.org/packages/).
7
+
8
+
9
+
10
+ Installing pkgwat
11
+ -----------------
12
+
13
+ ```bash
14
+ gem isntall pkgwat
15
+ ```
16
+
17
+ Alternatively, if you're using a Gemfile, just add this:
18
+
19
+ ```bash
20
+ gem 'pkgwat'
21
+ ```
22
+
23
+ Using pkgwat
24
+ ------------
25
+
26
+ ```ruby
27
+ Pkgwat.get_versions("rails")
28
+
29
+ # this will return true or false if the package exists
30
+ Pkgwat.check_gem("pry", "0.9.10", [Pkgwat::F16])
31
+ ```
32
+
33
+ We also plan to add some rake tasks so you can check that your bundler gems are
34
+ available in Fedora/EPEL repos either locally or as part of a test suite.
@@ -0,0 +1,2 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'pkgwat/tasks'
@@ -0,0 +1,68 @@
1
+ require "pkgwat/version"
2
+ require 'net/https'
3
+ require 'json'
4
+
5
+ module Pkgwat
6
+ require 'pkgwat/railtie' if defined?(Rails)
7
+
8
+ F17 = "Fedora 17"
9
+ F16 = "Fedora 16"
10
+ F18 = "Fedora 18"
11
+ EPEL6 = "Fedora EPEL 6"
12
+ EPEL5 = "Fedora EPEL 5"
13
+ DEFAULT_DISTROS = [F17, F16, EPEL6]
14
+ PACKAGE_NAME = "rubygem-:gem"
15
+ PACKAGES_URL = "https://apps.fedoraproject.org/packages/fcomm_connector/bodhi/query/query_active_releases"
16
+
17
+ def self.check_gem(name, version, distros = DEFAULT_DISTROS, throw_ex = false)
18
+ puts "Checking #{name} #{version}...\n"
19
+ versions = get_versions(name)
20
+ matches = []
21
+ distros.each do |distro|
22
+ dv = versions.detect { |v| v["release"] == distro }
23
+ match = compare_versions(version, dv["stable_version"])
24
+ matches << dv["release"] if match
25
+ end
26
+ puts "#{name} is available in the following distros: #{matches.join(",")}"
27
+ end
28
+
29
+ def self.compare_versions(version, distro)
30
+ distro.to_s.split("-").first == version.to_s
31
+ end
32
+
33
+ def self.get_versions(gem_name)
34
+ uri = search_url(gem_name)
35
+ response = submit_request(uri)
36
+ raise "Could not connect to packages API (#{response.inspect})" unless response.code == "200"
37
+ parse_results(response.body)
38
+ end
39
+
40
+ def self.package_name(gem)
41
+ PACKAGE_NAME.gsub(":gem", gem)
42
+ end
43
+
44
+ def self.search_params(gem)
45
+ filters = { :package => package_name(gem) }
46
+ { :filters => filters }
47
+ end
48
+
49
+ def self.search_url(gem)
50
+ query = search_params(gem)
51
+ url = PACKAGES_URL + "/" + query.to_json
52
+ URI.parse(URI.escape(url))
53
+ end
54
+
55
+ def self.submit_request(uri)
56
+ http = Net::HTTP.new(uri.host, uri.port)
57
+ http.use_ssl = true
58
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE #TODO: verify
59
+ request = Net::HTTP::Get.new(uri.request_uri)
60
+ http.request(request)
61
+ end
62
+
63
+ def self.parse_results(results)
64
+ results = JSON.parse(results)
65
+ results["rows"]
66
+ end
67
+
68
+ end
@@ -0,0 +1,11 @@
1
+ require 'pkgwat'
2
+ require 'rails'
3
+ module MyPlugin
4
+ class Railtie < Rails::Railtie
5
+ railtie_name :pkgwat
6
+
7
+ rake_tasks do
8
+ load "tasks/pkgwat.rake"
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,12 @@
1
+ require 'rake'
2
+ require 'pkgwat'
3
+
4
+ namespace :pkgwat do
5
+ desc "Check the Gemfile.lock for packages"
6
+ task :check do
7
+ lockfile = Bundler::LockfileParser.new(Bundler.read_file("Gemfile.lock"))
8
+ lockfile.specs.each do |gem|
9
+ Pkgwat.check_gem(gem.name, gem.version)
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,3 @@
1
+ module Pkgwat
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,33 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "pkgwat/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "pkgwat"
7
+ s.version = Pkgwat::VERSION
8
+ s.authors = ["David Davis"]
9
+ s.email = ["daviddavis@redhat.com"]
10
+ s.homepage = ""
11
+ s.summary = %q{pkgwat checks your gems to against Fedora/EPEL.}
12
+ s.description = %q{pkgwat checks your Gemfile.lock to make sure all your gems
13
+ are packaged in Fedora/EPEL. Eventually we hope to support
14
+ Gemfiles and bundle list as well.}
15
+
16
+ s.rubyforge_project = "pkgwat"
17
+
18
+ s.add_dependency("nokogiri", "= 1.5.5")
19
+ s.add_dependency("rake")
20
+ s.add_dependency("thor")
21
+ s.add_dependency("json", "1.6.5")
22
+
23
+ if RUBY_VERSION >= "1.9"
24
+ s.add_development_dependency("debugger")
25
+ else
26
+ s.add_development_dependency("ruby-debug")
27
+ end
28
+
29
+ s.files = `git ls-files`.split("\n")
30
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
31
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
32
+ s.require_paths = ["lib"]
33
+ end
metadata ADDED
@@ -0,0 +1,142 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pkgwat
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - David Davis
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-12-22 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: nokogiri
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - '='
20
+ - !ruby/object:Gem::Version
21
+ version: 1.5.5
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - '='
28
+ - !ruby/object:Gem::Version
29
+ version: 1.5.5
30
+ - !ruby/object:Gem::Dependency
31
+ name: rake
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: thor
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: json
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - '='
68
+ - !ruby/object:Gem::Version
69
+ version: 1.6.5
70
+ type: :runtime
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - '='
76
+ - !ruby/object:Gem::Version
77
+ version: 1.6.5
78
+ - !ruby/object:Gem::Dependency
79
+ name: debugger
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ description: ! "pkgwat checks your Gemfile.lock to make sure all your gems\n are
95
+ packaged in Fedora/EPEL. Eventually we hope to support\n Gemfiles
96
+ and bundle list as well."
97
+ email:
98
+ - daviddavis@redhat.com
99
+ executables: []
100
+ extensions: []
101
+ extra_rdoc_files: []
102
+ files:
103
+ - .gitignore
104
+ - Gemfile
105
+ - README.md
106
+ - Rakefile
107
+ - lib/pkgwat.rb
108
+ - lib/pkgwat/railtie.rb
109
+ - lib/pkgwat/tasks.rb
110
+ - lib/pkgwat/version.rb
111
+ - pkgwat.gemspec
112
+ homepage: ''
113
+ licenses: []
114
+ post_install_message:
115
+ rdoc_options: []
116
+ require_paths:
117
+ - lib
118
+ required_ruby_version: !ruby/object:Gem::Requirement
119
+ none: false
120
+ requirements:
121
+ - - ! '>='
122
+ - !ruby/object:Gem::Version
123
+ version: '0'
124
+ segments:
125
+ - 0
126
+ hash: -98816147268201223
127
+ required_rubygems_version: !ruby/object:Gem::Requirement
128
+ none: false
129
+ requirements:
130
+ - - ! '>='
131
+ - !ruby/object:Gem::Version
132
+ version: '0'
133
+ segments:
134
+ - 0
135
+ hash: -98816147268201223
136
+ requirements: []
137
+ rubyforge_project: pkgwat
138
+ rubygems_version: 1.8.24
139
+ signing_key:
140
+ specification_version: 3
141
+ summary: pkgwat checks your gems to against Fedora/EPEL.
142
+ test_files: []