From 08dd6dc16f3cec6a36b69e6840a07b68f6ebb83d Mon Sep 17 00:00:00 2001 From: Prakriti-nith Date: Thu, 2 Aug 2018 02:00:19 +0530 Subject: [PATCH 1/2] Updated specs --- lib/daru/view.rb | 5 ++--- lib/daru/view/adapters/datatables.rb | 7 +++---- spec/adapters/datatables_spec.rb | 12 ++++++------ spec/spec_helper.rb | 1 + spec/table_spec.rb | 4 ++-- 5 files changed, 14 insertions(+), 15 deletions(-) diff --git a/lib/daru/view.rb b/lib/daru/view.rb index 2b17056..395e8d7 100644 --- a/lib/daru/view.rb +++ b/lib/daru/view.rb @@ -99,7 +99,7 @@ def dependent_script(lib=:nyaplot) when 'googlecharts' GoogleVisualr.init_script when 'datatables' - DataTables.init_script + init_script else raise ArgumentError, "Unsupported library #{lib}" end @@ -146,8 +146,7 @@ def load_lib_in_iruby(library) library = 'GoogleVisualr' Object.const_get(library).init_iruby elsif library.match('datatables') - library = 'DataTables' - Object.const_get(library).init_iruby + init_iruby else Object.const_get(library.capitalize).init_iruby end diff --git a/lib/daru/view/adapters/datatables.rb b/lib/daru/view/adapters/datatables.rb index bb4ec2a..1f4c7ce 100644 --- a/lib/daru/view/adapters/datatables.rb +++ b/lib/daru/view/adapters/datatables.rb @@ -1,4 +1,3 @@ -require 'daru/data_tables' require 'daru' require 'securerandom' require 'erb' @@ -59,13 +58,13 @@ module DatatablesAdapter # table2 = Daru::View::Table.new(df_sale_exp, options2) # table3 = Daru::View::Table.new(df_sale_exp) def init_table(data=[], options={}, _user_options={}) - @table = Daru::DataTables::DataTable.new(data, options) + @table = Daru::View::DataTable.new(data, options) @table end # @return [String] returns code of the dependent JS and CSS file(s) def init_script - Daru::DataTables.init_script + Daru::View.init_script end # @param table [Daru::DataTables::DataTable] table object to access @@ -117,7 +116,7 @@ def generate_html(table) # table = Daru::View::Table.new(data, options) # table.init_iruby def init_iruby - Daru::DataTables.init_iruby + Daru::View.init_iruby end end end diff --git a/spec/adapters/datatables_spec.rb b/spec/adapters/datatables_spec.rb index 3aff3a5..abc769a 100644 --- a/spec/adapters/datatables_spec.rb +++ b/spec/adapters/datatables_spec.rb @@ -18,20 +18,20 @@ let(:table_dv) { Daru::View::Table.new(@data_vec1, @options) } describe "initialization Tables" do - it "Table class must be Daru::DataTables::DataTable" do - expect(Daru::View::Table.new.table).to be_a Daru::DataTables::DataTable + it "Table class must be Daru::View::DataTable" do + expect(Daru::View::Table.new.table).to be_a Daru::View::DataTable end - it "Table class must be Daru::DataTables::DataTable when data objects" \ + it "Table class must be Daru::View::DataTable when data objects" \ " are of class Array" do - expect(table_string_array.table).to be_a Daru::DataTables::DataTable + expect(table_string_array.table).to be_a Daru::View::DataTable expect(table_string_array.data).to eq string_array expect(table_string_array.options).to eq options end - it "Table class must be Daru::DataTables::DataTable when data objects" \ + it "Table class must be Daru::View::DataTable when data objects" \ " are of class Array of Arrays" do - expect(table_array.table).to be_a Daru::DataTables::DataTable + expect(table_array.table).to be_a Daru::View::DataTable expect(table_array.data).to eq data_array expect(table_array.options).to eq options end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index e645619..8245726 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,6 +1,7 @@ require 'rspec' require 'simplecov' require 'daru/view' +require 'daru/data_tables' require 'daru' require 'coveralls' require 'simplecov-console' diff --git a/spec/table_spec.rb b/spec/table_spec.rb index 3785c9e..0ef93be 100644 --- a/spec/table_spec.rb +++ b/spec/table_spec.rb @@ -70,14 +70,14 @@ it 'daru-data_tables table using DataFrame' do expect(table_df).to be_a Daru::View::Table - expect(table_df.table).to be_a Daru::DataTables::DataTable + expect(table_df.table).to be_a Daru::View::DataTable expect(table_df.options).to eq options expect(table_df.data).to eq df end it 'daru-data_tables table using Vector' do expect(table_dv).to be_a Daru::View::Table - expect(table_dv.table).to be_a Daru::DataTables::DataTable + expect(table_dv.table).to be_a Daru::View::DataTable expect(table_dv.options).to eq options expect(table_dv.data).to eq dv end From 88826564b80d7dedd6a4389d0d38f43fc83af8f0 Mon Sep 17 00:00:00 2001 From: Prakriti-nith Date: Sun, 5 Aug 2018 04:18:40 +0530 Subject: [PATCH 2/2] update method call to DataTables.init_script --- lib/daru/view.rb | 5 +++-- lib/daru/view/adapters/datatables.rb | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/daru/view.rb b/lib/daru/view.rb index 395e8d7..2b17056 100644 --- a/lib/daru/view.rb +++ b/lib/daru/view.rb @@ -99,7 +99,7 @@ def dependent_script(lib=:nyaplot) when 'googlecharts' GoogleVisualr.init_script when 'datatables' - init_script + DataTables.init_script else raise ArgumentError, "Unsupported library #{lib}" end @@ -146,7 +146,8 @@ def load_lib_in_iruby(library) library = 'GoogleVisualr' Object.const_get(library).init_iruby elsif library.match('datatables') - init_iruby + library = 'DataTables' + Object.const_get(library).init_iruby else Object.const_get(library.capitalize).init_iruby end diff --git a/lib/daru/view/adapters/datatables.rb b/lib/daru/view/adapters/datatables.rb index 1f4c7ce..cec4a2c 100644 --- a/lib/daru/view/adapters/datatables.rb +++ b/lib/daru/view/adapters/datatables.rb @@ -64,7 +64,7 @@ def init_table(data=[], options={}, _user_options={}) # @return [String] returns code of the dependent JS and CSS file(s) def init_script - Daru::View.init_script + Daru::View::DataTables.init_script end # @param table [Daru::DataTables::DataTable] table object to access @@ -116,7 +116,7 @@ def generate_html(table) # table = Daru::View::Table.new(data, options) # table.init_iruby def init_iruby - Daru::View.init_iruby + Daru::View::DataTables.init_iruby end end end