Class: Instrumentality::Profile

Inherits:
Command
  • Object
show all
Defined in:
lib/instrumentality/command/profile.rb,
lib/instrumentality/command/profile/custom.rb,
lib/instrumentality/command/profile/benchmark.rb,
lib/instrumentality/command/profile/file_activity.rb

Direct Known Subclasses

Benchmark, Custom, FileActivity

Defined Under Namespace

Classes: Benchmark, Custom, FileActivity

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(argv) ⇒ Profile

—–#



11
12
13
14
15
16
17
18
19
20
# File 'lib/instrumentality/command/profile.rb', line 11

def initialize(argv)
  @process = argv.shift_argument
  @workspace = argv.option('workspace') || Finder.find_workspace
  @project = argv.option('project')
  @project ||= Finder.find_project if @workspace.nil?
  @scheme = argv.option('scheme') || @process
  @server_port = argv.option('server-port') || Constants::DEFAULT_SERVER_PORT
  @interactive = argv.flag?('interactive', false)
  super
end

Class Method Details

.shared_argumentsObject



32
33
34
35
36
# File 'lib/instrumentality/command/profile.rb', line 32

def self.shared_arguments
  [
    CLAide::Argument.new("process", true),
  ]
end

.shared_optionsObject



38
39
40
41
42
43
44
45
46
# File 'lib/instrumentality/command/profile.rb', line 38

def self.shared_options
  [
    ['--workspace=path/to/name.xcworkspace', 'If not set, Instr will try to find one'],
    ['--project=path/to/name.xcodeproj', 'If not set and workspace search failed, Instr will try to find one'],
    ['--scheme=name', 'If not set, Instr will use the process name'],
    ['--server-port=port_number', 'If not set, Instr will use 8080'],
    ['--interactive', 'If set, Instr will not attempt to run an Xcode scheme, but instead attach DTrace directly'],
  ]
end

Instance Method Details

#validate!Object



22
23
24
# File 'lib/instrumentality/command/profile.rb', line 22

def validate!
  super
end

#validate_shared_arguments!Object



26
27
28
29
30
# File 'lib/instrumentality/command/profile.rb', line 26

def validate_shared_arguments!
  help! 'A process name is required' unless @process
  return if @interactive
  help! 'Xcode workspace or project files not found' if @workspace.nil? && @project.nil?
end