Module: Fulmar::Domain::Service::Helper::CommonHelper

Defined in:
lib/fulmar/service/helper/common_helper.rb

Overview

Provides the helper methods used in the tasks

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#environmentObject

Returns the value of attribute environment.



10
11
12
# File 'lib/fulmar/service/helper/common_helper.rb', line 10

def environment
  @environment
end

Instance Method Details

#composer(command, arguments = []) ⇒ Object



20
21
22
# File 'lib/fulmar/service/helper/common_helper.rb', line 20

def composer(command, arguments = [])
  (storage['composer'] ||= Fulmar::Infrastructure::Service::ComposerService.new(local_shell)).execute(command, arguments)
end

#configurationObject



16
17
18
# File 'lib/fulmar/service/helper/common_helper.rb', line 16

def configuration
  (@_config_service ||= Fulmar::Domain::Service::ConfigurationService.instance)
end

#download(filename) ⇒ Object



48
49
50
# File 'lib/fulmar/service/helper/common_helper.rb', line 48

def download(filename)
  Fulmar::Infrastructure::Service::CopyService.download(local_shell, configuration[:hostname], filename, configuration[:local_path])
end

#error(text) ⇒ Object



74
75
76
# File 'lib/fulmar/service/helper/common_helper.rb', line 74

def error(text)
  puts (ENV['TERM'] == 'xterm-256color' ? text.light_red : "* Error: #{text}")
end

#file_syncObject



32
33
34
# File 'lib/fulmar/service/helper/common_helper.rb', line 32

def file_sync
  storage['file_sync'] ||= Fulmar::FileSync.create_transfer configuration
end

#full_configurationObject



12
13
14
# File 'lib/fulmar/service/helper/common_helper.rb', line 12

def full_configuration
  configuration.configuration
end

#gitObject



40
41
42
# File 'lib/fulmar/service/helper/common_helper.rb', line 40

def git
  storage['git'] ||= Fulmar::Infrastructure::Service::GitService.new configuration
end

#info(text) ⇒ Object



66
67
68
# File 'lib/fulmar/service/helper/common_helper.rb', line 66

def info(text)
  puts (ENV['TERM'] == 'xterm-256color' ? text.blue : "* Info: #{text}")
end

#local_shellObject



24
25
26
# File 'lib/fulmar/service/helper/common_helper.rb', line 24

def local_shell
  storage['local_shell'] ||= new_shell(configuration[:local_path])
end

#new_shell(path, hostname = 'localhost') ⇒ Object



52
53
54
55
56
57
# File 'lib/fulmar/service/helper/common_helper.rb', line 52

def new_shell(path, hostname = 'localhost')
  shell = Fulmar::Infrastructure::Service::ShellService.new(path, hostname)
  shell.strict = true
  shell.debug = configuration[:debug]
  shell
end

#remote_shellObject



28
29
30
# File 'lib/fulmar/service/helper/common_helper.rb', line 28

def remote_shell
  storage['remote_shell'] ||= new_shell(configuration[:remote_path], (configuration[:user] ? configuration[:user]+'@' : '')+configuration[:hostname])
end

#render_templatesObject



36
37
38
# File 'lib/fulmar/service/helper/common_helper.rb', line 36

def render_templates
  (Fulmar::Domain::Service::ConfigRenderingService.new configuration).render
end

#storageObject



59
60
61
62
63
64
# File 'lib/fulmar/service/helper/common_helper.rb', line 59

def storage
  fail 'You need to set an environment and a target first' unless configuration.ready?
  @storage ||= {}
  @storage[configuration.environment] ||= {}
  @storage[configuration.environment][configuration.target] ||= {}
end

#upload(filename) ⇒ Object



44
45
46
# File 'lib/fulmar/service/helper/common_helper.rb', line 44

def upload(filename)
  Fulmar::Infrastructure::Service::CopyService.upload(local_shell, filename, configuration[:hostname], configuration[:remote_path])
end

#warn(text) ⇒ Object



70
71
72
# File 'lib/fulmar/service/helper/common_helper.rb', line 70

def warn(text)
  puts (ENV['TERM'] == 'xterm-256color' ? text.magenta : "* Warning: #{text}")
end