stickler 2.1.4 → 2.2.2

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.asciidoc CHANGED
@@ -2,6 +2,12 @@ Stickler Changelog
2
2
  ==================
3
3
  Jeremy Hinegardner <jeremy@hinegardner.org>
4
4
 
5
+
6
+ Version 2.2.2 - 2012-02-13
7
+ --------------------------
8
+ * Updated dependencies to latest versions
9
+ * Added supoort for HTTP Basic Auth in the client
10
+
5
11
  Version 2.1.4 - 2011-09-09
6
12
  --------------------------
7
13
  * Update dependencies to newest version
data/Rakefile CHANGED
@@ -1,5 +1,5 @@
1
1
  begin
2
- USING_BONES_VERSION = '3.7.1'
2
+ USING_BONES_VERSION = '3.7.3'
3
3
  require 'bones'
4
4
  rescue LoadError
5
5
  load 'tasks/contribute.rake'
@@ -19,7 +19,7 @@ Bones {
19
19
  url 'http://www.copiousfreetime.org/projects/stickler'
20
20
  version Stickler::VERSION
21
21
 
22
- ruby_opts %w[-W0 -rubygems]
22
+ ruby_opts %w[-w -rubygems]
23
23
  readme_file 'README.asciidoc'
24
24
  ignore_file '.bnsignore'
25
25
  history_file 'HISTORY.asciidoc'
@@ -41,18 +41,18 @@ _
41
41
  # I'm explicitly controlling the version of bones.
42
42
 
43
43
 
44
- depend_on 'sinatra' , '~> 1.2.6'
45
- depend_on 'addressable', '~> 2.2.4'
46
- depend_on 'excon' , '~> 0.6.6'
44
+ depend_on 'sinatra' , '~> 1.3.2'
45
+ depend_on 'addressable', '~> 2.2.6'
46
+ depend_on 'excon' , '~> 0.9.5'
47
47
  depend_on 'trollop' , '~> 1.16.2'
48
- depend_on 'logging' , '~> 1.6.1'
48
+ depend_on 'logging' , '~> 1.6.2'
49
49
 
50
- depend_on 'rake' , '~> 0.9.2'
50
+ depend_on 'rake' , '~> 0.9.2.2', :development => true
51
51
  depend_on 'bones' , "~> #{USING_BONES_VERSION}", :development => true
52
52
  depend_on 'rack-test' , '~> 0.6.1', :development => true
53
53
  depend_on 'bones-extras', '~> 1.3.0', :development => true
54
54
  depend_on 'builder' , '~> 3.0.0', :development => true
55
- depend_on 'rspec' , '~> 2.6.0', :development => true
55
+ depend_on 'rspec' , '~> 2.8.0', :development => true
56
56
  }
57
57
 
58
58
  # Sorry Tim, I need to manage my own bones version
@@ -0,0 +1,15 @@
1
+ #-----------------------------------------------------------------------
2
+ # Example rackup file for an entire stickler stack with authorization
3
+ #
4
+ # -*- vim: set ft=ruby: -*-
5
+ #-----------------------------------------------------------------------
6
+ $:.unshift File.expand_path( File.join( File.dirname(__FILE__), "..", "lib" ) )
7
+
8
+ require 'stickler'
9
+
10
+ tmp = File.expand_path( File.join( File.dirname( __FILE__ ), "..", "spec", "data" ) )
11
+
12
+ use Rack::Auth::Basic, 'Secure Stickler' do |u,p|
13
+ (u == "stickler") and (p == "secret")
14
+ end
15
+ run Stickler::Server.new( tmp ).app
@@ -63,9 +63,9 @@ module Stickler::Middleware
63
63
 
64
64
  server_path = Stickler::Paths.lib_path( "stickler", "server" )
65
65
 
66
- set :views, File.join( server_path, "views" )
67
- set :public, File.join( server_path, "public" )
68
- set :static, true
66
+ set :views, File.join( server_path, "views" )
67
+ set :public_folder, File.join( server_path, "public" )
68
+ set :static, true
69
69
 
70
70
  def initialize( app, opts = {} )
71
71
  @app = app
@@ -0,0 +1,22 @@
1
+ require 'addressable/uri'
2
+
3
+ module Stickler::Repository
4
+ #
5
+ # Generate the authentication for basic auth request
6
+ #
7
+ class BasicAuthenticator
8
+ def self.handles?( uri )
9
+ %w[ http https ].include?( uri.scheme ) and uri.user and uri.password
10
+ end
11
+
12
+ def initialize( uri )
13
+ @user = uri.user
14
+ @password = uri.password
15
+ @cred = ["#{@user}:#{@password}"].pack('m').tr("\n", '')
16
+ end
17
+
18
+ def credentials
19
+ "Basic #{@cred}"
20
+ end
21
+ end
22
+ end
@@ -30,7 +30,7 @@ module Stickler::Repository
30
30
 
31
31
  # the directory containing the .gem files
32
32
  attr_reader :gems_dir
33
-
33
+
34
34
  # the directory containing the .gemspec files
35
35
  attr_reader :specifications_dir
36
36
 
@@ -22,8 +22,8 @@ module Stickler::Repository
22
22
  @local_repo = ::Stickler::Repository::Local.new( root_dir )
23
23
  @remote_repos = {}
24
24
  end
25
- def_delegators :@local_repo, :uri, :gems_uri, :uri_for_gem, :search_for,
26
- :push, :delete, :get, :open,
25
+ def_delegators :@local_repo, :uri, :gems_uri, :uri_for_gem, :search_for,
26
+ :push, :delete, :get, :open,
27
27
  :specs, :latest_specs, :root_dir,
28
28
  :last_modified_time, :full_path_to_gem,
29
29
  :full_path_to_specification
@@ -3,6 +3,7 @@ require 'stickler/repository'
3
3
  require 'stickler/version'
4
4
  require 'stickler/repository/api'
5
5
  require 'stickler/repository/rubygems_authenticator'
6
+ require 'stickler/repository/basic_authenticator'
6
7
  require 'stringio'
7
8
 
8
9
  module ::Stickler::Repository
@@ -16,8 +17,8 @@ module ::Stickler::Repository
16
17
  attr_reader :authenticator
17
18
 
18
19
  def initialize( repo_uri, options = {} )
19
- @authenticator = options[:authenticator] || Stickler::Repository::RubygemsAuthenticator.new
20
20
  @uri = Addressable::URI.parse( ensure_http( ensure_trailing_slash( repo_uri ) ) )
21
+ @authenticator = load_authenticator( @uri )
21
22
  @specs_list = nil
22
23
  end
23
24
 
@@ -139,6 +140,17 @@ module ::Stickler::Repository
139
140
  return uri
140
141
  end
141
142
 
143
+ def authenticator_class( uri )
144
+ [ RubygemsAuthenticator, BasicAuthenticator ].find { |a| a.handles?( uri ) }
145
+ end
146
+
147
+ def load_authenticator( uri )
148
+ if klass = authenticator_class( uri ) then
149
+ return klass.new( uri )
150
+ end
151
+ return nil
152
+ end
153
+
142
154
  def full_uri_to_gem( spec )
143
155
  gems_uri.join( spec.file_name )
144
156
  end
@@ -200,7 +212,7 @@ module ::Stickler::Repository
200
212
  def download_resource( resource )
201
213
  resource_request( resource, :method => :get, :expects => [200] ).body
202
214
  rescue Excon::Errors::Error => e
203
- puts e.inspect
215
+ $stderr.puts e.inspect
204
216
  return false
205
217
  end
206
218
 
@@ -234,19 +246,20 @@ module ::Stickler::Repository
234
246
  begin
235
247
  resource.connection[:headers]['User-Agent'] = "Stickler Client v#{Stickler::VERSION}"
236
248
  resource.connection[:headers].delete('Authorization')
237
- if authenticator.handles?( resource.connection[:scheme], resource.connection[:host] ) then
249
+ if authenticator then
238
250
  resource.connection[:headers]['Authorization'] = authenticator.credentials
239
251
  end
240
252
  trys += 1
241
- #puts "Making request #{resource.connection.inspect} with extra params #{params.inspect}"
242
253
  resource.request( params )
254
+ rescue Excon::Errors::Unauthorized => unauth
255
+ uri = "#{unauth.request[:scheme]}://#{unauth.request[:host]}:#{unauth.request[:port]}#{unauth.request[:path]}"
256
+ raise Stickler::Repository::Error, "Not authorized to access #{uri}. Authorization needed for: #{unauth.response.headers['WWW-Authenticate']}"
243
257
  rescue Excon::Errors::MovedPermanently, Excon::Errors::Found,
244
258
  Excon::Errors::SeeOther, Excon::Errors::TemporaryRedirect => redirect
245
259
  # follow a redirect, it is only allowable to follow redirects from a GET or
246
260
  # HEAD request. Only follow a few times though.
247
261
  raise redirect unless [ :get, :head ].include?( redirect.request[:method] )
248
262
  raise redirect if trys > 5
249
- #puts "Redirecting to #{redirect.response.headers['Location']}"
250
263
  resource = Excon::Connection.new( redirect.response.headers['Location'],
251
264
  { :headers => resource.connection[:headers],
252
265
  :query => resource.connection[:headers],
@@ -11,6 +11,15 @@ module Stickler::Repository
11
11
  @rubygems_uri ||= Addressable::URI.parse( "https://rubygems.org" )
12
12
  end
13
13
 
14
+ def self.handles?( uri )
15
+ return ( uri.scheme == rubygems_uri.scheme ) &&
16
+ ( uri.host == rubygems_uri.host )
17
+ end
18
+
19
+ def initialize( uri )
20
+ # do nothing
21
+ end
22
+
14
23
  def credentials
15
24
  Gem.configuration.rubygems_api_key
16
25
  end
@@ -19,9 +28,5 @@ module Stickler::Repository
19
28
  self.class.rubygems_uri
20
29
  end
21
30
 
22
- def handles?( scheme, host )
23
- return ( scheme == rubygems_uri.scheme ) &&
24
- ( host == rubygems_uri.host )
25
- end
26
31
  end
27
32
  end
@@ -11,8 +11,8 @@ module Stickler
11
11
  module Version
12
12
 
13
13
  MAJOR = 2
14
- MINOR = 1
15
- BUILD = 4
14
+ MINOR = 2
15
+ BUILD = 2
16
16
 
17
17
  def self.to_ary
18
18
  [ MAJOR, MINOR, BUILD ]
@@ -1,4 +1,3 @@
1
- require 'spec_helper'
2
1
  require 'rack/test'
3
2
  require 'rubygems/user_interaction'
4
3
  require 'rubygems/indexer'
@@ -3,6 +3,41 @@ require File.expand_path( File.join( File.dirname(__FILE__), "api_behavior.rb" )
3
3
 
4
4
  require 'stickler/repository/remote'
5
5
 
6
+ class SticklerTestServer
7
+ def initialize( spec_dir, ru_file )
8
+ @spec_dir = spec_dir
9
+ @repo_uri = "http://localhost:6789/"
10
+ @tmp_dir = File.join( @spec_dir, "tmp" )
11
+ FileUtils.mkdir_p( @tmp_dir )
12
+
13
+ @pid_file = File.join( @tmp_dir , "rack.pid" )
14
+ @ru_file = File.expand_path( File.join( @spec_dir, "..", "examples", ru_file ) )
15
+ @cmd = "rackup --port 6789 --pid #{@pid_file} --daemonize #{@ru_file}"
16
+ end
17
+
18
+ def start
19
+ system @cmd
20
+ tries = 0
21
+ loop do
22
+ begin
23
+ Excon.get( @repo_uri + "specs.#{Gem.marshal_version}.gz" )
24
+ #puts "rackup started with pid #{IO.read( @pid_file )}"
25
+ break
26
+ rescue => e
27
+ tries += 1
28
+ sleep tries * 0.1
29
+ end
30
+ end
31
+ end
32
+
33
+ def stop
34
+ pid = IO.read( @pid_file ).to_i
35
+ Process.kill( 'KILL', pid )
36
+ #FileUtils.rm_rf( @tmp_dir, :verbose => true )
37
+ FileUtils.rm_rf( @tmp_dir )
38
+ end
39
+ end
40
+
6
41
  describe Stickler::Repository::Remote do
7
42
  before do
8
43
  @repo_uri = "http://localhost:6789/"
@@ -13,36 +48,41 @@ describe Stickler::Repository::Remote do
13
48
 
14
49
  describe "Using a live server" do
15
50
  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
- loop do
27
- begin
28
- Excon.get( @repo_uri + "specs.#{Gem.marshal_version}.gz" )
29
- #puts "rackup started with pid #{IO.read( @pid_file )}"
30
- break
31
- rescue => e
32
- tries += 1
33
- sleep tries * 0.1
34
- end
35
- end
51
+ @server = SticklerTestServer.new( @spec_dir, "gemcutter_repo.ru" )
52
+ @server.start
36
53
  end
37
54
 
38
55
  after do
39
- pid = IO.read( @pid_file ).to_i
40
- Process.kill( 'KILL', pid )
41
- #FileUtils.rm_rf( @tmp_dir, :verbose => true )
42
- FileUtils.rm_rf( @tmp_dir )
56
+ @server.stop
43
57
  end
44
58
 
45
59
  it_should_behave_like 'implements Repository::Api'
46
60
  end
61
+
62
+ describe "Using a live authenticated server" do
63
+ before do
64
+ @server = SticklerTestServer.new( @spec_dir, "auth_repo.ru" )
65
+ @server.start
66
+ @foo_gem_local_path = File.join( @gems_dir, "foo-1.0.0.gem" )
67
+ @foo_spec = Stickler::SpecLite.new( 'foo', '1.0.0' )
68
+ @foo_digest = Digest::SHA1.hexdigest( IO.read( @foo_gem_local_path ) )
69
+ end
70
+
71
+ after do
72
+ @server.stop
73
+ end
74
+
75
+ it "should raise an an authentication denied error" do
76
+ repo = ::Stickler::Repository::Remote.new( "http://localhost:6789/")
77
+ lambda { repo.get( @foo_spec ) }.should raise_error( ::Stickler::Repository::Error, /Not authorized/ )
78
+ end
79
+
80
+ it "should connect with proper authentication" do
81
+ repo = ::Stickler::Repository::Remote.new( "http://stickler:secret@localhost:6789/")
82
+ data = repo.get( @foo_spec )
83
+ sha1 = Digest::SHA1.hexdigest( data )
84
+ sha1.should == @foo_digest
85
+ end
86
+ end
47
87
  end
48
88
 
metadata CHANGED
@@ -5,9 +5,9 @@ version: !ruby/object:Gem::Version
5
5
  prerelease:
6
6
  segments:
7
7
  - 2
8
- - 1
9
- - 4
10
- version: 2.1.4
8
+ - 2
9
+ - 2
10
+ version: 2.2.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jeremy Hinegardner
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-09-10 00:00:00 Z
18
+ date: 2012-02-13 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: sinatra
@@ -25,12 +25,12 @@ dependencies:
25
25
  requirements:
26
26
  - - ~>
27
27
  - !ruby/object:Gem::Version
28
- hash: 19
28
+ hash: 31
29
29
  segments:
30
30
  - 1
31
+ - 3
31
32
  - 2
32
- - 6
33
- version: 1.2.6
33
+ version: 1.3.2
34
34
  type: :runtime
35
35
  version_requirements: *id001
36
36
  - !ruby/object:Gem::Dependency
@@ -41,12 +41,12 @@ dependencies:
41
41
  requirements:
42
42
  - - ~>
43
43
  - !ruby/object:Gem::Version
44
- hash: 15
44
+ hash: 11
45
45
  segments:
46
46
  - 2
47
47
  - 2
48
- - 4
49
- version: 2.2.4
48
+ - 6
49
+ version: 2.2.6
50
50
  type: :runtime
51
51
  version_requirements: *id002
52
52
  - !ruby/object:Gem::Dependency
@@ -57,12 +57,12 @@ dependencies:
57
57
  requirements:
58
58
  - - ~>
59
59
  - !ruby/object:Gem::Version
60
- hash: 11
60
+ hash: 49
61
61
  segments:
62
62
  - 0
63
- - 6
64
- - 6
65
- version: 0.6.6
63
+ - 9
64
+ - 5
65
+ version: 0.9.5
66
66
  type: :runtime
67
67
  version_requirements: *id003
68
68
  - !ruby/object:Gem::Dependency
@@ -89,12 +89,12 @@ dependencies:
89
89
  requirements:
90
90
  - - ~>
91
91
  - !ruby/object:Gem::Version
92
- hash: 13
92
+ hash: 11
93
93
  segments:
94
94
  - 1
95
95
  - 6
96
- - 1
97
- version: 1.6.1
96
+ - 2
97
+ version: 1.6.2
98
98
  type: :runtime
99
99
  version_requirements: *id005
100
100
  - !ruby/object:Gem::Dependency
@@ -105,13 +105,14 @@ dependencies:
105
105
  requirements:
106
106
  - - ~>
107
107
  - !ruby/object:Gem::Version
108
- hash: 63
108
+ hash: 11
109
109
  segments:
110
110
  - 0
111
111
  - 9
112
112
  - 2
113
- version: 0.9.2
114
- type: :runtime
113
+ - 2
114
+ version: 0.9.2.2
115
+ type: :development
115
116
  version_requirements: *id006
116
117
  - !ruby/object:Gem::Dependency
117
118
  name: bones
@@ -121,12 +122,12 @@ dependencies:
121
122
  requirements:
122
123
  - - ~>
123
124
  - !ruby/object:Gem::Version
124
- hash: 25
125
+ hash: 29
125
126
  segments:
126
127
  - 3
127
128
  - 7
128
- - 1
129
- version: 3.7.1
129
+ - 3
130
+ version: 3.7.3
130
131
  type: :development
131
132
  version_requirements: *id007
132
133
  - !ruby/object:Gem::Dependency
@@ -185,12 +186,12 @@ dependencies:
185
186
  requirements:
186
187
  - - ~>
187
188
  - !ruby/object:Gem::Version
188
- hash: 23
189
+ hash: 47
189
190
  segments:
190
191
  - 2
191
- - 6
192
+ - 8
192
193
  - 0
193
- version: 2.6.0
194
+ version: 2.8.0
194
195
  type: :development
195
196
  version_requirements: *id011
196
197
  description: |
@@ -225,16 +226,16 @@ extra_rdoc_files:
225
226
  - lib/stickler/server/views/layout.erb
226
227
  files:
227
228
  - .gitignore
229
+ - .rvmrc
228
230
  - HISTORY.asciidoc
229
231
  - LICENSE
230
232
  - README.asciidoc
231
233
  - Rakefile
232
234
  - TODO.asciidoc
233
- - asciidoc-output/docbook-xsl.css
234
- - asciidoc-output/man/docbook-xsl.css
235
235
  - bin/stickler
236
236
  - bin/stickler-passenger-config
237
237
  - bin/stickler-server
238
+ - examples/auth_repo.ru
238
239
  - examples/config.ru
239
240
  - examples/fetch-a-gem
240
241
  - examples/gemcutter_repo.ru
@@ -263,6 +264,7 @@ files:
263
264
  - lib/stickler/paths.rb
264
265
  - lib/stickler/repository.rb
265
266
  - lib/stickler/repository/api.rb
267
+ - lib/stickler/repository/basic_authenticator.rb
266
268
  - lib/stickler/repository/index.rb
267
269
  - lib/stickler/repository/local.rb
268
270
  - lib/stickler/repository/mirror.rb
@@ -282,12 +284,8 @@ files:
282
284
  - lib/stickler/spec_lite.rb
283
285
  - lib/stickler/version.rb
284
286
  - man/asciidoc.conf
285
- - man/docbook-xsl.css
286
- - man/stickler-passenger-config.1
287
287
  - man/stickler-passenger-config.asciidoc
288
- - man/stickler-server.1
289
288
  - man/stickler-server.asciidoc
290
- - man/stickler.1
291
289
  - man/stickler.asciidoc
292
290
  - spec/data/gemcutter/gems/foo-1.0.0.gem
293
291
  - spec/data/gemcutter/specifications/foo-1.0.0.gemspec
@@ -316,10 +314,6 @@ files:
316
314
  - tasks/bundler.rake
317
315
  - tasks/contribute.rake
318
316
  - tasks/man.rake
319
- - work/mirror/gems/hitimes-1.1.1.gem
320
- - work/mirror/gems/rails-3.0.3.gem
321
- - work/mirror/specifications/hitimes-1.1.1.gemspec
322
- - work/mirror/specifications/rails-3.0.3.gemspec
323
317
  homepage: http://www.copiousfreetime.org/projects/stickler
324
318
  licenses: []
325
319
 
@@ -350,7 +344,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
350
344
  requirements: []
351
345
 
352
346
  rubyforge_project: stickler
353
- rubygems_version: 1.8.7
347
+ rubygems_version: 1.8.15
354
348
  signing_key:
355
349
  specification_version: 3
356
350
  summary: Stickler is a tool to organize and maintain an internal gem repository.