Class: RedmineCLI::Subcommands::Issue

Inherits:
Thor
  • Object
show all
Extended by:
Helpers::Output
Includes:
Helpers::Output, RedmineRest
Defined in:
lib/redmine_cli/subcommands/issue.rb

Overview

All methods for working with issues, e.g. listing, linking, updating…

Instance Method Summary collapse

Methods included from Helpers::Output

erb, message, print_object_list, print_prompt_message

Instance Method Details

#createObject



64
65
66
67
68
69
70
71
72
# File 'lib/redmine_cli/subcommands/issue.rb', line 64

def create
  self.class.include Helpers::Issue::Create

  @issue = Models::Issue.new
  set_attributes

  @issue.save
  puts 'Done.'
end

#list(id = 'current') ⇒ Object



16
17
18
19
20
# File 'lib/redmine_cli/subcommands/issue.rb', line 16

def list(id = 'current')
  fail('new config') if Config.new?

  puts erb('issue/list', issues: Models::User.find(id).issues)
end

#show(id) ⇒ Object



24
25
26
27
28
29
# File 'lib/redmine_cli/subcommands/issue.rb', line 24

def show(id)
  puts erb('issue/show', issue: Models::Issue.find(id), journals_limit: options[:limit])

rescue ActiveResource::ResourceNotFound # WARNING: it can be raised by associations in template
  puts m(:not_found)
end

#update(id) ⇒ Object



48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/redmine_cli/subcommands/issue.rb', line 48

def update(id)
  # load helpers inside instance method for better performance
  self.class.include Helpers::Issue::Update

  issue = Models::Issue.find(id)
  if update_issue(issue) # update_issue will return nil/false if something goes wrong
    puts m(issue.save ? :success : :error)
  else
    @errors.each { |e| puts e }
  end

rescue ActiveResource::ResourceNotFound
  puts m(:not_found)
end