ftp_transfer 0.0.1 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/.gitignore +1 -0
- data/Gemfile +3 -0
- data/README.md +28 -0
- data/ftp_transfer.gemspec +21 -0
- data/lib/ftp_transfer.rb +10 -6
- data/lib/ftp_transfer/version.rb +3 -0
- metadata +32 -13
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: a46f99b16eab2c4c7ea74fe30350d759ce734bd438f74fde31574776cdcf378c
|
|
4
|
+
data.tar.gz: 3a12f565f56163b037619f4d1c3d2b43419b0c0af1e1642176ca4a345840dd7a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8898920bb4d6d4ed0d9c159e65fbdbe1df50b81bd07802a513d5ecc39b596031031acfad1ba31fdbed3c1f1a847bea87a67e85d5e936c588503a3b54cbd132fa
|
|
7
|
+
data.tar.gz: 68eab974c056c3e14923af52a8db600c5105a864ecd959270f702d481efb472f4ad992e7e19766308fc4616d0f2b17bd882d123387ec6ff5e58ee80237cce4c8
|
data/.gitignore
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Gemfile.lock
|
data/Gemfile
ADDED
data/README.md
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
ftp_transfer
|
|
2
|
+
============
|
|
3
|
+
|
|
4
|
+
The ftp_transfer gem was designed in an attempt to create a simpler api for bulk ftp transfers.
|
|
5
|
+
|
|
6
|
+
Here is an example of an upload. In this case, the optional archive directory option has been specified so a copy of the transferred files will be kept locally in that directory. The pattern option is also optional and will default to '*'.
|
|
7
|
+
```ruby
|
|
8
|
+
require 'ftp_transfer'
|
|
9
|
+
FtpTransfer.new(
|
|
10
|
+
host: 'foobar.bazquux.com',
|
|
11
|
+
user: 'user',
|
|
12
|
+
pass: 'password',
|
|
13
|
+
port: 21212, # optional param (will default to 21)
|
|
14
|
+
local_dir: '~/files-to-send',
|
|
15
|
+
pattern: '*.jpg',
|
|
16
|
+
archive_dir: '~/archived-files').upload('file-upload-dir')
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Here is an example of a download
|
|
20
|
+
```ruby
|
|
21
|
+
FtpTransfer.new(
|
|
22
|
+
host: 'foobar.bazquux.com',
|
|
23
|
+
user: 'user',
|
|
24
|
+
pass: 'password',
|
|
25
|
+
local_dir: '~/received-files',
|
|
26
|
+
pattern: '*.jpg').download('file-download-dir')
|
|
27
|
+
```
|
|
28
|
+
There is not currently an archive option for the download method. If you need that for your application, feel free to send a pull request.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
lib = File.expand_path("../lib", __FILE__)
|
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
3
|
+
require "ftp_transfer/version"
|
|
4
|
+
|
|
5
|
+
Gem::Specification.new do |spec|
|
|
6
|
+
spec.name = 'ftp_transfer'
|
|
7
|
+
spec.version = FtpTransfer::VERSION
|
|
8
|
+
spec.summary = 'Bulk FTP Transfer'
|
|
9
|
+
spec.description = 'A bulk ftp transfer library'
|
|
10
|
+
spec.authors = ['Eric Mathison']
|
|
11
|
+
spec.email = 'dev@ekmathison.com'
|
|
12
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
|
13
|
+
f.match(%r{^test/})
|
|
14
|
+
end
|
|
15
|
+
spec.licenses = ['GPL-2.0']
|
|
16
|
+
spec.add_development_dependency 'fake_ftp', '~> 0.3'
|
|
17
|
+
spec.add_development_dependency 'minitest', '~> 5.0'
|
|
18
|
+
spec.add_runtime_dependency 'stringglob', '~> 0.0.3'
|
|
19
|
+
spec.homepage =
|
|
20
|
+
'https://github.com/ericmathison/ftp_transfer'
|
|
21
|
+
end
|
data/lib/ftp_transfer.rb
CHANGED
|
@@ -1,20 +1,24 @@
|
|
|
1
|
+
require 'ftp_transfer/version'
|
|
1
2
|
require 'net/ftp'
|
|
2
3
|
require 'digest/md5'
|
|
3
4
|
require 'fileutils'
|
|
4
5
|
require 'stringglob'
|
|
5
6
|
|
|
6
7
|
class FtpTransfer
|
|
7
|
-
def initialize(
|
|
8
|
-
@host = host
|
|
9
|
-
@user = user
|
|
10
|
-
@password =
|
|
11
|
-
@local_directory = File.expand_path(
|
|
8
|
+
def initialize(options = {})
|
|
9
|
+
@host = options[:host]
|
|
10
|
+
@user = options[:user]
|
|
11
|
+
@password = options[:pass]
|
|
12
|
+
@local_directory = File.expand_path(options[:local_dir])
|
|
12
13
|
@archive_directory = nil
|
|
13
14
|
if options[:archive_dir]
|
|
14
15
|
@archive_directory = File.expand_path(options[:archive_dir])
|
|
15
16
|
end
|
|
16
17
|
@pattern = options[:pattern] || '*'
|
|
17
|
-
@
|
|
18
|
+
@port = options[:port] || 21
|
|
19
|
+
@ftp = Net::FTP.new
|
|
20
|
+
@ftp.connect(@host, @port)
|
|
21
|
+
@ftp.login(@user, @password)
|
|
18
22
|
@ftp.passive = true
|
|
19
23
|
end
|
|
20
24
|
|
metadata
CHANGED
|
@@ -1,41 +1,55 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ftp_transfer
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0
|
|
4
|
+
version: 0.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Eric Mathison
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2018-02-20 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: fake_ftp
|
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
|
16
16
|
requirements:
|
|
17
|
-
- -
|
|
17
|
+
- - "~>"
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
|
-
version: 0.
|
|
19
|
+
version: '0.3'
|
|
20
20
|
type: :development
|
|
21
21
|
prerelease: false
|
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
23
|
requirements:
|
|
24
|
-
- -
|
|
24
|
+
- - "~>"
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
|
-
version: 0.
|
|
26
|
+
version: '0.3'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: minitest
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - "~>"
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '5.0'
|
|
34
|
+
type: :development
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - "~>"
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '5.0'
|
|
27
41
|
- !ruby/object:Gem::Dependency
|
|
28
42
|
name: stringglob
|
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
|
30
44
|
requirements:
|
|
31
|
-
- - ~>
|
|
45
|
+
- - "~>"
|
|
32
46
|
- !ruby/object:Gem::Version
|
|
33
47
|
version: 0.0.3
|
|
34
48
|
type: :runtime
|
|
35
49
|
prerelease: false
|
|
36
50
|
version_requirements: !ruby/object:Gem::Requirement
|
|
37
51
|
requirements:
|
|
38
|
-
- - ~>
|
|
52
|
+
- - "~>"
|
|
39
53
|
- !ruby/object:Gem::Version
|
|
40
54
|
version: 0.0.3
|
|
41
55
|
description: A bulk ftp transfer library
|
|
@@ -44,10 +58,15 @@ executables: []
|
|
|
44
58
|
extensions: []
|
|
45
59
|
extra_rdoc_files: []
|
|
46
60
|
files:
|
|
61
|
+
- ".gitignore"
|
|
62
|
+
- Gemfile
|
|
63
|
+
- README.md
|
|
64
|
+
- ftp_transfer.gemspec
|
|
47
65
|
- lib/ftp_transfer.rb
|
|
48
|
-
|
|
66
|
+
- lib/ftp_transfer/version.rb
|
|
67
|
+
homepage: https://github.com/ericmathison/ftp_transfer
|
|
49
68
|
licenses:
|
|
50
|
-
- GPL-2
|
|
69
|
+
- GPL-2.0
|
|
51
70
|
metadata: {}
|
|
52
71
|
post_install_message:
|
|
53
72
|
rdoc_options: []
|
|
@@ -55,17 +74,17 @@ require_paths:
|
|
|
55
74
|
- lib
|
|
56
75
|
required_ruby_version: !ruby/object:Gem::Requirement
|
|
57
76
|
requirements:
|
|
58
|
-
- -
|
|
77
|
+
- - ">="
|
|
59
78
|
- !ruby/object:Gem::Version
|
|
60
79
|
version: '0'
|
|
61
80
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
62
81
|
requirements:
|
|
63
|
-
- -
|
|
82
|
+
- - ">="
|
|
64
83
|
- !ruby/object:Gem::Version
|
|
65
84
|
version: '0'
|
|
66
85
|
requirements: []
|
|
67
86
|
rubyforge_project:
|
|
68
|
-
rubygems_version: 2.
|
|
87
|
+
rubygems_version: 2.7.3
|
|
69
88
|
signing_key:
|
|
70
89
|
specification_version: 4
|
|
71
90
|
summary: Bulk FTP Transfer
|