Class: Knapsack::Report
- Inherits:
-
Object
- Object
- Knapsack::Report
- Includes:
- Singleton
- Defined in:
- lib/knapsack/report.rb
Instance Method Summary collapse
- #config(args = {}) ⇒ Object
- #open ⇒ Object
- #report_path ⇒ Object
- #save ⇒ Object
- #test_file_pattern ⇒ Object
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 |
#open ⇒ Object
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_path ⇒ Object
10 11 12 |
# File 'lib/knapsack/report.rb', line 10 def report_path config[:report_path] || raise('Missing report_path') end |
#save ⇒ Object
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_pattern ⇒ Object
14 15 16 |
# File 'lib/knapsack/report.rb', line 14 def test_file_pattern config[:test_file_pattern] || raise('Missing test_file_pattern') end |