clipboard 0.6.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +0 -2
- data/Rakefile +3 -5
- data/VERSION +1 -1
- data/clipboard.gemspec +2 -2
- data/lib/clipboard.rb +39 -2
- metadata +9 -4
data/README.rdoc
CHANGED
@@ -16,10 +16,8 @@ Have fun ;)
|
|
16
16
|
* +Zucker+ gem
|
17
17
|
|
18
18
|
=== TODO
|
19
|
-
* Automatically require the <tt>win32-clipboard</tt> gem - but only on windows!
|
20
19
|
* Don't depend on +xclip+
|
21
20
|
* Don't depend on the <tt>win32-clipboard</tt> gem (or fix the 1.9 issues with the gem)
|
22
|
-
* Error management?
|
23
21
|
|
24
22
|
Feel free to report bugs or to implement one of the above features ;)
|
25
23
|
|
data/Rakefile
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require 'rake'
|
3
|
-
# require 'bundler'
|
4
3
|
|
5
4
|
begin
|
6
5
|
require 'jeweler'
|
@@ -12,11 +11,10 @@ begin
|
|
12
11
|
gem.homepage = "http://github.com/janlelis/clipboard"
|
13
12
|
gem.authors = ["Jan Lelis"]
|
14
13
|
gem.add_development_dependency "jeweler", ">= 0"
|
15
|
-
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
16
14
|
gem.add_dependency('zucker', '>= 4')
|
17
|
-
gem.requirements << '
|
18
|
-
gem.requirements << '
|
19
|
-
|
15
|
+
gem.requirements << 'on linux (or other X), you need xclip'
|
16
|
+
gem.requirements << 'on windows, you need the win32-clipboard gem'
|
17
|
+
|
20
18
|
end
|
21
19
|
Jeweler::GemcutterTasks.new
|
22
20
|
rescue LoadError
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.7.0
|
data/clipboard.gemspec
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{clipboard}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.7.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Jan Lelis"]
|
@@ -61,7 +61,7 @@ Gem::Specification.new do |s|
|
|
61
61
|
s.homepage = %q{http://github.com/janlelis/clipboard}
|
62
62
|
s.rdoc_options = ["--charset=UTF-8"]
|
63
63
|
s.require_paths = ["lib"]
|
64
|
-
s.requirements = ["
|
64
|
+
s.requirements = ["on linux (or other X), you need xclip", "on windows, you need the win32-clipboard gem"]
|
65
65
|
s.rubygems_version = %q{1.3.7}
|
66
66
|
s.summary = %q{Access the clipboard on all systems}
|
67
67
|
|
data/lib/clipboard.rb
CHANGED
@@ -1,8 +1,17 @@
|
|
1
1
|
require 'zucker/os'
|
2
2
|
require 'zucker/alias_for'
|
3
|
+
require 'stringio'
|
3
4
|
|
4
5
|
require File.expand_path '../../version', __FILE__
|
5
6
|
|
7
|
+
def capture_stderr
|
8
|
+
capture = StringIO.new
|
9
|
+
restore, $stderr = $stderr, capture
|
10
|
+
yield
|
11
|
+
$stderr = restore
|
12
|
+
capture.string
|
13
|
+
end
|
14
|
+
|
6
15
|
class << Clipboard ||= Module.new
|
7
16
|
case # OS
|
8
17
|
when OS.linux? || OS.mac? || OS.bsd? || OS.posix?
|
@@ -14,10 +23,21 @@ class << Clipboard ||= Module.new
|
|
14
23
|
else # linuX
|
15
24
|
WriteCommand = 'xclip'
|
16
25
|
ReadCommand = 'xclip -o'
|
26
|
+
|
27
|
+
# catch dependency errors
|
28
|
+
Open3.popen3( "xclip -version" ){ |_, _, error|
|
29
|
+
unless error.read =~ /^xclip version/
|
30
|
+
raise "clipboard -\n" +
|
31
|
+
"Could not find required prgram xclip\n" +
|
32
|
+
"You can install it (on debian/ubuntu) with sudo apt-get install xclip"
|
33
|
+
end
|
34
|
+
}
|
17
35
|
end
|
18
36
|
|
19
37
|
def write(data)
|
20
|
-
Open3.popen3( WriteCommand ){ |input, _, _|
|
38
|
+
Open3.popen3( WriteCommand ){ |input, _, _|
|
39
|
+
input << data
|
40
|
+
}
|
21
41
|
read # or true or nil?
|
22
42
|
end
|
23
43
|
|
@@ -29,7 +49,13 @@ class << Clipboard ||= Module.new
|
|
29
49
|
write ''
|
30
50
|
end
|
31
51
|
when OS.windows?
|
32
|
-
|
52
|
+
begin
|
53
|
+
require 'win32/clipboard'
|
54
|
+
rescue LoadError
|
55
|
+
raise "clipboard -\n" +
|
56
|
+
"Could not load the required win32-clipboard gem\n"
|
57
|
+
"You can install it with gem install win32-clipboard"
|
58
|
+
end
|
33
59
|
|
34
60
|
def write(data)
|
35
61
|
Win32::Clipboard.set_data( data )
|
@@ -48,6 +74,17 @@ class << Clipboard ||= Module.new
|
|
48
74
|
|
49
75
|
alias_for :write, :copy
|
50
76
|
alias_for :read, :paste
|
77
|
+
|
78
|
+
# private
|
79
|
+
|
80
|
+
def capture_stdout
|
81
|
+
capture = StringIO.new
|
82
|
+
restore, $stdout = $stdout, capture
|
83
|
+
yield
|
84
|
+
$stdout = restore
|
85
|
+
capture.string
|
86
|
+
end
|
87
|
+
|
51
88
|
end
|
52
89
|
|
53
90
|
# J-_-L
|
metadata
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: clipboard
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
+
hash: 3
|
4
5
|
prerelease: false
|
5
6
|
segments:
|
6
7
|
- 0
|
7
|
-
-
|
8
|
+
- 7
|
8
9
|
- 0
|
9
|
-
version: 0.
|
10
|
+
version: 0.7.0
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- Jan Lelis
|
@@ -25,6 +26,7 @@ dependencies:
|
|
25
26
|
requirements:
|
26
27
|
- - ">="
|
27
28
|
- !ruby/object:Gem::Version
|
29
|
+
hash: 3
|
28
30
|
segments:
|
29
31
|
- 0
|
30
32
|
version: "0"
|
@@ -38,6 +40,7 @@ dependencies:
|
|
38
40
|
requirements:
|
39
41
|
- - ">="
|
40
42
|
- !ruby/object:Gem::Version
|
43
|
+
hash: 11
|
41
44
|
segments:
|
42
45
|
- 4
|
43
46
|
version: "4"
|
@@ -107,6 +110,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
107
110
|
requirements:
|
108
111
|
- - ">="
|
109
112
|
- !ruby/object:Gem::Version
|
113
|
+
hash: 3
|
110
114
|
segments:
|
111
115
|
- 0
|
112
116
|
version: "0"
|
@@ -115,12 +119,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
115
119
|
requirements:
|
116
120
|
- - ">="
|
117
121
|
- !ruby/object:Gem::Version
|
122
|
+
hash: 3
|
118
123
|
segments:
|
119
124
|
- 0
|
120
125
|
version: "0"
|
121
126
|
requirements:
|
122
|
-
-
|
123
|
-
-
|
127
|
+
- on linux (or other X), you need xclip
|
128
|
+
- on windows, you need the win32-clipboard gem
|
124
129
|
rubyforge_project:
|
125
130
|
rubygems_version: 1.3.7
|
126
131
|
signing_key:
|