spectre-ftp 2.0.0 → 2.0.1
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/lib/spectre/ftp.rb +130 -3
- metadata +17 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: '055907f899bb094c17845e01db766dd1d643ef78d87981fc4bd007bf3b430b2e'
|
|
4
|
+
data.tar.gz: 3b9fb444b4949712f8df4891c4276a938aa04b4c34b9a5b7789023234a572722
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3d0f4f82bf15afe3d0927a86af940ca8dfa291fdb4f4958f66811541666f202fec7922f8a38515a2500da14b70dd01276733ff607bc57b029539b6213f81c11f
|
|
7
|
+
data.tar.gz: 5ef3c799773931a559725d3f296358451e4e7db8c424deec11b7a549357db5716652511a3a582aab7ed7a47aa06dd4aa5f811e15bbda2bad7b4b9867a59d0345
|
data/lib/spectre/ftp.rb
CHANGED
|
@@ -66,12 +66,73 @@ module Spectre
|
|
|
66
66
|
@__session.putbinaryfile(localfile, to)
|
|
67
67
|
end
|
|
68
68
|
|
|
69
|
-
def list
|
|
69
|
+
def list path = nil
|
|
70
70
|
connect!
|
|
71
|
-
file_list = @__session.list
|
|
72
|
-
@__logger.info("Listing files in #{@__session.pwd}\n#{file_list}")
|
|
71
|
+
file_list = path ? @__session.list(path) : @__session.list
|
|
72
|
+
@__logger.info("Listing files in #{path || @__session.pwd}\n#{file_list}")
|
|
73
73
|
file_list
|
|
74
74
|
end
|
|
75
|
+
|
|
76
|
+
def mkdir dirname
|
|
77
|
+
connect!
|
|
78
|
+
@__logger.info("Creating directory '#{dirname}' in #{@__session.pwd}")
|
|
79
|
+
@__session.mkdir(dirname)
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
def rmdir dirname
|
|
83
|
+
connect!
|
|
84
|
+
@__logger.info("Removing directory '#{dirname}' in #{@__session.pwd}")
|
|
85
|
+
@__session.rmdir(dirname)
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
def delete filename
|
|
89
|
+
connect!
|
|
90
|
+
@__logger.info("Deleting file '#{filename}' in #{@__session.pwd}")
|
|
91
|
+
@__session.delete(filename)
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
def rename oldname, newname
|
|
95
|
+
connect!
|
|
96
|
+
@__logger.info("Renaming '#{oldname}' to '#{newname}' in #{@__session.pwd}")
|
|
97
|
+
@__session.rename(oldname, newname)
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
def chdir path
|
|
101
|
+
connect!
|
|
102
|
+
@__logger.info("Changing directory to '#{path}'")
|
|
103
|
+
@__session.chdir(path)
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
def pwd
|
|
107
|
+
connect!
|
|
108
|
+
current_dir = @__session.pwd
|
|
109
|
+
@__logger.info("Current directory: #{current_dir}")
|
|
110
|
+
current_dir
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
def exists path
|
|
114
|
+
connect!
|
|
115
|
+
begin
|
|
116
|
+
@__session.size(path)
|
|
117
|
+
true
|
|
118
|
+
rescue Net::FTPPermError, Net::FTPTempError
|
|
119
|
+
false
|
|
120
|
+
end
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
def file_size filename
|
|
124
|
+
connect!
|
|
125
|
+
size = @__session.size(filename)
|
|
126
|
+
@__logger.info("File size of '#{filename}': #{size} bytes")
|
|
127
|
+
size
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
def mtime filename
|
|
131
|
+
connect!
|
|
132
|
+
modification_time = @__session.mtime(filename)
|
|
133
|
+
@__logger.info("Modification time of '#{filename}': #{modification_time}")
|
|
134
|
+
modification_time
|
|
135
|
+
end
|
|
75
136
|
end
|
|
76
137
|
|
|
77
138
|
class SFTPConnection
|
|
@@ -144,6 +205,7 @@ module Spectre
|
|
|
144
205
|
end
|
|
145
206
|
|
|
146
207
|
def exists path
|
|
208
|
+
connect!
|
|
147
209
|
begin
|
|
148
210
|
@__session.stat! path
|
|
149
211
|
rescue Net::SFTP::StatusException => e
|
|
@@ -154,6 +216,71 @@ module Spectre
|
|
|
154
216
|
|
|
155
217
|
true
|
|
156
218
|
end
|
|
219
|
+
|
|
220
|
+
def list path = '.'
|
|
221
|
+
connect!
|
|
222
|
+
files = []
|
|
223
|
+
@__session.dir.foreach(path) do |entry|
|
|
224
|
+
files << entry.longname
|
|
225
|
+
end
|
|
226
|
+
@__logger.info("Listing files in #{path}\n#{files}")
|
|
227
|
+
files
|
|
228
|
+
end
|
|
229
|
+
|
|
230
|
+
def mkdir dirname
|
|
231
|
+
connect!
|
|
232
|
+
@__logger.info("Creating directory '#{dirname}'")
|
|
233
|
+
@__session.mkdir!(dirname)
|
|
234
|
+
end
|
|
235
|
+
|
|
236
|
+
def rmdir dirname
|
|
237
|
+
connect!
|
|
238
|
+
@__logger.info("Removing directory '#{dirname}'")
|
|
239
|
+
@__session.rmdir!(dirname)
|
|
240
|
+
end
|
|
241
|
+
|
|
242
|
+
def delete filename
|
|
243
|
+
connect!
|
|
244
|
+
@__logger.info("Deleting file '#{filename}'")
|
|
245
|
+
@__session.remove!(filename)
|
|
246
|
+
end
|
|
247
|
+
|
|
248
|
+
def rename oldname, newname
|
|
249
|
+
connect!
|
|
250
|
+
@__logger.info("Renaming '#{oldname}' to '#{newname}'")
|
|
251
|
+
@__session.rename!(oldname, newname)
|
|
252
|
+
end
|
|
253
|
+
|
|
254
|
+
# # SFTP is stateless and doesn't have a concept of current directory
|
|
255
|
+
# # All operations use absolute paths or paths relative to the user's home directory
|
|
256
|
+
# # This method is a no-op for API compatibility with FTP
|
|
257
|
+
# def chdir path
|
|
258
|
+
# connect!
|
|
259
|
+
# @__logger.info("Note: SFTP is stateless - paths are always absolute or relative to home directory")
|
|
260
|
+
# end
|
|
261
|
+
|
|
262
|
+
def pwd
|
|
263
|
+
connect!
|
|
264
|
+
current_dir = @__session.realpath!('.')
|
|
265
|
+
@__logger.info("Current directory: #{current_dir.name}")
|
|
266
|
+
current_dir.name
|
|
267
|
+
end
|
|
268
|
+
|
|
269
|
+
def file_size filename
|
|
270
|
+
connect!
|
|
271
|
+
stat_info = @__session.stat!(filename)
|
|
272
|
+
size = stat_info.size
|
|
273
|
+
@__logger.info("File size of '#{filename}': #{size} bytes")
|
|
274
|
+
size
|
|
275
|
+
end
|
|
276
|
+
|
|
277
|
+
def mtime filename
|
|
278
|
+
connect!
|
|
279
|
+
stat_info = @__session.stat!(filename)
|
|
280
|
+
modification_time = Time.at(stat_info.mtime)
|
|
281
|
+
@__logger.info("Modification time of '#{filename}': #{modification_time}")
|
|
282
|
+
modification_time
|
|
283
|
+
end
|
|
157
284
|
end
|
|
158
285
|
|
|
159
286
|
class Client
|
metadata
CHANGED
|
@@ -1,14 +1,28 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: spectre-ftp
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.0.
|
|
4
|
+
version: 2.0.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Christian Neubauer
|
|
8
8
|
bindir: bin
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
|
+
- !ruby/object:Gem::Dependency
|
|
13
|
+
name: logger
|
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
|
15
|
+
requirements:
|
|
16
|
+
- - ">="
|
|
17
|
+
- !ruby/object:Gem::Version
|
|
18
|
+
version: '0'
|
|
19
|
+
type: :runtime
|
|
20
|
+
prerelease: false
|
|
21
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
22
|
+
requirements:
|
|
23
|
+
- - ">="
|
|
24
|
+
- !ruby/object:Gem::Version
|
|
25
|
+
version: '0'
|
|
12
26
|
- !ruby/object:Gem::Dependency
|
|
13
27
|
name: net-ftp
|
|
14
28
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -66,7 +80,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
66
80
|
- !ruby/object:Gem::Version
|
|
67
81
|
version: '0'
|
|
68
82
|
requirements: []
|
|
69
|
-
rubygems_version: 3.6.
|
|
83
|
+
rubygems_version: 3.6.9
|
|
70
84
|
specification_version: 4
|
|
71
85
|
summary: Standalone FTP wrapper compatible with spectre
|
|
72
86
|
test_files: []
|