clipboard 1.3.0 → 1.3.5
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 +17 -0
- data/MIT-LICENSE.txt +1 -1
- data/README.md +8 -4
- data/clipboard.gemspec +11 -10
- data/lib/clipboard.rb +1 -1
- data/lib/clipboard/cygwin.rb +2 -2
- data/lib/clipboard/linux.rb +9 -9
- data/lib/clipboard/version.rb +1 -1
- data/lib/clipboard/windows.rb +1 -1
- data/spec/clipboard_file_spec.rb +26 -0
- data/spec/clipboard_spec.rb +17 -25
- data/spec/spec_helper.rb +2 -0
- metadata +10 -11
- 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: 892729b3fc00a3f989dfa1c3c5e1c05062b94a2f01af23a358d519a09b737f33
|
4
|
+
data.tar.gz: 38f17ac7f06b2ff302b9498c3a3ad81bc2e7c9418f700f485569d8b8f15a18c9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5920c4e55b0322ac05a0df5c36e7d3c2dca41a31a481aab7ed3df6f838a10c0d4592910617c4e95b5878d5133d1b628b46cecef236118abecab608dc64b31827
|
7
|
+
data.tar.gz: 4ff5e2aba0b87384d16941ed3b85ba61382c7e28bc3a07e922328e3a9faf8a23f0524b797d8a729fd34cbb11720d6271890b6d772597444793dc66dd9443ad27
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,22 @@
|
|
1
1
|
# CHANGELOG
|
2
2
|
|
3
|
+
## 1.3.5
|
4
|
+
* Fix missing String#+@ method on Ruby <2.3, patch by @AaronC81
|
5
|
+
|
6
|
+
## 1.3.4
|
7
|
+
* Don't break on Ruby 2.1, patch by @grosser
|
8
|
+
|
9
|
+
## 1.3.3
|
10
|
+
|
11
|
+
* Fix Cygwin implementation to work when File constant is loaded, fix by @ntachino
|
12
|
+
|
13
|
+
## 1.3.2
|
14
|
+
* Windows version actually mutates a string, fix by @scivola
|
15
|
+
|
16
|
+
## 1.3.1
|
17
|
+
* Prefer xsel over xclip, because it can handle more data
|
18
|
+
* See here: https://github.com/janlelis/clipboard/pull/33/files#diff-80752ab4de37ec2dcf1dc85457e09d40R13
|
19
|
+
|
3
20
|
## 1.3.0
|
4
21
|
### Bug Fixes
|
5
22
|
* Conditionally read or don't read the output stream of external commands, fixes #32
|
data/MIT-LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -10,6 +10,10 @@ Lets you access the clipboard from everywhere. Currently supported platforms:
|
|
10
10
|
- Gtk+ (Cross Platform Widget Toolkit)
|
11
11
|
- Java (on JRuby)
|
12
12
|
|
13
|
+
Supported Rubies: **2.7**, **2.6**, **2.5**
|
14
|
+
|
15
|
+
Unsupported, but might still work: **2.4**, **2.3**, **2.2**, **2.1**, **2.0**
|
16
|
+
|
13
17
|
## Usage
|
14
18
|
|
15
19
|
* `Clipboard.copy` - Copies a string to system clipboard
|
@@ -21,11 +25,11 @@ Lets you access the clipboard from everywhere. Currently supported platforms:
|
|
21
25
|
Add the following lines to your `Gemfile`:
|
22
26
|
|
23
27
|
```ruby
|
24
|
-
gem
|
25
|
-
gem
|
28
|
+
gem "clipboard"
|
29
|
+
gem "ffi", :platforms => [:mswin, :mingw] # Required by Clipboard on Windows
|
26
30
|
```
|
27
31
|
|
28
|
-
- Important note for
|
32
|
+
- **Important note for Linux** users: The clipboard requires the *xsel* or the *xclip* command-line program. On debian and ubuntu, *xsel* can be installed with: `sudo apt-get install xsel`
|
29
33
|
|
30
34
|
## Clipboard Implementations
|
31
35
|
|
@@ -84,4 +88,4 @@ Without any arguments, it will just paste the contents of the clipboard.
|
|
84
88
|
|
85
89
|
### MIT
|
86
90
|
|
87
|
-
Copyright (c) 2010-
|
91
|
+
Copyright (c) 2010-2020 Jan Lelis <https://janlelis.com> released under the MIT license. Contributions by and thanks to Michael Grosser and [all the other contributors!](https://github.com/janlelis/clipboard/graphs/contributors)
|
data/clipboard.gemspec
CHANGED
@@ -1,24 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
$:.unshift File.expand_path("../lib", __FILE__)
|
2
4
|
require 'clipboard/version'
|
3
5
|
|
4
6
|
Gem::Specification.new do |s|
|
5
|
-
s.name
|
6
|
-
s.version
|
7
|
-
|
8
|
-
s.
|
9
|
-
s.summary
|
7
|
+
s.name = 'clipboard'
|
8
|
+
s.version = Clipboard::VERSION
|
9
|
+
s.authors = ["Jan Lelis"]
|
10
|
+
s.email = ["hi@ruby.consulting"]
|
11
|
+
s.summary = "Access to the clipboard on Linux, MacOS, Windows, and Cygwin."
|
10
12
|
s.description = "Access to the clipboard on Linux, MacOS, Windows, and Cygwin: Clipboard.copy, Clipboard.paste, Clipboard.clear"
|
11
|
-
s.email = "mail@janlelis.de"
|
12
13
|
s.homepage = "https://github.com/janlelis/clipboard"
|
13
|
-
s.license
|
14
|
+
s.license = "MIT"
|
14
15
|
s.requirements = [
|
15
|
-
"
|
16
|
-
"
|
16
|
+
"Linux: You need xclip or xsel. On debian/ubuntu run: sudo apt-get install xsel",
|
17
|
+
"Windows: You need the ffi gem",
|
17
18
|
]
|
18
19
|
s.files = Dir.glob(%w[{lib,spec}/**/*.rb [A-Z]*.txt [A-Z]*.md]) + %w{clipboard.gemspec}
|
19
20
|
|
20
21
|
s.required_ruby_version = '>= 1.9.3'
|
21
|
-
s.add_development_dependency 'rake', '~>
|
22
|
+
s.add_development_dependency 'rake', '~> 13.0'
|
22
23
|
s.add_development_dependency 'rspec', '~> 3'
|
23
24
|
# s.add_development_dependency 'ffi', '~> 1.9'
|
24
25
|
# s.add_development_dependency 'gtk3', '~> 3'
|
data/lib/clipboard.rb
CHANGED
@@ -35,7 +35,7 @@ module Clipboard
|
|
35
35
|
# Running additional check to detect if running in Microsoft WSL
|
36
36
|
if os == :Linux
|
37
37
|
require "etc"
|
38
|
-
if Etc.uname[:release] =~ /Microsoft/
|
38
|
+
if Etc.respond_to?(:uname) && Etc.uname[:release] =~ /Microsoft/ # uname was added in ruby 2.2
|
39
39
|
os = :Wsl
|
40
40
|
end
|
41
41
|
end
|
data/lib/clipboard/cygwin.rb
CHANGED
@@ -5,11 +5,11 @@ module Clipboard
|
|
5
5
|
extend self
|
6
6
|
|
7
7
|
def paste(_ = nil)
|
8
|
-
File.read("/dev/clipboard")
|
8
|
+
::File.read("/dev/clipboard")
|
9
9
|
end
|
10
10
|
|
11
11
|
def copy(data)
|
12
|
-
File.open("/dev/clipboard", "w"){ |f| f.write(data) }
|
12
|
+
::File.open("/dev/clipboard", "w"){ |f| f.write(data) }
|
13
13
|
paste
|
14
14
|
end
|
15
15
|
|
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
data/lib/clipboard/windows.rb
CHANGED
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "spec_helper"
|
4
|
+
|
5
|
+
describe 'Clipboard::File' do
|
6
|
+
before :all do
|
7
|
+
Clipboard.implementation = Clipboard::File
|
8
|
+
cache = Clipboard::File::FILE
|
9
|
+
FileUtils.rm cache if File.exist?(cache)
|
10
|
+
end
|
11
|
+
|
12
|
+
it "can paste with empty file" do
|
13
|
+
expect( Clipboard.paste ).to eq ''
|
14
|
+
end
|
15
|
+
|
16
|
+
it "can copy & paste" do
|
17
|
+
expect( Clipboard.copy('xxx') ).to eq 'xxx'
|
18
|
+
expect( Clipboard.paste ).to eq 'xxx'
|
19
|
+
end
|
20
|
+
|
21
|
+
it "can clear" do
|
22
|
+
expect( Clipboard.copy('xxx') ).to eq 'xxx'
|
23
|
+
Clipboard.clear
|
24
|
+
expect( Clipboard.paste ).to eq ''
|
25
|
+
end
|
26
|
+
end
|
data/spec/clipboard_spec.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# Please note: cannot test, if it really accesses your platform clipboard.
|
2
4
|
|
3
|
-
|
5
|
+
require_relative "spec_helper"
|
4
6
|
|
5
7
|
os_to_restore = RbConfig::CONFIG['host_os']
|
6
8
|
|
@@ -18,12 +20,10 @@ describe Clipboard do
|
|
18
20
|
expect( Clipboard.paste ).to eq "FOO\nBAR"
|
19
21
|
end
|
20
22
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
expect( Clipboard.paste ).to eq "日本語"
|
26
|
-
end
|
23
|
+
it "can copy & paste with multibyte char" do
|
24
|
+
Encoding.default_external = "utf-8"
|
25
|
+
Clipboard.copy("日本語")
|
26
|
+
expect( Clipboard.paste ).to eq "日本語"
|
27
27
|
end
|
28
28
|
|
29
29
|
it "returns data on copy" do
|
@@ -50,27 +50,19 @@ describe Clipboard do
|
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
end
|
53
|
+
# See https://github.com/janlelis/clipboard/issues/32 by @orange-kao
|
54
|
+
it "can copy more than 8192 bytes" do
|
55
|
+
# first batch
|
56
|
+
data1 = Random.new.bytes(2**14).unpack("H*").first
|
57
|
+
data2 = Clipboard.copy(data1)
|
59
58
|
|
60
|
-
|
61
|
-
expect( Clipboard.paste ).to eq ''
|
62
|
-
end
|
59
|
+
expect(data2).to eq data1
|
63
60
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
end
|
61
|
+
# second batch
|
62
|
+
data1 = Random.new.bytes(2**14).unpack("H*").first
|
63
|
+
data2 = Clipboard.copy(data1)
|
68
64
|
|
69
|
-
|
70
|
-
expect( Clipboard.copy('xxx') ).to eq 'xxx'
|
71
|
-
Clipboard.clear
|
72
|
-
expect( Clipboard.paste ).to eq ''
|
73
|
-
end
|
65
|
+
expect(data2).to eq data1
|
74
66
|
end
|
75
67
|
|
76
68
|
describe :implementation do
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
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.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jan Lelis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-09-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '13.0'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '13.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rspec
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -40,7 +40,8 @@ dependencies:
|
|
40
40
|
version: '3'
|
41
41
|
description: 'Access to the clipboard on Linux, MacOS, Windows, and Cygwin: Clipboard.copy,
|
42
42
|
Clipboard.paste, Clipboard.clear'
|
43
|
-
email:
|
43
|
+
email:
|
44
|
+
- hi@ruby.consulting
|
44
45
|
executables: []
|
45
46
|
extensions: []
|
46
47
|
extra_rdoc_files: []
|
@@ -61,7 +62,7 @@ files:
|
|
61
62
|
- lib/clipboard/version.rb
|
62
63
|
- lib/clipboard/windows.rb
|
63
64
|
- lib/clipboard/wsl.rb
|
64
|
-
- spec/
|
65
|
+
- spec/clipboard_file_spec.rb
|
65
66
|
- spec/clipboard_spec.rb
|
66
67
|
- spec/spec_helper.rb
|
67
68
|
homepage: https://github.com/janlelis/clipboard
|
@@ -83,11 +84,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
83
84
|
- !ruby/object:Gem::Version
|
84
85
|
version: '0'
|
85
86
|
requirements:
|
86
|
-
- '
|
87
|
-
|
88
|
-
|
89
|
-
rubyforge_project:
|
90
|
-
rubygems_version: 2.7.7
|
87
|
+
- 'Linux: You need xclip or xsel. On debian/ubuntu run: sudo apt-get install xsel'
|
88
|
+
- 'Windows: You need the ffi gem'
|
89
|
+
rubygems_version: 3.1.2
|
91
90
|
signing_key:
|
92
91
|
specification_version: 4
|
93
92
|
summary: Access to the clipboard on Linux, MacOS, Windows, and Cygwin.
|
@@ -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
|