class SmartMachine::User

Public Class Methods

create_htpasswd_files() click to toggle source
# File lib/smart_machine/user.rb, line 11
def self.create_htpasswd_files
        htpasswd_dirpath = "#{Dir.pwd}/grids/nginx/htpasswd"

        # Remove existing htpasswd_dirpath
        FileUtils.rm_r htpasswd_dirpath if Dir.exist?(htpasswd_dirpath)
        
        # Create new htpasswd_dirpath
        FileUtils.mkdir htpasswd_dirpath

        # Add hostfiles to htpasswd_dirpath
        self.get_users_from_file.each do |domainname, users|
                next unless users

                file_data = ""
                users.each do |user, password|
                        file_data += "#{user}:#{BCrypt::Password.create(password)}\n"
                end
                File.open("#{Dir.pwd}/grids/nginx/htpasswd/#{domainname}", "w") { |file| file.write(file_data) }
        end
end
new() click to toggle source
# File lib/smart_machine/user.rb, line 8
def initialize
end

Private Class Methods

get_users_from_file() click to toggle source
# File lib/smart_machine/user.rb, line 34
def self.get_users_from_file
        YAML.load_file("#{Dir.pwd}/config/users.yml") || Hash.new
end