Skip to content

Commit

Permalink
move getting gem specifications to gem-empty/specification
Browse files Browse the repository at this point in the history
  • Loading branch information
mpapis committed Dec 20, 2013
1 parent 8b69465 commit c6a0405
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 16 deletions.
10 changes: 2 additions & 8 deletions lib/gem-empty/command.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
require 'gem-empty/specification'
require 'rubygems/command_manager'
require 'rubygems/uninstaller'
require 'rubygems/version'
Expand Down Expand Up @@ -44,16 +45,9 @@ def execute(options = {})

def gem_dir_specs
@gem_dir_specs ||=
installed_gems.select do |spec|
GemEmpty::Specification.installed_gems.select do |spec|
File.exists?( File.join( Gem.dir, 'gems', spec.full_name ) )
end
end

def installed_gems
if Gem::VERSION > '1.8' then
Gem::Specification.to_a
else
Gem.source_index.map{|name,spec| spec}
end
end
end
16 changes: 8 additions & 8 deletions lib/gem-empty/specification.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
module GemEmpty
module Specification
def self.installed_gems
if Gem::VERSION > '1.8' then
Gem::Specification.to_a
else
Gem.source_index.map{|name,spec| spec}
end
end
def self.find(name = "gem-empty")
@gem_empty_spec ||=
if Gem::Specification.respond_to?(:find_by_name)
Gem::Specification.find_by_name(name)
else
Gem.source_index.find_name(name).last
end
rescue Gem::LoadError
nil
@gem_empty_spec ||= installed_gems.find{|spec| spec.name == name}
end
def self.version
find ? find.version.to_s : nil
Expand Down

0 comments on commit c6a0405

Please sign in to comment.