Sha256: d10cf3cee0349e90cdfb92c6f6a6e90f4bf7f0bc14a1cde0a03af05ca78f197d
Contents?: true
Size: 1.16 KB
Versions: 2
Compression:
Stored size: 1.16 KB
Contents
require 'erb' module PrivatePlease module Reporting class SimpleText def initialize(result) @result = result end def text compiled_data = compile_data # passed to ERB via 'binding' erb = ERB.new(File.read(template), 0, '%<>') erb.result(binding) end #----------------------------------------------------------------------------- private def template templates_home = File.expand_path(File.dirname(__FILE__) + '/templates') "#{templates_home}/simple.txt.erb" end # Output example: # [ # ["/tmp/project/foo/simple_text_foo.rb", # [[18, "SimpleTextFoo#public_i_2"], # [11, "SimpleTextFoo.public_c_2"] # ] # ] # ... # ] def compile_data res = Hash.new { |h, k| h[k] = [] } @result.to_two_level_hash.each do |klass, methods_and_locations| methods_and_locations.each_pair do |meth, locations| source, lineno = locations res[source] << [lineno, "#{klass}#{meth}"] end end res.sort # by source file path end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
private_please-0.1.2 | lib/private_please/reporting/simple_text.rb |
private_please-0.1.1 | lib/private_please/reporting/simple_text.rb |