Git Product home page Git Product logo

otr's Introduction

One True Repo

One feed to rule them all, and in the mashup bind them.

Created by Stephen McDonald

One True Repo merges both the GitHub and Bitbucket APIs into a single JSON feed, for the purpose of combining numbers of watchers and forks across duplicate repositories. It comes as both a Sinatra app and command-line gem.

Sinatra

The Sinatra app is hosted on Heroku at otr.jupo.org. Add your username to the path to get your feed. For example my GitHub and Bitbucket username is stephenmcd so my feed is available at otr.jupo.org/stephenmcd. If you have different usernames between GitHub and Bitbucket, you can use the URL otr.jupo.org/github_username/bitbucket_username to provide them separately. Note that feeds are cached for about 24 hours.

JSON

Here’s a sample of the JSON provided:

[
    {
        "name": "mezzanine",
        "urls": [
            "https://github.com/stephenmcd/mezzanine",
            "https://bitbucket.org/stephenmcd/mezzanine"
        ],
        "watchers": 316,
        "forks": 102,
        "fork": false
    },
    {
        "name": "django-socketio",
        "urls": [
            "https://github.com/stephenmcd/django-socketio",
            "https://bitbucket.org/stephenmcd/django-socketio"
        ],
        "watchers": 112,
        "forks": 11,
        "fork": false
    }
]

JSONP

You can also append a callback parameter to the Sinatra app’s URLs, specifying the name of a JavaScript function to call:

<script>
    var displayRepos = function(repos) {
        // The repos argument will contain the
        // JSON data for stephenmcd's feed.
        var watchers = 0, forks = 0;
        for (var i = 0; i < repos.length; i++) {
            watchers += repos[i].watchers;
            forks += repos[i].forks;
        }
        alert('Total watchers: ' + watchers + '\nTotal forks: ' + forks);
    }
</script>
<script src="http://otr.jupo.org/stephenmcd?callback=displayRepos"></script>

Ruby Gem

One True Repo is also an installable gem named otr. Install the otr gem with the following command:

$ gem install otr

Once installed, otr can be called from the command-line and will output its JSON feed:

Usage: otr [options]

    -u, --username NAME              Combined GitHub / Bitbucket username
    -g, --github-username NAME       GitHub username if different from
                                     Bitbucket username (required without -u)
    -b, --bitbucket-username NAME    Bitbucket username if different from
                                     GitHub username (required without -u)
    -h, --help                       Show this message
    -v, --version                    Show version

You can also use otr in your own Ruby code:

require 'rubygems'
require 'otr'

# With a combined username:
options = {:username => "stephenmcd"}

# Or with differing usernames:
options = {:github_username => "alice", :bitbucket_username => "bob"}

json = OTR.get(options).to_json

otr's People

Contributors

stephenmcd avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

otr's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.