Class: Gem::StubSpecification::StubLine

Inherits:
Object
  • Object
show all
Defined in:
lib/rubygems/stub_specification.rb

Overview

:nodoc: all

Constant Summary collapse

NO_EXTENSIONS =
[].freeze
REQUIRE_PATHS =

These are common require paths.

{ # :nodoc:
  'lib'  => 'lib'.freeze,
  'test' => 'test'.freeze,
  'ext'  => 'ext'.freeze,
}.freeze
REQUIRE_PATH_LIST =

These are common require path lists. This hash is used to optimize and consolidate require_path objects. Most specs just specify “lib” in their require paths, so lets take advantage of that by pre-allocating a require path list for that case.

{ # :nodoc:
  'lib' => ['lib'].freeze
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data, extensions) ⇒ StubLine

Returns a new instance of StubLine.



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/rubygems/stub_specification.rb', line 37

def initialize(data, extensions)
  parts          = data[PREFIX.length..-1].split(" ".freeze, 4)
  @name          = parts[0].freeze
  @version       = if Gem::Version.correct?(parts[1])
                     Gem::Version.new(parts[1])
                   else
                     Gem::Version.new(0)
                   end

  @platform      = Gem::Platform.new parts[2]
  @extensions    = extensions
  @full_name     = if platform == Gem::Platform::RUBY
                     "#{name}-#{version}"
                   else
                     "#{name}-#{version}-#{platform}"
                   end

  path_list = parts.last
  @require_paths = REQUIRE_PATH_LIST[path_list] || path_list.split("\0".freeze).map! do |x|
    REQUIRE_PATHS[x] || x
  end
end

Instance Attribute Details

#extensionsObject (readonly)

Returns the value of attribute extensions



17
18
19
# File 'lib/rubygems/stub_specification.rb', line 17

def extensions
  @extensions
end

#full_nameObject (readonly)

Returns the value of attribute full_name



17
18
19
# File 'lib/rubygems/stub_specification.rb', line 17

def full_name
  @full_name
end

#nameObject (readonly)

Returns the value of attribute name



17
18
19
# File 'lib/rubygems/stub_specification.rb', line 17

def name
  @name
end

#platformObject (readonly)

Returns the value of attribute platform



17
18
19
# File 'lib/rubygems/stub_specification.rb', line 17

def platform
  @platform
end

#require_pathsObject (readonly)

Returns the value of attribute require_paths



17
18
19
# File 'lib/rubygems/stub_specification.rb', line 17

def require_paths
  @require_paths
end

#versionObject (readonly)

Returns the value of attribute version



17
18
19
# File 'lib/rubygems/stub_specification.rb', line 17

def version
  @version
end