From 68848aa550bed6b67626be5d0ac4a77838d1252d Mon Sep 17 00:00:00 2001 From: Stephen Sawchuk Date: Thu, 2 Oct 2014 09:44:13 -0400 Subject: [PATCH] pubsub refactor --- docs/components/docs/docs-services.js | 20 + docs/components/docs/docs-values.js | 50 ++ docs/components/docs/docs.html | 25 +- docs/components/docs/docs.js | 200 +++-- docs/index.html | 3 + docs/lib/semver.js | 1098 +++++++++++++++++++++++++ lib/common/util.js | 3 + lib/index.js | 29 +- lib/pubsub/index.js | 534 +++++------- lib/pubsub/subscription.js | 327 ++++++++ lib/pubsub/topic.js | 270 ++++++ npm-debug.log | 33 + package.json | 8 +- regression/pubsub.js | 200 +++-- scripts/docs.sh | 27 + test/pubsub/index.js | 219 +++-- test/pubsub/subscription.js | 430 ++++++++++ test/pubsub/topic.js | 341 ++++++++ 18 files changed, 3192 insertions(+), 625 deletions(-) create mode 100644 docs/components/docs/docs-services.js create mode 100644 docs/components/docs/docs-values.js create mode 100644 docs/lib/semver.js create mode 100644 lib/pubsub/subscription.js create mode 100644 lib/pubsub/topic.js create mode 100644 npm-debug.log create mode 100755 scripts/docs.sh create mode 100644 test/pubsub/subscription.js create mode 100644 test/pubsub/topic.js diff --git a/docs/components/docs/docs-services.js b/docs/components/docs/docs-services.js new file mode 100644 index 000000000000..6df728e744e0 --- /dev/null +++ b/docs/components/docs/docs-services.js @@ -0,0 +1,20 @@ +angular.module('gcloud.docs') + .factory('getLinks', function(pages, versions) { + return function(version) { + var baseUrl = '#/docs/' + version; + var VERSIONS = pages.VERSIONS; + if (!version || version === 'master') { + var versions = Object.keys(VERSIONS); + match = versions[versions.length - 1]; + } else { + match = Object.keys(VERSIONS).filter(semver.satisfies.bind(null, version))[0]; + } + return VERSIONS[match] + .map(function(module) { + if (pages[module]._url) { + pages[module].url = pages[module]._url.replace('{baseUrl}', baseUrl); + } + return pages[module]; + }); + }; + }); diff --git a/docs/components/docs/docs-values.js b/docs/components/docs/docs-values.js new file mode 100644 index 000000000000..8eda76b49ba3 --- /dev/null +++ b/docs/components/docs/docs-values.js @@ -0,0 +1,50 @@ +angular.module('gcloud.docs') + .value('pages', { + gcloud: { + title: 'gcloud', + _url: '{baseUrl}' + }, + + datastore: { + title: 'Datastore', + _url: '{baseUrl}/datastore', + pages: [ + { + title: 'Dataset', + url: '/dataset' + }, + { + title: 'Query', + url: '/query' + } + ] + }, + + pubsub: { + title: 'PubSub', + _url: '{baseUrl}/pubsub', + pages: [ + { + title: 'Topic', + url: '/topic' + }, + { + title: 'Subscription', + url: '/subscription' + } + ] + }, + + storage: { + title: 'Storage', + _url: '{baseUrl}/storage' + }, + + VERSIONS: { + // Give a version with/without a comparator, anything semver: + // https://github.com/npm/node-semver#versions + // List should be in ascending order. + '<=0.7.1': ['gcloud', 'datastore', 'storage'], + '>0.7.1': ['gcloud', 'datastore', 'pubsub', 'storage'] + } + }); diff --git a/docs/components/docs/docs.html b/docs/components/docs/docs.html index be0e1e0d3f5a..7cd950d59738 100644 --- a/docs/components/docs/docs.html +++ b/docs/components/docs/docs.html @@ -73,6 +73,21 @@

Datastore Overview

+
+

Pub/Sub Overview

+

+ The gcloud.pubsub method will return a pubsub object, allowing you to create topics, publish messages, subscribe to topics, and more. See the Google Cloud Pub/Sub overview for more information. +

+
+var pubsub = gcloud.pubsub({ + projectId: 'myProject', + keyFilename: '/path/to/keyfile.json' +});
+

+ See the examples below, which demonstrate everything from creating a topic to subscribing to messages on a topic. +

+
+

Storage Overview

@@ -98,8 +113,7 @@

ng-if="method.name[0].toUpperCase() !== method.name[0]"> + ng-href="{{activeUrl + '?method=' + method.name}}"># {{method.name}}

@@ -118,9 +132,8 @@

Parameters

Returns

Example

-
+

@@ -135,7 +148,7 @@

Example