github_activity 0.0.0
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 +7 -0
- data/lib/github_activity.rb +38 -0
- metadata +43 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: ac8c54052745baec874d68ed28c4bb3212473305490971d100322715133a95c3
|
4
|
+
data.tar.gz: 85d2f3e51d83d8ffabbc44d8e75c1cf8db0953a8fb6922889b1f47163d6d7f3e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2a2941857dfbda817a219dc1480d0695e692fcbfc83002fc155bf9535c4ad707f452c8d90bb900e61262a29a00ad6181dd64eb34787cb00089744c2cf6e188bb
|
7
|
+
data.tar.gz: ba61f76209b6dcf782a48b2610f47840c679d4fa46a54e528e00fd95250abf65c25a031efc6d990f1d60f9166eea31eb9f64147874d2c10b0d1a5078fb7ba562
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'rest-client'
|
2
|
+
require 'date'
|
3
|
+
require 'json'
|
4
|
+
|
5
|
+
class GithubActivity
|
6
|
+
attr_reader :response, :date, :json
|
7
|
+
|
8
|
+
def initialize(username, date = Date.today)
|
9
|
+
@username = username
|
10
|
+
@date = date
|
11
|
+
@json = RestClient.get("https://github-contributions-api.herokuapp.com/#{@username}/count")
|
12
|
+
@response = JSON.parse(@json)
|
13
|
+
end
|
14
|
+
|
15
|
+
def today
|
16
|
+
response['data'][date.year.to_s][date.month.to_s][date.day.to_s]
|
17
|
+
end
|
18
|
+
|
19
|
+
def last_week
|
20
|
+
get_activity(6)
|
21
|
+
end
|
22
|
+
|
23
|
+
def last_month
|
24
|
+
end
|
25
|
+
|
26
|
+
|
27
|
+
private
|
28
|
+
def get_activity(num_days)
|
29
|
+
((date - num_days)..date).to_a.sum do |prev_date|
|
30
|
+
get_score(prev_date)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def get_score(prev_date)
|
35
|
+
num = response['data'][prev_date.year.to_s][prev_date.month.to_s][prev_date.day.to_s]
|
36
|
+
num.nil? ? 0 : num
|
37
|
+
end
|
38
|
+
end
|
metadata
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: github_activity
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Douglas Berkley
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-08-24 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: A way to retrieve recent Github activity about a user
|
14
|
+
email: douglasmberkley@gmail.com
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- lib/github_activity.rb
|
20
|
+
homepage: https://rubygems.org/gems/github_activity
|
21
|
+
licenses:
|
22
|
+
- MIT
|
23
|
+
metadata: {}
|
24
|
+
post_install_message:
|
25
|
+
rdoc_options: []
|
26
|
+
require_paths:
|
27
|
+
- lib
|
28
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
34
|
+
requirements:
|
35
|
+
- - ">="
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
requirements: []
|
39
|
+
rubygems_version: 3.0.3
|
40
|
+
signing_key:
|
41
|
+
specification_version: 4
|
42
|
+
summary: Github Activity
|
43
|
+
test_files: []
|