1
0
Fork 0
mirror of https://github.com/nishiki/manage-password.git synced 2024-11-27 15:43:04 +00:00

update syntax

This commit is contained in:
nishiki 2014-11-16 19:50:09 +01:00
parent 3e2c8eef0c
commit d2eb57a5c4
3 changed files with 14 additions and 26 deletions

View file

@ -51,9 +51,7 @@ module MPW
# @args: gpg_password -> the gpg password # @args: gpg_password -> the gpg password
# @rtrn: nil if nothing data or error # @rtrn: nil if nothing data or error
def get(gpg_password) def get(gpg_password)
if !@enable return nil if not @enable
return nil
end
tmp_file = tmpfile tmp_file = tmpfile
Net::FTP.open(@host) do |ftp| Net::FTP.open(@host) do |ftp|
@ -62,7 +60,7 @@ module MPW
end end
mpw = MPW.new(tmp_file) mpw = MPW.new(tmp_file)
if !mpw.decrypt(gpg_password) if not mpw.decrypt(gpg_password)
@error_msg = mpw.error_msg @error_msg = mpw.error_msg
return nil return nil
end end
@ -78,9 +76,7 @@ module MPW
# @args: data -> the data to send on server # @args: data -> the data to send on server
# @rtrn: false if there is a problem # @rtrn: false if there is a problem
def update(data) def update(data)
if !@enable return true if not @enable
return true
end
tmp_file = tmpfile tmp_file = tmpfile
File.open(tmp_file, "w") do |file| File.open(tmp_file, "w") do |file|

View file

@ -33,7 +33,7 @@ module MPW
# @rtrn: false if the connection fail # @rtrn: false if the connection fail
def connect(host, user, password, path, port=nil) def connect(host, user, password, path, port=nil)
@host = host @host = host
@port = !port.instance_of?(Integer) ? 2201 : port @port = not port.instance_of?(Integer) ? 2201 : port
@gpg_key = user @gpg_key = user
@password = password @password = password
@suffix = path @suffix = path
@ -62,9 +62,7 @@ module MPW
# @args: gpg_password -> the gpg password # @args: gpg_password -> the gpg password
# @rtrn: nil if nothing data or error # @rtrn: nil if nothing data or error
def get(gpg_password) def get(gpg_password)
if !@enable return nil if not @enable
return nil
end
msg = nil msg = nil
TCPSocket.open(@host, @port) do |socket| TCPSocket.open(@host, @port) do |socket|
@ -78,13 +76,13 @@ module MPW
msg = JSON.parse(socket.gets) msg = JSON.parse(socket.gets)
end end
if !defined?(msg['error']) if not defined?(msg['error'])
@error_msg = I18n.t('error.sync.communication') @error_msg = I18n.t('error.sync.communication')
return nil return nil
elsif !msg['error'].nil? elsif not msg['error'].nil?
@error_msg = I18n.t(msg['error']) @error_msg = I18n.t(msg['error'])
return nil return nil
elsif msg['data'].nil? || msg['data'].empty? elsif msg['data'].nil? or msg['data'].empty?
return [] return []
else else
tmp_file = tmpfile tmp_file = tmpfile
@ -93,7 +91,7 @@ module MPW
end end
mpw = MPW.new(tmp_file) mpw = MPW.new(tmp_file)
if !mpw.decrypt(gpg_password) if not mpw.decrypt(gpg_password)
@error_msg = mpw.error_msg @error_msg = mpw.error_msg
return nil return nil
end end
@ -107,9 +105,7 @@ module MPW
# @args: data -> the data to send on server # @args: data -> the data to send on server
# @rtrn: false if there is a problem # @rtrn: false if there is a problem
def update(data) def update(data)
if !@enable return true if not @enable
return true
end
msg = nil msg = nil
TCPSocket.open(@host, @port) do |socket| TCPSocket.open(@host, @port) do |socket|
@ -124,7 +120,7 @@ module MPW
msg = JSON.parse(socket.gets) msg = JSON.parse(socket.gets)
end end
if !defined?(msg['error']) if not defined?(msg['error'])
@error_msg = I18n.t('error.sync.communication') @error_msg = I18n.t('error.sync.communication')
return false return false
elsif msg['error'].nil? elsif msg['error'].nil?

View file

@ -51,9 +51,7 @@ module MPW
# @args: gpg_password -> the gpg password # @args: gpg_password -> the gpg password
# @rtrn: nil if nothing data or error # @rtrn: nil if nothing data or error
def get(gpg_password) def get(gpg_password)
if !@enable return nil if not @enable
return nil
end
tmp_file = tmpfile tmp_file = tmpfile
Net::SCP.start(@host, @user, password: @password, port: @port) do |scp| Net::SCP.start(@host, @user, password: @password, port: @port) do |scp|
@ -61,7 +59,7 @@ module MPW
end end
mpw = MPW.new(tmp_file) mpw = MPW.new(tmp_file)
if !mpw.decrypt(gpg_password) if not mpw.decrypt(gpg_password)
@error_msg = mpw.error_msg @error_msg = mpw.error_msg
return nil return nil
end end
@ -77,9 +75,7 @@ module MPW
# @args: data -> the data to send on server # @args: data -> the data to send on server
# @rtrn: false if there is a problem # @rtrn: false if there is a problem
def update(data) def update(data)
if !@enable return true if not @enable
return true
end
tmp_file = tmpfile tmp_file = tmpfile
File.open(tmp_file, "w") do |file| File.open(tmp_file, "w") do |file|