Skip to content

Commit 035f80d

Browse files
authored
Merge pull request #162 from sayant1204/update_rspec
added tag for skipping updation of googlechart/highchart files locally
2 parents b4ac5fd + ddb2c18 commit 035f80d

File tree

13 files changed

+29
-22
lines changed

13 files changed

+29
-22
lines changed

lib/assets/.keep

Whitespace-only changes.

lib/daru/view.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
require 'daru/view/adapters/googlecharts/iruby_notebook'
1414

1515
# Rails Helper
16-
require 'daru/view/app/rails/railtie.rb' if defined?(Rails)
16+
require 'daru/view/app/rails/railtie' if defined?(Rails)
1717

1818
module Daru
1919
module View

lib/daru/view/adapters/googlecharts.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ def extract_chart_type(options)
255255
chart_type = 'SteppedArea' if chart_type == 'Steppedarea'
256256
chart_type = 'TreeMap' if chart_type == 'Treemap'
257257
direct_name = %w[Map Histogram TreeMap Timeline Gauge]
258-
direct_name.include?(chart_type) ? chart_type : chart_type + 'Chart'
258+
direct_name.include?(chart_type) ? chart_type : "#{chart_type}Chart"
259259
end
260260

261261
# For google table, column is needed.

lib/daru/view/adapters/googlecharts/display.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ module Display
1313
attr_accessor :formatters
1414

1515
def show_script(dom=SecureRandom.uuid, options={})
16-
script_tag = options.fetch(:script_tag) { true }
16+
script_tag = options.fetch(:script_tag, true)
1717
# To understand different formatters see:
1818
# https://developers.google.com/chart/interactive/docs/reference#formatters
1919
apply_formatters if is_a?(GoogleVisualr::DataTable)
@@ -282,7 +282,7 @@ def apply_date_arrow_bar_number_formatter(formatter)
282282
formatter[:options] ||= {}
283283
formatter[:columns] ||= 0
284284
frmttr = GoogleVisualr.const_get(
285-
formatter[:type].to_s.capitalize + 'Format'
285+
"#{formatter[:type].to_s.capitalize}Format"
286286
).new(formatter[:options])
287287
frmttr.columns(formatter[:columns])
288288
frmttr

lib/daru/view/adapters/googlecharts/formatters.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
module GoogleVisualr
22
class PatternFormat < Formatter
33
attr_accessor :des_col
4+
45
def initialize(format_string='')
6+
super
57
@format_string = format_string
68
end
79

lib/daru/view/adapters/highcharts/core_ext/string.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
class String
2-
def js_code(true_or_false=true)
2+
def js_code(true_or_false: true)
33
@_lazy_high_charts_js_code = true_or_false
44
self
55
end

lib/daru/view/adapters/highcharts/display.rb

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ class HighChart
5454
# be rendered in
5555
attr_accessor :div_id
5656
attr_accessor :user_options
57+
5758
# @example
5859
#
5960
# To display the html code of the chart, use `to_html`. To see the same
@@ -71,14 +72,15 @@ def to_html(placeholder=random_canvas_id)
7172
script << high_chart_css(placeholder)
7273
# Helps to denote either of the three classes.
7374
chart_class = extract_chart_class
75+
case chart_class
7476
# When user wants to plot a HighMap
75-
if chart_class == 'Map'
77+
when 'Map'
7678
script << high_map(placeholder, self)
7779
# When user wants to plot a HighStock
78-
elsif chart_class == 'StockChart'
80+
when 'StockChart'
7981
script << high_stock(placeholder, self)
8082
# When user wants to plot a HighChart
81-
elsif chart_class == 'Chart'
83+
when 'Chart'
8284
script << high_chart(placeholder, self)
8385
end
8486
script
@@ -117,7 +119,7 @@ def high_chart_css(placeholder)
117119
css_script << "\n<style>"
118120
# Applying the css to chart div
119121
css_data.each do |css|
120-
css_script << "\n #" + placeholder + ' '
122+
css_script << "\n ##{placeholder} "
121123
css_script << css
122124
end
123125
css_script << "\n</style>"
@@ -133,9 +135,10 @@ def high_chart_css(placeholder)
133135
# notebook and returns initial script of the modules for web frameworks
134136
def load_dependencies(type)
135137
dep_js = extract_dependencies
136-
if type == 'iruby'
138+
case type
139+
when 'iruby'
137140
LazyHighCharts.init_iruby(dep_js) unless dep_js.nil?
138-
elsif type == 'web_frameworks'
141+
when 'web_frameworks'
139142
dep_js.nil? ? '' : LazyHighCharts.init_javascript(dep_js)
140143
end
141144
end
@@ -214,7 +217,7 @@ def extract_export_code(
214217
js << "\n \t\tvar chart = Highcharts.charts[Highcharts.attr(chartDom,"
215218
js << " 'data-highcharts-chart')]"
216219
js << "\n \t\tchart.exportChartLocal({"
217-
js << "\n \t\t\t" + append_chart_type(export_type)
220+
js << "\n \t\t\t#{append_chart_type(export_type)}"
218221
js << "\n \t\t\tfilename: '#{file_name}'"
219222
js << "\n \t\t});\n \t};\n })();"
220223
js << "\n </script>"
@@ -236,7 +239,7 @@ def extract_export_code_iruby(
236239
js << "\n \tvar chart = Highcharts.charts[Highcharts.attr(chartDom,"
237240
js << " 'data-highcharts-chart')]"
238241
js << "\n \tchart.exportChart({"
239-
js << "\n \t\t" + append_chart_type(export_type)
242+
js << "\n \t\t#{append_chart_type(export_type)}"
240243
js << "\n \t\tfilename: '#{file_name}'"
241244
js << "\n \t});"
242245
js << "\n })();"

lib/daru/view/adapters/nyaplot.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def init_iruby
3939
private
4040

4141
def multi_dimension_check(arr)
42-
arr.all? { |a| a.class==Array }
42+
arr.all? { |a| a.instance_of?(Array) }
4343
end
4444

4545
def guess_data(data_set)

lib/daru/view/plot.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ module View
33
class Plot
44
attr_reader :chart, :data, :options, :user_options
55
attr_accessor :adapter
6+
67
class << self
78
# class method
89
#
@@ -15,7 +16,7 @@ def adapter=(adapter)
1516
require "daru/view/adapters/#{adapter}"
1617
# rubocop:disable Style/ClassVars
1718
@@adapter = Daru::View::Adapter.const_get(
18-
adapter.to_s.capitalize + 'Adapter'
19+
"#{adapter.to_s.capitalize}Adapter"
1920
)
2021
# rubocop:enable Style/ClassVars
2122
end
@@ -46,7 +47,7 @@ def initialize(data=[], options={}, user_options={}, &block)
4647
def adapter=(adapter)
4748
require "daru/view/adapters/#{adapter}"
4849
@adapter = Daru::View::Adapter.const_get(
49-
adapter.to_s.capitalize + 'Adapter'
50+
"#{adapter.to_s.capitalize}Adapter"
5051
)
5152
end
5253

lib/daru/view/plot_list.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ def extract_charts_script(charts_id_div_tag=[])
6565
charts_script = ''
6666
@data.each do |plot|
6767
chart_script = extract_chart_script(plot)
68-
charts_id_div_tag << chart_script.partition(%r{<div(.*?)<\/div>}ixm)[1]
69-
chart_script.sub!(%r{<div(.*?)<\/div>}ixm, '')
68+
charts_id_div_tag << chart_script.partition(%r{<div(.*?)</div>}ixm)[1]
69+
chart_script.sub!(%r{<div(.*?)</div>}ixm, '')
7070
charts_script << chart_script
7171
end
7272
charts_script

0 commit comments

Comments
 (0)