Class: Redcuine::Issue

Inherits:
Base
  • Object
show all
Defined in:
lib/redcuine/issue.rb

Constant Summary collapse

@@default_param =
{}
@@issue_attribute_keys =
[:subject, :description, :tracker_id, :status_id,
:category_id, :assigned_to_id, :priority_id, :fixed_version,
:start_date, :due_date, :estimate_date, :done_ratio]

Class Method Summary collapse

Class Method Details

.deleteObject



63
64
65
66
67
68
69
70
71
72
73
# File 'lib/redcuine/issue.rb', line 63

def self.delete
  issue = Resource::Issue.find(CONFIG["id"])
  res = issue.destroy
  puts res ? "Destroyed issue!" : "Fail to destroy issue."
  return res
rescue
  puts $!.to_s
  puts $!.backtrace if CONFIG["debug"]
  puts "Fail to destroy issue."
  return false
end

.getObject



18
19
20
21
22
23
24
25
# File 'lib/redcuine/issue.rb', line 18

def self.get
  CONFIG["id"] ? show(CONFIG["id"]) : index
rescue
  puts $!.to_s
  puts $!.backtrace if CONFIG["debug"]
  puts "Fail to get issue."
  return false
end

.postObject



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/redcuine/issue.rb', line 27

def self.post
  keys = [:project_id] + @@issue_attribute_keys
  opts = rest_options(keys, @@default_param)
  opts[:description] = description_by_editor if CONFIG["editor"]
  issue = Resource::Issue.new(opts)
  issue.save!
  puts "Created issue!"
  CONFIG["id"] = issue.id
  get
  return true
rescue
  puts $!.to_s
  puts $!.backtrace if CONFIG["debug"]
  puts "Fail to create issue."
  return false
end

.putObject



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/redcuine/issue.rb', line 44

def self.put
  opts = rest_options(@@issue_attribute_keys, @@default_param)
  issue = Resource::Issue.find(CONFIG["id"])
  if CONFIG["editor"]
    opts[:description] = description_by_editor(issue.description)
  end
  issue.load(opts)
  issue.save!
  puts "Updated issue!"
  CONFIG["id"] = issue.id
  get
  return true
rescue
  puts $!.to_s
  puts $!.backtrace if CONFIG["debug"]
  puts "Fail to update issue."
  return false
end

.runObject



10
11
12
13
14
15
16
# File 'lib/redcuine/issue.rb', line 10

def self.run
  if super
    @@default_param = {:key => CONFIG["api_key"]} if CONFIG["enable_api_key"]
    return self.send(CONFIG['rest_type'])
  end
  return false
end