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

Commit

Permalink
Merge pull request #89 from stripe/jar-cleanup
Browse files Browse the repository at this point in the history
Various cleanup
  • Loading branch information
jamesreggio committed May 22, 2014
2 parents 71595ac + 7c65fcb commit a7217f8
Show file tree
Hide file tree
Showing 9 changed files with 104 additions and 120 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
21 changes: 3 additions & 18 deletions Cakefile
Original file line number Diff line number Diff line change
@@ -1,25 +1,10 @@
{print} = require 'util'
{spawn} = require 'child_process'

task 'build', 'Build lib/ from src/', ->
coffee = spawn 'coffee', ['-c', '-o', 'lib', 'src']
coffee.stderr.on 'data', (data) ->
process.stderr.write data.toString()
coffee.stdout.on 'data', (data) ->
print data.toString()
coffee.on 'exit', (code) ->
callback?() if code is 0
spawn 'coffee', ['-c', '-o', 'lib', 'src'], stdio: 'inherit'

task 'watch', 'Watch src/ for changes', ->
coffee = spawn 'coffee', ['-w', '-c', '-o', 'lib', 'src']
coffee.stderr.on 'data', (data) ->
process.stderr.write data.toString()
coffee.stdout.on 'data', (data) ->
print data.toString()
spawn 'coffee', ['-w', '-c', '-o', 'lib', 'src'], stdio: 'inherit'

task 'test', 'Run tests', ->
mocha = spawn 'mocha', ['--compilers', 'coffee:coffee-script/register']
mocha.stderr.on 'data', (data) ->
process.stderr.write data.toString()
mocha.stdout.on 'data', (data) ->
print data.toString()
spawn 'mocha', ['--compilers', 'coffee:coffee-script/register'], stdio: 'inherit'
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2012 Stripe (alex@stripe.com)
Copyright (c) 2014 Stripe

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
Expand Down
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

A general purpose library for building credit card forms, validating inputs and formatting numbers.

For example, you can make a input act like a credit card field (with number formatting, and length restriction):
For example, you can make a input act like a credit card field (with number formatting and length restriction):

``` javascript
$('input.cc-num').payment('formatCardNumber');
```

Then, when say the payment form is submitted, you can validate the card number on the client-side like so:
Then, when the payment form is submitted, you can validate the card number on the client-side like so:

``` javascript
var valid = $.payment.validateCardNumber($('input.cc-num').val());
Expand All @@ -19,7 +19,7 @@ if ( !valid ) {
}
```

You can find a full [demo here](http://stripe.github.com/jquery.payment/example).
You can find a full [demo here](http://stripe.github.io/jquery.payment/example).

Supported card types are:

Expand All @@ -39,11 +39,11 @@ Supported card types are:

Formats card numbers:

* Including a space between every 4 digits
* Includes a space between every 4 digits
* Restricts input to numbers
* Limits to 16 numbers
* American Express formatting support
* Adds a class of the card type (i.e. 'visa') to the input
* Supports American Express formatting
* Adds a class of the card type (e.g. 'visa') to the input

Example:

Expand Down Expand Up @@ -85,7 +85,7 @@ General numeric input restriction.
Example:

``` javascript
$('data-numeric').payment('restrictNumeric');
$('[data-numeric]').payment('restrictNumeric');
```

### $.payment.validateCardNumber(number)
Expand Down Expand Up @@ -165,19 +165,19 @@ $.payment.cardExpiryVal('05 / 04'); //=> {month: 5, year: 2004}
$('input.cc-exp').payment('cardExpiryVal') //=> {month: 4, year: 2020}
```

This function doesn't do any validation of the month or year, use `$.payment.validateCardExpiry(month, year)` for that.
This function doesn't perform any validation of the month or year; use `$.payment.validateCardExpiry(month, year)` for that.

## Example

Look in `./example/index.html`
Look in [`./example/index.html`](example/index.html)

## Building

Run `cake build`

## Run tests
## Running tests

Run `mocha --compilers coffee:coffee-script`
Run `cake test`

## Autocomplete recommendations

Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jquery.payment",
"version": "1.0.2",
"version": "1.0.3",
"main": "lib/jquery.payment.js",
"dependencies": {
"jquery": ">=1.5"
Expand Down
89 changes: 47 additions & 42 deletions lib/jquery.payment.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 16 additions & 20 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,33 +1,29 @@
{
"name": "jquery.payment",
"version": "1.0.2",
"description": "jQuery Payment",
"main": "lib/jquery.payment.js",
"directories": {
"example": "example",
"test": "test"
},
"scripts": {
"test": "cake test"
},
"repository": {
"type": "git",
"url": "git://github.com/stripe/jquery.payment.git"
},
"version": "1.0.3",
"description": "A general purpose library for building credit card forms, validating inputs and formatting numbers.",
"keywords": [
"payment",
"cc",
"card"
],
"author": "Alex MacCaw",
"author": "Stripe (https://www.stripe.com)",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/stripe/jquery.payment.git"
},
"main": "lib/jquery.payment.js",
"scripts": {
"test": "cake test"
},
"dependencies": {
"jquery": "latest"
"jquery": ">=1.5"
},
"devDependencies": {
"jsdom": "*",
"cake": "*",
"coffee-script": "*",
"mocha": "*"
"cake": "~0.1",
"coffee-script": "~1.7",
"jsdom": "~0.10",
"mocha": "~1.18"
}
}
43 changes: 21 additions & 22 deletions payment.jquery.json
Original file line number Diff line number Diff line change
@@ -1,25 +1,24 @@
{
"name": "payment",
"title": "jQuery Payment",
"description": "A general purpose library for building credit card forms, validating inputs and formatting numbers.",
"keywords": [
"credit-cards",
"payments"
],
"version": "1.0.1",
"author": {
"name": "Alex MacCaw",
"url": "https://github.com/maccman"
},
"licenses": [
{
"url": "https://github.com/stripe/jquery.payment/blob/master/LICENSE"
}
],
"bugs": "https://github.com/stripe/jquery.payment/issues",
"homepage": "https://stripe.com/blog/jquery-payment",
"docs": "https://github.com/stripe/jquery.payment",
"dependencies": {
"jquery": ">=1.5"
"name": "payment",
"version": "1.0.3",
"title": "jQuery.payment",
"description": "A general purpose library for building credit card forms, validating inputs and formatting numbers.",
"keywords": [
"payment",
"cc",
"card"
],
"author": {
"name": "Stripe",
"url": "https://www.stripe.com"
},
"licenses": [
{
"type": "MIT",
"url": "https://github.com/stripe/jquery.payment/blob/master/LICENSE"
}
],
"dependencies": {
"jquery": ">=1.5"
}
}
8 changes: 3 additions & 5 deletions test/index.coffee
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
assert = require('assert')
jsdom = require('jsdom').jsdom
doc = jsdom('')
global.window = doc.createWindow()
$ = require('jquery')
window = require('jsdom').jsdom().createWindow()
$ = require('jquery')(window)
global.jQuery = $

require('../src/jquery.payment')
Expand Down Expand Up @@ -138,7 +136,7 @@ describe 'jquery.payment', ->
it 'should fail if year or month is NaN', ->
topic = $.payment.validateCardExpiry '12', NaN
assert.equal topic, false

it 'should support year shorthand', ->
assert.equal $.payment.validateCardExpiry('05', '20'), true

Expand Down

0 comments on commit a7217f8

Please sign in to comment.