Module: Mach5::Command::Chart
- Included in:
- Runner
- Defined in:
- lib/mach5-tools/command/chart.rb
Instance Method Summary collapse
- #_all_charts ⇒ Object
- #_check_benchmarks(chart) ⇒ Object
- #_filename(commit_id, benchmark_id) ⇒ Object
- #_generate_chart(chart) ⇒ Object
- #_only_charts(charts) ⇒ Object
- #_only_new_charts ⇒ Object
- #list_charts ⇒ Object
Instance Method Details
#_all_charts ⇒ Object
4 5 6 7 8 |
# File 'lib/mach5-tools/command/chart.rb', line 4 def _all_charts @config.charts.each do |chart| _generate_chart(chart) end end |
#_check_benchmarks(chart) ⇒ Object
32 33 34 35 36 37 38 39 |
# File 'lib/mach5-tools/command/chart.rb', line 32 def _check_benchmarks(chart) benchmarks = [] chart.series.each do |benchmark| filename = _filename(benchmark[:commit_id], benchmark[:benchmark_id]) benchmarks << "#{benchmark[:commit_id]}.#{benchmark[:benchmark_id]}" unless File.exists?(filename) end benchmarks end |
#_filename(commit_id, benchmark_id) ⇒ Object
41 42 43 44 45 46 47 |
# File 'lib/mach5-tools/command/chart.rb', line 41 def _filename(commit_id, benchmark_id) if @config.benchmarks.tagged[commit_id] "#{File.join(@config.output_folder, @config.benchmarks.tagged[commit_id])}.#{benchmark_id}.json" else "#{File.join(@config.output_folder, commit_id)}.#{benchmark_id}.json" end end |
#_generate_chart(chart) ⇒ Object
26 27 28 29 30 |
# File 'lib/mach5-tools/command/chart.rb', line 26 def _generate_chart(chart) benchmarks = _check_benchmarks(chart) _only_benchmarks(benchmarks) if benchmarks.size > 0 Kernel.system "phantomjs #{File.join(File.dirname(__FILE__), "../js/chart.js")} #{File.join(File.dirname(__FILE__), "../js")} \"[#{chart.build.to_json.gsub("\"", "\\\"")}]\" #{File.join(@config.output_folder, chart.id)}.png" end |
#_only_charts(charts) ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/mach5-tools/command/chart.rb', line 10 def _only_charts(charts) @config.charts.each do |chart| if charts.include? chart.id _generate_chart(chart) end end end |
#_only_new_charts ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/mach5-tools/command/chart.rb', line 18 def _only_new_charts @config.charts.each do |chart| unless File.exists?("#{File.join(@config.output_folder, chart.id)}.png") _generate_chart(chart) end end end |
#list_charts ⇒ Object
49 50 51 |
# File 'lib/mach5-tools/command/chart.rb', line 49 def list_charts @config.charts.map(&:id) end |