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
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/terjira/option_support/option_selector.rb', line 54 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
31 32 33 34 35 36 37 38 39 40 |
# File 'lib/terjira/option_support/option_selector.rb', line 31 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
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/terjira/option_support/option_selector.rb', line 91 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
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/terjira/option_support/option_selector.rb', line 74 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
114 115 116 117 118 119 120 121 122 123 |
# File 'lib/terjira/option_support/option_selector.rb', line 114 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
19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/terjira/option_support/option_selector.rb', line 19 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
125 126 127 128 129 130 131 132 133 134 |
# File 'lib/terjira/option_support/option_selector.rb', line 125 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
42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/terjira/option_support/option_selector.rb', line 42 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
156 157 158 159 160 161 162 163 164 165 166 |
# File 'lib/terjira/option_support/option_selector.rb', line 156 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
11 12 13 |
# File 'lib/terjira/option_support/option_selector.rb', line 11 def with_editor=(with_editor = false) @with_editor = with_editor end |
#with_editor? ⇒ Boolean
15 16 17 |
# File 'lib/terjira/option_support/option_selector.rb', line 15 def with_editor? @with_editor || false end |
#write_comment ⇒ Object
146 147 148 149 150 151 152 153 154 |
# File 'lib/terjira/option_support/option_selector.rb', line 146 def write_comment fetch(:comment) do if with_editor? Editor.editor_text else prompt_multiline('Comment') end end end |
#write_description ⇒ Object
168 169 170 171 172 173 174 175 176 |
# File 'lib/terjira/option_support/option_selector.rb', line 168 def write_description fetch(:description) do if with_editor? Editor.editor_text else prompt_multiline('Description') end end end |
#write_epic_name ⇒ Object
142 143 144 |
# File 'lib/terjira/option_support/option_selector.rb', line 142 def write_epic_name option_prompt.ask('Epic name?') end |
#write_epiclink_key ⇒ Object
136 137 138 139 140 |
# File 'lib/terjira/option_support/option_selector.rb', line 136 def write_epiclink_key fetch(:epiclink) do option_prompt.ask('Epic key?') end end |
#write_parent_issue_key ⇒ Object
182 183 184 |
# File 'lib/terjira/option_support/option_selector.rb', line 182 def write_parent_issue_key fetch(:parent) { option_prompt.ask('Parent issue key?') } end |
#write_summary ⇒ Object
178 179 180 |
# File 'lib/terjira/option_support/option_selector.rb', line 178 def write_summary fetch(:summary) { option_prompt.ask('Summary?') } end |