githubstats 3.2.0 → 4.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: aa26d02c85e58b01ee8553a90a628aed98fa010b89142b056187d28467eb710a
4
- data.tar.gz: b6671f2fa390ad49016cee0bc816a28d7063f7d2fc48a8b60aff5a6c4ebccdc0
3
+ metadata.gz: 85efd3ef7382a78839410709a66d068aa9d13de94b3da28994c8afd42dfb03c1
4
+ data.tar.gz: a7bbcb3ded14ef503a048724a452917b119150146c07fb5885798d69f2212a61
5
5
  SHA512:
6
- metadata.gz: 4de055321d31ac225c4b519866a6a475268e20117daa8ba5f93164bfb00531d79722efadfe9bb655d81dc1cda91bb20d809f3d8c61657e1290b94e53f7c33f06
7
- data.tar.gz: 7dd16f5fcb857c6f312123969f469080247886463d708fb270770bd169b35e1f192ae26e1dbc5b879d91a4c843bccabd7be72521b1f08b27f727e5c45647683f
6
+ metadata.gz: 10e07635dbe3eeccc3773de65c0400fc907fd28f9bf5c802bbb07b67c2cef5316009705711409f051c760286d40b08691bf3f9431f15922735606037a599ea12
7
+ data.tar.gz: 2b57b802d0ef16fecb194e4a25ad181cb98eed71b9f46b5a958a1c8f3014b496afd2a7d9cd16b9994763a663104b519443996aa6cc186630dc6d23108f768f6c
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env bash
2
+
3
+ set -euo pipefail
4
+
5
+ URL="https://exporter.akerl.app/metric"
6
+ AUTH="Authorization: Bearer $EXPORTER_TOKEN"
7
+ if [[ "$JOB_STATUS" == "success" ]] ; then
8
+ VALUE=1
9
+ else
10
+ VALUE=0
11
+ fi
12
+ BODY="{\"name\":\"gh/${GITHUB_REPOSITORY}\",\"metrics\":[{\"name\":\"ghactions\",\"type\":\"gauge\",\"tags\":{\"repo\":\"${GITHUB_REPOSITORY}\"},\"value\":\"${VALUE}\"}]}"
13
+
14
+ echo "$BODY"
15
+
16
+ curl -i -XPOST -d "$BODY" -H"$AUTH" "$URL"
@@ -0,0 +1,37 @@
1
+ ---
2
+ name: Build
3
+ 'on':
4
+ push:
5
+ branches:
6
+ - main
7
+ tags:
8
+ - "**"
9
+ pull_request_target:
10
+ jobs:
11
+ build:
12
+ name: Build
13
+ runs-on: ubuntu-22.04
14
+ permissions:
15
+ contents: write
16
+ steps:
17
+ - name: Checkout
18
+ uses: actions/checkout@v3
19
+ with:
20
+ submodules: recursive
21
+ - uses: ruby/setup-ruby@v1
22
+ with:
23
+ ruby-version: '3.1'
24
+ bundler-cache: true
25
+ - name: Build
26
+ run: bundle exec rake
27
+ - name: Release
28
+ if: github.ref_type == 'tag'
29
+ run: bundle exec rake release
30
+ env:
31
+ GEM_HOST_API_KEY: "${{ secrets.GEM_HOST_API_KEY }}"
32
+ - name: Post to hook-exporter
33
+ run: "./.github/exporter.sh"
34
+ env:
35
+ EXPORTER_TOKEN: "${{ secrets.EXPORTER_TOKEN }}"
36
+ JOB_STATUS: "${{ job.status }}"
37
+ if: always() && github.ref == 'refs/heads/main'
data/.rubocop.yml CHANGED
@@ -1,5 +1,2 @@
1
1
  inherit_gem:
2
2
  goodcop: .rubocop.yml
3
- Metrics/BlockLength:
4
- Exclude:
5
- - 'spec/**/*'
data/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ # 4.0.0 / 2023-07-18
2
+
3
+ * [FEATURE] Support updated table element now in use on github.com. Thanks @shih91!
4
+
5
+ # 3.3.0 / 2023-01-08
6
+
7
+ * [BUGFIX] Update to handle changes to GitHub contribution chart SVG naming
8
+
1
9
  # 3.2.0 / 2021-02-06
2
10
 
3
11
  * [BUGFIX] Update to handle GitHub changes to contribution data CSS
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2014 Les Aker
3
+ Copyright (c) 2023 Les Aker
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -2,8 +2,7 @@ GithubStats
2
2
  =========
3
3
 
4
4
  [![Gem Version](https://img.shields.io/gem/v/githubstats.svg)](https://rubygems.org/gems/githubstats)
5
- [![Build Status](https://img.shields.io/travis/com/akerl/githubstats.svg)](https://travis-ci.com/akerl/githubstats)
6
- [![Coverage Status](https://img.shields.io/codecov/c/github/akerl/githubstats.svg)](https://codecov.io/github/akerl/githubstats)
5
+ [![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/akerl/githubstats/build.yml?branch=main)](https://github.com/akerl/githubstats/actions)
7
6
  [![MIT Licensed](https://img.shields.io/badge/license-MIT-green.svg)](https://tldrlegal.com/license/mit-license)
8
7
 
9
8
  Grabs Github contribution statistics and presents it in an easily consumable format.
data/githubstats.gemspec CHANGED
@@ -5,8 +5,7 @@ require 'githubstats/version'
5
5
  Gem::Specification.new do |s|
6
6
  s.name = 'githubstats'
7
7
  s.version = GithubStats::VERSION
8
- s.date = Time.now.strftime('%Y-%m-%d')
9
- s.required_ruby_version = '>= 2.5.0'
8
+ s.required_ruby_version = '>= 2.6.0'
10
9
 
11
10
  s.summary = 'Present Github contributions stats in a consumable format'
12
11
  s.description = 'Pulls the statistics from Github\'s user contribution chart and provides an interface for analyzing that data' # rubocop:disable Layout/LineLength
@@ -16,16 +15,12 @@ Gem::Specification.new do |s|
16
15
  s.license = 'MIT'
17
16
 
18
17
  s.files = `git ls-files`.split
19
- s.test_files = `git ls-files spec/*`.split
20
18
  s.executables = ['githubstats']
21
19
 
22
20
  s.add_runtime_dependency 'basiccache', '~> 1.0.0'
23
- s.add_runtime_dependency 'nokogiri', '~> 1.10.8'
21
+ s.add_runtime_dependency 'nokogiri', '~> 1.15.3'
24
22
 
25
- s.add_development_dependency 'codecov', '~> 0.1.1'
26
- s.add_development_dependency 'fuubar', '~> 2.5.0'
27
- s.add_development_dependency 'goodcop', '~> 0.9.3'
28
- s.add_development_dependency 'rake', '~> 13.0.0'
29
- s.add_development_dependency 'rspec', '~> 3.9.0'
30
- s.add_development_dependency 'timecop', '~> 0.9.0'
23
+ s.add_development_dependency 'goodcop', '~> 0.9.7'
24
+ s.add_development_dependency 'timecop', '~> 0.9.6'
25
+ s.metadata['rubygems_mfa_required'] = 'true'
31
26
  end
@@ -128,7 +128,7 @@ module GithubStats
128
128
 
129
129
  def std_var
130
130
  first_pass = @raw.reduce(0) do |acc, elem|
131
- (elem.score.to_f - mean)**2 + acc
131
+ ((elem.score.to_f - mean)**2) + acc
132
132
  end
133
133
  Math.sqrt(first_pass / (@raw.size - 1))
134
134
  end
@@ -159,11 +159,11 @@ module GithubStats
159
159
  range = (1..top).to_a
160
160
  range = [0] * 3 if range.empty?
161
161
  mids = (1..3).map do |q|
162
- index = q * range.size / 4 - 1
162
+ index = (q * range.size / 4) - 1
163
163
  range[index]
164
164
  end
165
165
  bounds = (mids + [max.score]).uniq.sort
166
- [0] * (5 - bounds.size) + bounds
166
+ ([0] * (5 - bounds.size)) + bounds
167
167
  end
168
168
 
169
169
  ##
@@ -195,7 +195,7 @@ module GithubStats
195
195
  private
196
196
 
197
197
  def _pad(data, index, fill_value, goal)
198
- mod = index * -2 - 1 # 0 index moves -1 in time, -1 move +1 in time
198
+ mod = (index * -2) - 1 # 0 index moves -1 in time, -1 move +1 in time
199
199
  point = GithubStats::Datapoint
200
200
  data.insert index, point.new(data[index].date + mod, fill_value) until data[index].date.wday == goal
201
201
  data
@@ -3,5 +3,5 @@
3
3
  ##
4
4
  # Define the version
5
5
  module GithubStats
6
- VERSION = '3.2.0'
6
+ VERSION = '4.0.0'
7
7
  end
data/lib/githubstats.rb CHANGED
@@ -108,7 +108,7 @@ module GithubStats
108
108
 
109
109
  def guess_user(names = [])
110
110
  names << Rugged::Config.global['github.user'] if USE_RUGGED
111
- names << ENV['USER']
111
+ names << ENV.fetch('USER', nil)
112
112
  names.find { |name| name } || (raise 'Failed to guess username')
113
113
  end
114
114
 
@@ -143,9 +143,9 @@ module GithubStats
143
143
  def download(to_date = nil)
144
144
  resp = request(to_date)
145
145
  html = Nokogiri::HTML(resp)
146
- svg = html.at_css('svg.js-calendar-graph-svg')
146
+ svg = html.css('table.ContributionCalendar-grid td[data-date]')
147
147
  svg.css('.ContributionCalendar-day').map do |x|
148
- x.attributes.values_at('data-date', 'data-count').map(&:value)
148
+ x.attributes.values_at('data-date', 'data-level').map(&:value)
149
149
  end
150
150
  end
151
151
 
data/spec/spec_helper.rb CHANGED
@@ -1,11 +1,2 @@
1
- if ENV['CI'] == 'true'
2
- require 'simplecov'
3
- require 'codecov'
4
- SimpleCov.formatter = SimpleCov::Formatter::Codecov
5
- SimpleCov.start do
6
- add_filter '/spec/'
7
- end
8
- end
9
-
10
1
  require 'rspec'
11
2
  require 'githubstats'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: githubstats
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.0
4
+ version: 4.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Les Aker
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-02-06 00:00:00.000000000 Z
11
+ date: 2023-07-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: basiccache
@@ -30,98 +30,42 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 1.10.8
33
+ version: 1.15.3
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
- version: 1.10.8
41
- - !ruby/object:Gem::Dependency
42
- name: codecov
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - "~>"
46
- - !ruby/object:Gem::Version
47
- version: 0.1.1
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - "~>"
53
- - !ruby/object:Gem::Version
54
- version: 0.1.1
55
- - !ruby/object:Gem::Dependency
56
- name: fuubar
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - "~>"
60
- - !ruby/object:Gem::Version
61
- version: 2.5.0
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - "~>"
67
- - !ruby/object:Gem::Version
68
- version: 2.5.0
40
+ version: 1.15.3
69
41
  - !ruby/object:Gem::Dependency
70
42
  name: goodcop
71
43
  requirement: !ruby/object:Gem::Requirement
72
44
  requirements:
73
45
  - - "~>"
74
46
  - !ruby/object:Gem::Version
75
- version: 0.9.3
47
+ version: 0.9.7
76
48
  type: :development
77
49
  prerelease: false
78
50
  version_requirements: !ruby/object:Gem::Requirement
79
51
  requirements:
80
52
  - - "~>"
81
53
  - !ruby/object:Gem::Version
82
- version: 0.9.3
83
- - !ruby/object:Gem::Dependency
84
- name: rake
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - "~>"
88
- - !ruby/object:Gem::Version
89
- version: 13.0.0
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - "~>"
95
- - !ruby/object:Gem::Version
96
- version: 13.0.0
97
- - !ruby/object:Gem::Dependency
98
- name: rspec
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - "~>"
102
- - !ruby/object:Gem::Version
103
- version: 3.9.0
104
- type: :development
105
- prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - "~>"
109
- - !ruby/object:Gem::Version
110
- version: 3.9.0
54
+ version: 0.9.7
111
55
  - !ruby/object:Gem::Dependency
112
56
  name: timecop
113
57
  requirement: !ruby/object:Gem::Requirement
114
58
  requirements:
115
59
  - - "~>"
116
60
  - !ruby/object:Gem::Version
117
- version: 0.9.0
61
+ version: 0.9.6
118
62
  type: :development
119
63
  prerelease: false
120
64
  version_requirements: !ruby/object:Gem::Requirement
121
65
  requirements:
122
66
  - - "~>"
123
67
  - !ruby/object:Gem::Version
124
- version: 0.9.0
68
+ version: 0.9.6
125
69
  description: Pulls the statistics from Github's user contribution chart and provides
126
70
  an interface for analyzing that data
127
71
  email: me@lesaker.org
@@ -131,11 +75,11 @@ extensions: []
131
75
  extra_rdoc_files: []
132
76
  files:
133
77
  - ".circle-ruby"
78
+ - ".github/exporter.sh"
79
+ - ".github/workflows/build.yml"
134
80
  - ".gitignore"
135
- - ".prospectus"
136
81
  - ".rspec"
137
82
  - ".rubocop.yml"
138
- - ".travis.yml"
139
83
  - CHANGELOG.md
140
84
  - Gemfile
141
85
  - LICENSE
@@ -160,8 +104,9 @@ files:
160
104
  homepage: https://github.com/akerl/githubstats
161
105
  licenses:
162
106
  - MIT
163
- metadata: {}
164
- post_install_message:
107
+ metadata:
108
+ rubygems_mfa_required: 'true'
109
+ post_install_message:
165
110
  rdoc_options: []
166
111
  require_paths:
167
112
  - lib
@@ -169,26 +114,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
169
114
  requirements:
170
115
  - - ">="
171
116
  - !ruby/object:Gem::Version
172
- version: 2.5.0
117
+ version: 2.6.0
173
118
  required_rubygems_version: !ruby/object:Gem::Requirement
174
119
  requirements:
175
120
  - - ">="
176
121
  - !ruby/object:Gem::Version
177
122
  version: '0'
178
123
  requirements: []
179
- rubygems_version: 3.1.2
180
- signing_key:
124
+ rubygems_version: 3.3.26
125
+ signing_key:
181
126
  specification_version: 4
182
127
  summary: Present Github contributions stats in a consumable format
183
- test_files:
184
- - spec/examples/akerl.user
185
- - spec/examples/fly.user
186
- - spec/examples/laker.user
187
- - spec/examples/leematos.user
188
- - spec/examples/lmatos.user
189
- - spec/examples/mikegrb.user
190
- - spec/examples/results
191
- - spec/examples/torvalds.user
192
- - spec/githubstats/data_spec.rb
193
- - spec/githubstats_spec.rb
194
- - spec/spec_helper.rb
128
+ test_files: []
data/.prospectus DELETED
@@ -1,11 +0,0 @@
1
- my_slug = 'akerl/githubstats'
2
-
3
- Prospectus.extra_dep('file', 'prospectus_travis')
4
- Prospectus.extra_dep('file', 'prospectus_gems')
5
-
6
- item do
7
- noop
8
-
9
- extend ProspectusGems::Gemspec.new
10
- extend ProspectusTravis::Build.new(my_slug)
11
- end
data/.travis.yml DELETED
@@ -1,10 +0,0 @@
1
- dist: xenial
2
- install:
3
- - for i in $(cat .circle-ruby) ; do rvm install $i || exit 1 ; done
4
- - for i in $(cat .circle-ruby) ; do rvm-exec $i bundle install || exit 1 ; done
5
- script:
6
- - for i in $(cat .circle-ruby) ; do rvm-exec $i bundle exec rake || exit 1 ; done
7
- notifications:
8
- email: false
9
- slack:
10
- secure: PQOCIfuacnmF9MMGmZseYwGn8HfxmL1m7qqftoWhDkkp8oKLKVaSfoMPGAADWQsWLBl4JQC+z/lRH8I2gXChQjZhKZBz15bFH6mwFBI82DXidVNVxt27g/uR3RMT8GfGw8CkgW8DsSpNF+E4pBPOKONFLhj9Y0xdpAID7slrPwd6wDdpi4oDXvnfTO4ZfUZbB3OGT0nnzcH4gCiKXKijv4MRzHTVpvbwe+P3TOKkTY0V21B++YSBpX1tIYt6cLOHaDFQT4DScwFajtvynpwWf3PCRMCATganpyEqEpkiUp+dSg1h2WjYilAwVHkLnNaESUFKeTLQGIXpKMj4+3yHlIPPG6M2MawgwhSDuYy1IAE/81+Y06V9Sn9PPnICsjV1+W0LxnCms13t1JcVWrzVOtlzyCInKr8ENAX6Ku6SSQaouuqYghm1maG8ZtNhqyByqGctov7noLUH6T+lHS8ODr22cLg6f0lzVn5d13/aha9OvTZV7DN6uVCfwpbAL9S+u1TNtjrDhJQFohSe7X+jb+KxN7sLZR5Z5RKwM8sx6Tadf3rrvVRF5+jQxpb2IgjakV2QgxmVDrZDu3XXWbRUYMlGbmR4EEwDaKPJsjKh8KIu6GS6rhrQHiwvwDH6FQcXdeQsieLaVTBoKnE1slYvRMVTMZxFkAbI2dIt+H06c7c=