Class: Appydave::Tools::Jump::Commands::Report

Inherits:
Base
  • Object
show all
Defined in:
lib/appydave/tools/jump/commands/report.rb

Overview

Report command generates various reports about locations

Constant Summary collapse

VALID_REPORTS =
%w[
  categories brands clients types tags
  by-brand by-client by-type by-tag
  summary
].freeze

Instance Attribute Summary collapse

Attributes inherited from Base

#config, #options, #path_validator

Instance Method Summary collapse

Constructor Details

#initialize(config, report_type, **options) ⇒ Report

Returns a new instance of Report.



17
18
19
20
21
22
23
# File 'lib/appydave/tools/jump/commands/report.rb', line 17

def initialize(config, report_type, **options)
  super(config, path_validator: options[:path_validator] || PathValidator.new, **options)
  @report_type = report_type
  @filter = options[:filter]
  @limit = options[:limit]
  @skip_unassigned = options.fetch(:skip_unassigned, true)
end

Instance Attribute Details

#filterObject (readonly)

Returns the value of attribute filter.



15
16
17
# File 'lib/appydave/tools/jump/commands/report.rb', line 15

def filter
  @filter
end

#limitObject (readonly)

Returns the value of attribute limit.



15
16
17
# File 'lib/appydave/tools/jump/commands/report.rb', line 15

def limit
  @limit
end

#report_typeObject (readonly)

Returns the value of attribute report_type.



15
16
17
# File 'lib/appydave/tools/jump/commands/report.rb', line 15

def report_type
  @report_type
end

#skip_unassignedObject (readonly)

Returns the value of attribute skip_unassigned.



15
16
17
# File 'lib/appydave/tools/jump/commands/report.rb', line 15

def skip_unassigned
  @skip_unassigned
end

Instance Method Details

#runObject



25
26
27
28
29
30
31
32
33
34
35
# File 'lib/appydave/tools/jump/commands/report.rb', line 25

def run
  unless VALID_REPORTS.include?(report_type)
    return error_result(
      "Unknown report type: #{report_type}",
      code: 'INVALID_INPUT',
      suggestion: "Valid types: #{VALID_REPORTS.join(', ')}"
    )
  end

  send("report_#{report_type.gsub('-', '_')}")
end