From 5d267a486580ada4ec0da6581deda75e42e8f075 Mon Sep 17 00:00:00 2001 From: Adrien Waksberg Date: Sun, 26 Feb 2017 21:34:54 +0100 Subject: [PATCH] config: rename key to gpg_key --- lib/mpw/cli.rb | 4 ++-- lib/mpw/config.rb | 14 +++++++------- templates/setup_form.erb | 9 --------- 3 files changed, 9 insertions(+), 18 deletions(-) delete mode 100644 templates/setup_form.erb diff --git a/lib/mpw/cli.rb b/lib/mpw/cli.rb index 409bf5a..3ad32be 100644 --- a/lib/mpw/cli.rb +++ b/lib/mpw/cli.rb @@ -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 diff --git a/lib/mpw/config.rb b/lib/mpw/config.rb index 94b9eb8..2cf5481 100644 --- a/lib/mpw/config.rb +++ b/lib/mpw/config.rb @@ -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 << "\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 diff --git a/templates/setup_form.erb b/templates/setup_form.erb deleted file mode 100644 index f7e6d7b..0000000 --- a/templates/setup_form.erb +++ /dev/null @@ -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 %>