lib/knapsack/report.rb in knapsack-0.5.0 vs lib/knapsack/report.rb in knapsack-1.0.0

- old
+ new

@@ -1,33 +1,35 @@ module Knapsack class Report include Singleton - def config(opts={}) - @config ||= default_config - @config.merge!(opts) + def config(args={}) + @config ||= args + @config.merge!(args) end + def report_path + config[:report_path] || raise('Missing report_path') + end + + def test_file_pattern + config[:test_file_pattern] || raise('Missing test_file_pattern') + end + def save - File.open(config[:report_path], 'w+') do |f| + File.open(report_path, 'w+') do |f| f.write(report_json) end end def open - report = File.read(config[:report_path]) + report = File.read(report_path) JSON.parse(report) rescue Errno::ENOENT raise "Knapsack report file doesn't exist. Please generate report first!" end private - - def default_config - { - report_path: Config.report_path - } - end def report_json Presenter.report_json end end