Skip to content

Commit

Permalink
Patch #20610, gemspec backwards compatibility, installed location for…
Browse files Browse the repository at this point in the history
… query -d

git-svn-id: http://rubygems.rubyforge.org/svn/trunk@1765 3d4018f9-ac1a-0410-99e9-8a154d859a19
  • Loading branch information
drbrain committed Jun 16, 2008
1 parent 644819c commit f27e2b2
Show file tree
Hide file tree
Showing 9 changed files with 254 additions and 114 deletions.
7 changes: 7 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@
format before running =~ again. Fixes bug reported by Chad Wooley.
* lib/rubygems/commands/stale_command.rb: `gem stale` lists gems by
last access time. Patch #20593 by Aaron Patterson.
* lib/rubygems/setup.rb: Add --vendor and --destdir to setup.rb for
packagers. Patch #20610 by Richard Brown. Don't look for stub
files to remove any more.
* lib/rubygems/specification.rb: Bump specification version and be
backwards compatible with type 2 specs.
* lib/rubygems/commands/query_command.rb: Add installed location to
details for installed gems.

2008-06-09 Eric Hodel <drbrain@segment7.net>

Expand Down
4 changes: 3 additions & 1 deletion lib/rubygems.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@ module Gem
:ruby_install_name => RbConfig::CONFIG["ruby_install_name"],
:ruby_version => RbConfig::CONFIG["ruby_version"],
:sitedir => RbConfig::CONFIG["sitedir"],
:sitelibdir => RbConfig::CONFIG["sitelibdir"]
:sitelibdir => RbConfig::CONFIG["sitelibdir"],
:vendordir => RbConfig::CONFIG["vendordir"] ,
:vendorlibdir => RbConfig::CONFIG["vendorlibdir"]
)

DIRECTORIES = %w[cache doc gems specifications] unless defined?(DIRECTORIES)
Expand Down
14 changes: 14 additions & 0 deletions lib/rubygems/commands/query_command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,20 @@ def output_query_results(spec_tuples)
entry << "\n" << format_text("Homepage: #{spec.homepage}", 68, 4)
end

if spec.loaded_from then
if matching_tuples.length == 1 then
loaded_from = File.dirname File.dirname(spec.loaded_from)
entry << "\n" << " Installed at: #{loaded_from}"
else
label = 'Installed at'
matching_tuples.each do |(_,version,_,s),|
loaded_from = File.dirname File.dirname(s.loaded_from)
entry << "\n" << " #{label} (#{version}): #{loaded_from}"
label = ' ' * label.length
end
end
end

entry << "\n\n" << format_text(spec.summary, 68, 4)
end
output << entry
Expand Down
23 changes: 21 additions & 2 deletions lib/rubygems/dependency.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,36 @@
# The Dependency class holds a Gem name and a Gem::Requirement

class Gem::Dependency

##
# Valid dependency types.
#--
# When this list is updated, be sure to change
# Gem::Specification::CURRENT_SPECIFICATION_VERSION as well.

TYPES = [
:development,
:runtime,
:development
]

##
# Dependency name or regular expression.

attr_accessor :name

##
# Dependency type.

attr_reader :type

##
# Dependent versions.

attr_writer :version_requirements

##
# Orders dependencies by name only.

def <=>(other)
[@name] <=> [other.name]
end
Expand Down Expand Up @@ -92,7 +111,7 @@ def =~(other)
version_requirements.satisfied_by? version
end

def hash
def hash # :nodoc:
name.hash + type.hash + version_requirements.hash
end

Expand Down
16 changes: 15 additions & 1 deletion lib/rubygems/platform.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
require 'rubygems'

##
# Available list of platforms for targeting Gem installations.
#

class Gem::Platform

@local = nil
Expand Down Expand Up @@ -122,11 +123,20 @@ def to_s
to_a.compact.join '-'
end

##
# Is +other+ equal to this platform? Two platforms are equal if they have
# the same CPU, OS and version.

def ==(other)
self.class === other and
@cpu == other.cpu and @os == other.os and @version == other.version
end

##
# Does +other+ match this platform? Two platforms match if they have the
# same CPU, or either has a CPU of 'universal', they have the same OS, and
# they have the same version, or either has no version.

def ===(other)
return nil unless Gem::Platform === other

Expand All @@ -140,6 +150,10 @@ def ===(other)
(@version.nil? or other.version.nil? or @version == other.version)
end

##
# Does +other+ match this platform? If +other+ is a String it will be
# converted to a Gem::Platform first. See #=== for matching rules.

def =~(other)
case other
when Gem::Platform then # nop
Expand Down
40 changes: 33 additions & 7 deletions lib/rubygems/specification.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,22 +40,32 @@ module Gem
#
class Specification

##
# Allows deinstallation of gems with legacy platforms.

attr_accessor :original_platform # :nodoc:

# ------------------------- Specification version contstants.

##
# The the version number of a specification that does not specify one
# (i.e. RubyGems 0.7 or earlier).

NONEXISTENT_SPECIFICATION_VERSION = -1

##
# The specification version applied to any new Specification instances
# created. This should be bumped whenever something in the spec format
# changes.
CURRENT_SPECIFICATION_VERSION = 2
#--
# When updating this number, be sure to also update #to_ruby.

CURRENT_SPECIFICATION_VERSION = 3

##
# An informal list of changes to the specification. The highest-valued
# key should be equal to the CURRENT_SPECIFICATION_VERSION.

SPECIFICATION_VERSION_HISTORY = {
-1 => ['(RubyGems versions up to and including 0.7 did not have versioned specifications)'],
1 => [
Expand All @@ -66,10 +76,13 @@ class Specification
'Added "required_rubygems_version"',
'Now forward-compatible with future versions',
],
3 => [
'Added dependency types',
],
}

# :stopdoc:
MARSHAL_FIELDS = { -1 => 16, 1 => 16, 2 => 16 }
MARSHAL_FIELDS = { -1 => 16, 1 => 16, 2 => 16, 3 => 16 }

now = Time.at(Time.now.to_i)
TODAY = now - ((now.to_i + now.gmt_offset) % 86400)
Expand Down Expand Up @@ -794,9 +807,11 @@ def yaml_initialize(tag, vals) # :nodoc:
self.platform = Gem::Platform.new @platform
end

##
# Returns a Ruby code representation of this specification, such that it
# can be eval'ed and reconstruct the same specification later. Attributes
# that still have their default values are omitted.

def to_ruby
mark_version
result = []
Expand Down Expand Up @@ -832,12 +847,23 @@ def to_ruby
end
end

result << nil unless dependencies.empty?
unless dependencies.empty? then
result << nil
result << ' if s.respond_to? :specification_version and s.specification_version >= 3 then'

dependencies.each do |dep|
version_reqs_param = dep.requirements_list.inspect
dep.instance_variable_set :@type, :runtime if dep.type.nil? # HACK
result << " s.add_#{dep.type}_dependency(%q<#{dep.name}>, #{version_reqs_param})"
dependencies.each do |dep|
version_reqs_param = dep.requirements_list.inspect
dep.instance_variable_set :@type, :runtime if dep.type.nil? # HACK
result << " s.add_#{dep.type}_dependency(%q<#{dep.name}>, #{version_reqs_param})"
end

result << ' else'

dependencies.each do |dep|
version_reqs_param = dep.requirements_list.inspect
result << " s.add_dependency(%q<#{dep.name}>, #{version_reqs_param})"
end
result << ' end'
end

result << "end"
Expand Down
Loading

0 comments on commit f27e2b2

Please sign in to comment.