polisher 0.7.1 → 0.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6,4 +6,32 @@
6
6
  module Polisher
7
7
  class Vendor
8
8
  end
9
+
10
+ module HasVendoredDeps
11
+ # Return list of file paths marked as vendored
12
+ #
13
+ # Scope which this module is being mixed into
14
+ # must defined 'file_paths'
15
+ def vendored_file_paths
16
+ self.file_paths.select { |f| f.include?('vendor/') }
17
+ end
18
+
19
+ # Return list of vendered gems in file list
20
+ def vendored
21
+ vendored_file_paths.inject({}) do |v,fp|
22
+ vendored_file = fp.split('/')
23
+ vendor_index = vendored_file.index('vendor')
24
+
25
+ # only process vendor'd dirs:
26
+ next v if vendor_index + 2 == vendored_file.size
27
+
28
+ vname = vendored_file[vendor_index + 1]
29
+ vversion = nil
30
+ # TODO set vversion from version.rb:
31
+ #vf.last.downcase == 'version.rb'
32
+ v[vname] = vversion
33
+ v
34
+ end
35
+ end
36
+ end
9
37
  end
@@ -1,3 +1,3 @@
1
1
  module Polisher
2
- VERSION = "0.7.1"
2
+ VERSION = "0.8.1"
3
3
  end
@@ -6,7 +6,7 @@
6
6
  require 'polisher/gem'
7
7
  require 'polisher/fedora'
8
8
  require 'polisher/koji'
9
- require 'polisher/git'
9
+ require 'polisher/git/pkg'
10
10
  require 'polisher/bodhi'
11
11
  require 'polisher/yum'
12
12
 
@@ -32,6 +32,11 @@ module Polisher
32
32
  @check_list << target
33
33
  end
34
34
 
35
+ def self.should_check?(target)
36
+ @check_list ||= ALL_TARGETS
37
+ @check_list.include?(target)
38
+ end
39
+
35
40
  # Retrieve all the versions of the specified package using
36
41
  # the configured targets.
37
42
  #
@@ -41,30 +46,29 @@ module Polisher
41
46
  # @returns [Hash<target,Array<String>>] returns a hash of target to versions
42
47
  # available for specified package
43
48
  def self.versions_for(name, &bl)
44
- @check_list ||= ALL_TARGETS
45
49
  versions = {}
46
50
 
47
- if @check_list.include?(GEM_TARGET)
51
+ if should_check?(GEM_TARGET)
48
52
  versions.merge! :gem => Gem.local_versions_for(name, &bl)
49
53
  end
50
54
 
51
- if @check_list.include?(FEDORA_TARGET)
55
+ if should_check?(FEDORA_TARGET)
52
56
  versions.merge! :fedora => Fedora.versions_for(name, &bl)
53
57
  end
54
58
 
55
- if @check_list.include?(KOJI_TARGET)
59
+ if should_check?(KOJI_TARGET)
56
60
  versions.merge! :koji => Koji.versions_for(name, &bl)
57
61
  end
58
62
 
59
- if @check_list.include?(GIT_TARGET)
60
- versions.merge! :git => [GitPackage.version_for(name, &bl)]
63
+ if should_check?(GIT_TARGET)
64
+ versions.merge! :git => [Git::Pkg.version_for(name, &bl)]
61
65
  end
62
66
 
63
- if @check_list.include?(YUM_TARGET)
67
+ if should_check?(YUM_TARGET)
64
68
  versions.merge! :yum => [Yum.version_for(name, &bl)]
65
69
  end
66
70
 
67
- if @check_list.include?(BODHI_TARGET)
71
+ if should_check?(BODHI_TARGET)
68
72
  versions.merge! :bodhi => Bodhi.versions_for(name, &bl)
69
73
  end
70
74
 
@@ -84,14 +84,14 @@ module Polisher
84
84
  describe "#download_gem_path" do
85
85
  it "downloads gem" do
86
86
  gem = Polisher::Gem.new
87
- gem.should_receive(:download_gem)
87
+ Polisher::Gem.should_receive(:download_gem)
88
88
  gem.downloaded_gem_path
89
89
  end
90
90
 
91
91
  it "returns gem cache path for gem" do
92
92
  # stub out d/l
93
93
  gem = Polisher::Gem.new :name => 'rails', :version => '1.0'
94
- gem.should_receive(:download_gem)
94
+ Polisher::Gem.should_receive(:download_gem)
95
95
  Polisher::GemCache.should_receive(:path_for).
96
96
  with('rails', '1.0').
97
97
  at_least(:once).
@@ -155,29 +155,6 @@ module Polisher
155
155
  end
156
156
  end
157
157
 
158
- describe "#vendored_file_paths" do
159
- it "returns file marks in gem marked as vendored" do
160
- expected = [ 'vendor/foo.rb', 'vendor/bar/foo.rb']
161
- paths = ['foo.rb'] + expected
162
- gem = Polisher::Gem.new
163
- gem.should_receive(:file_paths).and_return(paths)
164
- gem.vendored_file_paths.should == expected
165
- end
166
- end
167
-
168
- describe "#vendored" do
169
- it "returns list of vendored modules in gem" do
170
- gem = Polisher::Gem.new
171
- vendored = ['vendor/thor.rb', 'vendor/thor/foo.rb', 'vendor/biz/baz.rb']
172
- gem.should_receive(:vendored_file_paths).and_return(vendored)
173
- gem.vendored.should == {'thor' => nil, 'biz' => nil}
174
- end
175
-
176
- context "vendored module has VERSION.rb file" do
177
- it "returns version of vendored gems"
178
- end
179
- end
180
-
181
158
  describe "#diff" do
182
159
  before(:each) do
183
160
  @gem1 = Polisher::Gem.new
@@ -3,6 +3,8 @@
3
3
  # Licensed under the MIT license
4
4
  # Copyright (C) 2013-2014 Red Hat, Inc.
5
5
 
6
+ require 'spec_helper'
7
+
6
8
  require 'polisher/gemfile'
7
9
 
8
10
  module Bundler
@@ -41,5 +43,16 @@ module Polisher
41
43
  #pgemfile.dev_deps.should...
42
44
  end
43
45
  end
46
+
47
+ describe "#vendored" do
48
+ it "returns gemfile deps + dev_deps" do
49
+ gemfile = described_class.new :deps => ['rails'], :dev_deps => ['rake']
50
+ gemfile.vendored.should == ['rails', 'rake']
51
+ end
52
+ end
53
+
54
+ describe "#patched" do
55
+ it "..."
56
+ end
44
57
  end # describe Gemfile
45
58
  end # module Polisher
@@ -6,7 +6,7 @@
6
6
  require 'polisher/git'
7
7
 
8
8
  module Polisher
9
- describe GitRepo do
9
+ describe Git::Repo do
10
10
  describe "#initialize" do
11
11
  it "initializes url" do
12
12
  repo = described_class.new :url => 'repo_url'
@@ -73,6 +73,16 @@ module Polisher
73
73
  end
74
74
  end
75
75
 
76
+ describe "#file_paths" do
77
+ it "returns list of all first paths in git repo" do
78
+ expected = ['file1', 'dir1/file2', 'dir2']
79
+ repo = described_class.new
80
+ repo.should_receive(:in_repo).and_yield
81
+ Dir.should_receive(:[]).with('**/*').and_return(expected)
82
+ repo.file_paths.should == expected
83
+ end
84
+ end
85
+
76
86
  describe "#reset!" do
77
87
  it "resets git repo to head" do
78
88
  expected = "/usr/bin/git reset HEAD~ --hard"
@@ -114,7 +124,7 @@ module Polisher
114
124
  end
115
125
  end
116
126
 
117
- describe GitPackage do
127
+ describe Git::Pkg do
118
128
  describe "#initialize" do
119
129
  it "initializes name" do
120
130
  pkg = described_class.new :name => 'pkg_name'
@@ -149,7 +159,7 @@ module Polisher
149
159
  end
150
160
 
151
161
  describe "#spec" do
152
- it "returns handle to parsed Polisher::RPMSpec"
162
+ it "returns handle to parsed Polisher::RPM::Spec"
153
163
  end
154
164
 
155
165
  describe "#pkg_files" do
@@ -167,14 +177,15 @@ module Polisher
167
177
  describe "#clone" do
168
178
  it "clones package" do
169
179
  # stub out glob / rm_rf
170
- Dir.should_receive(:glob).and_return([])
180
+ Dir.should_receive(:foreach).and_return([])
171
181
  FileUtils.should_receive(:rm_rf).at_least(:once)
172
182
 
173
183
  pkg = described_class.new :name => 'rails'
174
184
  pkg.should_receive(:in_repo).and_yield
175
185
 
176
186
  expected = '/usr/bin/fedpkg clone rubygem-rails'
177
- AwesomeSpawn.should_receive(:run).with(expected)
187
+ result = AwesomeSpawn::CommandResult.new '', '', '', 0
188
+ AwesomeSpawn.should_receive(:run).with(expected).and_return(result)
178
189
  pkg.clone
179
190
  end
180
191
 
@@ -346,7 +357,7 @@ module Polisher
346
357
 
347
358
  describe "#version_for" do
348
359
  it "uses git to retrieve the package" do
349
- pkg = "#{described_class::DIST_GIT_URL}rubygem-rails.git"
360
+ pkg = "#{described_class.dist_git_url}rubygem-rails.git"
350
361
  dir = Polisher::GitCache.path_for('rubygem-rails')
351
362
  expected = "/usr/bin/git clone #{pkg} #{dir}"
352
363
  AwesomeSpawn.should_receive(:run).with(expected)
@@ -356,7 +367,7 @@ module Polisher
356
367
  it "returns version of the package" do
357
368
  AwesomeSpawn.should_receive(:run) # stub out run
358
369
 
359
- spec = Polisher::RPMSpec.new :version => '1.0.0'
370
+ spec = Polisher::RPM::Spec.new :version => '1.0.0'
360
371
  pkg = described_class.new
361
372
  described_class.should_receive(:new).and_return(pkg)
362
373
  pkg.should_receive(:spec).and_return(spec)
@@ -367,7 +378,7 @@ module Polisher
367
378
  it "invokes callback with version of package" do
368
379
  AwesomeSpawn.should_receive(:run) # stub out run
369
380
 
370
- spec = Polisher::RPMSpec.new :version => '1.0.0'
381
+ spec = Polisher::RPM::Spec.new :version => '1.0.0'
371
382
  pkg = described_class.new
372
383
  described_class.should_receive(:new).and_return(pkg)
373
384
  pkg.should_receive(:spec).and_return(spec)
@@ -377,6 +388,19 @@ module Polisher
377
388
  described_class.version_for('rails', &cb)
378
389
  end
379
390
  end
380
-
381
- end # describe GitPackage
391
+ end # describe Git::Pkg
392
+
393
+ describe Git::Project do
394
+ describe "#vendored" do
395
+ context "repo not cloned" do
396
+ it "clones repo" do
397
+ git = described_class.new
398
+ git.should_receive(:cloned?).and_return(false)
399
+ git.should_receive(:clone)
400
+ git.should_receive(:vendored_file_paths).and_return([]) # stub out
401
+ git.vendored
402
+ end
403
+ end
404
+ end
405
+ end
382
406
  end # module Polisher
@@ -5,11 +5,11 @@
5
5
 
6
6
  require 'spec_helper'
7
7
 
8
- require 'polisher/rpmspec'
8
+ require 'polisher/rpm/spec'
9
9
  require 'polisher/gem'
10
10
 
11
11
  module Polisher
12
- describe RPMSpec::Requirement do
12
+ describe RPM::Requirement do
13
13
  describe "#str" do
14
14
  it "returns requirement in string format" do
15
15
  req = described_class.new :name => 'rubygem(activesupport)'
@@ -345,17 +345,17 @@ module Polisher
345
345
  end
346
346
  end
347
347
 
348
- describe RPMSpec do
348
+ describe RPM::Spec do
349
349
  describe "#initialize" do
350
350
  it "sets gem metadata" do
351
- spec = Polisher::RPMSpec.new :version => '1.0.0'
351
+ spec = Polisher::RPM::Spec.new :version => '1.0.0'
352
352
  spec.metadata.should == {:version => '1.0.0'}
353
353
  end
354
354
  end
355
355
 
356
356
  describe "#method_missing" do
357
357
  it "proxies lookup to metadata" do
358
- spec = Polisher::RPMSpec.new :version => '1.0.0'
358
+ spec = Polisher::RPM::Spec.new :version => '1.0.0'
359
359
  spec.version.should == '1.0.0'
360
360
  end
361
361
  end
@@ -379,14 +379,14 @@ module Polisher
379
379
 
380
380
  describe "#requirements_for_gem" do
381
381
  it "returns requirements for specified gem name" do
382
- spec = Polisher::RPMSpec.new :requires =>
383
- [Polisher::RPMSpec::Requirement.new(:name => 'rubygem(rake)')]
382
+ spec = Polisher::RPM::Spec.new :requires =>
383
+ [Polisher::RPM::Requirement.new(:name => 'rubygem(rake)')]
384
384
  spec.requirements_for_gem('rake').should == [spec.requires.first]
385
385
  end
386
386
 
387
387
  context "spec has no requirement with specified name" do
388
388
  it "returns empty array" do
389
- spec = Polisher::RPMSpec.new
389
+ spec = Polisher::RPM::Spec.new
390
390
  spec.requirements_for_gem('rake').should be_empty
391
391
  end
392
392
  end
@@ -398,60 +398,60 @@ module Polisher
398
398
  end
399
399
 
400
400
  it "returns new rpmspec instance" do
401
- pspec = Polisher::RPMSpec.parse @spec[:contents]
402
- pspec.should be_an_instance_of(Polisher::RPMSpec)
401
+ pspec = Polisher::RPM::Spec.parse @spec[:contents]
402
+ pspec.should be_an_instance_of(Polisher::RPM::Spec)
403
403
  end
404
404
 
405
405
  it "parses contents from spec" do
406
- pspec = Polisher::RPMSpec.parse @spec[:contents]
406
+ pspec = Polisher::RPM::Spec.parse @spec[:contents]
407
407
  pspec.contents.should == @spec[:contents]
408
408
  end
409
409
 
410
410
  it "parses name from spec" do
411
- pspec = Polisher::RPMSpec.parse @spec[:contents]
411
+ pspec = Polisher::RPM::Spec.parse @spec[:contents]
412
412
  pspec.gem_name.should == @spec[:name]
413
413
  end
414
414
 
415
415
  it "parses version from spec" do
416
- pspec = Polisher::RPMSpec.parse @spec[:contents]
416
+ pspec = Polisher::RPM::Spec.parse @spec[:contents]
417
417
  pspec.version.should == @spec[:version]
418
418
  end
419
419
 
420
420
  it "parses release from spec" do
421
- pspec = Polisher::RPMSpec.parse @spec[:contents]
421
+ pspec = Polisher::RPM::Spec.parse @spec[:contents]
422
422
  pspec.release.should == @spec[:release]
423
423
  end
424
424
 
425
425
  it "parses requires from spec" do
426
- pspec = Polisher::RPMSpec.parse @spec[:contents]
426
+ pspec = Polisher::RPM::Spec.parse @spec[:contents]
427
427
  pspec.requires.should == @spec[:requires]
428
428
  end
429
429
 
430
430
  it "parses build requires from spec" do
431
- pspec = Polisher::RPMSpec.parse @spec[:contents]
431
+ pspec = Polisher::RPM::Spec.parse @spec[:contents]
432
432
  pspec.build_requires.should == @spec[:build_requires]
433
433
  end
434
434
 
435
435
  it "parses changelog from spec"
436
436
 
437
437
  it "parses unrpmized files from spec" do
438
- pspec = Polisher::RPMSpec.parse @spec[:contents]
438
+ pspec = Polisher::RPM::Spec.parse @spec[:contents]
439
439
  pspec.files.should == @spec[:files]
440
440
  end
441
441
 
442
442
  it "parses %check from spec" do
443
- pspec = Polisher::RPMSpec.parse @spec[:contents]
443
+ pspec = Polisher::RPM::Spec.parse @spec[:contents]
444
444
  pspec.has_check?.should be_true
445
445
 
446
- pspec = Polisher::RPMSpec.parse ""
446
+ pspec = Polisher::RPM::Spec.parse ""
447
447
  pspec.has_check?.should be_false
448
448
  end
449
449
  end
450
450
 
451
451
  describe "#update_to" do
452
452
  it "updates dependencies from gem" do
453
- spec = Polisher::RPMSpec.new :requires => [Polisher::RPMSpec::Requirement.parse('rubygem(rake)'),
454
- Polisher::RPMSpec::Requirement.parse('rubygem(activerecord)')],
453
+ spec = Polisher::RPM::Spec.new :requires => [Polisher::RPM::Requirement.parse('rubygem(rake)'),
454
+ Polisher::RPM::Requirement.parse('rubygem(activerecord)')],
455
455
  :build_requires => []
456
456
  gem = Polisher::Gem.new :deps => [::Gem::Dependency.new('rake'),
457
457
  ::Gem::Dependency.new('rails', '~> 10')],
@@ -459,15 +459,15 @@ module Polisher
459
459
 
460
460
  spec.should_receive(:update_files_from) # stub out files update
461
461
  spec.update_to(gem)
462
- spec.requires.should == [Polisher::RPMSpec::Requirement.parse('rubygem(activerecord)'),
463
- Polisher::RPMSpec::Requirement.parse('rubygem(rake) >= 0'),
464
- Polisher::RPMSpec::Requirement.parse('rubygem(rails) => 10'),
465
- Polisher::RPMSpec::Requirement.parse('rubygem(rails) < 11')]
466
- spec.build_requires.should == [Polisher::RPMSpec::Requirement.parse('rubygem(rspec) >= 0', :br => true)]
462
+ spec.requires.should == [Polisher::RPM::Requirement.parse('rubygem(activerecord)'),
463
+ Polisher::RPM::Requirement.parse('rubygem(rake) >= 0'),
464
+ Polisher::RPM::Requirement.parse('rubygem(rails) => 10'),
465
+ Polisher::RPM::Requirement.parse('rubygem(rails) < 11')]
466
+ spec.build_requires.should == [Polisher::RPM::Requirement.parse('rubygem(rspec) >= 0', :br => true)]
467
467
  end
468
468
 
469
469
  it "adds new files from gem" do
470
- spec = Polisher::RPMSpec.new :files => {'pkg' => ['/foo']}
470
+ spec = Polisher::RPM::Spec.new :files => {'pkg' => ['/foo']}
471
471
  gem = Polisher::Gem.new
472
472
  gem.should_receive(:file_paths).at_least(:once).
473
473
  and_return(['/foo', '/foo/bar', '/baz'])
@@ -476,7 +476,7 @@ module Polisher
476
476
  end
477
477
 
478
478
  it "updates metadata from gem" do
479
- spec = Polisher::RPMSpec.new
479
+ spec = Polisher::RPM::Spec.new
480
480
  gem = Polisher::Gem.new :version => '1.0.0'
481
481
  spec.should_receive(:update_files_from) # stub out files update
482
482
  spec.update_to(gem)
@@ -493,8 +493,8 @@ module Polisher
493
493
 
494
494
  describe "#compare" do
495
495
  it "returns requirements in spec but not in gem" do
496
- req = Polisher::RPMSpec::Requirement.parse 'rubygem(rails) > 3.0.0'
497
- spec = Polisher::RPMSpec.new :requires => [req]
496
+ req = Polisher::RPM::Requirement.parse 'rubygem(rails) > 3.0.0'
497
+ spec = Polisher::RPM::Spec.new :requires => [req]
498
498
  gem = Polisher::Gem.new
499
499
 
500
500
  spec.compare(gem).should ==
@@ -504,7 +504,7 @@ module Polisher
504
504
 
505
505
  it "returns requirements in gem but not in spec" do
506
506
  req = ::Gem::Dependency.new('rails', '> 3.0.0')
507
- spec = Polisher::RPMSpec.new
507
+ spec = Polisher::RPM::Spec.new
508
508
  gem = Polisher::Gem.new :deps => [req]
509
509
 
510
510
  spec.compare(gem).should ==
@@ -516,8 +516,8 @@ module Polisher
516
516
  greq = ::Gem::Dependency.new('rails', '< 5.0.0')
517
517
  gem = Polisher::Gem.new :deps => [greq]
518
518
 
519
- sreq = Polisher::RPMSpec::Requirement.parse 'rubygem(rails) > 3.0.0'
520
- spec = Polisher::RPMSpec.new :requires => [sreq]
519
+ sreq = Polisher::RPM::Requirement.parse 'rubygem(rails) > 3.0.0'
520
+ spec = Polisher::RPM::Spec.new :requires => [sreq]
521
521
 
522
522
  spec.compare(gem).should ==
523
523
  {:same => {}, :diff => {'rails' =>
@@ -528,13 +528,13 @@ module Polisher
528
528
  greq = ::Gem::Dependency.new('rails', '< 3.0.0')
529
529
  gem = Polisher::Gem.new :deps => [greq]
530
530
 
531
- sreq = Polisher::RPMSpec::Requirement.parse 'rubygem(rails) < 3.0.0'
532
- spec = Polisher::RPMSpec.new :requires => [sreq]
531
+ sreq = Polisher::RPM::Requirement.parse 'rubygem(rails) < 3.0.0'
532
+ spec = Polisher::RPM::Spec.new :requires => [sreq]
533
533
 
534
534
  spec.compare(gem).should ==
535
535
  {:diff => {}, :same => {'rails' =>
536
536
  {:spec => '< 3.0.0', :upstream => '< 3.0.0'}}}
537
537
  end
538
538
  end
539
- end # describe RPMSpec
539
+ end # describe RPM::Spec
540
540
  end # module Polisher