bumpspark 1.1.1 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.document +2 -4
- data/.gitignore +16 -3
- data/.rspec +2 -0
- data/.ruby-version +1 -0
- data/.rvmrc +1 -0
- data/.travis.yml +5 -0
- data/Gemfile +4 -0
- data/{LICENSE → LICENSE.txt} +3 -1
- data/README.md +91 -0
- data/Rakefile +5 -59
- data/bumpspark.gemspec +21 -68
- data/exe/bumpspark +7 -0
- data/lib/bumpspark.rb +2 -8
- data/lib/bumpspark/formats/data_uri.rb +24 -0
- data/lib/bumpspark/graph.rb +7 -1
- data/lib/bumpspark/helper.rb +17 -0
- data/lib/bumpspark/railtie.rb +10 -0
- data/lib/bumpspark/version.rb +3 -0
- data/spec/dummy/Rakefile +7 -0
- data/spec/dummy/app/controllers/application_controller.rb +3 -0
- data/spec/dummy/app/controllers/pages_controller.rb +4 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/helpers/pages_helper.rb +2 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/app/views/pages/home.html.erb +6 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/config/application.rb +70 -0
- data/spec/dummy/config/boot.rb +6 -0
- data/spec/dummy/config/database.yml +25 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +37 -0
- data/spec/dummy/config/environments/test.rb +37 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/inflections.rb +15 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/secret_token.rb +7 -0
- data/spec/dummy/config/initializers/session_store.rb +8 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +5 -0
- data/spec/dummy/config/routes.rb +59 -0
- data/spec/dummy/log/.gitkeep +0 -0
- data/spec/dummy/public/404.html +26 -0
- data/spec/dummy/public/422.html +26 -0
- data/spec/dummy/public/500.html +25 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/public/robots.txt +5 -0
- data/spec/dummy/script/rails +6 -0
- data/spec/helpers/application_helper_spec.rb +12 -0
- data/spec/lib/bumpspark/graph_spec.rb +30 -0
- data/spec/lib/bumpspark/helper_spec.rb +21 -0
- data/spec/spec_helper.rb +22 -0
- data/spec/support/matchers/valid_png.rb +9 -0
- metadata +190 -87
- data/README.markdown +0 -74
- data/VERSION +0 -1
- data/lib/bumpspark_helper.rb +0 -19
- data/rails/init.rb +0 -1
- data/test/bumpspark_helper_test.rb +0 -23
- data/test/bumpspark_test.rb +0 -32
- data/test/test_helper.rb +0 -10
@@ -0,0 +1,12 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe ApplicationHelper do
|
4
|
+
describe "#bumpspark_tag" do
|
5
|
+
it 'is an image tag' do
|
6
|
+
expect(helper.bumpspark_tag([1, 2, 3])).to include("<img")
|
7
|
+
end
|
8
|
+
it 'contains a data uri' do
|
9
|
+
expect(helper.bumpspark_tag([1, 2, 3])).to include("data:image/png")
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Bumpspark::Graph do
|
4
|
+
|
5
|
+
subject do
|
6
|
+
Bumpspark::Graph.new(data).send("to_#{format}")
|
7
|
+
end
|
8
|
+
|
9
|
+
context "generating pngs" do
|
10
|
+
|
11
|
+
let(:format) { 'png' }
|
12
|
+
|
13
|
+
context "for an empty bumpspark" do
|
14
|
+
let(:data) { [] }
|
15
|
+
it { should be_a_valid_png }
|
16
|
+
end
|
17
|
+
|
18
|
+
context "for a bumpspark with one datapoint" do
|
19
|
+
let(:data) { [1] }
|
20
|
+
it { should be_a_valid_png }
|
21
|
+
end
|
22
|
+
|
23
|
+
context "for a bumpspark with multiple datapoints" do
|
24
|
+
let(:data) { [1, 2, 3] }
|
25
|
+
it { should be_a_valid_png }
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
require 'bumpspark/helper'
|
4
|
+
|
5
|
+
describe Bumpspark::Helper do
|
6
|
+
|
7
|
+
let(:object) { Object.new }
|
8
|
+
before { object.extend(Bumpspark::Helper) }
|
9
|
+
|
10
|
+
context 'generating an image' do
|
11
|
+
|
12
|
+
it 'creates an image tag' do
|
13
|
+
object.should_receive(:tag) do |name, options|
|
14
|
+
expect(name).to eq(:img)
|
15
|
+
expect(options[:src]).to include("data:image/png;base64")
|
16
|
+
end
|
17
|
+
object.bumpspark_tag([1, 2, 3])
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
ENV["RAILS_ENV"] ||= 'test'
|
2
|
+
require_relative 'dummy/config/environment'
|
3
|
+
require 'rspec/rails'
|
4
|
+
require 'rspec/autorun'
|
5
|
+
|
6
|
+
Dir.glob('spec/support/**/*.rb') do |filename|
|
7
|
+
require File.expand_path(filename)
|
8
|
+
end
|
9
|
+
|
10
|
+
RSpec.configure do |config|
|
11
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
12
|
+
config.run_all_when_everything_filtered = true
|
13
|
+
config.filter_run :focus
|
14
|
+
|
15
|
+
config.mock_with :rspec
|
16
|
+
|
17
|
+
# Run specs in random order to surface order dependencies. If you find an
|
18
|
+
# order dependency and want to debug it, you can fix the order by providing
|
19
|
+
# the seed, which is printed after each run.
|
20
|
+
# --seed 1234
|
21
|
+
config.order = 'random'
|
22
|
+
end
|
metadata
CHANGED
@@ -1,114 +1,217 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: bumpspark
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 2.0.0
|
5
|
+
prerelease:
|
5
6
|
platform: ruby
|
6
|
-
authors:
|
7
|
+
authors:
|
7
8
|
- Bruce Williams
|
8
9
|
autorequire:
|
9
|
-
bindir:
|
10
|
+
bindir: exe
|
10
11
|
cert_chain: []
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
12
|
+
date: 2013-01-26 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rspec
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
17
22
|
type: :development
|
18
|
-
|
19
|
-
version_requirements: !ruby/object:Gem::Requirement
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
- !ruby/object:Gem::Dependency
|
26
|
-
name:
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rspec-rails
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
27
38
|
type: :development
|
28
|
-
|
29
|
-
version_requirements: !ruby/object:Gem::Requirement
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
- !ruby/object:Gem::Dependency
|
36
|
-
name:
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: chunky_png
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
37
54
|
type: :development
|
38
|
-
|
39
|
-
version_requirements: !ruby/object:Gem::Requirement
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
- !ruby/object:Gem::Dependency
|
46
|
-
name:
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: rake
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
47
70
|
type: :development
|
48
|
-
|
49
|
-
version_requirements: !ruby/object:Gem::Requirement
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: rails
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - '='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: 3.2.11
|
86
|
+
type: :development
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - '='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: 3.2.11
|
94
|
+
description: Generates transparent PNG and Data URI bumpspark-style sparklines. Use
|
95
|
+
from Ruby directly or as a Rails helper.
|
96
|
+
email:
|
97
|
+
- brwcodes@gmail.com
|
98
|
+
executables:
|
99
|
+
- bumpspark
|
59
100
|
extensions: []
|
60
|
-
|
61
|
-
|
62
|
-
- LICENSE
|
63
|
-
- README.markdown
|
64
|
-
files:
|
101
|
+
extra_rdoc_files: []
|
102
|
+
files:
|
65
103
|
- .document
|
66
104
|
- .gitignore
|
67
|
-
-
|
68
|
-
-
|
105
|
+
- .rspec
|
106
|
+
- .ruby-version
|
107
|
+
- .rvmrc
|
108
|
+
- .travis.yml
|
109
|
+
- Gemfile
|
110
|
+
- LICENSE.txt
|
111
|
+
- README.md
|
69
112
|
- Rakefile
|
70
113
|
- TODO.markdown
|
71
|
-
- VERSION
|
72
114
|
- bumpspark.gemspec
|
115
|
+
- exe/bumpspark
|
73
116
|
- lib/bumpspark.rb
|
117
|
+
- lib/bumpspark/formats/data_uri.rb
|
74
118
|
- lib/bumpspark/formats/png.rb
|
75
119
|
- lib/bumpspark/formats/string.rb
|
76
120
|
- lib/bumpspark/graph.rb
|
121
|
+
- lib/bumpspark/helper.rb
|
122
|
+
- lib/bumpspark/railtie.rb
|
77
123
|
- lib/bumpspark/scale.rb
|
78
|
-
- lib/
|
79
|
-
-
|
80
|
-
-
|
81
|
-
-
|
82
|
-
-
|
83
|
-
|
124
|
+
- lib/bumpspark/version.rb
|
125
|
+
- spec/dummy/Rakefile
|
126
|
+
- spec/dummy/app/controllers/application_controller.rb
|
127
|
+
- spec/dummy/app/controllers/pages_controller.rb
|
128
|
+
- spec/dummy/app/helpers/application_helper.rb
|
129
|
+
- spec/dummy/app/helpers/pages_helper.rb
|
130
|
+
- spec/dummy/app/views/layouts/application.html.erb
|
131
|
+
- spec/dummy/app/views/pages/home.html.erb
|
132
|
+
- spec/dummy/config.ru
|
133
|
+
- spec/dummy/config/application.rb
|
134
|
+
- spec/dummy/config/boot.rb
|
135
|
+
- spec/dummy/config/database.yml
|
136
|
+
- spec/dummy/config/environment.rb
|
137
|
+
- spec/dummy/config/environments/development.rb
|
138
|
+
- spec/dummy/config/environments/test.rb
|
139
|
+
- spec/dummy/config/initializers/backtrace_silencers.rb
|
140
|
+
- spec/dummy/config/initializers/inflections.rb
|
141
|
+
- spec/dummy/config/initializers/mime_types.rb
|
142
|
+
- spec/dummy/config/initializers/secret_token.rb
|
143
|
+
- spec/dummy/config/initializers/session_store.rb
|
144
|
+
- spec/dummy/config/initializers/wrap_parameters.rb
|
145
|
+
- spec/dummy/config/locales/en.yml
|
146
|
+
- spec/dummy/config/routes.rb
|
147
|
+
- spec/dummy/log/.gitkeep
|
148
|
+
- spec/dummy/public/404.html
|
149
|
+
- spec/dummy/public/422.html
|
150
|
+
- spec/dummy/public/500.html
|
151
|
+
- spec/dummy/public/favicon.ico
|
152
|
+
- spec/dummy/public/robots.txt
|
153
|
+
- spec/dummy/script/rails
|
154
|
+
- spec/helpers/application_helper_spec.rb
|
155
|
+
- spec/lib/bumpspark/graph_spec.rb
|
156
|
+
- spec/lib/bumpspark/helper_spec.rb
|
157
|
+
- spec/spec_helper.rb
|
158
|
+
- spec/support/matchers/valid_png.rb
|
84
159
|
homepage: http://github.com/bruce/bumpspark
|
85
160
|
licenses: []
|
86
|
-
|
87
161
|
post_install_message:
|
88
|
-
rdoc_options:
|
89
|
-
|
90
|
-
require_paths:
|
162
|
+
rdoc_options: []
|
163
|
+
require_paths:
|
91
164
|
- lib
|
92
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
165
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
166
|
+
none: false
|
167
|
+
requirements:
|
168
|
+
- - ! '>='
|
169
|
+
- !ruby/object:Gem::Version
|
170
|
+
version: '0'
|
171
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
172
|
+
none: false
|
173
|
+
requirements:
|
174
|
+
- - ! '>='
|
175
|
+
- !ruby/object:Gem::Version
|
176
|
+
version: '0'
|
104
177
|
requirements: []
|
105
|
-
|
106
|
-
|
107
|
-
rubygems_version: 1.3.5
|
178
|
+
rubyforge_project:
|
179
|
+
rubygems_version: 1.8.23
|
108
180
|
signing_key:
|
109
181
|
specification_version: 3
|
110
|
-
summary: Generates
|
111
|
-
test_files:
|
112
|
-
-
|
113
|
-
-
|
114
|
-
-
|
182
|
+
summary: Generates bumpspark-style sparklines for Ruby & Rails
|
183
|
+
test_files:
|
184
|
+
- spec/dummy/Rakefile
|
185
|
+
- spec/dummy/app/controllers/application_controller.rb
|
186
|
+
- spec/dummy/app/controllers/pages_controller.rb
|
187
|
+
- spec/dummy/app/helpers/application_helper.rb
|
188
|
+
- spec/dummy/app/helpers/pages_helper.rb
|
189
|
+
- spec/dummy/app/views/layouts/application.html.erb
|
190
|
+
- spec/dummy/app/views/pages/home.html.erb
|
191
|
+
- spec/dummy/config.ru
|
192
|
+
- spec/dummy/config/application.rb
|
193
|
+
- spec/dummy/config/boot.rb
|
194
|
+
- spec/dummy/config/database.yml
|
195
|
+
- spec/dummy/config/environment.rb
|
196
|
+
- spec/dummy/config/environments/development.rb
|
197
|
+
- spec/dummy/config/environments/test.rb
|
198
|
+
- spec/dummy/config/initializers/backtrace_silencers.rb
|
199
|
+
- spec/dummy/config/initializers/inflections.rb
|
200
|
+
- spec/dummy/config/initializers/mime_types.rb
|
201
|
+
- spec/dummy/config/initializers/secret_token.rb
|
202
|
+
- spec/dummy/config/initializers/session_store.rb
|
203
|
+
- spec/dummy/config/initializers/wrap_parameters.rb
|
204
|
+
- spec/dummy/config/locales/en.yml
|
205
|
+
- spec/dummy/config/routes.rb
|
206
|
+
- spec/dummy/log/.gitkeep
|
207
|
+
- spec/dummy/public/404.html
|
208
|
+
- spec/dummy/public/422.html
|
209
|
+
- spec/dummy/public/500.html
|
210
|
+
- spec/dummy/public/favicon.ico
|
211
|
+
- spec/dummy/public/robots.txt
|
212
|
+
- spec/dummy/script/rails
|
213
|
+
- spec/helpers/application_helper_spec.rb
|
214
|
+
- spec/lib/bumpspark/graph_spec.rb
|
215
|
+
- spec/lib/bumpspark/helper_spec.rb
|
216
|
+
- spec/spec_helper.rb
|
217
|
+
- spec/support/matchers/valid_png.rb
|
data/README.markdown
DELETED
@@ -1,74 +0,0 @@
|
|
1
|
-
# Bumpspark
|
2
|
-
|
3
|
-
Generate "bumpspark"-style sparklines from Ruby & Rails.
|
4
|
-
|
5
|
-
Note: This library is based on _why's `bumpspark' code, originally discussed and
|
6
|
-
collaborated on at [RedHanded] [1]. It has been refactored and built out as
|
7
|
-
a gem suitable for inclusion in Rails projects (and standalone Ruby code).
|
8
|
-
|
9
|
-
Bumpsparks are sparklines which show discrete data points and highlight
|
10
|
-
extremes. If you like Tufte and _why, you'll probably like these.
|
11
|
-
|
12
|
-
## Credits
|
13
|
-
|
14
|
-
Thanks to the various collaborators on _why's original post:
|
15
|
-
|
16
|
-
* _why (concept, BMP implementation)
|
17
|
-
* jzp (png)
|
18
|
-
* MenTaLguY (transparency)
|
19
|
-
|
20
|
-
## Installation
|
21
|
-
|
22
|
-
Since 1.1.0, bumpspark is only released on gemcutter. To install, you can setup gemcutter as your default gem source.
|
23
|
-
|
24
|
-
$ gem install gemcutter
|
25
|
-
$ gem tumble
|
26
|
-
|
27
|
-
Then you can install it:
|
28
|
-
|
29
|
-
$ gem install bumpspark
|
30
|
-
|
31
|
-
You can also just get it in one line:
|
32
|
-
|
33
|
-
$ gem install bumpspark -s http://gemcutter.org
|
34
|
-
|
35
|
-
## Usage
|
36
|
-
|
37
|
-
### From Rails
|
38
|
-
|
39
|
-
1. Include the gem as a gem dependency in `config/environment.rb`
|
40
|
-
2. Use `bumpspark_tag` from your views or helpers, passing it the data points
|
41
|
-
you'd like graphed.
|
42
|
-
|
43
|
-
<%= bumpspark_tag [12, 34, 12, 42, 12, 23] %>
|
44
|
-
|
45
|
-
## From Ruby
|
46
|
-
|
47
|
-
Simply create a `Bumpspark::Graph` instance and call `to_png` on it.
|
48
|
-
|
49
|
-
require 'bumpspark'
|
50
|
-
|
51
|
-
graph = Bumpspark::Graph.new [12, 34, 12, 42, 12, 23]
|
52
|
-
|
53
|
-
File.open('bumpspark.png', 'wb') do |file|
|
54
|
-
file.write graph.to_png
|
55
|
-
end
|
56
|
-
|
57
|
-
## Note on Patches/Pull Requests
|
58
|
-
|
59
|
-
Please check the TODO file for information on things that need doing.
|
60
|
-
|
61
|
-
* Fork the project.
|
62
|
-
* Make your feature addition or bug fix.
|
63
|
-
* Add tests for it. This is important so I don't break it in a
|
64
|
-
future version unintentionally.
|
65
|
-
* Commit, do not mess with rakefile, version, or history.
|
66
|
-
(if you want to have your own version, that is fine but
|
67
|
-
bump version in a commit by itself I can ignore when I pull)
|
68
|
-
* Send me a pull request. Bonus points for topic branches.
|
69
|
-
|
70
|
-
## Copyright
|
71
|
-
|
72
|
-
Copyright (c) 2009 Bruce Williams, et al. See LICENSE for details.
|
73
|
-
|
74
|
-
[1]: http://redhanded.hobix.com/inspect/sparklinesForMinimalists.html
|