summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/shogun.rb5
-rw-r--r--lib/shogun/github_score.rb21
2 files changed, 9 insertions, 17 deletions
diff --git a/lib/shogun.rb b/lib/shogun.rb
index 818e0a5..05b1a6a 100644
--- a/lib/shogun.rb
+++ b/lib/shogun.rb
@@ -3,3 +3,8 @@ require "uri"
require "json"
require "shogun/github_score"
+
+module Shogun
+ class UserNotFound < ArgumentError
+ end
+end
diff --git a/lib/shogun/github_score.rb b/lib/shogun/github_score.rb
index 48947a0..22019ec 100644
--- a/lib/shogun/github_score.rb
+++ b/lib/shogun/github_score.rb
@@ -1,8 +1,5 @@
module Shogun
- class UserNotFound < ArgumentError
- end
-
- class GithubScore
+ class GitHubScore
DEFAULT_POINTS = {
"IssuesEvent" => 1,
"IssueCommentEvent" => 2,
@@ -18,7 +15,9 @@ module Shogun
end
def score
- calculate_score_for(events)
+ events.sum do |event|
+ points.fetch(event["type"], 1)
+ end
end
private
@@ -35,17 +34,5 @@ module Shogun
JSON.parse(response.body)
end
-
- def calculate_score_for(events)
- grouped = events.group_by { |h| h["type"] }.values
- score = grouped.map { |g|
- event_type = g.first["type"].strip
- event_score = points[event_type] || 1
- event_score * g.count
- }.sum
- score
- end
end
-
-
end