gruff 0.7.0 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (91) hide show
  1. checksums.yaml +5 -5
  2. data/.editorconfig +14 -0
  3. data/.rubocop.yml +16 -0
  4. data/.rubocop_todo.yml +923 -0
  5. data/.travis.yml +21 -14
  6. data/{History.txt → CHANGELOG.md} +32 -25
  7. data/README.md +3 -2
  8. data/Rakefile +27 -18
  9. data/assets/bubble.png +0 -0
  10. data/assets/city_scene/background/0000.png +0 -0
  11. data/assets/city_scene/background/0600.png +0 -0
  12. data/assets/city_scene/background/2000.png +0 -0
  13. data/assets/city_scene/clouds/cloudy.png +0 -0
  14. data/assets/city_scene/clouds/partly_cloudy.png +0 -0
  15. data/assets/city_scene/clouds/stormy.png +0 -0
  16. data/assets/city_scene/grass/default.png +0 -0
  17. data/assets/city_scene/haze/true.png +0 -0
  18. data/assets/city_scene/number_sample/1.png +0 -0
  19. data/assets/city_scene/number_sample/2.png +0 -0
  20. data/assets/city_scene/number_sample/default.png +0 -0
  21. data/assets/city_scene/sky/0000.png +0 -0
  22. data/assets/city_scene/sky/0200.png +0 -0
  23. data/assets/city_scene/sky/0400.png +0 -0
  24. data/assets/city_scene/sky/0600.png +0 -0
  25. data/assets/city_scene/sky/0800.png +0 -0
  26. data/assets/city_scene/sky/1000.png +0 -0
  27. data/assets/city_scene/sky/1200.png +0 -0
  28. data/assets/city_scene/sky/1400.png +0 -0
  29. data/assets/city_scene/sky/1500.png +0 -0
  30. data/assets/city_scene/sky/1700.png +0 -0
  31. data/assets/city_scene/sky/2000.png +0 -0
  32. data/assets/pc306715.jpg +0 -0
  33. data/assets/plastik/blue.png +0 -0
  34. data/assets/plastik/green.png +0 -0
  35. data/assets/plastik/red.png +0 -0
  36. data/gruff.gemspec +12 -10
  37. data/lib/gruff.rb +2 -2
  38. data/lib/gruff/accumulator_bar.rb +2 -2
  39. data/lib/gruff/area.rb +1 -4
  40. data/lib/gruff/bar.rb +12 -13
  41. data/lib/gruff/bar_conversion.rb +11 -11
  42. data/lib/gruff/base.rb +36 -36
  43. data/lib/gruff/bezier.rb +1 -2
  44. data/lib/gruff/bullet.rb +7 -10
  45. data/lib/gruff/deprecated.rb +10 -11
  46. data/lib/gruff/dot.rb +3 -4
  47. data/lib/gruff/line.rb +13 -14
  48. data/lib/gruff/mini/bar.rb +3 -3
  49. data/lib/gruff/mini/legend.rb +7 -8
  50. data/lib/gruff/mini/pie.rb +6 -6
  51. data/lib/gruff/mini/side_bar.rb +7 -7
  52. data/lib/gruff/net.rb +2 -8
  53. data/lib/gruff/photo_bar.rb +9 -12
  54. data/lib/gruff/pie.rb +6 -6
  55. data/lib/gruff/scatter.rb +47 -51
  56. data/lib/gruff/scene.rb +17 -19
  57. data/lib/gruff/side_bar.rb +5 -8
  58. data/lib/gruff/side_stacked_bar.rb +24 -26
  59. data/lib/gruff/spider.rb +14 -15
  60. data/lib/gruff/stacked_area.rb +12 -16
  61. data/lib/gruff/stacked_bar.rb +50 -52
  62. data/lib/gruff/stacked_mixin.rb +2 -3
  63. data/lib/gruff/themes.rb +32 -33
  64. data/lib/gruff/version.rb +1 -1
  65. metadata +23 -67
  66. data/RELEASE.md +0 -30
  67. data/test/gruff_test_case.rb +0 -152
  68. data/test/image_compare.rb +0 -58
  69. data/test/test_accumulator_bar.rb +0 -51
  70. data/test/test_area.rb +0 -134
  71. data/test/test_bar.rb +0 -505
  72. data/test/test_base.rb +0 -33
  73. data/test/test_bezier.rb +0 -33
  74. data/test/test_bullet.rb +0 -26
  75. data/test/test_dot.rb +0 -263
  76. data/test/test_labels_for_null_data.rb +0 -27
  77. data/test/test_legend.rb +0 -68
  78. data/test/test_line.rb +0 -674
  79. data/test/test_mini_bar.rb +0 -33
  80. data/test/test_mini_pie.rb +0 -25
  81. data/test/test_mini_side_bar.rb +0 -36
  82. data/test/test_net.rb +0 -231
  83. data/test/test_photo.rb +0 -41
  84. data/test/test_pie.rb +0 -194
  85. data/test/test_scatter.rb +0 -270
  86. data/test/test_scene.rb +0 -100
  87. data/test/test_side_bar.rb +0 -56
  88. data/test/test_sidestacked_bar.rb +0 -105
  89. data/test/test_spider.rb +0 -226
  90. data/test/test_stacked_area.rb +0 -52
  91. data/test/test_stacked_bar.rb +0 -68
@@ -1,3 +1,3 @@
1
1
  module Gruff
2
- VERSION = '0.7.0'
2
+ VERSION = '0.8.0'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gruff
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Geoffrey Grosenbach
@@ -9,28 +9,36 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-06-01 00:00:00.000000000 Z
12
+ date: 2020-04-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rmagick
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - "~>"
19
- - !ruby/object:Gem::Version
20
- version: '2.13'
21
18
  - - ">="
22
19
  - !ruby/object:Gem::Version
23
- version: 2.13.4
20
+ version: '0'
24
21
  type: :runtime
25
22
  prerelease: false
26
23
  version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ version: '0'
28
+ - !ruby/object:Gem::Dependency
29
+ name: rubocop
30
+ requirement: !ruby/object:Gem::Requirement
27
31
  requirements:
28
32
  - - "~>"
29
33
  - !ruby/object:Gem::Version
30
- version: '2.13'
31
- - - ">="
34
+ version: 0.81.0
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "~>"
32
40
  - !ruby/object:Gem::Version
33
- version: 2.13.4
41
+ version: 0.81.0
34
42
  - !ruby/object:Gem::Dependency
35
43
  name: rake
36
44
  requirement: !ruby/object:Gem::Requirement
@@ -66,14 +74,16 @@ executables: []
66
74
  extensions: []
67
75
  extra_rdoc_files: []
68
76
  files:
77
+ - ".editorconfig"
69
78
  - ".gitignore"
79
+ - ".rubocop.yml"
80
+ - ".rubocop_todo.yml"
70
81
  - ".travis.yml"
82
+ - CHANGELOG.md
71
83
  - Gemfile
72
- - History.txt
73
84
  - MIT-LICENSE
74
85
  - Manifest.txt
75
86
  - README.md
76
- - RELEASE.md
77
87
  - Rakefile
78
88
  - assets/bubble.png
79
89
  - assets/city_scene/background/0000.png
@@ -135,31 +145,6 @@ files:
135
145
  - rails_generators/gruff/gruff_generator.rb
136
146
  - rails_generators/gruff/templates/controller.rb
137
147
  - rails_generators/gruff/templates/functional_test.rb
138
- - test/gruff_test_case.rb
139
- - test/image_compare.rb
140
- - test/test_accumulator_bar.rb
141
- - test/test_area.rb
142
- - test/test_bar.rb
143
- - test/test_base.rb
144
- - test/test_bezier.rb
145
- - test/test_bullet.rb
146
- - test/test_dot.rb
147
- - test/test_labels_for_null_data.rb
148
- - test/test_legend.rb
149
- - test/test_line.rb
150
- - test/test_mini_bar.rb
151
- - test/test_mini_pie.rb
152
- - test/test_mini_side_bar.rb
153
- - test/test_net.rb
154
- - test/test_photo.rb
155
- - test/test_pie.rb
156
- - test/test_scatter.rb
157
- - test/test_scene.rb
158
- - test/test_side_bar.rb
159
- - test/test_sidestacked_bar.rb
160
- - test/test_spider.rb
161
- - test/test_stacked_area.rb
162
- - test/test_stacked_bar.rb
163
148
  homepage: https://github.com/topfunky/gruff
164
149
  licenses:
165
150
  - MIT
@@ -173,43 +158,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
173
158
  - - ">="
174
159
  - !ruby/object:Gem::Version
175
160
  version: 1.9.3
176
- - - "<"
177
- - !ruby/object:Gem::Version
178
- version: '3'
179
161
  required_rubygems_version: !ruby/object:Gem::Requirement
180
162
  requirements:
181
163
  - - ">="
182
164
  - !ruby/object:Gem::Version
183
165
  version: '0'
184
166
  requirements: []
185
- rubyforge_project:
186
- rubygems_version: 2.5.1
167
+ rubygems_version: 3.1.2
187
168
  signing_key:
188
169
  specification_version: 4
189
170
  summary: Beautiful graphs for one or multiple datasets.
190
- test_files:
191
- - test/gruff_test_case.rb
192
- - test/image_compare.rb
193
- - test/test_accumulator_bar.rb
194
- - test/test_area.rb
195
- - test/test_bar.rb
196
- - test/test_base.rb
197
- - test/test_bezier.rb
198
- - test/test_bullet.rb
199
- - test/test_dot.rb
200
- - test/test_labels_for_null_data.rb
201
- - test/test_legend.rb
202
- - test/test_line.rb
203
- - test/test_mini_bar.rb
204
- - test/test_mini_pie.rb
205
- - test/test_mini_side_bar.rb
206
- - test/test_net.rb
207
- - test/test_photo.rb
208
- - test/test_pie.rb
209
- - test/test_scatter.rb
210
- - test/test_scene.rb
211
- - test/test_side_bar.rb
212
- - test/test_sidestacked_bar.rb
213
- - test/test_spider.rb
214
- - test/test_stacked_area.rb
215
- - test/test_stacked_bar.rb
171
+ test_files: []
data/RELEASE.md DELETED
@@ -1,30 +0,0 @@
1
- Subject: [ANN] Gruff 0.5.1 released!
2
-
3
- The Gruff team is pleased to announce the release of Gruff 0.5.1.
4
-
5
- New in version 0.5.1:
6
-
7
- Skip packaging the test images. This reduces the gem from 20MB+ to
8
- 300KB+.
9
-
10
- Bugfixes:
11
-
12
- * Issue #92 Reduce the gem size by not shipping the test images.
13
-
14
- You can find a complete list of issues here:
15
-
16
- * https://github.com/topfunky/gruff/issues?state=closed&milestone=7
17
-
18
-
19
- Installation:
20
-
21
- gem install gruff
22
-
23
- You can find an introductory tutorial at
24
- https://github.com/topfunky/gruff
25
-
26
- Enjoy!
27
-
28
-
29
- --
30
- The Gruff Team
@@ -1,152 +0,0 @@
1
- $:.unshift(File.dirname(__FILE__) + '/../lib/')
2
-
3
- RMAGICK_BYPASS_VERSION_TEST = true
4
-
5
- require 'gruff'
6
- require 'fileutils'
7
-
8
- TEST_OUTPUT_DIR = File.dirname(__FILE__) + "/output#{'_java' if RUBY_PLATFORM == 'java'}"
9
- FileUtils.mkdir_p(TEST_OUTPUT_DIR)
10
- FileUtils.rm_f Dir[TEST_OUTPUT_DIR + '/*']
11
-
12
- require 'minitest/autorun'
13
- require 'minitest/reporters'
14
- Minitest::Reporters.use!
15
-
16
- class Gruff::Base
17
- alias :write_org :write
18
-
19
- def write(filename='graph.png')
20
- basefilename = File.basename(filename).split('.')[0..-2].join('.')
21
- extension = filename.slice(/\.[^\.]*$/)
22
- testfilename = File.join(TEST_OUTPUT_DIR, basefilename) + extension
23
- counter = 0
24
- while File.exist?(testfilename)
25
- counter += 1
26
- testfilename = File.join(TEST_OUTPUT_DIR, basefilename) + "-#{counter}#{extension}"
27
- end
28
- write_org(testfilename)
29
- end
30
- end
31
-
32
- class GruffTestCase < Minitest::Test
33
- def setup
34
- srand 42
35
- @datasets = [
36
- [:Jimmy, [25, 36, 86, 39, 25, 31, 79, 88]],
37
- [:Charles, [80, 54, 67, 54, 68, 70, 90, 95]],
38
- [:Julie, [22, 29, 35, 38, 36, 40, 46, 57]],
39
- [:Jane, [95, 95, 95, 90, 85, 80, 88, 100]],
40
- [:Philip, [90, 34, 23, 12, 78, 89, 98, 88]],
41
- [:Arthur, [5, 10, 13, 11, 6, 16, 22, 32]],
42
- ]
43
-
44
- @labels = {
45
- 0 => '5/6',
46
- 1 => '5/15',
47
- 2 => '5/24',
48
- 3 => '5/30',
49
- 4 => '6/4',
50
- 5 => '6/12',
51
- 6 => '6/21',
52
- 7 => '6/28',
53
- }
54
- end
55
-
56
- def setup_single_dataset
57
- @datasets = [
58
- [:Jimmy, [25, 36, 86]]
59
- ]
60
-
61
- @labels = {
62
- 0 => 'You',
63
- 1 => 'Average',
64
- 2 => 'Lifetime'
65
- }
66
- end
67
-
68
- def setup_wide_dataset
69
- @datasets = [
70
- ['Auto', 25],
71
- ['Food', 5],
72
- ['Entertainment', 15]
73
- ]
74
-
75
- @labels = {0 => 'This Month'}
76
- end
77
-
78
- def test_dummy
79
- assert true
80
- end
81
-
82
- protected
83
-
84
- # Generate graphs at several sizes.
85
- #
86
- # Also writes the graph to disk.
87
- #
88
- # graph_sized 'bar_basic' do |g|
89
- # g.data('students', [1, 2, 3, 4])
90
- # end
91
- #
92
- def graph_sized(filename, sizes=['', 400])
93
- class_name = self.class.name.gsub(/^TestGruff/, '')
94
- Array(sizes).each do |size|
95
- g = instance_eval("Gruff::#{class_name}.new #{size}")
96
- g.title = "#{class_name} Graph"
97
- yield g
98
- write_test_file g, "#{filename}_#{size}.png"
99
- end
100
- end
101
-
102
- def write_test_file(graph, filename)
103
- testfilename = [TEST_OUTPUT_DIR, filename].join('/')
104
- basefilename = filename.split('.')[0..-2].join('.')
105
- extension = filename.slice(/\..*$/)
106
- counter = 0
107
- while File.exist? testfilename
108
- counter += 1
109
- testfilename = [TEST_OUTPUT_DIR, basefilename].join('/') + "-#{counter}#{extension}"
110
- end
111
- graph.write(testfilename)
112
- end
113
-
114
- ##
115
- # Example:
116
- #
117
- # setup_basic_graph Gruff::Pie, 400
118
- #
119
- def setup_basic_graph(*args)
120
- klass, size = Gruff::Bar, 400
121
- # Allow args to be klass, size or just klass or just size.
122
- #
123
- # TODO Refactor
124
- case args.length
125
- when 1
126
- case args[0]
127
- when Fixnum
128
- size = args[0]
129
- klass = eval("Gruff::#{self.class.name.gsub(/^TestGruff/, '')}")
130
- when String
131
- size = args[0]
132
- klass = eval("Gruff::#{self.class.name.gsub(/^TestGruff/, '')}")
133
- else
134
- klass = args[0]
135
- end
136
- when 2
137
- klass, size = args[0], args[1]
138
- end
139
-
140
- g = klass.new(size)
141
- g.title = 'My Bar Graph'
142
- g.labels = @labels
143
- g.font = '/Library/Fonts/Verdana.ttf'
144
-
145
-
146
- @datasets.each do |data|
147
- g.data(data[0], data[1])
148
- end
149
- g
150
- end
151
-
152
- end
@@ -1,58 +0,0 @@
1
- #!ruby
2
-
3
- require 'chunky_png'
4
-
5
- class ImageCompare
6
- include ChunkyPNG::Color
7
-
8
- def self.compare(file_name, old_file_name)
9
- name = file_name.chomp('.png')
10
- org_file_name = "#{name}_0.png~"
11
- new_file_name = "#{name}_1.png~"
12
-
13
- return nil unless File.exists? old_file_name
14
- images = [
15
- ChunkyPNG::Image.from_file(old_file_name),
16
- ChunkyPNG::Image.from_file(file_name),
17
- ]
18
-
19
- sizes = images.map(&:width).uniq + images.map(&:height).uniq
20
- if sizes.size != 2
21
- logger.warn "Image size has changed for #{name}: #{sizes}"
22
- return nil
23
- end
24
-
25
- diff = []
26
- images.first.height.times do |y|
27
- images.first.row(y).each_with_index do |pixel, x|
28
- unless pixel == images.last[x, y]
29
- diff << [x, y]
30
- end
31
- end
32
- end
33
-
34
- if diff.empty?
35
- File.delete(org_file_name) if File.exists? org_file_name
36
- File.delete(new_file_name) if File.exists? new_file_name
37
- return false
38
- end
39
-
40
- x, y = diff.map { |xy| xy[0] }, diff.map { |xy| xy[1] }
41
- (1..2).each do |i|
42
- images.each do |image|
43
- image.rect(x.min - i, y.min - i, x.max + i, y.max + i, ChunkyPNG::Color.rgb(255, 0, 0))
44
- end
45
- end
46
- images.first.save(org_file_name)
47
- images.last.save(new_file_name)
48
- true
49
- end
50
- end
51
-
52
- if $0 == __FILE__
53
- unless ARGV.size == 2
54
- puts "Usage: #$0 <image1> <image2>"
55
- exit 1
56
- end
57
- ImageCompare.compare(ARGV[0], ARGV[1])
58
- end
@@ -1,51 +0,0 @@
1
- require File.dirname(__FILE__) + '/gruff_test_case'
2
-
3
- class TestGruffAccumulatorBar < GruffTestCase
4
-
5
- # TODO Delete old output files once when starting tests
6
-
7
- def setup
8
- super
9
- @datasets = [
10
- (1..20).to_a.map { rand(10) }
11
- ]
12
- end
13
-
14
- def test_accumulator
15
- g = Gruff::AccumulatorBar.new 500
16
- g.title = 'Your Savings'
17
- g.hide_legend = true
18
-
19
- # g.font = File.expand_path(File.dirname(__FILE__) + "/../assets/fonts/ATMA____.TTF")
20
-
21
- g.marker_font_size = 18
22
-
23
- g.theme = {
24
- :colors => ['#aedaa9', '#12a702'],
25
- :marker_color => '#dddddd',
26
- :font_color => 'black',
27
- :background_colors => 'white'
28
- # :background_image => File.expand_path(File.dirname(__FILE__) + "/../assets/backgrounds/43things.png")
29
- }
30
-
31
- # Attempt at negative numbers
32
- # g.data 'Savings', (1..20).to_a.map { rand(10) * (rand(2) > 0 ? 1 : -1) }
33
- g.data 'Savings', (1..12).to_a.map { rand(100) }
34
- g.labels = (0..11).to_a.inject({}) {|memo, index| {index => '12-26'}.merge(memo)}
35
-
36
- g.maximum_value = 1000
37
- g.minimum_value = 0
38
-
39
- g.write('test/output/accum_bar.png')
40
- end
41
-
42
- def test_too_many_args
43
- assert_raises(Gruff::IncorrectNumberOfDatasetsException) {
44
- g = Gruff::AccumulatorBar.new
45
- g.data 'First', [1,1,1]
46
- g.data 'Too Many', [1,1,1]
47
- g.write('test/output/_SHOULD_NOT_ACTUALLY_BE_WRITTEN.png')
48
- }
49
- end
50
-
51
- end