Module: Ruby::Nginx

Includes:
Exceptions
Defined in:
lib/ruby/nginx.rb,
lib/ruby/nginx/cli.rb,
lib/ruby/nginx/version.rb,
lib/ruby/nginx/constants.rb,
lib/ruby/nginx/system/os.rb,
lib/ruby/nginx/exceptions.rb,
lib/ruby/nginx/system/hosts.rb,
lib/ruby/nginx/system/nginx.rb,
lib/ruby/nginx/configuration.rb,
lib/ruby/nginx/system/mkcert.rb,
lib/ruby/nginx/system/safe_file.rb,
lib/ruby/nginx/commands/stop_nginx.rb,
lib/ruby/nginx/commands/setup_nginx.rb,
lib/ruby/nginx/commands/start_nginx.rb,
lib/ruby/nginx/commands/setup_mkcert.rb,
lib/ruby/nginx/commands/install_nginx.rb,
lib/ruby/nginx/commands/nginx_options.rb,
lib/ruby/nginx/commands/nginx_version.rb,
lib/ruby/nginx/commands/install_mkcert.rb,
lib/ruby/nginx/commands/add_host_mapping.rb,
lib/ruby/nginx/commands/add_nginx_config.rb,
lib/ruby/nginx/commands/terminal_command.rb,
lib/ruby/nginx/commands/helpers/sudo_helper.rb,
lib/ruby/nginx/commands/remove_host_mapping.rb,
lib/ruby/nginx/commands/remove_nginx_config.rb,
lib/ruby/nginx/commands/helpers/prompt_helper.rb,
lib/ruby/nginx/commands/validate_nginx_config.rb,
lib/ruby/nginx/commands/create_mkcert_certificate.rb

Defined Under Namespace

Modules: Commands, Constants, Exceptions, System Classes: CLI, Configuration

Constant Summary collapse

VERSION =
"1.0.4"
Version =
Gem::Version

Constants included from Exceptions

Exceptions::AbortError, Exceptions::ConfigError, Exceptions::CreateError, Exceptions::Error, Exceptions::InstallError, Exceptions::SetupError, Exceptions::StartError, Exceptions::StopError

Class Method Summary collapse

Class Method Details

.add!(options = {}, &block) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/ruby/nginx.rb', line 13

def self.add!(options = {}, &block)
  setup!
  conf = config(options, &block)

  if System::Nginx.add_server_config(conf.name, conf.generate!)
    System::Nginx.validate_config!
    System::Nginx.restart!
  end

  System::Hosts.add(conf.domain, conf.host)

  conf
rescue Ruby::Nginx::AbortError
  raise
rescue Ruby::Nginx::Error
  remove!(options)
  raise
end

.remove!(options = {}, &block) ⇒ Object



32
33
34
35
36
37
38
39
# File 'lib/ruby/nginx.rb', line 32

def self.remove!(options = {}, &block)
  conf = config(options, &block)

  System::Nginx.restart! if System::Nginx.remove_server_config(conf.name)
  System::Hosts.remove(conf.domain)

  conf
end