Class: Maximus::CLI

Inherits:
Thor
  • Object
show all
Includes:
Thor::Actions
Defined in:
lib/maximus/cli.rb

Overview

Command line abilities

Since:

  • 0.1.0

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ CLI

Inherit from original Thor and add @config instance var

Since:

  • 0.1.0



27
28
29
30
# File 'lib/maximus/cli.rb', line 27

def initialize(*args)
  super
  @config ||= Maximus::Config.new(default_options)
end

Instance Method Details

#backendObject

Since:

  • 0.1.0



38
39
40
# File 'lib/maximus/cli.rb', line 38

def backend
  ['rubocop', 'railsbp', 'brakeman'].each { |e| check_exclude(e) }
end

#frontendObject

Since:

  • 0.1.0



33
34
35
# File 'lib/maximus/cli.rb', line 33

def frontend
  ['scsslint', 'jshint'].each { |e| check_exclude(e) }
end

#gitObject

Since:

  • 0.1.0



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/maximus/cli.rb', line 55

def git
  all_tasks = ['frontend', 'backend', 'statistics']

  # If all flag is enabled, run everything
  if options[:all]
    all_tasks.each { |a| send(a) }

  elsif options[:frontend].present? && options[:backend].present? && options[:statistics].present?
    all_tasks.each { |a| check_option(a) }

  # If include flag is enabled, run based on what's included
  elsif options[:include].present?
    options[:include].each { |i| send(i) }

  else
    # If all flag is not enabled, lint working copy as it's supposed to be
    @config.settings[:commit] = options[:git]
    Maximus::GitControl.new({config: @config}).lints_and_stats(true)

  end

  @config.destroy_temp
end

#installObject

Since:

  • 0.1.0



81
82
83
# File 'lib/maximus/cli.rb', line 81

def install
  `npm install -g jshint phantomas stylestats`
end

#rubyObject

Since:

  • 0.1.0



50
51
52
# File 'lib/maximus/cli.rb', line 50

def ruby
  backend
end

#statisticsObject

Since:

  • 0.1.0



43
44
45
# File 'lib/maximus/cli.rb', line 43

def statistics
  ['stylestats', 'phantomas', 'wraith'].each { |e| check_exclude(e) }
end