Class: CreateTicket::CLI
- Inherits:
-
Object
- Object
- CreateTicket::CLI
- Defined in:
- lib/create_ticket/cli.rb
Instance Method Summary collapse
- #assignee ⇒ Object
- #custom_fields ⇒ Object
- #duedate ⇒ Object
- #issue_type ⇒ Object
- #jira_token ⇒ Object
- #jira_url ⇒ Object
- #project ⇒ Object
- #prompt_for_jira_token ⇒ Object
- #run! ⇒ Object
- #template_filename ⇒ Object
Instance Method Details
#assignee ⇒ Object
32 33 34 |
# File 'lib/create_ticket/cli.rb', line 32 def assignee ENV.fetch('JIRA_ASSIGNEE') end |
#custom_fields ⇒ Object
40 41 42 43 |
# File 'lib/create_ticket/cli.rb', line 40 def custom_fields ENV.select { |k, _| k.start_with? 'JIRA_CUSTOMFIELD' }.to_a .map { |k, v| [k.downcase.sub(/^jira_/, ''), v] }.to_h end |
#duedate ⇒ Object
45 46 47 |
# File 'lib/create_ticket/cli.rb', line 45 def duedate ENV['JIRA_DUEDATE'] end |
#issue_type ⇒ Object
36 37 38 |
# File 'lib/create_ticket/cli.rb', line 36 def issue_type ENV.fetch('JIRA_ISSUE_TYPE') end |
#jira_token ⇒ Object
24 25 26 |
# File 'lib/create_ticket/cli.rb', line 24 def jira_token ENV.fetch('JIRA_TOKEN') { prompt_for_jira_token } end |
#jira_url ⇒ Object
9 10 11 |
# File 'lib/create_ticket/cli.rb', line 9 def jira_url ENV.fetch('JIRA_URL') end |
#project ⇒ Object
13 14 15 |
# File 'lib/create_ticket/cli.rb', line 13 def project ENV.fetch('JIRA_PROJECT') end |
#prompt_for_jira_token ⇒ Object
17 18 19 20 21 22 |
# File 'lib/create_ticket/cli.rb', line 17 def prompt_for_jira_token cli = HighLine.new username = cli.ask('Username: ') password = cli.ask('Password: ') { |q| q.echo = '*' } Base64.encode64 "#{username}:#{password}" end |
#run! ⇒ Object
49 50 51 52 53 54 55 |
# File 'lib/create_ticket/cli.rb', line 49 def run! ticket_url = CreateTicket.new(self).create_ticket! puts ticket_url rescue CouldNotCreateTicketError, KeyError, JSON::ParserError => e puts e. exit 1 end |
#template_filename ⇒ Object
28 29 30 |
# File 'lib/create_ticket/cli.rb', line 28 def template_filename ENV.fetch('TEMPLATE_FILENAME') end |