Class: Bl::Type

Inherits:
Thor
  • Object
show all
Includes:
Formatting, Requestable
Defined in:
lib/bl/type.rb

Instance Method Summary collapse

Methods included from Formatting

colorize_priority, colorize_status, colorize_type, print_issue

Methods included from Requestable

client

Constructor Details

#initializeType

Returns a new instance of Type.



6
7
8
9
10
# File 'lib/bl/type.rb', line 6

def initialize(*)
  @config = Bl::Config.instance
  @url = "projects/#{@config[:project_key]}/issueTypes"
  super
end

Instance Method Details

#add(*names) ⇒ Object



21
22
23
24
25
26
# File 'lib/bl/type.rb', line 21

def add(*names)
  names.each do |name|
    res = client.post(@url, name: name, color: options[:color])
    puts "type added: #{res.body.id}\t#{res.body.name}\t#{res.body.color}"
  end
end

#delete(*ids) ⇒ Object



40
41
42
43
44
45
# File 'lib/bl/type.rb', line 40

def delete(*ids)
  ids.each do |id|
    res = client.delete("#{@url}/#{id}", options)
    puts "type deleted: #{res.body.id}\t#{res.body.name}\t#{res.body.color}"
  end
end

#listObject



13
14
15
16
17
# File 'lib/bl/type.rb', line 13

def list
  client.get(@url).body.each do |t|
    puts [t.id, colorize_type(t.name, t.color), t.color].join("\t")
  end
end

#update(*ids) ⇒ Object



31
32
33
34
35
36
# File 'lib/bl/type.rb', line 31

def update(*ids)
  ids.each do |id|
    res = client.patch("#{@url}/#{id}", options)
    puts "type updated: #{res.body.id}\t#{res.body.name}\t#{res.body.color}"
  end
end