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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cee82f89d2fec3cd42459555c373688c981a25dd
4
- data.tar.gz: a4d18c1ba3dd02f95145d218faefcd1a0e9f9f6a
3
+ metadata.gz: 2a79c27201bd99d03df23d7fac22ac335904f591
4
+ data.tar.gz: c95aeb3a504437ed05e198d0e11d4b1d9ce2ecd4
5
5
  SHA512:
6
- metadata.gz: bf61e6ef142660c9094a8ee5f2bc2402155423f396e94be2b883c5a5ff1fe49a6d15d06123c8d68d02c7bbdf2368090c7ee24da93e0c9249e6e732bc276d1e45
7
- data.tar.gz: 589c4e23cccad086cfef34eba11be44cb7991d319e5101ed95a0615ceb24aaeb161c4f0562620e43343d91e0cf47cda7ac8a456fbc3e601de8ae5f927f55b114
6
+ metadata.gz: c96d73bf20f366be140b15d6702393431812bcf89094b2fd3dfbe04d20731adfff977f2c786f2415d9384c268590d32dca930474edf9c2dd5fd900bbdaff2e59
7
+ data.tar.gz: f0c685f277c99e5eb5a9dcf835c20d7af289f1f47927beec6d7f9ac311737d9d21203ab35079e4d9a17cc132f5ccd98e0372d0c669a61a2fddfa8f48751b7bc1
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -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', port: 21)
11
+ def initialize(host: '127.0.0.1', user: 'user', password: '1234',
12
+ port: 21, debug: false)
12
13
 
13
- @curdir = Dir.pwd
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 |x|
31
-
32
- puts x
33
- getbinaryfile x, x.downcase.gsub(/ +/,'-')
34
- yield(x) if block_given?
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) {|file| delete file }
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.1.1
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
- MIIDljCCAn6gAwIBAgIBATANBgkqhkiG9w0BAQUFADBIMRIwEAYDVQQDDAlnZW1t
14
- YXN0ZXIxHjAcBgoJkiaJk/IsZAEZFg5qYW1lc3JvYmVydHNvbjESMBAGCgmSJomT
15
- 8ixkARkWAmV1MB4XDTE3MDEyNDEyNTkwMFoXDTE4MDEyNDEyNTkwMFowSDESMBAG
16
- A1UEAwwJZ2VtbWFzdGVyMR4wHAYKCZImiZPyLGQBGRYOamFtZXNyb2JlcnRzb24x
17
- EjAQBgoJkiaJk/IsZAEZFgJldTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC
18
- ggEBAM6mxAwy84VrNmnnclGR4CVx4K7qOiHDOnmS3m2cqfWDyWRyaPh791JkpE8V
19
- 8M831U0KpI9fu+6xiJnG0zzaiCFw37/DyEGUkxHM1hvwETS66IWUfmd/6bjHYGw9
20
- 0wGHyWdSp0iN0YawQ6aZ5Ix6m4NDkonAY/lBINZd8a5V2r8shjiF53hBNjcSzURd
21
- 6rnK0ST6W162QV5mElPt32VKsVSmr7YTWRxBLW5+G3wVhv0ldKL50HLTkeAktBgQ
22
- LpejUQ2H9+wa+MXmTOWLir4yqHOLuO1qV8E6aJpA9JyvyZcaDsP2R8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h
19
+ 837NDczDJwqB/OH8chn9zO1qfyWIiTDg0e9BRWQsAwNAigoAbipC56x6ciizdXq7
20
+ Uc2hfxmKUP4Rt5P5myMWhTAHNcYxXud0HS3XrtFUIL3pP/LBtwWy+/5HVTMS5iML
21
+ rlJLLOZ5ll0aNrT4h0DlspAN4IBYuZEwD/VKBSD2zg5vocSrDmvXFxaUnfMNGSxK
22
+ LR0DthL2JJU1KSGbAgMBAAGjgYowgYcwCQYDVR0TBAIwADALBgNVHQ8EBAMCBLAw
23
+ HQYDVR0OBBYEFPr4r2Be8t/4br//MJNp3Rqta50nMCYGA1UdEQQfMB2BG2dlbW1h
24
+ c3RlckBqYW1lc3JvYmVydHNvbi5ldTAmBgNVHRIEHzAdgRtnZW1tYXN0ZXJAamFt
25
+ ZXNyb2JlcnRzb24uZXUwDQYJKoZIhvcNAQEFBQADggEBAMOtYvEPHEeLVwGNfgK5
26
+ lLMgIXA9Y4eRdOnhBFpcVlzsFrVm1oLieMFGVxkNHgflFRMHUpnzosaa8m+Tc4L4
27
+ ZQTtBa7dK7HjfBi7l8sGJR00KRk1QQNA1/dfhIr1YQejNq1J8RkUG7uI+aiEmMwW
28
+ +EWu4oQM7AHtDghXOxlPJlJphH/kpQcfSGfEz7pctL2WDEEr/7ax56cQHQzaInbh
29
+ 7c6Xalbryf2I+Uj21nW9Sn5ZGyGl7mFqRiclRyqg89+k55DgQolX05KJGfiV8aWA
30
+ XgExvIVcxlAxeQOUlcIGBWKIf+Hva5DT7OUUp76DGt6bi3X8uUeZd6y3+UtFj/RZ
31
+ BXg=
33
32
  -----END CERTIFICATE-----
34
- date: 2017-01-24 00:00:00.000000000 Z
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.8
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