hubstats 0.1.0 → 0.1.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.
- checksums.yaml +13 -5
- data/app/assets/javascripts/hubstats/application.js +4 -4
- data/app/assets/javascripts/hubstats/pull_requests.js +1 -2
- data/app/controllers/hubstats/pull_requests_controller.rb +2 -2
- data/app/models/hubstats/pull_request.rb +2 -2
- data/hubstats.gemspec +1 -1
- data/lib/hubstats/events_handler.rb +1 -1
- data/lib/hubstats/github_api.rb +98 -42
- data/lib/hubstats/version.rb +1 -1
- data/lib/tasks/hubstats_tasks.rake +7 -1
- data/lib/tasks/populate_task.rake +42 -42
- data/spec/lib/hubstats/events_handler_spec.rb +5 -6
- data/spec/lib/hubstats/github_api_spec.rb +41 -5
- data/spec/models/hubstats/label_spec.rb +0 -1
- metadata +26 -26
checksums.yaml
CHANGED
@@ -1,7 +1,15 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
YzQ0NzQ0ZjljODdiZjAyYTM3M2I3N2UxMGJjM2ViMmQ3OTJhY2U4Mg==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
NTVhMGRkNWIxZDE5MGU4MDFlZjgyZTk0MmU5NWE5NWQxMTVmYzdmOA==
|
5
7
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
MDkzZjcxYjI2ZmVmNzYxZDhjNDAwY2EzZWY2OTMwN2MzYWM2M2NjMDNiYzc5
|
10
|
+
YTEyYmRjNTRiZjU5ZTY5NWIwN2I5NTEwY2Y0YzJlOThiN2U5OTNiODQxN2Ix
|
11
|
+
MjhkMDFiZmYyYzVkMDE5YWYxYmViYTk2YzhlM2Y1N2I0MmZmZDY=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
OWZmYWQ3MWZkMmVjYzExYTRiMzAxZmE3OGM2NzVhMTViNTU1ODZmZGFlM2Iw
|
14
|
+
YzYyYTI1OWQzMWJmYzJhZWQyMWVmNzU3OWFjNmRhOWM0ODM5MWYyY2QxMTJh
|
15
|
+
YjU5NDY4ZmU1MzA4YjYyY2UzNzM1ZDJjMzNkNTU2NWFhMWE2Y2E=
|
@@ -32,7 +32,7 @@ function setTimespan() {
|
|
32
32
|
createCookie("hubstats_index",this.selectedIndex,1);
|
33
33
|
window.location.reload();
|
34
34
|
};
|
35
|
-
}
|
35
|
+
};
|
36
36
|
|
37
37
|
function createCookie(name,value,days) {
|
38
38
|
if (days) {
|
@@ -42,7 +42,7 @@ function createCookie(name,value,days) {
|
|
42
42
|
}
|
43
43
|
else var expires = "";
|
44
44
|
document.cookie = name+"="+value+expires+"; path=/";
|
45
|
-
}
|
45
|
+
};
|
46
46
|
|
47
47
|
function readCookie(name) {
|
48
48
|
var nameEQ = name + "=";
|
@@ -53,8 +53,8 @@ function readCookie(name) {
|
|
53
53
|
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
|
54
54
|
}
|
55
55
|
return null;
|
56
|
-
}
|
56
|
+
};
|
57
57
|
|
58
58
|
function eraseCookie(name) {
|
59
59
|
createCookie(name,"",-1);
|
60
|
-
}
|
60
|
+
};
|
@@ -57,10 +57,9 @@ function getUrlVars() {
|
|
57
57
|
for (var i = 0; i < hashes.length; i++) {
|
58
58
|
hash = hashes[i].split('=');
|
59
59
|
vars.push(hash[0]);
|
60
|
-
vars[hash[0]] = hash[1]
|
60
|
+
vars[hash[0]] = decodeURIComponent(hash[1]);
|
61
61
|
}
|
62
62
|
}
|
63
|
-
|
64
63
|
return vars;
|
65
64
|
}
|
66
65
|
|
@@ -9,9 +9,9 @@ module Hubstats
|
|
9
9
|
pull_ids = Hubstats::PullRequest
|
10
10
|
.belonging_to_users(params[:users])
|
11
11
|
.belonging_to_repos(params[:repos])
|
12
|
-
.
|
12
|
+
.state_based_order(@timespan,params[:state],"ASC")
|
13
13
|
.map(&:id)
|
14
|
-
|
14
|
+
|
15
15
|
@labels = Hubstats::Label.with_a_pull_request(pull_ids).order("pull_request_count DESC")
|
16
16
|
|
17
17
|
@pull_requests = Hubstats::PullRequest.includes(:user).includes(:repo)
|
@@ -49,9 +49,9 @@ module Hubstats
|
|
49
49
|
def self.state_based_order(timespan,state,order)
|
50
50
|
order = ["ASC","DESC"].detect{|order_type| order_type.to_s == order.to_s.upcase } || "DESC"
|
51
51
|
if state == "closed"
|
52
|
-
with_state(state).
|
52
|
+
with_state(state).updated_since(timespan).order("hubstats_pull_requests.closed_at #{order}")
|
53
53
|
else
|
54
|
-
with_state(state).
|
54
|
+
with_state(state).updated_since(timespan).order("hubstats_pull_requests.created_at #{order}")
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
data/hubstats.gemspec
CHANGED
@@ -19,7 +19,7 @@ Gem::Specification.new do |s|
|
|
19
19
|
s.add_dependency "rails", "~> 3.2.18"
|
20
20
|
s.add_dependency "octokit", "~> 3.2"
|
21
21
|
s.add_dependency "will_paginate-bootstrap"
|
22
|
-
s.add_dependency "select2-rails", "
|
22
|
+
s.add_dependency "select2-rails", "3.5.9"
|
23
23
|
|
24
24
|
s.add_development_dependency "rspec-rails",'~> 3.0.0.beta'
|
25
25
|
s.add_development_dependency "shoulda-matchers", "~> 2.6"
|
@@ -19,7 +19,7 @@ module Hubstats
|
|
19
19
|
pull_request[:repository] = payload[:repository]
|
20
20
|
new_pull = Hubstats::PullRequest.create_or_update(pull_request.with_indifferent_access)
|
21
21
|
repo_name = Hubstats::Repo.where(id: new_pull.repo_id).first.full_name
|
22
|
-
labels = Hubstats::GithubAPI.
|
22
|
+
labels = Hubstats::GithubAPI.get_labels_for_pull(repo_name, new_pull.number )
|
23
23
|
new_pull.add_labels(labels)
|
24
24
|
end
|
25
25
|
|
data/lib/hubstats/github_api.rb
CHANGED
@@ -3,7 +3,7 @@ module Hubstats
|
|
3
3
|
include HubHelper
|
4
4
|
|
5
5
|
cattr_accessor :auth_info
|
6
|
-
|
6
|
+
|
7
7
|
def self.configure(options={})
|
8
8
|
@@auth_info = {}
|
9
9
|
if access_token = ENV['GITHUB_API_TOKEN'] || options["access_token"]
|
@@ -22,6 +22,13 @@ module Hubstats
|
|
22
22
|
return ent
|
23
23
|
end
|
24
24
|
|
25
|
+
# Public: Gets all of a specific kind from a repo, and processes them.
|
26
|
+
#
|
27
|
+
# repo_name - the name of a repo
|
28
|
+
# kind - a kind of object (pull,comment)
|
29
|
+
# options - any possible option a particular kind of object
|
30
|
+
#
|
31
|
+
# Returns an array of that particular kind
|
25
32
|
def self.inline(repo_name, kind, options={})
|
26
33
|
path = ["repos",repo_name,kind].join('/')
|
27
34
|
octo = client({:auto_paginate => true })
|
@@ -31,6 +38,44 @@ module Hubstats
|
|
31
38
|
end.each{|v| route(v,kind,repo_name)}.clear
|
32
39
|
end
|
33
40
|
|
41
|
+
# Public: Gets repos found in configuration file
|
42
|
+
#
|
43
|
+
# Returns - an array of github repo objects
|
44
|
+
def self.get_repos
|
45
|
+
if Hubstats.config.github_config.has_key?("org_name")
|
46
|
+
repos = client.organization_repositories(Hubstats.config.github_config["org_name"])
|
47
|
+
else
|
48
|
+
repos = []
|
49
|
+
Hubstats.config.github_config["repo_list"].each do |repo|
|
50
|
+
repos << client.repository(repo)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
repos
|
54
|
+
end
|
55
|
+
|
56
|
+
# Public: Gets extra information on pull requests, e.g size, additions ...
|
57
|
+
def self.update_pulls
|
58
|
+
grab_size = 250
|
59
|
+
begin
|
60
|
+
while Hubstats::PullRequest.where(deletions: nil).where(additions: nil).count > 0
|
61
|
+
client = Hubstats::GithubAPI.client
|
62
|
+
incomplete = Hubstats::PullRequest.where(deletions: nil).where(additions: nil).limit(grab_size)
|
63
|
+
|
64
|
+
incomplete.each do |pull|
|
65
|
+
repo = Hubstats::Repo.where(id: pull.repo_id).first
|
66
|
+
pr = client.pull_request(repo.full_name, pull.number)
|
67
|
+
Hubstats::PullRequest.create_or_update(HubHelper.pull_setup(pr))
|
68
|
+
end
|
69
|
+
|
70
|
+
wait_limit(grab_size,client.rate_limit)
|
71
|
+
end
|
72
|
+
puts "All Pull Requests are up to date"
|
73
|
+
rescue Faraday::ConnectionFailed
|
74
|
+
puts "Connection Timeout, restarting pull request updating"
|
75
|
+
update_pulls
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
34
79
|
def self.create_hook(repo)
|
35
80
|
begin
|
36
81
|
client.create_hook(
|
@@ -61,61 +106,72 @@ module Hubstats
|
|
61
106
|
end
|
62
107
|
end
|
63
108
|
|
64
|
-
|
65
|
-
|
109
|
+
# Public: Delete webhook from github repository
|
110
|
+
#
|
111
|
+
# repo - a repo github object
|
112
|
+
# old_endpoint - A string of the previous endpoint
|
113
|
+
#
|
114
|
+
# Return - nothing
|
115
|
+
def self.delete_hook(repo, old_endpoint)
|
66
116
|
begin
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
incomplete.each do |pull|
|
72
|
-
repo = Hubstats::Repo.where(id: pull.repo_id).first
|
73
|
-
pr = client.pull_request(repo.full_name, pull.number)
|
74
|
-
Hubstats::PullRequest.create_or_update(HubHelper.pull_setup(pr))
|
117
|
+
client.hooks(repo.full_name).each do |hook|
|
118
|
+
if hook[:config][:url] == old_endpoint
|
119
|
+
Hubstats::GithubAPI.client.remove_hook(repo.full_name, hook[:id])
|
120
|
+
puts "successfully deleted hook with id #{hook[:id]} and url #{hook[:config][:url]} from #{repo.full_name}"
|
75
121
|
end
|
76
|
-
|
77
|
-
Hubstats::GithubAPI.wait_limit(grab_size,client.rate_limit)
|
78
122
|
end
|
79
|
-
|
80
|
-
|
81
|
-
puts "Connection Timeout, restarting pull request updating"
|
82
|
-
update_pulls
|
123
|
+
rescue Octokit::NotFound
|
124
|
+
puts "You don't have sufficient privledges to remove an event hook to #{repo.full_name}"
|
83
125
|
end
|
84
126
|
end
|
85
127
|
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
Hubstats::Label.all.each do |label|
|
96
|
-
inline(repo.full_name,'issues', labels: label.name, state: 'closed')
|
97
|
-
inline(repo.full_name,'issues', labels: label.name, state: 'open')
|
98
|
-
end
|
99
|
-
end
|
128
|
+
# Public: updates a hook if it exists, otherwise creates one
|
129
|
+
#
|
130
|
+
# repo - a repo github object
|
131
|
+
# old_endpoint - A string of the previous endpoint
|
132
|
+
#
|
133
|
+
# Returns - the new hook
|
134
|
+
def self.update_hook(repo, old_endpoint = nil)
|
135
|
+
delete_hook(repo, old_endpoint) unless old_endpoint == nil
|
136
|
+
create_hook(repo)
|
100
137
|
end
|
101
138
|
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
139
|
+
# Public: gets labels for a particular label
|
140
|
+
#
|
141
|
+
# repo - a repo github object
|
142
|
+
#
|
143
|
+
# Returns - all the labels for a given repo
|
144
|
+
def self.get_labels(repo)
|
145
|
+
labels = []
|
146
|
+
octo = Hubstats::GithubAPI.client({:auto_paginate => true})
|
147
|
+
github_labels = octo.labels(repo.full_name)
|
148
|
+
github_labels.each do |label|
|
149
|
+
label_hash = label.to_h if label.respond_to? :to_h
|
150
|
+
label_data = label_hash.slice(*Hubstats::Label.column_names.map(&:to_sym))
|
151
|
+
labels << Hubstats::Label.where(:name => label_data[:name]).first_or_create(label_data)
|
111
152
|
end
|
153
|
+
labels
|
112
154
|
end
|
113
155
|
|
114
|
-
|
115
|
-
|
156
|
+
# Public: gets the label for a given pull request
|
157
|
+
#
|
158
|
+
# repo_name - a the repo_name
|
159
|
+
# pull_request_number - the number of the pull_request you want labels of
|
160
|
+
#
|
161
|
+
# Returns - the issue
|
162
|
+
def self.get_labels_for_pull(repo_name, pull_request_number)
|
163
|
+
issue = client.issue(repo_name, pull_request_number)
|
116
164
|
issue[:labels]
|
117
165
|
end
|
118
166
|
|
167
|
+
# Public: Gets all the labels for a repo, adds all labels to a pull
|
168
|
+
#
|
169
|
+
# repo - the particular repository, you want to add labels to
|
170
|
+
def self.add_labels(repo)
|
171
|
+
get_labels(repo).each do |label|
|
172
|
+
inline(repo.full_name,'issues', labels: label.name, state: 'all')
|
173
|
+
end
|
174
|
+
end
|
119
175
|
|
120
176
|
def self.wait_limit(grab_size,rate_limit)
|
121
177
|
if rate_limit.remaining < grab_size
|
data/lib/hubstats/version.rb
CHANGED
@@ -7,7 +7,7 @@ namespace :hubstats do
|
|
7
7
|
puts "Running rake db:migrate"
|
8
8
|
Rake::Task['db:migrate'].invoke
|
9
9
|
puts "Pulling data from Github. This may take a while..."
|
10
|
-
Rake::Task['hubstats:populate:
|
10
|
+
Rake::Task['hubstats:populate:setup_repos'].invoke
|
11
11
|
end
|
12
12
|
|
13
13
|
desc "Drops the database, then runs rake hubstats:setup"
|
@@ -17,4 +17,10 @@ namespace :hubstats do
|
|
17
17
|
Rake::Task['hubstats:setup'].invoke
|
18
18
|
end
|
19
19
|
|
20
|
+
desc "Updates changes to the config file"
|
21
|
+
task :update => :environment do
|
22
|
+
puts "Updating repos"
|
23
|
+
Rake::Task['hubstats:populate:update_repos'].invoke
|
24
|
+
end
|
25
|
+
|
20
26
|
end
|
@@ -1,6 +1,37 @@
|
|
1
1
|
namespace :hubstats do
|
2
2
|
namespace :populate do
|
3
3
|
|
4
|
+
desc "Pull repos from Github save to database"
|
5
|
+
task :setup_repos => :environment do
|
6
|
+
Hubstats::GithubAPI.get_repos.each do |repo|
|
7
|
+
Rake::Task["hubstats:populate:setup_repo"].execute({repo: repo})
|
8
|
+
end
|
9
|
+
puts "Finished with initial population, grabing extra info about pull requests"
|
10
|
+
Rake::Task["hubstats:populate:update_pulls"].execute
|
11
|
+
end
|
12
|
+
|
13
|
+
desc "Updates which repos hubstats tracks"
|
14
|
+
task :update_repos => :environment do
|
15
|
+
Hubstats::GithubAPI.get_repos.each do |repo|
|
16
|
+
unless Hubstats::Repo.where(full_name: repo.full_name).first
|
17
|
+
Rake::Task["hubstats:populate:setup_repo"].execute({repo: repo})
|
18
|
+
end
|
19
|
+
end
|
20
|
+
puts "Finished with initial updating, grabing extra info about pull requests"
|
21
|
+
Rake::Task["hubstats:populate:update_pulls"].execute
|
22
|
+
end
|
23
|
+
|
24
|
+
desc "Pulls in all information for an indivdual repo"
|
25
|
+
task :setup_repo, [:repo] => :environment do |t, args|
|
26
|
+
repo = args[:repo]
|
27
|
+
Hubstats::Repo.create_or_update(repo)
|
28
|
+
Hubstats::GithubAPI.create_hook(repo)
|
29
|
+
Rake::Task["hubstats:populate:users"].execute({repo: repo})
|
30
|
+
Rake::Task["hubstats:populate:pulls"].execute({repo: repo})
|
31
|
+
Rake::Task["hubstats:populate:comments"].execute({repo: repo})
|
32
|
+
Rake::Task["hubstats:populate:labels"].execute({repo: repo})
|
33
|
+
end
|
34
|
+
|
4
35
|
desc "Pull members from Github saves in database"
|
5
36
|
task :users, [:repo] => :environment do |t, args|
|
6
37
|
repo = repo_checker(args[:repo])
|
@@ -32,31 +63,8 @@ namespace :hubstats do
|
|
32
63
|
desc "Pull labels from Github saves in database"
|
33
64
|
task :labels, [:repo] => :environment do |t, args|
|
34
65
|
repo = repo_checker(args[:repo])
|
35
|
-
puts "
|
36
|
-
|
37
|
-
Hubstats::GithubAPI.client({:auto_paginate => true}).labels(repo.full_name).each do |label|
|
38
|
-
|
39
|
-
label_hash = label.to_h if label.respond_to? :to_h
|
40
|
-
label_data = label_hash.slice(*Hubstats::Label.column_names.map(&:to_sym))
|
41
|
-
label = Hubstats::Label.where(:name => label_data[:name]).first_or_create(label_data)
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
desc "Pull repos from Github save to database"
|
46
|
-
task :all => :environment do
|
47
|
-
|
48
|
-
get_repos.each do |repo|
|
49
|
-
repo = Hubstats::Repo.create_or_update(repo)
|
50
|
-
Hubstats::GithubAPI.create_hook(repo)
|
51
|
-
|
52
|
-
Rake::Task["hubstats:populate:users"].execute({repo: repo})
|
53
|
-
Rake::Task["hubstats:populate:pulls"].execute({repo: repo})
|
54
|
-
Rake::Task["hubstats:populate:comments"].execute({repo: repo})
|
55
|
-
end
|
56
|
-
|
57
|
-
puts "Finished with initial population, grabing extra info for pull requests"
|
58
|
-
Rake::Task["hubstats:populate:update_labels"].execute
|
59
|
-
Rake::Task["hubstats:populate:update_pulls"].execute
|
66
|
+
puts "Getting labels for " + repo.full_name
|
67
|
+
Hubstats::GithubAPI.add_labels(repo)
|
60
68
|
end
|
61
69
|
|
62
70
|
desc "indivdually gets and updates pull requests"
|
@@ -64,14 +72,18 @@ namespace :hubstats do
|
|
64
72
|
Hubstats::GithubAPI.update_pulls
|
65
73
|
end
|
66
74
|
|
67
|
-
desc "
|
75
|
+
desc "Updates labels for all repos"
|
68
76
|
task :update_labels => :environment do
|
69
|
-
Hubstats::
|
77
|
+
Hubstats::Repo.all.each do |repo|
|
78
|
+
Hubstats::GithubAPI.add_labels(repo)
|
79
|
+
end
|
70
80
|
end
|
71
81
|
|
72
|
-
desc "
|
73
|
-
task :
|
74
|
-
Hubstats::
|
82
|
+
desc "Updates WebHooks for all repos"
|
83
|
+
task :update_hooks, [:old_endpoint] => :environment do |t, args|
|
84
|
+
Hubstats::Repo.all.each do |repo|
|
85
|
+
Hubstats::GithubAPI.update_hook(repo, args[:old_endpoint])
|
86
|
+
end
|
75
87
|
end
|
76
88
|
|
77
89
|
def repo_checker(args)
|
@@ -83,17 +95,5 @@ namespace :hubstats do
|
|
83
95
|
end
|
84
96
|
end
|
85
97
|
|
86
|
-
def get_repos
|
87
|
-
client = Hubstats::GithubAPI.client
|
88
|
-
if Hubstats.config.github_config.has_key?("org_name")
|
89
|
-
repos = client.organization_repositories(Hubstats.config.github_config["org_name"])
|
90
|
-
else
|
91
|
-
repos = []
|
92
|
-
Hubstats.config.github_config["repo_list"].each do |repo|
|
93
|
-
repos << client.repository(repo)
|
94
|
-
end
|
95
|
-
end
|
96
|
-
repos
|
97
|
-
end
|
98
98
|
end
|
99
99
|
end
|
@@ -7,19 +7,18 @@ module Hubstats
|
|
7
7
|
let(:repo) {build(:repo)}
|
8
8
|
let(:payload) {build(:pull_request_payload_hash)}
|
9
9
|
|
10
|
+
subject {Hubstats::EventsHandler.new()}
|
10
11
|
it 'successfully routes the event' do
|
11
|
-
|
12
|
-
|
13
|
-
ehandler.route(payload,payload[:type])
|
12
|
+
expect(subject).to receive(:pull_processor)
|
13
|
+
subject.route(payload,payload[:type])
|
14
14
|
end
|
15
15
|
|
16
16
|
it 'adds labels to pull request' do
|
17
|
-
ehandler = Hubstats::EventsHandler.new()
|
18
17
|
allow(Hubstats::PullRequest).to receive(:create_or_update) {pull}
|
19
18
|
allow(Hubstats::Repo).to receive(:where) {[repo,repo]}
|
20
|
-
allow(Hubstats::GithubAPI).to receive(:
|
19
|
+
allow(Hubstats::GithubAPI).to receive(:get_labels_for_pull) {['low','high']}
|
21
20
|
expect(pull).to receive(:add_labels).with(['low','high'])
|
22
|
-
|
21
|
+
subject.route(payload,payload[:type])
|
23
22
|
end
|
24
23
|
end
|
25
24
|
|
@@ -66,11 +66,47 @@ module Hubstats
|
|
66
66
|
end
|
67
67
|
end
|
68
68
|
|
69
|
-
|
69
|
+
context ".update_hook" do
|
70
|
+
subject {Hubstats::GithubAPI}
|
71
|
+
let(:repo) {'hubstats'}
|
72
|
+
context "with old_endpoint" do
|
73
|
+
let(:old_endpoint) {'www.hubstats.com'}
|
74
|
+
it 'calls delete_hook' do
|
75
|
+
allow(subject).to receive(:create_hook)
|
76
|
+
expect(subject).to receive(:delete_hook).with(repo,old_endpoint)
|
77
|
+
subject.update_hook('hubstats','www.hubstats.com')
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
context "without old_point" do
|
82
|
+
it 'does not call delete_hook' do
|
83
|
+
allow(subject).to receive(:create_hook)
|
84
|
+
expect(subject).to_not receive(:delete_hook).with(repo)
|
85
|
+
subject.update_hook('hubstats')
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
context ".create_hook" do
|
91
|
+
subject {Hubstats::GithubAPI}
|
92
|
+
let(:config) {double(:webhook_secret => 'a1b2c3d4', :webhook_endpoint => "hubstats.com")}
|
93
|
+
let(:client) {double}
|
94
|
+
let(:repo) {double(:full_name =>'hubstats') }
|
95
|
+
before do
|
96
|
+
allow(Hubstats).to receive(:config) {config}
|
97
|
+
allow(subject).to receive(:client) {client}
|
98
|
+
end
|
99
|
+
|
100
|
+
it "calls octokit create_hook" do
|
101
|
+
expect(client).to receive(:create_hook)
|
102
|
+
subject.create_hook(repo)
|
103
|
+
end
|
104
|
+
|
105
|
+
it "rescues unprocessable entity" do
|
106
|
+
allow(client).to receive(:create_hook) { raise Octokit::UnprocessableEntity }
|
107
|
+
subject.create_hook(repo)
|
108
|
+
end
|
109
|
+
end
|
70
110
|
|
71
|
-
# it 'catches error and continues'
|
72
|
-
# Hubstats::GithubAPI.update_pulls
|
73
|
-
# end
|
74
|
-
# end
|
75
111
|
end
|
76
112
|
end
|
metadata
CHANGED
@@ -1,125 +1,125 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hubstats
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Elliot Hursh
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-10-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ~>
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: 3.2.18
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ~>
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 3.2.18
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: octokit
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ~>
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '3.2'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ~>
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '3.2'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: will_paginate-bootstrap
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ! '>='
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ! '>='
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: select2-rails
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - '='
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
61
|
+
version: 3.5.9
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - '='
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
68
|
+
version: 3.5.9
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rspec-rails
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- -
|
73
|
+
- - ~>
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: 3.0.0.beta
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- -
|
80
|
+
- - ~>
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: 3.0.0.beta
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: shoulda-matchers
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- -
|
87
|
+
- - ~>
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: '2.6'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- -
|
94
|
+
- - ~>
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '2.6'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: factory_girl_rails
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- -
|
101
|
+
- - ~>
|
102
102
|
- !ruby/object:Gem::Version
|
103
103
|
version: '4.4'
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- -
|
108
|
+
- - ~>
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '4.4'
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: faker
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
|
-
- -
|
115
|
+
- - ~>
|
116
116
|
- !ruby/object:Gem::Version
|
117
117
|
version: '1.3'
|
118
118
|
type: :development
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
|
-
- -
|
122
|
+
- - ~>
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '1.3'
|
125
125
|
description: Github Statistics
|
@@ -129,10 +129,10 @@ executables: []
|
|
129
129
|
extensions: []
|
130
130
|
extra_rdoc_files: []
|
131
131
|
files:
|
132
|
-
-
|
133
|
-
-
|
134
|
-
-
|
135
|
-
-
|
132
|
+
- .automation.yml
|
133
|
+
- .gitignore
|
134
|
+
- .rspec
|
135
|
+
- .travis.yml
|
136
136
|
- Gemfile
|
137
137
|
- MIT-LICENSE
|
138
138
|
- README.rdoc
|
@@ -282,12 +282,12 @@ require_paths:
|
|
282
282
|
- lib
|
283
283
|
required_ruby_version: !ruby/object:Gem::Requirement
|
284
284
|
requirements:
|
285
|
-
- -
|
285
|
+
- - ! '>='
|
286
286
|
- !ruby/object:Gem::Version
|
287
287
|
version: '0'
|
288
288
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
289
289
|
requirements:
|
290
|
-
- -
|
290
|
+
- - ! '>='
|
291
291
|
- !ruby/object:Gem::Version
|
292
292
|
version: '0'
|
293
293
|
requirements: []
|