Class: Ruby::Nginx::CLI

Inherits:
Thor
  • Object
show all
Includes:
Thor::Actions
Defined in:
lib/ruby/nginx/cli.rb

Constant Summary collapse

FAKE_CONFIG =
Ruby::Nginx::Configuration.new(domain: "[DOMAIN]")

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.default_paths(param) ⇒ Object



17
18
19
# File 'lib/ruby/nginx/cli.rb', line 17

def self.default_paths(param)
  "default: #{FAKE_CONFIG.default_paths[param]}"
end

.defaults(param) ⇒ Object



13
14
15
# File 'lib/ruby/nginx/cli.rb', line 13

def self.defaults(param)
  "default: #{FAKE_CONFIG.defaults[param]}"
end

Instance Method Details

#addObject



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/ruby/nginx/cli.rb', line 33

def add
  config = {
    domain: options.domain,
    port: options.port,
    host: options.host,
    root_path: options.root_path,
    template_path: options.template_path,
    ssl: options.ssl,
    log: options.log,
    ssl_certificate_path: options.ssl_certificate_path,
    ssl_certificate_key_path: options.ssl_certificate_key_path,
    access_log_path: options.access_log_path,
    error_log_path: options.error_log_path
  }.compact

  Ruby::Nginx.add!(**config)
rescue Ruby::Nginx::Error => e
  abort "[Ruby::Nginx] #{e.message}"
end

#removeObject



55
56
57
58
59
# File 'lib/ruby/nginx/cli.rb', line 55

def remove
  Ruby::Nginx.remove!(domain: options.domain)
rescue Ruby::Nginx::Error => e
  abort "[Ruby::Nginx] #{e.message}"
end