file_transfer_mixin 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/README CHANGED
@@ -2,8 +2,12 @@
2
2
  FileTransferMixin is a module that you can include in a library. It will support various mechanisms long-term, but
3
3
  for now is focused on SFTP servers.
4
4
 
5
+ It provides the following methods for now:
6
+
5
7
  - sftp_send(key, remote_location, local_file_path)
6
8
  - sftp_fetch(key, remote_path, local_path)
9
+ - sftp_move(key, original_remote_path, new_remote_path)
10
+ - sftp_block(key)
7
11
 
8
12
  - It expects an ENV variable named FILE_TRANSFER_MIXIN_CONFIG_PATH to be set.
9
13
  - It expects a yml configuration file in FILE_TRANSFER_MIXIN_CONFIG_PATH that looks like the following:
@@ -32,6 +36,18 @@ class SomeClass
32
36
  def fetch_method
33
37
  sftp_fetch(:some_key, remote_path, local_path)
34
38
  end
39
+
40
+ # Some method that moves a file
41
+ def move_method
42
+ sftp_move(:some_key, original_remote_path, new_remote_path)
43
+ end
44
+
45
+ # Some method that otherwise uses Net::SFTP commands but still uses our config block
46
+ def sftp_detailed_method
47
+ sftp_block(:some_key) do |ftp|
48
+ ftp.rename!('foo', 'bar')
49
+ end
50
+ end
35
51
  end
36
52
 
37
53
  == Motivation ==
@@ -2,7 +2,7 @@ module FileTransferMixin
2
2
  module InstanceMethods
3
3
  extend Forwardable
4
4
 
5
- def_delegators :file_transfer_mixin_sftp_instance, :sftp_send, :sftp_fetch, :sftp_block
5
+ def_delegators :file_transfer_mixin_sftp_instance, :sftp_send, :sftp_fetch, :sftp_move, :sftp_block
6
6
 
7
7
  private
8
8
  def file_transfer_mixin_sftp_instance
@@ -36,6 +36,12 @@ module FileTransferMixin
36
36
  end
37
37
  end
38
38
 
39
+ def sftp_move(key, original_remote_path, new_remote_path)
40
+ sftp_block(key) do |sftp|
41
+ sftp.rename!(original_remote_path, new_remote_path)
42
+ end
43
+ end
44
+
39
45
  def perform_network_operations?
40
46
  FileTransferMixin.env.to_s != 'test'
41
47
  end
@@ -1,3 +1,3 @@
1
1
  module FileTransferMixin
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 3
9
- version: 0.0.3
8
+ - 4
9
+ version: 0.0.4
10
10
  platform: ruby
11
11
  authors:
12
12
  - Josh Adams