Class: YARD::CLI::Display
- Inherits:
 - 
      Yardoc
      
        
- Object
 - Command
 - YardoptsCommand
 - Yardoc
 - YARD::CLI::Display
 
 
- Defined in:
 - lib/yard/cli/display.rb
 
Overview
Display one object
Instance Method Summary collapse
- #description ⇒ Object
 - 
  
    
      #format_objects  ⇒ String 
    
    
  
  
  
  
  
  
  
  
  
    
The output data for all formatted objects.
 - 
  
    
      #initialize(*args)  ⇒ Display 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    
A new instance of Display.
 - #output_options(opts) ⇒ Object
 - 
  
    
      #parse_arguments(*args)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Parses commandline options.
 - 
  
    
      #run(*args)  ⇒ void 
    
    
  
  
  
  
  
  
  
  
  
    
Runs the commandline utility, parsing arguments and displaying an object from the Registry.
 - #wrap_layout(contents) ⇒ Object
 
Constructor Details
#initialize(*args) ⇒ Display
Returns a new instance of Display.
      9 10 11 12 13 14  | 
    
      # File 'lib/yard/cli/display.rb', line 9 def initialize(*args) super .format = :text # default for this command @layout = nil @objects = [] end  | 
  
Instance Method Details
#description ⇒ Object
      7  | 
    
      # File 'lib/yard/cli/display.rb', line 7 def description; 'Displays a formatted object' end  | 
  
#format_objects ⇒ String
Returns the output data for all formatted objects.
      27 28 29 30 31  | 
    
      # File 'lib/yard/cli/display.rb', line 27 def format_objects @objects.inject([]) do |arr, obj| arr.push obj.format() end.join("\n") end  | 
  
#output_options(opts) ⇒ Object
      61 62 63 64 65 66  | 
    
      # File 'lib/yard/cli/display.rb', line 61 def (opts) super(opts) opts.on('-l', '--layout [LAYOUT]', 'Wraps output in layout template (good for HTML)') do |layout| @layout = layout || 'layout' end end  | 
  
#parse_arguments(*args) ⇒ Object
Parses commandline options.
      46 47 48 49 50 51 52 53 54 55 56 57 58 59  | 
    
      # File 'lib/yard/cli/display.rb', line 46 def parse_arguments(*args) opts = OptionParser.new opts. = "Usage: yard display [options] OBJECT [OTHER OBJECTS]" (opts) (opts) (opts, args) Registry.load @objects = args.map {|o| Registry.at(o) } # validation return false if @objects.any?(&:nil?) end  | 
  
#run(*args) ⇒ void
This method returns an undefined value.
Runs the commandline utility, parsing arguments and displaying an object from the Registry.
      21 22 23 24  | 
    
      # File 'lib/yard/cli/display.rb', line 21 def run(*args) return unless parse_arguments(*args) log.puts wrap_layout(format_objects) end  | 
  
#wrap_layout(contents) ⇒ Object
      33 34 35 36 37 38 39 40 41 42  | 
    
      # File 'lib/yard/cli/display.rb', line 33 def wrap_layout(contents) return contents unless @layout opts = .merge( :contents => contents, :object => @objects.first, :objects => @objects ) args = [.template, @layout, .format] Templates::Engine.template(*args).run(opts) end  |