class Maximus::CLI
Command line abilities @since 0.1.0
Public Class Methods
new(*args)
click to toggle source
Inherit from original Thor and add @config instance var
Calls superclass method
# File lib/maximus/cli.rb, line 27 def initialize(*args) super @config ||= Maximus::Config.new(default_options) end
Public Instance Methods
backend()
click to toggle source
# File lib/maximus/cli.rb, line 38 def backend ['rubocop', 'railsbp', 'brakeman'].each { |e| check_exclude(e) } end
brakeman()
click to toggle source
# File lib/maximus/cli.rb, line 132 def brakeman Maximus::Brakeman.new({config: @config}).result end
check_exclude(opt)
click to toggle source
Don't run command if it's present in the exlude options
# File lib/maximus/cli.rb, line 93 def check_exclude(opt) send(opt) unless options[:exclude].include?(opt) end
check_option(opt)
click to toggle source
Only run command if option is present
# File lib/maximus/cli.rb, line 88 def check_option(opt) send(opt) if options[opt.to_sym] end
default_options()
click to toggle source
# File lib/maximus/cli.rb, line 97 def default_options opts = { file_paths: options[:filepath], paths: options[:urls], domain: options[:domain], port: options[:port], is_dev: true, config_file: options[:config] } stats = { stylestats: options[:include].include?('stylestats'), wraith: options[:include].include?('wraith'), phantomas: options[:include].include?('phantomas') } opts.merge!(stats) unless options[:include].include?('statistics') || options[:statistics] opts end
frontend()
click to toggle source
# File lib/maximus/cli.rb, line 33 def frontend ['scsslint', 'jshint'].each { |e| check_exclude(e) } end
git()
click to toggle source
# 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
install()
click to toggle source
# File lib/maximus/cli.rb, line 81 def install `npm install -g jshint phantomas stylestats` end
jshint()
click to toggle source
# File lib/maximus/cli.rb, line 120 def jshint Maximus::Jshint.new({config: @config}).result end
phantomas()
click to toggle source
# File lib/maximus/cli.rb, line 140 def phantomas Maximus::Phantomas.new({config: @config}).result end
railsbp()
click to toggle source
# File lib/maximus/cli.rb, line 128 def railsbp Maximus::Railsbp.new({config: @config}).result end
rubocop()
click to toggle source
# File lib/maximus/cli.rb, line 124 def rubocop Maximus::Rubocop.new({config: @config}).result end
ruby()
click to toggle source
# File lib/maximus/cli.rb, line 50 def ruby backend end
scsslint()
click to toggle source
# File lib/maximus/cli.rb, line 116 def scsslint Maximus::Scsslint.new({config: @config}).result end
statistics()
click to toggle source
# File lib/maximus/cli.rb, line 43 def statistics ['stylestats', 'phantomas', 'wraith'].each { |e| check_exclude(e) } end
stylestats()
click to toggle source
# File lib/maximus/cli.rb, line 136 def stylestats Maximus::Stylestats.new({config: @config}).result end
wraith()
click to toggle source
# File lib/maximus/cli.rb, line 144 def wraith Maximus::Wraith.new({config: @config}).result end