1
0
Fork 0
mirror of https://github.com/nishiki/manage-password.git synced 2025-02-20 01:50: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,19 +317,20 @@ class Cli
# Display the wallet
# @args: wallet -> the wallet name
def get_wallet(wallet = nil)
if wallet.to_s.empty?
wallets = Dir.glob("#{@config.wallet_dir}/*.mpw")
@wallet_file =
if wallet.to_s.empty?
wallets = Dir.glob("#{@config.wallet_dir}/*.mpw")
if wallets.length == 1
@wallet_file = wallets[0]
elsif !@config.default_wallet.to_s.empty?
@wallet_file = "#{@config.wallet_dir}/#{@config.default_wallet}.mpw"
if wallets.length == 1
wallets[0]
elsif !@config.default_wallet.to_s.empty?
"#{@config.wallet_dir}/#{@config.default_wallet}.mpw"
else
"#{@config.wallet_dir}/default.mpw"
end
else
@wallet_file = "#{@config.wallet_dir}/default.mpw"
"#{@config.wallet_dir}/#{wallet}.mpw"
end
else
@wallet_file = "#{@config.wallet_dir}/#{wallet}.mpw"
end
end
# Add a new public key

View file

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

View file

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