From b1fd013d921f12f71b93bc1db0a532bd6562f44b Mon Sep 17 00:00:00 2001 From: Adrien Waksberg Date: Wed, 29 Mar 2017 23:15:45 +0200 Subject: [PATCH] fix indentation for multiline method and hash --- lib/mpw/cli.rb | 32 +++++++++++++++--------------- lib/mpw/config.rb | 6 ++---- lib/mpw/mpw.rb | 50 +++++++++++++++++++++++++---------------------- 3 files changed, 45 insertions(+), 43 deletions(-) diff --git a/lib/mpw/cli.rb b/lib/mpw/cli.rb index 3488b5a..12f18af 100644 --- a/lib/mpw/cli.rb +++ b/lib/mpw/cli.rb @@ -148,8 +148,7 @@ class MPW::Cli protocol: { length: 9, color: 'white' }, port: { length: 5, color: 'white' }, otp: { length: 4, color: 'white' }, - comment: { length: 14, color: 'magenta' }, - } + comment: { length: 14, color: 'magenta' } } items.each do |item| data.each do |k, v| @@ -481,18 +480,20 @@ class MPW::Cli data = {} items.each do |item| - data.merge!(item.id => { 'host' => item.host, - 'user' => item.user, - 'group' => item.group, - 'password' => @mpw.get_password(item.id), - 'protocol' => item.protocol, - 'port' => item.port, - 'otp_key' => @mpw.get_otp_key(item.id), - 'comment' => item.comment, - 'last_edit' => item.last_edit, - 'created' => item.created, - } - ) + data.merge!( + item.id => { + 'host' => item.host, + 'user' => item.user, + 'group' => item.group, + 'password' => @mpw.get_password(item.id), + 'protocol' => item.protocol, + 'port' => item.port, + 'otp_key' => @mpw.get_otp_key(item.id), + 'comment' => item.comment, + 'last_edit' => item.last_edit, + 'created' => item.created, + } + ) end File.open(file, 'w') { |f| f << data.to_yaml } @@ -514,8 +515,7 @@ class MPW::Cli protocol: row['protocol'], user: row['user'], port: row['port'], - comment: row['comment'], - ) + comment: row['comment']) next if item.empty? diff --git a/lib/mpw/config.rb b/lib/mpw/config.rb index 4818104..f82fadb 100644 --- a/lib/mpw/config.rb +++ b/lib/mpw/config.rb @@ -60,8 +60,7 @@ class MPW::Config password = { numeric: true, alpha: true, special: false, - length: 16, - } + length: 16 } %w(numeric special alpha length).each do |k| if options.key?("pwd_#{k}".to_sym) @@ -81,8 +80,7 @@ class MPW::Config 'wallet_dir' => wallet_dir, 'default_wallet' => default_wallet, 'gpg_exe' => gpg_exe, - 'password' => password, - } + 'password' => password } FileUtils.mkdir_p(@config_dir, mode: 0700) FileUtils.mkdir_p(wallet_dir, mode: 0700) diff --git a/lib/mpw/mpw.rb b/lib/mpw/mpw.rb index 0aa9aea..1e385cb 100644 --- a/lib/mpw/mpw.rb +++ b/lib/mpw/mpw.rb @@ -80,18 +80,20 @@ class MPW::MPW unless data.to_s.empty? YAML.safe_load(data).each_value do |d| - @data.push(Item.new(id: d['id'], - group: d['group'], - host: d['host'], - protocol: d['protocol'], - user: d['user'], - port: d['port'], - otp: @otp_keys.key?(d['id']), - comment: d['comment'], - last_edit: d['last_edit'], - created: d['created'], - ) - ) + @data.push( + Item.new( + id: d['id'], + group: d['group'], + host: d['host'], + protocol: d['protocol'], + user: d['user'], + port: d['port'], + otp: @otp_keys.key?(d['id']), + comment: d['comment'], + last_edit: d['last_edit'], + created: d['created'], + ) + ) end end @@ -108,17 +110,19 @@ class MPW::MPW @data.each do |item| next if item.empty? - data.merge!(item.id => { 'id' => item.id, - 'group' => item.group, - 'host' => item.host, - 'protocol' => item.protocol, - 'user' => item.user, - 'port' => item.port, - 'comment' => item.comment, - 'last_edit' => item.last_edit, - 'created' => item.created, - } - ) + data.merge!( + item.id => { + 'id' => item.id, + 'group' => item.group, + 'host' => item.host, + 'protocol' => item.protocol, + 'user' => item.user, + 'port' => item.port, + 'comment' => item.comment, + 'last_edit' => item.last_edit, + 'created' => item.created, + } + ) end @config['last_update'] = Time.now.to_i