Class: Jira::CLI

Inherits:
Thor
  • Object
show all
Includes:
Thor::Actions, Thor::Shell
Defined in:
lib/jira.rb,
lib/jira/lookup.rb,
lib/jira/mixins.rb,
lib/jira/install.rb,
lib/jira/version.rb

Instance Method Summary collapse

Instance Method Details

#all ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/jira/lookup.rb', line 18

def all
  tickets = []
  branches = ex("git branch").delete("*").split("\n")
  branches.each do |branch|
    stripped = branch.strip
    if !!stripped[/^[a-zA-Z]+-[0-9]+$/]
      tickets << stripped
    end
  end

  threads = []
  tickets.each do |ticket|
    threads << Thread.new{ self.summarize(ticket) }
  end
  threads.each{ |thread| thread.join }
end

#comment(ticket = nil) ⇒ Object



36
37
38
39
40
# File 'lib/jira/lookup.rb', line 36

def comment(ticket=nil)
  say "Coming soon"
  #ticket ||= ex('get rev-parse --abbrev-ref HEAD')
  #json = self.api_post("issue/#{ticket}")
end

#install ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/jira/install.rb', line 9

def install
  create_file self.jira_url_path, nil, verbose:false do
    self.cli.ask("Enter your JIRA URL: ")
  end

  create_file self.jira_auth_path, nil, verbose:false do
    username = self.cli.ask("Enter your JIRA username: ")
    password = self.cli.ask("Enter your JIRA password: ") do |q|
      q.echo = false
    end
    "#{username}:#{password}"
  end

  self.discard_memoized
end

#summarize(ticket = nil) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
# File 'lib/jira/lookup.rb', line 5

def summarize(ticket=nil)
  ticket ||= ex('git rev-parse --abbrev-ref HEAD')
  json = self.api_get("issue/#{ticket}")
  summary = json['fields']['summary']
  status = json['fields']['status']['name']
  self.mutex.synchronize do
    say "#{self.colored_ticket(ticket)} "\
        "#{self.colored_status(status).center(26)} "\
        "#{self.colored_summary(summary)}"
  end
end

#transition(ticket = nil) ⇒ Object



43
44
45
# File 'lib/jira/lookup.rb', line 43

def transition(ticket=nil)
  say "Coming soon"
end

#version ⇒ Object



5
6
7
# File 'lib/jira/version.rb', line 5

def version
  say "jira #{Jira::VERSION}"
end