clipboard 1.3.0 → 1.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0db9702c7b8ca48e95e26e612cf294b78d4eb188a4e74a72a002fb064e6c61e3
4
- data.tar.gz: 6abd7baac11e392fa41997d771504c6b104350f8049693735f233dee6bba8915
3
+ metadata.gz: 2e5ac85c5f3eefe7f038800d250f7aa0a0aa4f5cad84b288a5f61f7ee354476f
4
+ data.tar.gz: aec83891b78fa15dfa574ccd83736956033e25e763cb59d38aea592e12947ee5
5
5
  SHA512:
6
- metadata.gz: a4b5ff54912337f98f1918375e8839b6eae786b9aa464bfa1b1aacf4bff3e30967f9104fa520f8fe6f343e7273c5982db1c109705884f4426b23166f02a8ec37
7
- data.tar.gz: cbe9164425d0f9f1ab7f0efd270a8adcf9e65ba472a644afab3301e100e9fab9d27a400c0e8964200898edec99a2fa91259d877dc0219549778f35625d594295
6
+ metadata.gz: 5d686fcb2be31dfb73a94930f2dbd9cecd41256b62399677fc07c44a5dbb289f36e808e69fe0fe9763cf806960103b0ddeb34f7daafd8e9b3d28bf1725c4bc8a
7
+ data.tar.gz: 27e56c7766971c528033760410adb598cc81d949844d892bcd0a401df0d9154c88c06e79eb7b614529a8df9b204264d0292f0bd1925f66236d15c11bb0f40f16
@@ -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, xclip can be installed with: `sudo apt-get install xclip`
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
 
@@ -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
- "On Linux (or other X), you will need xclip. On debian/ubuntu this is: sudo apt-get install xclip",
16
- "On Windows, you will need the ffi gem.",
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
 
@@ -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?('xclip')
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 xclip"
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)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Clipboard
4
- VERSION = "1.3.0"
4
+ VERSION = "1.3.1"
5
5
  end
@@ -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
@@ -1,6 +1,6 @@
1
1
  # Please note: cannot test, if it really accesses your platform clipboard.
2
2
 
3
- require File.expand_path('spec/spec_helper')
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
- if RUBY_VERSION >= "1.9"
22
- it "can copy & paste with multibyte char" do
23
- Encoding.default_external = "utf-8"
24
- Clipboard.copy("日本語")
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
- describe 'Clipboard::File' do
54
- before :all do
55
- Clipboard.implementation = Clipboard::File
56
- cache = Clipboard::File::FILE
57
- FileUtils.rm cache if File.exist?(cache)
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
- it "can paste with empty file" do
61
- expect( Clipboard.paste ).to eq ''
62
- end
57
+ expect(data2).to eq data1
63
58
 
64
- it "can copy & paste" do
65
- expect( Clipboard.copy('xxx') ).to eq 'xxx'
66
- expect( Clipboard.paste ).to eq 'xxx'
67
- end
59
+ # second batch
60
+ data1 = Random.new.bytes(2**14).unpack("H*").first
61
+ data2 = Clipboard.copy(data1)
68
62
 
69
- it "can clear" do
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.0
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/clipboard_linux_spec.rb
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
- - 'On Linux (or other X), you will need xclip. On debian/ubuntu this is: sudo apt-get
87
- install xclip'
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