class YARD::LinkStdlib::RubySource
Light utility object around a Ruby {Gem::Version} used to download and extract it's source code to the {LinkStdlib.tmp_dir}.
Attributes
version[R]
Ruby version.
@return [Gem::Version]
Public Class Methods
ensure(version)
click to toggle source
Ensure the version's source is downloaded and extracted.
@example
YARD::LinkStdlib::RubySource.ensure '2.5.1'
@param [Gem::Version || to_s
] version
The Ruby version you need present.
@return [RubySource]
The utility object instance.
# File lib/yard/link_stdlib/ruby_source.rb, line 65 def self.ensure version new( version ).ensure end
list()
click to toggle source
# File lib/yard/link_stdlib/ruby_source.rb, line 70 def self.list LinkStdlib.tmp_dir.entries. select { |filename| filename.to_s =~ /\Aruby\-\d+\_\d+\_\d+\z/ }. map { |filename| new filename.to_s.sub( /\Aruby\-/, '' ).gsub( '_', '.' ) }. sort end
make_missing=(value)
click to toggle source
# File lib/yard/link_stdlib/ruby_source.rb, line 49 def self.make_missing= value @make_missing = !!value end
make_missing?()
click to toggle source
new(version)
click to toggle source
Make a new instance for a version.
@param [Gem::Version || to_s
] version
The Ruby version to work with.
# File lib/yard/link_stdlib/ruby_source.rb, line 97 def initialize version @version = Gem::Version.new version end
Public Instance Methods
<=>(other)
click to toggle source
# File lib/yard/link_stdlib/ruby_source.rb, line 199 def <=> other version <=> other.version end
download(force: false)
click to toggle source
# File lib/yard/link_stdlib/ruby_source.rb, line 131 def download force: false if force log.info "FORCING download of Ruby #{ version } tarball..." elsif tar_path.exist? log.info "Ruby #{ version } tarball present." return self else log.info "Downloading Ruby #{ version } tarball..." end response = LinkStdlib.http_get url tar_path.open( "wb" ) { |file| file.write response.body } self # For chaining end
ensure()
click to toggle source
# File lib/yard/link_stdlib/ruby_source.rb, line 169 def ensure if src_path.exist? # Nothing to do, source is already in place log.info "Source for Ruby #{ version } is present." return end unless self.class.make_missing? raise RuntimeError, "Object map for Ruby version #{ version } missing; " + "not configured to auto-make" end # Download unless the tar's already there download # And we must need to extract it since the src path wasn't there extract self # For chaining end
extract(force: false)
click to toggle source
# File lib/yard/link_stdlib/ruby_source.rb, line 148 def extract force: false if force log.info "FORCING extraction of Ruby #{ version } source tarball..." elsif src_path.exist? log.info "Ruby #{ version } source present." return self else log.info "Extracting #{ tar_path } -> #{ src_path }..." end LinkStdlib.system! \ 'tar', '-x', # extract '-f', tar_path.to_s, # file '-C', LinkStdlib.tmp_dir.to_s # directory (chdir) log.info "Source for Ruby #{ version } extracted to #{ src_path }." self # For chaining end
inspect()
click to toggle source
# File lib/yard/link_stdlib/ruby_source.rb, line 196 def inspect; to_s; end
ruby_style_version()
click to toggle source
src_path()
click to toggle source
# File lib/yard/link_stdlib/ruby_source.rb, line 126 def src_path @src_path ||= LinkStdlib.tmp_dir.join "ruby-#{ ruby_style_version }" end
tar_filename()
click to toggle source
# File lib/yard/link_stdlib/ruby_source.rb, line 116 def tar_filename @tar_filename ||= "ruby-#{ ruby_style_version }.tar.gz" end
tar_path()
click to toggle source
# File lib/yard/link_stdlib/ruby_source.rb, line 121 def tar_path @tar_path ||= LinkStdlib.tmp_dir.join tar_filename end
to_s()
click to toggle source
# File lib/yard/link_stdlib/ruby_source.rb, line 192 def to_s %{#<YARD::LinkStdlib::RubySource "#{ version }">} end
url()
click to toggle source
# File lib/yard/link_stdlib/ruby_source.rb, line 110 def url @url ||= "https://github.com/ruby/ruby/archive/v#{ ruby_style_version }.tar.gz" end