githubchart 2.0.0 → 3.2.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
- SHA1:
3
- metadata.gz: 10dfa80d371c52dba32328690e164a7a9a08d9dc
4
- data.tar.gz: 57831c4b0694a31f41e8ad24fc58d2519885465f
2
+ SHA256:
3
+ metadata.gz: 88d4922b81a68658c9b38c254ad21a82520630de5283813869f9b2d319c603a7
4
+ data.tar.gz: bf982b0ac1fd5e1de52d25a25824a695e6575f2eff81843d3b55a15d8d6d867e
5
5
  SHA512:
6
- metadata.gz: 88d6755bf2df598c47e2369f1cece14616ee7b4e7b12aa7e9ed3f1bf1823ee821b0820312daa92d6f8ac3898af89b4a6b3a61ee913ac6d1875009b30b8fbccfa
7
- data.tar.gz: 9f893ad3059e55ca31497af62926fa0c27e3b03c78d4bd4c97f5da45e7a3fc6a591f29ca92cd784ca5e841219694b612b64770cb7d8e3f9ff2487d56fb43b6d0
6
+ metadata.gz: 712a905e7e1687454e11d60a80ed8f73f29f0f484eb8ae6c04adae3cc0f59a18be363b59a1b61a041ff96d8f1dd34b40f1002accf6aafc07b766ece4c6f707bd
7
+ data.tar.gz: ddfde891aed240185f897d6cecdacca210691540075fd97c86db8c8c33db5403bf30468a836f7de7daf26bfbf606bf7244e02762a507fcd7cdbbdd293bad5b8a
@@ -1,3 +1,4 @@
1
- 2.3.1
2
- 2.2.5
3
- 2.1.10
1
+ 2.6.1
2
+ 2.5.3
3
+ 2.4.5
4
+ 2.3.8
@@ -1,11 +1,11 @@
1
+ my_slug = 'akerl/githubchart'
2
+
3
+ Prospectus.extra_dep('file', 'prospectus_travis')
4
+ Prospectus.extra_dep('file', 'prospectus_gems')
5
+
1
6
  item do
2
- expected do
3
- static
4
- set 'green'
5
- end
7
+ noop
6
8
 
7
- actual do
8
- gemnasium
9
- slug 'akerl/githubchart'
10
- end
9
+ extend ProspectusGems::Gemspec.new
10
+ extend ProspectusTravis::Build.new(my_slug)
11
11
  end
@@ -1,2 +1,2 @@
1
- Encoding:
2
- Enabled: false
1
+ inherit_gem:
2
+ goodcop: .rubocop.yml
@@ -1,17 +1,10 @@
1
- language: ruby
2
- cache: bundler
3
- sudo: false
4
- rvm:
5
- - 2.2.2
6
- - 2.2.1
7
- - 2.2.0
8
- - 2.1.6
9
- - 2.0.0-p598
10
- - 1.9.3-p551
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
11
7
  notifications:
12
8
  email: false
13
- irc:
14
- template:
15
- - "%{repository}/%{branch}/%{build_number}: %{message} -- %{build_url}"
16
- channels:
17
- - irc.oftc.net#akerl
9
+ slack:
10
+ secure: XOIlpE54Yq450PGd3VI7atmVplX+WRmz+karIxlC+PEWgEbE3G9lCuIKez8OvJ+bS357KEsyF9k2ZhmaxJvQXKtMgQn6I7zBmjBRPm9xAb/ynFujquGsjW+OMAiP/3elq8DS6yvVYUDWBDgRv6SxHF/rLKliuSh4S8NrnuTyfokoWx4i/dIBQyujU6kmRW+2DIfkSY1wTyyb7Qo9HFH3ekOeJrYg+bK2Sm5HSLK+ATKpJ8nWvLirK8KIsQbCSj+Hkt61yBC+3pst51EUI5CwlHF1qxLy9T/eezY+bnUD/0WwcJX10co6K62+qykvN/4pKqYubfSsnYVmU3sZgk0FfRfBNOaYwai6mbZxxcFn4kIUOYoGTML/NTe7bu9dbtbHAM751x/V/tFM1V4m6xap451WQoommuMIcOuGS/OgzeOkc12VQ0X5nXM0DA20MOZKlMUJR+XlYu6derwIvOEOPlazZq8Ta4LQNrMaqax5IzJVyNsSqXMsEkpXDVSpvkwdXeBMy6X02ozNQOrcefoGGLhAtrnewyJnchDxhIy/aG2TUYx6qMGi/zxGr+yKyev2Op3Qwg8FAhJ2Nk3Noa+Tm9ZErcfKhVykowGFYdBurD0M+9eouz4LRQP+JOfvUjmdduEZ9H+uzTou3OCr3pCj+6PLltQRT7C7hNz1YCzocUc=
@@ -1,3 +1,31 @@
1
+ # 3.2.0 / 2020-10-06
2
+
3
+ * [ENHANCEMENT] Update GithubStats dep
4
+
5
+ # 3.1.1 / 2020-08-13
6
+
7
+ * [ENHANCEMENT] Update GithubStats dep
8
+
9
+ # 3.1.0 / 2017-10-03
10
+
11
+ * [ENHANCEMENT] GitHub updated their styling; this updated matches that change
12
+
13
+ # 3.0.0 / 2017-09-29
14
+
15
+ * [ENHANCEMENT] Upgrade to latest githubstats with better error messages
16
+
17
+ # 2.1.0 / 2017-08-25
18
+
19
+ * [ENHANCEMENT] Upgrade to latest githubstats
20
+
21
+ # 2.0.1 / 2016-11-08
22
+
23
+ * [BUGFIX] Actually update changelog in release
24
+
25
+ # 2.0.0 / 2016-11-07
26
+
27
+ * [FEATURE] Add support for svg_square as a rendering type, thanks @blerchin
28
+
1
29
  # 1.1.0 / 2016-05-19
2
30
 
3
31
  * [BUGFIX] Upgrade to newer GithubStats that fixes streak parsing
data/README.md CHANGED
@@ -2,10 +2,8 @@ GithubChart
2
2
  ============
3
3
 
4
4
  [![Gem Version](https://img.shields.io/gem/v/githubchart.svg)](https://rubygems.org/gems/githubchart)
5
- [![Dependency Status](https://img.shields.io/gemnasium/akerl/githubchart.svg)](https://gemnasium.com/akerl/githubchart)
6
- [![Build Status](https://img.shields.io/circleci/project/akerl/githubchart/master.svg)](https://circleci.com/gh/akerl/githubchart)
5
+ [![Build Status](https://img.shields.io/travis/com/akerl/githubchart.svg)](https://travis-ci.com/akerl/githubchart)
7
6
  [![Coverage Status](https://img.shields.io/codecov/c/github/akerl/githubchart.svg)](https://codecov.io/github/akerl/githubchart)
8
- [![Code Quality](https://img.shields.io/codacy/e8ee7e2aba4c4a01b93d5c0493bef68b.svg)](https://www.codacy.com/app/akerl/githubchart)
9
7
  [![MIT Licensed](https://img.shields.io/badge/license-MIT-green.svg)](https://tldrlegal.com/license/mit-license)
10
8
 
11
9
  Generates an SVG of your Github contributions:
@@ -21,7 +21,6 @@ OptionParser.new do |opts|
21
21
  if options.include? :user
22
22
  raise 'The --user and --input flags are incompatible with each other.'
23
23
  end
24
-
25
24
  if input.eql? '-'
26
25
  raise 'No data provided on stdin' if STDIN.tty?
27
26
  contents = STDIN.read
@@ -29,13 +28,11 @@ OptionParser.new do |opts|
29
28
  raise 'File does not exist' unless File.exist? input
30
29
  contents = File.read input
31
30
  end
32
-
33
31
  begin
34
32
  parsed = JSON.parse(contents)
35
- rescue => e
33
+ rescue StandardError => e
36
34
  raise "Unable to parse JSON data provided: #{e}"
37
35
  end
38
-
39
36
  options[:data] = GithubStats::Data.new(parsed)
40
37
  end
41
38
  opts.on('-cSCHEME', '--colors SCHEME', 'Pick a color scheme') do |scheme|
@@ -61,6 +58,7 @@ OptionParser.new do |opts|
61
58
  exit
62
59
  end
63
60
  end.parse!
61
+ # rubocop:enable Metrics/BlockLength
64
62
 
65
63
  SVG_Path = ARGV.shift
66
64
 
@@ -1,4 +1,5 @@
1
- $:.unshift File.expand_path('../lib/', __FILE__)
1
+ require 'English'
2
+ $LOAD_PATH.unshift File.expand_path('lib', __dir__)
2
3
  require 'githubchart/version'
3
4
 
4
5
  Gem::Specification.new do |s|
@@ -16,13 +17,14 @@ Gem::Specification.new do |s|
16
17
  s.test_files = `git ls-files spec/*`.split
17
18
  s.executables = ['githubchart']
18
19
 
19
- s.add_runtime_dependency 'githubstats', '~> 1.3.0'
20
+ s.add_runtime_dependency 'githubstats', '~> 3.1.0'
20
21
  s.add_runtime_dependency 'svgplot', '~> 1.0.0'
21
22
 
22
- s.add_development_dependency 'rubocop', '~> 0.45.0'
23
- s.add_development_dependency 'rake', '~> 11.3.0'
23
+ s.add_development_dependency 'rubocop', '~> 0.76.0'
24
+ s.add_development_dependency 'goodcop', '~> 0.8.0'
25
+ s.add_development_dependency 'rake', '~> 13.0.0'
24
26
  s.add_development_dependency 'codecov', '~> 0.1.1'
25
- s.add_development_dependency 'rspec', '~> 3.5.0'
26
- s.add_development_dependency 'fuubar', '~> 2.2.0'
27
+ s.add_development_dependency 'rspec', '~> 3.9.0'
28
+ s.add_development_dependency 'fuubar', '~> 2.5.0'
27
29
  end
28
30
 
@@ -40,7 +40,8 @@ module GithubChart
40
40
  ##
41
41
  # Color schemes for gradient
42
42
  COLOR_SCHEMES = {
43
- default: ['#eeeeee', '#d6e685', '#8cc665', '#44a340', '#1e6823'],
43
+ default: ['#eeeeee', '#c6e48b', '#7bc96f', '#239a3b', '#196127'],
44
+ old: ['#eeeeee', '#d6e685', '#8cc665', '#44a340', '#1e6823'],
44
45
  halloween: ['#EEEEEE', '#FFEE4A', '#FFC501', '#FE9600', '#03001C']
45
46
  }.freeze
46
47
 
@@ -57,7 +58,7 @@ module GithubChart
57
58
 
58
59
  def initialize(params = {})
59
60
  params = { user: params } unless params.is_a? Hash
60
- @stats = params.fetch(:data) { GithubStats.new(params[:user]).data }
61
+ @stats = load_stats(params[:data], params[:user])
61
62
  @colors = params[:colors] || :default
62
63
  @colors = COLOR_SCHEMES[@colors] unless @colors.is_a? Array
63
64
  end
@@ -71,6 +72,17 @@ module GithubChart
71
72
 
72
73
  private
73
74
 
75
+ ##
76
+ # Load stats from provided arg or github
77
+
78
+ def load_stats(data, user)
79
+ return data if data
80
+ raise('No data or user provided') unless user
81
+ stats = GithubStats.new(user).data
82
+ raise("Failed to find data for #{user} on GitHub") unless stats
83
+ stats
84
+ end
85
+
74
86
  ##
75
87
  # Convert the data into a matrix of weeks
76
88
  # The fill value is used to pad the front and backdd
@@ -14,10 +14,14 @@ module GithubChart
14
14
  class Chart
15
15
  private
16
16
 
17
+ CUBE_SIZE = 12
18
+ X_PAD = 27
19
+ Y_PAD = 20
20
+
17
21
  def render_svg
18
22
  grid = matrix
19
- chart = SVGPlot.new(width: 13 * grid.column_size + 13,
20
- height: 13 * grid.row_size + 13)
23
+ chart = SVGPlot.new(width: CUBE_SIZE * grid.column_size + X_PAD,
24
+ height: CUBE_SIZE * grid.row_size + Y_PAD)
21
25
  svg_add_points grid, chart
22
26
  svg_add_weekdays chart
23
27
  svg_add_months chart
@@ -26,51 +30,45 @@ module GithubChart
26
30
 
27
31
  def render_svg_square
28
32
  grid = matrix.minor(0, 7, -7, 7)
29
- chart = SVGPlot.new(width: 13 * grid.column_size - 2,
30
- height: 13 * grid.row_size - 2)
31
- svg_add_points grid, chart, 0
33
+ chart = SVGPlot.new(width: CUBE_SIZE * grid.column_size - 2,
34
+ height: CUBE_SIZE * grid.row_size - 2)
35
+ svg_add_points grid, chart, 0, 0
32
36
  chart.to_s
33
37
  end
34
38
 
35
- # rubocop:disable Style/HashSyntax, Lint/UnneededDisable
39
+ ##
40
+ # Define shared label style
41
+
42
+ SVG_SHARED_STYLE = {
43
+ fill: '#767676',
44
+ 'text-anchor': 'start',
45
+ 'text-align': 'center',
46
+ 'font-family': '-apple-system, BlinkMacSystemFont, \'Segoe UI\', Helvetica, Arial, sans-serif, \'Apple Color Emoji\', \'Segoe UI Emoji\', \'Segoe UI Symbol\'', # rubocop:disable Metrics/LineLength
47
+ 'white-space': 'nowrap'
48
+ }.freeze
36
49
 
37
50
  ##
38
51
  # Define style for weekday labels
39
52
 
40
- SVG_WEEKDAY_STYLE = {
41
- :fill => '#ccc',
42
- :'text-anchor' => 'middle',
43
- :'text-align' => 'center',
44
- :font => '9px Helvetica, arial, freesans, clean, sans-serif',
45
- :'white-space' => 'nowrap',
46
- :display => 'display'
47
- }.freeze
53
+ SVG_WEEKDAY_STYLE = SVG_SHARED_STYLE.dup.merge('font-size': '9px').freeze
48
54
 
49
55
  ##
50
56
  # Define Style for month labels
51
57
 
52
- SVG_MONTH_STYLE = {
53
- :fill => '#aaa',
54
- :'text-align' => 'center',
55
- :font => '10px Helvetica, arial, freesans, clean, sans-serif',
56
- :'white-space' => 'nowrap',
57
- :display => 'block'
58
- }.freeze
58
+ SVG_MONTH_STYLE = SVG_SHARED_STYLE.dup.merge('font-size': '10px').freeze
59
59
 
60
60
  def svg_point_style(point)
61
61
  {
62
62
  fill: @colors[@stats.quartile(point.score)],
63
- :'shape-rendering' => 'crispedges'
63
+ 'shape-rendering': 'crispedges'
64
64
  }
65
65
  end
66
66
 
67
- # rubocop:enable Style/HashSyntax, Lint/UnneededDisable
68
-
69
- def svg_add_points(grid, chart, padding = 14)
67
+ def svg_add_points(grid, chart, xpadding = X_PAD, ypadding = Y_PAD)
70
68
  grid.each_with_index do |point, y, x|
71
69
  next if point.score == -1
72
70
  chart.rectangle(
73
- (x * 13) + padding, (y * 13) + padding, 11, 11,
71
+ (x * CUBE_SIZE) + xpadding, (y * CUBE_SIZE) + ypadding, 10, 10,
74
72
  data: { score: point.score, date: point.date },
75
73
  style: svg_point_style(point)
76
74
  )
@@ -79,10 +77,11 @@ module GithubChart
79
77
 
80
78
  def svg_add_weekday(chart, point)
81
79
  index = point.date.wday
82
- letter = point.date.strftime('%a')[0]
80
+ letter = point.date.strftime('%a')
83
81
  style = SVG_WEEKDAY_STYLE.dup
84
82
  style[:display] = 'none' unless [1, 3, 5].include? index
85
- chart.text(4, 13 * index + 23, style: style) { raw letter }
83
+ shift = index > 3 ? 29 : 28
84
+ chart.text(0, CUBE_SIZE * index + shift, style: style) { raw letter }
86
85
  end
87
86
 
88
87
  def svg_add_weekdays(chart)
@@ -105,7 +104,8 @@ module GithubChart
105
104
  offsets.shift if [1, 2].include? offsets[1].last
106
105
  offsets.each do |month, offset|
107
106
  next if offset > 50
108
- chart.text(13 * offset + 14, 9, style: SVG_MONTH_STYLE) { raw month }
107
+ x = CUBE_SIZE * offset + X_PAD
108
+ chart.text(x, 10, style: SVG_MONTH_STYLE) { raw month }
109
109
  end
110
110
  end
111
111
  end
@@ -1,5 +1,5 @@
1
1
  ##
2
2
  # Define the version
3
3
  module GithubChart
4
- VERSION = '2.0.0'.freeze
4
+ VERSION = '3.2.0'.freeze
5
5
  end
@@ -3,7 +3,7 @@ require 'spec_helper'
3
3
  describe GithubChart do
4
4
  describe '#new' do
5
5
  it 'creates a new Chart object' do
6
- expect(GithubChart.new).to be_an_instance_of GithubChart::Chart
6
+ expect(GithubChart.new(data: [])).to be_an_instance_of GithubChart::Chart
7
7
  end
8
8
  end
9
9
 
@@ -22,10 +22,11 @@ describe GithubChart do
22
22
 
23
23
  describe GithubChart::Chart do
24
24
  it 'has default colors' do
25
- expect(GithubChart.new.colors.last).to eql '#1e6823'
25
+ expect(GithubChart.new(data: []).colors.last).to eql '#196127'
26
26
  end
27
27
  it 'lets you override the colors' do
28
- expect(GithubChart.new(colors: [1, 2, 3, 4, 5]).colors.last).to eql 5
28
+ colors = [1, 2, 3, 4, 5]
29
+ expect(GithubChart.new(data: [], colors: colors).colors.last).to eql 5
29
30
  end
30
31
  it 'lets you pass external data' do
31
32
  data = JSON.parse(File.read('spec/examples/input.json'))
@@ -33,7 +34,7 @@ describe GithubChart do
33
34
  end
34
35
  it 'creates a data object when not provided' do
35
36
  expect(
36
- GithubChart.new(username: 'fly').stats
37
+ GithubChart.new(user: 'akerl').stats
37
38
  ).to be_an_instance_of GithubStats::Data
38
39
  end
39
40
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: githubchart
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 3.2.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: 2016-11-07 00:00:00.000000000 Z
11
+ date: 2020-10-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: githubstats
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 1.3.0
19
+ version: 3.1.0
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
- version: 1.3.0
26
+ version: 3.1.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: svgplot
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -44,28 +44,42 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 0.45.0
47
+ version: 0.76.0
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 0.45.0
54
+ version: 0.76.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: goodcop
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 0.8.0
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 0.8.0
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: rake
57
71
  requirement: !ruby/object:Gem::Requirement
58
72
  requirements:
59
73
  - - "~>"
60
74
  - !ruby/object:Gem::Version
61
- version: 11.3.0
75
+ version: 13.0.0
62
76
  type: :development
63
77
  prerelease: false
64
78
  version_requirements: !ruby/object:Gem::Requirement
65
79
  requirements:
66
80
  - - "~>"
67
81
  - !ruby/object:Gem::Version
68
- version: 11.3.0
82
+ version: 13.0.0
69
83
  - !ruby/object:Gem::Dependency
70
84
  name: codecov
71
85
  requirement: !ruby/object:Gem::Requirement
@@ -86,28 +100,28 @@ dependencies:
86
100
  requirements:
87
101
  - - "~>"
88
102
  - !ruby/object:Gem::Version
89
- version: 3.5.0
103
+ version: 3.9.0
90
104
  type: :development
91
105
  prerelease: false
92
106
  version_requirements: !ruby/object:Gem::Requirement
93
107
  requirements:
94
108
  - - "~>"
95
109
  - !ruby/object:Gem::Version
96
- version: 3.5.0
110
+ version: 3.9.0
97
111
  - !ruby/object:Gem::Dependency
98
112
  name: fuubar
99
113
  requirement: !ruby/object:Gem::Requirement
100
114
  requirements:
101
115
  - - "~>"
102
116
  - !ruby/object:Gem::Version
103
- version: 2.2.0
117
+ version: 2.5.0
104
118
  type: :development
105
119
  prerelease: false
106
120
  version_requirements: !ruby/object:Gem::Requirement
107
121
  requirements:
108
122
  - - "~>"
109
123
  - !ruby/object:Gem::Version
110
- version: 2.2.0
124
+ version: 2.5.0
111
125
  description: Uses GithubStats to grab Github contributions scores and converts that
112
126
  into an SVG
113
127
  email: me@lesaker.org
@@ -128,7 +142,6 @@ files:
128
142
  - README.md
129
143
  - Rakefile
130
144
  - bin/githubchart
131
- - circle.yml
132
145
  - examples/chart.svg
133
146
  - examples/other_user.svg
134
147
  - githubchart.gemspec
@@ -143,7 +156,7 @@ homepage: https://github.com/akerl/githubchart
143
156
  licenses:
144
157
  - MIT
145
158
  metadata: {}
146
- post_install_message:
159
+ post_install_message:
147
160
  rdoc_options: []
148
161
  require_paths:
149
162
  - lib
@@ -158,9 +171,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
158
171
  - !ruby/object:Gem::Version
159
172
  version: '0'
160
173
  requirements: []
161
- rubyforge_project:
162
- rubygems_version: 2.5.1
163
- signing_key:
174
+ rubygems_version: 3.1.2
175
+ signing_key:
164
176
  specification_version: 4
165
177
  summary: Generate an SVG of Github contributions data
166
178
  test_files:
data/circle.yml DELETED
@@ -1,6 +0,0 @@
1
- dependencies:
2
- override:
3
- - 'for i in $(cat .circle-ruby) ; do rvm-exec $i bundle install || exit 1 ; done'
4
- test:
5
- override:
6
- - 'for i in $(cat .circle-ruby) ; do rvm-exec $i bundle exec rake || exit 1 ; done'