polisher 0.4 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (72) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +20 -661
  3. data/README.md +39 -0
  4. data/Rakefile +11 -88
  5. data/bin/binary_gem_resolver.rb +95 -0
  6. data/bin/gem_dependency_checker.rb +165 -0
  7. data/bin/git_gem_updater.rb +86 -0
  8. data/bin/ruby_rpm_spec_updater.rb +29 -0
  9. data/lib/polisher.rb +19 -0
  10. data/lib/polisher/apt.rb +12 -0
  11. data/lib/polisher/bodhi.rb +21 -0
  12. data/lib/polisher/bugzilla.rb +9 -0
  13. data/lib/polisher/core.rb +33 -0
  14. data/lib/polisher/errata.rb +43 -0
  15. data/lib/polisher/fedora.rb +43 -0
  16. data/lib/polisher/gem.rb +155 -0
  17. data/lib/polisher/gemfile.rb +72 -0
  18. data/lib/polisher/gemspec.rb +32 -0
  19. data/lib/polisher/git.rb +135 -0
  20. data/lib/polisher/koji.rb +54 -0
  21. data/lib/polisher/rhn.rb +14 -0
  22. data/lib/polisher/rpmspec.rb +254 -0
  23. data/lib/polisher/upstream.rb +29 -0
  24. data/lib/polisher/vendor.rb +9 -0
  25. data/lib/polisher/version_checker.rb +100 -0
  26. data/lib/polisher/yum.rb +28 -0
  27. data/spec/core_spec.rb +64 -0
  28. data/spec/fedora_spec.rb +14 -0
  29. data/spec/gem_spec.rb +82 -0
  30. data/spec/gemfile_spec.rb +45 -0
  31. data/spec/git_spec.rb +74 -0
  32. data/spec/rpmspec_spec.rb +105 -0
  33. data/spec/spec_helper.rb +50 -37
  34. data/spec/upstream_spec.rb +39 -0
  35. metadata +173 -179
  36. data/COPYING +0 -8
  37. data/README.rdoc +0 -105
  38. data/TODO +0 -7
  39. data/bin/server +0 -4
  40. data/config.ru +0 -25
  41. data/config/database.yml +0 -13
  42. data/config/polisher.yml +0 -5
  43. data/db/connection.rb +0 -52
  44. data/db/migrations/001_create_projects.rb +0 -23
  45. data/db/migrations/002_create_sources.rb +0 -25
  46. data/db/migrations/003_create_project_source_versions.rb +0 -28
  47. data/db/migrations/004_create_events.rb +0 -27
  48. data/db/migrations/005_create_project_dependencies.rb +0 -28
  49. data/db/models/event.rb +0 -87
  50. data/db/models/project.rb +0 -110
  51. data/db/models/project_dependency.rb +0 -27
  52. data/db/models/project_source_version.rb +0 -31
  53. data/db/models/source.rb +0 -101
  54. data/lib/common.rb +0 -71
  55. data/lib/dsl.rb +0 -292
  56. data/lib/event_handlers.rb +0 -166
  57. data/lib/gem_adapter.rb +0 -94
  58. data/lib/sinatra/url_for.rb +0 -40
  59. data/polisher.rb +0 -372
  60. data/public/stylesheets/style.css +0 -67
  61. data/spec/common_spec.rb +0 -28
  62. data/spec/dsl_spec.rb +0 -357
  63. data/spec/event_handlers_spec.rb +0 -300
  64. data/spec/gem_adapter_spec.rb +0 -89
  65. data/spec/models_spec.rb +0 -721
  66. data/spec/polisher_spec.rb +0 -573
  67. data/views/layout.haml +0 -22
  68. data/views/projects/index.haml +0 -42
  69. data/views/projects/index.html.haml +0 -38
  70. data/views/result.haml +0 -9
  71. data/views/sources/index.haml +0 -24
  72. data/views/sources/index.html.haml +0 -26
@@ -0,0 +1,29 @@
1
+ # Polisher Upstream Operations
2
+ #
3
+ # Licensed under the MIT license
4
+ # Copyright (C) 2013 Red Hat, Inc.
5
+
6
+ require 'polisher/gem'
7
+ require 'polisher/gemfile'
8
+
9
+ module Polisher
10
+ class Upstream
11
+ # Parse the specified upstream source, automatically
12
+ # dispatches to correct upstream parser depending on
13
+ # format of specified source
14
+ #
15
+ # @returns instance of class representing parsed source
16
+ def self.parse(source)
17
+ if source.gem?
18
+ Polisher::Gem.parse(:gem => source)
19
+
20
+ elsif source.gemspec?
21
+ Polisher::Gem.parse(:gemspec => source)
22
+
23
+ elsif source.gemfile?
24
+ Polisher::Gemfile.parse(source)
25
+
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,9 @@
1
+ # Polisher Vendor Operations
2
+ #
3
+ # Licensed under the MIT license
4
+ # Copyright (C) 2013 Red Hat, Inc.
5
+
6
+ module Polisher
7
+ class Vendor
8
+ end
9
+ end
@@ -0,0 +1,100 @@
1
+ # Helpers to check versions
2
+ #
3
+ # Licensed under the MIT license
4
+ # Copyright (C) 2013 Red Hat, Inc.
5
+
6
+ require 'polisher/gem'
7
+ require 'polisher/fedora'
8
+ require 'polisher/koji'
9
+ require 'polisher/git'
10
+ require 'polisher/bodhi'
11
+ require 'polisher/yum'
12
+
13
+ module Polisher
14
+ class VersionChecker
15
+ GEM_TARGET = :gem
16
+ KOJI_TARGET = :koji
17
+ FEDORA_TARGET = :fedora
18
+ GIT_TARGET = :git
19
+ YUM_TARGET = :yum
20
+ ALL_TARGETS = [GEM_TARGET, KOJI_TARGET, FEDORA_TARGET,
21
+ GIT_TARGET, YUM_TARGET]
22
+
23
+ # Enable the specified target(s) in the list of target to check
24
+ def self.check(target)
25
+ @check_list ||= []
26
+ if target.is_a?(Array)
27
+ target.each { |t| self.check(t) }
28
+ return
29
+ end
30
+
31
+ @check_list << target
32
+ end
33
+
34
+ # Retrieve all the versions of the specified package using
35
+ # the configured targets.
36
+ #
37
+ # If not specified, all targets are checked
38
+ # @param [String] name name of package to query
39
+ # @param [Callable] bl optional block to invoke with versions retrieved
40
+ # @returns [Hash<target,Array<String>>] returns a hash of target to versions
41
+ # available for specified package
42
+ def self.versions_for(name, &bl)
43
+ @check_list ||= ALL_TARGETS
44
+ versions = {}
45
+
46
+ if @check_list.include?(GEM_TARGET)
47
+ versions.merge! :gem => Gem.local_versions_for(name, &bl)
48
+ end
49
+
50
+ if @check_list.include?(FEDORA_TARGET)
51
+ versions.merge! :fedora => Fedora.versions_for(name, &bl)
52
+ end
53
+
54
+ if @check_list.include?(KOJI_TARGET)
55
+ versions.merge! :koji => Koji.versions_for(name, &bl)
56
+ end
57
+
58
+ if @check_list.include?(GIT_TARGET)
59
+ versions.merge! :git => [GitPackage.version_for(name, &bl)]
60
+ end
61
+
62
+ if @check_list.include?(YUM_TARGET)
63
+ versions.merge! :yum => [Yum.version_for(name, &bl)]
64
+ end
65
+
66
+ #bodhi_version = Bodhi.versions_for(name, &bl)
67
+ #errata_version = Errata.version_for('url?', name, &bl)
68
+
69
+ versions
70
+ end
71
+
72
+ # Return version of package most frequent in all configured targets.
73
+ # Invokes query as normal then counts versions over all targets and
74
+ # returns the max.
75
+ def self.version_for(name)
76
+ versions = self.versions_for(name).values
77
+ versions.inject(Hasn.new(0)) { |total, i| total[i] += 1; total }.first
78
+ end
79
+ end
80
+
81
+ # Helper module to be included in components
82
+ # that contain lists of dependencies which include version information
83
+ module VersionedDependencies
84
+
85
+ # Return list of versions of dependencies of component.
86
+ #
87
+ # Requires module define 'deps' method which returns list
88
+ # of gem names representing component dependencies. List
89
+ # will be iterated over, versions will be looked up
90
+ # recursively and returned
91
+ def dependency_versions(&bl)
92
+ versions = {}
93
+ self.deps.each do |dep|
94
+ gem = Polisher::Gem.retrieve(dep)
95
+ versions.merge!(gem.versions(:recursive => true, :dev_deps => true, &bl))
96
+ end
97
+ versions
98
+ end
99
+ end
100
+ end
@@ -0,0 +1,28 @@
1
+ # Polisher Yum Operations
2
+ #
3
+ # Licensed under the MIT license
4
+ # Copyright (C) 2013 Red Hat, Inc.
5
+
6
+ require 'pkgwat'
7
+
8
+ module Polisher
9
+ class Yum
10
+ YUM_CMD = '/usr/bin/yum'
11
+
12
+ # Retrieve version of gem available in yum
13
+ #
14
+ # @param [String] name name of gem to loopup
15
+ # @param [Callable] bl optional callback to invoke with version retrieved
16
+ # @returns [String] version of gem in yum or nil if not found
17
+ def self.version_for(name, &bl)
18
+ version = nil
19
+ out=`#{YUM_CMD} info rubygem-#{name} 2> /dev/null`
20
+ if out.include?("Version")
21
+ version = out.lines.to_a.find { |l| l =~ /^Version.*/ }
22
+ version = version.split(':').last.strip
23
+ end
24
+ bl.call(:yum, name, [version]) unless(bl.nil?)
25
+ version
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,64 @@
1
+ # Polisher Core Extensions Specs
2
+ #
3
+ # Licensed under the MIT license
4
+ # Copyright (C) 2013 Red Hat, Inc.
5
+
6
+ require 'spec_helper'
7
+ require 'polisher/core'
8
+
9
+ describe String do
10
+ describe "#gem?" do
11
+ context "string represents path to gem" do
12
+ it "returns true" do
13
+ "/foo/rails.gem".should be_gem
14
+ end
15
+ end
16
+
17
+ context "string does not represent path to gem" do
18
+ it "returns false" do
19
+ "/foo/rails.gemspec".should_not be_gem
20
+ end
21
+ end
22
+ end
23
+
24
+ describe "#gemspec?" do
25
+ context "string represents path to gemspec" do
26
+ it "returns true" do
27
+ "/foo/rails.gemspec".should be_gemspec
28
+ end
29
+ end
30
+
31
+ context "string does not represent path to gemspec" do
32
+ it "returns false" do
33
+ "/foo/rails.gem".should_not be_gemspec
34
+ end
35
+ end
36
+ end
37
+
38
+ describe "#gemfile?" do
39
+ context "string represents path to gemfile" do
40
+ it "returns true" do
41
+ "/foo/Gemfile".should be_gemfile
42
+ end
43
+ end
44
+
45
+ context "string does not represent path to gemfile" do
46
+ it "returns false" do
47
+ "/foo/foobar".should_not be_gemfile
48
+ end
49
+ end
50
+ end
51
+
52
+ describe "unrpmize" do
53
+ it "returns string with rpm macros removed/replaced" do
54
+ "%doc ".unrpmize.should == ""
55
+ "%{_bindir}".unrpmize.should == "/bin"
56
+ end
57
+ end
58
+
59
+ describe "#rpmize" do
60
+ it "returns string with rpm macros swapped in" do
61
+ "/bin".rpmize.should == "%{_bindir}"
62
+ end
63
+ end
64
+ end # describe String
@@ -0,0 +1,14 @@
1
+ # Polisher Fedora Spec
2
+ #
3
+ # Licensed under the MIT license
4
+ # Copyright (C) 2013 Red Hat, Inc.
5
+
6
+ require 'polisher/fedora'
7
+
8
+ module Polisher
9
+ describe Fedora do
10
+ describe "#gems_owned_by" do
11
+ it "retrieves gems owned by the specified user"
12
+ end
13
+ end # describe Fedora
14
+ end # module Polisher
@@ -0,0 +1,82 @@
1
+ # Polisher Gem Specs
2
+ #
3
+ # Licensed under the MIT license
4
+ # Copyright (C) 2013 Red Hat, Inc.
5
+
6
+ require 'polisher/gem'
7
+
8
+ module Polisher
9
+ describe Gem do
10
+ describe "#initialize" do
11
+ it "sets gemfile attributes" do
12
+ gem = Polisher::Gem.new :name => 'rails',
13
+ :version => '4.0.0',
14
+ :deps => ['activesupport', 'activerecord'],
15
+ :dev_deps => ['rake']
16
+ gem.name.should == 'rails'
17
+ gem.version.should == '4.0.0'
18
+ gem.deps.should == ['activesupport', 'activerecord']
19
+ gem.dev_deps.should == ['rake']
20
+ end
21
+ end
22
+
23
+ describe "#parse" do
24
+ it "returns new gem" do
25
+ gem = Polisher::Gem.parse
26
+ gem.should be_an_instance_of(Polisher::Gem)
27
+ end
28
+
29
+ it "parses gem from gem spec" do
30
+ spec = Polisher::Test::GEM_SPEC
31
+ gem = Polisher::Gem.parse(:gemspec => spec[:path])
32
+ gem.name.should == spec[:name]
33
+ gem.version.should == spec[:version]
34
+ gem.deps.should == spec[:deps]
35
+ gem.dev_deps.should == spec[:dev_deps]
36
+ end
37
+
38
+ it "parses gem from gem at path"
39
+
40
+ it "parses gem from metadata hash" do
41
+ gemj = Polisher::Test::GEM_JSON
42
+ gem = Polisher::Gem.parse gemj[:json]
43
+ gem.name.should == gemj[:name]
44
+ gem.version.should == gemj[:version]
45
+ gem.deps.should == gemj[:deps]
46
+ gem.dev_deps.should == gemj[:dev_deps]
47
+ end
48
+ end
49
+
50
+ describe "#retrieve" do
51
+ before(:each) do
52
+ @local_gem = Polisher::Test::LOCAL_GEM
53
+
54
+ # stub out expected calls to curl
55
+ @curl1 = Curl::Easy.new
56
+ @curl2 = Curl::Easy.new
57
+
58
+ Curl::Easy.should_receive(:http_get).with(@local_gem[:json_url]).and_return(@curl1)
59
+ @curl1.should_receive(:body_str).and_return(@local_gem[:json])
60
+
61
+ Curl::Easy.should_receive(:new).with(@local_gem[:url]).and_return(@curl2)
62
+ @curl2.should_receive(:http_get)
63
+ @curl2.should_receive(:body_str).and_return(@local_gem[:contents])
64
+ end
65
+
66
+ it "returns gem retrieved from rubygems" do
67
+ gem = Polisher::Gem.retrieve(@local_gem[:name])
68
+ gem.should be_an_instance_of(Polisher::Gem)
69
+ gem.name.should == @local_gem[:name]
70
+ gem.version.should == @local_gem[:version]
71
+ gem.deps.should == @local_gem[:deps]
72
+ gem.dev_deps.should == @local_gem[:dev_deps]
73
+ end
74
+
75
+ it "sets gem files" do
76
+ gem = Polisher::Gem.retrieve(@local_gem[:name])
77
+ gem.should be_an_instance_of(Polisher::Gem)
78
+ gem.files.should == @local_gem[:files]
79
+ end
80
+ end
81
+ end # describe Gem
82
+ end # module Polisher
@@ -0,0 +1,45 @@
1
+ # Polisher Gemfile Specs
2
+ #
3
+ # Licensed under the MIT license
4
+ # Copyright (C) 2013 Red Hat, Inc.
5
+
6
+ require 'polisher/gemfile'
7
+
8
+ module Bundler
9
+ describe "#gem" do
10
+ it "stores parsed gems"
11
+ end
12
+ end
13
+
14
+ module Polisher
15
+ describe Gemfile do
16
+ describe "#initialize" do
17
+ it "sets gemfile deps,dev_deps" do
18
+ gemfile = Polisher::Gemfile.new :deps => ['rails'], :dev_deps => ['rake']
19
+ gemfile.deps.should == ['rails']
20
+ gemfile.dev_deps.should == ['rake']
21
+ end
22
+
23
+ it "sets default gemfile version,files" do
24
+ gemfile = Polisher::Gemfile.new
25
+ gemfile.version.should be_nil
26
+ gemfile.files.should == []
27
+ end
28
+ end
29
+
30
+ describe "#parse" do
31
+ it "returns new gemfile instance" do
32
+ gemfile = Polisher::Test::GEMFILE
33
+ pgemfile = Polisher::Gemfile.parse gemfile[:path]
34
+ pgemfile.should be_an_instance_of(Polisher::Gemfile)
35
+ end
36
+
37
+ it "parses deps,dev_deps from spec" do
38
+ gemfile = Polisher::Test::GEMFILE
39
+ pgemfile = Polisher::Gemfile.parse gemfile[:path]
40
+ pgemfile.deps.should == gemfile[:deps]
41
+ #pgemfile.dev_deps.should...
42
+ end
43
+ end
44
+ end # describe Gemfile
45
+ end # module Polisher
@@ -0,0 +1,74 @@
1
+ # Polisher Git Spec
2
+ #
3
+ # Licensed under the MIT license
4
+ # Copyright (C) 2013 Red Hat, Inc.
5
+
6
+ require 'polisher/git'
7
+
8
+ module Polisher
9
+ describe GitPackage do
10
+ describe "#rpm_name" do
11
+ it "returns rubygem-gem_name" do
12
+ pkg = Polisher::GitPackage.new :name => 'rails'
13
+ pkg.rpm_name.should == 'rubygem-rails'
14
+ end
15
+ end
16
+
17
+ describe "#srpm" do
18
+ it "returns name of srpm" do
19
+ pkg = Polisher::GitPackage.new :name => 'rails', :version => '1.0.0'
20
+ pkg.srpm.should == 'rubygem-rails-1.0.0-1.*.src.rpm'
21
+ end
22
+ end
23
+
24
+ describe "#spec" do
25
+ it "returns name of spec" do
26
+ pkg = Polisher::GitPackage.new :name => 'rails'
27
+ pkg.spec.should == 'rubygem-rails.spec'
28
+ end
29
+ end
30
+
31
+ describe "#clone" do
32
+ context "package directory does not exist" do
33
+ it "uses package command to clone package"
34
+ end
35
+
36
+ context "dead.package file exists" do
37
+ it "raises Exception"
38
+ end
39
+
40
+ it "checks out master branch"
41
+ it "resets head"
42
+ it "pulls from remote"
43
+
44
+ it "returns new GitPackage instance"
45
+ end
46
+
47
+ describe "#update_to" do
48
+ it "updates rpm spec"
49
+ it "updates sources file"
50
+ it "updates .gitignore file"
51
+ end
52
+
53
+ describe "#build" do
54
+ it "uses package command to build srpm"
55
+ it "uses build command to build srpm"
56
+ end
57
+
58
+ describe "#has_check?" do
59
+ context "package spec has %check section" do
60
+ it "returns true"
61
+ end
62
+
63
+ context "package spec does not have a %check section" do
64
+ it "returns false"
65
+ end
66
+ end
67
+
68
+ describe "#commit" do
69
+ it "git adds the sources, .gitignore, and spec files"
70
+ it "commits the package"
71
+ end
72
+
73
+ end # describe GitPackage
74
+ end # module Polisher