class Dockerploy::Template

Constants

CONFIG_PATH
TEMPLATE_PATH

Public Class Methods

application_name() click to toggle source
# File lib/dockerploy/template.rb, line 6
def self.application_name
  File.basename(Dir.getwd)
end
generate() click to toggle source
# File lib/dockerploy/template.rb, line 16
def self.generate
  namespace = OpenStruct.new(user: ENV['USER'], application_name: self.application_name, project_name: self.project_name)
  template = File.read(File.expand_path(TEMPLATE_PATH, File.dirname(__FILE__)))
  ERB.new(template).result(namespace.instance_eval { binding })
end
project_name() click to toggle source
# File lib/dockerploy/template.rb, line 10
def self.project_name
  shell_client = ShellClient.new
  shell_client.command('git config --get remote.origin.url')
  shell_client.output.match(/([\w-]+\/[\w-]+).git/)[1]
end
write() click to toggle source
# File lib/dockerploy/template.rb, line 22
def self.write
  FileUtils.mkdir_p('docker')
  File.open(CONFIG_PATH, 'w') { |f| f.write(self.generate) }
end