From 60eef298ce81b1a452fe9b39d65571d97b1babc7 Mon Sep 17 00:00:00 2001 From: nishiki Date: Thu, 18 Jul 2013 22:12:45 +0200 Subject: [PATCH] fix bug setup --- cli.rb => Cli.rb | 3 +-- MPW.rb | 4 ++-- mpw | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) rename cli.rb => Cli.rb (98%) diff --git a/cli.rb b/Cli.rb similarity index 98% rename from cli.rb rename to Cli.rb index af06144..bc39f44 100755 --- a/cli.rb +++ b/Cli.rb @@ -31,7 +31,7 @@ class Cli file_pwd = ask("Enter te path to password file [default=#{Dir.home()}/.mpw.pwd]: ") timeout_pwd = ask("Enter the timeout (in seconde) to GPG password [default=300]: ") - if setup(key, file_gpg, file_pwd, timeout_pwd) + if @m.setup(key, file_gpg, file_pwd, timeout_pwd) puts "The config file has been created!" else puts "ERROR: #{@m.error_msg}" @@ -114,7 +114,6 @@ class Cli end def remove(id, force=false) - if not force confirm = ask("Are you sur to remove the item: #{id} ? (y/N) ") if confirm =~ /^(y|yes|YES|Yes|Y)$/ diff --git a/MPW.rb b/MPW.rb index a040a12..a646fc2 100755 --- a/MPW.rb +++ b/MPW.rb @@ -133,10 +133,10 @@ class MPW # Check if a password it saved # @rtrn: true if a password exist in the password file def checkFilePassword() - if File.exist?(@file_pwd) && File.stat(@file_pwd).mtime.to_i + @timeout_pwd < Time.now.to_i + if !@file_pwd.nil? && File.exist?(@file_pwd) && File.stat(@file_pwd).mtime.to_i + @timeout_pwd < Time.now.to_i File.delete(@file_pwd) return false - elsif File.exist?(@file_pwd) + elsif !@file_pwd.nil? && File.exist?(@file_pwd) return true else return false diff --git a/mpw b/mpw index db95d96..5da07d6 100755 --- a/mpw +++ b/mpw @@ -8,7 +8,7 @@ require 'optparse' require 'pathname' APP_ROOT = File.dirname(Pathname.new(__FILE__).realpath) -require "#{APP_ROOT}/cli.rb" +require "#{APP_ROOT}/Cli.rb" options = {} OptionParser.new do |opts|