Module: Snuffle::Formatters::Base
Class Method Summary collapse
Instance Method Summary collapse
- #columns ⇒ Object
- #content ⇒ Object
- #export ⇒ Object
- #file_extension ⇒ Object
- #filename ⇒ Object
- #initialize(summary, source = "") ⇒ Object
- #output_path ⇒ Object
- #path_to_results ⇒ Object
- #root_path ⇒ Object
Class Method Details
.included(klass) ⇒ Object
7 8 9 10 |
# File 'lib/snuffle/formatters/base.rb', line 7 def self.included(klass) klass.send(:attr_accessor, :summary) klass.send(:attr_accessor, :source) end |
Instance Method Details
#columns ⇒ Object
21 22 23 |
# File 'lib/snuffle/formatters/base.rb', line 21 def columns ["filename", "host class", "candidate object attributes", "source line numbers"] end |
#content ⇒ Object
17 18 19 |
# File 'lib/snuffle/formatters/base.rb', line 17 def content [header, rows, ].flatten.join("\r\n") end |
#export ⇒ Object
49 50 51 52 53 54 |
# File 'lib/snuffle/formatters/base.rb', line 49 def export outfile = File.open("#{path_to_results}", 'w') outfile.write(content) outfile.close path_to_results end |
#file_extension ⇒ Object
45 46 47 |
# File 'lib/snuffle/formatters/base.rb', line 45 def file_extension "" end |
#filename ⇒ Object
41 42 43 |
# File 'lib/snuffle/formatters/base.rb', line 41 def filename "#{summary.filename}" + file_extension end |
#initialize(summary, source = "") ⇒ Object
12 13 14 15 |
# File 'lib/snuffle/formatters/base.rb', line 12 def initialize(summary, source="") self.summary = summary self.source = source end |
#output_path ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/snuffle/formatters/base.rb', line 29 def output_path return @output_path if @output_path path = root_path path << "/" + summary.path_to_results if summary FileUtils.mkpath(path) @output_path = path end |
#path_to_results ⇒ Object
37 38 39 |
# File 'lib/snuffle/formatters/base.rb', line 37 def path_to_results "#{output_path}/#{filename}" end |
#root_path ⇒ Object
25 26 27 |
# File 'lib/snuffle/formatters/base.rb', line 25 def root_path "doc/snuffle" end |