Skip to content

Commit

Permalink
Merge pull request #24 from dwsupplee/release-0.1.0
Browse files Browse the repository at this point in the history
0.1.0 release!
  • Loading branch information
dwsupplee committed Mar 29, 2016
2 parents ef69161 + bfb5a89 commit 9d4c9fd
Show file tree
Hide file tree
Showing 47 changed files with 5,714 additions and 1,468 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,4 @@ Your pull request is where we (and anyone else who is interested) will discuss y

Be sure to check your pull request for a `cla:yes` label. If you see a `cla:no` label, verify that you have [signed the CLA](#signing-the-contributor-license-agreement-cla) using a Google Account that matches your Git email. Once your pull request has the `cla:yes` label, look out for an email notification that either your pull request has been merged, or someone has requested a little more work on it. If more work is needed, repeat **steps 5**, **7-11**, and **14**. Then, let us know when you're done and we'll take another look.

Happy contributing! And, once again, thank you.
Happy contributing! And, once again, thank you.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# Google Cloud PHP Client
[![Travis Build Status](https://travis-ci.org/GoogleCloudPlatform/gcloud-php.svg)](https://travis-ci.org/GoogleCloudPlatform/gcloud-php/)

> Idiomatic PHP client for [Google Cloud Platform](https://cloud.google.com/) services.
[![Travis Build Status](https://travis-ci.org/GoogleCloudPlatform/gcloud-php.svg)](https://travis-ci.org/GoogleCloudPlatform/gcloud-php/)
Please note this library is currently under active development. Any release versioned 0.x.y is subject to backwards incompatiable changes at any time.

## Contributing

Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "google/gcloud",
"name": "google/cloud",
"type": "library",
"description": "Google Cloud Client Library",
"keywords": [
Expand Down Expand Up @@ -35,7 +35,7 @@
},
"autoload": {
"psr-4": {
"Google\\Gcloud\\": "src"
"Google\\Cloud\\": "src"
}
}
}
50 changes: 50 additions & 0 deletions docs/toc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
"overview": "overview.html",
"guides": [{
"title": "Authentication",
"id": "authentication",
"edit": "https://github.com/GoogleCloudPlatform/gcloud-common/edit/master/authentication/readme.md",
"contents": [
"https://raw.githubusercontent.com/GoogleCloudPlatform/gcloud-common/master/authentication/readme.md",
"authentication.md"
]
}, {
"title": "FAQ",
"id": "faq",
"edit": "https://github.com/GoogleCloudPlatform/gcloud-common/edit/master/faq/readme.md",
"contents": [
"https://raw.githubusercontent.com/GoogleCloudPlatform/gcloud-common/master/faq/readme.md",
"faq.md"
]
}, {
"title": "Troubleshooting",
"id": "troubleshooting",
"edit": "https://github.com/GoogleCloudPlatform/gcloud-common/edit/master/troubleshooting/readme.md",
"contents": [
"https://raw.githubusercontent.com/GoogleCloudPlatform/gcloud-common/master/troubleshooting/readme.md",
"troubleshooting.md"
]
}, {
"title": "Contributing",
"id": "contributing",
"edit": "https://github.com/GoogleCloudPlatform/gcloud-common/edit/master/contributing/readme.md",
"contents": "https://raw.githubusercontent.com/GoogleCloudPlatform/gcloud-common/master/contributing/readme.md"
}],
"services": [{
"title": "Gcloud",
"type": "gcloud",
}, {
"title": "Storage",
"type": "storage",
"nav": [{
"title": "ACL",
"type": "acl",
}, {
"title": "Bucket",
"type": "bucket",
}, {
"title": "Object",
"type": "object",
}]
}]
}
65 changes: 44 additions & 21 deletions scripts/DocGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
use phpDocumentor\Reflection\FileReflector;

/**
* Parses given files and builds JSON documentation.
* Parses given files and builds documentation for our common docs site.
*/
class DocGenerator
{
Expand All @@ -47,36 +47,60 @@ public function __construct(array $files, $outputPath)
*/
public function generate()
{
$types = [];

foreach ($this->files as $file) {
$this->currentFile = substr(str_replace(__DIR__, '', $file), 3);
$jsonOutputPath = $this->buildOutputPath();
$fileReflector = new FileReflector($file);
$fileReflector->process();
$reflector = isset($fileReflector->getClasses()[0]) ? $fileReflector->getClasses()[0] : $fileReflector->getInterfaces()[0];
$document = $this->buildDocument($this->getReflector($fileReflector));

$document = $this->buildDocument($reflector);
$types[] = [
'id' => $document['id'],
'title' => $document['title'],
'contents' => $document['id'] . '.json'
];

if (!is_dir(dirname($jsonOutputPath))) {
mkdir(dirname($jsonOutputPath), 0777, true);
}

file_put_contents($jsonOutputPath, json_encode($document));
}

file_put_contents($this->outputPath . '/types.json', json_encode($types));
}

private function getReflector($fileReflector)
{
if (isset($fileReflector->getClasses()[0])) {
return $fileReflector->getClasses()[0];
}

if (isset($fileReflector->getInterfaces()[0])) {
return $fileReflector->getInterfaces()[0];
}

if (isset($fileReflector->getTraits()[0])) {
return $fileReflector->getTraits()[0];
}
}

private function buildDocument($reflector)
{
$name = $reflector->getShortName();
$title = explode('\\', $reflector->getNamespace());
$title[] = $name;
$id = substr($reflector->getName(), 14);
$id = str_replace('\\', '/', $id);
// @todo see if there is a better way to determine the type
$type = end(explode('_', get_class($reflector->getNode())));

return [
'id' => strtolower($name),
'metadata' => [
'name' => $name,
'title' => $title,
'description' => $this->buildDescription($reflector->getDocBlock())
],
'id' => strtolower($id),
'type' => strtolower($type),
'title' => $reflector->getNamespace() . '\\' . $name,
'name' => $name,
'description' => $this->buildDescription($reflector->getDocBlock()),
'methods' => $this->buildMethods($reflector->getMethods())
];
}
Expand All @@ -94,7 +118,7 @@ private function buildDescription($docBlock, $content = null)
foreach ($parsedContents as &$content) {
if ($content instanceof Seetag) {
$reference = $content->getReference();
if (substr_compare($reference, 'Google\Gcloud', 0, 13) === 0) {
if (substr_compare($reference, 'Google\Cloud', 0, 12) === 0) {
$content = $this->buildLink($reference);
}
}
Expand Down Expand Up @@ -133,14 +157,13 @@ private function buildMethod($method)
}

return [
'metadata' => [
'constructor' => $method->getName() === '__construct' ? true : false,
'name' => $method->getName(),
'source' => $this->currentFile . '#L' . $method->getLineNumber(),
'description' => $this->buildDescription($docBlock, $docText),
'examples' => $this->buildExamples($examples),
'resources' => $this->buildResources($resources)
],
'id' => $method->getName(),
'type' => $method->getName() === '__construct' ? 'constructor' : 'instance',
'name' => $method->getName(),
'source' => $this->currentFile . '#L' . $method->getLineNumber(),
'description' => $this->buildDescription($docBlock, $docText),
'examples' => $this->buildExamples($examples),
'resources' => $this->buildResources($resources),
'params' => $this->buildParams($params),
'exceptions' => $this->buildExceptions($exceptions),
'returns' => $this->buildReturns($returns)
Expand Down Expand Up @@ -314,7 +337,7 @@ private function buildReturns($returns)
private function handleTypes($types)
{
foreach ($types as &$type) {
if (substr_compare($type, '\Google\Gcloud', 0, 14) === 0) {
if (substr_compare($type, '\Google\Cloud', 0, 13) === 0) {
$type = $this->buildLink($type);
}
}
Expand Down
36 changes: 36 additions & 0 deletions src/ClientInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php
/**
* Copyright 2016 Google Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

namespace Google\Cloud;

use Google\Cloud\Storage\Connection\ConnectionInterface;

/**
* Interface for Google Cloud Platform Clients
*/
interface ClientInterface
{
const VERSION = '0.1.0';

/**
* Sets the connection.
*
* @param ConnectionInterface $connection Represents a connection to a
* Google Cloud Platform Service.
*/
public function setConnection(ConnectionInterface $connection);
}
43 changes: 43 additions & 0 deletions src/ClientTrait.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php
/**
* Copyright 2016 Google Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

namespace Google\Cloud;

use Google\Cloud\Storage\Connection\ConnectionInterface;

/**
* Provides shared functionality between Clients.
*/
trait ClientTrait
{
/**
* @var ConnectionInterface $connection Represents a connection to a Google
* Cloud Platform Service.
*/
private $connection;

/**
* Sets the connection.
*
* @param ConnectionInterface $connection Represents a connection to a Google
* Cloud Platform Service.
*/
public function setConnection(ConnectionInterface $connection)
{
$this->connection = $connection;
}
}
6 changes: 3 additions & 3 deletions src/Compute/Metadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
namespace Google\Gcloud\Compute;
namespace Google\Cloud\Compute;

use Google\Gcloud\Compute\Metadata\Readers\StreamReader;
use Google\Cloud\Compute\Metadata\Readers\StreamReader;

/**
* A library for accessing the Google Compute Engine (GCE) metadata.
Expand All @@ -27,7 +27,7 @@
*
* You can get the GCE metadata values very easily like:
*
* use Google\Gcloud\Compute\Metadata;
* use Google\Cloud\Compute\Metadata;
*
* $metadata = new Metadata();
* $project_id = $metadata->getProjectId();
Expand Down
2 changes: 1 addition & 1 deletion src/Compute/Metadata/Readers/StreamReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
namespace Google\Gcloud\Compute\Metadata\Readers;
namespace Google\Cloud\Compute\Metadata\Readers;

/**
* A class only reading the metadata URL with an appropriate header.
Expand Down
26 changes: 26 additions & 0 deletions src/Exception/GoogleException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php
/**
* Copyright 2016 Google Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

namespace Google\Cloud\Exception;

/**
* Exception thrown when a request fails.
*/
class GoogleException extends \Exception
{

}
Loading

0 comments on commit 9d4c9fd

Please sign in to comment.