Skip to content

Commit

Permalink
modular code style
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenplusplus committed Aug 4, 2016
1 parent 8a4da49 commit faa67d0
Show file tree
Hide file tree
Showing 36 changed files with 214 additions and 430 deletions.
4 changes: 2 additions & 2 deletions packages/google-cloud-compute/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@
"string-format-obj": "^1.0.0"
},
"devDependencies": {
"mocha": "^2.1.0",
"concat-stream": "^1.5.0",
"mocha": "^3.0.1",
"propprop": "^0.3.0",
"proxyquire": "^1.7.10"
},
Expand All @@ -75,4 +75,4 @@
"engines": {
"node": ">=0.12.0"
}
}
}
20 changes: 4 additions & 16 deletions packages/google-cloud-compute/src/address.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,7 @@
'use strict';

var common = require('@google-cloud/common');
var nodeutil = require('util');

/**
* @type {module:common/service-object}
* @private
*/
var ServiceObject = common.ServiceObject;

/**
* @type {module:common/util}
* @private
*/
var util = common.util;
var util = require('util');

/*! Developer Documentation
*
Expand Down Expand Up @@ -129,7 +117,7 @@ function Address(region, name) {
getMetadata: true
};

ServiceObject.call(this, {
common.ServiceObject.call(this, {
parent: region,
baseUrl: '/addresses',
id: name,
Expand All @@ -141,7 +129,7 @@ function Address(region, name) {
this.region = region;
}

nodeutil.inherits(Address, ServiceObject);
util.inherits(Address, common.ServiceObject);

/**
* Delete the address.
Expand All @@ -161,7 +149,7 @@ nodeutil.inherits(Address, ServiceObject);
* });
*/
Address.prototype.delete = function(callback) {
callback = callback || util.noop;
callback = callback || common.util.noop;

var region = this.region;

Expand Down
24 changes: 6 additions & 18 deletions packages/google-cloud-compute/src/autoscaler.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,7 @@
'use strict';

var common = require('@google-cloud/common');
var nodeutil = require('util');

/**
* @type {module:common/service-object}
* @private
*/
var ServiceObject = common.ServiceObject;

/**
* @type {module:common/util}
* @private
*/
var util = common.util;
var util = require('util');

/*! Developer Documentation
*
Expand Down Expand Up @@ -135,7 +123,7 @@ function Autoscaler(zone, name) {
getMetadata: true
};

ServiceObject.call(this, {
common.ServiceObject.call(this, {
parent: zone,
baseUrl: '/autoscalers',
id: name,
Expand All @@ -147,7 +135,7 @@ function Autoscaler(zone, name) {
this.zone = zone;
}

nodeutil.inherits(Autoscaler, ServiceObject);
util.inherits(Autoscaler, common.ServiceObject);

/**
* Delete the autoscaler.
Expand All @@ -167,11 +155,11 @@ nodeutil.inherits(Autoscaler, ServiceObject);
* });
*/
Autoscaler.prototype.delete = function(callback) {
callback = callback || util.noop;
callback = callback || common.util.noop;

var zone = this.zone;

ServiceObject.prototype.delete.call(this, function(err, resp) {
common.ServiceObject.prototype.delete.call(this, function(err, resp) {
if (err) {
callback(err, null, resp);
return;
Expand Down Expand Up @@ -210,7 +198,7 @@ Autoscaler.prototype.delete = function(callback) {
Autoscaler.prototype.setMetadata = function(metadata, callback) {
var zone = this.zone;

callback = callback || util.noop;
callback = callback || common.util.noop;

metadata = metadata || {};
metadata.name = this.name;
Expand Down
22 changes: 5 additions & 17 deletions packages/google-cloud-compute/src/disk.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,26 +24,14 @@ var common = require('@google-cloud/common');
var extend = require('extend');
var format = require('string-format-obj');
var is = require('is');
var nodeutil = require('util');

/**
* @type {module:common/service-object}
* @private
*/
var ServiceObject = common.ServiceObject;
var util = require('util');

/**
* @type {module:compute/snapshot}
* @private
*/
var Snapshot = require('./snapshot.js');

/**
* @type {module:common/util}
* @private
*/
var util = common.util;

/*! Developer Documentation
*
* @param {module:zone} zone - Zone this disk belongs to.
Expand Down Expand Up @@ -141,7 +129,7 @@ function Disk(zone, name) {
getMetadata: true
};

ServiceObject.call(this, {
common.ServiceObject.call(this, {
parent: zone,
baseUrl: '/disks',
id: name,
Expand All @@ -155,7 +143,7 @@ function Disk(zone, name) {
this.formattedName = Disk.formatName_(zone, name);
}

nodeutil.inherits(Disk, ServiceObject);
util.inherits(Disk, common.ServiceObject);

/**
* Format a disk's name how the API expects.
Expand Down Expand Up @@ -252,9 +240,9 @@ Disk.prototype.createSnapshot = function(name, options, callback) {
Disk.prototype.delete = function(callback) {
var zone = this.zone;

callback = callback || util.noop;
callback = callback || common.util.noop;

ServiceObject.prototype.delete.call(this, function(err, resp) {
common.ServiceObject.prototype.delete.call(this, function(err, resp) {
if (err) {
callback(err, null, resp);
return;
Expand Down
24 changes: 6 additions & 18 deletions packages/google-cloud-compute/src/firewall.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,7 @@
'use strict';

var common = require('@google-cloud/common');
var nodeutil = require('util');

/**
* @type {module:common/service-object}
* @private
*/
var ServiceObject = common.ServiceObject;

/**
* @type {module:common/util}
* @private
*/
var util = common.util;
var util = require('util');

/*! Developer Documentation
*
Expand Down Expand Up @@ -131,7 +119,7 @@ function Firewall(compute, name) {
getMetadata: true
};

ServiceObject.call(this, {
common.ServiceObject.call(this, {
parent: compute,
baseUrl: '/global/firewalls',
id: name,
Expand All @@ -144,7 +132,7 @@ function Firewall(compute, name) {
this.metadata.network = 'global/networks/default';
}

nodeutil.inherits(Firewall, ServiceObject);
util.inherits(Firewall, common.ServiceObject);

/**
* Delete the firewall.
Expand All @@ -166,9 +154,9 @@ nodeutil.inherits(Firewall, ServiceObject);
Firewall.prototype.delete = function(callback) {
var compute = this.compute;

callback = callback || util.noop;
callback = callback || common.util.noop;

ServiceObject.prototype.delete.call(this, function(err, resp) {
common.ServiceObject.prototype.delete.call(this, function(err, resp) {
if (err) {
callback(err, null, resp);
return;
Expand Down Expand Up @@ -207,7 +195,7 @@ Firewall.prototype.delete = function(callback) {
Firewall.prototype.setMetadata = function(metadata, callback) {
var compute = this.compute;

callback = callback || util.noop;
callback = callback || common.util.noop;

metadata = metadata || {};
metadata.name = this.name;
Expand Down
28 changes: 9 additions & 19 deletions packages/google-cloud-compute/src/health-check.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,7 @@
var common = require('@google-cloud/common');
var extend = require('extend');
var is = require('is');
var nodeutil = require('util');

/**
* @type {module:common/service-object}
* @private
*/
var ServiceObject = common.ServiceObject;

/**
* @type {module:common/util}
* @private
*/
var util = common.util;
var util = require('util');

/*! Developer Documentation
*
Expand Down Expand Up @@ -143,7 +131,7 @@ function HealthCheck(compute, name, options) {
var https = options.https;
this.compute = compute;

ServiceObject.call(this, {
common.ServiceObject.call(this, {
parent: compute,
baseUrl: '/global/' + (https ? 'httpsHealthChecks' : 'httpHealthChecks'),
id: name,
Expand All @@ -161,7 +149,7 @@ function HealthCheck(compute, name, options) {
});
}

nodeutil.inherits(HealthCheck, ServiceObject);
util.inherits(HealthCheck, common.ServiceObject);

/**
* Delete the health check.
Expand All @@ -184,9 +172,9 @@ nodeutil.inherits(HealthCheck, ServiceObject);
HealthCheck.prototype.delete = function(callback) {
var compute = this.compute;

callback = callback || util.noop;
callback = callback || common.util.noop;

ServiceObject.prototype.delete.call(this, function(err, resp) {
common.ServiceObject.prototype.delete.call(this, function(err, resp) {
if (err) {
callback(err, null, resp);
return;
Expand Down Expand Up @@ -227,9 +215,11 @@ HealthCheck.prototype.delete = function(callback) {
HealthCheck.prototype.setMetadata = function(metadata, callback) {
var compute = this.compute;

callback = callback || util.noop;
callback = callback || common.util.noop;

var setMetadata = common.ServiceObject.prototype.setMetadata;

ServiceObject.prototype.setMetadata.call(this, metadata, function(err, resp) {
setMetadata.call(this, metadata, function(err, resp) {
if (err) {
callback(err, null, resp);
return;
Expand Down
Loading

0 comments on commit faa67d0

Please sign in to comment.