Skip to content
This repository has been archived by the owner on Sep 29, 2020. It is now read-only.

Commit

Permalink
Revert "Actually use constants for a couple private variables."
Browse files Browse the repository at this point in the history
This reverts commit e270329.
  • Loading branch information
tristandunn committed Jun 25, 2010
1 parent c451a02 commit 29239d6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
18 changes: 8 additions & 10 deletions lib/hoptoad-notifier.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
var HTTP = require('http');

const BACKTRACE_MATCHER = /\s+at (.*) \(([^\:]+)\:(\d+)\:(\d+)\)/;
const NOTICE_XML = '<?xml version="1.0" encoding="UTF-8"?><notice version="2.0"><api-key>API_KEY</api-key><notifier><name>node-hoptoad-notifier</name><version>0.1.0</version><url>http://github.com/tristandunn/node-hoptoad-notifier</url></notifier><error><class>EXCEPTION_CLASS</class><message>EXCEPTION_MESSAGE</message><backtrace>BACKTRACE_LINES</backtrace></error><server-environment><project-root>PROJECT_ROOT</project-root><environment-name></environment-name></server-environment></notice>';

var HTTP = require('http');
var Hoptoad = {
ROOT : process.cwd(),
VERSION : '0.1.0',
root : process.cwd(),
NOTICE_XML : '<?xml version="1.0" encoding="UTF-8"?><notice version="2.0"><api-key>API_KEY</api-key><notifier><name>node-hoptoad-notifier</name><version>0.1.0</version><url>http://github.com/tristandunn/node-hoptoad-notifier</url></notifier><error><class>EXCEPTION_CLASS</class><message>EXCEPTION_MESSAGE</message><backtrace>BACKTRACE_LINES</backtrace></error><server-environment><project-root>PROJECT_ROOT</project-root><environment-name></environment-name></server-environment></notice>',
BACKTRACE_MATCHER : /\s+at (.*) \(([^\:]+)\:(\d+)\:(\d+)\)/,
backtrace_filters : [/hoptoad-notifier\.js/],

notify: function(error) {
Expand Down Expand Up @@ -66,10 +64,10 @@ var Hoptoad = {
return !line.match(filter);
});
}).map(function(line) {
var matches = line.match(BACKTRACE_MATCHER);
var matches = line.match(Hoptoad.BACKTRACE_MATCHER);

if (matches) {
var file = matches[2].replace(Hoptoad.root, '[PROJECT_ROOT]');
var file = matches[2].replace(Hoptoad.ROOT, '[PROJECT_ROOT]');

return '<line method="' + Hoptoad.escapeText(matches[1]) +
'" file="' + Hoptoad.escapeText(file) +
Expand All @@ -81,8 +79,8 @@ var Hoptoad = {
},

generateXML: function(error) {
var xml = NOTICE_XML;
var root = Hoptoad.escapeText(Hoptoad.root);
var xml = Hoptoad.NOTICE_XML;
var root = Hoptoad.escapeText(Hoptoad.ROOT);
var type = Hoptoad.escapeText(error.type || 'Error');
var message = Hoptoad.escapeText(error.message || 'Unknown error.');
var backtrace = Hoptoad.generateBacktrace(error);
Expand Down
2 changes: 1 addition & 1 deletion spec/unit/spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ JSpec.describe('Hoptoad', function() {
});

it('should replace root path with [PROJECT_ROOT] in file path', function() {
var path = Hoptoad.root;
var path = Hoptoad.ROOT;
var backtraceXML = Hoptoad.generateBacktrace({
stack : " at exampleFunction (" + path + "/file.js:10:1)"
});
Expand Down

0 comments on commit 29239d6

Please sign in to comment.