Class: StartupTime::App

Inherits:
Object
  • Object
show all
Includes:
FileUtils, Util
Defined in:
lib/startup_time/app.rb

Overview

StartupTime::App - the entry point for the app. selects an action based on the command-line options and runs it.

Constant Summary collapse

EXPECTED_OUTPUT =
/\AHello, world!\r?\n\z/

Instance Method Summary collapse

Methods included from Util

#which

Constructor Details

#initialize(args = ARGV) ⇒ App

Returns a new instance of App.



26
27
28
29
30
31
32
33
34
35
# File 'lib/startup_time/app.rb', line 26

def initialize(args = ARGV)
  @options = Options.new(args)
  @json = @options.format == :json
  @verbosity = @options.verbosity
  @times = []

  # provide/publish the Options instance we've just created so it's
  # available to other components
  Services.once(:options) { @options }
end

Instance Method Details

#runObject

run the command corresponding to the command-line options: either an auxiliary command (e.g. clean the build directory or print a help message) or the default command, which runs the selected benchmark-tests



41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/startup_time/app.rb', line 41

def run
  case @options.action
  when :clean
    builder.clean!
  when :help
    puts @options.usage
  when :version
    puts VERSION
  when :show_ids
    render_ids_to_groups
  else
    benchmark
  end
end