bumpspark 1.1.1 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- 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
data/VERSION
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
1.1.1
|
data/lib/bumpspark_helper.rb
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
require 'base64'
|
2
|
-
|
3
|
-
module BumpsparkHelper
|
4
|
-
|
5
|
-
# Generate a "bumpspark"-style sparkline image tag
|
6
|
-
#
|
7
|
-
# call-seq:
|
8
|
-
# <%= bumpspark_tag([20, 23, 12, 23]) %>
|
9
|
-
def bumpspark_tag(numbers, html_opts={})
|
10
|
-
graph = Bumpspark::Graph.new(numbers)
|
11
|
-
tag(:img, html_opts.merge(:src => bumpspark_tag_src(graph)))
|
12
|
-
end
|
13
|
-
|
14
|
-
def bumpspark_tag_src(graph) #:nodoc:
|
15
|
-
data = Base64.encode64(graph.to_png).delete("\n")
|
16
|
-
return "data:image/png;base64,#{CGI.escape(data)}"
|
17
|
-
end
|
18
|
-
|
19
|
-
end
|
data/rails/init.rb
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
ActionView::Base.send(:include, BumpsparkHelper)
|
@@ -1,23 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
require 'activesupport'
|
4
|
-
require 'action_view'
|
5
|
-
require 'action_controller'
|
6
|
-
|
7
|
-
require 'bumpspark_helper'
|
8
|
-
|
9
|
-
BumpsparkHelper.send(:include, ActionView::Helpers::TagHelper)
|
10
|
-
BumpsparkHelper.send(:include, ActionView::Helpers::AssetTagHelper)
|
11
|
-
|
12
|
-
class BumpsparkHelperTest < Test::Unit::TestCase
|
13
|
-
|
14
|
-
include BumpsparkHelper
|
15
|
-
include ActionView::Helpers::AssetTagHelper
|
16
|
-
|
17
|
-
should "generate an image" do
|
18
|
-
tag = bumpspark_tag([1, 2, 3])
|
19
|
-
assert tag.include?('<img'), tag
|
20
|
-
assert tag.include?('src'), tag
|
21
|
-
end
|
22
|
-
|
23
|
-
end
|
data/test/bumpspark_test.rb
DELETED
@@ -1,32 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
require 'rmagick'
|
3
|
-
|
4
|
-
class BumpsparkTest < Test::Unit::TestCase
|
5
|
-
|
6
|
-
context "generating pngs" do
|
7
|
-
|
8
|
-
should "work for an empty bumpspark" do
|
9
|
-
assert_valid_png []
|
10
|
-
end
|
11
|
-
|
12
|
-
should "work for a bumpspark with one datapoint" do
|
13
|
-
assert_valid_png [1]
|
14
|
-
end
|
15
|
-
|
16
|
-
should "work for a bumpspark with multiple datapoints" do
|
17
|
-
assert_valid_png [1, 2, 3]
|
18
|
-
end
|
19
|
-
|
20
|
-
end
|
21
|
-
|
22
|
-
def assert_valid_png(data)
|
23
|
-
image = Magick::Image.from_blob(generate(data)).first
|
24
|
-
assert image, "No valid image generated"
|
25
|
-
assert_equal "image/png", image.mime_type, "Image has wrong mime type"
|
26
|
-
end
|
27
|
-
|
28
|
-
def generate(data, format=:png)
|
29
|
-
Bumpspark::Graph.new(data).send("to_#{format}")
|
30
|
-
end
|
31
|
-
|
32
|
-
end
|
data/test/test_helper.rb
DELETED