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, additional_options = {}) ⇒ CommandLineInterface
constructor
A new instance of CommandLineInterface.
- #open_bundle ⇒ Object
Constructor Details
#initialize(argv, additional_options = {}) ⇒ 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 57 58 |
# File 'lib/turbulence/command_line_interface.rb', line 19 def initialize(argv, = {}) Turbulence::Calculators::Churn.scm = Scm::Git @graph_type = "turbulence" 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 @output = .fetch(:output, STDOUT) 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
60 61 62 |
# File 'lib/turbulence/command_line_interface.rb', line 60 def copy_templates_into(directory) FileUtils.cp TEMPLATE_FILES, directory end |
#generate_bundle ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/turbulence/command_line_interface.rb', line 64 def generate_bundle FileUtils.mkdir_p("turbulence") Dir.chdir("turbulence") do turb = Turbulence.new(directory, @output, @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
81 82 83 |
# File 'lib/turbulence/command_line_interface.rb', line 81 def open_bundle Launchy.open("file:///#{directory}/turbulence/#{@graph_type}.html") end |