1
0
Fork 0
mirror of https://github.com/nishiki/manage-password.git synced 2025-02-22 02:40:04 +00:00

fix syntax for variable with multiple conditional

This commit is contained in:
Adrien Waksberg 2017-03-30 19:41:00 +02:00
parent 3c787371b3
commit 755df6c342
3 changed files with 28 additions and 25 deletions

View file

@ -317,18 +317,19 @@ class Cli
# Display the wallet # Display the wallet
# @args: wallet -> the wallet name # @args: wallet -> the wallet name
def get_wallet(wallet = nil) def get_wallet(wallet = nil)
@wallet_file =
if wallet.to_s.empty? if wallet.to_s.empty?
wallets = Dir.glob("#{@config.wallet_dir}/*.mpw") wallets = Dir.glob("#{@config.wallet_dir}/*.mpw")
if wallets.length == 1 if wallets.length == 1
@wallet_file = wallets[0] wallets[0]
elsif !@config.default_wallet.to_s.empty? elsif !@config.default_wallet.to_s.empty?
@wallet_file = "#{@config.wallet_dir}/#{@config.default_wallet}.mpw" "#{@config.wallet_dir}/#{@config.default_wallet}.mpw"
else else
@wallet_file = "#{@config.wallet_dir}/default.mpw" "#{@config.wallet_dir}/default.mpw"
end end
else else
@wallet_file = "#{@config.wallet_dir}/#{wallet}.mpw" "#{@config.wallet_dir}/#{wallet}.mpw"
end end
end end

View file

@ -38,12 +38,13 @@ class Config
def initialize(config_file = nil) def initialize(config_file = nil)
@config_file = config_file @config_file = config_file
@config_dir =
if /darwin/ =~ RUBY_PLATFORM if /darwin/ =~ RUBY_PLATFORM
@config_dir = "#{Dir.home}/Library/Preferences/mpw" "#{Dir.home}/Library/Preferences/mpw"
elsif /cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM elsif /cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM
@config_dir = "#{Dir.home}/AppData/Local/mpw" "#{Dir.home}/AppData/Local/mpw"
else else
@config_dir = "#{Dir.home}/.config/mpw" "#{Dir.home}/.config/mpw"
end end
@config_file = "#{@config_dir}/mpw.cfg" if @config_file.nil? || @config_file.empty? @config_file = "#{@config_dir}/mpw.cfg" if @config_file.nil? || @config_file.empty?

View file

@ -308,13 +308,14 @@ class MPW
# Generate a random password # Generate a random password
# @args: options -> :length, :special, :alpha, :numeric # @args: options -> :length, :special, :alpha, :numeric
# @rtrn: a random string # @rtrn: a random string
def self.password(options = {}) def self.password(**options)
length =
if !options.include?(:length) || options[:length].to_i <= 0 if !options.include?(:length) || options[:length].to_i <= 0
length = 8 8
elsif options[:length].to_i >= 32768 elsif options[:length].to_i >= 32_768
length = 32768 32_768
else else
length = options[:length].to_i options[:length].to_i
end end
chars = [] chars = []