Class: Jira::Format

Inherits:
Object
  • Object
show all
Defined in:
lib/jira/format.rb

Class Method Summary collapse

Class Method Details

.comment(comment) ⇒ Object



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/jira/format.rb', line 45

def comment(comment)
  comment = self.wrap(comment)
  comment.gsub!(/\[~[a-z]+\]/, '[[[\0]]]')
  comment.gsub!(
    '[[[[~',
    "#{Thor::Shell::Color::BOLD}"\
    "#{Thor::Shell::Color::WHITE}"\
    "("\
    "#{Thor::Shell::Color::MAGENTA}"\
    "@"
  )
  comment.gsub!(
    ']]]]',
    "#{Thor::Shell::Color::WHITE}"\
    ")"\
    "#{Thor::Shell::Color::CLEAR}"
  )
  comment
end

.starObject



5
6
7
8
9
10
# File 'lib/jira/format.rb', line 5

def star
  "#{Thor::Shell::Color::BOLD}"\
  "#{Thor::Shell::Color::YELLOW}"\
  "*"\
  "#{Thor::Shell::Color::CLEAR}"
end

.status(status) ⇒ Object



18
19
20
21
22
23
24
# File 'lib/jira/format.rb', line 18

def status(status)
  "["\
  "#{Thor::Shell::Color::BLUE}"\
  "#{status}"\
  "#{Thor::Shell::Color::CLEAR}"\
  "]"
end

.summary(summary) ⇒ Object



26
27
28
29
30
31
# File 'lib/jira/format.rb', line 26

def summary(summary)
  "#{Thor::Shell::Color::BOLD}"\
  "#{Thor::Shell::Color::WHITE}"\
  "#{summary}"\
  "#{Thor::Shell::Color::CLEAR}"
end

.ticket(ticket) ⇒ Object



12
13
14
15
16
# File 'lib/jira/format.rb', line 12

def ticket(ticket)
  "#{Thor::Shell::Color::RED}"\
  "#{ticket}"\
  "#{Thor::Shell::Color::CLEAR}"
end

.time(time) ⇒ Object



39
40
41
42
43
# File 'lib/jira/format.rb', line 39

def time(time)
  "#{Thor::Shell::Color::BLUE}"\
  "#{time.strftime('%l:%M%P on %b %d, %Y').strip}"\
  "#{Thor::Shell::Color::CLEAR}"
end

.user(user) ⇒ Object



33
34
35
36
37
# File 'lib/jira/format.rb', line 33

def user(user)
  "#{Thor::Shell::Color::MAGENTA}"\
  "#{user}"\
  "#{Thor::Shell::Color::CLEAR}"
end

.wrap(text) ⇒ Object



65
66
67
68
69
70
71
72
73
74
# File 'lib/jira/format.rb', line 65

def wrap(text)
  width = 80
  text.split("\n").collect do |line|
    if line.length > width
      line.gsub(/(.{1,#{width}})(\s+|$)/, "\\1\n").strip
    else
      line
    end
  end * "\n"
end