hexabat 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.gitignore ADDED
@@ -0,0 +1,20 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ .rbx
19
+
20
+ examples/
data/.rvmrc ADDED
@@ -0,0 +1 @@
1
+ rvm use 1.9.3@hexabat --create
data/.travis.yml ADDED
@@ -0,0 +1,12 @@
1
+ language: ruby
2
+ matrix:
3
+ allow_failures:
4
+ - rvm: ruby-head
5
+ - rvm: rbx-19mode
6
+ - rvm: jruby-19mode
7
+ rvm:
8
+ - 1.9.3
9
+ - 1.9.2
10
+ - ruby-head
11
+ - rbx-19mode
12
+ - jruby-19mode
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in hexabat.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 path11
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,119 @@
1
+ # Hexabat [![Build Status](https://secure.travis-ci.org/jacegu/hexabat.png?branch=master)](http://travis-ci.org/jacegu/hexabat) [![Code Climate](https://codeclimate.com/badge.png)](https://codeclimate.com/github/jacegu/hexabat)
2
+
3
+ **Hexabat is a Github issues importer tool for Ruby.**
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'hexabat'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install hexabat
18
+
19
+
20
+ ## Overview
21
+
22
+ The
23
+ [Github issues API](http://developer.github.com/v3/issues/#list-issues-for-a-repository)
24
+ is nice, but if you try to get all the issues of a project you will have a hard
25
+ time. You will need to query page by page and get open and closed issues
26
+ separately.
27
+
28
+ Also, if you want to find out the total number of issues, there is no easy way
29
+ of doing it. You can't find out the amount of open issues through the
30
+ [repositories API](http://developer.github.com/v3/repos/#get)
31
+ but, where are the closed ones?
32
+
33
+
34
+ ## Features
35
+
36
+ Hexabat tackles those two problems by providing an easy way of importing
37
+ the issues of a Github repository:
38
+
39
+ ```ruby
40
+ Hexabat.on_issue_retrieved do |issue|
41
+ puts "issue ##{issue['number']} imported"
42
+ end
43
+
44
+ Hexabat.on_issue_count_known do |count|
45
+ puts "The repository has #{count} issues"
46
+ end
47
+
48
+ Hexabat.on_error do |repo, status, message|
49
+ STDERR.puts "Failed to import #{repo} due to #{status}: #{message}"
50
+ end
51
+
52
+ Hexabat.import 'rails/rails'
53
+ ```
54
+
55
+ That means that Hexabat will allow you to:
56
+
57
+ * **Find out the total number of issues** (both open and closed) of the repository.
58
+ * **Do something with the data of every issue in the repository** (i.e. store it in a database).
59
+ * **Handle importing errors properly** (i.e. store the error reason in a database)
60
+
61
+ You don't need set every single callback if you don't want to. You can setup only one
62
+ callback if that's what you need. We also provide a default `errback` that will
63
+ print to `STDERR` a message with the failure (pretty similar to the example above).
64
+
65
+
66
+
67
+ ###Authentication
68
+
69
+ If you are importing a public repository's issues you don't need to authenticate:
70
+
71
+ ```ruby
72
+ Hexabat.import 'rails/rails'
73
+ ```
74
+
75
+ If you want to import issues on behalf of a user you authenticated with OAuth
76
+ you can use her token in order to do it:
77
+
78
+ ```ruby
79
+ Hexabat.import 'path11/private_repo', token: auth_token
80
+ ```
81
+
82
+
83
+ ## EventMachine integration
84
+
85
+ Hexabat runs on top of
86
+ [EventMachine](https://github.com/eventmachine/eventmachine).
87
+
88
+ You can use it inside a running event loop:
89
+
90
+ ```ruby
91
+ EM.run do
92
+ Hexabat.on_issue_retrieved { |issue| puts "issue ##{issue['number']} imported" }
93
+ Hexabat.on_issue_count_known { |count| puts "The repository has #{count} issues" }
94
+ Hexabat.import 'rails/rails' # this won't start an event loop
95
+ end
96
+ ```
97
+
98
+ Hexabat will start the event loop for you if you call it outside a running one.
99
+
100
+
101
+ ### Does Hexabat stop the event loop?
102
+
103
+ No it doesn't. Given that Hexabat doesn't know the work you are going to do
104
+ with each of the issues it doesn't know when it's work will be done. For
105
+ example: if you use
106
+ [em-mongo](https://github.com/bcg/em-mongo)
107
+ to store each issue Hexabat can't know when each of those callbacks is done.
108
+
109
+ **It's your job to** sync them up and **stop the event loop**.
110
+
111
+
112
+ ## What's next?
113
+
114
+ There are a few tweaks and improvements that we want to add to Hexabat:
115
+
116
+ * Being able to provide an OAuth tokens, and keys so you can authorize your
117
+ application without the need of a user OAuth token.
118
+
119
+ After that we have a few more things planned but that will be a surprise.
data/Rakefile ADDED
@@ -0,0 +1,32 @@
1
+ #!/usr/bin/env rake
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'cucumber/rake/task'
5
+ require 'rspec/core/rake_task'
6
+
7
+ namespace :cucumber do
8
+ Cucumber::Rake::Task.new(:ok, 'Run features that should pass') do |t|
9
+ t.cucumber_opts = ['--strict', '--tags ~@wip', '--format progress']
10
+ end
11
+
12
+ Cucumber::Rake::Task.new(:wip, 'Run features that are being worked on') do |t|
13
+ t.cucumber_opts = ['--wip', '--tags @wip']
14
+ end
15
+
16
+ Cucumber::Rake::Task.new(:all, 'Run all features')
17
+ end
18
+
19
+ namespace :rspec do
20
+ desc 'Run specs with progress output'
21
+ RSpec::Core::RakeTask.new(:progress) do |t|
22
+ t.rspec_opts = '--format progress'
23
+ end
24
+
25
+ desc 'Run all specs'
26
+ RSpec::Core::RakeTask.new(:spec)
27
+ end
28
+
29
+ task spec: 'rspec:spec'
30
+ task cucumber: 'cucumber:ok'
31
+ task test: ['rspec:progress', 'cucumber:ok']
32
+ task default: 'test'
@@ -0,0 +1,21 @@
1
+ #language: en
2
+
3
+ Feature: Callbacks
4
+
5
+ Scenario: A single issue is retrieved and the callback is called.
6
+ Given there is a single open issue on "path11/hexabat"
7
+ When I set up an issue retrieved callback
8
+ And I import the "path11/hexabat" repository
9
+ Then the callback is called with the issue in that repository
10
+
11
+ Scenario: The number of issues is found out and the callback is called.
12
+ Given there are 101 open issues and 300 closed issues on "path11/hexabat"
13
+ When I setup the issue count known callback
14
+ And I import the "path11/hexabat" repository
15
+ Then the callback is called with the number of issues of the repository
16
+
17
+ Scenario: The repository can't be imported and the errback is called.
18
+ Given the repository "path11/rails" doesn't exist
19
+ When I setup the errback
20
+ And I import the "path11/rails" repository
21
+ Then the errback is called with the error message