Class: Abide::CLI::JiraFromCoverageCommand

Inherits:
CmdParse::Command
  • Object
show all
Defined in:
lib/abide_dev_utils/cli/jira.rb

Constant Summary collapse

CMD_NAME =
'from_coverage'
CMD_SHORT =
'Creates a parent issue with subtasks from a coverage report'
CMD_LONG =
'Creates a parent issue with subtasks for a benchmark and any uncovered controls'

Instance Method Summary collapse

Constructor Details

#initializeJiraFromCoverageCommand

Returns a new instance of JiraFromCoverageCommand.



98
99
100
101
102
103
104
# File 'lib/abide_dev_utils/cli/jira.rb', line 98

def initialize
  super(CMD_NAME, takes_commands: false)
  short_desc(CMD_SHORT)
  long_desc(CMD_LONG)
  argument_desc(REPORT: 'A JSON coverage report from the abide puppet coverage command', PROJECT: 'A Jira project')
  options.on('-d', '--dry-run', 'Print to console instead of saving objects') { |_| @data[:dry_run] = true }
end

Instance Method Details

#execute(report, project) ⇒ Object



106
107
108
109
110
111
112
113
114
# File 'lib/abide_dev_utils/cli/jira.rb', line 106

def execute(report, project)
  Abide::CLI::VALIDATE.file(report)
  @data[:dry_run] = false if @data[:dry_run].nil?
  client = JIRA.client(options: {})
  proj = JIRA.project(client, project)
  File.open(report) do |f|
    JIRA.new_issues_from_coverage(client, proj, JSON.parse(f.read), dry_run: @data[:dry_run])
  end
end