Class: IssueScheduler::IssueTemplate

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Validations::Callbacks, ActiveModelPersistence::Persistence
Defined in:
lib/issue_scheduler/issue_template.rb

Overview

A template for an issue

Examples:

Create a new issue template specifying all attributes

attributes = {
  name: 'weekly_status_report.yaml',
  cron: '0 7 * * 6', # every Friday at 7:00 AM
  project: 'MYJIRA',
  component: 'Management',
  type: 'Story',
  summary: 'Weekly status report',
  description: "Update the weekly status report\n\nhttp://mydomain.com/status",
  due_date: '2022-05-06'
}

template = IssueScheduler::IssueTemplate.new(attributes)

Create a new issue template specifying only required attributes

attributes = {
  name: 'weekly_status_report.yaml',
  cron: '0 7 * * 6', # every Friday at 7:00 AM
  project: 'MYJIRA',
  summary: 'Weekly status report',
}

template = IssueScheduler::IssueTemplate.new(attributes)

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#componentString

The JIRA component name

  • component is optional and defaults to nil

  • component may be nil but not an empty string

The component name is optional and will be set to nil if not given.

Examples:

template.component #=> "MYCOMPONENT"

Returns:

  • (String)

    the component name



114
# File 'lib/issue_scheduler/issue_template.rb', line 114

attribute :component, :string, default: nil

#cronString

A cron string that specifies when the issue should be created

  • cron must be present

  • cron must be a valid cron string

Examples:

# 7 AM Monday - Friday
template.cron #=> "0 7 * * 1,2,3,4,5"

Returns:

  • (String)

    the cron string

See Also:



73
# File 'lib/issue_scheduler/issue_template.rb', line 73

attribute :cron, :string

#descriptionString

The JIRA issue description

  • description is optional and defaults to nil

  • description may be nil but not an empty string

Examples:

template.description #=> "Take out the trash in:\n- kitchen\n- bathroom\n- bedroom"

Returns:

  • (String)

    the JIRA issue description



145
# File 'lib/issue_scheduler/issue_template.rb', line 145

attribute :description, :string, default: nil

#due_dateDate?

The JIRA issue due date

  • due_date is optional and defaults to nil

  • If non-nil, due_date must be a Date object or parsable by Date.parse

Examples:

template.due_date #=> #<Date: 2022-05-03 ((2459703j,0s,0n),+0s,2299161j)>

Returns:

  • (Date, nil)

    the JIRA issue description



177
# File 'lib/issue_scheduler/issue_template.rb', line 177

attribute :due_date, :date

#due_date_before_type_castDate, ... (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

The due_date supplied by the user since ActiveModel sets it to nil of invalid

Returns:

  • (Date, String, nil)

    the due_date before type cast



200
201
202
# File 'lib/issue_scheduler/issue_template.rb', line 200

def due_date_before_type_cast
  @due_date_before_type_cast
end

#nameString

The template name

  • name must not be present

  • name must be unique across all IssueTemplate objects

Examples:

template.name #=> "weekly_status_report"

Returns:

  • (String)

    the template name



54
# File 'lib/issue_scheduler/issue_template.rb', line 54

attribute :name, :string

#projectString

The JIRA project name

  • project must be present

  • project is upcased

Examples:

template.project #=> "MYPROJECT"

Returns:

  • (String)

    the project name



92
# File 'lib/issue_scheduler/issue_template.rb', line 92

attribute :project, :string

#summaryString

The JIRA issue summary

  • summary must be present

Examples:

template.summary #=> "Take out the trash"

Returns:

  • (String)

    the JIRA issue summary



129
# File 'lib/issue_scheduler/issue_template.rb', line 129

attribute :summary, :string

#typeString

The name of the JIRA issue type

  • type is optional and defaults to nil

  • type may be nil but not an empty string

Examples:

template.type #=> "Story"

Returns:

  • (String)

    the JIRA issue type



161
# File 'lib/issue_scheduler/issue_template.rb', line 161

attribute :type, :string, default: nil

Class Method Details

.primary_keySymbol

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Sets the primary key to ‘:name`

Returns:

  • (Symbol)

    the attribute name of the primary key



193
194
195
# File 'lib/issue_scheduler/issue_template.rb', line 193

def self.primary_key
  :name
end