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 539ebd5 commit bb84b2b
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 50 deletions.
4 changes: 2 additions & 2 deletions packages/google-cloud-resourcemanager/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
"devDependencies": {
"arrify": "^1.0.0",
"google-auto-auth": "^0.2.4",
"mocha": "^2.1.0",
"mocha": "^3.0.1",
"proxyquire": "^1.7.10"
},
"scripts": {
Expand All @@ -69,4 +69,4 @@
"engines": {
"node": ">=0.12.0"
}
}
}
29 changes: 6 additions & 23 deletions packages/google-cloud-resourcemanager/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,32 +23,15 @@
var common = require('@google-cloud/common');
var extend = require('extend');
var is = require('is');
var nodeutil = require('util');
var PKG = require('../package.json');
var util = require('util');

/**
* @type {module:resource/project}
* @private
*/
var Project = require('./project.js');

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

/**
* @type {module:common/stream-router}
* @private
*/
var streamRouter = common.streamRouter;

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

/**
* [The Cloud Resource Manager](https://cloud.google.com/resource-manager/)
Expand Down Expand Up @@ -89,7 +72,7 @@ var util = common.util;
*/
function Resource(options) {
if (!(this instanceof Resource)) {
options = util.normalizeArguments(this, options, {
options = common.util.normalizeArguments(this, options, {
projectIdRequired: false
});
return new Resource(options);
Expand All @@ -102,12 +85,12 @@ function Resource(options) {
userAgent: PKG.name + '/' + PKG.version
};

Service.call(this, config, options);
common.Service.call(this, config, options);

this.defaultProjectId_ = options.projectId;
}

nodeutil.inherits(Resource, Service);
util.inherits(Resource, common.Service);

/**
* Create a project.
Expand Down Expand Up @@ -289,7 +272,7 @@ Resource.prototype.project = function(id) {
* These methods can be used with either a callback or as a readable object
* stream. `streamRouter` is used to add this dual behavior.
*/
streamRouter.extend(Resource, ['getProjects']);
common.streamRouter.extend(Resource, ['getProjects']);

Resource.Project = Project;

Expand Down
20 changes: 4 additions & 16 deletions packages/google-cloud-resourcemanager/src/project.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 @@ -188,7 +176,7 @@ function Project(resource, id) {
}
};

ServiceObject.call(this, {
common.ServiceObject.call(this, {
parent: resource,
baseUrl: '/projects',
id: id,
Expand All @@ -197,7 +185,7 @@ function Project(resource, id) {
});
}

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

/**
* Restore a project.
Expand All @@ -219,7 +207,7 @@ nodeutil.inherits(Project, ServiceObject);
* });
*/
Project.prototype.restore = function(callback) {
callback = callback || util.noop;
callback = callback || common.util.noop;

this.request({
method: 'POST',
Expand Down
16 changes: 8 additions & 8 deletions packages/google-cloud-resourcemanager/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,22 @@ var assert = require('assert');
var extend = require('extend');
var nodeutil = require('util');
var proxyquire = require('proxyquire');

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

var PKG = require('../package.json');

function FakeProject() {
this.calledWith_ = [].slice.call(arguments);
}

function FakeService() {
this.calledWith_ = arguments;
Service.apply(this, arguments);
}

nodeutil.inherits(FakeService, Service);

var extended = false;
var fakeStreamRouter = {
extend: function(Class, methods) {
Expand All @@ -55,13 +62,6 @@ var fakeUtil = extend({}, util, {
}
});

function FakeService() {
this.calledWith_ = arguments;
Service.apply(this, arguments);
}

nodeutil.inherits(FakeService, Service);

describe('Resource', function() {
var PROJECT_ID = 'test-project-id';

Expand Down
1 change: 0 additions & 1 deletion packages/google-cloud-resourcemanager/test/project.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ var assert = require('assert');
var extend = require('extend');
var nodeutil = require('util');
var proxyquire = require('proxyquire');

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

Expand Down

0 comments on commit bb84b2b

Please sign in to comment.