githubchart 2.1.0 → 3.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4a256147befb46b1059f9e6b9d5be479c61de11f
4
- data.tar.gz: 2097baa5f511c7e4d6eed17f86ae5f266a0a33e9
3
+ metadata.gz: 12ecb34761bd3f4f318e52195201320f239421a3
4
+ data.tar.gz: 83f0fd65e8f03d458faca75f4147c0de74065775
5
5
  SHA512:
6
- metadata.gz: 13287b1c631bd6a1ff3855ae836406a83eb005e645d90c9c44ae7a7f2db44d80723467f85e539d20c08b8a0cb9e9b022c209a9c678df73b9fa302cf9a2f445cd
7
- data.tar.gz: 1e5f586ec76d5b34cc6d2f9428c73e4da13e7ed2a37de74323434798d00c7f1529a5c769621f794494b7ea82316a6794f1025b26908039e22f7ffa2ebbe0a0ef
6
+ metadata.gz: af152bb8f0f252f9cb20a9ab5bdb9c33dd1eb13931216fc069b6f1fa6fd1b7754ff6b8ce4e114a5ee95ac5f8641f1e8aba45684ef057ac16f547018305b5f51c
7
+ data.tar.gz: cadae5c1945e63b6bc31d49f4fa07b0a8e9b04871992c334213f772ad4c7b90c30a07770de2204dab119a6d18cad45f98387e2219db8686ed8984f5973fa435b
@@ -1,3 +1,3 @@
1
- 2.4.1
2
- 2.3.4
3
- 2.2.7
1
+ 2.4.2
2
+ 2.3.5
3
+ 2.2.8
@@ -1,2 +1,2 @@
1
- Encoding:
2
- Enabled: false
1
+ inherit_gem:
2
+ goodcop: .rubocop.yml
@@ -1,3 +1,11 @@
1
+ # 3.1.0 / 2017-10-03
2
+
3
+ * [ENHANCEMENT] GitHub updated their styling; this updated matches that change
4
+
5
+ # 3.0.0 / 2017-09-29
6
+
7
+ * [ENHANCEMENT] Upgrade to latest githubstats with better error messages
8
+
1
9
  # 2.1.0 / 2017-08-25
2
10
 
3
11
  * [ENHANCEMENT] Upgrade to latest githubstats
@@ -32,7 +32,7 @@ OptionParser.new do |opts|
32
32
 
33
33
  begin
34
34
  parsed = JSON.parse(contents)
35
- rescue => e
35
+ rescue StandardError => e
36
36
  raise "Unable to parse JSON data provided: #{e}"
37
37
  end
38
38
 
@@ -16,11 +16,12 @@ Gem::Specification.new do |s|
16
16
  s.test_files = `git ls-files spec/*`.split
17
17
  s.executables = ['githubchart']
18
18
 
19
- s.add_runtime_dependency 'githubstats', '~> 1.4.0'
19
+ s.add_runtime_dependency 'githubstats', '~> 2.0.0'
20
20
  s.add_runtime_dependency 'svgplot', '~> 1.0.0'
21
21
 
22
- s.add_development_dependency 'rubocop', '~> 0.49.0'
23
- s.add_development_dependency 'rake', '~> 12.0.0'
22
+ s.add_development_dependency 'rubocop', '~> 0.50.0'
23
+ s.add_development_dependency 'goodcop', '~> 0.1.0'
24
+ s.add_development_dependency 'rake', '~> 12.1.0'
24
25
  s.add_development_dependency 'codecov', '~> 0.1.1'
25
26
  s.add_development_dependency 'rspec', '~> 3.6.0'
26
27
  s.add_development_dependency 'fuubar', '~> 2.2.0'
@@ -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,36 +30,34 @@ 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
39
  # rubocop:disable Style/HashSyntax, Lint/UnneededDisable
36
40
 
37
41
  ##
38
- # Define style for weekday labels
42
+ # Define shared label style
39
43
 
40
- SVG_WEEKDAY_STYLE = {
41
- :fill => '#ccc',
42
- :'text-anchor' => 'middle',
44
+ SVG_SHARED_STYLE = {
45
+ :fill => '#767676',
46
+ :'text-anchor' => 'start',
43
47
  :'text-align' => 'center',
44
- :font => '9px Helvetica, arial, freesans, clean, sans-serif',
45
- :'white-space' => 'nowrap',
46
- :display => 'display'
48
+ :'font-family' => '-apple-system, BlinkMacSystemFont, \'Segoe UI\', Helvetica, Arial, sans-serif, \'Apple Color Emoji\', \'Segoe UI Emoji\', \'Segoe UI Symbol\'', # rubocop:disable Metrics/LineLength
49
+ :'white-space' => 'nowrap'
47
50
  }.freeze
48
51
 
52
+ ##
53
+ # Define style for weekday labels
54
+
55
+ SVG_WEEKDAY_STYLE = SVG_SHARED_STYLE.dup.merge(:'font-size' => '9px').freeze
56
+
49
57
  ##
50
58
  # Define Style for month labels
51
59
 
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
60
+ SVG_MONTH_STYLE = SVG_SHARED_STYLE.dup.merge(:'font-size' => '10px').freeze
59
61
 
60
62
  def svg_point_style(point)
61
63
  {
@@ -64,13 +66,11 @@ module GithubChart
64
66
  }
65
67
  end
66
68
 
67
- # rubocop:enable Style/HashSyntax, Lint/UnneededDisable
68
-
69
- def svg_add_points(grid, chart, padding = 14)
69
+ def svg_add_points(grid, chart, xpadding = X_PAD, ypadding = Y_PAD)
70
70
  grid.each_with_index do |point, y, x|
71
71
  next if point.score == -1
72
72
  chart.rectangle(
73
- (x * 13) + padding, (y * 13) + padding, 11, 11,
73
+ (x * CUBE_SIZE) + xpadding, (y * CUBE_SIZE) + ypadding, 10, 10,
74
74
  data: { score: point.score, date: point.date },
75
75
  style: svg_point_style(point)
76
76
  )
@@ -79,10 +79,11 @@ module GithubChart
79
79
 
80
80
  def svg_add_weekday(chart, point)
81
81
  index = point.date.wday
82
- letter = point.date.strftime('%a')[0]
82
+ letter = point.date.strftime('%a')
83
83
  style = SVG_WEEKDAY_STYLE.dup
84
84
  style[:display] = 'none' unless [1, 3, 5].include? index
85
- chart.text(4, 13 * index + 23, style: style) { raw letter }
85
+ shift = index > 3 ? 29 : 28
86
+ chart.text(0, CUBE_SIZE * index + shift, style: style) { raw letter }
86
87
  end
87
88
 
88
89
  def svg_add_weekdays(chart)
@@ -105,7 +106,8 @@ module GithubChart
105
106
  offsets.shift if [1, 2].include? offsets[1].last
106
107
  offsets.each do |month, offset|
107
108
  next if offset > 50
108
- chart.text(13 * offset + 14, 9, style: SVG_MONTH_STYLE) { raw month }
109
+ x = CUBE_SIZE * offset + X_PAD
110
+ chart.text(x, 10, style: SVG_MONTH_STYLE) { raw month }
109
111
  end
110
112
  end
111
113
  end
@@ -1,5 +1,5 @@
1
1
  ##
2
2
  # Define the version
3
3
  module GithubChart
4
- VERSION = '2.1.0'.freeze
4
+ VERSION = '3.1.0'.freeze
5
5
  end
@@ -1,11 +1,9 @@
1
1
  require 'spec_helper'
2
2
 
3
- # rubocop:disable Metrics/BlockLength
4
-
5
3
  describe GithubChart do
6
4
  describe '#new' do
7
5
  it 'creates a new Chart object' do
8
- expect(GithubChart.new).to be_an_instance_of GithubChart::Chart
6
+ expect(GithubChart.new(data: [])).to be_an_instance_of GithubChart::Chart
9
7
  end
10
8
  end
11
9
 
@@ -24,10 +22,11 @@ describe GithubChart do
24
22
 
25
23
  describe GithubChart::Chart do
26
24
  it 'has default colors' do
27
- expect(GithubChart.new.colors.last).to eql '#1e6823'
25
+ expect(GithubChart.new(data: []).colors.last).to eql '#196127'
28
26
  end
29
27
  it 'lets you override the colors' do
30
- 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
31
30
  end
32
31
  it 'lets you pass external data' do
33
32
  data = JSON.parse(File.read('spec/examples/input.json'))
@@ -35,7 +34,7 @@ describe GithubChart do
35
34
  end
36
35
  it 'creates a data object when not provided' do
37
36
  expect(
38
- GithubChart.new(username: 'fly').stats
37
+ GithubChart.new(user: 'akerl').stats
39
38
  ).to be_an_instance_of GithubStats::Data
40
39
  end
41
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.1.0
4
+ version: 3.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Les Aker
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-08-25 00:00:00.000000000 Z
11
+ date: 2017-10-03 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.4.0
19
+ version: 2.0.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.4.0
26
+ version: 2.0.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.49.0
47
+ version: 0.50.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.49.0
54
+ version: 0.50.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.1.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.1.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: 12.0.0
75
+ version: 12.1.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: 12.0.0
82
+ version: 12.1.0
69
83
  - !ruby/object:Gem::Dependency
70
84
  name: codecov
71
85
  requirement: !ruby/object:Gem::Requirement
@@ -159,7 +173,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
159
173
  version: '0'
160
174
  requirements: []
161
175
  rubyforge_project:
162
- rubygems_version: 2.6.11
176
+ rubygems_version: 2.6.13
163
177
  signing_key:
164
178
  specification_version: 4
165
179
  summary: Generate an SVG of Github contributions data