Class/Module Index [+]

Quicksearch

YARD::CLI::Diff

CLI command to return the objects that were added/removed from 2 versions of a project (library, gem, working copy). @since 0.6.0

Public Class Methods

new() click to toggle source
# File lib/yard/cli/diff.rb, line 11
def initialize
  super
  @list_all = false
  @use_git = false
  @old_git_commit = nil
  @old_path = Dir.pwd
  log.show_backtraces = true
end

Public Instance Methods

description() click to toggle source
# File lib/yard/cli/diff.rb, line 20
def description
  'Returns the object diff of two gems or .yardoc files'
end
run(*args) click to toggle source
# File lib/yard/cli/diff.rb, line 24
def run(*args)
  registry = optparse(*args).map do |gemfile|
    if @use_git
      load_git_commit(gemfile)
      Registry.all.map {|o| o.path }
    else
      if load_gem_data(gemfile)
        log.info "Found #{gemfile}"
        Registry.all.map {|o| o.path }
      else
        log.error "Cannot find gem #{gemfile}"
        nil
      end
    end
  end.compact

  return if registry.size != 2

  [   ["Added objects", registry[1] - registry[0]],
      ["Removed objects", registry[0] - registry[1]]].each do |name, objects|
    next if objects.empty?
    last_object = nil
    all_objects_notice = false
    puts name + ":"
    objects.sort.each do |object|
      if !@list_all && last_object && object =~ /#{Regexp.quote last_object}(::|\.|#)/
        print " (...)" unless all_objects_notice
        all_objects_notice = true
        next
      else
        puts
      end
      all_objects_notice = false
      print "  " + object
      last_object = object
    end
    puts
    puts
  end
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.