Module: Viiite::Command::Commons

Included in:
Plot, Report, Run
Defined in:
lib/viiite/command/commons.rb

Instance Method Summary collapse

Instance Method Details

#single_source(argv) ⇒ Object

Raises:

  • (Quickl::InvalidArgument)


5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/viiite/command/commons.rb', line 5

def single_source(argv)
  raise Quickl::InvalidArgument if argv.size > 1
  if arg = argv.first
    if File.exists?(arg.to_s)
      Alf::Reader.reader(arg.to_s)
    elsif requester && requester.respond_to?(:bdb)
      block_given? ? yield(requester.bdb, arg) : requester.bdb.dataset(arg)
    else
      raise Quickl::InvalidArgument, "Missing benchmark #{arg}"
    end
  else
    Alf::Reader.reader($stdin)
  end
end