class GitFeats::Runner

Public Class Methods

new(*args) click to toggle source

Creates a new Runner

args - The args to be run with git

# File lib/git-feats/runner.rb, line 7
def initialize(*args)
  @args = Args.new(args)
  # parse args for feats
  Checker.check(@args)
end
run(*args) click to toggle source

Run shortcut

# File lib/git-feats/runner.rb, line 14
def self.run(*args)
  new(*args).run
end

Public Instance Methods

run() click to toggle source

Run the args as one of the following:

  • Pure git-feats command

  • Overridden git command

  • Pure git command

# File lib/git-feats/runner.rb, line 22
def run
  # Pure git-feats command
  case @args[0]
  when "feats"
    run_feats_cmd

  # Overriden git command
  when "version" || "--version"
    version

  # Pure git command
  else
    exec_args
  end
end

Private Instance Methods

exec_args() click to toggle source

Exec the args as a git command

# File lib/git-feats/runner.rb, line 78
def exec_args
  exec(*@args.to_exec)
end
feats_help() click to toggle source

Run git-feats specific help command

# File lib/git-feats/runner.rb, line 48
    def feats_help
      puts <<help
usage: git feats <command>

commands:
  update  Update your feats and command history on gitfeats.com
  help    Display git-feats specific help
help
    end
feats_update() click to toggle source

Run git-feats specific update command

# File lib/git-feats/runner.rb, line 41
def feats_update
  if Config.exists?
    API.upload_feats
  end
end
run_feats_cmd() click to toggle source

Run a git-feats specific command

Precondition: The first argument is ‘feats’ ex: ‘git feats update’

# File lib/git-feats/runner.rb, line 68
def run_feats_cmd
  case @args[1]
  when "update"
    feats_update
  else
    feats_help
  end
end
version() click to toggle source

Override ‘git version` to output the git-feats version

# File lib/git-feats/runner.rb, line 59
def version
  puts "git-feats version #{GitFeats::VERSION}" 
  exec_args
end