Module: Fukuzatsu::Formatters::Base
- Defined in:
- lib/fukuzatsu/formatters/base.rb
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
- #export ⇒ Object
- #filename ⇒ Object
- #initialize(source: nil, summary: nil, base_output_path:) ⇒ Object
- #output_directory ⇒ Object
- #output_path ⇒ Object
- #path_to_results ⇒ Object
Class Method Details
.included(klass) ⇒ Object
7 8 9 10 11 12 |
# File 'lib/fukuzatsu/formatters/base.rb', line 7 def self.included(klass) klass.send(:attr_accessor, :summary) klass.send(:attr_accessor, :source) klass.send(:attr_accessor, :base_output_path) klass.extend(ClassMethods) end |
Instance Method Details
#export ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/fukuzatsu/formatters/base.rb', line 20 def export begin File.open(path_to_results, 'w') {|outfile| outfile.write(content)} rescue Exception => e puts "Unable to write output to #{path_to_results}: #{e} #{e.backtrace}" end end |
#filename ⇒ Object
28 29 30 |
# File 'lib/fukuzatsu/formatters/base.rb', line 28 def filename File.basename(self.summary.source_file) + file_extension end |
#initialize(source: nil, summary: nil, base_output_path:) ⇒ Object
14 15 16 17 18 |
# File 'lib/fukuzatsu/formatters/base.rb', line 14 def initialize(source: nil, summary:nil, base_output_path:) self.source = source self.summary = summary self.base_output_path = base_output_path end |
#output_directory ⇒ Object
32 33 34 |
# File 'lib/fukuzatsu/formatters/base.rb', line 32 def output_directory self.base_output_path + "/" + file_extension.gsub(".","") end |
#output_path ⇒ Object
36 37 38 39 40 41 42 43 44 |
# File 'lib/fukuzatsu/formatters/base.rb', line 36 def output_path if self.summary output_path = output_directory + "/" + File.dirname(self.summary.source_file) FileUtils.mkpath(output_path) else output_path = File.dirname(output_directory) end output_path end |
#path_to_results ⇒ Object
46 47 48 |
# File 'lib/fukuzatsu/formatters/base.rb', line 46 def path_to_results File.join(output_path, filename) end |