edit-google-spreadsheet
Advanced tools
Comparing version
60
index.js
@@ -8,6 +8,16 @@ | ||
_ = require("underscore"), | ||
num = require("../utils").num, | ||
GoogleClientLogin = require('googleclientlogin').GoogleClientLogin; | ||
//parse number | ||
var num = function(obj) { | ||
if(obj === undefined) return 0; | ||
if(typeof obj === 'number') return obj; | ||
if(typeof obj === 'string') { | ||
var res = parseFloat(obj, 10); | ||
if(isNaN(res)) return obj; | ||
return res; | ||
} | ||
throw "Invalid number: " + JSON.stringify(obj); | ||
}; | ||
//spreadsheet class | ||
@@ -20,12 +30,2 @@ function Spreadsheet() { | ||
Spreadsheet.create = function(usr, pw, spreadsheetId, worksheetId, done) { | ||
var s = new Spreadsheet(); | ||
s.spreadsheetId = spreadsheetId; | ||
s.worksheetId = worksheetId; | ||
s.setTemplates(); | ||
s.auth(usr, pw, function(err) { | ||
done(err, s); | ||
}); | ||
}; | ||
Spreadsheet.prototype.auth = function(usr, pw, done) { | ||
@@ -62,2 +62,3 @@ if(!usr || !pw || !done) return; | ||
Spreadsheet.prototype.setTemplates = function() { | ||
this.bodyTemplate = _.template( | ||
@@ -219,2 +220,7 @@ '<feed xmlns="http://www.w3.org/2005/Atom"\n' + | ||
if(!this.token) | ||
return callback("No authorization token. Use auth() first."); | ||
if(!this.bodyTemplate || !this.entryTemplate) | ||
return callback("No templates have been created. Use setTemplates() first."); | ||
var _this = this, | ||
@@ -259,4 +265,30 @@ entries = this.toString(), | ||
//entry point | ||
module.exports = Spreadsheet; | ||
//public api | ||
module.exports = { | ||
create: function(opts) { | ||
var s = new Spreadsheet(); | ||
if(!opts.callback) throw "Missing callback"; | ||
var check = function(n) { | ||
if(opts[n]) | ||
return true; | ||
else | ||
opts.callback("Missing '"+n+"'"); | ||
return false; | ||
}; | ||
if(!(check('username') && | ||
check('password') && | ||
check('worksheetId') && | ||
check('worksheetId'))) return; | ||
s.spreadsheetId = opts.spreadsheetId; | ||
s.worksheetId = opts.worksheetId; | ||
s.setTemplates(); | ||
s.auth(opts.username, opts.password, function(err) { | ||
opts.callback(err, s); | ||
}); | ||
} | ||
}; | ||
{ | ||
"name": "edit-google-spreadsheet", | ||
"version": "0.0.1", | ||
"dependencies": { | ||
"colors": "*", | ||
"request": "*", | ||
"underscore": "*", | ||
"coffee-script": "*" | ||
}, | ||
"version": "0.0.2", | ||
"dependencies": [ | ||
"colors", | ||
"underscore", | ||
"request", | ||
"googleclientlogin" | ||
], | ||
"engines": { | ||
@@ -11,0 +11,0 @@ "node": "~0.8.x" |
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 4 instances in 1 package
Wildcard dependency
QualityPackage has a dependency with a floating version range. This can cause issues if the dependency publishes a new major version.
Found 4 instances in 1 package
7693
11.36%234
13.04%0
-100%4
Infinity%+ Added
+ Added
+ Added
+ Added
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed