https://github.com/kevinjalbert/github_archive_parser
Easily parse GitHub Archive
https://github.com/kevinjalbert/github_archive_parser
github github-archive rubygem
Last synced: 10 months ago
JSON representation
Easily parse GitHub Archive
- Host: GitHub
- URL: https://github.com/kevinjalbert/github_archive_parser
- Owner: kevinjalbert
- License: mit
- Created: 2014-01-14T21:08:02.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2014-05-09T02:57:02.000Z (about 12 years ago)
- Last Synced: 2025-03-11T01:38:02.776Z (over 1 year ago)
- Topics: github, github-archive, rubygem
- Language: Ruby
- Homepage: https://rubygems.org/gems/github_archive_parser
- Size: 316 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# GitHub Archive Parser
[](https://gitter.im/kevinjalbert/github_archive_parser)
[](http://badge.fury.io/rb/github_archive_parser)
[](http://travis-ci.org/kevinjalbert/github_archive_parser)
[](https://coveralls.io/r/kevinjalbert/github_archive_parser)
[](https://codeclimate.com/github/kevinjalbert/github_archive_parser)
[](https://gemnasium.com/kevinjalbert/github_archive_parser)
## Introduction
This gem provides a streamlined method for parsing the [GitHub Archive](http://www.githubarchive.org/). You have the ability to define custom event handlers for the different [22 GitHub Event Types](http://developer.github.com/v3/activity/events/types/). A custom event handler allows you to parse individual events as they are processed by the GitHub Archive Parser.
## Example
You want to print the name of newly created repositories. The first thing you need to do is create your own custom event handler which requires the following statement: `includes GitHubArchiveParser::CreateEvent`. This causes GitHub Archive Parser to call your custom event handler class anytime it encounters a *CreateEvent*. In your custom event handler you only require one method `def parser(event)`, which is executed when a *CreateEvent* is encountered. The event is a [Hashie::Mash](https://github.com/intridea/hashie#mash) object which allows you to access the values of the hash using simple *dot* notation. You can define as many unique custom event handlers as needed (even for the same event type).
module AwesomeApplication
class PrintCreateEvent
include GitHubArchiveParser::CreateEvent
def parse(event)
# The event is a Hashie::Mash object for easy (dot) access
puts "#{event.repository.owner}/#{event.repository.name}"
end
end
end
When you have your custom event handlers setup you can simply start processing [GitHub Archive](http://www.githubarchive.org/) using `GitHubArchiveParser::Processor`. Currently you can process one hour blocks on an individual basis, or by specifing ranges.
processor = GitHubArchiveParser::Processor.new
processor.process_url("http://data.githubarchive.org/2012-04-11-15.json.gz")
processor.process_since("One Month Ago")
processor.process_between("One Week Ago", "Yesterday")