summaryrefslogtreecommitdiff
path: root/lib/rubygems/stub_specification.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/rubygems/stub_specification.rb')
-rw-r--r--lib/rubygems/stub_specification.rb39
1 files changed, 20 insertions, 19 deletions
diff --git a/lib/rubygems/stub_specification.rb b/lib/rubygems/stub_specification.rb
index b184d29d5e..ed07e8011f 100644
--- a/lib/rubygems/stub_specification.rb
+++ b/lib/rubygems/stub_specification.rb
@@ -15,35 +15,32 @@ class Gem::StubSpecification < Gem::BasicSpecification
end
class StubLine # :nodoc: all
- attr_reader :parts
+ attr_reader :name, :version, :platform, :require_paths
def initialize(data)
- @parts = data[PREFIX.length..-1].split(" ")
- end
-
- def name
- @parts[0]
- end
-
- def version
- Gem::Version.new @parts[1]
+ parts = data[PREFIX.length..-1].split(" ")
+ @name = parts[0]
+ @version = Gem::Version.new parts[1]
+ @platform = Gem::Platform.new parts[2]
+ @require_paths = parts.drop(3).join(" ").split("\0")
end
+ end
- def platform
- Gem::Platform.new @parts[2]
- end
+ def self.default_gemspec_stub filename
+ new filename, true
+ end
- def require_paths
- @parts[3..-1].join(" ").split("\0")
- end
+ def self.gemspec_stub filename
+ new filename, false
end
- def initialize(filename)
+ def initialize filename, default_gem
self.loaded_from = filename
@data = nil
@extensions = nil
@name = nil
@spec = nil
+ @default_gem = default_gem
end
##
@@ -57,6 +54,10 @@ class Gem::StubSpecification < Gem::BasicSpecification
end
end
+ def default_gem?
+ @default_gem
+ end
+
def build_extensions # :nodoc:
return if default_gem?
return if extensions.empty?
@@ -135,14 +136,14 @@ class Gem::StubSpecification < Gem::BasicSpecification
# Name of the gem
def name
- @name ||= data.name
+ data.name
end
##
# Platform of the gem
def platform
- @platform ||= data.platform
+ data.platform
end
##