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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0db9702c7b8ca48e95e26e612cf294b78d4eb188a4e74a72a002fb064e6c61e3
4
- data.tar.gz: 6abd7baac11e392fa41997d771504c6b104350f8049693735f233dee6bba8915
3
+ metadata.gz: 892729b3fc00a3f989dfa1c3c5e1c05062b94a2f01af23a358d519a09b737f33
4
+ data.tar.gz: 38f17ac7f06b2ff302b9498c3a3ad81bc2e7c9418f700f485569d8b8f15a18c9
5
5
  SHA512:
6
- metadata.gz: a4b5ff54912337f98f1918375e8839b6eae786b9aa464bfa1b1aacf4bff3e30967f9104fa520f8fe6f343e7273c5982db1c109705884f4426b23166f02a8ec37
7
- data.tar.gz: cbe9164425d0f9f1ab7f0efd270a8adcf9e65ba472a644afab3301e100e9fab9d27a400c0e8964200898edec99a2fa91259d877dc0219549778f35625d594295
6
+ metadata.gz: 5920c4e55b0322ac05a0df5c36e7d3c2dca41a31a481aab7ed3df6f838a10c0d4592910617c4e95b5878d5133d1b628b46cecef236118abecab608dc64b31827
7
+ data.tar.gz: 4ff5e2aba0b87384d16941ed3b85ba61382c7e28bc3a07e922328e3a9faf8a23f0524b797d8a729fd34cbb11720d6271890b6d772597444793dc66dd9443ad27
@@ -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
@@ -1,4 +1,4 @@
1
- Copyright (c) 2010-2018 Jan Lelis
1
+ Copyright (c) 2010-2020 Jan Lelis
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
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 'clipboard'
25
- gem 'ffi', :platforms => [:mswin, :mingw]
28
+ gem "clipboard"
29
+ gem "ffi", :platforms => [:mswin, :mingw] # Required by Clipboard on Windows
26
30
  ```
27
31
 
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`
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-2018 Jan Lelis <http://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)
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)
@@ -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 = 'clipboard'
6
- s.version = Clipboard::VERSION
7
-
8
- s.authors = ["Jan Lelis"]
9
- s.summary = "Access to the clipboard on Linux, MacOS, Windows, and Cygwin."
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 = "MIT"
14
+ s.license = "MIT"
14
15
  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.",
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', '~> 11'
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'
@@ -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
@@ -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
 
@@ -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.5"
5
5
  end
@@ -42,7 +42,7 @@ module Clipboard
42
42
 
43
43
  # see http://www.codeproject.com/KB/clipboard/archerclipboard1.aspx
44
44
  def paste(_ = nil)
45
- data = ""
45
+ data = "".dup
46
46
  if 0 != User32.open( 0 )
47
47
  hclip = User32.get( CF_UNICODETEXT )
48
48
  if hclip && 0 != hclip
@@ -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
@@ -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
- require File.expand_path('spec/spec_helper')
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
- 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
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
- 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
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
- it "can paste with empty file" do
61
- expect( Clipboard.paste ).to eq ''
62
- end
59
+ expect(data2).to eq data1
63
60
 
64
- it "can copy & paste" do
65
- expect( Clipboard.copy('xxx') ).to eq 'xxx'
66
- expect( Clipboard.paste ).to eq 'xxx'
67
- end
61
+ # second batch
62
+ data1 = Random.new.bytes(2**14).unpack("H*").first
63
+ data2 = Clipboard.copy(data1)
68
64
 
69
- it "can clear" do
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
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  $LOAD_PATH.unshift 'lib'
2
4
  require 'clipboard'
3
5
  require 'clipboard/file'
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.0
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: 2018-12-11 00:00:00.000000000 Z
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: '11'
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: '11'
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: mail@janlelis.de
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/clipboard_linux_spec.rb
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
- - '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.
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