remote_cp 0.0.1 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/Gemfile.lock +9 -0
- data/README +2 -0
- data/bin/rt +103 -0
- data/lib/remote_cp/version.rb +1 -1
- data/lib/remote_cp.rb +65 -18
- data/lib/rt +103 -0
- data/remote_cp.gemspec +1 -0
- metadata +25 -8
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
@@ -2,13 +2,22 @@ PATH
|
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
4
|
remote_cp (0.0.1)
|
5
|
+
aws-s3
|
5
6
|
|
6
7
|
GEM
|
7
8
|
remote: http://rubygems.org/
|
8
9
|
specs:
|
10
|
+
aws-s3 (0.6.2)
|
11
|
+
builder
|
12
|
+
mime-types
|
13
|
+
xml-simple
|
14
|
+
builder (2.1.2)
|
15
|
+
mime-types (1.16)
|
16
|
+
xml-simple (1.0.12)
|
9
17
|
|
10
18
|
PLATFORMS
|
11
19
|
ruby
|
12
20
|
|
13
21
|
DEPENDENCIES
|
22
|
+
aws-s3
|
14
23
|
remote_cp!
|
data/README
ADDED
data/bin/rt
ADDED
@@ -0,0 +1,103 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'rubygems'
|
3
|
+
require 'zlib'
|
4
|
+
require 'archive/tar/minitar'
|
5
|
+
require 'thor'
|
6
|
+
require 'aws/s3'
|
7
|
+
|
8
|
+
class RemoteCp < Thor
|
9
|
+
include Archive::Tar
|
10
|
+
include AWS::S3
|
11
|
+
|
12
|
+
def initialize(*args)
|
13
|
+
AWS::S3::Base.establish_connection!(
|
14
|
+
:access_key_id => ENV['AMAZON_ACCESS_KEY_ID'],
|
15
|
+
:secret_access_key => ENV['AMAZON_SECRET_ACCESS_KEY']
|
16
|
+
)
|
17
|
+
super
|
18
|
+
end
|
19
|
+
|
20
|
+
desc "cp [FILENAME]", "copy FILENAME to the cloudi. If FILENAME not given send STDIN to the cloud"
|
21
|
+
def cp(filename = nil)
|
22
|
+
type = nil
|
23
|
+
content_type = nil
|
24
|
+
|
25
|
+
content = if filename.nil?
|
26
|
+
basename = "anonymous"
|
27
|
+
$stdin.read
|
28
|
+
else
|
29
|
+
full_path = File.expand_path(filename)
|
30
|
+
basename = File.basename(full_path)
|
31
|
+
if File.directory?(full_path)
|
32
|
+
content_type = "application/gzip"
|
33
|
+
io = StringIO.new("")
|
34
|
+
tgz = Zlib::GzipWriter.new(io)
|
35
|
+
Minitar.pack(basename, tgz)
|
36
|
+
type = 'directory'
|
37
|
+
io.rewind
|
38
|
+
io.string
|
39
|
+
else
|
40
|
+
type = 'file'
|
41
|
+
File.open(full_path)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
# I think that all this info should be included file's metadata
|
46
|
+
S3Object.store("file_name.txt", basename, 'RemoteClipboard')
|
47
|
+
S3Object.store("content", content, 'RemoteClipboard', :content_type => content_type)
|
48
|
+
S3Object.store("type", type, 'RemoteClipboard')
|
49
|
+
end
|
50
|
+
|
51
|
+
desc "p", "paste from the cloud to current dir"
|
52
|
+
def p
|
53
|
+
file_name = S3Object.find("file_name.txt", 'RemoteClipboard').value
|
54
|
+
type = S3Object.find("type", 'RemoteClipboard').value
|
55
|
+
|
56
|
+
if File.exist?(file_name)
|
57
|
+
puts "#{file_name} already exist."
|
58
|
+
print "Do you want to replace it (y/n)? "
|
59
|
+
res = $stdin.gets.chomp
|
60
|
+
return unless res == "y"
|
61
|
+
end
|
62
|
+
|
63
|
+
content = S3Object.find('content', 'RemoteClipboard').value
|
64
|
+
case type
|
65
|
+
when 'file'
|
66
|
+
File.open(file_name, "w+") {|f| f << content}
|
67
|
+
puts "#{file_name} copied."
|
68
|
+
when 'directory'
|
69
|
+
tgz = Zlib::GzipReader.new(StringIO.new(content))
|
70
|
+
Minitar.unpack(tgz, ".")
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
desc "fn", "Returns the file name of the copied file"
|
75
|
+
def fn
|
76
|
+
rm_filename
|
77
|
+
end
|
78
|
+
|
79
|
+
desc "cat", "Dump the copied file to stdout"
|
80
|
+
def cat
|
81
|
+
rm_content
|
82
|
+
end
|
83
|
+
|
84
|
+
private
|
85
|
+
def s3_connect
|
86
|
+
require 'aws/s3'
|
87
|
+
include AWS::S3
|
88
|
+
AWS::S3::Base.establish_connection!(
|
89
|
+
:access_key_id => ENV['AMAZON_ACCESS_KEY_ID'],
|
90
|
+
:secret_access_key => ENV['AMAZON_SECRET_ACCESS_KEY']
|
91
|
+
)
|
92
|
+
end
|
93
|
+
|
94
|
+
def filename
|
95
|
+
S3Object.find("file_name.txt", 'RemoteClipboard').value
|
96
|
+
end
|
97
|
+
|
98
|
+
def rm_content
|
99
|
+
S3Object.find( 'content', 'RemoteClipboard').value
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
RemoteCp.start
|
data/lib/remote_cp/version.rb
CHANGED
data/lib/remote_cp.rb
CHANGED
@@ -1,37 +1,84 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
require 'rubygems'
|
2
|
+
require 'zlib'
|
3
|
+
require 'archive/tar/minitar'
|
4
|
+
require 'thor'
|
5
|
+
require 'aws/s3'
|
6
|
+
|
7
|
+
class RemoteCp < Thor
|
8
|
+
include Archive::Tar
|
9
|
+
include AWS::S3
|
10
|
+
|
11
|
+
def initialize(*args)
|
12
|
+
AWS::S3::Base.establish_connection!(
|
13
|
+
:access_key_id => ENV['AMAZON_ACCESS_KEY_ID'],
|
14
|
+
:secret_access_key => ENV['AMAZON_SECRET_ACCESS_KEY']
|
15
|
+
)
|
16
|
+
super
|
17
|
+
end
|
18
|
+
|
19
|
+
desc "cp", "copy to the cloud clipboard"
|
20
|
+
def cp(filename = nil)
|
21
|
+
type = nil
|
22
|
+
content_type = nil
|
23
|
+
|
24
|
+
content = if filename.nil?
|
4
25
|
basename = "anonymous"
|
5
|
-
|
26
|
+
$stdin.read
|
6
27
|
else
|
7
28
|
full_path = File.expand_path(filename)
|
8
29
|
basename = File.basename(full_path)
|
9
|
-
|
30
|
+
if File.directory?(full_path)
|
31
|
+
content_type = "application/gzip"
|
32
|
+
io = StringIO.new("")
|
33
|
+
tgz = Zlib::GzipWriter.new(io)
|
34
|
+
Minitar.pack(basename, tgz)
|
35
|
+
type = 'directory'
|
36
|
+
io.rewind
|
37
|
+
io.string
|
38
|
+
else
|
39
|
+
type = 'file'
|
40
|
+
File.open(full_path)
|
41
|
+
end
|
10
42
|
end
|
11
|
-
|
43
|
+
|
44
|
+
# I think that all this info should be included file's metadata
|
12
45
|
S3Object.store("file_name.txt", basename, 'RemoteClipboard')
|
13
|
-
S3Object.store("content", content, 'RemoteClipboard')
|
46
|
+
S3Object.store("content", content, 'RemoteClipboard', :content_type => content_type)
|
47
|
+
S3Object.store("type", type, 'RemoteClipboard')
|
14
48
|
end
|
15
|
-
|
49
|
+
|
50
|
+
desc "p", "paste from the cloud to current dir"
|
16
51
|
def rmp
|
17
52
|
s3_connect
|
53
|
+
|
18
54
|
file_name = S3Object.find("file_name.txt", 'RemoteClipboard').value
|
55
|
+
type = S3Object.find("type", 'RemoteClipboard').value
|
56
|
+
|
19
57
|
if File.exist?(file_name)
|
20
58
|
puts "#{file_name} already exist."
|
21
59
|
print "Do you want to replace it (y/n)? "
|
22
60
|
res = $stdin.gets.chomp
|
23
61
|
return unless res == "y"
|
24
62
|
end
|
63
|
+
|
25
64
|
content = S3Object.find('content', 'RemoteClipboard').value
|
26
|
-
|
27
|
-
|
65
|
+
case type
|
66
|
+
when 'file'
|
67
|
+
File.open(file_name, "w+") {|f| f << content}
|
68
|
+
puts "#{file_name} copied."
|
69
|
+
when 'directory'
|
70
|
+
tgz = Zlib::GzipReader.new(StringIO.new(content))
|
71
|
+
Minitar.unpack(tgz, ".")
|
72
|
+
end
|
28
73
|
end
|
29
|
-
|
30
|
-
|
74
|
+
|
75
|
+
desc "fn", "Returns the file name of the copied file"
|
76
|
+
def fn
|
31
77
|
rm_filename
|
32
78
|
end
|
33
79
|
|
34
|
-
|
80
|
+
desc "cat", "Dump the copied file to stdout"
|
81
|
+
def cat
|
35
82
|
rm_content
|
36
83
|
end
|
37
84
|
|
@@ -45,13 +92,13 @@ private
|
|
45
92
|
)
|
46
93
|
end
|
47
94
|
|
48
|
-
def
|
49
|
-
|
50
|
-
file_name = S3Object.find("file_name.txt", 'RemoteClipboard').value
|
95
|
+
def filename
|
96
|
+
S3Object.find("file_name.txt", 'RemoteClipboard').value
|
51
97
|
end
|
52
98
|
|
53
99
|
def rm_content
|
54
|
-
|
55
|
-
content = S3Object.find( 'content', 'RemoteClipboard').value
|
100
|
+
S3Object.find( 'content', 'RemoteClipboard').value
|
56
101
|
end
|
57
102
|
end
|
103
|
+
|
104
|
+
RemoteCp.start
|
data/lib/rt
ADDED
@@ -0,0 +1,103 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'rubygems'
|
3
|
+
require 'zlib'
|
4
|
+
require 'archive/tar/minitar'
|
5
|
+
require 'thor'
|
6
|
+
require 'aws/s3'
|
7
|
+
|
8
|
+
class RemoteCp < Thor
|
9
|
+
include Archive::Tar
|
10
|
+
include AWS::S3
|
11
|
+
|
12
|
+
def initialize(*args)
|
13
|
+
AWS::S3::Base.establish_connection!(
|
14
|
+
:access_key_id => ENV['AMAZON_ACCESS_KEY_ID'],
|
15
|
+
:secret_access_key => ENV['AMAZON_SECRET_ACCESS_KEY']
|
16
|
+
)
|
17
|
+
super
|
18
|
+
end
|
19
|
+
|
20
|
+
desc "cp [FILENAME]", "copy FILENAME to the cloudi. If FILENAME not given send STDIN to the cloud"
|
21
|
+
def cp(filename = nil)
|
22
|
+
type = nil
|
23
|
+
content_type = nil
|
24
|
+
|
25
|
+
content = if filename.nil?
|
26
|
+
basename = "anonymous"
|
27
|
+
$stdin.read
|
28
|
+
else
|
29
|
+
full_path = File.expand_path(filename)
|
30
|
+
basename = File.basename(full_path)
|
31
|
+
if File.directory?(full_path)
|
32
|
+
content_type = "application/gzip"
|
33
|
+
io = StringIO.new("")
|
34
|
+
tgz = Zlib::GzipWriter.new(io)
|
35
|
+
Minitar.pack(basename, tgz)
|
36
|
+
type = 'directory'
|
37
|
+
io.rewind
|
38
|
+
io.string
|
39
|
+
else
|
40
|
+
type = 'file'
|
41
|
+
File.open(full_path)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
# I think that all this info should be included file's metadata
|
46
|
+
S3Object.store("file_name.txt", basename, 'RemoteClipboard')
|
47
|
+
S3Object.store("content", content, 'RemoteClipboard', :content_type => content_type)
|
48
|
+
S3Object.store("type", type, 'RemoteClipboard')
|
49
|
+
end
|
50
|
+
|
51
|
+
desc "p", "paste from the cloud to current dir"
|
52
|
+
def p
|
53
|
+
file_name = S3Object.find("file_name.txt", 'RemoteClipboard').value
|
54
|
+
type = S3Object.find("type", 'RemoteClipboard').value
|
55
|
+
|
56
|
+
if File.exist?(file_name)
|
57
|
+
puts "#{file_name} already exist."
|
58
|
+
print "Do you want to replace it (y/n)? "
|
59
|
+
res = $stdin.gets.chomp
|
60
|
+
return unless res == "y"
|
61
|
+
end
|
62
|
+
|
63
|
+
content = S3Object.find('content', 'RemoteClipboard').value
|
64
|
+
case type
|
65
|
+
when 'file'
|
66
|
+
File.open(file_name, "w+") {|f| f << content}
|
67
|
+
puts "#{file_name} copied."
|
68
|
+
when 'directory'
|
69
|
+
tgz = Zlib::GzipReader.new(StringIO.new(content))
|
70
|
+
Minitar.unpack(tgz, ".")
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
desc "fn", "Returns the file name of the copied file"
|
75
|
+
def fn
|
76
|
+
rm_filename
|
77
|
+
end
|
78
|
+
|
79
|
+
desc "cat", "Dump the copied file to stdout"
|
80
|
+
def cat
|
81
|
+
rm_content
|
82
|
+
end
|
83
|
+
|
84
|
+
private
|
85
|
+
def s3_connect
|
86
|
+
require 'aws/s3'
|
87
|
+
include AWS::S3
|
88
|
+
AWS::S3::Base.establish_connection!(
|
89
|
+
:access_key_id => ENV['AMAZON_ACCESS_KEY_ID'],
|
90
|
+
:secret_access_key => ENV['AMAZON_SECRET_ACCESS_KEY']
|
91
|
+
)
|
92
|
+
end
|
93
|
+
|
94
|
+
def filename
|
95
|
+
S3Object.find("file_name.txt", 'RemoteClipboard').value
|
96
|
+
end
|
97
|
+
|
98
|
+
def rm_content
|
99
|
+
S3Object.find( 'content', 'RemoteClipboard').value
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
RemoteCp.start
|
data/remote_cp.gemspec
CHANGED
@@ -15,6 +15,7 @@ Gem::Specification.new do |s|
|
|
15
15
|
s.rubyforge_project = "remote_cp"
|
16
16
|
|
17
17
|
s.add_dependency "aws-s3"
|
18
|
+
s.add_dependency "thor"
|
18
19
|
s.files = `git ls-files`.split("\n")
|
19
20
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
20
21
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: remote_cp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: 25
|
5
|
+
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 3
|
10
|
+
version: 0.0.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Martin Chabot
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-03-25 00:00:00 -04:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -32,11 +32,25 @@ dependencies:
|
|
32
32
|
version: "0"
|
33
33
|
type: :runtime
|
34
34
|
version_requirements: *id001
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: thor
|
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: :runtime
|
48
|
+
version_requirements: *id002
|
35
49
|
description: Tools to facilitate file transfert across machine
|
36
50
|
email:
|
37
51
|
- chabotm@gmail.com
|
38
|
-
executables:
|
39
|
-
|
52
|
+
executables:
|
53
|
+
- rt
|
40
54
|
extensions: []
|
41
55
|
|
42
56
|
extra_rdoc_files: []
|
@@ -45,9 +59,12 @@ files:
|
|
45
59
|
- .gitignore
|
46
60
|
- Gemfile
|
47
61
|
- Gemfile.lock
|
62
|
+
- README
|
48
63
|
- Rakefile
|
64
|
+
- bin/rt
|
49
65
|
- lib/remote_cp.rb
|
50
66
|
- lib/remote_cp/version.rb
|
67
|
+
- lib/rt
|
51
68
|
- remote_cp.gemspec
|
52
69
|
has_rdoc: true
|
53
70
|
homepage: http://github.com/martinos/remote_cp
|
@@ -79,7 +96,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
79
96
|
requirements: []
|
80
97
|
|
81
98
|
rubyforge_project: remote_cp
|
82
|
-
rubygems_version: 1.
|
99
|
+
rubygems_version: 1.5.0
|
83
100
|
signing_key:
|
84
101
|
specification_version: 3
|
85
102
|
summary: Tools to facilitate file transfert across machine
|