lazy_high_charts 1.0.8 → 1.0.9

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ Mar 19,2011
2
+ * refactor my gem code,dumped to 1.0.9
3
+
1
4
  Nov 30,2010
2
5
  * dumped to gem 0.0.1
3
6
 
data/README.md CHANGED
@@ -1,19 +1,11 @@
1
1
  LazyHighCharts
2
2
  =======
3
- = update(Dec 4,2010)
4
- bumping version to gem 0.0.3
5
-
6
- - Test Environment
7
- ruby 1.9.2p0 (2010-08-18 revision 29036) [x86_64-darwin10.4.0]
8
- rspec 2.0
9
- rails 3.0.1
10
- - Result(autotest)
11
- Finished in 0.01502 seconds
12
- 9 examples, 0 failures
3
+ LazyHighCharts is Rails 3.x Gem for displaying Highcharts graphs.
13
4
 
14
- Attention:
15
- this gem Only support Rails 3.x
5
+ Compatibility:
6
+ lazy_high_charts 1.x is only compatible with Rails 3.x
16
7
 
8
+ Current Version: 1.0.9
17
9
  Usage
18
10
  =======
19
11
  In your Gemfile, add this line:
@@ -74,10 +66,9 @@ Usage
74
66
 
75
67
 
76
68
 
77
- h2.Contributors
78
- LayHighCharts gem is maintained by "Deshi Xiao":https://github.com/xiaods
79
-
80
- @git shortlog -n -s --no-merges@
81
-
69
+ Contributors
70
+ =======
71
+ LazyHighCharts gem is maintained by "Deshi Xiao":https://github.com/xiaods
72
+ git shortlog -n -s --no-merges
82
73
 
83
74
  Copyright (c) 2010 Miguel Michelson Martinez, released under the MIT license
@@ -17,16 +17,16 @@ Gem::Specification.new do |s|
17
17
  s.extra_rdoc_files = [ "README.md", "CHANGELOG.md" ]
18
18
  s.rdoc_options = [ "--charset=UTF-8" ]
19
19
 
20
- s.required_rubygems_version = ">= 1.3.6"
20
+ s.required_rubygems_version = "~> 1.3"
21
21
 
22
22
  s.add_dependency "bundler", "~> 1.0"
23
23
 
24
- s.add_development_dependency "webrat", "~> 0.7"
24
+ s.add_development_dependency "webrat","~> 0.7"
25
25
  s.add_development_dependency "rspec", "~> 2.0"
26
26
  s.add_development_dependency "rails", "~> 3.0"
27
27
 
28
28
  s.description = <<-DESC
29
- Lazy_high_charts provides a Rails interface for utilize highcharts to displaying graphs.
29
+ lazy_high_charts is a Rails 3.x gem for displaying Highcharts graphs.
30
30
  DESC
31
31
 
32
32
  s.files = `git ls-files`.split("\n")
@@ -1,7 +1,6 @@
1
1
  module LazyHighCharts
2
2
  class InstallGenerator < Rails::Generators::Base
3
3
  desc "This generator install highcharts javascripts"
4
- @@version = "2.1.1"
5
4
 
6
5
  def install_highcharts
7
6
  say_status("installing", "Highcharts javascript (github HEAD)", :green)
@@ -11,4 +10,4 @@ module LazyHighCharts
11
10
  end
12
11
 
13
12
  end
14
- end
13
+ end
@@ -1,5 +1,5 @@
1
1
  require 'lazy_high_charts/high_chart'
2
- require 'lazy_high_charts/high_charts_helper.rb'
2
+ require 'lazy_high_charts/layout_helper.rb'
3
3
 
4
4
  require File.join(File.dirname(__FILE__), *%w[lazy_high_charts railtie]) if defined?(::Rails::Railtie)
5
5
 
@@ -1,6 +1,5 @@
1
1
  module LazyHighCharts
2
2
  class HighChart
3
- CANVAS_DEFAULT_HTML_OPTIONS = {:style => "height: 300px, width:615px" }
4
3
  SERIES_OPTIONS = %w(lines points bars shadowSize colors)
5
4
 
6
5
  attr_accessor :data, :options, :placeholder, :html_options
@@ -15,7 +14,7 @@ module LazyHighCharts
15
14
  high_chart.data ||= []
16
15
  high_chart.options ||= {}
17
16
  high_chart.defaults_options
18
- high_chart.html_options = html_opts.reverse_merge(CANVAS_DEFAULT_HTML_OPTIONS)
17
+ high_chart.html_options = html_opts
19
18
  high_chart.canvas = canvas if canvas
20
19
  yield high_chart if block_given?
21
20
  end
@@ -0,0 +1,51 @@
1
+ # coding: utf-8
2
+
3
+ module LazyHighCharts
4
+ module LayoutHelper
5
+
6
+ def high_chart(placeholder, object, &block)
7
+ if object
8
+ object.html_options.merge!({:id=>placeholder})
9
+ object.options[:chart][:renderTo] = placeholder
10
+ high_graph(placeholder,object , &block).concat(content_tag("div","", object.html_options))
11
+ end
12
+ end
13
+
14
+ def high_graph(placeholder, object, &block)
15
+ @options = {
16
+ "chart" => object.options[:chart],
17
+ "title" => object.options[:title],
18
+ "legend" => object.options[:legend],
19
+ "xAxis" => object.options[:xAxis],
20
+ "yAxis" => object.options[:yAxis],
21
+ "credits" => object.options[:credits],
22
+ "plotOptions" => object.options[:plotOptions],
23
+ "series" => object.options[:series],
24
+ "subtitle" => object.options[:subtitle]
25
+ }.reject{|k,v| v.nil?}
26
+
27
+ graph =<<-EOJS
28
+ <script type="text/javascript">
29
+ jQuery(function() {
30
+ var options = { #{format_options} };
31
+ #{capture(&block) if block_given?}
32
+ var chart = new Highcharts.Chart(options);
33
+ });
34
+ </script>
35
+ EOJS
36
+
37
+ return raw(graph)
38
+
39
+ end
40
+
41
+ def format_options
42
+ options = []
43
+ @options.each do |k,v|
44
+ options << "#{k}: #{v.to_json}"
45
+ end
46
+ options << "tooltip:{}"
47
+ options.join(', ')
48
+ end
49
+
50
+ end
51
+ end
@@ -1,15 +1,12 @@
1
1
  # encoding: utf-8
2
2
 
3
- require 'lazy_high_charts'
4
- require 'lazy_high_charts/high_charts_helper.rb'
5
-
6
- require 'rails'
7
-
8
3
  module LazyHighCharts
4
+ # @private
9
5
  class Railtie < Rails::Railtie
10
- initializer 'lazy_high_charts.initialize', :after => :after_initialize do
11
- ActionView::Base.send :include, LazyHighCharts::LayoutHelper
12
- ActionView::Base.send(:include, LazyHighCharts::LayoutHelper)
6
+ initializer 'lazy_high_charts.initialize' do
7
+ ActiveSupport.on_load(:action_view) do
8
+ include LazyHighCharts::LayoutHelper
9
+ end
13
10
  end
14
11
  end
15
12
  end
@@ -1,3 +1,3 @@
1
1
  module LazyHighCharts
2
- VERSION = "1.0.8"
2
+ VERSION = "1.0.9"
3
3
  end
@@ -1,9 +1,8 @@
1
1
  # coding: utf-8
2
2
  require File.dirname(__FILE__) + '/spec_helper'
3
- require 'pp'
4
3
 
5
- describe HighChartsHelper do
6
- include HighChartsHelper
4
+ describe LazyHighCharts::LayoutHelper do
5
+ include LazyHighCharts::LayoutHelper
7
6
 
8
7
  before(:each) do
9
8
  @class = "stylin"
@@ -13,7 +12,7 @@ describe HighChartsHelper do
13
12
  @options = "options"
14
13
  end
15
14
 
16
- describe "high_chart_helper" do
15
+ describe "layout_helper" do
17
16
  it "should return a div with an id of high_chart object" do
18
17
  hc = LazyHighCharts::HighChart.new("placeholder", :class => 'stylin')
19
18
  high_chart(hc.placeholder, hc).should have_selector('div', :id => hc.placeholder, :class => 'stylin')
data/spec/spec_helper.rb CHANGED
@@ -10,7 +10,7 @@ require 'action_controller'
10
10
  #require 'action_mailer'
11
11
 
12
12
  require File.expand_path(File.join(File.dirname(__FILE__), '../lib/lazy_high_charts'))
13
- require File.expand_path(File.join(File.dirname(__FILE__), '../lib/lazy_high_charts/high_charts_helper'))
13
+ require File.expand_path(File.join(File.dirname(__FILE__), '../lib/lazy_high_charts/layout_helper'))
14
14
 
15
15
  require 'webrat'
16
16
  require 'rspec'
metadata CHANGED
@@ -1,12 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lazy_high_charts
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 1
7
- - 0
8
- - 8
9
- version: 1.0.8
4
+ prerelease:
5
+ version: 1.0.9
10
6
  platform: ruby
11
7
  authors:
12
8
  - Miguel Michelson Martinez
@@ -15,7 +11,7 @@ autorequire:
15
11
  bindir: bin
16
12
  cert_chain: []
17
13
 
18
- date: 2010-12-05 00:00:00 +08:00
14
+ date: 2011-03-19 00:00:00 +08:00
19
15
  default_executable:
20
16
  dependencies:
21
17
  - !ruby/object:Gem::Dependency
@@ -26,9 +22,6 @@ dependencies:
26
22
  requirements:
27
23
  - - ~>
28
24
  - !ruby/object:Gem::Version
29
- segments:
30
- - 1
31
- - 0
32
25
  version: "1.0"
33
26
  type: :runtime
34
27
  version_requirements: *id001
@@ -40,9 +33,6 @@ dependencies:
40
33
  requirements:
41
34
  - - ~>
42
35
  - !ruby/object:Gem::Version
43
- segments:
44
- - 0
45
- - 7
46
36
  version: "0.7"
47
37
  type: :development
48
38
  version_requirements: *id002
@@ -54,9 +44,6 @@ dependencies:
54
44
  requirements:
55
45
  - - ~>
56
46
  - !ruby/object:Gem::Version
57
- segments:
58
- - 2
59
- - 0
60
47
  version: "2.0"
61
48
  type: :development
62
49
  version_requirements: *id003
@@ -68,13 +55,10 @@ dependencies:
68
55
  requirements:
69
56
  - - ~>
70
57
  - !ruby/object:Gem::Version
71
- segments:
72
- - 3
73
- - 0
74
58
  version: "3.0"
75
59
  type: :development
76
60
  version_requirements: *id004
77
- description: " Lazy_high_charts provides a Rails interface for utilize highcharts to displaying graphs.\n"
61
+ description: " lazy_high_charts is a Rails 3.x gem for displaying Highcharts graphs.\n"
78
62
  email:
79
63
  - miguelmichelson@gmail.com
80
64
  - xiaods@gmail.com
@@ -99,7 +83,7 @@ files:
99
83
  - lib/generators/lazy_high_charts/install/install_generator.rb
100
84
  - lib/lazy_high_charts.rb
101
85
  - lib/lazy_high_charts/high_chart.rb
102
- - lib/lazy_high_charts/high_charts_helper.rb
86
+ - lib/lazy_high_charts/layout_helper.rb
103
87
  - lib/lazy_high_charts/railtie.rb
104
88
  - lib/lazy_high_charts/version.rb
105
89
  - rails/init.rb
@@ -120,23 +104,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
120
104
  requirements:
121
105
  - - ">="
122
106
  - !ruby/object:Gem::Version
123
- segments:
124
- - 0
125
107
  version: "0"
126
108
  required_rubygems_version: !ruby/object:Gem::Requirement
127
109
  none: false
128
110
  requirements:
129
- - - ">="
111
+ - - ~>
130
112
  - !ruby/object:Gem::Version
131
- segments:
132
- - 1
133
- - 3
134
- - 6
135
- version: 1.3.6
113
+ version: "1.3"
136
114
  requirements: []
137
115
 
138
116
  rubyforge_project:
139
- rubygems_version: 1.3.7
117
+ rubygems_version: 1.5.2
140
118
  signing_key:
141
119
  specification_version: 3
142
120
  summary: lazy higcharts plugin for rails
@@ -1,46 +0,0 @@
1
- # coding: utf-8
2
-
3
- module LazyHighCharts
4
- module LayoutHelper
5
- # ActiveSupport::JSON.unquote_hash_key_identifiers = false
6
- def high_chart(placeholder, object , &block)
7
- object.html_options.merge!({:id=>placeholder})
8
- object.options[:chart][:renderTo] = placeholder
9
- high_graph(placeholder,object , &block).concat(content_tag("div","", object.html_options))
10
- end
11
-
12
-
13
- def high_graph(placeholder, object, &block)
14
- graph =<<-EOJS
15
- <script type="text/javascript">
16
- jQuery(function() {
17
- // 1. Define JSON options
18
- var options = {
19
- chart: #{object.options[:chart].to_json},
20
- title: #{object.options[:title].to_json},
21
- legend: #{object.options[:legend].to_json},
22
- xAxis: #{object.options[:x_axis].to_json},
23
- yAxis: #{object.options[:y_axis].to_json},
24
- tooltip: #{object.options[:tooltip].to_json},
25
- credits: #{object.options[:credits].to_json},
26
- plotOptions: #{object.options[:plot_options].to_json},
27
- series: #{object.data.to_json},
28
- subtitle: #{object.options[:subtitle].to_json}
29
- };
30
-
31
- // 2. Add callbacks (non-JSON compliant)
32
- #{capture(&block) if block_given?}
33
- // 3. Build the chart
34
- var chart = new Highcharts.Chart(options);
35
- });
36
- </script>
37
- EOJS
38
- if defined?(raw)
39
- return raw(graph)
40
- else
41
- return graph
42
- end
43
- end
44
- end
45
- end
46
-