bumpspark 1.1.1 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. data/.document +2 -4
  2. data/.gitignore +16 -3
  3. data/.rspec +2 -0
  4. data/.ruby-version +1 -0
  5. data/.rvmrc +1 -0
  6. data/.travis.yml +5 -0
  7. data/Gemfile +4 -0
  8. data/{LICENSE → LICENSE.txt} +3 -1
  9. data/README.md +91 -0
  10. data/Rakefile +5 -59
  11. data/bumpspark.gemspec +21 -68
  12. data/exe/bumpspark +7 -0
  13. data/lib/bumpspark.rb +2 -8
  14. data/lib/bumpspark/formats/data_uri.rb +24 -0
  15. data/lib/bumpspark/graph.rb +7 -1
  16. data/lib/bumpspark/helper.rb +17 -0
  17. data/lib/bumpspark/railtie.rb +10 -0
  18. data/lib/bumpspark/version.rb +3 -0
  19. data/spec/dummy/Rakefile +7 -0
  20. data/spec/dummy/app/controllers/application_controller.rb +3 -0
  21. data/spec/dummy/app/controllers/pages_controller.rb +4 -0
  22. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  23. data/spec/dummy/app/helpers/pages_helper.rb +2 -0
  24. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  25. data/spec/dummy/app/views/pages/home.html.erb +6 -0
  26. data/spec/dummy/config.ru +4 -0
  27. data/spec/dummy/config/application.rb +70 -0
  28. data/spec/dummy/config/boot.rb +6 -0
  29. data/spec/dummy/config/database.yml +25 -0
  30. data/spec/dummy/config/environment.rb +5 -0
  31. data/spec/dummy/config/environments/development.rb +37 -0
  32. data/spec/dummy/config/environments/test.rb +37 -0
  33. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  34. data/spec/dummy/config/initializers/inflections.rb +15 -0
  35. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  36. data/spec/dummy/config/initializers/secret_token.rb +7 -0
  37. data/spec/dummy/config/initializers/session_store.rb +8 -0
  38. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  39. data/spec/dummy/config/locales/en.yml +5 -0
  40. data/spec/dummy/config/routes.rb +59 -0
  41. data/spec/dummy/log/.gitkeep +0 -0
  42. data/spec/dummy/public/404.html +26 -0
  43. data/spec/dummy/public/422.html +26 -0
  44. data/spec/dummy/public/500.html +25 -0
  45. data/spec/dummy/public/favicon.ico +0 -0
  46. data/spec/dummy/public/robots.txt +5 -0
  47. data/spec/dummy/script/rails +6 -0
  48. data/spec/helpers/application_helper_spec.rb +12 -0
  49. data/spec/lib/bumpspark/graph_spec.rb +30 -0
  50. data/spec/lib/bumpspark/helper_spec.rb +21 -0
  51. data/spec/spec_helper.rb +22 -0
  52. data/spec/support/matchers/valid_png.rb +9 -0
  53. metadata +190 -87
  54. data/README.markdown +0 -74
  55. data/VERSION +0 -1
  56. data/lib/bumpspark_helper.rb +0 -19
  57. data/rails/init.rb +0 -1
  58. data/test/bumpspark_helper_test.rb +0 -23
  59. data/test/bumpspark_test.rb +0 -32
  60. data/test/test_helper.rb +0 -10
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 1.1.1
@@ -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
@@ -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
@@ -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
@@ -1,10 +0,0 @@
1
- require 'rubygems'
2
- require 'test/unit'
3
- require 'shoulda'
4
-
5
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
6
- $LOAD_PATH.unshift(File.dirname(__FILE__))
7
- require 'bumpspark'
8
-
9
- class Test::Unit::TestCase
10
- end