photocopier 1.2.0 → 1.3.0.pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/photocopier/ftp/session.rb +46 -0
- data/lib/photocopier/ftp.rb +2 -6
- data/lib/photocopier/version.rb +1 -1
- data/lib/photocopier.rb +2 -0
- data/photocopier.gemspec +1 -0
- metadata +19 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c7c9e146b3e1470970f2f95815ef0bac16517ee2
|
4
|
+
data.tar.gz: b9a43d8c3b696e6b755f8888d6286ad8512bdceb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 30e977409752782228a0b4dd73d496b5308236a4770c752efe46b3b88ec2785bbce9f808e1ac06ae9fece98719d9a263874ef1ad9d42471ec092a32be29d6cd6
|
7
|
+
data.tar.gz: 66c2b1d04a8715715262875d8c317eaff2a3d2b638a95083a08afff4af826b30d4e4a3aaf177197c07c69556be6af5cdf00fff0dfaabe17a74d4fecb5d39d126
|
@@ -0,0 +1,46 @@
|
|
1
|
+
module Photocopier
|
2
|
+
class FTP
|
3
|
+
class Session
|
4
|
+
def initialize(options)
|
5
|
+
@scheme = options[:scheme]
|
6
|
+
|
7
|
+
if sftp?
|
8
|
+
@session = Net::SFTP.start(options[:host], options[:user], password: options[:password])
|
9
|
+
else
|
10
|
+
@session = Net::FTP.open(options[:host], options[:user], options[:password])
|
11
|
+
@session.passive = options[:passive] if options.key?(:passive)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def get(remote, local)
|
16
|
+
if sftp?
|
17
|
+
@session.download!(remote, local)
|
18
|
+
else
|
19
|
+
@session.get(remote, local)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def put_file(local, remote)
|
24
|
+
if sftp?
|
25
|
+
@session.upload!(local, remote)
|
26
|
+
else
|
27
|
+
@session.put(local, remote)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def delete(remote)
|
32
|
+
if sftp?
|
33
|
+
@session.remove!(remote)
|
34
|
+
else
|
35
|
+
@session.delete(remote)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
private
|
40
|
+
|
41
|
+
def sftp?
|
42
|
+
@scheme == 'sftp'
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
data/lib/photocopier/ftp.rb
CHANGED
@@ -13,7 +13,7 @@ module Photocopier
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def put_file(file_path, remote_path)
|
16
|
-
session.
|
16
|
+
session.put_file file_path, remote_path
|
17
17
|
end
|
18
18
|
|
19
19
|
def delete(remote_path)
|
@@ -32,11 +32,7 @@ module Photocopier
|
|
32
32
|
private
|
33
33
|
|
34
34
|
def session
|
35
|
-
|
36
|
-
@session = Net::FTP.open(options[:host], options[:user], options[:password])
|
37
|
-
@session.passive = options[:passive] if options.has_key?(:passive)
|
38
|
-
end
|
39
|
-
@session
|
35
|
+
@session ||= Session.new(options)
|
40
36
|
end
|
41
37
|
|
42
38
|
def lftp(local, remote, reverse, exclude)
|
data/lib/photocopier/version.rb
CHANGED
data/lib/photocopier.rb
CHANGED
@@ -2,6 +2,7 @@ require 'tempfile'
|
|
2
2
|
require 'logger'
|
3
3
|
require 'fileutils'
|
4
4
|
require 'net/ftp'
|
5
|
+
require 'net/sftp'
|
5
6
|
require 'net/ssh'
|
6
7
|
require 'net/ssh/gateway'
|
7
8
|
require 'net/scp'
|
@@ -13,3 +14,4 @@ require "active_support/core_ext"
|
|
13
14
|
require 'photocopier/adapter'
|
14
15
|
require "photocopier/ssh"
|
15
16
|
require "photocopier/ftp"
|
17
|
+
require "photocopier/ftp/session"
|
data/photocopier.gemspec
CHANGED
@@ -22,6 +22,7 @@ Gem::Specification.new do |spec|
|
|
22
22
|
|
23
23
|
spec.add_dependency "activesupport", '~> 5.1', '>= 5.1.1'
|
24
24
|
spec.add_dependency "net-scp", "~> 1.2", ">= 1.2.1"
|
25
|
+
spec.add_dependency "net-sftp", "~> 2.1.2"
|
25
26
|
spec.add_dependency "net-ssh", "~> 4.1"
|
26
27
|
spec.add_dependency "net-ssh-gateway", "~> 2.0"
|
27
28
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: photocopier
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0.pre
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stefano Verna
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: exe
|
12
12
|
cert_chain: []
|
13
|
-
date: 2018-
|
13
|
+
date: 2018-07-27 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activesupport
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: 1.2.1
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: net-sftp
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 2.1.2
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 2.1.2
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: net-ssh
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -203,6 +217,7 @@ files:
|
|
203
217
|
- lib/photocopier.rb
|
204
218
|
- lib/photocopier/adapter.rb
|
205
219
|
- lib/photocopier/ftp.rb
|
220
|
+
- lib/photocopier/ftp/session.rb
|
206
221
|
- lib/photocopier/ssh.rb
|
207
222
|
- lib/photocopier/version.rb
|
208
223
|
- photocopier.gemspec
|
@@ -221,9 +236,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
221
236
|
version: 2.4.0
|
222
237
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
223
238
|
requirements:
|
224
|
-
- - "
|
239
|
+
- - ">"
|
225
240
|
- !ruby/object:Gem::Version
|
226
|
-
version:
|
241
|
+
version: 1.3.1
|
227
242
|
requirements: []
|
228
243
|
rubyforge_project:
|
229
244
|
rubygems_version: 2.6.11
|