Class: RedmineInstaller::Configuration::Base

Inherits:
Object
  • Object
show all
Includes:
Utils
Defined in:
lib/redmine-installer/configuration.rb

Direct Known Subclasses

CustomConfiguration, Gmail, Nothing, SendMail

Constant Summary

Constants included from Utils

Utils::PROGRESSBAR_FORMAT

Instance Method Summary collapse

Methods included from Utils

#class_name, #create_dir, #env_user, #error, #logger, #ok, #pastel, #print_title, #prompt, #run_command

Constructor Details

#initialize(redmine) ⇒ Base

Returns a new instance of Base.



31
32
33
# File 'lib/redmine-installer/configuration.rb', line 31

def initialize(redmine)
  @redmine = redmine
end

Instance Method Details

#buildObject



46
47
48
49
50
51
52
53
54
55
# File 'lib/redmine-installer/configuration.rb', line 46

def build
  {
    'default' => {
      'email_delivery' => {
        'delivery_method' => delivery_method,
        "#{delivery_method}_settings" => delivery_settings
      }
    }
  }
end

#delivery_methodObject



57
58
59
# File 'lib/redmine-installer/configuration.rb', line 57

def delivery_method
  :smtp
end

#delivery_settingsObject



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/redmine-installer/configuration.rb', line 61

def delivery_settings
  settings = {}

  # Required
  settings['address'] = @address
  settings['port']    = @port

  # Optional
  settings['authentication']       = @authentication  unless @authentication.to_s.empty?
  settings['domain']               = @domain          unless @domain.to_s.empty?
  settings['user_name']            = @user_name       unless @user_name.to_s.empty?
  settings['password']             = @password        unless @password.to_s.empty?
  settings['enable_starttls_auto'] = @enable_starttls unless @enable_starttls.to_s.empty?
  settings['openssl_verify_mode']  = @openssl_verify  unless @openssl_verify.to_s.empty?

  settings
end

#get_parametersObject



35
36
37
38
# File 'lib/redmine-installer/configuration.rb', line 35

def get_parameters
  @username = prompt.ask('Username:', required: true)
  @password = prompt.mask('Password:', required: true)
end

#make_configObject



40
41
42
43
44
# File 'lib/redmine-installer/configuration.rb', line 40

def make_config
  File.open(@redmine.configuration_yml_path, 'w') do |f|
    f.puts(YAML.dump(build))
  end
end

#to_sObject



79
80
81
# File 'lib/redmine-installer/configuration.rb', line 79

def to_s
  "<#{class_name} #{@username}@#{@address}:#{@port}>"
end