stickler 2.3.0 → 2.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (80) hide show
  1. checksums.yaml +15 -0
  2. data/CONTRIBUTING.md +5 -4
  3. data/HISTORY.md +16 -9
  4. data/LICENSE +1 -1
  5. data/Manifest.txt +34 -20
  6. data/README.md +128 -0
  7. data/Rakefile +10 -9
  8. data/bin/stickler +9 -6
  9. data/bin/stickler-passenger-config +8 -8
  10. data/bin/stickler-server +12 -12
  11. data/examples/as_middleware.ru +14 -0
  12. data/examples/auth_repo.ru +1 -1
  13. data/examples/gemcutter_repo.ru +1 -1
  14. data/examples/local_repo.ru +1 -1
  15. data/lib/stickler.rb +3 -1
  16. data/lib/stickler/client.rb +2 -1
  17. data/lib/stickler/client/delete.rb +1 -1
  18. data/lib/stickler/client/latest-version.rb +40 -0
  19. data/lib/stickler/client/mirror.rb +47 -15
  20. data/lib/stickler/client/push.rb +1 -1
  21. data/lib/stickler/client/unyank.rb +1 -1
  22. data/lib/stickler/client/yank.rb +1 -1
  23. data/lib/stickler/gem_container.rb +40 -0
  24. data/lib/stickler/gemfile_lock_parser.rb +47 -0
  25. data/lib/stickler/middleware.rb +1 -0
  26. data/lib/stickler/middleware/server.rb +37 -0
  27. data/lib/stickler/repository/api.rb +16 -0
  28. data/lib/stickler/repository/index.rb +0 -3
  29. data/lib/stickler/repository/local.rb +6 -8
  30. data/lib/stickler/repository/remote.rb +29 -7
  31. data/lib/stickler/server.rb +2 -6
  32. data/man/stickler-passenger-config.1 +2 -22
  33. data/man/stickler-server.1 +9 -99
  34. data/man/stickler.1 +15 -173
  35. data/man/stickler.1.ronn +6 -0
  36. data/tasks/default.rake +16 -18
  37. data/tasks/man.rake +7 -0
  38. data/tasks/this.rb +5 -5
  39. data/test/data/Gemfile.lock.example +56 -0
  40. data/{spec → test}/data/gemcutter/gems/foo-1.0.0.gem +0 -0
  41. data/{spec → test}/data/gems/bar-1.0.0.gem +0 -0
  42. data/{spec → test}/data/gems/baz-3.1.4-java.gem +0 -0
  43. data/{spec → test}/data/gems/baz-3.1.4.gem +0 -0
  44. data/{spec → test}/data/gems/foo-1.0.0.gem +0 -0
  45. data/{spec → test}/data/gems/foo-2.0.0a.gem +0 -0
  46. data/test/data/specifications/bar-1.0.0.gemspec +31 -0
  47. data/test/data/specifications/baz-3.1.4-java.gemspec +32 -0
  48. data/test/data/specifications/baz-3.1.4.gemspec +31 -0
  49. data/test/data/specifications/foo-1.0.0.gemspec +31 -0
  50. data/test/data/specifications/foo-2.0.0a.gemspec +32 -0
  51. data/test/index_test_helpers.rb +75 -0
  52. data/test/middleware/test_local.rb +75 -0
  53. data/test/middleware/test_not_found.rb +26 -0
  54. data/test/repository/test_api.rb +49 -0
  55. data/test/repository/test_api_behavior.rb +208 -0
  56. data/test/repository/test_index.rb +48 -0
  57. data/test/repository/test_local.rb +59 -0
  58. data/test/repository/test_null.rb +15 -0
  59. data/test/repository/test_remote.rb +26 -0
  60. data/test/repository/test_remote_authenticated.rb +39 -0
  61. data/test/stickler_test_server.rb +35 -0
  62. data/test/test_gemfile_lock_parser.rb +28 -0
  63. data/test/test_paths.rb +22 -0
  64. data/test/test_spec_lite.rb +90 -0
  65. data/test/test_stickler.rb +49 -0
  66. metadata +58 -85
  67. data/README.rdoc +0 -156
  68. data/spec/index_spec_helpers.rb +0 -73
  69. data/spec/middleware/local_spec.rb +0 -72
  70. data/spec/middleware/not_found_spec.rb +0 -25
  71. data/spec/paths_spec.rb +0 -11
  72. data/spec/repository/api_behavior.rb +0 -192
  73. data/spec/repository/api_spec.rb +0 -37
  74. data/spec/repository/index_spec.rb +0 -46
  75. data/spec/repository/local_spec.rb +0 -49
  76. data/spec/repository/null_spec.rb +0 -14
  77. data/spec/repository/remote_spec.rb +0 -86
  78. data/spec/spec.opts +0 -2
  79. data/spec/spec_helper.rb +0 -24
  80. data/spec/spec_lite_spec.rb +0 -96
@@ -1,37 +0,0 @@
1
- require 'spec_helper'
2
- require 'repository/api_behavior'
3
-
4
- module Stickler::Repository
5
- class Stub
6
- include Stickler::Repository::Api
7
- end
8
- end
9
-
10
- describe Stickler::Repository::Api do
11
- before do
12
- @repo = Stickler::Repository::Stub.new
13
- @spec = Stickler::SpecLite.new( "foo", "1.0.0" )
14
- end
15
-
16
- %w[ uri gems_uri ].each do |method|
17
- it "raises an error when calling unimplmented method #{method}" do
18
- lambda { @repo.send( method ) }.should raise_error( NotImplementedError, /\APlease implement .*##{method}\Z/ )
19
- end
20
- end
21
-
22
- %w[ uri_for_gem search_for delete yank get open ].each do |method|
23
- it "raises an error when calling unimplmented method #{method} taking a spec" do
24
- lambda { @repo.send( method, @spec ) }.should raise_error( NotImplementedError, /\APlease implement .*##{method}\Z/ )
25
- end
26
- end
27
-
28
- %w[ push ].each do |method|
29
- it "raises an error when calling unimplmented method #{method} taking some other object" do
30
- lambda { @repo.send( method, Object.new ) }.should raise_error( NotImplementedError, /\APlease implement .*##{method}\Z/ )
31
- end
32
- end
33
-
34
- it_should_behave_like 'includes Repository::Api'
35
- end
36
-
37
-
@@ -1,46 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe ::Stickler::Repository::Index do
4
-
5
- before do
6
- @index_me = File.join( @spec_dir, "tmp" )
7
- FileUtils.mkdir_p( @index_me )
8
-
9
- @specifications = Dir.glob( File.join( @specifications_dir, "*.gemspec" ) )
10
- @specifications.each do |s|
11
- FileUtils.cp( s, @index_me )
12
- end
13
-
14
- @index = ::Stickler::Repository::Index.new( @index_me )
15
- end
16
-
17
- after( :each ) do
18
- FileUtils.rm_rf( @index_me )
19
- end
20
-
21
- it "indexes all the .gemspec files in the directory" do
22
- @index.specs.size.should eq @specifications.size
23
- end
24
-
25
- it "is able to notice changes in the index" do
26
- @index.specs.size.should eq @specifications.size
27
- FileUtils.rm( File.join( @index_me, "foo-1.0.0.gemspec" ) )
28
- @index.specs.size.should eq( @specifications.size - 1 )
29
- end
30
-
31
- it "knows just the latest specs" do
32
- @index.latest_specs.size.should eq(@specifications.size - 1)
33
- @index.latest_specs.collect { |s| s.full_name }.sort.should eq(%w[ bar-1.0.0 baz-3.1.4 baz-3.1.4-java foo-1.0.0 ])
34
- end
35
-
36
- it "knows the pre-release specs" do
37
- @index.prerelease_specs.size.should eq 1
38
- @index.prerelease_specs.first.full_name.should eq "foo-2.0.0a"
39
- end
40
-
41
- it "knows the released specs" do
42
- @index.released_specs.size.should eq 4
43
- @index.released_specs.collect { |s| s.full_name }.sort.should eq(%w[ bar-1.0.0 baz-3.1.4 baz-3.1.4-java foo-1.0.0 ])
44
- end
45
- end
46
-
@@ -1,49 +0,0 @@
1
- require 'spec_helper'
2
- require 'repository/api_behavior'
3
-
4
- describe ::Stickler::Repository::Local do
5
-
6
- before( :each ) do
7
- @repos_dir = File.join( @spec_dir, "repos" )
8
- @repo_dir = File.join( @repos_dir, "1" )
9
- @repo = ::Stickler::Repository::Local.new( @repo_dir )
10
- end
11
-
12
- after( :each ) do
13
- ::Stickler::Repository::Local.purge
14
- FileUtils.rm_rf( @repos_dir )
15
- end
16
-
17
- %w[ gems specifications ].each do |sub_dir|
18
- it "creates #{sub_dir} directory" do
19
- new_dir = File.join( @repo_dir , sub_dir ) + File::SEPARATOR
20
- File.directory?( new_dir ).should eq true
21
- @repo.send( "#{sub_dir}_dir" ).should eq new_dir
22
- end
23
-
24
- end
25
-
26
- it "returns a list of all the specs in the repo" do
27
- Dir.glob( File.join( @gems_dir, "*.gem" ) ).each do |gem|
28
- @repo.push( gem )
29
- end
30
- @repo.specs.size.should eq 5
31
- end
32
-
33
- it "two instances with the same repo dir are the same object" do
34
- repo2 = ::Stickler::Repository::Local.new( File.join(@repos_dir, '1') )
35
- repo2.object_id.should eq @repo.object_id
36
- ::Stickler::Repository::Local.repos.size.should eq 1
37
- end
38
-
39
-
40
- it "keeps track of all the repository instances" do
41
- ::Stickler::Repository::Local.new( File.join(@repos_dir, "2" ) )
42
- ::Stickler::Repository::Local.new( File.join(@repos_dir, "3" ) )
43
- ::Stickler::Repository::Local.repos.size.should eq 3
44
- end
45
-
46
- it_should_behave_like 'includes Repository::Api'
47
- it_should_behave_like 'implements Repository::Api'
48
- end
49
-
@@ -1,14 +0,0 @@
1
- require 'spec_helper'
2
- require 'repository/api_behavior'
3
- describe ::Stickler::Repository::Null do
4
-
5
- before do
6
- @repo = ::Stickler::Repository::Null.new
7
- end
8
-
9
- it "sets the root_dir to the class name" do
10
- @repo.root_dir.should == "Stickler::Repository::Null"
11
- end
12
-
13
- it_should_behave_like 'includes Repository::Api'
14
- end
@@ -1,86 +0,0 @@
1
- require 'spec_helper'
2
- require 'repository/api_behavior'
3
-
4
- class SticklerTestServer
5
- def initialize( spec_dir, ru_file )
6
- @spec_dir = spec_dir
7
- @repo_uri = "http://localhost:6789/"
8
- @tmp_dir = File.join( @spec_dir, "tmp" )
9
- FileUtils.mkdir_p( @tmp_dir )
10
-
11
- @pid_file = File.join( @tmp_dir , "rack.pid" )
12
- @ru_file = File.expand_path( File.join( @spec_dir, "..", "examples", ru_file ) )
13
- @cmd = "rackup --port 6789 --pid #{@pid_file} --daemonize #{@ru_file}"
14
- end
15
-
16
- def start
17
- system @cmd
18
- tries = 0
19
- loop do
20
- begin
21
- Excon.get( @repo_uri + "specs.#{Gem.marshal_version}.gz" )
22
- #puts "rackup started with pid #{IO.read( @pid_file )}"
23
- break
24
- rescue
25
- tries += 1
26
- sleep tries * 0.1
27
- end
28
- end
29
- end
30
-
31
- def stop
32
- pid = IO.read( @pid_file ).to_i
33
- Process.kill( 'KILL', pid )
34
- #FileUtils.rm_rf( @tmp_dir, :verbose => true )
35
- FileUtils.rm_rf( @tmp_dir )
36
- end
37
- end
38
-
39
- describe Stickler::Repository::Remote do
40
- before do
41
- @repo_uri = "http://localhost:6789/"
42
- @repo = ::Stickler::Repository::Remote.new( @repo_uri, :debug => true )
43
- end
44
-
45
- it_should_behave_like 'includes Repository::Api'
46
-
47
- describe "Using a live server" do
48
- before do
49
- @server = SticklerTestServer.new( @spec_dir, "gemcutter_repo.ru" )
50
- @server.start
51
- end
52
-
53
- after do
54
- @server.stop
55
- end
56
-
57
- it_should_behave_like 'implements Repository::Api'
58
- end
59
-
60
- describe "Using a live authenticated server" do
61
- before do
62
- @server = SticklerTestServer.new( @spec_dir, "auth_repo.ru" )
63
- @server.start
64
- @foo_gem_local_path = File.join( @gems_dir, "foo-1.0.0.gem" )
65
- @foo_spec = Stickler::SpecLite.new( 'foo', '1.0.0' )
66
- @foo_digest = Digest::SHA1.hexdigest( IO.read( @foo_gem_local_path ) )
67
- end
68
-
69
- after do
70
- @server.stop
71
- end
72
-
73
- it "should raise an an authentication denied error" do
74
- repo = ::Stickler::Repository::Remote.new( "http://localhost:6789/")
75
- lambda { repo.get( @foo_spec ) }.should raise_error( ::Stickler::Repository::Error, /Not authorized/ )
76
- end
77
-
78
- it "should connect with proper authentication" do
79
- repo = ::Stickler::Repository::Remote.new( "http://stickler:secret@localhost:6789/")
80
- data = repo.get( @foo_spec )
81
- sha1 = Digest::SHA1.hexdigest( data )
82
- sha1.should == @foo_digest
83
- end
84
- end
85
- end
86
-
@@ -1,2 +0,0 @@
1
- --format documentation
2
- --colour
@@ -1,24 +0,0 @@
1
- if RUBY_VERSION >= '1.9.2' then
2
- require 'simplecov'
3
- SimpleCov.start if ENV['COVERAGE']
4
- end
5
-
6
- require "rspec/autorun"
7
- require 'stickler'
8
- require 'index_spec_helpers'
9
-
10
-
11
- RSpec.configure do |config|
12
-
13
- config.before( :each ) do
14
- @spec_dir = File.expand_path( File.dirname( __FILE__ ) )
15
- @gem_root = File.join( @spec_dir, 'data' )
16
- @specifications_dir = File.join( @gem_root, "specifications" )
17
- @gems_dir = File.join( @gem_root, "gems" )
18
- end
19
-
20
- config.after( :each ) do
21
- ::Stickler::Repository::Local.purge
22
- end
23
-
24
- end
@@ -1,96 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Stickler::SpecLite do
4
- before do
5
- @specs = {
6
- :ruby => Stickler::SpecLite.new( 'foo', '0.4.2' ),
7
- :win => Stickler::SpecLite.new( 'bar', '1.0.1', "x86-mswin32" ),
8
- :java => Stickler::SpecLite.new( 'jfoo', '0.4.2', 'jruby' )
9
- }
10
- end
11
-
12
- it "defaults to ruby platform" do
13
- @specs[:ruby].platform.should == Gem::Platform::RUBY
14
- end
15
-
16
- { [:ruby, 'file_name'] => "foo-0.4.2.gem",
17
- [:ruby, 'spec_file_name'] => "foo-0.4.2.gemspec" ,
18
- [:win , 'file_name'] => "bar-1.0.1-x86-mswin32.gem",
19
- [:win , 'spec_file_name'] => "bar-1.0.1-x86-mswin32.gemspec",
20
- [:java, 'file_name'] => 'jfoo-0.4.2-jruby.gem',
21
- [:java, 'spec_file_name'] => 'jfoo-0.4.2-jruby.gemspec',
22
- }.each do |params, result|
23
- platform, method = *params
24
- it "on a #{platform} gem ##{method} is #{result}" do
25
- @specs[platform].send( method ).should == result
26
- end
27
- end
28
-
29
- it "has an array format" do
30
- @specs[:win].to_a.should == [ 'bar', '1.0.1', 'x86-mswin32' ]
31
- end
32
-
33
- it "returns false when compared to something that does not resond to :name, :version or :platform_string" do
34
- x = @specs[:ruby] =~ Object.new
35
- x.should == false
36
- end
37
-
38
- it "can compare against anything that responds to :name, :version and :platform_string" do
39
- class OSpec
40
- attr_accessor :name
41
- attr_accessor :version
42
- attr_accessor :platform_string
43
- end
44
-
45
- o = OSpec.new
46
- o.name = @specs[:ruby].name
47
- o.version = @specs[:ruby].version
48
- o.platform_string = @specs[:ruby].platform_string
49
- r = @specs[:ruby] =~ o
50
- r.should == true
51
- end
52
-
53
- it "can be compared against another spec" do
54
- (@specs[:ruby] =~ @specs[:win]).should == false
55
- end
56
-
57
- it "can be compared against something with the same name and version but different platform" do
58
- list = []
59
- list << r = Stickler::SpecLite.new( 'alib', '4.2' )
60
- list << u = Stickler::SpecLite.new( 'alib', '4.2', 'x86-mswin32' )
61
- list.sort.should == [ r, u ]
62
- end
63
-
64
- it 'converts platform comparisons to something that can be compared' do
65
- list = []
66
- list << h2 = Stickler::SpecLite.new( 'htimes', '1.1.1', 'x86-mingw32' )
67
- list << h1 = Stickler::SpecLite.new( 'htimes', '1.1.1', 'java' )
68
- list.sort.should == [ h1, h2 ]
69
- end
70
-
71
- it "can be sorted" do
72
- list = @specs.values
73
- alib = Stickler::SpecLite.new( 'alib', '4.2' )
74
- list << alib
75
- list.sort.should == [ alib, @specs[:win], @specs[:ruby], @specs[:java] ]
76
- end
77
-
78
- it "knows when it is a prerelease specification" do
79
- spec = Stickler::SpecLite.new( 'prerelease', '1.2.3a' )
80
- spec.should be_prerelease
81
- end
82
-
83
- it "knows when it is not a prerelease specification" do
84
- spec = Stickler::SpecLite.new( 'prerelease', '1.2.3' )
85
- spec.should_not be_prerelease
86
- end
87
-
88
- it "needs to be version sortable" do
89
- a = Stickler::SpecLite.new( "foo", "1.0.3" )
90
- b = Stickler::SpecLite.new( "foo", "1.0.22" )
91
- c = Stickler::SpecLite.new( "foo", "1.0.17" )
92
-
93
- [ b, a, c ].sort.should == [ a, c, b ]
94
-
95
- end
96
- end