Class: IssueTrackers::CloudfujiTracker

Inherits:
IssueTracker
  • Object
show all
Defined in:
app/models/issue_trackers/cloudfuji_tracker.rb

Constant Summary collapse

Label =
"cloudfuji"
Fields =
[
  [:project_id, {
    :label       => "Project Ido ID",
    :placeholder => "Ido ID of project to create task on"
  }]
]

Instance Method Summary collapse

Instance Method Details

#body_templateObject



48
49
50
# File 'app/models/issue_trackers/cloudfuji_tracker.rb', line 48

def body_template
  @@body_template ||= ERB.new(File.read(File.expand_path("../../../views/issue_trackers/cloudfuji_body.txt.erb", __FILE__)).gsub(/^\s*/, ''))
end

#check_paramsObject



11
12
13
14
15
# File 'app/models/issue_trackers/cloudfuji_tracker.rb', line 11

def check_params
  if Fields.detect {|f| self[f[0]].blank? }
    errors.add :base, 'You must specify your Project Ido ID'
  end
end

#create_issue(problem, reported_by) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'app/models/issue_trackers/cloudfuji_tracker.rb', line 17

def create_issue(problem, reported_by)
  if ::Cloudfuji::Platform.on_cloudfuji?
    err = problem.errs.last

    event = {
      :category => :project_task,
      :name     => :created,
      :data     => {
        :ido_id          => err.ido_id,
        :title           => issue_title(problem),
        :description     => body_template.result(binding),
        :task_type       => 'bug',
        :state           => 'unscheduled',
        :requested_by_id => reported_by.ido_id,
        :project_id      => project_id,
        :labels          => "errbit"
      }
    }

    puts "Publishing Cloudfuji Event: #{event.inspect}"

    ::Cloudfuji::Event.publish(event)

    # Display 'pending' message until tracker responds with url
    problem.update_attributes(
      :issue_link => "pending",
      :issue_type => Label
    )
  end
end

#urlObject



52
53
54
# File 'app/models/issue_trackers/cloudfuji_tracker.rb', line 52

def url
  "http://cloudfuji.com"
end