Class: YARD::Server::LibraryVersion
- Inherits:
-
Object
- Object
- YARD::Server::LibraryVersion
- Defined in:
- lib/yard/server/library_version.rb
Overview
Instance Attribute Summary collapse
Instance Method Summary collapse
- #eql?(other) ⇒ Boolean (also: #==, #equal?)
- #gemspec ⇒ Object
- #hash ⇒ Object
-
#initialize(name, version = nil, yardoc = nil, source = :disk) ⇒ LibraryVersion
constructor
A new instance of LibraryVersion.
- #load_yardoc_from_disk ⇒ Object protected
- #load_yardoc_from_gem ⇒ Object protected
- #prepare! ⇒ Object
- #source_path_for_disk ⇒ Object protected
- #source_path_for_gem ⇒ Object protected
- #to_s(url_format = true) ⇒ Object
Constructor Details
#initialize(name, version = nil, yardoc = nil, source = :disk) ⇒ LibraryVersion
Returns 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
#name ⇒ Object
8 9 10 |
# File 'lib/yard/server/library_version.rb', line 8 def name @name end |
#source ⇒ Object
11 12 13 |
# File 'lib/yard/server/library_version.rb', line 11 def source @source end |
#source_path ⇒ Object
12 13 14 |
# File 'lib/yard/server/library_version.rb', line 12 def source_path @source_path end |
#version ⇒ Object
9 10 11 |
# File 'lib/yard/server/library_version.rb', line 9 def version @version end |
#yardoc_file ⇒ Object
10 11 12 |
# File 'lib/yard/server/library_version.rb', line 10 def yardoc_file @yardoc_file end |
Instance Method Details
#eql?(other) ⇒ Boolean 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 |
#gemspec ⇒ Object
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 |
#hash ⇒ Object
26 |
# File 'lib/yard/server/library_version.rb', line 26 def hash; to_s.hash end |
#load_yardoc_from_disk ⇒ Object (protected)
48 49 50 |
# File 'lib/yard/server/library_version.rb', line 48 def load_yardoc_from_disk nil end |
#load_yardoc_from_gem ⇒ Object (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 |
#prepare! ⇒ Object
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 |
#source_path_for_disk ⇒ Object (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 |
#source_path_for_gem ⇒ Object (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 |
#to_s(url_format = true) ⇒ Object
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 |