From 90dbcff3ebbf14c8fb1f62b5afdf680cb0be6834 Mon Sep 17 00:00:00 2001 From: "Rico Sta. Cruz" Date: Thu, 20 Jun 2013 13:38:19 +0800 Subject: [PATCH] Update lots. --- chai.md | 77 +++++++++++++++++++++++++++++++ codestuff.md | 17 +++++++ curl.md | 7 +-- jade.md | 6 +++ nodejs.md | 12 ++++- node-package.md => npm-package.md | 4 ++ npm.md | 2 + qjs.md | 52 +++++++++++++++++++++ sinon.md | 2 +- time.md | 62 +++++++++++++++++++++++++ travis.md | 33 ++++++++++++- 11 files changed, 268 insertions(+), 6 deletions(-) create mode 100644 chai.md create mode 100644 codestuff.md create mode 100644 jade.md rename node-package.md => npm-package.md (90%) create mode 100644 npm.md create mode 100644 qjs.md create mode 100644 time.md diff --git a/chai.md b/chai.md new file mode 100644 index 000000000..80b639bde --- /dev/null +++ b/chai.md @@ -0,0 +1,77 @@ +title: Chai +--- + + +### Assert + + assert(val) + assert.fail(actual, expected) + assert.ok(val) // is truthy + assert.equal(actual, expected) // 'compare with ==' + assert.strictEqual + assert.deepEqual + + assert.isTrue + assert.isFalse + + assert.isNull + assert.isNotNull + assert.isUndefined + assert.isDefined + assert.isFunction + assert.isObject + assert.isArray + assert.isString + assert.isNumber + assert.isBoolean + + assert.typeOf(/tea/, 'regexp') // Object.prototype.toString() + assert.instanceOf(chai, Tea) + assert.include([ a,b,c ], a) + assert.match(val, /regexp/) + assert.property(obj, 'tea') // 'tea' in object + assert.deepProperty(obj, 'tea.green') + assert.propertyVal(person, 'name', 'John') + assert.deepPropertyVal(post, 'author.name', 'John') + + assert.lengthOf(object, 3) + assert.throws(function() { ... }) + assert.throws(function() { ... }, /reference error/) + assert.doesNotThrow + + assert.operator(1, '<', 2) + assert.closeTo(actual, expected) + +### Should: chains + + .to .be .been .is .that .and .have .with .at .of .same + +### Should not + + expect(object).not.equal('x') + +### Expectations + + .equal(expected) + .eql // deepequal + .deep.equal(expected) + .be.a('string') + .include(val) + .be.ok(val) + .be.true + .be.false + .be.null + .be.undefined + .exist + .be.empty + .be.arguments + expect(10).above(5) + + +### References + + * http://chaijs.com/api/assert/ + + + + diff --git a/codestuff.md b/codestuff.md new file mode 100644 index 000000000..ea93bf60c --- /dev/null +++ b/codestuff.md @@ -0,0 +1,17 @@ +Badges for open source projects + + * Version badge (gems, npm): http://badge.fury.io/ + + * Dependencies (ruby): http://gemnasium.com/ + + * CI: http://travis-ci.org/ + + * Code quality (ruby): http://codeclimate.com/ + + * Test coverage: https://coveralls.io/ + +[![Status](https://travis-ci.org/USER/REPO.png?branch=master)](https://travis-ci.org/USER/REPO) + +[![NPM version](https://badge.fury.io/js/PACKAGE.png)](http://badge.fury.io/js/PACKAGE) + +[![Gem version](https://badge.fury.io/rb/GEM.png)](http://badge.fury.io/rb/GEM) diff --git a/curl.md b/curl.md index 88e80da05..6d4f53d58 100644 --- a/curl.md +++ b/curl.md @@ -16,9 +16,10 @@ Data options: Headers: - -A # --user-agent - -b name=val # --cookie - -b FILE # --cookie + -A # --user-agent + -b name=val # --cookie + -b FILE # --cookie + -H "X-Foo: y" # --header SSL: diff --git a/jade.md b/jade.md new file mode 100644 index 000000000..a1cd3e7af --- /dev/null +++ b/jade.md @@ -0,0 +1,6 @@ +### Iteration + + ul + each user in users + li= user + diff --git a/nodejs.md b/nodejs.md index b53614147..d54a2a977 100644 --- a/nodejs.md +++ b/nodejs.md @@ -105,6 +105,17 @@ title: NodeJS api } }); +## [assert] + + assert(val) + assert.equal(actual, expected) + assert.notEqual(a, e) + + assert.deepEqual(a, e) + assert.notDeepEqual(a, e) + + assert.throws(fn) + [all]: http://nodejs.org/api/all.html [process]: http://nodejs.org/api/process.html [fs]: http://nodejs.org/api/fs.html @@ -114,5 +125,4 @@ title: NodeJS api info = require('../package.json') info.version - process.stdout.write(util.inspect(objekt, false, Infinity, true) + '\n'); diff --git a/node-package.md b/npm-package.md similarity index 90% rename from node-package.md rename to npm-package.md index afb83fdef..43ef0801b 100644 --- a/node-package.md +++ b/npm-package.md @@ -10,6 +10,10 @@ title: Package JSON "author": "Rico Sta. Cruz ", "version": "0.1.0", "engines": {"node": ">=0.8.0"}, + "repository": { + "type": "git", + "url": "https://github.com/rstacruz/___.git" + }, } ### Dependencies diff --git a/npm.md b/npm.md new file mode 100644 index 000000000..ed40915ab --- /dev/null +++ b/npm.md @@ -0,0 +1,2 @@ + npm install + npm owner add rstacruz PACKAGENAME diff --git a/qjs.md b/qjs.md new file mode 100644 index 000000000..18d8fa878 --- /dev/null +++ b/qjs.md @@ -0,0 +1,52 @@ +title: Q.js +---- + +### Creating promises (Q.promise) + + Q.promise (resolve, reject) -> + asyncFunction -> + if error + reject new Error("Failure") + else + resolve deferred + +### Creating promises from Node + + # Works like .call() or .apply() + + Q.nfcall(FS.readFile, 'foo.txt', 'utf-8') + .then -> ... + + Q.nfapply(FS.readFile, ['foo.txt', 'utf-8']) + .then -> ... + + Q.npost(FS, 'readFile', ['foo.txt, 'utf-8']) + .then -> ... + + Q.npost(FS, 'readFile', 'foo.txt, 'utf-8') + .then -> ... + + readFile = Q.denodeify(FS.readFile) + readFile('foo.txt').then -> ... + +### Promises to Node async + + createUser = (next) -> + promiseMaker() + .nodeify(next) + +### Promise sugars + + # Shortcut for .then(ok, fail, progress) + promise + .then (data) -> + .catch (err) -> + .progress (percent) -> + +### Try + + Q.try -> + promise() + + .catch (e) -> + console.error "Oh well", e diff --git a/sinon.md b/sinon.md index 6c9bcf08a..d93980068 100644 --- a/sinon.md +++ b/sinon.md @@ -6,7 +6,7 @@ title: Sinon var fn = sinon.spy(); fn(); fn.calledOnce == true - fn.calledCount == 1 + fn.callCount == 1 ### Spy something diff --git a/time.md b/time.md new file mode 100644 index 000000000..fad65215f --- /dev/null +++ b/time.md @@ -0,0 +1,62 @@ +title: Time formats +--- + +### Ruby + + Weekday + %a - Sun + %A - Sunday + %w - 0..6 (Sunday is 0) + Year + %y - 13 + %Y - 2013 + Month + %b - Jan + %B - January + %m - 01..12 + Day + %d - 01..31 + %e - 1..31 + Time + %H - Hour of the day, 24-hour clock (00..23) + %I - Hour of the day, 12-hour clock (01..12) + %l - Hour of the day () + %M - Minute of the hour (00..59) + %p - Meridian indicator (AM or PM) + %S - Second of the minute (00..60) + %Z - Time zone name + Misc + %j - Day of the year (001..366) + %% - Literal % character + +### Moment.js + + Weekday + d - 4 + dd - Su + ddd - Sun + dddd - Sunday + Year + YY - 13 + YYYY - 2013 + Month + M - 1..12 (Jan is 1) + MM - 01..12 (Jan is 1) + MMM - Jan + MMMM - January + Day + D - 6..31 + DD - 06..31 + Time + H, HH - 24 hour time + h, hh - 12 hour time (use in conjunction with a or A) + m, mm - Minutes + s, ss - Seconds + S - Deciseconds (1/10th of a second) + SS - Centiseconds (1/100th of a second) + SSS - Milliseconds (1/1000th of a second) + Z, ZZ - Timezone offset as `+0700` or `+07:30` + X - Unix timestamp + a, A - AM/PM + Misc + DDD, DDDD - Day of year diff --git a/travis.md b/travis.md index 8c1dc7fa7..2df1c1205 100644 --- a/travis.md +++ b/travis.md @@ -15,6 +15,7 @@ title: Travis (.travis.yml) language: ruby rvm: + - 2.0.0 - 1.9.3 - 1.8.7 - rbx-19mode @@ -36,7 +37,7 @@ title: Travis (.travis.yml) - "rack=master" - "rack=1.3.4" -### Custom config +### Custom test command script: make test before_script: make pretest @@ -46,6 +47,36 @@ title: Travis (.travis.yml) - make pretest1 - make pretest2 +### Branches + + branches: + except: + - legacy + + only: + - gh-pages + - /^deploy/ + +### Etc + + gemfile: + - gemfiles/Gemfile.rails-2.3.x + - gemfiles/Gemfile.rails-3.0.x + +### Notifications + + notifications: + email: + - dropbox+travis@ricostacruz.com + + email: + recipients: + - dropbox+travis@ricostacruz.com + on_success: # default: change + on_failure: # default: always + + irc: "chat.freenode.net#travis" + ### References * http://about.travis-ci.org/docs/user/build-configuration/