Skip to content
This repository has been archived by the owner on Mar 15, 2018. It is now read-only.

Commit

Permalink
Set up scaffolding
Browse files Browse the repository at this point in the history
  • Loading branch information
kumar303 committed Mar 5, 2014
1 parent 696af46 commit f74e18d
Show file tree
Hide file tree
Showing 8 changed files with 190 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -1,2 +1,3 @@
*.sw[po]
.DS_Store
build
32 changes: 32 additions & 0 deletions .jshintrc
@@ -0,0 +1,32 @@
{
"boss": true,
"browser": true,
"camelcase": false,
"eqeqeq": true,
"eqnull": true,
"es5": false,
"esnext": true,
"expr": true,
"forin": false,
"globals": {
"define": false
},
"indent": 2,
"laxbreak": true,
"laxcomma": true,
"maxerr": 100,
"node": true,
"noarg": true,
"passfail": false,
"predef": [
"exports",
"require",
"process"
],
"shadow": false,
"strict": false,
"supernew": false,
"undef": true,
"unused": true,
"white": false
}
43 changes: 43 additions & 0 deletions Gruntfile.js
@@ -0,0 +1,43 @@
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),

jshint: {
options: { jshintrc: __dirname + '/.jshintrc' },
files: [
'Gruntfile.js',
'lib/*.js',
'test/*.js',
],
},

mochaTest: {
test: {
options: {
reporter: 'spec'
},
src: ['tests/test*.js']
}
},

uglify: {
my_target: {
files: {
'build/fxpay.min.js': ['lib/fxpay.js']
}
}
}
});

// Always show stack traces when Grunt prints out an uncaught exception.
grunt.option('stack', true);

grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-mocha-test');

grunt.registerTask('compress', 'uglify');
grunt.registerTask('unittest', 'mochaTest');
grunt.registerTask('test', ['jshint', 'mochaTest']);
grunt.registerTask('default', 'test');
};
27 changes: 27 additions & 0 deletions LICENSE.txt
@@ -0,0 +1,27 @@
Copyright (c) 2014, Mozilla Corporation
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

* Neither the name of the Mozilla Corporation nor the names of its contributors
may be used to endorse or promote products derived from this software without
specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39 changes: 39 additions & 0 deletions README.rst
@@ -1,3 +1,7 @@
=====
fxpay
=====

JavaScript library for `Firefox Marketplace`_ payments.

This is a helper library for web apps to accept in-app payments on
Expand All @@ -16,3 +20,38 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=944480
.. _`in-app payments guide`: https://developer.mozilla.org/en-US/Marketplace/Monetization/In-app_payments
.. _`Firefox Marketplace`: https://marketplace.firefox.com/
.. _`Firefox OS`: https://developer.mozilla.org/en-US/Firefox_OS

Developers
==========

To develop on this library you need `NodeJS`_ and `npm`_ installed.
When you clone the source, all other dependencies are included for you.
To execute scripts, you should add the local ``.bin`` directory to
your ``$PATH``::

PATH="./node_modules/.bin/:${PATH}"
export PATH

This is pretty standard for any Node project so you you might already have it.


From a source checkout, run all tests like this::

npm test

or::

grunt test

To just run unit tests, type::

grunt unittest

To build yourself a compressed version of ``fxpay.js``, run this::

grunt compress

The compressed source file will appear in the ``build`` directory.

.. _`NodeJS`: http://nodejs.org/
.. _`npm`: https://www.npmjs.org/
11 changes: 11 additions & 0 deletions lib/fxpay.js
@@ -0,0 +1,11 @@
(function(exports) {
"use strict";

exports.purchase = function _purchase(productId, options) {
options = options || {};
options.done = options.done || function() {};
options.apiUrlBase = options.apiUrlBase || 'https://marketplace.firefox.com/api/v1';

};

})(typeof exports === 'undefined' ? (this.fxpay = {}): exports);
24 changes: 24 additions & 0 deletions package.json
@@ -0,0 +1,24 @@
{
"name": "fxpay",
"version": "0.0.1",
"homepage": "https://github.com/mozilla/fxpay",
"repository": {
"type": "git",
"url": "https://github.com/mozilla/fxpay.git"
},
"description": "JavaScript library for Firefox Marketplace payments",
"dependencies": {},
"devDependencies": {
"grunt": "~0.4.2",
"grunt-contrib-jshint": "~0.6.5",
"grunt-contrib-uglify": "~0.4.0",
"grunt-mocha-test": "~0.9.4",
"mocha": "~1.17.1"
},
"scripts": {
"test": "node -e \"require('grunt').cli()\" null test"
},
"author": "Kumar McMillan",
"contributors": [],
"license": "MPL-2.0"
}
13 changes: 13 additions & 0 deletions tests/test-fxpay.js
@@ -0,0 +1,13 @@
var assert = require('assert');

var fxpay = require('../lib/fxpay');

describe('fxpay', function () {
describe('purchase()', function () {
it('should do something', function (done) {
// Just a placeholder for now.
assert.equal(1, 1);
done();
});
});
});

0 comments on commit f74e18d

Please sign in to comment.