Class: ErrbitUnfuddlePlugin::IssueTracker
- Inherits:
-
ErrbitPlugin::IssueTracker
- Object
- ErrbitPlugin::IssueTracker
- ErrbitUnfuddlePlugin::IssueTracker
- Defined in:
- lib/errbit_unfuddle_plugin/issue_tracker.rb
Constant Summary collapse
- LABEL =
'unfuddle'- NOTE =
''- FIELDS =
[ [:account, { :placeholder => "account-name (from account-name.unfuddle.com)" }], [:username, { :placeholder => "Your username" }], [:password, { :placeholder => "Your password" }], [:project_id, { :label => "Ticket Project ID", :placeholder => "Project where tickets will be created" }], [:milestone_id, { :optional => true, :label => "Ticket Milestone ID", :placeholder => "Milestone where tickets will be created" }] ]
Class Method Summary collapse
Instance Method Summary collapse
- #comments_allowed? ⇒ Boolean
- #configured? ⇒ Boolean
- #create_issue(problem, reported_by = nil) ⇒ Object
- #errors ⇒ Object
- #url ⇒ Object
Class Method Details
.body_template ⇒ Object
41 42 43 44 45 46 47 |
# File 'lib/errbit_unfuddle_plugin/issue_tracker.rb', line 41 def self.body_template @body_template ||= ERB.new(File.read( File.join( ErrbitUnfuddlePlugin.root, 'views', 'unfuddle_issues_body.txt.erb' ) )) end |
.fields ⇒ Object
37 38 39 |
# File 'lib/errbit_unfuddle_plugin/issue_tracker.rb', line 37 def self.fields FIELDS end |
.label ⇒ Object
29 30 31 |
# File 'lib/errbit_unfuddle_plugin/issue_tracker.rb', line 29 def self.label LABEL end |
.note ⇒ Object
33 34 35 |
# File 'lib/errbit_unfuddle_plugin/issue_tracker.rb', line 33 def self.note NOTE end |
Instance Method Details
#comments_allowed? ⇒ Boolean
61 |
# File 'lib/errbit_unfuddle_plugin/issue_tracker.rb', line 61 def comments_allowed?; false; end |
#configured? ⇒ Boolean
57 58 59 |
# File 'lib/errbit_unfuddle_plugin/issue_tracker.rb', line 57 def configured? errors.empty? end |
#create_issue(problem, reported_by = nil) ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/errbit_unfuddle_plugin/issue_tracker.rb', line 71 def create_issue(problem, reported_by = nil) ErrbitUnfuddlePlugin.config(params['account'], params['username'], params['password']) begin = { :project_id => params['project_id'], :summary => "[#{ problem.environment }][#{ problem.where }] #{problem.message.to_s.truncate(100)}", :priority => '5', :status => "new", :description => self.class.body_template.result(binding), 'description-format' => 'textile' } if params['milestone_id'].present? [:milestone_id] = params['milestone_id'] end issue = ErrbitUnfuddlePlugin::Ticket.create() problem.update_attributes( :issue_link => File.join("#{url}/tickets/#{issue.id}"), :issue_type => self.class.label ) rescue ActiveResource:: raise ActiveResource::, "Could not authenticate with Unfuddle. Please check your username and password." end end |
#errors ⇒ Object
63 64 65 66 67 68 69 |
# File 'lib/errbit_unfuddle_plugin/issue_tracker.rb', line 63 def errors errors = [] if self.class.fields.detect {|f| !f[1][:optional] && params[f[0].to_s].blank? } errors << [:base, 'You must specify your Account, Username, Password and Project ID'] end errors end |
#url ⇒ Object
49 50 51 52 53 54 55 |
# File 'lib/errbit_unfuddle_plugin/issue_tracker.rb', line 49 def url sprintf( "https://%s.unfuddle.com/projects/%s", params['account'], params['project_id'] ) end |