Class: YARD::CLI::Gems
| Relationships & Source Files | |
| Super Chains via Extension / Inclusion / Inheritance | |
| Class Chain: 
          self,
           Command | |
| Instance Chain: 
          self,
           Command | |
| Inherits: | YARD::CLI::Command 
 | 
| Defined in: | lib/yard/cli/gems.rb | 
Overview
Class Method Summary
Instance Method Summary
- #description
- 
    
      #run(*args)  ⇒ void 
    
    Runs the commandline utility, parsing arguments and generating ::YARDindexes for gems.
- #add_gems(gems) private
- 
    
      #build_gems  
    
    private
    Builds .yardoc files for all non-existing gems. 
- 
    
      #optparse(*args)  
    
    private
    Parses options. 
Command - Inherited
Constructor Details
    .new  ⇒ Gems 
  
# File 'lib/yard/cli/gems.rb', line 6
def initialize @rebuild = false @gems = [] end
Instance Method Details
#add_gems(gems) (private)
# File 'lib/yard/cli/gems.rb', line 47
def add_gems(gems) 0.step(gems.size - 1, 2) do |index| gem = gems[index] ver_require = gems[index + 1] || ">= 0" specs = YARD::GemIndex.find_all_by_name(gem, ver_require) if specs.empty? log.warn "#{gem} #{ver_require} could not be found in RubyGems index" else @gems += specs end end end
#build_gems (private)
Builds .yardoc files for all non-existing gems
# File 'lib/yard/cli/gems.rb', line 27
def build_gems require 'rubygems' @gems.each do |spec| ver = "= #{spec.version}" dir = Registry.yardoc_file_for_gem(spec.name, ver) if dir && File.directory?(dir) && !@rebuild log.debug "#{spec.name} index already exists at '#{dir}'" else yfile = Registry.yardoc_file_for_gem(spec.name, ver, true) next unless yfile next unless File.directory?(spec.full_gem_path) Registry.clear Dir.chdir(spec.full_gem_path) do log.info "Building yardoc index for gem: #{spec.full_name}" Yardoc.run('--no-stats', '-n', '-b', yfile) end end end end
#description
# File 'lib/yard/cli/gems.rb', line 11
def description; "Builds YARD index for gems" end
#optparse(*args) (private)
Parses options
# File 'lib/yard/cli/gems.rb', line 61
def optparse(*args) opts = OptionParser.new opts. = 'Usage: yard gems [options] [gem_name [version]]' opts.separator "" opts.separator "#{description}. If no gem_name is given," opts.separator "all gems are built." opts.separator "" opts.on('--rebuild', 'Rebuilds index') do @rebuild = true end (opts) (opts, args) add_gems(args) if !args.empty? && @gems.empty? log.error "No specified gems could be found for command" elsif @gems.empty? @gems += YARD::GemIndex.all if @gems.empty? end end
    #run(*args)  ⇒ void 
  
This method returns an undefined value.
Runs the commandline utility, parsing arguments and generating
::YARD indexes for gems.
# File 'lib/yard/cli/gems.rb', line 18
def run(*args) require 'rubygems' optparse(*args) build_gems end