file_transfer 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -51,6 +51,18 @@ module FileTransfer
51
51
  all_file_paths
52
52
  end
53
53
 
54
+ def list(path)
55
+ @ftp_obj.list path
56
+ end
57
+
58
+ def remove(path)
59
+ @ftp_obj.remove path
60
+ end
61
+
62
+ def rename(from_path, to_path)
63
+ @ftp_obj.rename from_path, to_path
64
+ end
65
+
54
66
  def close
55
67
  @ftp_obj.close
56
68
  end
@@ -21,6 +21,27 @@ module FileTransfer
21
21
  end
22
22
  end
23
23
 
24
+ def list(path)
25
+ connect if closed?
26
+ timeout(60) do
27
+ @sftp.dir.entries path
28
+ end
29
+ end
30
+
31
+ def remove(path)
32
+ connect if closed?
33
+ timeout(60) do
34
+ @sftp.remove! path
35
+ end
36
+ end
37
+
38
+ def rename(from_path, to_path)
39
+ connect if closed?
40
+ timeout(60) do
41
+ @sftp.rename! from_path, to_path
42
+ end
43
+ end
44
+
24
45
  def close
25
46
  # do nothing
26
47
  end
@@ -1,3 +1,3 @@
1
1
  module FileTransfer # :nodoc:
2
- VERSION = "0.0.4" # :nodoc:
2
+ VERSION = "0.0.5" # :nodoc:
3
3
  end
data/lib/file_transfer.rb CHANGED
@@ -62,6 +62,18 @@ module FileTransfer
62
62
  handler.close
63
63
  end
64
64
 
65
+ def self.remove(type, options, paths)
66
+ handler = FileTransferHandler.new type, options
67
+ handler.remove paths
68
+ handler.close
69
+ end
70
+
71
+ def self.list(type, options, path)
72
+ handler = FileTransferHandler.new type, options
73
+ handler.list path
74
+ handler.close
75
+ end
76
+
65
77
  def self.exists?(type, options, path)
66
78
  handler = FileTransferHandler.new type, options
67
79
  handler.exists? path
@@ -46,12 +46,22 @@ module FileTransfer
46
46
  # puts "--END OF TEST"
47
47
  #end
48
48
 
49
+ it "should list from OTTO SFTP" do
50
+ instance = FileTransferHandler.new :sftp, {
51
+ :host => "sftp-dmz.otto.de",
52
+ :username => "eosch",
53
+ :password => "hot}Orm1",
54
+ :port => 22
55
+ }
56
+ puts instance.list("/").inspect
57
+ end
58
+
49
59
  it "should upload a test-file to OTTO SFTP" do
50
60
  instance = FileTransferHandler.new :sftp, {
51
- :host => "sftp-dmz.otto.de",
52
- :username => "eosch",
53
- :password => "hot}Orm1",
54
- :port => 22
61
+ :host => "sftp-dmz.otto.de",
62
+ :username => "eosch",
63
+ :password => "hot}Orm1",
64
+ :port => 22
55
65
  }
56
66
  this_path = File.dirname(__FILE__)
57
67
  paths = {:from => "#{this_path}/../test_files/empty_file.csv", :to => "/eosch/in/test/empty_file_1.csv"}
@@ -88,6 +98,16 @@ module FileTransfer
88
98
  puts "--END OF TEST"
89
99
  end
90
100
 
101
+ it "should rename the test-file from OTTO SFTP" do
102
+ instance = FileTransferHandler.new :sftp, {
103
+ :host => "sftp-dmz.otto.de",
104
+ :username => "eosch",
105
+ :password => "hot}Orm1",
106
+ :port => 22
107
+ }
108
+ result = instance.rename "/eosch/in/test/empty_file_1.csv", "/eosch/in/test/empty_file_1.csv_old"
109
+ end
110
+
91
111
  #it "should return an Array of various Files" do
92
112
  # instance = FileTransferHandler.new :ftp, {}
93
113
  # this_path = File.dirname(__FILE__)
@@ -0,0 +1 @@
1
+ COL1,COL2,COL3
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: file_transfer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-08-31 00:00:00.000000000 Z
12
+ date: 2012-09-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
@@ -94,6 +94,7 @@ files:
94
94
  - spec/test_files/Chrysanthemum.jpg
95
95
  - spec/test_files/Desert.jpg
96
96
  - spec/test_files/empty_file.csv
97
+ - spec/test_files/empty_file_from_sftp.csv
97
98
  - spec/test_files/folder1/Koala.jpg
98
99
  - spec/test_files/folder1/Lighthouse.jpg
99
100
  - spec/test_files/folder1/text_3.txt
@@ -136,6 +137,7 @@ test_files:
136
137
  - spec/test_files/Chrysanthemum.jpg
137
138
  - spec/test_files/Desert.jpg
138
139
  - spec/test_files/empty_file.csv
140
+ - spec/test_files/empty_file_from_sftp.csv
139
141
  - spec/test_files/folder1/Koala.jpg
140
142
  - spec/test_files/folder1/Lighthouse.jpg
141
143
  - spec/test_files/folder1/text_3.txt