Class: Turbulence::CommandLineInterface
- Inherits:
-
Object
- Object
- Turbulence::CommandLineInterface
- Defined in:
- lib/turbulence/command_line_interface.rb
Constant Summary collapse
- TURBULENCE_TEMPLATE_PATH =
File.join(File.(File.dirname(__FILE__)), "..", "..", "template")
- TEMPLATE_FILES =
['turbulence.html', 'highcharts.js', 'jquery.min.js', 'treemap.html'].map do |filename| File.join(TURBULENCE_TEMPLATE_PATH, filename) end
Instance Attribute Summary collapse
-
#directory ⇒ Object
readonly
Returns the value of attribute directory.
-
#exclusion_pattern ⇒ Object
readonly
Returns the value of attribute exclusion_pattern.
Instance Method Summary collapse
- #copy_templates_into(directory) ⇒ Object
- #generate_bundle ⇒ Object
-
#initialize(argv) ⇒ CommandLineInterface
constructor
A new instance of CommandLineInterface.
- #open_bundle ⇒ Object
Constructor Details
#initialize(argv) ⇒ CommandLineInterface
Returns a new instance of CommandLineInterface.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/turbulence/command_line_interface.rb', line 19 def initialize(argv) Turbulence::Calculators::Churn.scm = Scm::Git OptionParser.new do |opts| opts. = "Usage: bule [options] [dir]" opts.on('--scm p4|git', String, 'scm to use (default: git)') do |s| case s when "git", "", nil when "p4" Turbulence::Calculators::Churn.scm = Scm::Perforce end end opts.on('--churn-range since..until', String, 'commit range to compute file churn') do |s| Turbulence::Calculators::Churn.commit_range = s end opts.on('--churn-mean', 'calculate mean churn instead of cummulative') do Turbulence::Calculators::Churn.compute_mean = true end opts.on('--exclude pattern', String, 'exclude files matching pattern') do |pattern| @exclusion_pattern = pattern end opts.on('--treemap', String, 'output treemap graph instead of scatterplot') do |s| @graph_type = "treemap" end opts.on_tail("-h", "--help", "Show this message") do puts opts exit end end.parse!(argv) @directory = argv.first || Dir.pwd end |
Instance Attribute Details
#directory ⇒ Object (readonly)
Returns the value of attribute directory.
18 19 20 |
# File 'lib/turbulence/command_line_interface.rb', line 18 def directory @directory end |
#exclusion_pattern ⇒ Object (readonly)
Returns the value of attribute exclusion_pattern.
17 18 19 |
# File 'lib/turbulence/command_line_interface.rb', line 17 def exclusion_pattern @exclusion_pattern end |
Instance Method Details
#copy_templates_into(directory) ⇒ Object
58 59 60 |
# File 'lib/turbulence/command_line_interface.rb', line 58 def copy_templates_into(directory) FileUtils.cp TEMPLATE_FILES, directory end |
#generate_bundle ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/turbulence/command_line_interface.rb', line 62 def generate_bundle FileUtils.mkdir_p("turbulence") Dir.chdir("turbulence") do turb = Turbulence.new(directory,STDOUT, @exclusion_pattern) generator = case @graph_type when "treemap" Turbulence::Generators::TreeMap.new({}) else Turbulence::Generators::ScatterPlot.new({}) end generator.generate_results(turb.metrics, self) end end |
#open_bundle ⇒ Object
79 80 81 82 83 84 85 86 |
# File 'lib/turbulence/command_line_interface.rb', line 79 def open_bundle case @graph_type when "treemap" Launchy.open("file://#{directory}/turbulence/treemap.html") else Launchy.open("file://#{directory}/turbulence/turbulence.html") end end |