githubchart 0.0.13 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/githubchart.gemspec +1 -1
- data/lib/githubchart/svg.rb +17 -14
- data/lib/githubchart/version.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6ecd87617b3f21634b56adb1e6c14d51f94e9758
|
4
|
+
data.tar.gz: d72dd7dd0549cafb640d544904f124a87b4dae99
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2b44d82bb9fc2755ef2fd41e0441198b4201ee91f395d220705d1df337aef0f14f9d5994ee8b0b0a7ec88ee8df219a7a96e8ec7b48de80eedbeb952f4ac052bb
|
7
|
+
data.tar.gz: 83bc6d54cdad7cdb3c353eda70baa18fb29d0dc241d3430d04d4a176e638a8ed43cfb591ed4808ff10884ac03bc9afd0aaade90d047d1adb42c28d2ba96b2d1c
|
data/githubchart.gemspec
CHANGED
@@ -17,7 +17,7 @@ Gem::Specification.new do |s|
|
|
17
17
|
s.executables = ['githubchart']
|
18
18
|
|
19
19
|
s.add_runtime_dependency 'githubstats', '~> 0.2.16'
|
20
|
-
s.add_runtime_dependency '
|
20
|
+
s.add_runtime_dependency 'svgplot', '~> 0.0.3'
|
21
21
|
|
22
22
|
s.add_development_dependency 'rubocop', '~> 0.28.0'
|
23
23
|
s.add_development_dependency 'rake', '~> 10.4.0'
|
data/lib/githubchart/svg.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require '
|
1
|
+
require 'svgplot'
|
2
2
|
|
3
3
|
##
|
4
4
|
# Add SVG support to GithubChart
|
@@ -13,13 +13,12 @@ module GithubChart
|
|
13
13
|
class Chart
|
14
14
|
def svg
|
15
15
|
grid = matrix
|
16
|
-
chart =
|
17
|
-
|
16
|
+
chart = SVGPlot.new(width: 13 * grid.column_size + 13,
|
17
|
+
height: 13 * grid.row_size + 13)
|
18
18
|
svg_add_points grid, chart
|
19
19
|
svg_add_weekdays chart
|
20
20
|
svg_add_months chart
|
21
|
-
chart.
|
22
|
-
chart.output
|
21
|
+
chart.to_s
|
23
22
|
end
|
24
23
|
|
25
24
|
private
|
@@ -53,19 +52,23 @@ module GithubChart
|
|
53
52
|
chart.rectangle(
|
54
53
|
(x * 13) + 14, (y * 13) + 14, 11, 11,
|
55
54
|
fill: @colors[@stats.quartile(point.score)],
|
56
|
-
:'shape-rendering' => 'crispedges'
|
55
|
+
:'shape-rendering' => 'crispedges',
|
56
|
+
:'data-score' => point.score,
|
57
|
+
:'data-data' => point.date
|
57
58
|
)
|
58
59
|
end
|
59
60
|
end
|
60
61
|
|
62
|
+
def svg_add_weekday(chart, point)
|
63
|
+
index = point.date.wday
|
64
|
+
letter = point.date.strftime('%a')[0]
|
65
|
+
style = SVG_WEEKDAY_STYLE.clone
|
66
|
+
style[:display] = 'none' unless [1, 3, 5].include? index
|
67
|
+
chart.text(4, 13 * index + 23, style) { raw letter }
|
68
|
+
end
|
69
|
+
|
61
70
|
def svg_add_weekdays(chart)
|
62
|
-
@stats.raw.first(7).each
|
63
|
-
index = point.date.wday
|
64
|
-
letter = point.date.strftime('%a')[0]
|
65
|
-
style = SVG_WEEKDAY_STYLE.clone
|
66
|
-
style[:display] = 'none' unless [1, 3, 5].include? index
|
67
|
-
chart.text(4, 13 * index + 23, letter, style)
|
68
|
-
end
|
71
|
+
@stats.raw.first(7).each { |point| svg_add_weekday chart, point }
|
69
72
|
end
|
70
73
|
|
71
74
|
def svg_get_month_offsets # rubocop:disable Metrics/AbcSize
|
@@ -84,7 +87,7 @@ module GithubChart
|
|
84
87
|
offsets.shift if offsets.take(2).map(&:last) == [0, 1]
|
85
88
|
offsets.each do |month, offset|
|
86
89
|
next if offset > 50
|
87
|
-
chart.text(13 * offset + 14, 9, month
|
90
|
+
chart.text(13 * offset + 14, 9, SVG_MONTH_STYLE) { raw month }
|
88
91
|
end
|
89
92
|
end
|
90
93
|
end
|
data/lib/githubchart/version.rb
CHANGED
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.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Les Aker
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-01-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: githubstats
|
@@ -25,19 +25,19 @@ dependencies:
|
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 0.2.16
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: svgplot
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.
|
33
|
+
version: 0.0.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: 0.
|
40
|
+
version: 0.0.3
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rubocop
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|