mymedia_ftp 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/mymedia_ftp.rb +64 -25
- metadata +22 -23
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2a79c27201bd99d03df23d7fac22ac335904f591
|
4
|
+
data.tar.gz: c95aeb3a504437ed05e198d0e11d4b1d9ce2ecd4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c96d73bf20f366be140b15d6702393431812bcf89094b2fd3dfbe04d20731adfff977f2c786f2415d9384c268590d32dca930474edf9c2dd5fd900bbdaff2e59
|
7
|
+
data.tar.gz: f0c685f277c99e5eb5a9dcf835c20d7af289f1f47927beec6d7f9ac311737d9d21203ab35079e4d9a17cc132f5ccd98e0372d0c669a61a2fddfa8f48751b7bc1
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/mymedia_ftp.rb
CHANGED
@@ -8,17 +8,25 @@ require 'fileutils'
|
|
8
8
|
|
9
9
|
class MyMediaFTP < Net::FTP
|
10
10
|
|
11
|
-
def initialize(host: '127.0.0.1', user: 'user', password: '1234',
|
11
|
+
def initialize(host: '127.0.0.1', user: 'user', password: '1234',
|
12
|
+
port: 21, debug: false)
|
12
13
|
|
13
|
-
@
|
14
|
+
@debug = debug
|
15
|
+
@curdir = '/'
|
14
16
|
super()
|
15
17
|
connect(host, port)
|
16
18
|
login(user, password)
|
17
19
|
|
18
20
|
end
|
21
|
+
|
22
|
+
def chdir(dir)
|
23
|
+
super(dir)
|
24
|
+
@curdir = pwd
|
25
|
+
end
|
19
26
|
|
20
|
-
def cp(src='', dest='')
|
27
|
+
def cp(src='', dest='', &blk)
|
21
28
|
|
29
|
+
puts 'cp: ' + src.inspect if @debug
|
22
30
|
chdir File.dirname(src)
|
23
31
|
FileUtils.mkdir_p dest
|
24
32
|
Dir.chdir dest
|
@@ -27,38 +35,69 @@ class MyMediaFTP < Net::FTP
|
|
27
35
|
|
28
36
|
puts 'copying ...'
|
29
37
|
|
30
|
-
files.each do |
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
38
|
+
files.each do |h|
|
39
|
+
|
40
|
+
name, type = h[:name], h[:type]
|
41
|
+
|
42
|
+
puts name
|
43
|
+
|
44
|
+
if type == :file then
|
45
|
+
getbinaryfile name, name.downcase.gsub(/ +/,'-')
|
46
|
+
else
|
47
|
+
cp_dir(name, &blk)
|
48
|
+
end
|
49
|
+
blk.call(name, type) if block_given?
|
35
50
|
end
|
36
51
|
|
37
52
|
end
|
53
|
+
|
54
|
+
def list_filenames(s=@curdir+'/*')
|
55
|
+
|
56
|
+
if @debug
|
57
|
+
puts 'inside list_filenames'
|
58
|
+
puts 's: ' + s.inspect
|
59
|
+
end
|
60
|
+
|
61
|
+
src = File.dirname(s)
|
62
|
+
|
63
|
+
raw_q = File.basename(s)
|
64
|
+
puts 'raw_q: ' + raw_q.inspect if @debug
|
65
|
+
|
66
|
+
q = raw_q.gsub('.','\.').gsub('*','.*').gsub('?','.?')\
|
67
|
+
.sub(/[^\*\?\.]$/,'.*')
|
68
|
+
|
69
|
+
list(src).inject([]) do |r, x|
|
70
|
+
|
71
|
+
raw_attr, _, owner, group, filesize, month, day, time, filename = \
|
72
|
+
x.split(/ +/,9)
|
73
|
+
type = raw_attr =~ /d/ ? :directory : :file
|
74
|
+
filename[/^#{q}$/] ? r << {name: filename, type: type} : r
|
75
|
+
r
|
76
|
+
end
|
38
77
|
|
78
|
+
end
|
79
|
+
|
80
|
+
alias ls list_filenames
|
39
81
|
|
40
82
|
def mv(src='', dest='')
|
41
83
|
|
42
84
|
puts 'moving ...'
|
43
|
-
cp(src, dest)
|
44
|
-
|
45
|
-
|
46
|
-
end
|
47
|
-
|
48
|
-
private
|
49
|
-
|
50
|
-
def list_filenames(src)
|
51
|
-
|
52
|
-
raw_q = File.basename(src)
|
53
|
-
|
54
|
-
q = raw_q.gsub('.','\.').gsub('*','.*').gsub('?','.?')
|
55
|
-
|
56
|
-
list.inject([]) do |r, x|
|
57
|
-
|
58
|
-
filename = x.split(/ +/,9).last
|
59
|
-
filename[/^#{q}$/] ? r << filename : r
|
85
|
+
cp(src, dest) do |file, type|
|
86
|
+
type == :file ? delete(file) : rmdir(file)
|
60
87
|
end
|
61
88
|
|
62
89
|
end
|
63
90
|
|
91
|
+
private
|
92
|
+
|
93
|
+
def cp_dir(directory, &blk)
|
94
|
+
|
95
|
+
puts 'inside cp_dir: ' + directory.inspect if @debug
|
96
|
+
FileUtils.mkdir_p directory
|
97
|
+
parent_dir = pwd
|
98
|
+
chdir directory
|
99
|
+
cp('*', directory, &blk)
|
100
|
+
chdir parent_dir
|
101
|
+
end
|
102
|
+
|
64
103
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mymedia_ftp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -10,28 +10,27 @@ bindir: bin
|
|
10
10
|
cert_chain:
|
11
11
|
- |
|
12
12
|
-----BEGIN CERTIFICATE-----
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
4B4pCY1yRwNaig==
|
13
|
+
MIIDXjCCAkagAwIBAgIBATANBgkqhkiG9w0BAQUFADAsMSowKAYDVQQDDCFnZW1t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cfSGfEz7pctL2WDEEr/7ax56cQHQzaInbh
|
29
|
+
7c6Xalbryf2I+Uj21nW9Sn5ZGyGl7mFqRiclRyqg89+k55DgQolX05KJGfiV8aWA
|
30
|
+
XgExvIVcxlAxeQOUlcIGBWKIf+Hva5DT7OUUp76DGt6bi3X8uUeZd6y3+UtFj/RZ
|
31
|
+
BXg=
|
33
32
|
-----END CERTIFICATE-----
|
34
|
-
date:
|
33
|
+
date: 2018-03-12 00:00:00.000000000 Z
|
35
34
|
dependencies: []
|
36
35
|
description:
|
37
36
|
email: james@jamesrobertson.eu
|
@@ -60,7 +59,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
60
59
|
version: '0'
|
61
60
|
requirements: []
|
62
61
|
rubyforge_project:
|
63
|
-
rubygems_version: 2.6.
|
62
|
+
rubygems_version: 2.6.13
|
64
63
|
signing_key:
|
65
64
|
specification_version: 4
|
66
65
|
summary: A MyMedia FTP client which uses Net/FTP.
|
metadata.gz.sig
CHANGED
Binary file
|