Permalink
Browse files

ruby -w unused variables and others

  • Loading branch information...
1 parent b800580 commit e97655c9d90f30efdf773d44c1b9046b50618a06 @copiousfreetime committed Mar 9, 2013
View
2 lib/stickler/middleware/gemcutter.rb
@@ -53,7 +53,7 @@ def initialize( app = nil, options = {} )
# gemcutter yank
delete '/api/v1/gems/yank' do
spec = Stickler::SpecLite.new( params[:gem_name], params[:version] )
- if s = @repo.yank( spec ) then
+ if @repo.yank( spec ) then
logger.info( "Yanked #{spec.full_name}" )
return "Yanked #{spec.full_name}"
else
View
2 lib/stickler/middleware/helpers.rb
@@ -104,6 +104,6 @@ def specs_grouped_by_name( spec_list )
end
return by_name
end
- end
+ end
end
end
View
2 lib/stickler/middleware/local.rb
@@ -23,7 +23,7 @@ module Stickler::Middleware
# use Stickler::Middleware::Local, :repo_root => '/path/to/repository',
# :serve_indexes => true
#
- class Local < Index
+ class Local < ::Stickler::Middleware::Index
def initialize( app = nil, opts = {} )
super( app, opts )
# overwrite the repo that is set in the parent
View
42 lib/stickler/repository/remote.rb
@@ -74,7 +74,7 @@ def get( spec )
def push( path )
spec = speclite_from_gem_file( path )
raise Stickler::Repository::Error, "gem #{spec.full_name} already exists in remote repository" if remote_gem_file_exist?( spec )
- resp = resource_request( push_resource, :body => IO.read( path ) )
+ resource_request( push_resource, :body => IO.read( path ) )
return spec
rescue Excon::Errors::Error => e
msg = "Failure pushing #{path} to remote repository : response code => #{e.response.status}, response message => '#{e.response.body}'"
@@ -87,7 +87,7 @@ def push( path )
def yank( spec )
return nil unless remote_gem_file_exist?( spec )
query = { :gem_name => spec.name, :version => spec.version.to_s }
- resp = resource_request( yank_resource, :query => query )
+ resource_request( yank_resource, :query => query )
return full_uri_to_gem( spec )
rescue Excon::Errors::Error => e
raise Stickler::Repository::Error, "Failure yanking: #{e.inspect}"
@@ -99,11 +99,10 @@ def yank( spec )
def unyank( spec )
return nil unless remote_gem_file_exist?( spec )
query = { :spec_name => spec.name, :version => spec.version.to_s }
- resp = resource_request( unyank_resource, :query => query )
+ resource_request( unyank_resource, :query => query )
true
rescue Excon::Errors::Error => e
- # raise Stickler::Repository::Error, "Failure unyanking: #{e.inspect}"
- []
+ raise Stickler::Repository::Error, "Failure unyanking: #{e.inspect}"
end
#
@@ -113,7 +112,7 @@ def delete( spec )
return false unless remote_gem_file_exist?( spec )
resource_request( gem_resource( spec ), :method => :delete )
return true
- rescue Excon::Errors::Error => e
+ rescue Excon::Errors::Error
return false
end
@@ -179,11 +178,10 @@ def push_uri
end
def push_resource
- unless @push_resource then
+ @push_resource ||= begin
params = { :method => :post, :headers => { 'Content-Type' => 'application/octet-stream' }, :expects => [ 201, 200 ] }
- @push_resource = Excon.new( push_uri.to_s, params )
+ Excon.new( push_uri.to_s, params )
end
- return @push_resource
end
def yank_uri
@@ -195,23 +193,21 @@ def unyank_uri
end
def yank_resource
- unless @yank_resource then
+ @yank_resource ||= begin
params = { :method => :delete,
:headers => { 'Content-Type' => 'application/x-www-form-urlencoded' },
:expects => [200] }
- @yank_resource = Excon.new( yank_uri.to_s, params )
+ Excon.new( yank_uri.to_s, params )
end
- return @yank_resource
end
def unyank_resource
- unless @unyank_resource then
+ @unyank_resource ||= begin
params = { :method => :post,
:headers => { 'Content-Type' => 'application/x-www-form-urlencoded' },
:expects => [200] }
- @unyank_resource = Excon.new( unyank_uri.to_s, params )
+ Excon.new( unyank_uri.to_s, params )
end
- return @unyank_resource
end
def gem_resource( spec )
@@ -247,9 +243,9 @@ def remote_gem_file_exist?( spec )
end
def remote_uri_exist?( uri )
- rc = resource_request( Excon.new( uri.to_s ), :method => :head, :expects => [200] )
+ resource_request( Excon.new( uri.to_s ), :method => :head, :expects => [200] )
return true
- rescue Excon::Errors::Error => e
+ rescue Excon::Errors::Error
return false
end
@@ -269,10 +265,10 @@ def speclite_from_specification( spec )
def resource_request( resource, params = {} )
trys = 0
begin
- resource.connection[:headers]['User-Agent'] = "Stickler Client v#{Stickler::VERSION}"
- resource.connection[:headers].delete('Authorization')
+ resource.data[:headers]['User-Agent'] = "Stickler Client v#{Stickler::VERSION}"
+ resource.data[:headers].delete('Authorization')
if authenticator then
- resource.connection[:headers]['Authorization'] = authenticator.credentials
+ resource.data[:headers]['Authorization'] = authenticator.credentials
end
trys += 1
resource.request( params )
@@ -286,9 +282,9 @@ def resource_request( resource, params = {} )
raise redirect unless [ :get, :head ].include?( redirect.request[:method] )
raise redirect if trys > 5
resource = Excon::Connection.new( redirect.response.headers['Location'],
- { :headers => resource.connection[:headers],
- :query => resource.connection[:headers],
- :method => resource.connection[:method] } )
+ { :headers => resource.data[:headers],
+ :query => resource.data[:headers],
+ :method => resource.data[:method] } )
retry
end
end
View
2 lib/stickler/repository/remote_mirror.rb
@@ -13,7 +13,7 @@ class RemoteMirror < Remote
# repository
def mirror( spec, upstream_host )
raise Stickler::Repository::Error, "gem #{spec.full_name} already exists in remote repository" if remote_gem_file_exist?( spec )
- resp = resource_request( mirror_resource( spec, upstream_host ) )
+ resource_request( mirror_resource( spec, upstream_host ) )
end
private
View
2 lib/stickler/server.rb
@@ -22,5 +22,5 @@ def app
run Sinatra::Base
end
end
- end
+ end
end
View
4 spec/repository/api_behavior.rb
@@ -60,8 +60,8 @@
it "deletes a gem from the repo" do
@repo.search_for( @foo_spec ).should be_empty
@repo.push( @foo_gem_local_path )
- @repo.search_for( @foo_spec ).size.should == 1
- @repo.delete( @foo_spec ).should == true
+ @repo.search_for( @foo_spec ).size.should eq 1
+ @repo.delete( @foo_spec ).should eq true
@repo.search_for( @foo_spec ).should be_empty
end
View
18 spec/repository/index_spec.rb
@@ -19,28 +19,28 @@
end
it "indexes all the .gemspec files in the directory" do
- @index.specs.size.should == @specifications.size
+ @index.specs.size.should eq @specifications.size
end
it "is able to notice changes in the index" do
- @index.specs.size.should == @specifications.size
+ @index.specs.size.should eq @specifications.size
FileUtils.rm( File.join( @index_me, "foo-1.0.0.gemspec" ) )
- @index.specs.size.should == ( @specifications.size - 1 )
+ @index.specs.size.should eq( @specifications.size - 1 )
end
it "knows just the latest specs" do
- @index.latest_specs.size.should == (@specifications.size - 1)
- @index.latest_specs.collect { |s| s.full_name }.sort.should == %w[ bar-1.0.0 baz-3.1.4 baz-3.1.4-java foo-1.0.0 ]
+ @index.latest_specs.size.should eq(@specifications.size - 1)
+ @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 ])
end
it "knows the pre-release specs" do
- @index.prerelease_specs.size.should == 1
- @index.prerelease_specs.first.full_name.should == "foo-2.0.0a"
+ @index.prerelease_specs.size.should eq 1
+ @index.prerelease_specs.first.full_name.should eq "foo-2.0.0a"
end
it "knows the released specs" do
- @index.released_specs.size.should == 4
- @index.released_specs.collect { |s| s.full_name }.sort.should == %w[ bar-1.0.0 baz-3.1.4 baz-3.1.4-java foo-1.0.0 ]
+ @index.released_specs.size.should eq 4
+ @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 ])
end
end
View
16 spec/repository/local_spec.rb
@@ -17,8 +17,8 @@
%w[ gems specifications ].each do |sub_dir|
it "creates #{sub_dir} directory" do
new_dir = File.join( @repo_dir , sub_dir ) + File::SEPARATOR
- File.directory?( new_dir ).should == true
- @repo.send( "#{sub_dir}_dir" ).should == new_dir
+ File.directory?( new_dir ).should eq true
+ @repo.send( "#{sub_dir}_dir" ).should eq new_dir
end
end
@@ -27,20 +27,20 @@
Dir.glob( File.join( @gems_dir, "*.gem" ) ).each do |gem|
@repo.push( gem )
end
- @repo.specs.size.should == 5
+ @repo.specs.size.should eq 5
end
it "two instances with the same repo dir are the same object" do
repo2 = ::Stickler::Repository::Local.new( File.join(@repos_dir, '1') )
- repo2.object_id.should == @repo.object_id
- ::Stickler::Repository::Local.repos.size.should == 1
+ repo2.object_id.should eq @repo.object_id
+ ::Stickler::Repository::Local.repos.size.should eq 1
end
it "keeps track of all the repository instances" do
- repo2 = ::Stickler::Repository::Local.new( File.join(@repos_dir, "2" ) )
- repo3 = ::Stickler::Repository::Local.new( File.join(@repos_dir, "3" ) )
- ::Stickler::Repository::Local.repos.size.should == 3
+ ::Stickler::Repository::Local.new( File.join(@repos_dir, "2" ) )
+ ::Stickler::Repository::Local.new( File.join(@repos_dir, "3" ) )
+ ::Stickler::Repository::Local.repos.size.should eq 3
end
it_should_behave_like 'includes Repository::Api'
View
2 spec/repository/remote_spec.rb
@@ -21,7 +21,7 @@ def start
Excon.get( @repo_uri + "specs.#{Gem.marshal_version}.gz" )
#puts "rackup started with pid #{IO.read( @pid_file )}"
break
- rescue => e
+ rescue
tries += 1
sleep tries * 0.1
end

0 comments on commit e97655c

Please sign in to comment.