nwcopy 0.0.8 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +2 -5
- data/README.rdoc +13 -6
- data/lib/nwcopy.rb +36 -21
- data/lib/nwcopy/client.rb +7 -2
- data/lib/nwcopy/dropbox.rb +1 -1
- data/lib/nwcopy/gist.rb +1 -1
- data/lib/nwcopy/version.rb +1 -1
- metadata +3 -3
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
nwcopy (0.0.
|
4
|
+
nwcopy (0.0.8)
|
5
5
|
gist
|
6
6
|
json
|
7
7
|
multipart-post
|
@@ -10,14 +10,11 @@ GEM
|
|
10
10
|
remote: http://rubygems.org/
|
11
11
|
specs:
|
12
12
|
gist (2.0.0)
|
13
|
-
json (1.
|
13
|
+
json (1.5.1)
|
14
14
|
multipart-post (1.1.0)
|
15
15
|
|
16
16
|
PLATFORMS
|
17
17
|
ruby
|
18
18
|
|
19
19
|
DEPENDENCIES
|
20
|
-
gist
|
21
|
-
json
|
22
|
-
multipart-post
|
23
20
|
nwcopy!
|
data/README.rdoc
CHANGED
@@ -4,27 +4,34 @@ The fool proof network copy & paste program. Well, maybe someday.
|
|
4
4
|
|
5
5
|
= Usage
|
6
6
|
|
7
|
-
|
7
|
+
Copy data from the clipboard (pbpaste).
|
8
8
|
> nwcopy -p
|
9
9
|
/Users/josh/Dropbox/nwcopy/f314eee55161b14f140ee07b358ba63ef54112ac
|
10
|
-
|
10
|
+
|
11
|
+
Paste to STDOUT and the clipboard (pbcopy)
|
11
12
|
> nwpaste
|
12
13
|
<Contents of clipboard>
|
13
14
|
|
14
|
-
|
15
|
+
Copy contents of a file to the clipboard (works with binaries)
|
15
16
|
> nwcopy /path/to/file
|
16
17
|
/Users/josh/Dropbox/nwcopy/e1c1675f009e65d8571bbab9243660da20a3b2a2
|
17
|
-
|
18
|
+
|
19
|
+
Paste the file to disk
|
18
20
|
> nwpaste
|
19
21
|
Pasted to file
|
20
22
|
|
21
|
-
|
23
|
+
Pipe arbitrary whatever to the clipboard
|
22
24
|
> echo 'pipes work' | nwcopy
|
23
25
|
/Users/josh/Dropbox/nwcopy/5293e79627710caf507fb9b841df51356650c78d
|
24
|
-
|
26
|
+
|
27
|
+
Paste to STDOUT and the clipboard (pbcopy)
|
25
28
|
> nwpaste
|
26
29
|
pipes work
|
27
30
|
|
31
|
+
Paste a hash from nwcopy.net (shared or otherwise)
|
32
|
+
> nwpaste <hash>
|
33
|
+
Whatever that hash represented
|
34
|
+
|
28
35
|
= Description
|
29
36
|
|
30
37
|
nwcopy takes whatever is in the clipboard (or pipe or filename) and copies it to http://nwcopy.net. If you don't have nwcopy.net configured, it will copy to a file in your Dropbox folder ~/Dropbox/nwcopy/<sha1>
|
data/lib/nwcopy.rb
CHANGED
@@ -13,7 +13,7 @@ module Nwcopy
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def self.copy
|
16
|
-
data =
|
16
|
+
data = copy_data_from_options
|
17
17
|
|
18
18
|
unavailable = []
|
19
19
|
plugins.each do |plugin|
|
@@ -26,11 +26,11 @@ module Nwcopy
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def self.paste
|
29
|
-
|
29
|
+
data = paste_data_from_options
|
30
30
|
unavailable = []
|
31
31
|
plugins.each do |plugin|
|
32
32
|
if plugin.available?
|
33
|
-
if clipboard = plugin.paste
|
33
|
+
if clipboard = plugin.paste(data)
|
34
34
|
`echo "#{clipboard}" | pbcopy` unless `which pbcopy`.empty?
|
35
35
|
return clipboard
|
36
36
|
end
|
@@ -41,7 +41,15 @@ module Nwcopy
|
|
41
41
|
end
|
42
42
|
|
43
43
|
private
|
44
|
-
def self.
|
44
|
+
def self.paste_data_from_options
|
45
|
+
if ARGV.include? '--help'
|
46
|
+
help
|
47
|
+
else
|
48
|
+
ARGV.shift
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def self.copy_data_from_options
|
45
53
|
if ARGV.empty?
|
46
54
|
nodata = ARGF.read_nonblock(1) rescue true
|
47
55
|
else
|
@@ -49,27 +57,34 @@ module Nwcopy
|
|
49
57
|
end
|
50
58
|
|
51
59
|
if nodata || ARGV.include?('--help')
|
52
|
-
|
53
|
-
puts 'Sign up at http://nwcopy.net.' unless Nwcopy::Client.available?
|
54
|
-
puts "nwcopy.net account: #{Nwcopy::Client.credentials.first}" if Nwcopy::Client.available? rescue ''
|
55
|
-
puts
|
56
|
-
puts ' nwcopy <file>'
|
57
|
-
puts ' Copies the file to nwcopy.net'
|
58
|
-
puts ' nwcopy -p'
|
59
|
-
puts ' Copies the contents of the clipboard (MacOS) to nwcopy.net'
|
60
|
-
puts ' command | nwcopy'
|
61
|
-
puts ' Copies the results of the piped command to nwcopy.net'
|
62
|
-
puts
|
63
|
-
puts ' nwpaste'
|
64
|
-
puts ' Pastes the last thing you copied to nwcopy.net'
|
65
|
-
puts ' If it is a file, it will be put into that file name.'
|
66
|
-
puts ' Any piped input or clipboard will be printed to STDOUT.'
|
67
|
-
puts
|
68
|
-
exit
|
60
|
+
help
|
69
61
|
elsif ARGV.include?('-p')
|
70
62
|
StringIO.new `pbpaste`
|
71
63
|
else
|
72
64
|
ARGF
|
73
65
|
end
|
74
66
|
end
|
67
|
+
|
68
|
+
def self.help
|
69
|
+
puts 'nwcopy: network copy and paste.'
|
70
|
+
puts 'Sign up at http://nwcopy.net.' unless Nwcopy::Client.available?
|
71
|
+
puts "nwcopy.net account: #{Nwcopy::Client.credentials.first}" if Nwcopy::Client.available? rescue ''
|
72
|
+
puts
|
73
|
+
puts ' nwcopy <file>'
|
74
|
+
puts ' Copies the file to nwcopy.net'
|
75
|
+
puts ' nwcopy -p'
|
76
|
+
puts ' Copies the contents of the clipboard (MacOS) to nwcopy.net'
|
77
|
+
puts ' command | nwcopy'
|
78
|
+
puts ' Copies the results of the piped command to nwcopy.net'
|
79
|
+
puts
|
80
|
+
puts ' nwpaste'
|
81
|
+
puts ' Pastes the last thing you copied to nwcopy.net'
|
82
|
+
puts ' If it is a file, it will be put into that file name.'
|
83
|
+
puts ' Any piped input or clipboard will be printed to STDOUT.'
|
84
|
+
puts
|
85
|
+
puts ' nwpaste <hash>'
|
86
|
+
puts ' Pastes the provided hash from nwcopy.net'
|
87
|
+
puts
|
88
|
+
exit
|
89
|
+
end
|
75
90
|
end
|
data/lib/nwcopy/client.rb
CHANGED
@@ -44,8 +44,13 @@ module Nwcopy
|
|
44
44
|
end
|
45
45
|
|
46
46
|
|
47
|
-
def self.paste
|
48
|
-
url =
|
47
|
+
def self.paste url_or_hash = nil
|
48
|
+
url = if url_or_hash
|
49
|
+
hash = url_or_hash.split('/').last
|
50
|
+
URI.parse("#{base_url}/pastes/#{hash}")
|
51
|
+
else
|
52
|
+
URI.parse("#{base_url}/paste")
|
53
|
+
end
|
49
54
|
|
50
55
|
req = Net::HTTP::Get.new(url.path)
|
51
56
|
res = start req, url
|
data/lib/nwcopy/dropbox.rb
CHANGED
data/lib/nwcopy/gist.rb
CHANGED
data/lib/nwcopy/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nwcopy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
+
- 1
|
8
9
|
- 0
|
9
|
-
|
10
|
-
version: 0.0.8
|
10
|
+
version: 0.1.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Josh Kleinpeter
|