module Fulmar::Domain::Service::Helper::CommonHelper

Provides the helper methods used in the tasks

Attributes

environment[RW]

Public Instance Methods

config() click to toggle source

@return [Fulmar::Domain::Service::ConfigurationService]

# File lib/fulmar/domain/service/helper/common_helper.rb, line 14
def config
  (@_config_service ||= Fulmar::Domain::Service::ConfigurationService.instance.configuration)
end
download(filename, target = config[:local_path]) click to toggle source
# File lib/fulmar/domain/service/helper/common_helper.rb, line 49
def download(filename, target = config[:local_path])
  Fulmar::Infrastructure::Service::CopyService.download(local_shell, config.ssh_user_and_host, filename, target)
end
error(text) click to toggle source
# File lib/fulmar/domain/service/helper/common_helper.rb, line 79
def error(text)
  STDERR.puts(ENV['TERM'] == 'xterm-256color' ? text.light_red : "* Error: #{text}")
end
file_sync() click to toggle source
# File lib/fulmar/domain/service/helper/common_helper.rb, line 35
def file_sync
  file_sync_model = Fulmar::FileSync.get_class config
  cache_id = "file_sync-#{file_sync_model.config_hash(config)}"
  storage[cache_id] ||= file_sync_model.new(config.clone)
end
info(text) click to toggle source
# File lib/fulmar/domain/service/helper/common_helper.rb, line 71
def info(text)
  puts(ENV['TERM'] == 'xterm-256color' ? text.blue : "* Info: #{text}") if verbose
end
local_shell() click to toggle source

@return [Fulmar::Shell]

# File lib/fulmar/domain/service/helper/common_helper.rb, line 24
def local_shell
  cache_id = "local_shell-#{config[:local_path]}"
  storage[cache_id] ||= new_shell(config[:local_path])
end
new_shell(path, hostname = 'localhost') click to toggle source
# File lib/fulmar/domain/service/helper/common_helper.rb, line 53
def new_shell(path, hostname = 'localhost')
  shell = Fulmar::Shell.new(path, hostname)
  shell.strict = true
  shell.debug = config[:debug]
  shell
end
project() click to toggle source

@return [Fulmar::Domain::Model::Project]

# File lib/fulmar/domain/service/helper/common_helper.rb, line 19
def project
  config.project
end
remote_shell() click to toggle source

@return [Fulmar::Shell]

# File lib/fulmar/domain/service/helper/common_helper.rb, line 30
def remote_shell
  cache_id = "remote_shell-#{config[:remote_path]}-#{config.ssh_user_and_host}"
  storage[cache_id] ||= new_shell(config[:remote_path], config.ssh_user_and_host)
end
render_templates() click to toggle source
# File lib/fulmar/domain/service/helper/common_helper.rb, line 41
def render_templates
  (Fulmar::Domain::Service::TemplateRenderingService.new config).render
end
ssh_config() click to toggle source
# File lib/fulmar/domain/service/helper/common_helper.rb, line 60
def ssh_config
  storage['ssh_config'] ||= Fulmar::Infrastructure::Service::SSHConfigService.new config
end
storage() click to toggle source
# File lib/fulmar/domain/service/helper/common_helper.rb, line 64
def storage
  raise 'You need to set an environment and a target first' unless config.ready?
  @storage ||= {}
  @storage[config.environment] ||= {}
  @storage[config.environment][config.target] ||= {}
end
upload(filename, target = config[:remote_path]) click to toggle source
# File lib/fulmar/domain/service/helper/common_helper.rb, line 45
def upload(filename, target = config[:remote_path])
  Fulmar::Infrastructure::Service::CopyService.upload(local_shell, filename, config.ssh_user_and_host, target)
end
warning(text) click to toggle source
# File lib/fulmar/domain/service/helper/common_helper.rb, line 75
def warning(text)
  STDERR.puts(ENV['TERM'] == 'xterm-256color' ? text.magenta : "* Warning: #{text}")
end