clipboard 1.3.0 → 1.3.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +1 -1
- data/clipboard.gemspec +2 -2
- data/lib/clipboard/linux.rb +9 -9
- data/lib/clipboard/version.rb +1 -1
- data/spec/clipboard_file_spec.rb +24 -0
- data/spec/clipboard_spec.rb +15 -25
- metadata +4 -5
- data/spec/clipboard_linux_spec.rb +0 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2e5ac85c5f3eefe7f038800d250f7aa0a0aa4f5cad84b288a5f61f7ee354476f
|
4
|
+
data.tar.gz: aec83891b78fa15dfa574ccd83736956033e25e763cb59d38aea592e12947ee5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5d686fcb2be31dfb73a94930f2dbd9cecd41256b62399677fc07c44a5dbb289f36e808e69fe0fe9763cf806960103b0ddeb34f7daafd8e9b3d28bf1725c4bc8a
|
7
|
+
data.tar.gz: 27e56c7766971c528033760410adb598cc81d949844d892bcd0a401df0d9154c88c06e79eb7b614529a8df9b204264d0292f0bd1925f66236d15c11bb0f40f16
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
# CHANGELOG
|
2
2
|
|
3
|
+
## 1.3.1
|
4
|
+
* Prefer xsel over xclip, because it can handle more data
|
5
|
+
* See here: https://github.com/janlelis/clipboard/pull/33/files#diff-80752ab4de37ec2dcf1dc85457e09d40R13
|
6
|
+
|
3
7
|
## 1.3.0
|
4
8
|
### Bug Fixes
|
5
9
|
* Conditionally read or don't read the output stream of external commands, fixes #32
|
data/README.md
CHANGED
@@ -25,7 +25,7 @@ gem 'clipboard'
|
|
25
25
|
gem 'ffi', :platforms => [:mswin, :mingw]
|
26
26
|
```
|
27
27
|
|
28
|
-
- Important note for **Linux** users: The clipboard requires the *xclip* or the *xsel* command-line program. On debian and ubuntu,
|
28
|
+
- Important note for **Linux** users: The clipboard requires the *xclip* or the *xsel* command-line program. On debian and ubuntu, *xsel* can be installed with: `sudo apt-get install xsel`
|
29
29
|
|
30
30
|
## Clipboard Implementations
|
31
31
|
|
data/clipboard.gemspec
CHANGED
@@ -12,8 +12,8 @@ Gem::Specification.new do |s|
|
|
12
12
|
s.homepage = "https://github.com/janlelis/clipboard"
|
13
13
|
s.license = "MIT"
|
14
14
|
s.requirements = [
|
15
|
-
"
|
16
|
-
"
|
15
|
+
"Linux: You need xclip or xsel. On debian/ubuntu run: sudo apt-get install xsel",
|
16
|
+
"Windows: You need the ffi gem",
|
17
17
|
]
|
18
18
|
s.files = Dir.glob(%w[{lib,spec}/**/*.rb [A-Z]*.txt [A-Z]*.md]) + %w{clipboard.gemspec}
|
19
19
|
|
data/lib/clipboard/linux.rb
CHANGED
@@ -9,14 +9,7 @@ module Clipboard
|
|
9
9
|
CLIPBOARDS = %w[clipboard primary secondary].freeze
|
10
10
|
|
11
11
|
# check which backend to use
|
12
|
-
if Utils.executable_installed?
|
13
|
-
WriteCommand = 'xclip'
|
14
|
-
ReadCommand = 'xclip -o'
|
15
|
-
ReadOutputStream = false
|
16
|
-
Selection = proc{ |x|
|
17
|
-
"-selection #{x}"
|
18
|
-
}.freeze
|
19
|
-
elsif Utils.executable_installed?('xsel')
|
12
|
+
if Utils.executable_installed? "xsel"
|
20
13
|
WriteCommand = 'xsel -i'
|
21
14
|
ReadCommand = 'xsel -o'
|
22
15
|
ReadOutputStream = true
|
@@ -25,9 +18,16 @@ module Clipboard
|
|
25
18
|
'primary' => '-p',
|
26
19
|
'secondary' => '-s'
|
27
20
|
}.freeze
|
21
|
+
elsif Utils.executable_installed? "xclip"
|
22
|
+
WriteCommand = 'xclip'
|
23
|
+
ReadCommand = 'xclip -o'
|
24
|
+
ReadOutputStream = false
|
25
|
+
Selection = proc{ |x|
|
26
|
+
"-selection #{x}"
|
27
|
+
}.freeze
|
28
28
|
else
|
29
29
|
raise Clipboard::ClipboardLoadError, "clipboard: Could not find required program xclip or xsel\n" \
|
30
|
-
"On debian/ubuntu, you can install it with: sudo apt-get install
|
30
|
+
"On debian/ubuntu, you can install it with: sudo apt-get install xsel"
|
31
31
|
end
|
32
32
|
|
33
33
|
def paste(which = nil)
|
data/lib/clipboard/version.rb
CHANGED
@@ -0,0 +1,24 @@
|
|
1
|
+
require_relative "spec_helper"
|
2
|
+
|
3
|
+
describe 'Clipboard::File' do
|
4
|
+
before :all do
|
5
|
+
Clipboard.implementation = Clipboard::File
|
6
|
+
cache = Clipboard::File::FILE
|
7
|
+
FileUtils.rm cache if File.exist?(cache)
|
8
|
+
end
|
9
|
+
|
10
|
+
it "can paste with empty file" do
|
11
|
+
expect( Clipboard.paste ).to eq ''
|
12
|
+
end
|
13
|
+
|
14
|
+
it "can copy & paste" do
|
15
|
+
expect( Clipboard.copy('xxx') ).to eq 'xxx'
|
16
|
+
expect( Clipboard.paste ).to eq 'xxx'
|
17
|
+
end
|
18
|
+
|
19
|
+
it "can clear" do
|
20
|
+
expect( Clipboard.copy('xxx') ).to eq 'xxx'
|
21
|
+
Clipboard.clear
|
22
|
+
expect( Clipboard.paste ).to eq ''
|
23
|
+
end
|
24
|
+
end
|
data/spec/clipboard_spec.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Please note: cannot test, if it really accesses your platform clipboard.
|
2
2
|
|
3
|
-
|
3
|
+
require_relative "spec_helper"
|
4
4
|
|
5
5
|
os_to_restore = RbConfig::CONFIG['host_os']
|
6
6
|
|
@@ -18,12 +18,10 @@ describe Clipboard do
|
|
18
18
|
expect( Clipboard.paste ).to eq "FOO\nBAR"
|
19
19
|
end
|
20
20
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
expect( Clipboard.paste ).to eq "日本語"
|
26
|
-
end
|
21
|
+
it "can copy & paste with multibyte char" do
|
22
|
+
Encoding.default_external = "utf-8"
|
23
|
+
Clipboard.copy("日本語")
|
24
|
+
expect( Clipboard.paste ).to eq "日本語"
|
27
25
|
end
|
28
26
|
|
29
27
|
it "returns data on copy" do
|
@@ -50,27 +48,19 @@ describe Clipboard do
|
|
50
48
|
end
|
51
49
|
end
|
52
50
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
end
|
51
|
+
# See https://github.com/janlelis/clipboard/issues/32 by @orange-kao
|
52
|
+
it "can copy more than 8192 bytes" do
|
53
|
+
# first batch
|
54
|
+
data1 = Random.new.bytes(2**14).unpack("H*").first
|
55
|
+
data2 = Clipboard.copy(data1)
|
59
56
|
|
60
|
-
|
61
|
-
expect( Clipboard.paste ).to eq ''
|
62
|
-
end
|
57
|
+
expect(data2).to eq data1
|
63
58
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
end
|
59
|
+
# second batch
|
60
|
+
data1 = Random.new.bytes(2**14).unpack("H*").first
|
61
|
+
data2 = Clipboard.copy(data1)
|
68
62
|
|
69
|
-
|
70
|
-
expect( Clipboard.copy('xxx') ).to eq 'xxx'
|
71
|
-
Clipboard.clear
|
72
|
-
expect( Clipboard.paste ).to eq ''
|
73
|
-
end
|
63
|
+
expect(data2).to eq data1
|
74
64
|
end
|
75
65
|
|
76
66
|
describe :implementation do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: clipboard
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jan Lelis
|
@@ -61,7 +61,7 @@ files:
|
|
61
61
|
- lib/clipboard/version.rb
|
62
62
|
- lib/clipboard/windows.rb
|
63
63
|
- lib/clipboard/wsl.rb
|
64
|
-
- spec/
|
64
|
+
- spec/clipboard_file_spec.rb
|
65
65
|
- spec/clipboard_spec.rb
|
66
66
|
- spec/spec_helper.rb
|
67
67
|
homepage: https://github.com/janlelis/clipboard
|
@@ -83,9 +83,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
83
83
|
- !ruby/object:Gem::Version
|
84
84
|
version: '0'
|
85
85
|
requirements:
|
86
|
-
- '
|
87
|
-
|
88
|
-
- On Windows, you will need the ffi gem.
|
86
|
+
- 'Linux: You need xclip or xsel. On debian/ubuntu run: sudo apt-get install xsel'
|
87
|
+
- 'Windows: You need the ffi gem'
|
89
88
|
rubyforge_project:
|
90
89
|
rubygems_version: 2.7.7
|
91
90
|
signing_key:
|
@@ -1,20 +0,0 @@
|
|
1
|
-
require_relative 'spec_helper'
|
2
|
-
|
3
|
-
require "clipboard/linux"
|
4
|
-
|
5
|
-
describe Clipboard::Linux do
|
6
|
-
# See https://github.com/janlelis/clipboard/issues/32 by @orange-kao
|
7
|
-
it "can copy more than 8192 bytes" do
|
8
|
-
# first batch
|
9
|
-
data1 = Random.new.bytes(2**14).unpack("H*").first
|
10
|
-
data2 = Clipboard.copy(data1)
|
11
|
-
|
12
|
-
expect(data2).to eq data1
|
13
|
-
|
14
|
-
# second batch
|
15
|
-
data1 = Random.new.bytes(2**14).unpack("H*").first
|
16
|
-
data2 = Clipboard.copy(data1)
|
17
|
-
|
18
|
-
expect(data2).to eq data1
|
19
|
-
end
|
20
|
-
end
|