class Nib::Integrate::Registrar
registers applications for integration
Attributes
config_path[R]
options[R]
Public Class Methods
call(options, config_path = ConfigFile::PATH)
click to toggle source
# File lib/nib/integrate/registrar.rb, line 6 def call(options, config_path = ConfigFile::PATH) new(options, config_path).call end
new(options, config_path)
click to toggle source
# File lib/nib/integrate/registrar.rb, line 13 def initialize(options, config_path) @options = options @config_path = config_path end
Public Instance Methods
call()
click to toggle source
# File lib/nib/integrate/registrar.rb, line 18 def call return unless valid? return if app_config_exists? register_app true end
Private Instance Methods
app_config_exists?()
click to toggle source
# File lib/nib/integrate/registrar.rb, line 34 def app_config_exists? existing_config['apps'] .select { |app| app['name'] == app_name } .size .positive? end
app_name()
click to toggle source
# File lib/nib/integrate/registrar.rb, line 60 def app_name options[:a] end
config_file()
click to toggle source
# File lib/nib/integrate/registrar.rb, line 64 def config_file ConfigFile end
existing_config()
click to toggle source
# File lib/nib/integrate/registrar.rb, line 56 def existing_config @existing_config ||= config_file.read(config_path) end
new_app()
click to toggle source
# File lib/nib/integrate/registrar.rb, line 46 def new_app { 'name' => options[:a], 'path' => options[:p], 'service' => options[:s], 'compose_file' => options[:d], 'integration_compose_file' => options[:i] }.compact end
register_app()
click to toggle source
# File lib/nib/integrate/registrar.rb, line 41 def register_app existing_config['apps'] << new_app config_file.write(existing_config, config_path) end
valid?()
click to toggle source
# File lib/nib/integrate/registrar.rb, line 27 def valid? raise 'No app name given' unless options[:a] raise 'No path given' unless options[:p] raise 'No service name given' unless options[:s] true end