From 834c34c102128c73123bcfc98ad34be0fc0c3ca0 Mon Sep 17 00:00:00 2001 From: Peter Halloran Date: Mon, 22 May 2017 16:27:36 -0500 Subject: [PATCH 1/2] feat: add methods to support chart widget accessors --- lib/cortex/snippets/webpage.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/cortex/snippets/webpage.rb b/lib/cortex/snippets/webpage.rb index e6b6389..0cd096f 100644 --- a/lib/cortex/snippets/webpage.rb +++ b/lib/cortex/snippets/webpage.rb @@ -67,6 +67,14 @@ def tables_widget_data_for(section_name) tables_widget_data&.[](section_name) || [] end + def charts_widget_data + JSON.parse(@webpage[:charts_widget_json] || 'null', quirks_mode: true) + end + + def charts_widget_data_for(section_name) + charts_widget_data&.[](section_name) || [] + end + def snippets @webpage[:snippets] end From 3c982acb0860b455721a9490574a36999017d3e2 Mon Sep 17 00:00:00 2001 From: Peter Halloran Date: Mon, 22 May 2017 16:40:40 -0500 Subject: [PATCH 2/2] fix: return object literal if chart_widget value is not found --- lib/cortex/snippets/webpage.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/cortex/snippets/webpage.rb b/lib/cortex/snippets/webpage.rb index 0cd096f..2ff813d 100644 --- a/lib/cortex/snippets/webpage.rb +++ b/lib/cortex/snippets/webpage.rb @@ -72,7 +72,7 @@ def charts_widget_data end def charts_widget_data_for(section_name) - charts_widget_data&.[](section_name) || [] + charts_widget_data&.[](section_name) || {} end def snippets