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:
"r:UTF-8:-"
Instance Attribute Summary collapse
-
#base_dir ⇒ Object
readonly
Returns the value of attribute base_dir.
-
#gems_dir ⇒ Object
readonly
Returns the value of attribute gems_dir.
Attributes inherited from BasicSpecification
#extension_dir, #full_gem_path, #ignored, #loaded_from
Class Method Summary collapse
- .default_gemspec_stub(filename, base_dir, gems_dir) ⇒ Object
- .gemspec_stub(filename, base_dir, gems_dir) ⇒ Object
Instance Method Summary collapse
-
#<=>(other) ⇒ Object
:nodoc:.
-
#==(other) ⇒ Object
(also: #eql?)
:nodoc:.
-
#activated? ⇒ Boolean
True when this gem has been activated.
-
#build_extensions ⇒ Object
:nodoc:.
- #default_gem? ⇒ Boolean
-
#extensions ⇒ Object
Extensions for this gem.
- #full_name ⇒ Object
-
#hash ⇒ Object
:nodoc:.
-
#initialize(filename, base_dir, gems_dir, default_gem) ⇒ StubSpecification
constructor
A new instance of StubSpecification.
- #missing_extensions? ⇒ Boolean
-
#name ⇒ Object
Name of the gem.
-
#platform ⇒ Object
Platform of the gem.
-
#raw_require_paths ⇒ Object
:nodoc:.
-
#sort_obj ⇒ Object
:nodoc:.
-
#spec ⇒ Object
(also: #to_spec)
The full Gem::Specification for this gem, loaded from evalling its gemspec.
-
#stubbed? ⇒ Boolean
Is there a stub line present for this StubSpecification?.
-
#valid? ⇒ Boolean
Is this StubSpecification valid? i.e.
-
#version ⇒ Object
Version of the gem.
Methods inherited from BasicSpecification
#base_dir_priority, #contains_requirable_file?, #datadir, #default_gem_priority, default_specifications_dir, #extensions_dir, #full_name_with_location, #full_require_paths, #gem_build_complete_path, #gem_dir, #ignored?, #internal_init, #lib_dirs_glob, #matches_for_glob, #plugins, #require_paths, #source_paths, #this, #to_fullpath
Methods included from Deprecate
#deprecate, next_rubygems_major_version, rubygems_deprecate, rubygems_deprecate_command, skip, skip=, skip_during
Constructor Details
#initialize(filename, base_dir, gems_dir, default_gem) ⇒ StubSpecification
Returns a new instance of StubSpecification.
70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/rubygems/stub_specification.rb', line 70 def initialize(filename, base_dir, gems_dir, default_gem) super() self.loaded_from = filename @data = nil @name = nil @spec = nil @base_dir = base_dir @gems_dir = gems_dir @default_gem = default_gem end |
Instance Attribute Details
#base_dir ⇒ Object (readonly)
Returns the value of attribute base_dir.
68 69 70 |
# File 'lib/rubygems/stub_specification.rb', line 68 def base_dir @base_dir end |
#gems_dir ⇒ Object (readonly)
Returns the value of attribute gems_dir.
68 69 70 |
# File 'lib/rubygems/stub_specification.rb', line 68 def gems_dir @gems_dir end |
Class Method Details
.default_gemspec_stub(filename, base_dir, gems_dir) ⇒ Object
60 61 62 |
# File 'lib/rubygems/stub_specification.rb', line 60 def self.default_gemspec_stub(filename, base_dir, gems_dir) new filename, base_dir, gems_dir, true end |
.gemspec_stub(filename, base_dir, gems_dir) ⇒ Object
64 65 66 |
# File 'lib/rubygems/stub_specification.rb', line 64 def self.gemspec_stub(filename, base_dir, gems_dir) new filename, base_dir, gems_dir, false end |
Instance Method Details
#<=>(other) ⇒ Object
:nodoc:
219 220 221 |
# File 'lib/rubygems/stub_specification.rb', line 219 def <=>(other) # :nodoc: sort_obj <=> other.sort_obj end |
#==(other) ⇒ Object Also known as: eql?
:nodoc:
206 207 208 209 210 211 |
# File 'lib/rubygems/stub_specification.rb', line 206 def ==(other) # :nodoc: self.class === other && name == other.name && version == other.version && platform == other.platform end |
#activated? ⇒ Boolean
True when this gem has been activated
85 86 87 |
# File 'lib/rubygems/stub_specification.rb', line 85 def activated? @activated ||= !loaded_spec.nil? end |
#build_extensions ⇒ Object
:nodoc:
93 94 95 96 97 98 |
# 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 |
#default_gem? ⇒ Boolean
89 90 91 |
# File 'lib/rubygems/stub_specification.rb', line 89 def default_gem? @default_gem end |
#extensions ⇒ Object
Extensions for this gem
167 168 169 |
# File 'lib/rubygems/stub_specification.rb', line 167 def extensions data.extensions end |
#full_name ⇒ Object
178 179 180 |
# File 'lib/rubygems/stub_specification.rb', line 178 def full_name data.full_name end |
#hash ⇒ Object
:nodoc:
215 216 217 |
# File 'lib/rubygems/stub_specification.rb', line 215 def hash # :nodoc: name.hash ^ version.hash ^ platform.hash end |
#missing_extensions? ⇒ Boolean
142 143 144 145 146 147 148 |
# 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 |
#name ⇒ Object
Name of the gem
153 154 155 |
# File 'lib/rubygems/stub_specification.rb', line 153 def name data.name end |
#platform ⇒ Object
Platform of the gem
160 161 162 |
# File 'lib/rubygems/stub_specification.rb', line 160 def platform data.platform end |
#raw_require_paths ⇒ Object
:nodoc:
138 139 140 |
# File 'lib/rubygems/stub_specification.rb', line 138 def raw_require_paths # :nodoc: data.require_paths end |
#sort_obj ⇒ Object
:nodoc:
223 224 225 |
# File 'lib/rubygems/stub_specification.rb', line 223 def sort_obj # :nodoc: [name, version, Gem::Platform.sort_priority(platform)] end |
#spec ⇒ Object Also known as: to_spec
The full Gem::Specification for this gem, loaded from evalling its gemspec
185 186 187 188 |
# File 'lib/rubygems/stub_specification.rb', line 185 def spec @spec ||= loaded_spec if @data @spec ||= Gem::Specification.load(loaded_from) end |
#stubbed? ⇒ Boolean
Is there a stub line present for this StubSpecification?
202 203 204 |
# File 'lib/rubygems/stub_specification.rb', line 202 def stubbed? data.is_a? StubLine end |
#valid? ⇒ Boolean
Is this StubSpecification valid? i.e. have we found a stub line, OR does the filename contain a valid gemspec?
195 196 197 |
# File 'lib/rubygems/stub_specification.rb', line 195 def valid? data end |
#version ⇒ Object
Version of the gem
174 175 176 |
# File 'lib/rubygems/stub_specification.rb', line 174 def version data.version end |