Class: Availability::Setup

Inherits:
Object
  • Object
show all
Defined in:
lib/availability/setup.rb

Overview

Creates deployment starter files without replacing existing configuration.

Constant Summary collapse

SERVER_NAME_PATTERN =
/\A[a-zA-Z0-9.-]+\z/
URL_PATH_PATTERN =
%r{\A/[a-zA-Z0-9_-]+/\z}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config_path:, nginx_path:, output_dir:, log_dir:, server_name:, url_path:) ⇒ Setup

Returns a new instance of Setup.



12
13
14
15
16
17
18
19
# File 'lib/availability/setup.rb', line 12

def initialize(config_path:, nginx_path:, output_dir:, log_dir:, server_name:, url_path:)
  @config_path = File.expand_path(config_path)
  @nginx_path = File.expand_path(nginx_path)
  @output_dir = File.expand_path(output_dir)
  @log_dir = File.expand_path(log_dir)
  @server_name = server_name
  @url_path = url_path
end

Instance Attribute Details

#config_pathObject (readonly)

Returns the value of attribute config_path.



21
22
23
# File 'lib/availability/setup.rb', line 21

def config_path
  @config_path
end

#log_dirObject (readonly)

Returns the value of attribute log_dir.



21
22
23
# File 'lib/availability/setup.rb', line 21

def log_dir
  @log_dir
end

#nginx_pathObject (readonly)

Returns the value of attribute nginx_path.



21
22
23
# File 'lib/availability/setup.rb', line 21

def nginx_path
  @nginx_path
end

#output_dirObject (readonly)

Returns the value of attribute output_dir.



21
22
23
# File 'lib/availability/setup.rb', line 21

def output_dir
  @output_dir
end

Instance Method Details

#runObject



23
24
25
26
27
28
29
30
31
32
33
# File 'lib/availability/setup.rb', line 23

def run
  validate!
  ensure_targets_are_available!
  create_files
  FileUtils.mkdir_p(output_dir)
  FileUtils.mkdir_p(log_dir)
  true
rescue SystemCallError => e
  cleanup_created_files
  raise SetupError, "Setup failed: #{e.message}"
end