mirror of
https://github.com/nishiki/manage-password.git
synced 2025-02-20 01:50:04 +00:00
multiple fix on syntax
This commit is contained in:
parent
755df6c342
commit
0f7510b6e6
4 changed files with 7 additions and 16 deletions
|
@ -70,9 +70,7 @@ class Cli
|
|||
password = ask(I18n.t('form.setup_gpg_key.password')) { |q| q.echo = false }
|
||||
confirm = ask(I18n.t('form.setup_gpg_key.confirm_password')) { |q| q.echo = false }
|
||||
|
||||
if password != confirm
|
||||
raise I18n.t('form.setup_gpg_key.error_password')
|
||||
end
|
||||
raise I18n.t('form.setup_gpg_key.error_password') if password != confirm
|
||||
|
||||
@password = password.to_s
|
||||
|
||||
|
@ -378,7 +376,7 @@ class Cli
|
|||
opts = YAML.load_file(tmp_file)
|
||||
end
|
||||
|
||||
opts.delete_if { |k, v| v.to_s.empty? }
|
||||
opts.delete_if { |_, v| v.to_s.empty? }
|
||||
|
||||
opts.each do |k, v|
|
||||
options[k.to_sym] = v
|
||||
|
|
|
@ -101,11 +101,8 @@ class Config
|
|||
# expire -> the time of expire to GPG key
|
||||
# @rtrn: true if the GPG key is create, else false
|
||||
def setup_gpg_key(password, name, length = 4096, expire = 0)
|
||||
if name.to_s.empty?
|
||||
raise I18n.t('error.config.genkey_gpg.name')
|
||||
elsif password.to_s.empty?
|
||||
raise I18n.t('error.config.genkey_gpg.password')
|
||||
end
|
||||
raise I18n.t('error.config.genkey_gpg.name') if name.to_s.empty?
|
||||
raise I18n.t('error.config.genkey_gpg.password') if password.to_s.empty?
|
||||
|
||||
param = ''
|
||||
param << '<GnupgKeyParms format="internal">' + "\n"
|
||||
|
|
|
@ -96,7 +96,7 @@ class Item
|
|||
|
||||
# Generate an random id
|
||||
def generate_id
|
||||
([*('A'..'Z'), *('a'..'z'), *('0'..'9')]).sample(16).join
|
||||
[*('A'..'Z'), *('a'..'z'), *('0'..'9')].sample(16).join
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -32,9 +32,7 @@ class MPW
|
|||
@gpg_exe = gpg_exe
|
||||
@wallet_file = wallet_file
|
||||
|
||||
unless @gpg_exe.to_s.empty?
|
||||
GPGME::Engine.set_info(GPGME::PROTOCOL_OpenPGP, @gpg_exe, "#{Dir.home}/.gnupg")
|
||||
end
|
||||
GPGME::Engine.set_info(GPGME::PROTOCOL_OpenPGP, @gpg_exe, "#{Dir.home}/.gnupg") unless @gpg_exe.to_s.empty?
|
||||
end
|
||||
|
||||
# Read mpw file
|
||||
|
@ -204,9 +202,7 @@ class MPW
|
|||
data = GPGME::Key.export(key, armor: true).read
|
||||
end
|
||||
|
||||
if data.to_s.empty?
|
||||
raise I18n.t('error.export_key')
|
||||
end
|
||||
raise I18n.t('error.export_key') if data.to_s.empty?
|
||||
|
||||
@keys[key] = data
|
||||
@passwords.each_key { |id| set_password(id, get_password(id)) }
|
||||
|
|
Loading…
Add table
Reference in a new issue