Module: Rbcli

Defined in:
lib/rbcli.rb,
lib/rbcli/version.rb,
lib/rbcli/engine/parser.rb,
lib/rbcli/logging/logging.rb,
lib/rbcli/engine/load_project.rb,
lib/rbcli/configuration/config.rb,
lib/rbcli/configuration/configurate.rb,
lib/rbcli/stateful_systems/storagetypes/localstate.rb,
lib/rbcli/stateful_systems/storagetypes/remotestate_dynamodb.rb

Overview

User Interface

Defined Under Namespace

Modules: Autoupdate, Config, Configurate, ConfigurateStorage, Logger, Parser, State Classes: Command, Scriptwrapper

Constant Summary collapse

VERSION =
"0.2.0"

Class Method Summary collapse

Class Method Details

.config ⇒ Object



54
55
56
# File 'lib/rbcli/configuration/config.rb', line 54

def self.config
	Rbcli::Config::config
end

.configuration ⇒ Object



126
127
128
# File 'lib/rbcli/configuration/configurate.rb', line 126

def self.configuration
	Rbcli::Configurate::configuration
end

.debug(obj) ⇒ Object



94
95
96
# File 'lib/rbcli/logging/logging.rb', line 94

def self.debug obj
	puts obj.to_s.red
end

.load_project ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/rbcli/engine/load_project.rb', line 23

def self.load_project
	project_root = File.expand_path("#{File.dirname(caller[0].split(':')[0])}/../")

	# Add lib to the load path for the user's convenience
	lib = "#{project_root}/lib"
	$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)

	# We require all ruby files as-is
	%w(config hooks application application/commands).each do |dir|
		dirpath = "#{project_root}/#{dir}"
		Dir.glob "#{dirpath}/*.rb" do |file|
			require file
		end if Dir.exists? dirpath
	end

	# We automatically pull in default user configs
	configspath = "#{project_root}/userconf"
	Dir.glob "#{configspath}/*.{yml,yaml,json}" do |file|
		Rbcli::Configurate.me {config_defaults file}
	end

end

.local_state ⇒ Object



35
36
37
# File 'lib/rbcli/stateful_systems/storagetypes/localstate.rb', line 35

def self.local_state
	Rbcli::ConfigurateStorage.data[:localstate]
end

.log ⇒ Object



90
91
92
# File 'lib/rbcli/logging/logging.rb', line 90

def self.log
	Rbcli::Logger::log
end

.parse ⇒ Object



82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/rbcli/engine/parser.rb', line 82

def self.parse
	if Rbcli.configuration[:first_run]
		if Rbcli.local_state
			if Rbcli.local_state.rbclidata.key? :first_run
				Rbcli::Parser::parse
			else
				Rbcli.configuration[:first_run].call
				Rbcli.local_state.set_rbclidata :first_run, true
				Rbcli::Parser::parse unless Rbcli.configuration[:halt_after_first_run]
			end
		else
			raise StandardError.new "Error: Can not use `first_run` without also configuring `local_state`."
		end
	else
		Rbcli::Parser::parse
	end
end

.remote_state ⇒ Object



39
40
41
# File 'lib/rbcli/stateful_systems/storagetypes/remotestate_dynamodb.rb', line 39

def self.remote_state
	Rbcli::ConfigurateStorage.data[:remotestate]
end