Class: Gem::StubSpecification
Relationships & Source Files | |
Namespace Children | |
Classes:
| |
Super Chains via Extension / Inclusion / Inheritance | |
Class Chain:
self,
BasicSpecification ,
Deprecate
|
|
Instance Chain:
self,
BasicSpecification
|
|
Inherits: |
Gem::BasicSpecification
|
Defined in: | lib/rubygems/stub_specification.rb |
Overview
StubSpecification
reads the stub: line from the gemspec. This prevents us having to eval the entire gemspec in order to find out certain information.
Constant Summary
-
OPEN_MODE =
Internal use only
# File 'lib/rubygems/stub_specification.rb', line 13"r:UTF-8:-"
-
PREFIX =
Internal use only
# File 'lib/rubygems/stub_specification.rb', line 10"# stub: "
Class Method Summary
- .default_gemspec_stub(filename, base_dir, gems_dir)
- .gemspec_stub(filename, base_dir, gems_dir)
- .new(filename, base_dir, gems_dir, default_gem) ⇒ StubSpecification constructor
BasicSpecification
- Inherited
Deprecate
- Extended
deprecate | Simple deprecation method that deprecates #name by wrapping it up in a dummy method. |
rubygems_deprecate | Simple deprecation method that deprecates #name by wrapping it up in a dummy method. |
rubygems_deprecate_command | Deprecation method to deprecate Rubygems commands. |
skip_during | Temporarily turn off warnings. |
Instance Attribute Summary
-
#activated? ⇒ Boolean
readonly
True when this gem has been activated.
- #base_dir readonly
- #default_gem? ⇒ Boolean readonly
- #gems_dir readonly
- #missing_extensions? ⇒ Boolean readonly
-
#stubbed? ⇒ Boolean
readonly
Is there a stub line present for this StubSpecification?
-
#valid? ⇒ Boolean
readonly
Is this
StubSpecification
valid? i.e.
BasicSpecification
- Inherited
#activated? | True when the gem has been activated. |
#base_dir | Returns the full path to the base gem directory. |
#default_gem?, | |
#extension_dir | Returns full path to the directory where gem’s extensions are installed. |
#full_gem_path | The full path to the gem (install path + full name). |
#ignored? | Return true if this spec should be ignored because it’s missing extensions. |
#loaded_from | The path this gemspec was loaded from. |
#stubbed? | Whether this specification is stubbed - i.e. |
#have_extensions?, | |
#base_dir= | Allows installation of extensions for git: gems. |
#extension_dir= | Sets the directory where extensions for this gem will be installed. |
#full_gem_path= | Allows correct activation of git: and path: gems. |
#ignored= | Is this specification ignored for activation purposes? |
Instance Method Summary
-
#extensions
Extensions for this gem.
- #full_name
-
#name
Name of the gem.
-
#platform
Platform
of the gem. -
#spec
(also: #to_spec)
The full
Specification
for this gem, loaded from evalling its gemspec. -
#to_spec
Alias for #spec.
-
#version
Version
of the gem. -
#data
private
If the gemspec contains a stubline, returns a
StubLine
instance. - #loaded_spec private
- #<=>(other) Internal use only
- #==(other) (also: #eql?) Internal use only
- #build_extensions Internal use only
-
#eql?(other)
Internal use only
Alias for #==.
- #hash Internal use only
- #raw_require_paths Internal use only
- #sort_obj Internal use only
BasicSpecification
- Inherited
#base_dir_priority | Gems higher up in |
#contains_requirable_file? | Return true if this spec can require |
#datadir | The path to the data directory for this gem. |
#default_gem_priority | Regular gems take precedence over default gems. |
#extensions_dir | Returns path to the extensions directory. |
#full_name | Returns the full name (name-version) of this |
#full_name_with_location | Returns the full name of this |
#full_require_paths | Full paths in the gem to add to |
#gem_dir | Returns the full path to this spec’s gem directory. |
#gems_dir | Returns the full path to the gems directory containing this spec’s gem directory. |
#lib_dirs_glob | Returns a string usable in |
#matches_for_glob | Return all files in this gem that match for |
#name | Name of the gem. |
#platform |
|
#plugins | Returns the list of plugins in this spec. |
#require_paths | Paths in the gem to add to |
#source_paths | Returns the paths to the source files for use with analysis and documentation tools. |
#this, | |
#to_fullpath | Full path of the target library file. |
#to_spec | Return a |
#version |
|
#have_file?, | |
#gem_build_complete_path | The path to the gem.build_complete file within the extension install directory. |
#internal_init, #raw_require_paths, #find_full_gem_path |
Constructor Details
.new(filename, base_dir, gems_dir, default_gem) ⇒ StubSpecification
Class Method Details
.default_gemspec_stub(filename, base_dir, gems_dir)
[ GitHub ].gemspec_stub(filename, base_dir, gems_dir)
[ GitHub ]Instance Attribute Details
#activated? ⇒ Boolean
(readonly)
True when this gem has been activated
# File 'lib/rubygems/stub_specification.rb', line 85
def activated? @activated ||= !loaded_spec.nil? end
#base_dir (readonly)
[ GitHub ]# File 'lib/rubygems/stub_specification.rb', line 68
attr_reader :base_dir, :gems_dir
#default_gem? ⇒ Boolean
(readonly)
[ GitHub ]
# File 'lib/rubygems/stub_specification.rb', line 89
def default_gem? @default_gem end
#gems_dir (readonly)
[ GitHub ]# File 'lib/rubygems/stub_specification.rb', line 68
attr_reader :base_dir, :gems_dir
#missing_extensions? ⇒ Boolean
(readonly)
[ GitHub ]
# File 'lib/rubygems/stub_specification.rb', line 142
def missing_extensions? return false if default_gem? return false if extensions.empty? return false if File.exist? gem_build_complete_path to_spec.missing_extensions? end
#stubbed? ⇒ Boolean
(readonly)
Is there a stub line present for this StubSpecification?
#valid? ⇒ Boolean
(readonly)
Is this StubSpecification
valid? i.e. have we found a stub line, OR does the filename contain a valid gemspec?
# File 'lib/rubygems/stub_specification.rb', line 195
def valid? data end
Instance Method Details
#<=>(other)
#==(other) Also known as: #eql?
#build_extensions
# File 'lib/rubygems/stub_specification.rb', line 93
def build_extensions # :nodoc: return if default_gem? return if extensions.empty? to_spec.build_extensions end
#data (private)
If the gemspec contains a stubline, returns a StubSpecification::StubLine
instance. Otherwise returns the full Specification
.
# File 'lib/rubygems/stub_specification.rb', line 104
def data unless @data begin saved_lineno = $. Gem.open_file loaded_from, OPEN_MODE do |file| file.readline # discard encoding line stubline = file.readline if stubline.start_with?(PREFIX) extline = file.readline extensions = if extline.delete_prefix!(PREFIX) extline.chomp! extline.split "\0" else StubLine::NO_EXTENSIONS end stubline.chomp! # readline(chomp: true) allocates 3x as much as .readline.chomp! @data = StubLine.new stubline, extensions end rescue EOFError end ensure $. = saved_lineno end end @data ||= to_spec end
#eql?(other)
Alias for #==.
# File 'lib/rubygems/stub_specification.rb', line 213
alias_method :eql?, :== # :nodoc:
#extensions
Extensions for this gem
# File 'lib/rubygems/stub_specification.rb', line 167
def extensions data.extensions end
#full_name
[ GitHub ]# File 'lib/rubygems/stub_specification.rb', line 178
def full_name data.full_name end
#hash
#loaded_spec (private)
[ GitHub ]# File 'lib/rubygems/stub_specification.rb', line 229
def loaded_spec spec = Gem.loaded_specs[name] return unless spec && spec.version == version && spec.default_gem? == default_gem? spec end
#name
Name of the gem
# File 'lib/rubygems/stub_specification.rb', line 153
def name data.name end
#platform
Platform
of the gem
# File 'lib/rubygems/stub_specification.rb', line 160
def platform data.platform end
#raw_require_paths
# File 'lib/rubygems/stub_specification.rb', line 138
def raw_require_paths # :nodoc: data.require_paths end
#sort_obj
#spec Also known as: #to_spec
The full Specification
for this gem, loaded from evalling its gemspec
# File 'lib/rubygems/stub_specification.rb', line 185
def spec @spec ||= loaded_spec if @data @spec ||= Gem::Specification.load(loaded_from) end
#to_spec
Alias for #spec.
# File 'lib/rubygems/stub_specification.rb', line 189
alias_method :to_spec, :spec
#version
Version
of the gem
# File 'lib/rubygems/stub_specification.rb', line 174
def version data.version end