Sha256: 1b279cbc39c896f6e91119e5718fd78516f1a2facaac75a16d0ead5c2dcbf6fe

Contents?: true

Size: 1.89 KB

Versions: 5

Compression:

Stored size: 1.89 KB

Contents

require 'spout/version'

require 'spout/models/dictionary'

Spout::COMMANDS = {
  'n' => :new_project,
  'v' => :version,
  't' => :test,
  'i' => :importer,
  'e' => :exporter,
  'c' => :coverage_report,
  'g' => :generate_charts_and_tables,
  'o' => :outliers_report,
  'd' => :deploy
}

module Spout
  def self.launch(argv)
    send((Spout::COMMANDS[argv.first.to_s.scan(/\w/).first] || :help), argv)
  end

  def self.new_project(argv)
    require 'spout/commands/project_generator'
    Spout::Commands::ProjectGenerator.new(argv)
  end

  def self.coverage_report(argv)
    require 'spout/commands/coverage'
    Spout::Commands::Coverage.new(standard_version, argv)
  rescue NoMemoryError
    puts "[NoMemoryError] You made Spout cry... Spout doesn't run on potatoes :'-("
  end

  def self.exporter(argv)
    require 'spout/commands/exporter'
    Spout::Commands::Exporter.new(standard_version, argv)
  end

  def self.generate_charts_and_tables(argv)
    argv = argv.last(argv.size - 1)
    require 'spout/commands/graphs'
    Spout::Commands::Graphs.new(argv, standard_version)
  end

  def self.help(argv)
    require 'spout/commands/help'
    Spout::Commands::Help.new(argv)
  end

  def self.deploy(argv)
    require 'spout/commands/deploy'
    Spout::Commands::Deploy.new(argv, standard_version)
  end

  def self.importer(argv)
    require 'spout/commands/importer'
    Spout::Commands::Importer.new(argv)
  end

  def self.outliers_report(argv)
    require 'spout/commands/outliers'
    Spout::Commands::Outliers.new(standard_version, argv)
  end

  def self.test(_argv)
    system 'bundle exec rake'
    # require 'spout/commands/test_runner'
    # Spout::Commands::TestRunner.new(argv)
  end

  def self.version(_argv)
    puts "Spout #{Spout::VERSION::STRING}"
  end

  def self.standard_version
    version = File.open('VERSION', &:readline).strip
    version == '' ? '1.0.0' : version
  rescue
    '1.0.0'
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
spout-0.11.0 lib/spout.rb
spout-0.11.0.rc lib/spout.rb
spout-0.11.0.beta3 lib/spout.rb
spout-0.11.0.beta2 lib/spout.rb
spout-0.11.0.beta1 lib/spout.rb