Class: YARD::Server::LibraryVersion
- Inherits:
-
Object
- Object
- YARD::Server::LibraryVersion
- Defined in:
- lib/yard/server/library_version.rb
Overview
Instance Attribute Summary (collapse)
-
- (Object) name
Returns the value of attribute name.
-
- (Object) source
Returns the value of attribute source.
-
- (Object) source_path
Returns the value of attribute source_path.
-
- (Object) version
Returns the value of attribute version.
-
- (Object) yardoc_file
Returns the value of attribute yardoc_file.
Instance Method Summary (collapse)
- - (Boolean) eql?(other) (also: #==, #equal?)
- - (Object) gemspec
- - (Object) hash
-
- (LibraryVersion) initialize(name, version = nil, yardoc = nil, source = :disk)
constructor
A new instance of LibraryVersion.
- - (Object) load_yardoc_from_disk protected
- - (Object) load_yardoc_from_gem protected
- - (Object) prepare!
- - (Object) source_path_for_disk protected
- - (Object) source_path_for_gem protected
- - (Object) to_s(url_format = true)
Constructor Details
- (LibraryVersion) initialize(name, version = nil, yardoc = nil, source = :disk)
A new instance of LibraryVersion
14 15 16 17 18 19 20 |
# File 'lib/yard/server/library_version.rb', line 14 def initialize(name, version = nil, yardoc = nil, source = :disk) self.name = name self.yardoc_file = yardoc self.version = version self.source = source self.source_path = load_source_path end |
Instance Attribute Details
- (Object) name
Returns the value of attribute name
8 9 10 |
# File 'lib/yard/server/library_version.rb', line 8 def name @name end |
- (Object) source
Returns the value of attribute source
11 12 13 |
# File 'lib/yard/server/library_version.rb', line 11 def source @source end |
- (Object) source_path
Returns the value of attribute source_path
12 13 14 |
# File 'lib/yard/server/library_version.rb', line 12 def source_path @source_path end |
- (Object) version
Returns the value of attribute version
9 10 11 |
# File 'lib/yard/server/library_version.rb', line 9 def version @version end |
- (Object) yardoc_file
Returns the value of attribute yardoc_file
10 11 12 |
# File 'lib/yard/server/library_version.rb', line 10 def yardoc_file @yardoc_file end |
Instance Method Details
- (Boolean) eql?(other) Also known as: ==, equal?
28 29 30 31 |
# File 'lib/yard/server/library_version.rb', line 28 def eql?(other) other.is_a?(LibraryVersion) && other.name == name && other.version == version && other.yardoc_file == yardoc_file end |
- (Object) gemspec
41 42 43 44 |
# File 'lib/yard/server/library_version.rb', line 41 def gemspec ver = version ? "= #{version}" : ">= 0" Gem.source_index.find_name(name, ver).first end |
- (Object) hash
26 |
# File 'lib/yard/server/library_version.rb', line 26 def hash; to_s.hash end |
- (Object) load_yardoc_from_disk (protected)
48 49 50 |
# File 'lib/yard/server/library_version.rb', line 48 def load_yardoc_from_disk nil end |
- (Object) load_yardoc_from_gem (protected)
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/yard/server/library_version.rb', line 52 def load_yardoc_from_gem require 'rubygems' ver = version ? "= #{version}" : ">= 0" self.yardoc_file = Registry.yardoc_file_for_gem(name, ver) unless yardoc_file && File.directory?(yardoc_file) Thread.new do # Build gem docs on demand log.debug "Building gem docs for #{to_s(false)}" CLI::Gems.run(name, ver) self.yardoc_file = Registry.yardoc_file_for_gem(name, ver) FileUtils.touch(File.join(yardoc_file, 'complete')) end end unless yardoc_file && File.exist?(File.join(yardoc_file, 'complete')) raise LibraryNotPreparedError end end |
- (Object) prepare!
35 36 37 38 39 |
# File 'lib/yard/server/library_version.rb', line 35 def prepare! return if yardoc_file meth = "load_yardoc_from_#{source}" send(meth) if respond_to?(meth) end |
- (Object) source_path_for_disk (protected)
70 71 72 |
# File 'lib/yard/server/library_version.rb', line 70 def source_path_for_disk File.dirname(yardoc_file) if yardoc_file end |
- (Object) source_path_for_gem (protected)
74 75 76 |
# File 'lib/yard/server/library_version.rb', line 74 def source_path_for_gem gemspec.full_gem_path if gemspec end |
- (Object) to_s(url_format = true)
22 23 24 |
# File 'lib/yard/server/library_version.rb', line 22 def to_s(url_format = true) version ? "#{name}#{url_format ? '/' : '-'}#{version}" : "#{name}" end |