From d2eb57a5c42ccc27b459d2234e2d80777c864738 Mon Sep 17 00:00:00 2001 From: nishiki Date: Sun, 16 Nov 2014 19:50:09 +0100 Subject: [PATCH] update syntax --- lib/Sync/FTP.rb | 10 +++------- lib/Sync/MPWSync.rb | 20 ++++++++------------ lib/Sync/SSH.rb | 10 +++------- 3 files changed, 14 insertions(+), 26 deletions(-) diff --git a/lib/Sync/FTP.rb b/lib/Sync/FTP.rb index 6a6b236..4b6ba33 100644 --- a/lib/Sync/FTP.rb +++ b/lib/Sync/FTP.rb @@ -51,9 +51,7 @@ module MPW # @args: gpg_password -> the gpg password # @rtrn: nil if nothing data or error def get(gpg_password) - if !@enable - return nil - end + return nil if not @enable tmp_file = tmpfile Net::FTP.open(@host) do |ftp| @@ -62,7 +60,7 @@ module MPW end mpw = MPW.new(tmp_file) - if !mpw.decrypt(gpg_password) + if not mpw.decrypt(gpg_password) @error_msg = mpw.error_msg return nil end @@ -78,9 +76,7 @@ module MPW # @args: data -> the data to send on server # @rtrn: false if there is a problem def update(data) - if !@enable - return true - end + return true if not @enable tmp_file = tmpfile File.open(tmp_file, "w") do |file| diff --git a/lib/Sync/MPWSync.rb b/lib/Sync/MPWSync.rb index 730d9fb..1a9f7b6 100644 --- a/lib/Sync/MPWSync.rb +++ b/lib/Sync/MPWSync.rb @@ -33,7 +33,7 @@ module MPW # @rtrn: false if the connection fail def connect(host, user, password, path, port=nil) @host = host - @port = !port.instance_of?(Integer) ? 2201 : port + @port = not port.instance_of?(Integer) ? 2201 : port @gpg_key = user @password = password @suffix = path @@ -62,9 +62,7 @@ module MPW # @args: gpg_password -> the gpg password # @rtrn: nil if nothing data or error def get(gpg_password) - if !@enable - return nil - end + return nil if not @enable msg = nil TCPSocket.open(@host, @port) do |socket| @@ -78,13 +76,13 @@ module MPW msg = JSON.parse(socket.gets) end - if !defined?(msg['error']) + if not defined?(msg['error']) @error_msg = I18n.t('error.sync.communication') return nil - elsif !msg['error'].nil? + elsif not msg['error'].nil? @error_msg = I18n.t(msg['error']) return nil - elsif msg['data'].nil? || msg['data'].empty? + elsif msg['data'].nil? or msg['data'].empty? return [] else tmp_file = tmpfile @@ -93,7 +91,7 @@ module MPW end mpw = MPW.new(tmp_file) - if !mpw.decrypt(gpg_password) + if not mpw.decrypt(gpg_password) @error_msg = mpw.error_msg return nil end @@ -107,9 +105,7 @@ module MPW # @args: data -> the data to send on server # @rtrn: false if there is a problem def update(data) - if !@enable - return true - end + return true if not @enable msg = nil TCPSocket.open(@host, @port) do |socket| @@ -124,7 +120,7 @@ module MPW msg = JSON.parse(socket.gets) end - if !defined?(msg['error']) + if not defined?(msg['error']) @error_msg = I18n.t('error.sync.communication') return false elsif msg['error'].nil? diff --git a/lib/Sync/SSH.rb b/lib/Sync/SSH.rb index 4868a85..d1f3801 100644 --- a/lib/Sync/SSH.rb +++ b/lib/Sync/SSH.rb @@ -51,9 +51,7 @@ module MPW # @args: gpg_password -> the gpg password # @rtrn: nil if nothing data or error def get(gpg_password) - if !@enable - return nil - end + return nil if not @enable tmp_file = tmpfile Net::SCP.start(@host, @user, password: @password, port: @port) do |scp| @@ -61,7 +59,7 @@ module MPW end mpw = MPW.new(tmp_file) - if !mpw.decrypt(gpg_password) + if not mpw.decrypt(gpg_password) @error_msg = mpw.error_msg return nil end @@ -77,9 +75,7 @@ module MPW # @args: data -> the data to send on server # @rtrn: false if there is a problem def update(data) - if !@enable - return true - end + return true if not @enable tmp_file = tmpfile File.open(tmp_file, "w") do |file|