phantom_graph 0.0.4

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.
@@ -0,0 +1,71 @@
1
+ #encoding: UTF-8
2
+ require 'spec_helper'
3
+
4
+ describe PhantomGraph::Convert::Stockchart do
5
+
6
+ it { PhantomGraph::Convert::Stockchart.should respond_to :attributes }
7
+
8
+ def json_str(data="")
9
+ "{
10
+ rangeSelector : {
11
+ selected : 1
12
+ },
13
+
14
+ title : {
15
+ text : 'AAPL Stock Price'
16
+ },
17
+
18
+ series : [{
19
+ name : 'AAPL',
20
+ data : #{data},
21
+ tooltip: {
22
+ valueDecimals: 2
23
+ }
24
+ }]
25
+ }"
26
+ end
27
+
28
+ before do
29
+ data = File.open("#{File.expand_path(File.dirname(__FILE__))}/stock.json", "r"){|io| io.read}
30
+ @json_str = json_str(data)
31
+ PhantomGraph.configure do |config|
32
+ config.logger = true
33
+ end
34
+ end
35
+
36
+ context "initialize" do
37
+ before do
38
+ @highchart = PhantomGraph::Convert::Stockchart.new(@json_str, {auto_process: false})
39
+ end
40
+
41
+ it "should have merged options" do
42
+ @highchart.options[:constr].should == "StockChart"
43
+ end
44
+
45
+ it "should have temporary json file" do
46
+ @highchart.json_file.should_not be_nil
47
+ end
48
+
49
+ it "should have temporary image file" do
50
+ @highchart.image_file.should_not be_nil
51
+ end
52
+
53
+ it "should have temporary callback file" do
54
+ @highchart.image_file.should_not be_nil
55
+ end
56
+ end
57
+
58
+ context "error" do
59
+ it "should raise No Executable if phantomjs file not exist" do
60
+ expect{ PhantomGraph::Convert::Stockchart.new(@json_str, {phantom_js_path: nil}) }.to raise_error PhantomGraph::Error::NoExecutable
61
+ end
62
+ end
63
+
64
+ context "processing" do
65
+ it "should generate image" do
66
+ @highchart = PhantomGraph::Convert::Stockchart.new(@json_str, {image_file_path: File.expand_path(File.dirname(__FILE__))})
67
+ File.size?(@highchart.image.path).should_not be_nil
68
+ end
69
+ end
70
+
71
+ end
@@ -0,0 +1,85 @@
1
+ #encoding: UTF-8
2
+ require 'spec_helper'
3
+
4
+ describe PhantomGraph::Setting do
5
+
6
+ def current_file(filename)
7
+ PhantomGraph.setting.current_file(filename)
8
+ end
9
+
10
+ before do
11
+ PhantomGraph.configure do |config|
12
+ config.phantomjs = "/usr/local/bin/phantomjs"
13
+ config.logger = true
14
+ end
15
+ end
16
+
17
+ context "when initialize" do
18
+ describe "default options" do
19
+ it "should have phantom_js_path" do
20
+ PhantomGraph.setting.default_options[:phantom_js_path].should eq(PhantomGraph.setting.phantomjs)
21
+ end
22
+
23
+ it "should have logger" do
24
+ PhantomGraph.setting.default_options[:logger].should be_true
25
+ end
26
+
27
+ it "should have auto_process" do
28
+ PhantomGraph.setting.default_options[:auto_process].should be_true
29
+ end
30
+
31
+ it "should have highcharts_convert_path" do
32
+ PhantomGraph.setting.default_options[:highcharts_convert_path].should eq(current_file("highcharts-convert.js"))
33
+ end
34
+
35
+ it "should have highcharts_theme_path" do
36
+ PhantomGraph.setting.default_options[:highcharts_theme_path].should eq(current_file("gray.js"))
37
+ end
38
+
39
+ it "should have highstock_path" do
40
+ PhantomGraph.setting.default_options[:highstock_path].should eq(current_file("highstock.js"))
41
+ end
42
+
43
+ it "should have highcharts_path" do
44
+ PhantomGraph.setting.default_options[:highcharts_path].should eq(current_file("highcharts.js"))
45
+ end
46
+
47
+ it "should have jquery_path" do
48
+ PhantomGraph.setting.default_options[:jquery_path].should eq(current_file("jquery.js"))
49
+ end
50
+ end
51
+
52
+ describe "file" do
53
+ it "should exist phantomjs binnary" do
54
+ File.exist?(PhantomGraph.setting.phantomjs).should be_true
55
+ end
56
+
57
+ it "should exist highcharts-convert.js" do
58
+ File.exist?(current_file("highcharts-convert.js")).should be_true
59
+ end
60
+
61
+ it "should exist highcharts-convert.js" do
62
+ File.exist?(current_file("highcharts-convert.js")).should be_true
63
+ end
64
+
65
+ it "should exist gray.js" do
66
+ File.exist?(current_file("gray.js")).should be_true
67
+ end
68
+
69
+ it "should exist highstock.js" do
70
+ File.exist?(current_file("highstock.js")).should be_true
71
+ end
72
+
73
+ it "should exist highcharts.js" do
74
+ File.exist?(current_file("highcharts.js")).should be_true
75
+ end
76
+
77
+ it "should exist jquery.js" do
78
+ File.exist?(current_file("jquery.js")).should be_true
79
+ end
80
+
81
+
82
+ end
83
+ end
84
+
85
+ end
@@ -0,0 +1,6 @@
1
+ require 'rack/test'
2
+ require 'phantom_graph'
3
+
4
+ RSpec.configure do |config|
5
+ include Rack::Test::Methods
6
+ end
metadata ADDED
@@ -0,0 +1,143 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: phantom_graph
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.4
5
+ platform: ruby
6
+ authors:
7
+ - Yacobus Reinhart
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-06-27 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: json
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ! '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ! '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
33
+ version: 0.9.2
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ! '>='
39
+ - !ruby/object:Gem::Version
40
+ version: 0.9.2
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ! '>='
46
+ - !ruby/object:Gem::Version
47
+ version: 2.2.0
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: 2.2.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: rack-test
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: 0.5.6
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ! '>='
67
+ - !ruby/object:Gem::Version
68
+ version: 0.5.6
69
+ description: PhantomGraph helps complex process to generate javascript charts to image
70
+ or pdf without requesting or rendering view to the application. PhantomGraph is
71
+ pure server-side process by using phantomjs and suitable for background process.
72
+ It is lighweight solution for wkhtmltopdf alternative.
73
+ email:
74
+ - yacobus.reinhart@gmail.com
75
+ executables: []
76
+ extensions: []
77
+ extra_rdoc_files: []
78
+ files:
79
+ - .gitignore
80
+ - .rspec
81
+ - Gemfile
82
+ - Gemfile.lock
83
+ - MIT-LICENSE
84
+ - README.rdoc
85
+ - Rakefile
86
+ - lib/phantom_graph.rb
87
+ - lib/phantom_graph/base.rb
88
+ - lib/phantom_graph/convert.rb
89
+ - lib/phantom_graph/convert/highchart.rb
90
+ - lib/phantom_graph/convert/stockchart.rb
91
+ - lib/phantom_graph/error.rb
92
+ - lib/phantom_graph/js/data.js
93
+ - lib/phantom_graph/js/gray.js
94
+ - lib/phantom_graph/js/highcharts-convert.js
95
+ - lib/phantom_graph/js/highcharts-more.js
96
+ - lib/phantom_graph/js/highcharts.js
97
+ - lib/phantom_graph/js/highstock.js
98
+ - lib/phantom_graph/js/jquery.js
99
+ - lib/phantom_graph/js/readme.md
100
+ - lib/phantom_graph/setting.rb
101
+ - lib/phantom_graph/version.rb
102
+ - lib/tasks/phantom_graph_tasks.rake
103
+ - phantom_graph.gemspec
104
+ - spec/phantom_graph/convert/14892-1372331188.png
105
+ - spec/phantom_graph/convert/56666-1372331186.png
106
+ - spec/phantom_graph/convert/highchart_spec.rb
107
+ - spec/phantom_graph/convert/stock.json
108
+ - spec/phantom_graph/convert/stockchart_spec.rb
109
+ - spec/phantom_graph/setting_spec.rb
110
+ - spec/spec_helper.rb
111
+ homepage: https://github.com/jackbit
112
+ licenses: []
113
+ metadata: {}
114
+ post_install_message:
115
+ rdoc_options: []
116
+ require_paths:
117
+ - lib
118
+ required_ruby_version: !ruby/object:Gem::Requirement
119
+ requirements:
120
+ - - ! '>='
121
+ - !ruby/object:Gem::Version
122
+ version: '0'
123
+ required_rubygems_version: !ruby/object:Gem::Requirement
124
+ requirements:
125
+ - - ! '>='
126
+ - !ruby/object:Gem::Version
127
+ version: '0'
128
+ requirements:
129
+ - phantomjs, v1.6 or greater
130
+ rubyforge_project:
131
+ rubygems_version: 2.0.3
132
+ signing_key:
133
+ specification_version: 4
134
+ summary: Ruby api to convert javascript chart to pdf or image with phantomjs
135
+ test_files:
136
+ - spec/phantom_graph/convert/14892-1372331188.png
137
+ - spec/phantom_graph/convert/56666-1372331186.png
138
+ - spec/phantom_graph/convert/highchart_spec.rb
139
+ - spec/phantom_graph/convert/stock.json
140
+ - spec/phantom_graph/convert/stockchart_spec.rb
141
+ - spec/phantom_graph/setting_spec.rb
142
+ - spec/spec_helper.rb
143
+ has_rdoc: