stickler 0.1.1 → 2.0.0a
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.
- data/HISTORY.rdoc +5 -2
- data/Rakefile +31 -0
- data/examples/config.ru +9 -0
- data/examples/gemcutter_repo.ru +19 -0
- data/examples/index_repo.ru +15 -0
- data/examples/local_repo.ru +14 -0
- data/examples/mirror_repo.ru +16 -0
- data/examples/not_found.ru +8 -0
- data/lib/stickler/error.rb +3 -0
- data/lib/stickler/middleware/compression.rb +30 -0
- data/lib/stickler/middleware/gemcutter.rb +62 -0
- data/lib/stickler/middleware/helpers.rb +84 -0
- data/lib/stickler/middleware/index.rb +137 -0
- data/lib/stickler/middleware/local.rb +38 -0
- data/lib/stickler/middleware/mirror.rb +60 -0
- data/lib/stickler/middleware/not_found.rb +62 -0
- data/lib/stickler/middleware.rb +4 -0
- data/lib/stickler/repository/api.rb +167 -0
- data/lib/stickler/repository/index.rb +97 -0
- data/lib/stickler/repository/local.rb +251 -0
- data/lib/stickler/repository/mirror.rb +48 -0
- data/lib/stickler/repository/null.rb +58 -0
- data/lib/stickler/repository/remote.rb +235 -0
- data/lib/stickler/repository.rb +7 -499
- data/lib/stickler/spec_lite.rb +60 -14
- data/lib/stickler/version.rb +6 -6
- data/lib/stickler/web.rb +19 -0
- data/spec/data/gems/bar-1.0.0.gem +0 -0
- data/spec/data/gems/foo-1.0.0.gem +0 -0
- data/spec/data/specifications/bar-1.0.0.gemspec +31 -0
- data/spec/data/specifications/foo-1.0.0.gemspec +31 -0
- data/spec/middleware/common_gem_server_helpers.rb +67 -0
- data/spec/middleware/index_spec.rb +26 -0
- data/spec/middleware/legacy_gem_server_behavior.rb +33 -0
- data/spec/middleware/local_spec.rb +25 -0
- data/spec/middleware/modern_gem_server_behavior.rb +20 -0
- data/spec/middleware/not_found_spec.rb +25 -0
- data/spec/repository/api_behavior.rb +162 -0
- data/spec/repository/api_spec.rb +38 -0
- data/spec/repository/index_spec.rb +32 -0
- data/spec/repository/local_spec.rb +36 -0
- data/spec/repository/null_spec.rb +17 -0
- data/spec/repository/remote_spec.rb +49 -0
- data/spec/spec.opts +2 -0
- data/spec/spec_helper.rb +15 -3
- data/spec/spec_lite_spec.rb +62 -0
- data/stickler.gemspec +60 -0
- data/views/index.erb +19 -0
- data/views/layout.erb +39 -0
- metadata +93 -63
- data/COPYING +0 -339
- data/bin/stickler +0 -58
- data/data/stickler.yml +0 -14
- data/gemspec.rb +0 -62
- data/lib/stickler/cli.rb +0 -302
- data/lib/stickler/configuration.rb +0 -74
- data/lib/stickler/console.rb +0 -72
- data/lib/stickler/paths.rb +0 -62
- data/lib/stickler/source.rb +0 -75
- data/lib/stickler/source_group.rb +0 -365
- data/lib/stickler.rb +0 -19
- data/spec/configuration_spec.rb +0 -68
- data/spec/paths_spec.rb +0 -25
- data/spec/repository_spec.rb +0 -55
- data/spec/version_spec.rb +0 -17
- data/tasks/announce.rake +0 -39
- data/tasks/config.rb +0 -107
- data/tasks/distribution.rake +0 -45
- data/tasks/documentation.rake +0 -31
- data/tasks/rspec.rake +0 -29
- data/tasks/rubyforge.rake +0 -51
- data/tasks/utils.rb +0 -80
@@ -0,0 +1,31 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = %q{foo}
|
5
|
+
s.version = "1.0.0"
|
6
|
+
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
|
+
s.authors = ["Jeremy Hinegardner"]
|
9
|
+
s.date = %q{2010-06-23}
|
10
|
+
s.description = %q{foo gem}
|
11
|
+
s.email = %q{jeremy@hinegardner.org}
|
12
|
+
s.files = ["README.rdoc", "lib/foo.rb", "bin/foo", "Rakefile", "foo.gemspec"]
|
13
|
+
s.homepage = %q{http://github.com/copiousfreetime/stickler}
|
14
|
+
s.require_paths = ["lib"]
|
15
|
+
s.rubygems_version = %q{1.3.5}
|
16
|
+
s.summary = %q{foo gem}
|
17
|
+
|
18
|
+
if s.respond_to? :specification_version then
|
19
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
20
|
+
s.specification_version = 3
|
21
|
+
|
22
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
23
|
+
s.add_runtime_dependency(%q<rake>, [">= 0"])
|
24
|
+
else
|
25
|
+
s.add_dependency(%q<rake>, [">= 0"])
|
26
|
+
end
|
27
|
+
else
|
28
|
+
s.add_dependency(%q<rake>, [">= 0"])
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
@@ -0,0 +1,67 @@
|
|
1
|
+
require File.expand_path( File.join( File.dirname(__FILE__), "..", "spec_helper.rb" ) )
|
2
|
+
require 'rubygems/server'
|
3
|
+
|
4
|
+
shared_examples_for "common gem server before after" do
|
5
|
+
|
6
|
+
before do
|
7
|
+
@spec_dir = File.join( @gem_dir, "specifications" )
|
8
|
+
|
9
|
+
@webrick = ::Gem::Server.new(@gem_dir,4567,false)
|
10
|
+
@underlying_server = @webrick.instance_variable_get("@server")
|
11
|
+
@webrick_thread = Thread.new( @webrick ) do |webrick|
|
12
|
+
webrick.run
|
13
|
+
end
|
14
|
+
@webrick_request = WEBrick::HTTPRequest.new :Logger => nil
|
15
|
+
@webrick_response = WEBrick::HTTPResponse.new :HTTPVersion => '1.0'
|
16
|
+
end
|
17
|
+
|
18
|
+
|
19
|
+
after do
|
20
|
+
@underlying_server.shutdown
|
21
|
+
@webrick_thread.kill
|
22
|
+
end
|
23
|
+
|
24
|
+
|
25
|
+
#
|
26
|
+
# pulled and modified from sinatra-rubygems
|
27
|
+
# http://github.com/jnewland/sinatra-rubygems
|
28
|
+
#
|
29
|
+
def should_match_webrick_behavior(url)
|
30
|
+
|
31
|
+
#webrick
|
32
|
+
data = StringIO.new "GET #{url} HTTP/1.0\r\n\r\n"
|
33
|
+
@webrick_request.parse data
|
34
|
+
verify_webrick = {}
|
35
|
+
begin
|
36
|
+
@underlying_server.service( @webrick_request, @webrick_response)
|
37
|
+
verify_webrick[:status] = @webrick_response.status
|
38
|
+
verify_webrick[:content_type] = @webrick_response['Content-Type']
|
39
|
+
verify_webrick[:body_length] = @webrick_response.body.length
|
40
|
+
verify_webrick[:body] = @webrick_response.body
|
41
|
+
rescue WEBrick::HTTPStatus::NotFound
|
42
|
+
verify_webrick = {
|
43
|
+
:status => 404,
|
44
|
+
:content_type => 'text/html',
|
45
|
+
:body_length => "446"
|
46
|
+
}
|
47
|
+
end
|
48
|
+
|
49
|
+
#sinatra
|
50
|
+
get url
|
51
|
+
|
52
|
+
#verify
|
53
|
+
if 200 == last_response.status and 200 == verify_webrick[:status] then
|
54
|
+
{
|
55
|
+
:status => last_response.status,
|
56
|
+
:content_type => last_response['Content-Type'],
|
57
|
+
:body_length => last_response.body.length,
|
58
|
+
:body => last_response.body
|
59
|
+
}.should == verify_webrick
|
60
|
+
else
|
61
|
+
last_response.status.should == verify_webrick[:status]
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
65
|
+
|
66
|
+
|
67
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require File.expand_path( File.join( File.dirname(__FILE__), "..", "spec_helper.rb" ) )
|
2
|
+
require File.expand_path( File.join( File.dirname(__FILE__), "modern_gem_server_behavior.rb" ) )
|
3
|
+
|
4
|
+
require 'stickler/middleware/index'
|
5
|
+
require 'stickler/middleware/compression'
|
6
|
+
|
7
|
+
describe Stickler::Middleware::Index do
|
8
|
+
def app
|
9
|
+
::Rack::Builder.new do
|
10
|
+
use ::Stickler::Middleware::Compression
|
11
|
+
use ::Stickler::Middleware::Index
|
12
|
+
run ::Sinatra::Base
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
before do
|
17
|
+
@gem_dir = File.expand_path( File.join( File.dirname( __FILE__ ), "tmp" ) )
|
18
|
+
FileUtils.mkdir_p( File.join( @gem_dir, "specifications" ))
|
19
|
+
end
|
20
|
+
|
21
|
+
after do
|
22
|
+
FileUtils.rm_rf( @gem_dir )
|
23
|
+
end
|
24
|
+
|
25
|
+
it_should_behave_like "modern gem server indexes"
|
26
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require File.expand_path( File.join( File.dirname(__FILE__), "..", "spec_helper.rb" ) )
|
2
|
+
require File.expand_path( File.join( File.dirname(__FILE__), "common_gem_server_helpers.rb" ) )
|
3
|
+
|
4
|
+
require 'rubygems/server'
|
5
|
+
|
6
|
+
shared_examples_for "legacy gem server indexes" do
|
7
|
+
|
8
|
+
it_should_behave_like "common gem server before after"
|
9
|
+
|
10
|
+
LEGACY_URLS = [
|
11
|
+
"/yaml",
|
12
|
+
"/yam.Z",
|
13
|
+
"/Marshal.#{Gem.marshal_version}",
|
14
|
+
"/Marshal.#{Gem.marshal_version}.Z",
|
15
|
+
"/quick/index",
|
16
|
+
"/quick/index.rz",
|
17
|
+
"/quick/latest_index",
|
18
|
+
"/quick/latest_index.rz",
|
19
|
+
"/quick/Marshal.#{Gem.marshal_version}/foo-1.0.0.gemspec.rz",
|
20
|
+
"/quick/foo-1.0.0.gemspec.rz",
|
21
|
+
"/quick/Marshal.#{Gem.marshal_version}/bar-1.0.0.gemspec.rz",
|
22
|
+
"/quick/bar-1.0.0.gemspec.rz",
|
23
|
+
"/quick/does-not-exist-1.2.0.gemspec.rz"
|
24
|
+
]
|
25
|
+
|
26
|
+
LEGACY_URLS.each do |url|
|
27
|
+
it "serves a legacy gem server index item from #{url}" do
|
28
|
+
should_match_webrick_behavior url
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require File.expand_path( File.join( File.dirname(__FILE__), "..", "spec_helper.rb" ) )
|
2
|
+
require File.expand_path( File.join( File.dirname(__FILE__), "modern_gem_server_behavior.rb" ) )
|
3
|
+
require File.expand_path( File.join( File.dirname(__FILE__), "legacy_gem_server_behavior.rb" ) )
|
4
|
+
|
5
|
+
require 'stickler/middleware/local'
|
6
|
+
require 'stickler/middleware/compression'
|
7
|
+
|
8
|
+
describe ::Stickler::Middleware::Local do
|
9
|
+
def app
|
10
|
+
gem_dir = @gem_dir
|
11
|
+
::Rack::Builder.new do
|
12
|
+
use ::Stickler::Middleware::Compression
|
13
|
+
use ::Stickler::Middleware::Local, :repo_root => gem_dir
|
14
|
+
run ::Sinatra::Base
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
before do
|
19
|
+
@gem_dir = File.join( @spec_dir, "data" )
|
20
|
+
end
|
21
|
+
|
22
|
+
it_should_behave_like "modern gem server indexes"
|
23
|
+
# it_should_behave_like "legacy gem server indexes"
|
24
|
+
|
25
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require File.expand_path( File.join( File.dirname(__FILE__), "..", "spec_helper.rb" ) )
|
2
|
+
require File.expand_path( File.join( File.dirname(__FILE__), "common_gem_server_helpers.rb" ) )
|
3
|
+
|
4
|
+
shared_examples_for "modern gem server indexes" do
|
5
|
+
|
6
|
+
it_should_behave_like "common gem server before after"
|
7
|
+
|
8
|
+
MODERN_URLS = [
|
9
|
+
"/specs.#{Gem.marshal_version}",
|
10
|
+
"/specs.#{Gem.marshal_version}.gz",
|
11
|
+
"/latest_specs.#{Gem.marshal_version}",
|
12
|
+
"/latest_specs.#{Gem.marshal_version}.gz",
|
13
|
+
]
|
14
|
+
|
15
|
+
MODERN_URLS.each do |url|
|
16
|
+
it "serves a modern gem server index item from #{url}" do
|
17
|
+
should_match_webrick_behavior url
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require File.expand_path( File.join( File.dirname(__FILE__), "..", "spec_helper.rb" ) )
|
2
|
+
require 'stickler/middleware/not_found'
|
3
|
+
|
4
|
+
describe ::Stickler::Middleware::NotFound do
|
5
|
+
def app
|
6
|
+
::Stickler::Middleware::NotFound.new
|
7
|
+
end
|
8
|
+
|
9
|
+
before do
|
10
|
+
get "/"
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should respond to a 404 on everything" do
|
14
|
+
get '/'
|
15
|
+
last_response.status.should == 404
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should return a 'text/html' page" do
|
19
|
+
last_response.content_type.should == 'text/html'
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should say to go look somewhere else" do
|
23
|
+
last_response.body.should =~ /Not Found/m
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,162 @@
|
|
1
|
+
require 'stickler/repository/api'
|
2
|
+
|
3
|
+
shared_examples_for "includes Repository::Api" do
|
4
|
+
describe "responds to all the api methods" do
|
5
|
+
Stickler::Repository::Api.api_methods.each do |method|
|
6
|
+
it "responds to ##{method}" do
|
7
|
+
@repo.respond_to?( method ).should == true
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
require 'digest/sha1'
|
14
|
+
shared_examples_for "implements Repository::Api" do
|
15
|
+
before( :each ) do
|
16
|
+
@foo_gem_local_path = File.join( @gems_dir, "foo-1.0.0.gem" )
|
17
|
+
@foo_spec = Stickler::SpecLite.new( 'foo', '1.0.0' )
|
18
|
+
@foo_digest = Digest::SHA1.hexdigest( IO.read( @foo_gem_local_path ) )
|
19
|
+
@missing_spec = Stickler::SpecLite.new( "does_not_exist", "0.1.0" )
|
20
|
+
end
|
21
|
+
|
22
|
+
# removed specifications_uri
|
23
|
+
%w[ uri gems_uri ].each do |method|
|
24
|
+
it "returns a URI like object from #{method}" do
|
25
|
+
result = @repo.send( method )
|
26
|
+
[ ::URI, ::Addressable::URI ].include?( result.class ).should == true
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
# removed specification
|
31
|
+
%w[ gem ].each do |thing|
|
32
|
+
describe "#uri_for_#{thing}" do
|
33
|
+
before( :each ) do
|
34
|
+
@repo.push( @foo_gem_local_path )
|
35
|
+
@method = "uri_for_#{thing}"
|
36
|
+
end
|
37
|
+
|
38
|
+
it "returns URI for a #{thing} that exists" do
|
39
|
+
uri = @repo.send( @method, @foo_spec )
|
40
|
+
[ ::URI, ::Addressable::URI ].include?( uri.class ).should == true
|
41
|
+
end
|
42
|
+
|
43
|
+
it "returns nil for a #{thing} that does not exist" do
|
44
|
+
@repo.send( @method, @missing_spec ).should be_nil
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
describe "#push" do
|
50
|
+
it "pushes a gem from a .gem file" do
|
51
|
+
@repo.push( @foo_gem_local_path )
|
52
|
+
@repo.search_for( Stickler::SpecLite.new( "foo", "1.0.0" ) )
|
53
|
+
end
|
54
|
+
|
55
|
+
it "raises an error when pushing a gem if the gem already exists" do
|
56
|
+
@repo.push( @foo_gem_local_path )
|
57
|
+
lambda { @repo.push( @foo_gem_local_path ) }.should raise_error( Stickler::Repository::Error, /gem foo-1.0.0 already exists/ )
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
describe "#delete" do
|
62
|
+
it "deletes a gem from the repo" do
|
63
|
+
@repo.search_for( @foo_spec ).should be_empty
|
64
|
+
@repo.push( @foo_gem_local_path )
|
65
|
+
@repo.search_for( @foo_spec ).size.should == 1
|
66
|
+
@repo.delete( @foo_spec ).should == true
|
67
|
+
@repo.search_for( @foo_spec ).should be_empty
|
68
|
+
end
|
69
|
+
|
70
|
+
it "returns false if it is unable to delete a gem from the repo" do
|
71
|
+
@repo.search_for( @foo_spec ).should be_empty
|
72
|
+
@repo.delete( @foo_spec ).should == false
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
describe "#yank" do
|
77
|
+
before( :each ) do
|
78
|
+
@repo.search_for( @foo_spec ).should be_empty
|
79
|
+
@repo.push( @foo_gem_local_path )
|
80
|
+
@response_uri = @repo.yank( @foo_spec )
|
81
|
+
end
|
82
|
+
|
83
|
+
it "returns the uri in which to get the gem" do
|
84
|
+
[ ::URI, ::Addressable::URI ].include?( @response_uri.class ).should == true
|
85
|
+
end
|
86
|
+
|
87
|
+
it "returns nil if the gem to yank does not exist or is already yanked" do
|
88
|
+
@repo.yank( @missing_spec ).should == nil
|
89
|
+
end
|
90
|
+
|
91
|
+
it "does not find the gem in a search" do
|
92
|
+
@repo.search_for( @foo_spec ).should be_empty
|
93
|
+
end
|
94
|
+
|
95
|
+
it "does have the #uri_for_gem" do
|
96
|
+
@repo.uri_for_gem( @foo_spec ).should == @response_uri
|
97
|
+
end
|
98
|
+
|
99
|
+
it "can still return the gem" do
|
100
|
+
data = @repo.get( @foo_spec )
|
101
|
+
sha1 = Digest::SHA1.hexdigest( data )
|
102
|
+
sha1.should == @foo_digest
|
103
|
+
end
|
104
|
+
|
105
|
+
end
|
106
|
+
|
107
|
+
describe "#search_for" do
|
108
|
+
it "returns specs for items that are found" do
|
109
|
+
@repo.push( @foo_gem_local_path )
|
110
|
+
@repo.search_for( @foo_spec ).should_not be_empty
|
111
|
+
end
|
112
|
+
|
113
|
+
it "returns an empty array when nothing is found" do
|
114
|
+
@repo.search_for( @missing_spec ).should be_empty
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
describe "#get" do
|
119
|
+
it "returns the bytes of the gem for a gem that exists" do
|
120
|
+
@repo.push( @foo_gem_local_path )
|
121
|
+
data = @repo.get( @foo_spec )
|
122
|
+
sha1 = Digest::SHA1.hexdigest( data )
|
123
|
+
sha1.should == @foo_digest
|
124
|
+
end
|
125
|
+
|
126
|
+
it "returns nil if the gem does not exist" do
|
127
|
+
@repo.get( @missing_spec ).should be_nil
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
describe "#open" do
|
132
|
+
before( :each ) do
|
133
|
+
@repo.push( @foo_gem_local_path )
|
134
|
+
end
|
135
|
+
it "reads a gem via a returned output stream" do
|
136
|
+
io = @repo.open( @foo_spec )
|
137
|
+
sha1 = Digest::SHA1.hexdigest( io.read )
|
138
|
+
sha1.should == @foo_digest
|
139
|
+
end
|
140
|
+
|
141
|
+
it "can be called with a block" do
|
142
|
+
sha1 = Digest::SHA1.new
|
143
|
+
@repo.open( @foo_spec ) do |io|
|
144
|
+
sha1 << io.read
|
145
|
+
end
|
146
|
+
sha1.hexdigest.should == @foo_digest
|
147
|
+
end
|
148
|
+
|
149
|
+
it "returns nil if the gem does not exist" do
|
150
|
+
@repo.open( @missing_spec ).should == nil
|
151
|
+
end
|
152
|
+
|
153
|
+
it "does not call the block if the gem does not exist" do
|
154
|
+
called = false
|
155
|
+
@repo.open( @missing_spec ) do |io|
|
156
|
+
called = true
|
157
|
+
end
|
158
|
+
called.should == false
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require File.expand_path( File.join( File.dirname(__FILE__), "..", "spec_helper.rb" ) )
|
2
|
+
require File.expand_path( File.join( File.dirname(__FILE__), "api_behavior.rb" ) )
|
3
|
+
|
4
|
+
require 'stickler/repository/api'
|
5
|
+
module Stickler::Repository
|
6
|
+
class Stub
|
7
|
+
include Stickler::Repository::Api
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
describe Stickler::Repository::Api do
|
12
|
+
before do
|
13
|
+
@repo = Stickler::Repository::Stub.new
|
14
|
+
@spec = Stickler::SpecLite.new( "foo", "1.0.0" )
|
15
|
+
end
|
16
|
+
|
17
|
+
%w[ uri gems_uri ].each do |method|
|
18
|
+
it "raises an error when calling unimplmented method #{method}" do
|
19
|
+
lambda { @repo.send( method ) }.should raise_error( NotImplementedError, /\APlease implement .*##{method}\Z/ )
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
%w[ uri_for_gem search_for delete yank get open ].each do |method|
|
24
|
+
it "raises an error when calling unimplmented method #{method} taking a spec" do
|
25
|
+
lambda { @repo.send( method, @spec ) }.should raise_error( NotImplementedError, /\APlease implement .*##{method}\Z/ )
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
%w[ push ].each do |method|
|
30
|
+
it "raises an error when calling unimplmented method #{method} taking some other object" do
|
31
|
+
lambda { @repo.send( method, Object.new ) }.should raise_error( NotImplementedError, /\APlease implement .*##{method}\Z/ )
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
it_should_behave_like 'includes Repository::Api'
|
36
|
+
end
|
37
|
+
|
38
|
+
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require File.expand_path( File.join( File.dirname(__FILE__), "..", "spec_helper.rb" ) )
|
2
|
+
require 'stickler/repository/index'
|
3
|
+
|
4
|
+
describe ::Stickler::Repository::Index do
|
5
|
+
|
6
|
+
before do
|
7
|
+
@index_me = File.join( @spec_dir, "tmp" )
|
8
|
+
FileUtils.mkdir_p( @index_me )
|
9
|
+
|
10
|
+
@specifications = Dir.glob( File.join( @specifications_dir, "*.gemspec" ) )
|
11
|
+
@specifications.each do |s|
|
12
|
+
FileUtils.cp( s, @index_me )
|
13
|
+
end
|
14
|
+
|
15
|
+
@index = ::Stickler::Repository::Index.new( @index_me )
|
16
|
+
end
|
17
|
+
|
18
|
+
after( :each ) do
|
19
|
+
FileUtils.rm_rf( @index_me )
|
20
|
+
end
|
21
|
+
|
22
|
+
it "indexes all the .gemspec files in the directory" do
|
23
|
+
@index.specs.size.should == @specifications.size
|
24
|
+
end
|
25
|
+
|
26
|
+
it "is able to notice changes in the index" do
|
27
|
+
@index.specs.size.should == @specifications.size
|
28
|
+
FileUtils.rm( File.join( @index_me, "foo-1.0.0.gemspec" ) )
|
29
|
+
@index.specs.size.should == ( @specifications.size - 1 )
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require File.expand_path( File.join( File.dirname(__FILE__), "..", "spec_helper.rb" ) )
|
2
|
+
require File.expand_path( File.join( File.dirname(__FILE__), "api_behavior.rb" ) )
|
3
|
+
|
4
|
+
require 'stickler/repository/local'
|
5
|
+
|
6
|
+
describe ::Stickler::Repository::Local do
|
7
|
+
|
8
|
+
before do
|
9
|
+
@repo_dir = File.join( @spec_dir, "tmp" )
|
10
|
+
@repo = ::Stickler::Repository::Local.new( @repo_dir )
|
11
|
+
end
|
12
|
+
|
13
|
+
after( :each ) do
|
14
|
+
FileUtils.rm_rf( @repo_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 == true
|
21
|
+
@repo.send( "#{sub_dir}_dir" ).should == 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 == 2
|
31
|
+
end
|
32
|
+
|
33
|
+
it_should_behave_like 'includes Repository::Api'
|
34
|
+
it_should_behave_like 'implements Repository::Api'
|
35
|
+
end
|
36
|
+
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require File.expand_path( File.join( File.dirname(__FILE__), "..", "spec_helper.rb" ) )
|
2
|
+
require File.expand_path( File.join( File.dirname(__FILE__), "api_behavior.rb" ) )
|
3
|
+
|
4
|
+
require 'stickler/repository/null'
|
5
|
+
|
6
|
+
describe ::Stickler::Repository::Null do
|
7
|
+
|
8
|
+
before do
|
9
|
+
@repo = ::Stickler::Repository::Null.new
|
10
|
+
end
|
11
|
+
|
12
|
+
it "sets the root_dir to the class name" do
|
13
|
+
@repo.root_dir.should == "Stickler::Repository::Null"
|
14
|
+
end
|
15
|
+
|
16
|
+
it_should_behave_like 'includes Repository::Api'
|
17
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require File.expand_path( File.join( File.dirname(__FILE__), "..", "spec_helper.rb" ) )
|
2
|
+
require File.expand_path( File.join( File.dirname(__FILE__), "api_behavior.rb" ) )
|
3
|
+
|
4
|
+
require 'stickler/repository/remote'
|
5
|
+
|
6
|
+
describe Stickler::Repository::Remote do
|
7
|
+
before do
|
8
|
+
@repo_uri = "http://localhost:6789/"
|
9
|
+
@repo = ::Stickler::Repository::Remote.new( @repo_uri )
|
10
|
+
end
|
11
|
+
|
12
|
+
it_should_behave_like 'includes Repository::Api'
|
13
|
+
|
14
|
+
describe "Using a live server" do
|
15
|
+
before do
|
16
|
+
@tmp_dir = File.join( @spec_dir, "tmp" )
|
17
|
+
FileUtils.mkdir_p( @tmp_dir )
|
18
|
+
|
19
|
+
@pid_file = File.join( @tmp_dir , "rack.pid" )
|
20
|
+
@ru_file = File.expand_path( File.join( @spec_dir, "..", "examples", "gemcutter_repo.ru" ) )
|
21
|
+
cmd = "rackup --port 6789 --pid #{@pid_file} --daemonize #{@ru_file}"
|
22
|
+
#puts cmd
|
23
|
+
system cmd
|
24
|
+
|
25
|
+
tries = 0
|
26
|
+
@acc = ::Resourceful::HttpAccessor.new
|
27
|
+
loop do
|
28
|
+
begin
|
29
|
+
@acc.resource( @repo_uri + "specs.#{Gem.marshal_version}.gz" ).get
|
30
|
+
#puts "rackup started with pid #{IO.read( @pid_file )}"
|
31
|
+
break
|
32
|
+
rescue => e
|
33
|
+
tries += 1
|
34
|
+
sleep tries * 0.1
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
after do
|
40
|
+
pid = IO.read( @pid_file ).to_i
|
41
|
+
Process.kill( 'KILL', pid )
|
42
|
+
#FileUtils.rm_rf( @tmp_dir, :verbose => true )
|
43
|
+
FileUtils.rm_rf( @tmp_dir )
|
44
|
+
end
|
45
|
+
|
46
|
+
it_should_behave_like 'implements Repository::Api'
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
data/spec/spec.opts
ADDED
data/spec/spec_helper.rb
CHANGED
@@ -1,5 +1,17 @@
|
|
1
|
-
require 'rubygems'
|
2
1
|
require 'spec'
|
2
|
+
require 'rack/test'
|
3
|
+
|
4
|
+
Spec::Runner.configure do |config|
|
5
|
+
config.include Rack::Test::Methods
|
6
|
+
|
7
|
+
config.before( :each ) do
|
8
|
+
@spec_dir = File.expand_path( File.dirname( __FILE__ ) )
|
9
|
+
@gem_root = File.join( @spec_dir, 'data' )
|
10
|
+
@specifications_dir = File.join( @gem_root, "specifications" )
|
11
|
+
@gems_dir = File.join( @gem_root, "gems" )
|
12
|
+
end
|
13
|
+
|
14
|
+
|
15
|
+
end
|
16
|
+
|
3
17
|
|
4
|
-
$: << File.expand_path( File.join( File.dirname( __FILE__ ), "..", "lib" ) )
|
5
|
-
require 'stickler'
|
@@ -0,0 +1,62 @@
|
|
1
|
+
require File.expand_path( File.join( File.dirname(__FILE__), "spec_helper.rb" ) )
|
2
|
+
|
3
|
+
require 'stickler/spec_lite'
|
4
|
+
|
5
|
+
describe Stickler::SpecLite do
|
6
|
+
before do
|
7
|
+
@specs = {
|
8
|
+
:ruby => Stickler::SpecLite.new( 'foo', '0.4.2' ),
|
9
|
+
:win => Stickler::SpecLite.new( 'bar', '1.0.1', "x86-mswin32" )
|
10
|
+
}
|
11
|
+
end
|
12
|
+
|
13
|
+
it "defaults to ruby platform" do
|
14
|
+
@specs[:ruby].platform.should == Gem::Platform::RUBY
|
15
|
+
end
|
16
|
+
|
17
|
+
{ [:ruby, 'file_name'] => "foo-0.4.2.gem",
|
18
|
+
[:ruby, 'spec_file_name'] => "foo-0.4.2.gemspec" ,
|
19
|
+
[:win , 'file_name'] => "bar-1.0.1-x86-mswin32.gem",
|
20
|
+
[:win , 'spec_file_name'] => "bar-1.0.1-x86-mswin32.gemspec",
|
21
|
+
}.each do |params, result|
|
22
|
+
platform, method = *params
|
23
|
+
it "on a #{platform} gem ##{method} is #{result}" do
|
24
|
+
@specs[platform].send( method ).should == result
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
it "has an array format" do
|
29
|
+
@specs[:win].to_a.should == [ 'bar', '1.0.1', 'x86-mswin32' ]
|
30
|
+
end
|
31
|
+
|
32
|
+
it "returns false when compared to something that does not resond to :name, :version or :platform" do
|
33
|
+
x = @specs[:ruby] =~ Object.new
|
34
|
+
x.should == false
|
35
|
+
end
|
36
|
+
|
37
|
+
it "can compare against anything that responds to :name, :version and :platform" do
|
38
|
+
class OSpec
|
39
|
+
attr_accessor :name
|
40
|
+
attr_accessor :version
|
41
|
+
attr_accessor :platform
|
42
|
+
end
|
43
|
+
|
44
|
+
o = OSpec.new
|
45
|
+
o.name = @specs[:ruby].name
|
46
|
+
o.version = @specs[:ruby].version
|
47
|
+
o.platform = @specs[:ruby].platform
|
48
|
+
r = @specs[:ruby] =~ o
|
49
|
+
r.should == true
|
50
|
+
end
|
51
|
+
|
52
|
+
it "can be compared against another spec" do
|
53
|
+
(@specs[:ruby] =~ @specs[:win]).should == false
|
54
|
+
end
|
55
|
+
|
56
|
+
it "can be sorted" do
|
57
|
+
list = @specs.values
|
58
|
+
alib = Stickler::SpecLite.new( 'alib', '4.2' )
|
59
|
+
list << alib
|
60
|
+
list.sort.should == [ alib, @specs[:win], @specs[:ruby] ]
|
61
|
+
end
|
62
|
+
end
|