githubchart 1.1.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circle-ruby +3 -0
- data/Gemfile +0 -1
- data/README.md +1 -1
- data/bin/githubchart +13 -6
- data/circle.yml +2 -8
- data/githubchart.gemspec +5 -5
- data/lib/githubchart.rb +7 -0
- data/lib/githubchart/svg.rb +13 -4
- data/lib/githubchart/version.rb +1 -1
- data/spec/githubchart/svg_spec.rb +16 -11
- data/spec/githubchart_spec.rb +7 -0
- metadata +13 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 10dfa80d371c52dba32328690e164a7a9a08d9dc
|
4
|
+
data.tar.gz: 57831c4b0694a31f41e8ad24fc58d2519885465f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 88d6755bf2df598c47e2369f1cece14616ee7b4e7b12aa7e9ed3f1bf1823ee821b0820312daa92d6f8ac3898af89b4a6b3a61ee913ac6d1875009b30b8fbccfa
|
7
|
+
data.tar.gz: 9f893ad3059e55ca31497af62926fa0c27e3b03c78d4bd4c97f5da45e7a3fc6a591f29ca92cd784ca5e841219694b612b64770cb7d8e3f9ff2487d56fb43b6d0
|
data/.circle-ruby
ADDED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -3,7 +3,7 @@ GithubChart
|
|
3
3
|
|
4
4
|
[![Gem Version](https://img.shields.io/gem/v/githubchart.svg)](https://rubygems.org/gems/githubchart)
|
5
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.svg)](https://circleci.com/gh/akerl/githubchart)
|
6
|
+
[![Build Status](https://img.shields.io/circleci/project/akerl/githubchart/master.svg)](https://circleci.com/gh/akerl/githubchart)
|
7
7
|
[![Coverage Status](https://img.shields.io/codecov/c/github/akerl/githubchart.svg)](https://codecov.io/github/akerl/githubchart)
|
8
8
|
[![Code Quality](https://img.shields.io/codacy/e8ee7e2aba4c4a01b93d5c0493bef68b.svg)](https://www.codacy.com/app/akerl/githubchart)
|
9
9
|
[![MIT Licensed](https://img.shields.io/badge/license-MIT-green.svg)](https://tldrlegal.com/license/mit-license)
|
data/bin/githubchart
CHANGED
@@ -3,7 +3,10 @@
|
|
3
3
|
require 'githubchart'
|
4
4
|
require 'optparse'
|
5
5
|
|
6
|
+
# rubocop:disable Metrics/BlockLength
|
6
7
|
options = {}
|
8
|
+
render_type = 'svg'.freeze
|
9
|
+
|
7
10
|
OptionParser.new do |opts|
|
8
11
|
opts.banner =
|
9
12
|
"Usage: githubchart (-u username) (-t type) path/for/new/image\n"
|
@@ -36,11 +39,9 @@ OptionParser.new do |opts|
|
|
36
39
|
options[:data] = GithubStats::Data.new(parsed)
|
37
40
|
end
|
38
41
|
opts.on('-cSCHEME', '--colors SCHEME', 'Pick a color scheme') do |scheme|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
raise 'Unknown color scheme provided'
|
43
|
-
end
|
42
|
+
is_good_scheme = GithubChart::COLOR_SCHEMES.include? scheme.to_sym
|
43
|
+
raise('Unknown color scheme provided') unless is_good_scheme
|
44
|
+
options[:colors] = scheme.to_sym
|
44
45
|
end
|
45
46
|
opts.on('-s', '--schemes', 'List known color schemes') do
|
46
47
|
puts 'Color schemes:'
|
@@ -49,6 +50,12 @@ OptionParser.new do |opts|
|
|
49
50
|
end
|
50
51
|
exit
|
51
52
|
end
|
53
|
+
opts.on('-t TYPE', '--type TYPE', 'What type to render') do |type|
|
54
|
+
raise('Unsupported render type') unless GithubChart.supported.include?(
|
55
|
+
type.to_sym
|
56
|
+
)
|
57
|
+
render_type = type
|
58
|
+
end
|
52
59
|
opts.on_tail('-v', '--version', 'Show version') do
|
53
60
|
puts GithubChart::VERSION
|
54
61
|
exit
|
@@ -57,7 +64,7 @@ end.parse!
|
|
57
64
|
|
58
65
|
SVG_Path = ARGV.shift
|
59
66
|
|
60
|
-
Chart = GithubChart.new(options).
|
67
|
+
Chart = GithubChart.new(options).render(render_type)
|
61
68
|
|
62
69
|
if SVG_Path.nil?
|
63
70
|
puts Chart
|
data/circle.yml
CHANGED
@@ -1,12 +1,6 @@
|
|
1
1
|
dependencies:
|
2
2
|
override:
|
3
|
-
|
4
|
-
- 'rvm-exec 2.0.0-p645 bundle install'
|
5
|
-
- 'rvm-exec 2.1.6 bundle install'
|
6
|
-
- 'rvm-exec 2.2.2 bundle install'
|
3
|
+
- 'for i in $(cat .circle-ruby) ; do rvm-exec $i bundle install || exit 1 ; done'
|
7
4
|
test:
|
8
5
|
override:
|
9
|
-
|
10
|
-
- 'rvm-exec 2.0.0-p645 bundle exec rake'
|
11
|
-
- 'rvm-exec 2.1.6 bundle exec rake'
|
12
|
-
- 'rvm-exec 2.2.2 bundle exec rake'
|
6
|
+
- 'for i in $(cat .circle-ruby) ; do rvm-exec $i bundle exec rake || exit 1 ; done'
|
data/githubchart.gemspec
CHANGED
@@ -16,13 +16,13 @@ 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.
|
19
|
+
s.add_runtime_dependency 'githubstats', '~> 1.3.0'
|
20
20
|
s.add_runtime_dependency 'svgplot', '~> 1.0.0'
|
21
21
|
|
22
|
-
s.add_development_dependency 'rubocop', '~> 0.
|
23
|
-
s.add_development_dependency 'rake', '~> 11.
|
22
|
+
s.add_development_dependency 'rubocop', '~> 0.45.0'
|
23
|
+
s.add_development_dependency 'rake', '~> 11.3.0'
|
24
24
|
s.add_development_dependency 'codecov', '~> 0.1.1'
|
25
|
-
s.add_development_dependency 'rspec', '~> 3.
|
26
|
-
s.add_development_dependency 'fuubar', '~> 2.
|
25
|
+
s.add_development_dependency 'rspec', '~> 3.5.0'
|
26
|
+
s.add_development_dependency 'fuubar', '~> 2.2.0'
|
27
27
|
end
|
28
28
|
|
data/lib/githubchart.rb
CHANGED
@@ -62,6 +62,13 @@ module GithubChart
|
|
62
62
|
@colors = COLOR_SCHEMES[@colors] unless @colors.is_a? Array
|
63
63
|
end
|
64
64
|
|
65
|
+
def render(type)
|
66
|
+
unless GithubChart.supports? type
|
67
|
+
raise NameError, "Format #{type} is unsupported."
|
68
|
+
end
|
69
|
+
send("render_#{type}".to_sym)
|
70
|
+
end
|
71
|
+
|
65
72
|
private
|
66
73
|
|
67
74
|
##
|
data/lib/githubchart/svg.rb
CHANGED
@@ -7,11 +7,14 @@ module GithubChart
|
|
7
7
|
# Declare SVG support
|
8
8
|
|
9
9
|
add_support(:svg)
|
10
|
+
add_support(:svg_square)
|
10
11
|
|
11
12
|
##
|
12
13
|
# Convert stats into SVG
|
13
14
|
class Chart
|
14
|
-
|
15
|
+
private
|
16
|
+
|
17
|
+
def render_svg
|
15
18
|
grid = matrix
|
16
19
|
chart = SVGPlot.new(width: 13 * grid.column_size + 13,
|
17
20
|
height: 13 * grid.row_size + 13)
|
@@ -21,7 +24,13 @@ module GithubChart
|
|
21
24
|
chart.to_s
|
22
25
|
end
|
23
26
|
|
24
|
-
|
27
|
+
def render_svg_square
|
28
|
+
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
|
32
|
+
chart.to_s
|
33
|
+
end
|
25
34
|
|
26
35
|
# rubocop:disable Style/HashSyntax, Lint/UnneededDisable
|
27
36
|
|
@@ -57,11 +66,11 @@ module GithubChart
|
|
57
66
|
|
58
67
|
# rubocop:enable Style/HashSyntax, Lint/UnneededDisable
|
59
68
|
|
60
|
-
def svg_add_points(grid, chart)
|
69
|
+
def svg_add_points(grid, chart, padding = 14)
|
61
70
|
grid.each_with_index do |point, y, x|
|
62
71
|
next if point.score == -1
|
63
72
|
chart.rectangle(
|
64
|
-
(x * 13) +
|
73
|
+
(x * 13) + padding, (y * 13) + padding, 11, 11,
|
65
74
|
data: { score: point.score, date: point.date },
|
66
75
|
style: svg_point_style(point)
|
67
76
|
)
|
data/lib/githubchart/version.rb
CHANGED
@@ -1,21 +1,26 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
require 'tempfile'
|
3
3
|
|
4
|
-
|
5
|
-
|
4
|
+
def test_svg(type)
|
5
|
+
file = Tempfile.new('svg')
|
6
|
+
file.write(GithubChart.new(user: 'akerl').render(type))
|
7
|
+
path = file.path
|
8
|
+
file.close
|
9
|
+
res = `file #{path}`
|
10
|
+
file.unlink
|
11
|
+
res
|
12
|
+
end
|
6
13
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
14
|
+
describe GithubChart::Chart do
|
15
|
+
describe '#render_svg' do
|
16
|
+
it 'makes an SVG' do
|
17
|
+
expect(test_svg(:svg)).to include('Scalable Vector Graphic')
|
18
|
+
end
|
12
19
|
end
|
13
20
|
|
14
|
-
|
15
|
-
|
16
|
-
describe '#svg' do
|
21
|
+
describe '#render_svg_square' do
|
17
22
|
it 'makes an SVG' do
|
18
|
-
expect(
|
23
|
+
expect(test_svg(:svg_square)).to include('Scalable Vector Graphic')
|
19
24
|
end
|
20
25
|
end
|
21
26
|
end
|
data/spec/githubchart_spec.rb
CHANGED
@@ -37,6 +37,13 @@ describe GithubChart do
|
|
37
37
|
).to be_an_instance_of GithubStats::Data
|
38
38
|
end
|
39
39
|
end
|
40
|
+
|
41
|
+
describe '#render' do
|
42
|
+
it 'raises error if render type is unsupported' do
|
43
|
+
expect { GithubChart.new(user: 'akerl').render(:dog) }
|
44
|
+
.to raise_error(NameError)
|
45
|
+
end
|
46
|
+
end
|
40
47
|
end
|
41
48
|
|
42
49
|
describe ::Integer do
|
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:
|
4
|
+
version: 2.0.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: 2016-
|
11
|
+
date: 2016-11-07 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.
|
19
|
+
version: 1.3.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.
|
26
|
+
version: 1.3.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: svgplot
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -44,28 +44,28 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 0.
|
47
|
+
version: 0.45.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.
|
54
|
+
version: 0.45.0
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rake
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 11.
|
61
|
+
version: 11.3.0
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 11.
|
68
|
+
version: 11.3.0
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: codecov
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -86,28 +86,28 @@ dependencies:
|
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: 3.
|
89
|
+
version: 3.5.0
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: 3.
|
96
|
+
version: 3.5.0
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: fuubar
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
101
|
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: 2.
|
103
|
+
version: 2.2.0
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: 2.
|
110
|
+
version: 2.2.0
|
111
111
|
description: Uses GithubStats to grab Github contributions scores and converts that
|
112
112
|
into an SVG
|
113
113
|
email: me@lesaker.org
|
@@ -116,6 +116,7 @@ executables:
|
|
116
116
|
extensions: []
|
117
117
|
extra_rdoc_files: []
|
118
118
|
files:
|
119
|
+
- ".circle-ruby"
|
119
120
|
- ".gitignore"
|
120
121
|
- ".prospectus"
|
121
122
|
- ".rspec"
|