Class: Turbulence::CommandLineInterface

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/turbulence/cli_parser.rb,
lib/turbulence/command_line_interface.rb

Defined Under Namespace

Modules: ConfigParser

Constant Summary collapse

TURBULENCE_TEMPLATE_PATH =
File.join(File.expand_path(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 Method Summary collapse

Constructor Details

#initialize(argv, additional_options = {}) ⇒ CommandLineInterface

Returns a new instance of CommandLineInterface.



23
24
25
26
# File 'lib/turbulence/command_line_interface.rb', line 23

def initialize(argv, additional_options = {})
  ConfigParser.parse_argv_into_config argv, config
  config.output = additional_options.fetch(:output, STDOUT)
end

Instance Method Details

#copy_templates_into(directory) ⇒ Object



36
37
38
# File 'lib/turbulence/command_line_interface.rb', line 36

def copy_templates_into(directory)
  FileUtils.cp TEMPLATE_FILES, directory
end

#generate_bundleObject



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/turbulence/command_line_interface.rb', line 40

def generate_bundle
  FileUtils.mkdir_p("turbulence")

  Dir.chdir("turbulence") do
    turb = Turbulence.new(config)

    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_bundleObject



57
58
59
# File 'lib/turbulence/command_line_interface.rb', line 57

def open_bundle
  Launchy.open("file:///#{directory}/turbulence/#{graph_type}.html")
end