Class: Ops

Inherits:
Object
  • Object
show all
Defined in:
lib/ops.rb

Overview

executes commands based on local ‘ops.yml`

Defined Under Namespace

Classes: UnknownActionError

Constant Summary collapse

CONFIG_FILE =
"ops.yml"
INVALID_SYNTAX_EXIT_CODE =
64
UNKNOWN_ACTION_EXIT_CODE =
65
ERROR_LOADING_APP_CONFIG_EXIT_CODE =
66
MIN_VERSION_NOT_MET_EXIT_CODE =
67

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(argv) ⇒ Ops

Returns a new instance of Ops.



36
37
38
39
40
41
# File 'lib/ops.rb', line 36

def initialize(argv)
	@action_name = argv[0]
	@args = argv[1..-1]

	Options.set(config["options"] || {})
end

Class Method Details

.project_nameObject



31
32
33
# File 'lib/ops.rb', line 31

def project_name
	File.basename(::Dir.pwd)
end

Instance Method Details

#runObject



43
44
45
46
47
48
49
50
51
52
53
# File 'lib/ops.rb', line 43

def run
	# "return" is here to allow specs to stub "exit" without executing everything after it
	return exit(INVALID_SYNTAX_EXIT_CODE) unless syntax_valid?
	return exit(MIN_VERSION_NOT_MET_EXIT_CODE) unless min_version_met?

	run_action
rescue UnknownActionError => e
	Output.error(e.to_s)
	print_did_you_mean
	exit(UNKNOWN_ACTION_EXIT_CODE)
end