Code coverage report for github/github.js

Statements: 58.46% (190 / 325)      Branches: 46.38% (64 / 138)      Functions: 58.47% (69 / 118)      Lines: 61.72% (187 / 303)      Ignored: 4 statements, 4 branches     

All files » github/ » github.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822                        1           1   1 1 1 1   1         1 1       1   1             1 1 38 38     38     38 38 38 148 38 35   3           38 37 37   1     38 38 38 38   38 12   26       38 1       1 3 3 3 3       3   3 3   3       3 3                         8 5   1 1             5 1 1             5 1 1             5 3 3             5 2   2 2             5   1 1             5 1 1             5   1 1             5 1 1             5 1 1           5 1               8 5 5   5 5   5               1                             5 3 3       3                       5 1                 5 1           5 1           5 1           5 1 1       1             5 2 2 2             5 1 1 1             5 1 1 1             5 1 1 2             5             5 1 1 1             5 2 2 2 1             5 1 1 1             5 1 1                     1 1 1             5                                           5                     5 1 1 1 1                     1 1                   5                 5 1           5 1           5 1           5                                   5             5             5             5             5             5             5 1 1   1 1               5                           5                                   5                                             5 1 1 1                               5                                                                               8                                                                                                                                                                             8                                 8       8 5     8 4     8           1 1   1      
/*!
 * @overview  Github.js
 *
 * @copyright (c) 2013 Michael Aufreiter, Development Seed
 *            Github.js is freely distributable.
 *
 * @license   Licensed under MIT license
 *
 *            For all details and documentation:
 *            http://substance.io/michael/github
 */
 
(function() {
  'use strict';
  
  // Initial Setup
  // -------------
 
  var XMLHttpRequest,  _;
  /* istanbul ignore else  */
  Eif (typeof exports !== 'undefined') {
      XMLHttpRequest = require('xmlhttprequest').XMLHttpRequest;
      _ = require('underscore');
      var btoa = require('btoa'); //jshint ignore:line
  } else { 
      _ = window._; 
  }
  
  //prefer native XMLHttpRequest always
  /* istanbul ignore if: hard to test without using Karma or somesuch.  */
  Iif (typeof window !== 'undefined' && typeof window.XMLHttpRequest !== 'undefined'){
      XMLHttpRequest = window.XMLHttpRequest;
  }
 
 
  var API_URL = 'https://api.github.com';
 
  var Github = function(options) {
 
    // HTTP Request Abstraction
    // =======
    //
    // I'm not proud of this and neither should you be if you were responsible for the XMLHttpRequest spec.
 
    function _request(method, path, data, cb, raw, sync) {
      function getURL() {
        var url = path.indexOf('//') >= 0 ? path : API_URL + path;
        return url + ((/\?/).test(url) ? '&' : '?') + (new Date()).getTime();
      }
 
      var xhr = new XMLHttpRequest();
 
 
      xhr.open(method, getURL(), !sync);
      Eif (!sync) {
        xhr.onreadystatechange = function () {
          if (this.readyState === 4) {
            if (this.status >= 200 && this.status < 300 || this.status === 304) {
              cb(null, raw ? this.responseText : this.responseText ? JSON.parse(this.responseText) : true, this);
            } else {
              cb({path: path, request: this, error: this.status});
            }
          }
        };
      }
 
      if (!raw) {
        xhr.dataType = 'json';
        xhr.setRequestHeader('Accept','application/vnd.github.v3+json');
      } else {
        xhr.setRequestHeader('Accept','application/vnd.github.v3.raw+json');
      }
 
      xhr.setRequestHeader('Content-Type','application/json;charset=UTF-8');
      Eif ((options.token) || (options.username && options.password)) {
        var authorization = options.token ? 'token ' + options.token : 'Basic ' + btoa(options.username + ':' + options.password);
        xhr.setRequestHeader('Authorization', authorization);
      }
      if (data) {
        xhr.send(JSON.stringify(data));
      } else {
        xhr.send();
      }
      
      /* istanbul ignore next: Sync is never used. */
      Iif (sync) {
        return xhr.response;
      }
    }
 
    function _requestAllPages(path, cb) {
      var results = [];
      (function iterate() {
        _request('GET', path, null, function(err, res, xhr) {
          Iif (err) {
            return cb(err);
          }
 
          results.push.apply(results, res);
 
          var links = (xhr.getResponseHeader('link') || '').split(/\s*,\s*/g),
              next = _.find(links, function(link) { return /rel="next"/.test(link); });
 
          Iif (next) {
            next = (/<(.*)>/.exec(next) || [])[1];
          }
 
          Eif (!next) {
            cb(err, results);
          } else {
            path = next;
            iterate();
          }
        });
      })();
    }
 
 
    // User API
    // =======
 
    Github.User = function() {
      this.repos = function(cb) {
        // Github does not always honor the 1000 limit so we want to iterate over the data set.
        _requestAllPages('/user/repos?type=all&per_page=1000&sort=updated', function(err, res) {
          cb(err, res);
        });
      };
 
      // List user organizations
      // -------
 
      this.orgs = function(cb) {
        _request("GET", '/user/orgs', null, function(err, res) {
          cb(err, res);
        });
      };
 
      // List authenticated user's gists
      // -------
 
      this.gists = function(cb) {
        _request("GET", '/gists', null, function(err, res) {
          cb(err,res);
        });
      };
 
      // List authenticated user's unread notifications
      // -------
 
      this.notifications = function(cb) {
        _request("GET", '/notifications', null, function(err, res) {
          cb(err,res);
        });
      };
 
      // Show user information
      // -------
 
      this.show = function(username, cb) {
        var command = username ? '/users/' + username : '/user';
 
        _request('GET', command, null, function(err, res) {
          cb(err, res);
        });
      };
 
      // List user repositories
      // -------
 
      this.userRepos = function(username, cb) {
        // Github does not always honor the 1000 limit so we want to iterate over the data set.
        _requestAllPages('/users/' + username + '/repos?type=all&per_page=1000&sort=updated', function(err, res) {
          cb(err, res);
        });
      };
 
      // List a user's gists
      // -------
 
      this.userGists = function(username, cb) {
        _request('GET', '/users/' + username + '/gists', null, function(err, res) {
          cb(err,res);
        });
      };
 
      // List organization repositories
      // -------
 
      this.orgRepos = function(orgname, cb) {
        // Github does not always honor the 1000 limit so we want to iterate over the data set.
        _requestAllPages('/orgs/' + orgname + '/repos?type=all&&page_num=1000&sort=updated&direction=desc', function(err, res) {
          cb(err, res);
        });
      };
 
      // Follow user
      // -------
 
      this.follow = function(username, cb) {
        _request('PUT', '/user/following/' + username, null, function(err, res) {
          cb(err, res);
        });
      };
 
      // Unfollow user
      // -------
 
      this.unfollow = function(username, cb) {
        _request('DELETE', '/user/following/' + username, null, function(err, res) {
          cb(err, res);
        });
      };
 
      // Create a repo
      // -------
      this.createRepo = function(options, cb) {
        _request('POST', '/user/repos', options, cb);
      };
 
    };
 
    // Repository API
    // =======
 
    Github.Repository = function(options) {
      var repo = options.name;
      var user = options.user;
 
      var that = this;
      var repoPath = '/repos/' + user + '/' + repo;
 
      var currentTree = {
        'branch': null,
        'sha': null
      };
 
      // Uses the cache if branch has not been changed
      // -------
 
      function updateTree(branch, cb) {
        if (branch === currentTree.branch && currentTree.sha) {
          return cb(null, currentTree.sha);
        }
        
        that.getRef('heads/' + branch, function(err, sha) {
          currentTree.branch = branch;
          currentTree.sha = sha;
          cb(err, sha);
        });
      }
 
      // Get a particular reference
      // -------
 
      this.getRef = function(ref, cb) {
        _request('GET', repoPath + '/git/refs/' + ref, null, function(err, res) {
          Iif (err) {
            return cb(err);
          }
          
          cb(null, res.object.sha);
        });
      };
 
      // Create a new reference
      // --------
      //
      // {
      //   "ref": "refs/heads/my-new-branch-name",
      //   "sha": "827efc6d56897b048c772eb4087f854f46256132"
      // }
 
      this.createRef = function(options, cb) {
        _request('POST', repoPath + '/git/refs', options, cb);
      };
 
      // Delete a reference
      // --------
      //
      // repo.deleteRef('heads/gh-pages')
      // repo.deleteRef('tags/v1.0')
 
      this.deleteRef = function(ref, cb) {
        _request('DELETE', repoPath + '/git/refs/' + ref, options, cb);
      };
 
      // Create a repo
      // -------
 
      this.createRepo = function(options, cb) {
        _request('POST', '/user/repos', options, cb);
      };
 
      // Delete a repo
      // --------
 
      this.deleteRepo = function(cb) {
        _request('DELETE', repoPath, options, cb);
      };
 
      // List all tags of a repository
      // -------
 
      this.listTags = function(cb) {
        _request('GET', repoPath + '/tags', null, function(err, tags) {
          Iif (err) {
            return cb(err);
          }
          
          cb(null, tags);
        });
      };
 
      // List all pull requests of a respository
      // -------
 
      this.listPulls = function(state, cb) {
        _request('GET', repoPath + "/pulls" + (state ? '?state=' + state : ''), null, function(err, pulls) {
          Iif (err) return cb(err);
          cb(null, pulls);
        });
      };
 
      // Gets details for a specific pull request
      // -------
 
      this.getPull = function(number, cb) {
        _request("GET", repoPath + "/pulls/" + number, null, function(err, pull) {
          Iif (err) return cb(err);
          cb(null, pull);
        });
      };
 
      // Retrieve the changes made between base and head
      // -------
 
      this.compare = function(base, head, cb) {
        _request("GET", repoPath + "/compare/" + base + "..." + head, null, function(err, diff) {
          Iif (err) return cb(err);
          cb(null, diff);
        });
      };
 
      // List all branches of a repository
      // -------
 
      this.listBranches = function(cb) {
        _request("GET", repoPath + "/git/refs/heads", null, function(err, heads) {
          Iif (err) return cb(err);
          cb(null, _.map(heads, function(head) { return _.last(head.ref.split('/')); }));
        });
      };
 
      // Retrieve the contents of a blob
      // -------
 
      this.getBlob = function(sha, cb) {
        _request("GET", repoPath + "/git/blobs/" + sha, null, cb, 'raw');
      };
 
      // For a given file path, get the corresponding sha (blob for files, tree for dirs)
      // -------
 
      this.getCommit = function(branch, sha, cb) {
        _request("GET", repoPath + "/git/commits/"+sha, null, function(err, commit) {
          Iif (err) return cb(err);
          cb(null, commit);
        });
      };
 
      // For a given file path, get the corresponding sha (blob for files, tree for dirs)
      // -------
 
      this.getSha = function(branch, path, cb) {
        Iif (!path || path === "") return that.getRef("heads/"+branch, cb);
        _request("GET", repoPath + "/contents/"+path, {ref: branch}, function(err, pathContent) {
          if (err) return cb(err);
          cb(null, pathContent.sha);
        });
      };
 
      // Retrieve the tree a commit points to
      // -------
 
      this.getTree = function(tree, cb) {
        _request("GET", repoPath + "/git/trees/"+tree, null, function(err, res) {
          Iif (err) return cb(err);
          cb(null, res.tree);
        });
      };
 
      // Post a new blob object, getting a blob SHA back
      // -------
 
      this.postBlob = function(content, cb) {
        Eif (typeof(content) === "string") {
          content = {
            "content": content,
            "encoding": "utf-8"
          };
        } else {
          	content = {
              "content": btoa(String.fromCharCode.apply(null, new Uint8Array(content))),
              "encoding": "base64"
            };
          }
 
        _request("POST", repoPath + "/git/blobs", content, function(err, res) {
          Iif (err) return cb(err);
          cb(null, res.sha);
        });
      };
 
      // Update an existing tree adding a new blob object getting a tree SHA back
      // -------
 
      this.updateTree = function(baseTree, path, blob, cb) {
        var data = {
          "base_tree": baseTree,
          "tree": [
            {
              "path": path,
              "mode": "100644",
              "type": "blob",
              "sha": blob
            }
          ]
        };
        _request("POST", repoPath + "/git/trees", data, function(err, res) {
          if (err) return cb(err);
          cb(null, res.sha);
        });
      };
 
      // Post a new tree object having a file path pointer replaced
      // with a new blob SHA getting a tree SHA back
      // -------
 
      this.postTree = function(tree, cb) {
        _request("POST", repoPath + "/git/trees", { "tree": tree }, function(err, res) {
          if (err) return cb(err);
          cb(null, res.sha);
        });
      };
 
      // Create a new commit object with the current commit SHA as the parent
      // and the new tree SHA, getting a commit SHA back
      // -------
 
      this.commit = function(parent, tree, message, cb) {
        var user = new Github.User();
        user.show(null, function(err, userData){
          Iif (err) return cb(err);
          var data = {
            "message": message,
            "author": {
              "name": options.user,
              "email": userData.email
            },
            "parents": [
              parent
            ],
            "tree": tree
          };
          _request("POST", repoPath + "/git/commits", data, function(err, res) {
            Eif (err) return cb(err);
            currentTree.sha = res.sha; // update latest commit
            cb(null, res.sha);
          });
        });
      };
 
      // Update the reference of your head to point to the new commit SHA
      // -------
 
      this.updateHead = function(head, commit, cb) {
        _request("PATCH", repoPath + "/git/refs/heads/" + head, { "sha": commit }, function(err) {
          cb(err);
        });
      };
 
      // Show repository information
      // -------
 
      this.show = function(cb) {
        _request("GET", repoPath, null, cb);
      };
 
      // Get contents
      // --------
 
      this.contents = function(ref, path, cb) {
        _request("GET", repoPath + "/contents/"+path, { ref: ref }, cb);
      };
 
      // Fork repository
      // -------
 
      this.fork = function(cb) {
        _request("POST", repoPath + "/forks", null, cb);
      };
 
      // Branch repository
      // --------
 
      this.branch = function(oldBranch,newBranch,cb) {
        if(arguments.length === 2 && typeof arguments[1] === "function") {
          cb = newBranch;
          newBranch = oldBranch;
          oldBranch = "master";
        }
        this.getRef("heads/" + oldBranch, function(err,ref) {
          if(err && cb) return cb(err);
          that.createRef({
            ref: "refs/heads/" + newBranch,
            sha: ref
          },cb);
        });
      };
 
      // Create pull request
      // --------
 
      this.createPullRequest = function(options, cb) {
        _request("POST", repoPath + "/pulls", options, cb);
      };
 
      // List hooks
      // --------
 
      this.listHooks = function(cb) {
        _request("GET", repoPath + "/hooks", null, cb);
      };
 
      // Get a hook
      // --------
 
      this.getHook = function(id, cb) {
        _request("GET", repoPath + "/hooks/" + id, null, cb);
      };
 
      // Create a hook
      // --------
 
      this.createHook = function(options, cb) {
        _request("POST", repoPath + "/hooks", options, cb);
      };
 
      // Edit a hook
      // --------
 
      this.editHook = function(id, options, cb) {
        _request("PATCH", repoPath + "/hooks/" + id, options, cb);
      };
 
      // Delete a hook
      // --------
 
      this.deleteHook = function(id, cb) {
        _request("DELETE", repoPath + "/hooks/" + id, null, cb);
      };
 
      // Read file at given path
      // -------
 
      this.read = function(branch, path, cb) {
        _request("GET", repoPath + "/contents/"+path, {ref: branch}, function(err, obj) {
          Iif (err && err.error === 404) return cb("not found", null, null);
 
          Iif (err) return cb(err);
          cb(null, obj);
        }, true);
      };
 
 
      // Remove a file
      // -------
 
      this.remove = function(branch, path, cb) {
        that.getSha(branch, path, function(err, sha) {
          if (err) return cb(err);
          _request("DELETE", repoPath + "/contents/" + path, {
            message: path + " is removed",
            sha: sha,
            branch: branch
          }, cb);
        });
      };
 
      // Delete a file from the tree
      // -------
 
      this.delete = function(branch, path, cb) {
        that.getSha(branch, path, function(err, sha) {
          if (!sha) return cb("not found", null);
          var delPath = repoPath + "/contents/" + path;
          var params = {
            "message": "Deleted " + path,
            "sha": sha
          };
          delPath += "?message=" + encodeURIComponent(params.message);
          delPath += "&sha=" + encodeURIComponent(params.sha);
          delPath += '&branch=' + encodeURIComponent(branch);
          _request("DELETE", delPath, null, cb);
        });
      };
 
      // Move a file to a new location
      // -------
 
      this.move = function(branch, path, newPath, cb) {
        updateTree(branch, function(err, latestCommit) {
          that.getTree(latestCommit+"?recursive=true", function(err, tree) {
            // Update Tree
            _.each(tree, function(ref) {
              if (ref.path === path) ref.path = newPath;
              if (ref.type === "tree") delete ref.sha;
            });
 
            that.postTree(tree, function(err, rootTree) {
              that.commit(latestCommit, rootTree, 'Deleted '+path , function(err, commit) {
                that.updateHead(branch, commit, function(err) {
                  cb(err);
                });
              });
            });
          });
        });
      };
 
      // Write file contents to a given branch and path
      // -------
 
      this.write = function(branch, path, content, message, cb) {
        that.getSha(branch, path, function(err, sha) {
          Iif (err && err.error !== 404) return cb(err);
          _request("PUT", repoPath + "/contents/" + path, {
            message: message,
            content: btoa(content),
            branch: branch,
            sha: sha
          }, cb);
        });
      };
 
      // List commits on a repository. Takes an object of optional paramaters:
      // sha: SHA or branch to start listing commits from
      // path: Only commits containing this file path will be returned
      // since: ISO 8601 date - only commits after this date will be returned
      // until: ISO 8601 date - only commits before this date will be returned
      // -------
 
      this.getCommits = function(options, cb) {
          options = options || {};
          var url = repoPath + "/commits";
          var params = [];
          if (options.sha) {
              params.push("sha=" + encodeURIComponent(options.sha));
          }
          if (options.path) {
              params.push("path=" + encodeURIComponent(options.path));
          }
          if (options.since) {
              var since = options.since;
              if (since.constructor === Date) {
                  since = since.toISOString();
              }
              params.push("since=" + encodeURIComponent(since));
          }
          if (options.until) {
              var until = options.until;
              if (until.constructor === Date) {
                  until = until.toISOString();
              }
              params.push("until=" + encodeURIComponent(until));
          }
          if (options.page) {
              params.push("page=" + options.page);
          }
          if (options.perpage) {
              params.push("per_page=" + options.perpage);
          }
          if (params.length > 0) {
              url += "?" + params.join("&");
          }
          _request("GET", url, null, cb);
      };
    };
 
    // Gists API
    // =======
 
    Github.Gist = function(options) {
      var id = options.id;
      var gistPath = "/gists/"+id;
 
      // Read the gist
      // --------
 
      this.read = function(cb) {
        _request("GET", gistPath, null, function(err, gist) {
          cb(err, gist);
        });
      };
 
      // Create the gist
      // --------
      // {
      //  "description": "the description for this gist",
      //    "public": true,
      //    "files": {
      //      "file1.txt": {
      //        "content": "String file contents"
      //      }
      //    }
      // }
 
      this.create = function(options, cb){
        _request("POST","/gists", options, cb);
      };
 
      // Delete the gist
      // --------
 
      this.delete = function(cb) {
        _request("DELETE", gistPath, null, function(err,res) {
          cb(err,res);
        });
      };
 
      // Fork a gist
      // --------
 
      this.fork = function(cb) {
        _request("POST", gistPath+"/fork", null, function(err,res) {
          cb(err,res);
        });
      };
 
      // Update a gist with the new stuff
      // --------
 
      this.update = function(options, cb) {
        _request("PATCH", gistPath, options, function(err,res) {
          cb(err,res);
        });
      };
 
      // Star a gist
      // --------
 
      this.star = function(cb) {
        _request("PUT", gistPath+"/star", null, function(err,res) {
          cb(err,res);
        });
      };
 
      // Untar a gist
      // --------
 
      this.unstar = function(cb) {
        _request("DELETE", gistPath+"/star", null, function(err,res) {
          cb(err,res);
        });
      };
 
      // Check if a gist is starred
      // --------
 
      this.isStarred = function(cb) {
        _request("GET", gistPath+"/star", null, function(err,res) {
          cb(err,res);
        });
      };
    };
 
    // Issues API
    // ==========
 
    Github.Issue = function(options) {
      var path = "/repos/" + options.user + "/" + options.repo + "/issues";
 
      this.list = function(options, cb) {
        var query = [];
        for (var key in options) {
          if (options.hasOwnProperty(key)) {
            query.push(encodeURIComponent(key) + "=" + encodeURIComponent(options[key]));
          }
        }
        _requestAllPages(path + '?' + query.join("&"), cb);
      };
    };
 
    // Top Level API
    // -------
 
    this.getIssues = function(user, repo) {
      return new Github.Issue({user: user, repo: repo});
    };
 
    this.getRepo = function(user, repo) {
      return new Github.Repository({user: user, name: repo});
    };
 
    this.getUser = function() {
      return new Github.User();
    };
 
    this.getGist = function(id) {
      return new Github.Gist({id: id});
    };
  };
 
  /* istanbul ignore else  */
  Eif (typeof exports !== 'undefined') {
    module.exports = Github;
  } else {
    window.Github = Github;
  }
}).call(this);