Class: Gem::StubSpecification
- Inherits:
-
BasicSpecification
- Object
- BasicSpecification
- Gem::StubSpecification
- Defined in:
- lib/rubygems/stub_specification.rb
Overview
Gem::StubSpecification reads the stub: line from the gemspec. This prevents us having to eval the entire gemspec in order to find out certain information.
Defined Under Namespace
Classes: StubLine
Constant Summary collapse
- PREFIX =
:nodoc:
"# stub: "
- OPEN_MODE =
:nodoc:
if Object.const_defined? :Encoding then 'r:UTF-8:-' else 'r' end
Instance Attribute Summary
Attributes inherited from BasicSpecification
#base_dir, #extension_dir, #full_gem_path, #loaded_from
Instance Method Summary collapse
-
#activated? ⇒ Boolean
True when this gem has been activated.
-
#build_extensions ⇒ Object
:nodoc:.
-
#extensions ⇒ Object
Extensions for this gem.
-
#find_full_gem_path ⇒ Object
If a gem has a stub specification it doesn’t need to bother with compatibility with original_name gems.
-
#full_require_paths ⇒ Object
Full paths in the gem to add to
$LOAD_PATH
when this gem is activated. -
#initialize(filename) ⇒ StubSpecification
constructor
A new instance of StubSpecification.
-
#name ⇒ Object
Name of the gem.
-
#platform ⇒ Object
Platform of the gem.
-
#require_paths ⇒ Object
Require paths of the gem.
-
#stubbed? ⇒ Boolean
Is there a stub line present for this StubSpecification?.
-
#to_spec ⇒ Object
The full Gem::Specification for this gem, loaded from evalling its gemspec.
-
#valid? ⇒ Boolean
Is this StubSpecification valid? i.e.
-
#version ⇒ Object
Version of the gem.
Methods inherited from BasicSpecification
#contains_requirable_file?, #default_gem?, default_specifications_dir, #extensions_dir, #full_name, #gem_dir, #gems_dir, #raw_require_paths
Constructor Details
#initialize(filename) ⇒ StubSpecification
Returns a new instance of StubSpecification.
41 42 43 44 45 46 |
# File 'lib/rubygems/stub_specification.rb', line 41 def initialize(filename) self.loaded_from = filename @data = nil @extensions = nil @spec = nil end |
Instance Method Details
#activated? ⇒ Boolean
True when this gem has been activated
51 52 53 54 |
# File 'lib/rubygems/stub_specification.rb', line 51 def activated? loaded = Gem.loaded_specs[name] loaded && loaded.version == version end |
#build_extensions ⇒ Object
:nodoc:
56 57 58 59 60 61 |
# File 'lib/rubygems/stub_specification.rb', line 56 def build_extensions # :nodoc: return if default_gem? return if extensions.empty? to_spec.build_extensions end |
#extensions ⇒ Object
Extensions for this gem
94 95 96 97 98 99 100 |
# File 'lib/rubygems/stub_specification.rb', line 94 def extensions return @extensions if @extensions data # load @extensions end |
#find_full_gem_path ⇒ Object
If a gem has a stub specification it doesn’t need to bother with compatibility with original_name gems. It was installed with the normalized name.
107 108 109 110 111 |
# File 'lib/rubygems/stub_specification.rb', line 107 def find_full_gem_path # :nodoc: path = File. File.join gems_dir, full_name path.untaint path end |
#full_require_paths ⇒ Object
Full paths in the gem to add to $LOAD_PATH
when this gem is activated.
117 118 119 120 121 |
# File 'lib/rubygems/stub_specification.rb', line 117 def full_require_paths @require_paths ||= data.require_paths super end |
#name ⇒ Object
Name of the gem
126 127 128 |
# File 'lib/rubygems/stub_specification.rb', line 126 def name @name ||= data.name end |
#platform ⇒ Object
Platform of the gem
133 134 135 |
# File 'lib/rubygems/stub_specification.rb', line 133 def platform @platform ||= data.platform end |
#require_paths ⇒ Object
Require paths of the gem
140 141 142 143 144 |
# File 'lib/rubygems/stub_specification.rb', line 140 def require_paths @require_paths ||= data.require_paths super end |
#stubbed? ⇒ Boolean
Is there a stub line present for this StubSpecification?
171 172 173 |
# File 'lib/rubygems/stub_specification.rb', line 171 def stubbed? data.is_a? StubLine end |
#to_spec ⇒ Object
The full Gem::Specification for this gem, loaded from evalling its gemspec
149 150 151 |
# File 'lib/rubygems/stub_specification.rb', line 149 def to_spec @spec ||= Gem::Specification.load(loaded_from) end |
#valid? ⇒ Boolean
Is this StubSpecification valid? i.e. have we found a stub line, OR does the filename contain a valid gemspec?
157 158 159 |
# File 'lib/rubygems/stub_specification.rb', line 157 def valid? data end |
#version ⇒ Object
Version of the gem
164 165 166 |
# File 'lib/rubygems/stub_specification.rb', line 164 def version @version ||= data.version end |