Class: Knapsack::Report

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/knapsack/report.rb

Instance Method Summary collapse

Instance Method Details

#config(args = {}) ⇒ Object



5
6
7
8
# File 'lib/knapsack/report.rb', line 5

def config(args={})
  @config ||= args
  @config.merge!(args)
end

#openObject



24
25
26
27
28
29
# File 'lib/knapsack/report.rb', line 24

def open
  report = File.read(report_path)
  JSON.parse(report)
rescue Errno::ENOENT
  raise "Knapsack report file #{report_path} doesn't exist. Please generate report first!"
end

#report_pathObject



10
11
12
# File 'lib/knapsack/report.rb', line 10

def report_path
  config[:report_path] || raise('Missing report_path')
end

#saveObject



18
19
20
21
22
# File 'lib/knapsack/report.rb', line 18

def save
  File.open(report_path, 'w+') do |f|
    f.write(report_json)
  end
end

#test_file_patternObject



14
15
16
# File 'lib/knapsack/report.rb', line 14

def test_file_pattern
  config[:test_file_pattern] || raise('Missing test_file_pattern')
end