lib/yard/cli/gems.rb in yard-0.6.1 vs lib/yard/cli/gems.rb in yard-0.6.2

- old
+ new

@@ -13,12 +13,12 @@ # YARD indexes for gems. # # @param [Array<String>] args the list of arguments # @return [void] def run(*args) + require 'rubygems' optparse(*args) - @gems += Gem.source_index.find_name('') if @gems.empty? build_gems end private @@ -42,13 +42,18 @@ end end end def add_gems(gems) - gems.each_slice(2) do |gem, ver_require| - specs = Gem.source_index.find_name(gem, ver_require || ">= 0") - @gems += specs unless specs.empty? + 0.step(gems.size - 1, 2) do |index| + gem, ver_require = gems[index], gems[index + 1] || ">= 0" + specs = Gem.source_index.find_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 # Parses options def optparse(*args) @@ -59,16 +64,20 @@ opts.separator "all gems are built." opts.separator "" opts.on('--rebuild', 'Rebuilds index') do @rebuild = true end - opts.on('--legacy', 'Use old style parser and handlers. Unavailable under Ruby 1.8.x') do - YARD::Parser::SourceParser.parser_type = :ruby18 - end common_options(opts) parse_options(opts, args) add_gems(args) + + + if !args.empty? && @gems.empty? + log.error "No specified gems could be found for command" + elsif @gems.empty? + @gems += Gem.source_index.find_name('') if @gems.empty? + end end end end end \ No newline at end of file