Class: AbideDevUtils::Jira::IssueBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/abide_dev_utils/jira/issue_builder.rb

Constant Summary collapse

CUSTOM_FIELDS =
{
  'epic_link' => 'customfield_10014',
  'epic_name' => 'customfield_10011',
}.freeze
FIELD_DEFAULTS =
{
  'issuetype' => 'Task',
  'priority' => 'Medium',
  'labels' => ['abide_dev_utils'],
}.freeze
REQUIRED_FIELDS =
%w[project summary].freeze

Instance Method Summary collapse

Constructor Details

#initialize(client, finder) ⇒ IssueBuilder

Returns a new instance of IssueBuilder.



21
22
23
24
# File 'lib/abide_dev_utils/jira/issue_builder.rb', line 21

def initialize(client, finder)
  @client = client
  @finder = finder
end

Instance Method Details

#can_create?(type) ⇒ Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/abide_dev_utils/jira/issue_builder.rb', line 26

def can_create?(type)
  respond_to?("create_#{type}".to_sym, true)
end

#create(type, **fields) ⇒ Object

Raises:

  • (ArgumentError)


30
31
32
33
34
35
36
# File 'lib/abide_dev_utils/jira/issue_builder.rb', line 30

def create(type, **fields)
  type = type.to_s.downcase.to_sym
  raise ArgumentError, "Invalid type \"#{type}\"; no method \"create_#{type}\"" unless can_create?(type)

  fields = process_fields(fields)
  send("create_#{type}".to_sym, **fields)
end