Module: Terjira::OptionSelector
- Defined in:
- lib/terjira/option_support/option_selector.rb
Instance Method Summary collapse
- #select_assignee ⇒ Object
- #select_board(type = nil) ⇒ Object
- #select_issue_status ⇒ Object
- #select_issuetype ⇒ Object
- #select_priority ⇒ Object
- #select_project ⇒ Object
- #select_resolution ⇒ Object
- #select_sprint ⇒ Object
- #update_comment ⇒ Object
- #with_editor=(with_editor = false) ⇒ Object
- #with_editor? ⇒ Boolean
- #write_comment ⇒ Object
- #write_description ⇒ Object
- #write_epic_name ⇒ Object
- #write_epiclink_key ⇒ Object
- #write_parent_issue_key ⇒ Object
- #write_summary ⇒ Object
Instance Method Details
#select_assignee ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/terjira/option_support/option_selector.rb', line 52 def select_assignee fetch(:assignee) do users = fetch(:users) do if issue = get(:issue) Client::User.assignables_by_issue(issue) elsif board = get(:board) Client::User.assignables_by_board(board) elsif sprint = get(:sprint) Client::User.assignables_by_sprint(sprint) else users = Client::User.assignables_by_project(select_project) end end option_select_prompt.select('Choose assignee?', per_page: per_page(users)) do || users.each { |user| .choice user_choice_title(user), user } end end end |
#select_board(type = nil) ⇒ Object
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/terjira/option_support/option_selector.rb', line 29 def select_board(type = nil) fetch(:board) do boards = fetch(:boards) { Client::Board.all(type: type) } option_select_prompt.select('Choose board?', per_page: per_page(boards)) do || boards.sort_by(&:id).each do |board| .choice "#{board.key_value} - #{board.name}", board end end end end |
#select_issue_status ⇒ Object
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/terjira/option_support/option_selector.rb', line 89 def select_issue_status fetch(:status) do statuses = fetch(:statuses) do project = if issue = get(:issue) if issue.respond_to?(:project) issue.project else set(:issue, Client::Issue.find(issue)).project end else select_project end Client::Status.all(project) end option_select_prompt.select('Choose status?') do || statuses.each do |status| .choice status.name, status end end end end |
#select_issuetype ⇒ Object
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/terjira/option_support/option_selector.rb', line 72 def select_issuetype fetch(:issuetype) do project = get(:issue).try(:project).try(:key) project ||= select_project if project.is_a? String project = Client::Project.find(project) set(:project, project) end option_select_prompt.select('Choose issue type?') do || project.issuetypes.each do |issuetype| .choice issuetype.name, issuetype end end end end |
#select_priority ⇒ Object
112 113 114 115 116 117 118 119 120 121 |
# File 'lib/terjira/option_support/option_selector.rb', line 112 def select_priority fetch(:priority) do priorities = fetch(:priorities) { Terjira::Client::Priority.all } option_select_prompt.select('Choose priority?') do || priorities.each do |priority| .choice priority.name, priority end end end end |
#select_project ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/terjira/option_support/option_selector.rb', line 17 def select_project fetch :project do projects = fetch(:projects) { Client::Project.all } selected_project = option_select_prompt.select('Choose project?', per_page: per_page(projects)) do || projects.each { |project| .choice project_choice_title(project), project } end Client::Project.find(selected_project.id) end end |
#select_resolution ⇒ Object
123 124 125 126 127 128 129 130 131 132 |
# File 'lib/terjira/option_support/option_selector.rb', line 123 def select_resolution fetch(:resolution) do resolutions = fetch(:resolutions) { Terjira::Client::Resolution.all } option_select_prompt.select('Choose resolution?') do || resolutions.each do |resolution| .choice resolution.name, resolution end end end end |
#select_sprint ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/terjira/option_support/option_selector.rb', line 40 def select_sprint fetch(:sprint) do board = select_board('scrum') sprints = fetch(:sprints) { Client::Sprint.all(board) } option_select_prompt.select('Choose sprint?') do || sort_sprint_by_state(sprints).each do |sprint| .choice sprint_choice_title(sprint), sprint end end end end |
#update_comment ⇒ Object
154 155 156 157 158 159 160 161 162 163 164 |
# File 'lib/terjira/option_support/option_selector.rb', line 154 def update_comment fetch(:editable_comment) do selected_comment = user_comment if selected_comment.present? new_content = Editor.editor_text(selected_comment.body) { 'selected_comment' => selected_comment, 'new_content' => new_content } end end end |
#with_editor=(with_editor = false) ⇒ Object
9 10 11 |
# File 'lib/terjira/option_support/option_selector.rb', line 9 def with_editor=(with_editor = false) @with_editor = with_editor end |
#with_editor? ⇒ Boolean
13 14 15 |
# File 'lib/terjira/option_support/option_selector.rb', line 13 def with_editor? @with_editor || false end |
#write_comment ⇒ Object
144 145 146 147 148 149 150 151 152 |
# File 'lib/terjira/option_support/option_selector.rb', line 144 def write_comment fetch(:comment) do if with_editor? Editor.editor_text else prompt_multiline('Comment') end end end |
#write_description ⇒ Object
166 167 168 169 170 171 172 173 174 |
# File 'lib/terjira/option_support/option_selector.rb', line 166 def write_description fetch(:description) do if with_editor? Editor.editor_text else prompt_multiline('Description') end end end |
#write_epic_name ⇒ Object
140 141 142 |
# File 'lib/terjira/option_support/option_selector.rb', line 140 def write_epic_name option_prompt.ask('Epic Name?') end |
#write_epiclink_key ⇒ Object
134 135 136 137 138 |
# File 'lib/terjira/option_support/option_selector.rb', line 134 def write_epiclink_key fetch(:epiclink) do option_prompt.ask('Epic Key?') end end |
#write_parent_issue_key ⇒ Object
180 181 182 |
# File 'lib/terjira/option_support/option_selector.rb', line 180 def write_parent_issue_key fetch(:parent) { option_prompt.ask('Parent Issue Key?') } end |
#write_summary ⇒ Object
176 177 178 |
# File 'lib/terjira/option_support/option_selector.rb', line 176 def write_summary fetch(:summary) { option_prompt.ask('Summary?') } end |