Class: GitPusshuTen::Environment

Inherits:
Object
  • Object
show all
Includes:
Helpers::Environment::Installers, Helpers::Environment::Packages, Helpers::Environment::SCP, Helpers::Environment::SSH, Helpers::Environment::SSHKeys, Helpers::Environment::User
Defined in:
lib/gitpusshuten/environment.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Helpers::Environment::Installers

#ensure_aptitude_installed!, #install!, #install_gitconfig!, #install_pushand!, #installed?, #uninstall!

Methods included from Helpers::Environment::User

#add_user!, #add_user_to_sudoers!, #remove_user!, #user_exists?, #user_in_sudoers?

Methods included from Helpers::Environment::Packages

#clean_up_packages!, #download_packages!

Methods included from Helpers::Environment::SSHKeys

#authorized_root_ssh_keys, #authorized_ssh_keys, #has_ssh_key?, #install_root_ssh_key!, #install_ssh_key!, #root_ssh_key_installed?, #ssh_key, #ssh_key_installed?, #ssh_key_path

Methods included from Helpers::Environment::SSH

#directory?, #execute_as_root, #execute_as_user, #file?

Methods included from Helpers::Environment::SCP

#scp_as_root, #scp_as_user

Constructor Details

#initialize(configuration) ⇒ Environment

Initializes the environment with the provided configuration



22
23
24
# File 'lib/gitpusshuten/environment.rb', line 22

def initialize(configuration)
  @configuration = configuration
end

Instance Attribute Details

#configurationObject

Stores the configuration



18
19
20
# File 'lib/gitpusshuten/environment.rb', line 18

def configuration
  @configuration
end

Instance Method Details

#app_dirObject

Returns the root of the application



52
53
54
# File 'lib/gitpusshuten/environment.rb', line 52

def app_dir
  File.join(home_dir, "#{sanitized_app_name}.#{name}")
end

#app_nameObject

Returns the name of the application



46
47
48
# File 'lib/gitpusshuten/environment.rb', line 46

def app_name
  c.application
end

#cObject

Shorthand for the configuration object



28
29
30
# File 'lib/gitpusshuten/environment.rb', line 28

def c
  configuration
end

#delete!Object

Deletes the current environment (application)



65
66
67
# File 'lib/gitpusshuten/environment.rb', line 65

def delete!
  execute_as_user("rm -rf #{app_dir}")
end

#home_dirObject

Users home directory



40
41
42
# File 'lib/gitpusshuten/environment.rb', line 40

def home_dir
  c.path
end

#nameObject

Returns the name of the environment



34
35
36
# File 'lib/gitpusshuten/environment.rb', line 34

def name
  c.environment
end

#sanitized_app_nameObject

Takes the application name from the configuration and replaces spaces with underscores and downcases capitalized characters



59
60
61
# File 'lib/gitpusshuten/environment.rb', line 59

def sanitized_app_name
  app_name.gsub(' ', '_').downcase
end