Class: Attractor::CLI

Inherits:
Thor
  • Object
show all
Defined in:
lib/attractor/cli.rb

Overview

contains methods implementing the CLI

Instance Method Summary collapse

Instance Method Details

#calcObject



50
51
52
53
54
55
56
57
# File 'lib/attractor/cli.rb', line 50

def calc
  file_prefix = options[:file_prefix]
  output_format = options[:format]

  report! Attractor::ConsoleReporter.new(file_prefix: file_prefix, ignores: options[:ignore], calculators: calculators(options), format: output_format)
rescue RuntimeError => e
  puts "Runtime error: #{e.message}"
end

#cleanObject



31
32
33
34
# File 'lib/attractor/cli.rb', line 31

def clean
  puts "Clearing attractor cache"
  Attractor.clear
end

#initObject



40
41
42
43
# File 'lib/attractor/cli.rb', line 40

def init
  puts "Warming attractor cache"
  Attractor.init(calculators(options))
end

#reportObject



63
64
65
66
67
68
69
70
# File 'lib/attractor/cli.rb', line 63

def report
  file_prefix = options[:file_prefix]
  open_browser = !(options[:no_open_browser] || options[:ci])

  report! Attractor::HtmlReporter.new(file_prefix: file_prefix, ignores: options[:ignore], calculators: calculators(options), open_browser: open_browser)
rescue RuntimeError => e
  puts "Runtime error: #{e.message}"
end

#serveObject



76
77
78
79
80
81
# File 'lib/attractor/cli.rb', line 76

def serve
  file_prefix = options[:file_prefix]
  open_browser = !(options[:no_open_browser] || options[:ci])

  report! Attractor::SinatraReporter.new(file_prefix: file_prefix, ignores: options[:ignore], calculators: calculators(options), open_browser: open_browser)
end

#versionObject



24
25
26
27
28
# File 'lib/attractor/cli.rb', line 24

def version
  puts "Attractor version #{Attractor::VERSION}"
rescue RuntimeError => e
  puts "Runtime error: #{e.message}"
end