Module: ConfigUnique

Included in:
App::Config, App::Config
Defined in:
lib/core/config_unique.rb

Constant Summary collapse

CONFIG_FILE =

USED BY CONFIG CLASS

'~/.brightpearlrc'
GEM_NAME =
'brightpearl'
MAC =

MISC

'mac'
LINUX =
'linux'
WORKSTATION_OS =

STORED PARAMETERS

'workstation_os'
WORKSTATION_PATH_TO_BP_CODE =
'workstation_path_to_bp_code'
WORKSTATION_PATH_TO_BP_DB =
'workstation_path_to_bp_db'
VM_IP =
'vm_ip'
VM_USER =
'vm_user'
VM_USER_PASSWORD =
'vm_user_password'
VM_MYSQL_USER =
'vm_mysql_user'
VM_MYSQL_PASSWORD =
'vm_mysql_password'
PREFERRED_TEXT_EDITOR =
'preferred_text_editor'
GIT_USERNAME =
'git_username'
CRYPT_KEY =
'crypt_key'
CRYPT_HEX =
'crypt_hex'
EC2_HOST =
'ec2_host'
EC2_USER =
'ec2_user'
EC2_PASS =
'ec2_pass'
BETA =

BETA

'beta'

Instance Method Summary collapse

Instance Method Details

#config_file_createObject



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/core/config_unique.rb', line 51

def config_file_create
    File.open("#{File.expand_path(CONFIG_FILE)}", 'w') { |file|
        file.write("# CONFIGURATION FILE -- Use this file to configure brightpearl-cli\n")
        file.write("\n")
        file.write("#{WORKSTATION_OS}=linux\n")
        file.write("#{WORKSTATION_PATH_TO_BP_CODE}=~/brightpearl-source/brightpearl-code\n")
        file.write("#{WORKSTATION_PATH_TO_BP_DB}=~/brightpearl-source/brightpearl-db\n")
        file.write("\n")
        file.write("#{VM_IP}=172.27.X.X\n")
        file.write("#{VM_USER}=\n")
        file.write("#{VM_USER_PASSWORD}=\n")
        file.write("#{VM_MYSQL_USER}=root\n")
        file.write("#{VM_MYSQL_PASSWORD}=peXXXXXXXre\n")
        file.write("\n")
        file.write("# Usually vi, vim or nano\n")
        file.write("#{PREFERRED_TEXT_EDITOR}=\n")
        file.write("\n")
        file.write("# Found by running $ git config user.name\n")
        file.write("#{GIT_USERNAME}=\n")
    }
end

#param(param_name) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/core/config_unique.rb', line 34

def param(param_name)

    # IF RETRIEVING DIRECTORIES
    if [
        WORKSTATION_PATH_TO_BP_CODE,
        WORKSTATION_PATH_TO_BP_DB,
    ].include?(param_name)
        begin
            return "/#{App::UtilsStrings.remove_surrounding_slashes(File.expand_path(@params[param_name]))}"
        rescue Exception => e
            App::Terminal::error("Something went wrong trying to get parameter: #{param_name}", e.message)
        end
    end

    @params[param_name]
end

#required_config_keysObject



73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/core/config_unique.rb', line 73

def required_config_keys
    [
        WORKSTATION_OS,
        WORKSTATION_PATH_TO_BP_CODE,
        WORKSTATION_PATH_TO_BP_DB,
        VM_IP,
        VM_USER,
        VM_USER_PASSWORD,
        VM_MYSQL_USER,
        VM_MYSQL_PASSWORD,
        PREFERRED_TEXT_EDITOR,
        GIT_USERNAME
    ]
end