Class: TDX::Base
- Inherits:
-
Object
- Object
- TDX::Base
- Defined in:
- lib/tdx/base.rb
Overview
Base class
Instance Method Summary collapse
-
#initialize(uri, opts) ⇒ Base
constructor
A new instance of Base.
- #svg ⇒ Object
Constructor Details
#initialize(uri, opts) ⇒ Base
Returns a new instance of Base.
37 38 39 40 |
# File 'lib/tdx/base.rb', line 37 def initialize(uri, opts) @uri = uri @opts = opts end |
Instance Method Details
#svg ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/tdx/base.rb', line 42 def svg dat = Tempfile.new('tdx') version = Exec.new('git --version').stdout.split(/ /)[2] raise "git version #{version} is too old, upgrade it to 2.0+" unless Gem::Version.new(version) >= Gem::Version.new('2.0') path = checkout commits = Exec.new('git log "--pretty=format:%H %cI" --reverse', path) .stdout.split(/\n/).map { |c| c.split(' ') } issues = issues(commits) puts "Date\t\t\tTest\tHoC\tFiles\tLoC\tIssues\tSHA" commits.each do |sha, date| Exec.new("git checkout --quiet #{sha}", path).stdout line = "#{date[0, 16]}\t#{tests(path)}\t#{hoc(path)}\t#{files(path)}\t\ #{loc(path)}\t#{issues[sha]}\t#{sha[0, 7]}" dat << "#{line}\n" puts line end dat.close svg = Tempfile.new('tdx') gpi = [ "set output \"#{svg.path}\"", 'set terminal svg size 700, 260', 'set termoption font "monospace,10"', 'set xdata time', 'set timefmt "%Y-%m"', 'set ytics format "%.0f%%" textcolor rgb "#81b341"', 'set grid linecolor rgb "gray"', 'set xtics format "%b/%y" font "monospace,8" textcolor rgb "black"', 'set autoscale', 'set style fill solid', 'set boxwidth 0.75 relative', [ "plot \"#{dat.path}\" using 1:2 with boxes", 'title "Test HoC" linecolor rgb "#81b341"', ', "" using 1:3 with boxes title "HoC" linecolor rgb "red"', ', "" using 1:4 with boxes title "Files" linecolor rgb "black"', ', "" using 1:5 with boxes title "LoC" linecolor rgb "cyan"', ', "" using 1:6 with boxes title "Issues" linecolor rgb "orange"' ].join(' ') ] Exec.new("gnuplot -e '#{gpi.join('; ')}'").stdout FileUtils.rm_rf(path) File.delete(dat) xml = File.read(svg) File.delete(svg) xml end |