Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .bowerrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"directory": "vendor"
"directory": "bower_components",
"analytics": false
}
33 changes: 33 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# EditorConfig helps developers define and maintain consistent
# coding styles between different editors and IDEs
# editorconfig.org

root = true


[*]
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
indent_style = space
indent_size = 2

[*.js]
indent_style = space
indent_size = 2

[*.hbs]
indent_style = space
indent_size = 2

[*.css]
indent_style = space
indent_size = 2

[*.html]
indent_style = space
indent_size = 2

[*.md]
trim_trailing_whitespace = false
9 changes: 9 additions & 0 deletions .ember-cli
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
/**
Ember CLI sends analytics information by default. The data is completely
anonymous, but there are times when you might want to disable this behavior.

Setting `disableAnalytics` to true will prevent any data from being sent.
*/
"disableAnalytics": false
}
8 changes: 4 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# See http://help.github.com/ignore-files/ for more about ignoring files.

# compiled output
/dist
/tmp

# dependencies
/node_modules
/vendor/*
/bower_components

# misc
/.sass-cache
/connect.lock
/libpeerconnection.log
.DS_Store
Thumbs.db
/coverage/*
/libpeerconnection.log
npm-debug.log
testem.log
18 changes: 5 additions & 13 deletions .jshintrc
Original file line number Diff line number Diff line change
@@ -1,22 +1,14 @@
{
"predef": {
"document": true,
"window": true,
"location": true,
"setTimeout": true,
"Ember": true,
"Em": true,
"DS": true,
"$": true,
"ENV": true,
"module": true
"console": true,
"gapi": true
},
"node" : false,
"browser" : false,
"browser" : true,
"boss" : true,
"curly": false,
"curly": true,
"debug": false,
"devel": false,
"devel": true,
"eqeqeq": true,
"evil": true,
"forin": false,
Expand Down
16 changes: 16 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
language: node_js

sudo: false

cache:
directories:
- node_modules

install:
- npm install -g bower
- npm install
- bower install

script:
- npm test
105 changes: 20 additions & 85 deletions Brocfile.js
Original file line number Diff line number Diff line change
@@ -1,85 +1,20 @@
/* global require, process */
'use strict';

var name = require('./package.json').name;
var path = require('path');
var env = process.env.EMBER_ENV;
var dist = env === 'dist';

var pickFiles = require('broccoli-static-compiler');
var compileES6 = require('broccoli-es6-concatenator');
var findBowerTrees = require('broccoli-bower');
var mergeTrees = require('broccoli-merge-trees');

var lib = pickFiles('lib', {
srcDir: '/',
destDir: name
});

if (dist) {
var loader = pickFiles('vendor', {
srcDir: '/loader',
files: ['loader.js'],
destDir: '/loader'
});

var scripts = mergeTrees([lib, loader], { overwrite: true });

var es6 = compileES6(scripts, {
loaderFile: 'loader/loader.js',
inputFiles: [name + '/**/*.js'],
outputFile: '/index.js',
wrapInEval: false
});

return module.exports = es6;
}

var index = pickFiles('tests', {
srcDir: '/',
files: ['index.html'],
destDir: '/'
});

var tests = pickFiles('tests', {
srcDir: '/',
destDir: name + '/tests'
});

var sourceFiles = [lib, tests, 'vendor'].concat(findBowerTrees());
var scripts = mergeTrees(sourceFiles, { overwrite: true });

var ignoredModules = [
'ember',
'ember/resolver',
'ic-ajax'
];

var legacyFilesToAppend = [
'jquery.js',
'handlebars.js',
'ember.js',
'ic-ajax/dist/named-amd/main.js',
'ember-data.js',
'app-shims.js',
'ember-resolver.js'
];

var qunit = require('broctree-qunit');

var testem = pickFiles('tests', {
files: ['testem.js'],
srcDir: 'helpers',
destDir: '/'
});

var es6 = compileES6(scripts, {
loaderFile: 'loader/loader.js',
ignoredModules: ignoredModules,
inputFiles: [name + '/**/*.js'],
wrapInEval: true,
outputFile: '/index.js',
legacyFilesToAppend: legacyFilesToAppend
});

return module.exports = mergeTrees([index, es6, qunit, testem], { overwrite: true});
/* global require, module */

var EmberAddon = require('ember-cli/lib/broccoli/ember-addon');

var app = new EmberAddon();

// Use `app.import` to add additional libraries to the generated
// output files.
//
// If you need to use different assets in different
// environments, specify an object as the first parameter. That
// object's keys should be the environment name and the values
// should be the asset to use in that environment.
//
// If the library that you are including contains AMD or ES6
// modules that you would like to import into your application
// please specify an object with the list of modules as keys
// along with the exports of each module as its value.

module.exports = app.toTree();
36 changes: 35 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
# Work In Progress
# Ember-google-api-client - Work In Progress

# Installation

**note: this has not been published yet**
```
npm install --save-dev ember-google-api-client
```

# Usage

## Initialization

Expand Down Expand Up @@ -70,3 +79,28 @@ egc.update(file)
```javascript
egc.destroy(file.id);
```

# Collaboration
This section outlines the details of collaborating on this Ember addon.

## Installation

* `git clone` this repository
* `npm install`
* `bower install`

## Running

* `ember server`
* Visit your app at http://localhost:4200.

## Running Tests

* `ember test`
* `ember test --server`

## Building

* `ember build`

For more information on using ember-cli, visit [http://www.ember-cli.com/](http://www.ember-cli.com/).
Empty file added addon/.gitkeep
Empty file.
16 changes: 16 additions & 0 deletions addon/egc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import Em from 'ember';
import ReadyMixin from './egc/ready';
import AuthorizationMixin from './egc/authorization';
import DriveMixin from './egc/drive';

var EGC = Em.Object.extend(
ReadyMixin,
AuthorizationMixin,
DriveMixin, {

DEBUG: true,
getScript: Em.$.getScript
});

Em.EGC = EGC;
export default EGC;
5 changes: 3 additions & 2 deletions lib/egc/authorization.js → addon/egc/authorization.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
// TODO - _gapi put in for testing needs to
// handle Em.run.next(). Get rid of it.
/*global gapi*/

var Promise = Em.RSVP.Promise;
import Em from 'ember';

export default Em.Mixin.create(Em.PromiseProxyMixin, {
apiKey: null,
Expand All @@ -20,7 +21,7 @@ export default Em.Mixin.create(Em.PromiseProxyMixin, {
},

setPromise: function() {
var promise = new Promise(function(resolve, reject) {
var promise = new Em.RSVP.Promise(function(resolve, reject) {
this.addObserver('authorized', function() {
var authorized = this.get('authorized');
if (authorized) { resolve(); }
Expand Down
4 changes: 3 additions & 1 deletion lib/egc/drive.js → addon/egc/drive.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import FilesMixin from 'egc/egc/drive/files';
/*global gapi*/
import Em from 'ember';
import FilesMixin from './drive/files';

export default Em.Mixin.create(
FilesMixin, {
Expand Down
15 changes: 8 additions & 7 deletions lib/egc/drive/files.js → addon/egc/drive/files.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { handleGapiResponse } from 'egc/egc/utils';
import uploadFile from 'egc/egc/drive/uploadFile';
/*global gapi*/

var Promise = Em.RSVP.Promise,
a_slice = Array.prototype.slice;
import Em from 'ember';
import { handleGapiResponse } from '../utils';
import uploadFile from './uploadFile';

var a_slice = Array.prototype.slice;

function extractItems(res) {
if (res.items) { return res.items; }
Expand All @@ -15,7 +17,6 @@ export default Em.Mixin.create({
driveVersion: 'v2', // also in DriveMixin

find: function(args) {
var self = this;

if (!args) {
return this.request('list').then(extractItems);
Expand Down Expand Up @@ -54,7 +55,7 @@ export default Em.Mixin.create({
var path = '/drive/' + this.get('driveVersion') + '/files/' + id,
DEBUG = this.get('DEBUG');

return new Promise(function(resolve, reject) {
return new Em.RSVP.Promise(function(resolve, reject) {
gapi.client.request({ path: path, method: 'DELETE' })
.execute(handleGapiResponse(resolve, reject, DEBUG));
});
Expand All @@ -66,7 +67,7 @@ export default Em.Mixin.create({
rest = args.slice(1),
DEBUG = this.get('DEBUG');

return new Promise(function(resolve, reject) {
return new Em.RSVP.Promise(function(resolve, reject) {
if (DEBUG) { console.log('sending gapi request', args);}

gapi.client.drive
Expand Down
6 changes: 4 additions & 2 deletions lib/egc/drive/uploadFile.js → addon/egc/drive/uploadFile.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { handleGapiResponse } from 'egc/egc/utils';
/*global gapi*/
import Em from 'ember';
import { handleGapiResponse } from '../utils';

var boundary = 'foo_bar_baz',
delimiter = "\r\n--" + boundary + "\r\n",
Expand Down Expand Up @@ -62,6 +64,6 @@ function uploadFile(file, opts) {
gapi.client.request(params)
.execute(handleGapiResponse(resolve, reject, (opts && opts.DEBUG)));
});
};
}

export default uploadFile;
2 changes: 2 additions & 0 deletions lib/egc/ready.js → addon/egc/ready.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import Em from 'ember';

export default Em.Mixin.create({
gapiSourceUrl: 'https://apis.google.com/js/client.js?onload=gapiReady',
getScript: null, // ie. $.getScript if using jQuery
Expand Down
2 changes: 2 additions & 0 deletions lib/egc/utils.js → addon/egc/utils.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import Em from 'ember';

export function handleGapiResponse(resolve, reject, DEBUG) {
return function(res) {
if (DEBUG) { console.log('gapi response', res); }
Expand Down
Empty file added app/.gitkeep
Empty file.
Loading