Class: BoPeep::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/bopeep.rb

Instance Method Summary collapse

Constructor Details

#initialize(argv) ⇒ Runner

Returns a new instance of Runner.



1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
# File 'lib/bopeep.rb', line 1649

def initialize(argv)
  @argv = argv.dup
  @path = nil

  find_bopeep_directory!
  load_config!

  @context = Context.new(@argv)
  @context.copy(BoPeep.config)

  load_scripts!
  load_commands!

  @command = Command.find(@argv)
end

Instance Method Details

#runObject



1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
# File 'lib/bopeep.rb', line 1665

def run
  if @command.nil?
    @context.parse_options!
    $stderr.puts "Could not find command from #{@argv.inspect}"
    exit 1
  end

  @command.(@context)
  @context.parse_options!

  Console.hostname_width = @context.hosts.map { |host| host.address.length }.max

  BoPeep.console.redirecting_stdout_and_stderr do
    @context.playlist.play
  end
end