github_org_reports 0.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.rspec +1 -0
- data/Gemfile +19 -0
- data/Gemfile.lock +91 -0
- data/LICENSE.txt +20 -0
- data/README.rdoc +38 -0
- data/Rakefile +49 -0
- data/VERSION +1 -0
- data/include/github_org_reports_dbschema.rb +71 -0
- data/include/github_org_reports_models.rb +3 -0
- data/include/github_org_reports_repo.rb +7 -0
- data/lib/github_org_reports.rb +148 -0
- data/models/commit.rb +25 -0
- data/models/commit_organization_link.rb +4 -0
- data/models/organization.rb +3 -0
- data/models/pull_request.rb +30 -0
- data/models/pull_request_organization_link.rb +4 -0
- data/models/user.rb +3 -0
- data/spec/github_org_reports_spec.rb +25 -0
- data/spec/spec_helper.rb +12 -0
- metadata +214 -0
data/.document
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/Gemfile
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
# Add dependencies required to use your gem here.
|
3
|
+
# Example:
|
4
|
+
# gem "activesupport", ">= 2.3.5"
|
5
|
+
|
6
|
+
gem "baza", :path => "/Users/kaspernj/Dev/Ruby/baza"
|
7
|
+
gem "json"
|
8
|
+
gem "github_api"
|
9
|
+
gem "string-cases"
|
10
|
+
|
11
|
+
# Add dependencies to develop your gem here.
|
12
|
+
# Include everything needed to run rake, tests, features, etc.
|
13
|
+
group :development do
|
14
|
+
gem "rspec", "~> 2.8.0"
|
15
|
+
gem "rdoc", "~> 3.12"
|
16
|
+
gem "bundler", ">= 1.0.0"
|
17
|
+
gem "jeweler", "~> 1.8.4"
|
18
|
+
gem "sqlite3"
|
19
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,91 @@
|
|
1
|
+
PATH
|
2
|
+
remote: /Users/kaspernj/Dev/Ruby/baza
|
3
|
+
specs:
|
4
|
+
baza (0.0.8)
|
5
|
+
array_enumerator
|
6
|
+
datet
|
7
|
+
knjrbfw
|
8
|
+
wref
|
9
|
+
|
10
|
+
GEM
|
11
|
+
remote: http://rubygems.org/
|
12
|
+
specs:
|
13
|
+
array_enumerator (0.0.3)
|
14
|
+
datet (0.0.25)
|
15
|
+
diff-lcs (1.1.3)
|
16
|
+
faraday (0.8.7)
|
17
|
+
multipart-post (~> 1.1)
|
18
|
+
git (1.2.5)
|
19
|
+
github_api (0.9.7)
|
20
|
+
faraday (~> 0.8.1)
|
21
|
+
hashie (>= 1.2)
|
22
|
+
multi_json (~> 1.4)
|
23
|
+
nokogiri (~> 1.5.2)
|
24
|
+
oauth2
|
25
|
+
hashie (2.0.5)
|
26
|
+
http2 (0.0.14)
|
27
|
+
httpauth (0.2.0)
|
28
|
+
jeweler (1.8.4)
|
29
|
+
bundler (~> 1.0)
|
30
|
+
git (>= 1.2.5)
|
31
|
+
rake
|
32
|
+
rdoc
|
33
|
+
json (1.8.0)
|
34
|
+
jwt (0.1.8)
|
35
|
+
multi_json (>= 1.5)
|
36
|
+
knjrbfw (0.0.104)
|
37
|
+
datet
|
38
|
+
http2
|
39
|
+
php4r
|
40
|
+
ruby_process
|
41
|
+
tsafe
|
42
|
+
wref
|
43
|
+
multi_json (1.7.3)
|
44
|
+
multi_xml (0.5.3)
|
45
|
+
multipart-post (1.2.0)
|
46
|
+
nokogiri (1.5.9)
|
47
|
+
oauth2 (0.9.1)
|
48
|
+
faraday (~> 0.8)
|
49
|
+
httpauth (~> 0.1)
|
50
|
+
jwt (~> 0.1.4)
|
51
|
+
multi_json (~> 1.0)
|
52
|
+
multi_xml (~> 0.5)
|
53
|
+
rack (~> 1.2)
|
54
|
+
php4r (0.0.4)
|
55
|
+
datet
|
56
|
+
http2
|
57
|
+
string-strtr
|
58
|
+
rack (1.5.2)
|
59
|
+
rake (10.0.4)
|
60
|
+
rdoc (3.12.2)
|
61
|
+
json (~> 1.4)
|
62
|
+
rspec (2.8.0)
|
63
|
+
rspec-core (~> 2.8.0)
|
64
|
+
rspec-expectations (~> 2.8.0)
|
65
|
+
rspec-mocks (~> 2.8.0)
|
66
|
+
rspec-core (2.8.0)
|
67
|
+
rspec-expectations (2.8.0)
|
68
|
+
diff-lcs (~> 1.1.2)
|
69
|
+
rspec-mocks (2.8.0)
|
70
|
+
ruby_process (0.0.8)
|
71
|
+
tsafe
|
72
|
+
wref
|
73
|
+
sqlite3 (1.3.7)
|
74
|
+
string-cases (0.0.0)
|
75
|
+
string-strtr (0.0.3)
|
76
|
+
tsafe (0.0.11)
|
77
|
+
wref (0.0.6)
|
78
|
+
|
79
|
+
PLATFORMS
|
80
|
+
ruby
|
81
|
+
|
82
|
+
DEPENDENCIES
|
83
|
+
baza!
|
84
|
+
bundler (>= 1.0.0)
|
85
|
+
github_api
|
86
|
+
jeweler (~> 1.8.4)
|
87
|
+
json
|
88
|
+
rdoc (~> 3.12)
|
89
|
+
rspec (~> 2.8.0)
|
90
|
+
sqlite3
|
91
|
+
string-cases
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2013 kaspernj
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
= github_org_reports
|
2
|
+
|
3
|
+
A gem able to generate organization based statistics based on information given in commits and pull requests.
|
4
|
+
|
5
|
+
Example:
|
6
|
+
|
7
|
+
1. Make some commits that contains information like this:
|
8
|
+
|
9
|
+
My commit message.
|
10
|
+
!{time: '00:30', orgs: [org1, org3]}!
|
11
|
+
|
12
|
+
2. Run a small scripts that uses the gem:
|
13
|
+
|
14
|
+
require "rubygems"
|
15
|
+
require "github_org_reports"
|
16
|
+
|
17
|
+
db = Baza::Db.new(...) #See "baza" for this part.
|
18
|
+
gor = GithubOrgReports.new(:db => db)
|
19
|
+
gor.add_repo GithubOrgReports::Repo.new(:user => "username", :name => "reponame", :login => "your_username", :password => "your_password")
|
20
|
+
gor.scan
|
21
|
+
|
22
|
+
3. You can now go through the database to get the various time-information.
|
23
|
+
|
24
|
+
== Contributing to github_org_reports
|
25
|
+
|
26
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
|
27
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
|
28
|
+
* Fork the project.
|
29
|
+
* Start a feature/bugfix branch.
|
30
|
+
* Commit and push until you are happy with your contribution.
|
31
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
32
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
33
|
+
|
34
|
+
== Copyright
|
35
|
+
|
36
|
+
Copyright (c) 2013 kaspernj. See LICENSE.txt for
|
37
|
+
further details.
|
38
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
begin
|
6
|
+
Bundler.setup(:default, :development)
|
7
|
+
rescue Bundler::BundlerError => e
|
8
|
+
$stderr.puts e.message
|
9
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
+
exit e.status_code
|
11
|
+
end
|
12
|
+
require 'rake'
|
13
|
+
|
14
|
+
require 'jeweler'
|
15
|
+
Jeweler::Tasks.new do |gem|
|
16
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
17
|
+
gem.name = "github_org_reports"
|
18
|
+
gem.homepage = "http://github.com/kaspernj/github_org_reports"
|
19
|
+
gem.license = "MIT"
|
20
|
+
gem.summary = %Q{A gem to generate organization reports based on pull requests and commits.}
|
21
|
+
gem.description = %Q{A gem to generate organization reports based on pull requests and commits.}
|
22
|
+
gem.email = "k@spernj.org"
|
23
|
+
gem.authors = ["kaspernj"]
|
24
|
+
# dependencies defined in Gemfile
|
25
|
+
end
|
26
|
+
Jeweler::RubygemsDotOrgTasks.new
|
27
|
+
|
28
|
+
require 'rspec/core'
|
29
|
+
require 'rspec/core/rake_task'
|
30
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
31
|
+
spec.pattern = FileList['spec/**/*_spec.rb']
|
32
|
+
end
|
33
|
+
|
34
|
+
RSpec::Core::RakeTask.new(:rcov) do |spec|
|
35
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
36
|
+
spec.rcov = true
|
37
|
+
end
|
38
|
+
|
39
|
+
task :default => :spec
|
40
|
+
|
41
|
+
require 'rdoc/task'
|
42
|
+
Rake::RDocTask.new do |rdoc|
|
43
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
44
|
+
|
45
|
+
rdoc.rdoc_dir = 'rdoc'
|
46
|
+
rdoc.title = "github_org_reports #{version}"
|
47
|
+
rdoc.rdoc_files.include('README*')
|
48
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
49
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.0
|
@@ -0,0 +1,71 @@
|
|
1
|
+
class GithubOrgReports::Dbschema
|
2
|
+
SCHEMA = {
|
3
|
+
:tables => {
|
4
|
+
:Commit => {
|
5
|
+
:columns => [
|
6
|
+
{:name => :id, :type => :int, :autoincr => true, :primarykey => true},
|
7
|
+
{:name => :user_id, :type => :int},
|
8
|
+
{:name => :pull_request_id, :type => :int},
|
9
|
+
{:name => :sha, :type => :varchar},
|
10
|
+
{:name => :date, :type => :datetime},
|
11
|
+
{:name => :text, :type => :text},
|
12
|
+
{:name => :time, :type => :int}
|
13
|
+
],
|
14
|
+
:indexes => [
|
15
|
+
:user_id
|
16
|
+
]
|
17
|
+
},
|
18
|
+
:CommitOrganizationLink => {
|
19
|
+
:columns => [
|
20
|
+
{:name => :id, :type => :int, :autoincr => true, :primarykey => true},
|
21
|
+
{:name => :commit_id, :type => :int},
|
22
|
+
{:name => :organization_id, :type => :int},
|
23
|
+
{:name => :time, :type => :int}
|
24
|
+
],
|
25
|
+
:indexes => [
|
26
|
+
:commit_id,
|
27
|
+
:organization_id
|
28
|
+
]
|
29
|
+
},
|
30
|
+
:Organization => {
|
31
|
+
:columns => [
|
32
|
+
{:name => :id, :type => :int, :autoincr => true, :primarykey => true},
|
33
|
+
{:name => :name, :type => :varchar},
|
34
|
+
{:name => :name_short, :type => :varchar, :maxlength => 5}
|
35
|
+
]
|
36
|
+
},
|
37
|
+
:User => {
|
38
|
+
:columns => [
|
39
|
+
{:name => :id, :type => :int, :autoincr => true, :primarykey => true},
|
40
|
+
{:name => :name, :type => :varchar}
|
41
|
+
]
|
42
|
+
},
|
43
|
+
:PullRequest => {
|
44
|
+
:columns => [
|
45
|
+
{:name => :id, :type => :int, :autoincr => true, :primarykey => true},
|
46
|
+
{:name => :github_id, :type => :int, :renames => [:pull_request_id]},
|
47
|
+
{:name => :user_id, :type => :int},
|
48
|
+
{:name => :text, :type => :text},
|
49
|
+
{:name => :html, :type => :text},
|
50
|
+
{:name => :time, :type => :int}
|
51
|
+
],
|
52
|
+
:indexes => [
|
53
|
+
:github_id,
|
54
|
+
:user_id
|
55
|
+
]
|
56
|
+
},
|
57
|
+
:PullRequestOrganizationLink => {
|
58
|
+
:columns => [
|
59
|
+
{:name => :id, :type => :int, :autoincr => true, :primarykey => true},
|
60
|
+
{:name => :pull_request_id, :type => :int},
|
61
|
+
{:name => :organization_id, :type => :int},
|
62
|
+
{:name => :time, :type => :int}
|
63
|
+
],
|
64
|
+
:indexes => [
|
65
|
+
:pull_request_id,
|
66
|
+
:organization_id
|
67
|
+
]
|
68
|
+
}
|
69
|
+
}
|
70
|
+
}
|
71
|
+
end
|
@@ -0,0 +1,148 @@
|
|
1
|
+
require "rubygems"
|
2
|
+
require "github_api"
|
3
|
+
require "baza"
|
4
|
+
|
5
|
+
class GithubOrgReports
|
6
|
+
attr_reader :db, :ob, :repos
|
7
|
+
|
8
|
+
def self.const_missing(name)
|
9
|
+
require "#{File.dirname(__FILE__)}/../include/github_org_reports_#{name.to_s.downcase}.rb"
|
10
|
+
raise "Still not defined: '#{name}'." unless GithubOrgReports.const_defined?(name)
|
11
|
+
return GithubOrgReports.const_get(name)
|
12
|
+
end
|
13
|
+
|
14
|
+
def initialize(args = {})
|
15
|
+
@args = args
|
16
|
+
@repos = []
|
17
|
+
|
18
|
+
@db = @args[:db]
|
19
|
+
raise "No ':db' was given." unless @db
|
20
|
+
Baza::Revision.new.init_db(:db => @db, :schema => GithubOrgReports::Dbschema::SCHEMA)
|
21
|
+
|
22
|
+
@ob = Baza::ModelHandler.new(
|
23
|
+
:db => @db,
|
24
|
+
:class_path => "#{File.dirname(__FILE__)}/../models",
|
25
|
+
:class_pre => "",
|
26
|
+
:module => GithubOrgReports::Models,
|
27
|
+
:require_all => true
|
28
|
+
)
|
29
|
+
@ob.data[:github_org_reports] = self
|
30
|
+
end
|
31
|
+
|
32
|
+
def add_repo(repo)
|
33
|
+
raise "Invalid class: '#{repo.class.name}'." unless repo.is_a?(GithubOrgReports::Repo)
|
34
|
+
@repos << repo
|
35
|
+
end
|
36
|
+
|
37
|
+
def scan_hash(str)
|
38
|
+
str.to_s.scan(/!(\{(.+?)\})!/) do |match|
|
39
|
+
begin
|
40
|
+
yield JSON.parse(match[1])
|
41
|
+
rescue JSON::ParserError => e
|
42
|
+
$stderr.puts e.inspect
|
43
|
+
$stderr.puts e.backtrace
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def scan
|
49
|
+
@repos.each do |repo|
|
50
|
+
gh_args = {}
|
51
|
+
gh_args[:login] = repo.args[:login] if repo.args[:login]
|
52
|
+
gh_args[:password] = repo.args[:password] if repo.args[:password]
|
53
|
+
|
54
|
+
gh = ::Github.new(gh_args)
|
55
|
+
|
56
|
+
commits = gh.repos.commits.all(repo.args[:user], repo.args[:name])
|
57
|
+
commits.each do |commit_data|
|
58
|
+
commit = init_commit_from_data(commit_data)
|
59
|
+
end
|
60
|
+
|
61
|
+
prs = gh.pull_requests.list(repo.args[:user], repo.args[:name])
|
62
|
+
prs.each do |pr_data|
|
63
|
+
text = pr_data.body_text
|
64
|
+
|
65
|
+
user = @ob.get_or_add(:User, {
|
66
|
+
:name => pr_data.user
|
67
|
+
})
|
68
|
+
|
69
|
+
pr = @ob.get_or_add(:PullRequest, {
|
70
|
+
:github_id => pr_data.id
|
71
|
+
})
|
72
|
+
|
73
|
+
pr[:user_id] = user.id
|
74
|
+
pr[:text] = pr_data.body_text
|
75
|
+
pr[:html] = pr_data.body_html
|
76
|
+
|
77
|
+
pr.scan
|
78
|
+
|
79
|
+
commits = gh.pull_requests.commits(:repo => repo.args[:name], :user => repo.args[:user], :number => pr_data.number)
|
80
|
+
commits.each do |commit_data|
|
81
|
+
commit = init_commit_from_data(commit_data)
|
82
|
+
commit[:pull_request_id] = pr.id
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
def scan_for_time_and_orgs(str)
|
89
|
+
res = {:secs => 0, :orgs => [], :orgs_time => {}}
|
90
|
+
|
91
|
+
self.scan_hash(str) do |hash|
|
92
|
+
#Parse time.
|
93
|
+
if hash["time"] and match_time = hash["time"].to_s.match(/^(\d{1,2}):(\d{1,2})$/)
|
94
|
+
secs = 0
|
95
|
+
secs += match_time[1].to_i * 3600
|
96
|
+
secs += match_time[2].to_i * 60
|
97
|
+
|
98
|
+
res[:secs] += secs
|
99
|
+
|
100
|
+
#Parse organizations.
|
101
|
+
if orgs = hash["orgs"]
|
102
|
+
orgs = [orgs] if !orgs.is_a?(Hash)
|
103
|
+
orgs.each do |org_name_short|
|
104
|
+
org_name_short_dc = org_name_short.to_s.downcase
|
105
|
+
next if org_name_short_dc.strip.empty?
|
106
|
+
|
107
|
+
org = self.ob.get_or_add(:Organization, {:name_short => org_name_short_dc})
|
108
|
+
|
109
|
+
link = self.ob.get_or_add(:PullRequestOrganizationLink, {
|
110
|
+
:organization_id => org.id,
|
111
|
+
:pull_request_id => self.id
|
112
|
+
})
|
113
|
+
|
114
|
+
res[:orgs] << org unless res[:orgs].include?(org)
|
115
|
+
|
116
|
+
res[:orgs_time][org.id] = {:secs => 0} unless res[:orgs].key?(org.id)
|
117
|
+
res[:orgs_time][org.id][:secs] += match_time
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
return res
|
124
|
+
end
|
125
|
+
|
126
|
+
private
|
127
|
+
|
128
|
+
def init_commit_from_data(commit_data)
|
129
|
+
commit = @ob.get_or_add(:Commit, {
|
130
|
+
:sha => commit_data.sha
|
131
|
+
})
|
132
|
+
commit[:text] = commit_data.commit
|
133
|
+
commit[:date] = commit_data.commit.date
|
134
|
+
|
135
|
+
if commit_data.author
|
136
|
+
user = @ob.get_or_add(:User, {
|
137
|
+
:name => commit_data.author.login
|
138
|
+
})
|
139
|
+
commit[:user_id] = user.id
|
140
|
+
else
|
141
|
+
commit[:user_id] = 0
|
142
|
+
end
|
143
|
+
|
144
|
+
commit.scan
|
145
|
+
|
146
|
+
return commit
|
147
|
+
end
|
148
|
+
end
|
data/models/commit.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
class GithubOrgReports::Models::Commit < Baza::Model
|
2
|
+
has_one :User
|
3
|
+
has_one :PullRequest
|
4
|
+
|
5
|
+
def scan
|
6
|
+
hash = ob.data[:github_org_reports].scan_for_time_and_orgs(self[:text])
|
7
|
+
|
8
|
+
|
9
|
+
#Parse organizations.
|
10
|
+
hash[:orgs].each do |org|
|
11
|
+
link = self.ob.get_or_add(:CommitOrganizationLink, {
|
12
|
+
:organization_id => org.id,
|
13
|
+
:pull_request_id => self.id,
|
14
|
+
:time => hash[:orgs_time][org.id]
|
15
|
+
})
|
16
|
+
end
|
17
|
+
|
18
|
+
|
19
|
+
#Parse time.
|
20
|
+
self[:time] = hash[:secs]
|
21
|
+
|
22
|
+
|
23
|
+
return nil
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
class GithubOrgReports::Models::PullRequest < Baza::Model
|
2
|
+
has_many [[:PullRequestOrganizationLink, :pull_request_id]]
|
3
|
+
|
4
|
+
def scan
|
5
|
+
hash = ob.data[:github_org_reports].scan_for_time_and_orgs(self[:text])
|
6
|
+
|
7
|
+
|
8
|
+
#Parse organizations.
|
9
|
+
hash[:orgs].each do |org|
|
10
|
+
link = self.ob.get_or_add(:PullRequestOrganizationLink, {
|
11
|
+
:organization_id => org.id,
|
12
|
+
:pull_request_id => self.id,
|
13
|
+
:time => hash[:orgs_time][:secs]
|
14
|
+
})
|
15
|
+
end
|
16
|
+
|
17
|
+
|
18
|
+
#Parse time.
|
19
|
+
self[:time] = hash[:secs]
|
20
|
+
|
21
|
+
|
22
|
+
return nil
|
23
|
+
end
|
24
|
+
|
25
|
+
def total_time_for_orgs(args)
|
26
|
+
orgs = {}
|
27
|
+
|
28
|
+
|
29
|
+
end
|
30
|
+
end
|
data/models/user.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
require "tmpdir"
|
4
|
+
require "sqlite3"
|
5
|
+
require "json"
|
6
|
+
|
7
|
+
describe "GithubOrgReports" do
|
8
|
+
it "should be able to fill the database" do
|
9
|
+
db_path = "#{Dir.tmpdir}/github_org_reports.sqlite3"
|
10
|
+
db = Baza::Db.new(:type => :sqlite3, :path => db_path, :index_append_table_name => true)
|
11
|
+
|
12
|
+
login_info = JSON.parse(File.read("#{File.dirname(__FILE__)}/spec_info.txt").to_s.strip)
|
13
|
+
|
14
|
+
begin
|
15
|
+
gor = GithubOrgReports.new(:db => db)
|
16
|
+
gor.add_repo GithubOrgReports::Repo.new(:user => "kaspernj", :name => "php4r", :login => login_info["login"], :password => login_info["password"])
|
17
|
+
gor.add_repo GithubOrgReports::Repo.new(:user => "kaspernj", :name => "github_org_reports", :login => login_info["login"], :password => login_info["password"])
|
18
|
+
gor.scan
|
19
|
+
rescue => e
|
20
|
+
puts e.inspect
|
21
|
+
puts e.backtrace
|
22
|
+
raise e
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
3
|
+
require 'rspec'
|
4
|
+
require 'github_org_reports'
|
5
|
+
|
6
|
+
# Requires supporting files with custom matchers and macros, etc,
|
7
|
+
# in ./support/ and its subdirectories.
|
8
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
9
|
+
|
10
|
+
RSpec.configure do |config|
|
11
|
+
|
12
|
+
end
|
metadata
ADDED
@@ -0,0 +1,214 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: github_org_reports
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 0.0.0
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- kaspernj
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-05-16 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
version_requirements: !ruby/object:Gem::Requirement
|
16
|
+
none: false
|
17
|
+
requirements:
|
18
|
+
- - ! '>='
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '0'
|
21
|
+
name: baza
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
requirement: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
version_requirements: !ruby/object:Gem::Requirement
|
32
|
+
none: false
|
33
|
+
requirements:
|
34
|
+
- - ! '>='
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: '0'
|
37
|
+
name: json
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
requirement: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
version_requirements: !ruby/object:Gem::Requirement
|
48
|
+
none: false
|
49
|
+
requirements:
|
50
|
+
- - ! '>='
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '0'
|
53
|
+
name: github_api
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
requirement: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
version_requirements: !ruby/object:Gem::Requirement
|
64
|
+
none: false
|
65
|
+
requirements:
|
66
|
+
- - ! '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
name: string-cases
|
70
|
+
type: :runtime
|
71
|
+
prerelease: false
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
none: false
|
81
|
+
requirements:
|
82
|
+
- - ~>
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: 2.8.0
|
85
|
+
name: rspec
|
86
|
+
type: :development
|
87
|
+
prerelease: false
|
88
|
+
requirement: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ~>
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: 2.8.0
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
version_requirements: !ruby/object:Gem::Requirement
|
96
|
+
none: false
|
97
|
+
requirements:
|
98
|
+
- - ~>
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: '3.12'
|
101
|
+
name: rdoc
|
102
|
+
type: :development
|
103
|
+
prerelease: false
|
104
|
+
requirement: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ~>
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '3.12'
|
110
|
+
- !ruby/object:Gem::Dependency
|
111
|
+
version_requirements: !ruby/object:Gem::Requirement
|
112
|
+
none: false
|
113
|
+
requirements:
|
114
|
+
- - ! '>='
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: 1.0.0
|
117
|
+
name: bundler
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
requirement: !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
122
|
+
requirements:
|
123
|
+
- - ! '>='
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: 1.0.0
|
126
|
+
- !ruby/object:Gem::Dependency
|
127
|
+
version_requirements: !ruby/object:Gem::Requirement
|
128
|
+
none: false
|
129
|
+
requirements:
|
130
|
+
- - ~>
|
131
|
+
- !ruby/object:Gem::Version
|
132
|
+
version: 1.8.4
|
133
|
+
name: jeweler
|
134
|
+
type: :development
|
135
|
+
prerelease: false
|
136
|
+
requirement: !ruby/object:Gem::Requirement
|
137
|
+
none: false
|
138
|
+
requirements:
|
139
|
+
- - ~>
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: 1.8.4
|
142
|
+
- !ruby/object:Gem::Dependency
|
143
|
+
version_requirements: !ruby/object:Gem::Requirement
|
144
|
+
none: false
|
145
|
+
requirements:
|
146
|
+
- - ! '>='
|
147
|
+
- !ruby/object:Gem::Version
|
148
|
+
version: '0'
|
149
|
+
name: sqlite3
|
150
|
+
type: :development
|
151
|
+
prerelease: false
|
152
|
+
requirement: !ruby/object:Gem::Requirement
|
153
|
+
none: false
|
154
|
+
requirements:
|
155
|
+
- - ! '>='
|
156
|
+
- !ruby/object:Gem::Version
|
157
|
+
version: '0'
|
158
|
+
description: A gem to generate organization reports based on pull requests and commits.
|
159
|
+
email: k@spernj.org
|
160
|
+
executables: []
|
161
|
+
extensions: []
|
162
|
+
extra_rdoc_files:
|
163
|
+
- LICENSE.txt
|
164
|
+
- README.rdoc
|
165
|
+
files:
|
166
|
+
- .document
|
167
|
+
- .rspec
|
168
|
+
- Gemfile
|
169
|
+
- Gemfile.lock
|
170
|
+
- LICENSE.txt
|
171
|
+
- README.rdoc
|
172
|
+
- Rakefile
|
173
|
+
- VERSION
|
174
|
+
- include/github_org_reports_dbschema.rb
|
175
|
+
- include/github_org_reports_models.rb
|
176
|
+
- include/github_org_reports_repo.rb
|
177
|
+
- lib/github_org_reports.rb
|
178
|
+
- models/commit.rb
|
179
|
+
- models/commit_organization_link.rb
|
180
|
+
- models/organization.rb
|
181
|
+
- models/pull_request.rb
|
182
|
+
- models/pull_request_organization_link.rb
|
183
|
+
- models/user.rb
|
184
|
+
- spec/github_org_reports_spec.rb
|
185
|
+
- spec/spec_helper.rb
|
186
|
+
homepage: http://github.com/kaspernj/github_org_reports
|
187
|
+
licenses:
|
188
|
+
- MIT
|
189
|
+
post_install_message:
|
190
|
+
rdoc_options: []
|
191
|
+
require_paths:
|
192
|
+
- lib
|
193
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
194
|
+
none: false
|
195
|
+
requirements:
|
196
|
+
- - ! '>='
|
197
|
+
- !ruby/object:Gem::Version
|
198
|
+
segments:
|
199
|
+
- 0
|
200
|
+
hash: 2843595140910669046
|
201
|
+
version: '0'
|
202
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
203
|
+
none: false
|
204
|
+
requirements:
|
205
|
+
- - ! '>='
|
206
|
+
- !ruby/object:Gem::Version
|
207
|
+
version: '0'
|
208
|
+
requirements: []
|
209
|
+
rubyforge_project:
|
210
|
+
rubygems_version: 1.8.23
|
211
|
+
signing_key:
|
212
|
+
specification_version: 3
|
213
|
+
summary: A gem to generate organization reports based on pull requests and commits.
|
214
|
+
test_files: []
|