fun_sftp 0.0.1 → 0.0.2

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.
data/README.rdoc ADDED
@@ -0,0 +1,101 @@
1
+ = FunSFTP (Version 0.0.2)
2
+
3
+ Ruby Gem that provides a nice and easy to work with wrapper for the Net::SFTP library.
4
+
5
+ Modeled from:
6
+
7
+ http://net-ssh.github.com/sftp/v2/api/index.html
8
+
9
+
10
+ == Install
11
+
12
+ gem install fun_sftp
13
+
14
+ In Rails: gem 'fun_sftp'
15
+
16
+
17
+ == Usage
18
+
19
+ Let's say you need to send a file to a remote host. Well, you can upload it to the remote host using these steps:
20
+
21
+ #First setup the connection:
22
+ include FunSftp
23
+
24
+ conn = SFTPClient.new(server, username, password)
25
+
26
+ #Now, you can upload your file:
27
+
28
+ conn.upload!("my_file_name.txt", "some_directory/give_a_name.txt")
29
+
30
+ That's it! Check the remote host and see that your file posted.
31
+
32
+ You can also download a file locally by:
33
+
34
+ conn.download!("some_directory/file_to_download_name.txt", "give_the_local_name.txt")
35
+
36
+ Need to read a file on the remote host? No biggie...
37
+
38
+ conn.read("path/to/file")
39
+ # => Here is content in your requested file.
40
+
41
+ When investigating items in the remote host, these can be handy:
42
+
43
+ Command: conn.print_directory_items("directory_name")
44
+ #=> outputs directories
45
+ test1
46
+ test2
47
+ some_directory_here
48
+
49
+ Command: conn.entries("directory_name")
50
+ #=> outputs a nice array of entries in the specified directory
51
+ ["test1", "test2", "some_directory_here"]
52
+
53
+ Command: conn.glob("directory_name", "**/*.rb")
54
+ #=> Pattern matches the second argument for the directory_name given
55
+ #=> So, you can get things like...
56
+ some_directory_here/hello_world.rb
57
+ some_directory_here/sftp_is_fun.rb
58
+
59
+ == FileUtils
60
+
61
+ FileUtilities are handy for doing some dirty work on the remote host.
62
+
63
+ So far, you can make/remove directories, remove/rename files
64
+
65
+ Command: conn.mkdir!("some_directory/a_new_directory_name_here")
66
+ #=> makes a_new_directory_name_here under some_directory which exists
67
+
68
+ Removing a directory is the same as above except you would now specify: conn.rmdir!
69
+
70
+ Files can be renamed and removed off the remote:
71
+
72
+ Command: conn.rm("path/to/file.txt")
73
+ #=> would remove file.txt
74
+
75
+ Command: conn.rename("old_file_name.txt", "new_file_name.txt")
76
+ #=> old_file_name.txt is now named new_file_name.txt on remote host.
77
+
78
+ Hopefully, this is basic enough to work with and transfer files!!
79
+
80
+ == License
81
+
82
+ Copyright (c) 2012 George Diaz
83
+
84
+ Permission is hereby granted, free of charge, to any person obtaining
85
+ a copy of this software and associated documentation files (the
86
+ "Software"), to deal in the Software without restriction, including
87
+ without limitation the rights to use, copy, modify, merge, publish,
88
+ distribute, sublicense, and/or sell copies of the Software, and to
89
+ permit persons to whom the Software is furnished to do so, subject to
90
+ the following conditions:
91
+
92
+ The above copyright notice and this permission notice shall be
93
+ included in all copies or substantial portions of the Software.
94
+
95
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
96
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
97
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
98
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
99
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
100
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
101
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/fun_sftp.gemspec CHANGED
@@ -9,7 +9,7 @@ Gem::Specification.new do |s|
9
9
  s.email = ["georgediaz88@yahoo.com"]
10
10
  s.homepage = ""
11
11
  s.summary = %q{FunSFTP for secure file transfers}
12
- s.description = %q{Wrapper for Rubys Net::SFTP library which makes SFTP easy!}
12
+ s.description = %q{Wrapper for Rubys Net::SFTP library which makes SFTP easy! See Documentation at https://georgediaz88@github.com/georgediaz88/fun_sftp.git}
13
13
 
14
14
  s.rubyforge_project = "fun_sftp"
15
15
 
@@ -1,3 +1,3 @@
1
1
  module FunSftp
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
data/lib/fun_sftp.rb CHANGED
@@ -15,7 +15,7 @@ module FunSftp
15
15
  end
16
16
 
17
17
  def upload!(source, target) #send to remote
18
- @client.upload!(source, target) #target example: 'lrs/some_name.txt'
18
+ @client.upload!(source, target) #target example: 'some_directory/some_name.txt'
19
19
  end
20
20
 
21
21
  def download!(target, source) #fetch locally from remote
@@ -29,7 +29,7 @@ module FunSftp
29
29
  end
30
30
  end
31
31
 
32
- def glob(path, pattern) # ex: ('lrs', '**/*.rb')
32
+ def glob(path, pattern) # ex: ('some_directory', '**/*.rb')
33
33
  @client.dir.glob(path, pattern).collect(&:name)
34
34
  end
35
35
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fun_sftp
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 27
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 1
10
- version: 0.0.1
9
+ - 2
10
+ version: 0.0.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - George Diaz
@@ -46,7 +46,7 @@ dependencies:
46
46
  version: "0"
47
47
  type: :development
48
48
  version_requirements: *id002
49
- description: Wrapper for Rubys Net::SFTP library which makes SFTP easy!
49
+ description: Wrapper for Rubys Net::SFTP library which makes SFTP easy! See Documentation at https://georgediaz88@github.com/georgediaz88/fun_sftp.git
50
50
  email:
51
51
  - georgediaz88@yahoo.com
52
52
  executables: []
@@ -58,6 +58,7 @@ extra_rdoc_files: []
58
58
  files:
59
59
  - .gitignore
60
60
  - Gemfile
61
+ - README.rdoc
61
62
  - Rakefile
62
63
  - fun_sftp.gemspec
63
64
  - lib/fun_sftp.rb