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/rate_limited_jira_client.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/rate_limited_jira_client/redis_based.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/rate_limited_jira_client/in_process_based.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, RateLimitedJiraClient, 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.2.4"
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.
35
36
37
|
# File 'lib/jira/auto/tool.rb', line 35
def initialize
@environment = EnvironmentLoader.new(self)
end
|
Instance Attribute Details
#environment ⇒ Object
Returns the value of attribute environment.
33
34
35
|
# File 'lib/jira/auto/tool.rb', line 33
def environment
@environment
end
|
Instance Method Details
51
52
53
54
55
56
57
58
|
# File 'lib/jira/auto/tool.rb', line 51
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
167
168
169
|
# File 'lib/jira/auto/tool.rb', line 167
def board_controller
@board_controller ||= BoardController.new(self)
end
|
#board_name ⇒ Object
47
48
49
|
# File 'lib/jira/auto/tool.rb', line 47
def board_name
jira_board_name
end
|
60
61
62
|
# File 'lib/jira/auto/tool.rb', line 60
def boards
board_controller.boards
end
|
39
40
41
|
# File 'lib/jira/auto/tool.rb', line 39
def config
@config ||= Config.new(self)
end
|
#create_sprint(attributes) ⇒ Object
71
72
73
74
75
76
77
78
79
|
# File 'lib/jira/auto/tool.rb', line 71
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
183
184
185
|
# File 'lib/jira/auto/tool.rb', line 183
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
64
65
66
67
|
# File 'lib/jira/auto/tool.rb', line 64
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
195
196
197
|
# File 'lib/jira/auto/tool.rb', line 195
def field_controller
@field_controller ||= FieldController.new(jira_client)
end
|
43
44
45
|
# File 'lib/jira/auto/tool.rb', line 43
def home_dir
File.expand_path(File.join("..", "..", ".."), __dir__)
end
|
#implementation_team_field(field_name = implementation_team_field_name) ⇒ Object
187
188
189
|
# File 'lib/jira/auto/tool.rb', line 187
def implementation_team_field(field_name = implementation_team_field_name)
field_controller.implementation_team_field(field_name)
end
|
#jira_base_url ⇒ Object
134
135
136
|
# File 'lib/jira/auto/tool.rb', line 134
def jira_base_url
jira_client.options[:site] + jira_client.options[:context_path]
end
|
#jira_client_options ⇒ Object
99
100
101
102
103
104
105
106
107
108
|
# File 'lib/jira/auto/tool.rb', line 99
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
|
# File 'lib/jira/auto/tool.rb', line 111
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
130
131
132
|
# File 'lib/jira/auto/tool.rb', line 130
def jira_request_path(path)
jira_client.options[:context_path] + path
end
|
#jira_sprint_field(field_name = jira_sprint_field_name) ⇒ Object
191
192
193
|
# File 'lib/jira/auto/tool.rb', line 191
def jira_sprint_field(field_name = jira_sprint_field_name)
field_controller.sprint_field(field_name)
end
|
#jira_url(url) ⇒ Object
138
139
140
|
# File 'lib/jira/auto/tool.rb', line 138
def jira_url(url)
jira_base_url + url
end
|
179
180
181
|
# File 'lib/jira/auto/tool.rb', line 179
def project
@project ||= Project.find(self, jira_project_key)
end
|
#project_ticket_fields ⇒ Object
175
176
177
|
# File 'lib/jira/auto/tool.rb', line 175
def project_ticket_fields
project.ticket_fields
end
|
#sprint_controller ⇒ Object
171
172
173
|
# File 'lib/jira/auto/tool.rb', line 171
def sprint_controller
@sprint_controller ||= SprintController.new(self, board)
end
|
#team_sprint_ticket_dispatcher ⇒ Object
222
223
224
225
226
|
# File 'lib/jira/auto/tool.rb', line 222
def team_sprint_ticket_dispatcher
TeamSprintTicketDispatcher.new(jira_client,
tickets(jat_tickets_for_team_sprint_ticket_dispatcher_jql),
unclosed_sprint_prefixes)
end
|
207
208
209
|
# File 'lib/jira/auto/tool.rb', line 207
def teams
implementation_team_field.values.collect { |value| Team.new(value) }.collect(&:name)
end
|
#tickets(jql = "project = #{project.key}") ⇒ Object
211
212
213
214
215
216
217
218
219
220
|
# File 'lib/jira/auto/tool.rb', line 211
def tickets(jql = "project = #{project.key}")
jira_client.Issue.jql(jql).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
81
82
83
|
# File 'lib/jira/auto/tool.rb', line 81
def transition_sprint_state(created_sprint, desired_state:)
SprintStateController.new(jira_client, created_sprint).transition_to(desired_state)
end
|
#unclosed_sprint_prefixes ⇒ Object
203
204
205
|
# File 'lib/jira/auto/tool.rb', line 203
def unclosed_sprint_prefixes
sprint_controller.unclosed_sprint_prefixes
end
|
#unclosed_sprints ⇒ Object
199
200
201
|
# File 'lib/jira/auto/tool.rb', line 199
def unclosed_sprints
sprint_controller.unclosed_sprints
end
|