fun_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.
- data/.gitignore +4 -0
- data/Gemfile +4 -0
- data/Rakefile +1 -0
- data/fun_sftp.gemspec +22 -0
- data/lib/fun_sftp.rb +63 -0
- data/lib/fun_sftp/version.rb +3 -0
- metadata +100 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/fun_sftp.gemspec
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "fun_sftp/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "fun_sftp"
|
7
|
+
s.version = FunSftp::VERSION
|
8
|
+
s.authors = ["George Diaz"]
|
9
|
+
s.email = ["georgediaz88@yahoo.com"]
|
10
|
+
s.homepage = ""
|
11
|
+
s.summary = %q{FunSFTP for secure file transfers}
|
12
|
+
s.description = %q{Wrapper for Rubys Net::SFTP library which makes SFTP easy!}
|
13
|
+
|
14
|
+
s.rubyforge_project = "fun_sftp"
|
15
|
+
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
+
s.require_paths = ["lib"]
|
20
|
+
s.add_dependency 'net-sftp'
|
21
|
+
s.add_development_dependency 'rspec'
|
22
|
+
end
|
data/lib/fun_sftp.rb
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'fun_sftp/version'
|
2
|
+
require 'net/sftp'
|
3
|
+
|
4
|
+
module FunSftp
|
5
|
+
class SFTPClient
|
6
|
+
attr_accessor :server, :user, :password, :client
|
7
|
+
|
8
|
+
def initialize(server, user, password)
|
9
|
+
@server, @user, @password = server, user, password
|
10
|
+
@client = setup_login
|
11
|
+
end
|
12
|
+
|
13
|
+
def setup_login
|
14
|
+
Net::SFTP.start(@server, @user, :password => @password)
|
15
|
+
end
|
16
|
+
|
17
|
+
def upload!(source, target) #send to remote
|
18
|
+
@client.upload!(source, target) #target example: 'lrs/some_name.txt'
|
19
|
+
end
|
20
|
+
|
21
|
+
def download!(target, source) #fetch locally from remote
|
22
|
+
@client.download!(target, source)
|
23
|
+
end
|
24
|
+
|
25
|
+
def read(path)
|
26
|
+
file = @client.file.open(path)
|
27
|
+
while !file.eof?
|
28
|
+
puts file.gets
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def glob(path, pattern) # ex: ('lrs', '**/*.rb')
|
33
|
+
@client.dir.glob(path, pattern).collect(&:name)
|
34
|
+
end
|
35
|
+
|
36
|
+
def entries(dir) #array of directory items
|
37
|
+
@client.dir.entries(dir).collect(&:name)
|
38
|
+
end
|
39
|
+
|
40
|
+
def print_directory_items(dir) #printout of directory items
|
41
|
+
@client.dir.foreach(dir) { |file| print "#{file.name}\n" }
|
42
|
+
end
|
43
|
+
|
44
|
+
#### Some Handy File Util Methods
|
45
|
+
def mkdir!(path) #make directory
|
46
|
+
@client.mkdir! path
|
47
|
+
end
|
48
|
+
|
49
|
+
def rm(path) #remove a file
|
50
|
+
@client.remove!(path)
|
51
|
+
end
|
52
|
+
|
53
|
+
def rmdir!(path) #remove directory
|
54
|
+
@client.rmdir!(path)
|
55
|
+
end
|
56
|
+
|
57
|
+
def rename(name, new_name) #rename a file
|
58
|
+
@client.rename!(name, new_name)
|
59
|
+
end
|
60
|
+
##################################
|
61
|
+
|
62
|
+
end
|
63
|
+
end
|
metadata
ADDED
@@ -0,0 +1,100 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fun_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
|
+
- George Diaz
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2012-02-23 00:00:00 -06:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: net-sftp
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 3
|
30
|
+
segments:
|
31
|
+
- 0
|
32
|
+
version: "0"
|
33
|
+
type: :runtime
|
34
|
+
version_requirements: *id001
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: rspec
|
37
|
+
prerelease: false
|
38
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
hash: 3
|
44
|
+
segments:
|
45
|
+
- 0
|
46
|
+
version: "0"
|
47
|
+
type: :development
|
48
|
+
version_requirements: *id002
|
49
|
+
description: Wrapper for Rubys Net::SFTP library which makes SFTP easy!
|
50
|
+
email:
|
51
|
+
- georgediaz88@yahoo.com
|
52
|
+
executables: []
|
53
|
+
|
54
|
+
extensions: []
|
55
|
+
|
56
|
+
extra_rdoc_files: []
|
57
|
+
|
58
|
+
files:
|
59
|
+
- .gitignore
|
60
|
+
- Gemfile
|
61
|
+
- Rakefile
|
62
|
+
- fun_sftp.gemspec
|
63
|
+
- lib/fun_sftp.rb
|
64
|
+
- lib/fun_sftp/version.rb
|
65
|
+
has_rdoc: true
|
66
|
+
homepage: ""
|
67
|
+
licenses: []
|
68
|
+
|
69
|
+
post_install_message:
|
70
|
+
rdoc_options: []
|
71
|
+
|
72
|
+
require_paths:
|
73
|
+
- lib
|
74
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
75
|
+
none: false
|
76
|
+
requirements:
|
77
|
+
- - ">="
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
hash: 3
|
80
|
+
segments:
|
81
|
+
- 0
|
82
|
+
version: "0"
|
83
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
84
|
+
none: false
|
85
|
+
requirements:
|
86
|
+
- - ">="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
hash: 3
|
89
|
+
segments:
|
90
|
+
- 0
|
91
|
+
version: "0"
|
92
|
+
requirements: []
|
93
|
+
|
94
|
+
rubyforge_project: fun_sftp
|
95
|
+
rubygems_version: 1.5.3
|
96
|
+
signing_key:
|
97
|
+
specification_version: 3
|
98
|
+
summary: FunSFTP for secure file transfers
|
99
|
+
test_files: []
|
100
|
+
|