ftpro 0.0.3 → 0.0.4
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 +4 -4
- data/ftpro.gemspec +1 -1
- data/lib/ftpro.rb +1 -1
- data/spec/ftpro_spec.rb +70 -17
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1c55466dc7609eef6e2fdd48315c945c7444e6ff
|
|
4
|
+
data.tar.gz: 14c75d721882b8019165a2beb1e9d94516d59187
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9a3d49b2f81cfd3b0a953e9f23a0d2226435065a3308068d979964f64cca5252aac068ca7b95138c2655f5e78f87f96e13c11f6618b24bd6aa34e7db537b75e2
|
|
7
|
+
data.tar.gz: c2ec8094cf05a70885677b3dbbf86e78f464010f1bf88813effd5b734aad9eadfef726a7301a2030cc40f2a24f3c6161a8c864ce9693bc0481ea37d251e602ce
|
data/ftpro.gemspec
CHANGED
|
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
|
4
4
|
|
|
5
5
|
Gem::Specification.new do |spec|
|
|
6
6
|
spec.name = "ftpro"
|
|
7
|
-
spec.version = '0.0.
|
|
7
|
+
spec.version = '0.0.4'
|
|
8
8
|
spec.authors = ["dddd1919"]
|
|
9
9
|
spec.email = ["dingrank@gmail.com"]
|
|
10
10
|
spec.summary = %q{The enhanced version of net/ftp}
|
data/lib/ftpro.rb
CHANGED
|
@@ -91,7 +91,7 @@ class Ftpro < Net::FTP
|
|
|
91
91
|
|
|
92
92
|
def upload_dir(local_dir, remote_dir)
|
|
93
93
|
remote_folder = local_dir.split('/')[-1] == ".." ? "" : local_dir.split('/')[-1] ## check if folder name is return symbol
|
|
94
|
-
remote_new_dir = "#{remote_dir}/#{remote_folder}"
|
|
94
|
+
remote_new_dir = remote_dir.empty? ? "#{remote_folder}" : "#{remote_dir}/#{remote_folder}"
|
|
95
95
|
mkdir_p(remote_new_dir) ## init remote dir
|
|
96
96
|
Dir.foreach(local_dir) do |file|
|
|
97
97
|
if file != "." && file != ".."
|
data/spec/ftpro_spec.rb
CHANGED
|
@@ -2,29 +2,82 @@ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
|
|
2
2
|
|
|
3
3
|
describe "Ftpro test" do
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
@ftp_pwd = 'password'
|
|
10
|
-
end
|
|
5
|
+
let(:ftp_host) { "example.com" }
|
|
6
|
+
let(:ftp_port) { "21"}
|
|
7
|
+
let(:ftp_user) { 'name'}
|
|
8
|
+
let(:ftp_pwd) { 'password'}
|
|
11
9
|
|
|
12
|
-
|
|
13
|
-
ftp = Ftpro.new
|
|
14
|
-
ftp.connect(@ftp_host, @ftp_port)
|
|
15
|
-
ftp.login(@ftp_user, @ftp_pwd)
|
|
16
|
-
expect(ftp.nlst.class).to eq(Array)
|
|
17
|
-
end
|
|
10
|
+
describe "Normal function" do
|
|
18
11
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
ftp.login(
|
|
12
|
+
it 'With normal way' do
|
|
13
|
+
ftp = Ftpro.new
|
|
14
|
+
ftp.connect(ftp_host, ftp_port)
|
|
15
|
+
ftp.login(ftp_user, ftp_pwd)
|
|
23
16
|
expect(ftp.nlst.class).to eq(Array)
|
|
17
|
+
ftp.close
|
|
24
18
|
end
|
|
19
|
+
|
|
20
|
+
it 'With block call' do
|
|
21
|
+
Net::FTP::FTP_PORT = ftp_port ## There will raise a warning cause FTP_PORT is a constant
|
|
22
|
+
Ftpro.open(ftp_host) do |ftp|
|
|
23
|
+
ftp.login(ftp_user, ftp_pwd)
|
|
24
|
+
expect(ftp.nlst.class).to eq(Array)
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
25
28
|
end
|
|
26
29
|
|
|
27
|
-
|
|
30
|
+
describe "Extension function test" do
|
|
31
|
+
|
|
32
|
+
before(:each) do
|
|
33
|
+
@ftp = Ftpro.new
|
|
34
|
+
@ftp.connect(ftp_host, ftp_port)
|
|
35
|
+
@ftp.login(ftp_user, ftp_pwd)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
after(:each) do
|
|
39
|
+
@ftp.close
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
it 'nlst_a method test' do
|
|
43
|
+
@ftp.putbinaryfile('../.gitignore')
|
|
44
|
+
visible_files = @ftp.nlst
|
|
45
|
+
all_files = @ftp.nlst_a
|
|
46
|
+
expect(visible_files.count).to be < all_files.count
|
|
47
|
+
expect(all_files - visible_files).to include('.gitignore')
|
|
48
|
+
@ftp.delete('.gitignore')
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
it 'judge file type and exist' do
|
|
52
|
+
@ftp.put_r("../spec", "")
|
|
53
|
+
expect(@ftp.exist?("spec")).to be true
|
|
54
|
+
expect(@ftp.directory?("spec")).to be true
|
|
55
|
+
expect(@ftp.exist?("spec/ftpro_spec.rb")).to be true
|
|
56
|
+
expect(@ftp.directory?("spec/ftpro_spec.rb")).to be false
|
|
57
|
+
expect(@ftp.file?("spec/ftpro_spec.rb")).to be true
|
|
58
|
+
@ftp.rm_r("spec")
|
|
59
|
+
expect(@ftp.directory?("spec")).to be false
|
|
60
|
+
expect(@ftp.exist?("spec")).to be false
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
it 'mkdir_p method' do
|
|
64
|
+
target_dir = 'foo/bar/baz/test'
|
|
65
|
+
expect(@ftp.exist?(target_dir)).to be false
|
|
66
|
+
@ftp.mkdir_p(target_dir)
|
|
67
|
+
expect(@ftp.exist?(target_dir)).to be true
|
|
68
|
+
@ftp.rm_r("foo")
|
|
69
|
+
expect(@ftp.exist?(target_dir)).to be false
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
it 'put_r and rm_r methods' do
|
|
73
|
+
expect(@ftp.exist?('foo/bar')).to be false
|
|
74
|
+
@ftp.put_r('../', 'foo/bar')
|
|
75
|
+
expect(@ftp.exist?('foo/bar/lib')).to eq true
|
|
76
|
+
expect(@ftp.nlst_a('foo/bar').count + 2).to eq(Dir.foreach('../').count)
|
|
77
|
+
@ftp.rm_r('foo')
|
|
78
|
+
expect(@ftp.exist?('foo/bar/lib')).to eq false
|
|
79
|
+
end
|
|
80
|
+
|
|
28
81
|
end
|
|
29
82
|
|
|
30
83
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ftpro
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- dddd1919
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2014-12-
|
|
11
|
+
date: 2014-12-31 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|