mock_sftp 0.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.
Files changed (2) hide show
  1. data/lib/mock_sftp.rb +44 -0
  2. metadata +68 -0
@@ -0,0 +1,44 @@
1
+ module MockSFTP
2
+
3
+ class SFTPEntry
4
+ attr_reader :name
5
+ def initialize(props)
6
+ @name = props[:name]
7
+ end
8
+ end
9
+
10
+ class SFTPDir
11
+ def initialize(dir) ; @dir = dir ; end
12
+
13
+ def [](base, pattern)
14
+ Dir[File.join(@dir, base, pattern)].map do |p|
15
+ SFTPEntry.new(:name => File.basename(p))
16
+ end
17
+ end
18
+ end
19
+
20
+ class Session
21
+
22
+ def initialize(dir) ; @dir = dir ; end
23
+ def dir ; SFTPDir.new(@dir) ; end
24
+
25
+ def upload!(local_path, remote_path)
26
+ local_remote_path = File.join(@dir, remote_path)
27
+ FileUtils.cp(local_path, local_remote_path)
28
+ nil
29
+ end
30
+
31
+ def rename(src, dest, flags_ignored)
32
+ local_src = File.join(@dir, src)
33
+ local_dest = File.join(@dir, dest)
34
+ FileUtils.mv(local_src, local_dest)
35
+ end
36
+
37
+ def download!(remote_dir, local_dir, options={})
38
+ raise 'options not supported' unless options == {:recursive => true}
39
+
40
+ local_remote_dir = File.join(@dir, remote_dir)
41
+ FileUtils.cp_r(Dir.glob(local_remote_dir + '/*'), local_dir)
42
+ end
43
+ end
44
+ end
metadata ADDED
@@ -0,0 +1,68 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: mock_sftp
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - MSP Dev Team
14
+ - Nick Griffiths
15
+ autorequire:
16
+ bindir: bin
17
+ cert_chain: []
18
+
19
+ date: 2012-09-25 00:00:00 Z
20
+ dependencies: []
21
+
22
+ description: Can be used to mimic the behaviour of an sftp session, based on a local filesystem location
23
+ email:
24
+ - devs@mediasp.com
25
+ - nicobrevin@gmail.com
26
+ executables: []
27
+
28
+ extensions: []
29
+
30
+ extra_rdoc_files: []
31
+
32
+ files:
33
+ - lib/mock_sftp.rb
34
+ homepage: https://github.com/playlouder
35
+ licenses: []
36
+
37
+ post_install_message:
38
+ rdoc_options: []
39
+
40
+ require_paths:
41
+ - lib
42
+ required_ruby_version: !ruby/object:Gem::Requirement
43
+ none: false
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ hash: 3
48
+ segments:
49
+ - 0
50
+ version: "0"
51
+ required_rubygems_version: !ruby/object:Gem::Requirement
52
+ none: false
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ hash: 3
57
+ segments:
58
+ - 0
59
+ version: "0"
60
+ requirements: []
61
+
62
+ rubyforge_project:
63
+ rubygems_version: 1.8.24
64
+ signing_key:
65
+ specification_version: 3
66
+ summary: Mock up an net/sftp session
67
+ test_files: []
68
+