Class: Jira::Auto::Tool
- Inherits:
-
Object
show all
- Extended by:
- Helpers::EnvironmentBasedValue
- Defined in:
- lib/jira/auto/tool.rb,
lib/jira/auto/tool/team.rb,
lib/jira/auto/tool/board.rb,
lib/jira/auto/tool/field.rb,
lib/jira/auto/tool/config.rb,
lib/jira/auto/tool/sprint.rb,
lib/jira/auto/tool/ticket.rb,
lib/jira/auto/tool/project.rb,
lib/jira/auto/tool/version.rb,
lib/jira/auto/tool/until_date.rb,
lib/jira/auto/tool/board/cache.rb,
lib/jira/auto/tool/sprint/name.rb,
lib/jira/auto/tool/field_option.rb,
lib/jira/auto/tool/sprint/prefix.rb,
lib/jira/auto/tool/common_options.rb,
lib/jira/auto/tool/config/options.rb,
lib/jira/auto/tool/project/options.rb,
lib/jira/auto/tool/request_builder.rb,
lib/jira/auto/tool/board_controller.rb,
lib/jira/auto/tool/field_controller.rb,
lib/jira/auto/tool/jira_http_options.rb,
lib/jira/auto/tool/performer/options.rb,
lib/jira/auto/tool/sprint_controller.rb,
lib/jira/auto/tool/environment_loader.rb,
lib/jira/auto/tool/helpers/pagination.rb,
lib/jira/auto/tool/next_sprint_creator.rb,
lib/jira/auto/tool/request_builder/get.rb,
lib/jira/auto/tool/project/ticket_fields.rb,
lib/jira/auto/tool/board/unavailable_board.rb,
lib/jira/auto/tool/sprint_state_controller.rb,
lib/jira/auto/tool/board_controller/options.rb,
lib/jira/auto/tool/helpers/overridable_time.rb,
lib/jira/auto/tool/performer/sprint_renamer.rb,
lib/jira/auto/tool/sprint_controller/options.rb,
lib/jira/auto/tool/team_sprint_prefix_mapper.rb,
lib/jira/auto/tool/environment_loader/options.rb,
lib/jira/auto/tool/team_sprint_ticket_dispatcher.rb,
lib/jira/auto/tool/request_builder/sprint_creator.rb,
lib/jira/auto/tool/helpers/environment_based_value.rb,
lib/jira/auto/tool/performer/prefix_sprint_updater.rb,
lib/jira/auto/tool/performer/sprint_end_date_updater.rb,
lib/jira/auto/tool/team_sprint_prefix_mapper/options.rb,
lib/jira/auto/tool/performer/quarterly_sprint_renamer.rb,
lib/jira/auto/tool/request_builder/field_option_fetcher.rb,
lib/jira/auto/tool/request_builder/sprint_state_updater.rb,
lib/jira/auto/tool/request_builder/field_context_fetcher.rb,
lib/jira/auto/tool/performer/sprint_time_in_dates_aligner.rb,
lib/jira/auto/tool/performer/planning_increment_sprint_creator.rb,
lib/jira/auto/tool/performer/sprint_renamer/next_name_generator.rb,
lib/jira/auto/tool/performer/sprint_renamer/keep_same_name_generator.rb,
lib/jira/auto/tool/performer/quarterly_sprint_renamer/next_name_generator.rb
Overview
rubocop:disable Metrics/ClassLength
Defined Under Namespace
Modules: CommonOptions, Helpers, JiraHttpOptions
Classes: Board, BoardController, Config, EnvironmentLoader, Error, Field, FieldController, FieldOption, NextSprintCreator, Performer, Project, RequestBuilder, Sprint, SprintController, SprintStateController, Team, TeamSprintPrefixMapper, TeamSprintTicketDispatcher, Ticket, UntilDate
Constant Summary
collapse
- ATTRIBUTES_TO_IGNORE_FOR_SPRINT_CREATION =
%i[state].freeze
- HOLDS_A_SECRET =
true
- ENVIRONMENT_BASED_VALUE_SYMBOLS =
([[:jira_api_token, HOLDS_A_SECRET]] + %i[
art_sprint_regex
expected_start_date_field_name
implementation_team_field_name
jat_rate_interval_in_seconds
jat_rate_limit_implementation
jat_rate_limit_per_interval
jat_tickets_for_team_sprint_ticket_dispatcher_jql
jira_board_name
jira_board_name_regex
jira_context_path
jira_http_debug
jira_project_key
jira_site_url
jira_sprint_field_name
jira_username
].collect { |value_name| [value_name, !HOLDS_A_SECRET] }).freeze
- VERSION =
"1.3.8"
Instance Attribute Summary collapse
Instance Method Summary
collapse
corresponding_environment_variable_defined?, define_environment_variable_name_constant, define_holds_a_secret_predicate, define_overridable_environment_based_value, define_predicate, define_reader, define_reader_accepting_default_value, define_writer, fetch_corresponding_environment_variable, instance_variable_name
Constructor Details
#initialize ⇒ Tool
Returns a new instance of Tool.
36
37
38
|
# File 'lib/jira/auto/tool.rb', line 36
def initialize
@environment = EnvironmentLoader.new(self)
end
|
Instance Attribute Details
#environment ⇒ Object
Returns the value of attribute environment.
34
35
36
|
# File 'lib/jira/auto/tool.rb', line 34
def environment
@environment
end
|
Instance Method Details
52
53
54
55
56
57
58
59
|
# File 'lib/jira/auto/tool.rb', line 52
def board
found_board = boards.find { |a_board| a_board.name == board_name } or
raise KeyError, "Board '#{board_name}' not found!"
log.debug { "Jira board '#{board_name}' found: #{found_board}!" }
found_board
end
|
#board_controller ⇒ Object
162
163
164
|
# File 'lib/jira/auto/tool.rb', line 162
def board_controller
@board_controller ||= BoardController.new(self)
end
|
#board_name ⇒ Object
48
49
50
|
# File 'lib/jira/auto/tool.rb', line 48
def board_name
jira_board_name
end
|
61
62
63
|
# File 'lib/jira/auto/tool.rb', line 61
def boards
board_controller.boards
end
|
40
41
42
|
# File 'lib/jira/auto/tool.rb', line 40
def config
@config ||= Config.new(self)
end
|
#create_sprint(attributes) ⇒ Object
72
73
74
75
76
77
78
79
80
|
# File 'lib/jira/auto/tool.rb', line 72
def create_sprint(attributes)
attributes_for_sprint_creation = attributes.except(*ATTRIBUTES_TO_IGNORE_FOR_SPRINT_CREATION)
created_sprint = create_future_sprint(attributes_for_sprint_creation)
log.debug { created_sprint.inspect }
transition_sprint_state(created_sprint, desired_state: attributes.fetch(:state))
end
|
#expected_start_date_field(field_name = expected_start_date_field_name) ⇒ Object
178
179
180
|
# File 'lib/jira/auto/tool.rb', line 178
def expected_start_date_field(field_name = expected_start_date_field_name)
field_controller.expected_start_date_field(field_name)
end
|
#fetch_sprint(sprint_name) ⇒ Object
65
66
67
68
|
# File 'lib/jira/auto/tool.rb', line 65
def fetch_sprint(sprint_name)
sprint_controller.sprints.find { |sprint| sprint.name == sprint_name } or
raise KeyError, "Sprint '#{sprint_name}' not found for #{board.name}!" end
|
#field_controller ⇒ Object
190
191
192
|
# File 'lib/jira/auto/tool.rb', line 190
def field_controller
@field_controller ||= FieldController.new(jira_client)
end
|
44
45
46
|
# File 'lib/jira/auto/tool.rb', line 44
def home_dir
File.expand_path(File.join("..", "..", ".."), __dir__)
end
|
#implementation_team_field(field_name = implementation_team_field_name) ⇒ Object
182
183
184
|
# File 'lib/jira/auto/tool.rb', line 182
def implementation_team_field(field_name = implementation_team_field_name)
field_controller.implementation_team_field(field_name)
end
|
#jira_base_url ⇒ Object
130
131
132
|
# File 'lib/jira/auto/tool.rb', line 130
def jira_base_url
jira_client.options[:site] + jira_client.options[:context_path]
end
|
#jira_client ⇒ Object
86
87
88
89
90
91
92
93
|
# File 'lib/jira/auto/tool.rb', line 86
def jira_client
RateLimitedJira::Client.build(
jira_client_options,
rate_interval_in_seconds: jat_rate_interval_in_seconds_when_defined_else(0).to_i,
rate_limit_per_interval: jat_rate_limit_per_interval_when_defined_else(0).to_i,
implementation: jat_rate_limit_implementation_when_defined_else("")
)
end
|
#jira_client_options ⇒ Object
95
96
97
98
99
100
101
102
103
104
|
# File 'lib/jira/auto/tool.rb', line 95
def jira_client_options
{
username: jira_username,
password: jira_api_token,
site: jira_site_url,
context_path: jira_context_path_when_defined_else(""),
auth_type: :basic,
http_debug: jira_http_debug?
}
end
|
#jira_http_debug? ⇒ Boolean
TODO: fix this overly complex logic
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
|
# File 'lib/jira/auto/tool.rb', line 107
def jira_http_debug?
value = if config.key?(:jira_http_debug)
config[:jira_http_debug]
else
jira_http_debug_defined? && jira_http_debug
end
result = case value
when String
value =~ /^(true|yes|1)$/i
else
value
end
log.debug { "jira_http_debug? = #{result} (jira_http_debug = #{value}, config = #{config.inspect})" }
result
end
|
#jira_request_path(path) ⇒ Object
126
127
128
|
# File 'lib/jira/auto/tool.rb', line 126
def jira_request_path(path)
jira_client.options[:context_path] + path
end
|
#jira_sprint_field(field_name = jira_sprint_field_name) ⇒ Object
186
187
188
|
# File 'lib/jira/auto/tool.rb', line 186
def jira_sprint_field(field_name = jira_sprint_field_name)
field_controller.sprint_field(field_name)
end
|
#jira_url(url) ⇒ Object
134
135
136
|
# File 'lib/jira/auto/tool.rb', line 134
def jira_url(url)
jira_base_url + url
end
|
174
175
176
|
# File 'lib/jira/auto/tool.rb', line 174
def project
@project ||= Project.find(self, jira_project_key)
end
|
#project_ticket_fields ⇒ Object
170
171
172
|
# File 'lib/jira/auto/tool.rb', line 170
def project_ticket_fields
project.ticket_fields
end
|
#sprint_controller ⇒ Object
166
167
168
|
# File 'lib/jira/auto/tool.rb', line 166
def sprint_controller
@sprint_controller ||= SprintController.new(self, board)
end
|
#team_sprint_ticket_dispatcher ⇒ Object
217
218
219
220
221
|
# File 'lib/jira/auto/tool.rb', line 217
def team_sprint_ticket_dispatcher
TeamSprintTicketDispatcher.new(jira_client,
tickets(jat_tickets_for_team_sprint_ticket_dispatcher_jql),
unclosed_sprint_prefixes)
end
|
202
203
204
|
# File 'lib/jira/auto/tool.rb', line 202
def teams
implementation_team_field.values.collect { |value| Team.new(value) }.collect(&:name)
end
|
#tickets(jql = "project = #{project.key}") ⇒ Object
206
207
208
209
210
211
212
213
214
215
|
# File 'lib/jira/auto/tool.rb', line 206
def tickets(jql = "project = #{project.key}")
jira_client.Issue.jql(jql, fields: ["*all"]).collect { |jira_ticket| Ticket.new(self, jira_ticket) }
rescue StandardError => e
raise <<~EOEM
Error fetching project tickets: Something went wrong:
__________ Please check your Jira configuration and your query ______
jql = #{jql}
#{e.class}: #{e.message}
EOEM
end
|
#transition_sprint_state(created_sprint, desired_state:) ⇒ Object
82
83
84
|
# File 'lib/jira/auto/tool.rb', line 82
def transition_sprint_state(created_sprint, desired_state:)
SprintStateController.new(jira_client, created_sprint).transition_to(desired_state)
end
|
#unclosed_sprint_prefixes ⇒ Object
198
199
200
|
# File 'lib/jira/auto/tool.rb', line 198
def unclosed_sprint_prefixes
sprint_controller.unclosed_sprint_prefixes
end
|
#unclosed_sprints ⇒ Object
194
195
196
|
# File 'lib/jira/auto/tool.rb', line 194
def unclosed_sprints
sprint_controller.unclosed_sprints
end
|