githubchart 0.0.1 → 0.0.2

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: bdac5ac1afcbbc3eaee06bb5f4b634f87ba9548e
4
- data.tar.gz: 9887848ec0fffee018df3bc674bd0f6344ce170b
3
+ metadata.gz: 1804c1a1b3b18c94f410703a8f541b8e60c95e93
4
+ data.tar.gz: 2dfc34c2e0da6cf3538cb6f5b120f20deacde2ac
5
5
  SHA512:
6
- metadata.gz: cdc40915ac56a0174dea41543ace55d266b076aae01cad2fdbb49d8ee9f606ffa88f65ad5351ad8b00cc14d3fd3ba8b0a7b0bf853e524ed2db406befe453df2a
7
- data.tar.gz: fae313f0eda227cc99f0bf481e44ad67263d25e624fad596d574988b8957a150864b2aed44a2d1e4a420092373f366d9fdd7a5fed1d3149eb337b818abd1967c
6
+ metadata.gz: 66029000faa0e132939387b9f7472a7897b195c6ddeba64dbf5e21a9dfec4b96b84f66b3be7f026d18138df8829eaed0c3ba5f64081ddc2e9385f2f4182d3cc9
7
+ data.tar.gz: b9f9cac1c594679fcc0eaced8c51c3ce7dc0fcb8088bcff05e110349683b5fddebbac1a931c0f6397802960cc208da3ecb411d30e345374af52aaa37e802e50c
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- githubchart (0.0.1)
4
+ githubchart (0.0.2)
5
5
  githubstats
6
6
  rasem
7
7
 
@@ -23,7 +23,7 @@ GEM
23
23
  rspec (~> 2.0)
24
24
  rspec-instafail (~> 0.2.0)
25
25
  ruby-progressbar (~> 1.0)
26
- githubstats (0.2.3)
26
+ githubstats (0.2.4)
27
27
  basiccache (< 2)
28
28
  curb
29
29
  json
data/githubchart.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'githubchart'
3
- s.version = '0.0.1'
3
+ s.version = '0.0.2'
4
4
  s.date = Time.now.strftime("%Y-%m-%d")
5
5
  s.summary = 'Generate an SVG of Github contributions data'
6
6
  s.description = "Uses GithubStats to grab Github contributions scores and converts that into an SVG"
@@ -18,8 +18,8 @@ module GithubChart
18
18
  chart = Rasem::SVGImage.new(13 * grid.column_size + 13,
19
19
  13 * grid.row_size + 13)
20
20
  svg_add_points grid, chart
21
- svg_add_weekdays grid, chart
22
- svg_add_months grid, chart
21
+ svg_add_weekdays chart
22
+ svg_add_months chart
23
23
  chart.close
24
24
  chart.output
25
25
  end
@@ -63,8 +63,8 @@ module GithubChart
63
63
  end
64
64
  end
65
65
 
66
- def svg_add_weekdays(grid, chart)
67
- grid.column(0).each do |point|
66
+ def svg_add_weekdays(chart)
67
+ @stats.raw.first(7).each do |point|
68
68
  index = point.date.wday
69
69
  letter = point.date.strftime('%a')[0]
70
70
  style = SVG_WEEKDAY_STYLE.clone
@@ -73,24 +73,18 @@ module GithubChart
73
73
  end
74
74
  end
75
75
 
76
- def svg_get_month_offsets(grid) # rubocop:disable MethodLength
77
- offsets = grid.group_by { |x| x.date.strftime('%Y%U') }
78
- offsets = offsets.map { |k, v| v.first.date.strftime('%b') }
79
- offsets = offsets.reduce([]) do |acc, x|
80
- acc << [x, 0] if acc.last.nil?
81
- acc << [x, acc.last[1]] if acc.last[0] != x
82
- acc.last[1] += 1
83
- acc
76
+ def svg_get_month_offsets
77
+ list = @stats.raw.group_by { |x| x.date.strftime('%Y%U').split('-') }
78
+ acc = 0
79
+ list = list.map { |k, v| v.first.date.strftime('%b') }
80
+ list.chunk { |x| x }.map do |month, offset|
81
+ acc += offset.size
82
+ [month, acc - offset.size]
84
83
  end
85
- offsets.each_index do |i|
86
- offsets[-1 - i][1] = (offsets[-2 - i] || [0, 0])[1]
87
- end
88
- offsets
89
84
  end
90
85
 
91
- def svg_add_months(grid, chart)
92
- svg_get_month_offsets(grid).each do |month, offset|
93
- next if offset == 0
86
+ def svg_add_months(chart)
87
+ svg_get_month_offsets.each do |month, offset|
94
88
  chart.text(13 * offset + 14, 9, month, SVG_MONTH_STYLE)
95
89
  end
96
90
  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: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Les Aker
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-01 00:00:00.000000000 Z
11
+ date: 2013-12-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: githubstats
@@ -167,7 +167,7 @@ files:
167
167
  - vendor/cache/diff-lcs-1.2.5.gem
168
168
  - vendor/cache/docile-1.1.1.gem
169
169
  - vendor/cache/fuubar-1.2.1.gem
170
- - vendor/cache/githubstats-0.2.3.gem
170
+ - vendor/cache/githubstats-0.2.4.gem
171
171
  - vendor/cache/hashr-0.0.22.gem
172
172
  - vendor/cache/json-1.8.1.gem
173
173
  - vendor/cache/mime-types-2.0.gem