mirror of
https://github.com/nishiki/manage-password.git
synced 2025-02-20 01:50:04 +00:00
config: rename key to gpg_key
This commit is contained in:
parent
d6f7c78eb1
commit
5d267a4865
3 changed files with 9 additions and 18 deletions
|
@ -98,7 +98,7 @@ class Cli
|
|||
|
||||
#wallet_file = wallet.nil? ? "#{@config.wallet_dir}/default.mpw" : "#{@config.wallet_dir}/#{wallet}.mpw"
|
||||
|
||||
@mpw = MPW.new(@config.key, @wallet_file, @password, @config.gpg_exe)
|
||||
@mpw = MPW.new(@config.gpg_key, @wallet_file, @password, @config.gpg_exe)
|
||||
@mpw.read_data
|
||||
@mpw.set_config(options)
|
||||
@mpw.write_data
|
||||
|
@ -127,7 +127,7 @@ class Cli
|
|||
def decrypt
|
||||
if not defined?(@mpw)
|
||||
@password = ask(I18n.t('display.gpg_password')) {|q| q.echo = false}
|
||||
@mpw = MPW.new(@config.key, @wallet_file, @password, @config.gpg_exe)
|
||||
@mpw = MPW.new(@config.gpg_key, @wallet_file, @password, @config.gpg_exe)
|
||||
end
|
||||
|
||||
@mpw.read_data
|
||||
|
|
|
@ -26,7 +26,7 @@ class Config
|
|||
|
||||
attr_accessor :error_msg
|
||||
|
||||
attr_accessor :key
|
||||
attr_accessor :gpg_key
|
||||
attr_accessor :lang
|
||||
attr_accessor :config_dir
|
||||
attr_accessor :default_wallet
|
||||
|
@ -54,7 +54,7 @@ class Config
|
|||
# @args: options -> hash with values
|
||||
# @rtrn: true if le config file is create
|
||||
def setup(options)
|
||||
gpg_key = options[:gpg_key] || @key
|
||||
gpg_key = options[:gpg_key] || @gpg_key
|
||||
lang = options[:lang] || @lang
|
||||
wallet_dir = options[:wallet_dir] || @wallet_dir
|
||||
default_wallet = options[:default_wallet] || @default_wallet
|
||||
|
@ -78,7 +78,7 @@ class Config
|
|||
end
|
||||
|
||||
wallet_dir = "#{@config_dir}/wallets" if wallet_dir.to_s.empty?
|
||||
config = { 'key' => gpg_key,
|
||||
config = { 'gpg_key' => gpg_key,
|
||||
'lang' => lang,
|
||||
'wallet_dir' => wallet_dir,
|
||||
'default_wallet' => default_wallet,
|
||||
|
@ -117,7 +117,7 @@ class Config
|
|||
param << "Subkey-Length: #{length}\n"
|
||||
param << "Name-Real: #{name}\n"
|
||||
param << "Name-Comment: #{name}\n"
|
||||
param << "Name-Email: #{@key}\n"
|
||||
param << "Name-Email: #{@gpg_key}\n"
|
||||
param << "Expire-Date: #{expire}\n"
|
||||
param << "Passphrase: #{password}\n"
|
||||
param << "</GnupgKeyParms>\n"
|
||||
|
@ -131,14 +131,14 @@ class Config
|
|||
# Load the config file
|
||||
def load_config
|
||||
config = YAML::load_file(@config_file)
|
||||
@key = config['key']
|
||||
@gpg_key = config['gpg_key']
|
||||
@lang = config['lang']
|
||||
@wallet_dir = config['wallet_dir']
|
||||
@default_wallet = config['default_wallet']
|
||||
@gpg_exe = config['gpg_exe']
|
||||
@password = config['password']
|
||||
|
||||
raise if @key.empty? or @wallet_dir.empty?
|
||||
raise if @gpg_key.empty? or @wallet_dir.empty?
|
||||
|
||||
I18n.locale = @lang.to_sym
|
||||
rescue Exception => e
|
||||
|
@ -149,7 +149,7 @@ class Config
|
|||
# @rtrn: true if the key exist, else false
|
||||
def check_gpg_key?
|
||||
ctx = GPGME::Ctx.new
|
||||
ctx.each_key(@key, true) do
|
||||
ctx.each_key(@gpg_key, true) do
|
||||
return true
|
||||
end
|
||||
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
---
|
||||
# <%= I18n.t('form.setup_config.lang') %>
|
||||
language: <%= @config.lang %>
|
||||
# <%= I18n.t('form.setup_config.gpg_key') %>
|
||||
gpg_key: <%= @config.key %>
|
||||
# <%= I18n.t('form.setup_config.wallet_dir') %>
|
||||
wallet_dir: <%= @config.config_dir %>
|
||||
# <%= I18n.t('form.setup_config.gpg_exe') %>
|
||||
gpg_exe: <%= @config.gpg_exe %>
|
Loading…
Add table
Reference in a new issue