mpw 4.0.0 → 4.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +122 -0
- data/.travis.yml +2 -0
- data/CHANGELOG.md +9 -0
- data/Gemfile +7 -9
- data/README.md +1 -7
- data/VERSION +1 -1
- data/bin/mpw +25 -25
- data/bin/mpw-add +54 -25
- data/bin/mpw-config +74 -62
- data/bin/mpw-copy +25 -30
- data/bin/mpw-delete +24 -29
- data/bin/mpw-export +27 -32
- data/bin/mpw-genpwd +22 -22
- data/bin/mpw-import +20 -25
- data/bin/mpw-list +24 -29
- data/bin/mpw-update +61 -32
- data/bin/mpw-wallet +48 -73
- data/i18n/en.yml +15 -26
- data/i18n/fr.yml +15 -26
- data/lib/mpw/cli.rb +554 -546
- data/lib/mpw/config.rb +168 -139
- data/lib/mpw/item.rb +75 -82
- data/lib/mpw/mpw.rb +328 -465
- data/mpw.gemspec +11 -10
- data/templates/add_form.erb +8 -8
- data/templates/update_form.erb +7 -7
- data/test/test_config.rb +70 -55
- data/test/test_item.rb +167 -167
- data/test/test_mpw.rb +132 -132
- data/test/test_translate.rb +23 -23
- data/test/tests.rb +1 -1
- metadata +4 -45
- data/lib/mpw/sync/ftp.rb +0 -68
- data/lib/mpw/sync/ssh.rb +0 -67
data/lib/mpw/sync/ssh.rb
DELETED
@@ -1,67 +0,0 @@
|
|
1
|
-
#!/usr/bin/ruby
|
2
|
-
# MPW is a software to crypt and manage your passwords
|
3
|
-
# Copyright (C) 2016 Adrien Waksberg <mpw@yae.im>
|
4
|
-
#
|
5
|
-
# This program is free software; you can redistribute it and/or
|
6
|
-
# modify it under the terms of the GNU General Public License
|
7
|
-
# as published by the Free Software Foundation; either version 2
|
8
|
-
# of the License, or (at your option) any later version.
|
9
|
-
#
|
10
|
-
# This program is distributed in the hope that it will be useful,
|
11
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
-
# GNU General Public License for more details.
|
14
|
-
#
|
15
|
-
# You should have received a copy of the GNU General Public License
|
16
|
-
# along with this program; if not, write to the Free Software
|
17
|
-
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
18
|
-
|
19
|
-
require 'i18n'
|
20
|
-
require 'net/ssh'
|
21
|
-
require 'net/sftp'
|
22
|
-
|
23
|
-
module MPW
|
24
|
-
class SyncSSH
|
25
|
-
|
26
|
-
# Constructor
|
27
|
-
# @args: config -> the config
|
28
|
-
def initialize(config)
|
29
|
-
@host = config['host']
|
30
|
-
@user = config['user']
|
31
|
-
@password = config['password']
|
32
|
-
@path = config['path']
|
33
|
-
@port = config['port'].instance_of?(Integer) ? 22 : config['port']
|
34
|
-
end
|
35
|
-
|
36
|
-
# Connect to server
|
37
|
-
def connect
|
38
|
-
Net::SSH.start(@host, @user, password: @password, port: @port) do
|
39
|
-
break
|
40
|
-
end
|
41
|
-
rescue Exception => e
|
42
|
-
raise "#{I18n.t('error.sync.connection')}\n#{e}"
|
43
|
-
end
|
44
|
-
|
45
|
-
# Get data on server
|
46
|
-
# @args: file_tmp -> the path where download the file
|
47
|
-
def get(file_tmp)
|
48
|
-
Net::SFTP.start(@host, @user, password: @password, port: @port) do |sftp|
|
49
|
-
sftp.lstat(@path) do |response|
|
50
|
-
sftp.download!(@path, file_tmp) if response.ok?
|
51
|
-
end
|
52
|
-
end
|
53
|
-
rescue Exception => e
|
54
|
-
raise "#{I18n.t('error.sync.download')}\n#{e}"
|
55
|
-
end
|
56
|
-
|
57
|
-
# Update the remote data
|
58
|
-
# @args: file_gpg -> the data to send on server
|
59
|
-
def update(file_gpg)
|
60
|
-
Net::SFTP.start(@host, @user, password: @password, port: @port) do |sftp|
|
61
|
-
sftp.upload!(file_gpg, @path)
|
62
|
-
end
|
63
|
-
rescue Exception => e
|
64
|
-
raise "#{I18n.t('error.sync.upload')}\n#{e}"
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|