Class: Crep::Crashes

Inherits:
Command
  • Object
show all
Defined in:
lib/crep/command/crashes.rb

Constant Summary collapse

DEFAULT_TOP_COUNT =
5
DEFAULT_TEMPLATE =
'templates/default_crash_report.txt.erb'

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(argv) ⇒ Crashes

Returns a new instance of Crashes


32
33
34
35
36
37
38
39
40
41
# File 'lib/crep/command/crashes.rb', line 32

def initialize(argv)
  super

  @show_only_unresolved = argv.flag?('only-unresolved', false)
  @top = argv.option('top', DEFAULT_TOP_COUNT)
  @bundle_identifier = argv.option('identifier')
  @version = argv.option('version')
  @build = argv.option('build')
  @template = argv.option('template', DEFAULT_TEMPLATE)
end

Class Method Details

.optionsObject


13
14
15
16
17
18
19
20
21
22
# File 'lib/crep/command/crashes.rb', line 13

def self.options
  [
    ['--top=5', "If set, Crep will show the top x crashes. #{DEFAULT_TOP_COUNT} by default."],
    ['--identifier=<com.company.app>', 'Crep will show crashes for the app with this bundle identifier'],
    ['--version=<7.10.0>', 'The version of the App.'],
    ['--build=<24>', 'The Build number of the App.'],
    ['--only-unresolved', 'If set, resolved crashes will be filtered out.'],
    ['--template=templates/defaul_crash_report.txt.erb', 'Set this to specify a erb template for the report format. If no value is specifed the default temapate will be used.']
  ].concat(super)
end

Instance Method Details

#runObject


51
52
53
54
55
# File 'lib/crep/command/crashes.rb', line 51

def run
  crash_datasource = HockeyAppCrashSource.new
  crash_controller = CrashController.new(@bundle_identifier, @top, crash_datasource, @show_only_unresolved, @template)
  crash_controller.top_crashes(@version, @build)
end

#validate!Object


43
44
45
46
47
48
49
# File 'lib/crep/command/crashes.rb', line 43

def validate!
  super

  help! 'The identifier (--identifier) is a required parameter' unless @bundle_identifier
  help! 'The version (--version)  is a required parameter' unless @version
  help! 'The build number (--build) is a required parameter' unless @build
end