Skip to content

Commit 4c8cffe

Browse files
author
tristen
committed
Merge pull request #57 from darvin/master
Testing & node.js
2 parents aa8aa3c + d614011 commit 4c8cffe

File tree

8 files changed

+185
-5
lines changed

8 files changed

+185
-5
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
_site/*
22
.DS_Store
33

4-
test/.DS_Store
4+
test/.DS_Store
5+
node_modules/

.travis.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
language: node_js
2+
node_js:
3+
- "0.11"
4+
- "0.10"
5+
- "0.8"
6+
- "0.6"

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
[![browser support](https://ci.testling.com/darvin/github.png)](https://ci.testling.com/darvin/github)
2+
3+
4+
[![Build Status](https://travis-ci.org/darvin/github.png?branch=master)](https://travis-ci.org/darvin/github)
5+
16
# Github.js
27

38
Github.js provides a minimal higher-level wrapper around git's [plumbing commands](http://git-scm.com/book/en/Git-Internals-Plumbing-and-Porcelain), exposing an API for manipulating GitHub repositories on the file level. It is being developed in the context of [Prose](http://prose.io), a content editor for GitHub.

github.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,20 @@
99
// Initial Setup
1010
// -------------
1111

12-
if (typeof this.exports !== 'undefined') {
13-
var XMLHttpRequest = require('xmlhttprequest').XMLHttpRequest;
14-
var _ = require('underscore');
12+
var XMLHttpRequest, Base64, _;
13+
if (typeof exports !== 'undefined') {
14+
XMLHttpRequest = require('xmlhttprequest').XMLHttpRequest;
15+
_ = require('underscore');
16+
Base64 = require('./lib/base64.js');
17+
}else{
18+
_ = window._;
19+
Base64 = window.Base64;
20+
}
21+
//prefer native XMLHttpRequest always
22+
if (typeof window !== 'undefined' && typeof window.XMLHttpRequest !== 'undefined'){
23+
XMLHttpRequest = window.XMLHttpRequest;
1524
}
25+
1626

1727
var API_URL = 'https://api.github.com';
1828

lib/base64.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,5 +78,10 @@ var Base64 = (function () {
7878

7979
return obj;
8080
})();
81+
if (typeof exports !== 'undefined') {
82+
// Github = exports;
83+
module.exports = Base64;
84+
} else {
85+
window.Base64 = Base64;
86+
}
8187

82-
window.Base64 = Base64

package.json

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
{
2+
"name": "github",
3+
"version": "0.7.0",
4+
"description": "A higher-level wrapper around the Github API.",
5+
"main": "github.js",
6+
"dependencies": {
7+
"xmlhttprequest": "*",
8+
"underscore": "*"
9+
},
10+
"devDependencies": {
11+
"mocha": "*",
12+
"chai": "*"
13+
},
14+
"scripts": {
15+
"test": "mocha"
16+
17+
},
18+
"repository": {
19+
"type": "git",
20+
"url": "git://github.com/darvin/github.git"
21+
},
22+
"keywords": [
23+
"github",
24+
"api"
25+
],
26+
"author": "Sergey Klimov <sergey.v.klimov@gmail.com> (http://darvin.github.com/)",
27+
"license": "BSD",
28+
"readmeFilename": "README.md",
29+
"gitHead": "aa8aa3c8cd5ce5240373d4fd1d06a7ab4af41a36",
30+
"bugs": {
31+
"url": "https://github.com/darvin/github/issues"
32+
},
33+
"browser": {
34+
"xmlhttprequest": false
35+
},
36+
"testling": {
37+
"files": "test/*_test.js",
38+
"browsers": [
39+
"iexplore/10.0",
40+
"iexplore/9.0",
41+
"chrome/6.0",
42+
"chrome/7.0",
43+
"chrome/8.0",
44+
"chrome/9.0",
45+
"chrome/10.0",
46+
"chrome/11.0",
47+
"chrome/12.0",
48+
"chrome/13.0",
49+
"chrome/14.0",
50+
"chrome/15.0",
51+
"chrome/16.0",
52+
"chrome/17.0",
53+
"chrome/18.0",
54+
"chrome/19.0",
55+
"chrome/20.0",
56+
"chrome/21.0",
57+
"chrome/22.0",
58+
"chrome/23.0",
59+
"chrome/24.0",
60+
"chrome/25.0",
61+
"firefox/3.0",
62+
"firefox/3.5",
63+
"firefox/3.6",
64+
"firefox/4.0",
65+
"firefox/5.0",
66+
"firefox/6.0",
67+
"firefox/7.0",
68+
"firefox/8.0",
69+
"firefox/9.0",
70+
"firefox/10.0",
71+
"firefox/11.0",
72+
"firefox/12.0",
73+
"firefox/13.0",
74+
"firefox/14.0",
75+
"firefox/15.0",
76+
"firefox/16.0",
77+
"firefox/17.0",
78+
"firefox/18.0",
79+
"firefox/19.0",
80+
"opera/10.0",
81+
"opera/10.5",
82+
"opera/11.0",
83+
"opera/11.5",
84+
"opera/11.6",
85+
"opera/12.0",
86+
"safari/4.0",
87+
"safari/5.0.5",
88+
"safari/5.1",
89+
"firefox/nightly",
90+
"opera/next",
91+
"chrome/canary",
92+
"iphone/6.0",
93+
"ipad/6.0",
94+
"safari/6.0",
95+
"android-browser/4.2"
96+
],
97+
"harness": "mocha"
98+
}
99+
100+
}

test/auth_test.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
if (typeof require !== 'undefined') {
2+
var Github = require("../")
3+
, chai = require("chai");
4+
}
5+
chai.should();
6+
var expect = chai.expect
7+
, TEST_USERNAME = "mikedeboertest"
8+
, TEST_PASSWORD = "test1324";
9+
10+
// var util = require("util");
11+
12+
describe("Auth", function(){
13+
this.timeout(10000);
14+
it("should authenticate with basic auth", function(done){
15+
var github = new Github({
16+
username: TEST_USERNAME,
17+
password: TEST_PASSWORD,
18+
auth: "basic"
19+
});
20+
var user = github.getUser();
21+
user.repos(function(err, repos) {
22+
// console.error(util.inspect(err));
23+
expect(err).to.be.null;
24+
repos.should.be.ok;
25+
repos.length.should.be.above(1);
26+
done();
27+
28+
});
29+
30+
});
31+
});

test/test_runner.html

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<html>
2+
<head>
3+
<meta charset="utf-8">
4+
<title>Mocha Tests</title>
5+
<link rel="stylesheet" href="../node_modules/mocha/mocha.css" />
6+
</head>
7+
<body>
8+
<div id="mocha"></div>
9+
<script src="../lib/base64.js"></script>
10+
<script src="../lib/underscore-min.js"></script>
11+
<script src="../github.js"></script>
12+
<script src="../node_modules/mocha/mocha.js"></script>
13+
<script src="../node_modules/chai/chai.js"></script>
14+
<script>mocha.setup('bdd')</script>
15+
<script src="auth_test.js"></script>
16+
<script>
17+
mocha.checkLeaks();
18+
mocha.globals(['_', 'Github']);
19+
mocha.run();
20+
</script>
21+
</body>
22+
</html>

0 commit comments

Comments
 (0)