clipboard 1.1.0 → 1.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: daabcc7f7c52f9aeff9e0163f00c3ecbdfc494d8
4
- data.tar.gz: 8b3a8aeb00f65797735f604a7c5ba5472e14e0d4
3
+ metadata.gz: c91049aa4bbdb688bc936ab74e419a79168565c5
4
+ data.tar.gz: 4556c855410c5585d338d9a75bb68e2370beb0b5
5
5
  SHA512:
6
- metadata.gz: 9c65bda01e0b1917fa33cf88e87bc47a8f4be01934cb6a506d9da694c674fd9110c9e059dd3c7a1605ef3e609f96cfdede4414b95186ec84578a9fa285035d03
7
- data.tar.gz: 9b57863507792943da2402fb711f0756b588d70dcf2eb24e32cd79ce52a13b5697ffd8232e84b9c137a1eb70c37320fff202bef281473718e288e9668ceb1c49
6
+ metadata.gz: 06c1548b9cf38578c899021de84979e85147db85b7bc4909cfcf96dc53b7457368fce3fce9f1cae992c64e21ab60832d5210894a1ee266e73e00105c2187805d
7
+ data.tar.gz: 9479f050e48e56f3d3f9c0c0028e7b409b5f5359d37d9249aa16b0accef35368912ce25976ea0d53cd75beeb253cb1fb7eb9a8d0d828965517c7a9090ced1fe9
@@ -1,5 +1,10 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 1.1.1
4
+
5
+ * Surpress 3rd party processes' STDERR, see #26
6
+ * Internal API changes to meet modified relaxed ruby style guidelines
7
+
3
8
  ## 1.1.0
4
9
  * Remove support for 1.8
5
10
  * Windows: Fix that the gem tries to convert encoding of pasted strings, leave this to user
@@ -1,5 +1,4 @@
1
1
  # -*- encoding: utf-8 -*-
2
- require 'rubygems' unless defined? Gem
3
2
 
4
3
  $:.unshift File.expand_path("../lib", __FILE__)
5
4
  require 'clipboard/version'
@@ -21,6 +20,6 @@ Gem::Specification.new do |s|
21
20
  s.files = Dir.glob(%w[{lib,spec}/**/*.rb [A-Z]*.txt [A-Z]*.md]) + %w{clipboard.gemspec}
22
21
 
23
22
  s.required_ruby_version = '>= 1.9.3'
24
- s.add_development_dependency 'rake'
25
- s.add_development_dependency 'rspec', '>=2'
23
+ s.add_development_dependency 'rake', '~> 11'
24
+ s.add_development_dependency 'rspec', '~> 3'
26
25
  end
@@ -17,7 +17,7 @@ module Clipboard
17
17
  autoload :File, 'clipboard/file'
18
18
 
19
19
  def self.implementation
20
- return @implementation if @implementation
20
+ return @implementation if @implementation
21
21
 
22
22
  os = case RbConfig::CONFIG['host_os']
23
23
  when /mac|darwin/ then :Mac
@@ -1,18 +1,18 @@
1
- module Clipboard; end
1
+ module Clipboard
2
+ module Cygwin
3
+ extend self
2
4
 
3
- module Clipboard::Cygwin
4
- extend self
5
+ def paste(_ = nil)
6
+ File.read("/dev/clipboard")
7
+ end
5
8
 
6
- def paste(_ = nil)
7
- File.read("/dev/clipboard")
8
- end
9
-
10
- def copy(data)
11
- File.open("/dev/clipboard", "w"){ |f| f.write(data) }
12
- paste
13
- end
9
+ def copy(data)
10
+ File.open("/dev/clipboard", "w"){ |f| f.write(data) }
11
+ paste
12
+ end
14
13
 
15
- def clear
16
- copy ''
14
+ def clear
15
+ copy ''
16
+ end
17
17
  end
18
18
  end
@@ -1,20 +1,20 @@
1
- module Clipboard; end
1
+ module Clipboard
2
+ module File
3
+ extend self
2
4
 
3
- module Clipboard::File
4
- extend self
5
+ FILE = ::File.expand_path("~/.clipboard")
5
6
 
6
- FILE = File.expand_path("~/.clipboard")
7
+ def copy(text)
8
+ ::File.open(FILE, 'w', 0o0600) { |f| f.write(text) } rescue ''
9
+ paste
10
+ end
7
11
 
8
- def copy(text)
9
- File.open(FILE, 'w', 0600) { |f| f.write(text) } rescue ''
10
- paste
11
- end
12
-
13
- def paste(_ = nil)
14
- File.read(FILE) rescue ''
15
- end
12
+ def paste(_ = nil)
13
+ ::File.read(FILE) rescue ''
14
+ end
16
15
 
17
- def clear
18
- copy ''
16
+ def clear
17
+ copy ''
18
+ end
19
19
  end
20
20
  end
@@ -1,24 +1,24 @@
1
- module Clipboard; end
1
+ module Clipboard
2
+ # Basic java clipboard access (jruby). No fun to use on X.
3
+ module Java
4
+ extend self
2
5
 
3
- # Basic java clipboard access (jruby). No fun to use on X.
4
- module Clipboard::Java
5
- extend self
6
+ FLAVOR = ::Java::JavaAwtDatatransfer::DataFlavor.stringFlavor
6
7
 
7
- FLAVOR = ::Java::JavaAwtDatatransfer::DataFlavor.stringFlavor
8
+ def copy(text)
9
+ selection_string = ::Java::JavaAwtDatatransfer::StringSelection.new text
10
+ ::Java::JavaAwt::Toolkit.default_toolkit.system_clipboard.set_contents selection_string, nil
11
+ paste
12
+ end
8
13
 
9
- def copy(text)
10
- selection_string = ::Java::JavaAwtDatatransfer::StringSelection.new text
11
- ::Java::JavaAwt::Toolkit.default_toolkit.system_clipboard.set_contents selection_string, nil
12
- paste
13
- end
14
-
15
- def paste(_ = nil)
16
- ::Java::JavaAwt::Toolkit.default_toolkit.system_clipboard.get_data(FLAVOR)
17
- rescue
18
- ''
19
- end
14
+ def paste(_ = nil)
15
+ ::Java::JavaAwt::Toolkit.default_toolkit.system_clipboard.get_data(FLAVOR)
16
+ rescue
17
+ ''
18
+ end
20
19
 
21
- def clear
22
- copy ''
20
+ def clear
21
+ copy ''
22
+ end
23
23
  end
24
24
  end
@@ -1,41 +1,41 @@
1
1
  require 'open3'
2
2
 
3
- module Clipboard; end
3
+ module Clipboard
4
+ module Linux
5
+ extend self
4
6
 
5
- module Clipboard::Linux
6
- extend self
7
+ CLIPBOARDS = %w[clipboard primary secondary].freeze
7
8
 
8
- CLIPBOARDS = %w[clipboard primary secondary]
9
-
10
- # check which backend to use
11
- if system('which xclip >/dev/null 2>&1')
12
- WriteCommand = 'xclip'
13
- ReadCommand = 'xclip -o'
14
- Selection = proc{|x| "-selection #{x}"}
15
- elsif system('which xsel >/dev/null 2>&1')
16
- WriteCommand = 'xsel -i'
17
- ReadCommand = 'xsel -o'
18
- Selection = {'clipboard' => '-b', 'primary' => '-p', 'secondary' => '-s'}
19
- else
20
- raise Clipboard::ClipboardLoadError, "clipboard: Could not find required program xclip or xsel\n" \
21
- "On debian/ubuntu, you can install it with: sudo apt-get install xclip"
22
- end
9
+ # check which backend to use
10
+ if system('which xclip >/dev/null 2>&1')
11
+ WriteCommand = 'xclip'.freeze
12
+ ReadCommand = 'xclip -o'.freeze
13
+ Selection = proc{ |x| "-selection #{x}" }.freeze
14
+ elsif system('which xsel >/dev/null 2>&1')
15
+ WriteCommand = 'xsel -i'.freeze
16
+ ReadCommand = 'xsel -o'.freeze
17
+ Selection = { 'clipboard' => '-b', 'primary' => '-p', 'secondary' => '-s' }.freeze
18
+ else
19
+ raise Clipboard::ClipboardLoadError, "clipboard: Could not find required program xclip or xsel\n" \
20
+ "On debian/ubuntu, you can install it with: sudo apt-get install xclip"
21
+ end
23
22
 
24
- def paste(which = nil)
25
- if !which || !CLIPBOARDS.include?(which.to_s.downcase)
26
- which = CLIPBOARDS.first
23
+ def paste(which = nil)
24
+ if !which || !CLIPBOARDS.include?(which.to_s.downcase)
25
+ which = CLIPBOARDS.first
26
+ end
27
+ `#{ReadCommand} #{Selection[which.to_s.downcase]} 2> /dev/null`
27
28
  end
28
- `#{ReadCommand} #{Selection[which.to_s.downcase]}`
29
- end
30
29
 
31
- def clear
32
- copy ''
33
- end
30
+ def clear
31
+ copy ''
32
+ end
34
33
 
35
- def copy(data)
36
- CLIPBOARDS.each{ |which|
37
- Open3.popen3( "#{WriteCommand} #{Selection[which.to_s.downcase]}" ){ |input,_,_| input << data }
38
- }
39
- paste
34
+ def copy(data)
35
+ CLIPBOARDS.each{ |which|
36
+ Open3.popen3( "#{WriteCommand} #{Selection[which.to_s.downcase]}" ){ |input, _, _| input << data }
37
+ }
38
+ paste
39
+ end
40
40
  end
41
41
  end
@@ -1,20 +1,20 @@
1
1
  require 'open3'
2
2
 
3
- module Clipboard; end
3
+ module Clipboard
4
+ module Mac
5
+ extend self
4
6
 
5
- module Clipboard::Mac
6
- extend self
7
+ def paste(_ = nil)
8
+ `pbpaste`
9
+ end
7
10
 
8
- def paste(_ = nil)
9
- `pbpaste`
10
- end
11
-
12
- def copy(data)
13
- Open3.popen3( 'pbcopy' ){ |input,_,_| input << data }
14
- paste
15
- end
11
+ def copy(data)
12
+ Open3.popen3( 'pbcopy' ){ |input, _, _| input << data }
13
+ paste
14
+ end
16
15
 
17
- def clear
18
- copy ''
16
+ def clear
17
+ copy ''
18
+ end
19
19
  end
20
20
  end
@@ -1,3 +1,3 @@
1
1
  module Clipboard
2
- VERSION = "1.1.0"
2
+ VERSION = "1.1.1".freeze
3
3
  end
@@ -1,84 +1,84 @@
1
1
  require 'open3'
2
2
 
3
- module Clipboard; end
3
+ module Clipboard
4
+ module Windows
5
+ extend self
4
6
 
5
- module Clipboard::Windows
6
- extend self
7
+ CF_TEXT = 1
8
+ CF_UNICODETEXT = 13
9
+ GMEM_MOVEABLE = 2
7
10
 
8
- CF_TEXT = 1
9
- CF_UNICODETEXT = 13
10
- GMEM_MOVEABLE = 2
11
-
12
- # get ffi function handlers
13
- begin
14
- require 'ffi'
15
- rescue LoadError
16
- raise LoadError, 'Could not load the required ffi gem, install it with: gem install ffi'
17
- end
11
+ # get ffi function handlers
12
+ begin
13
+ require 'ffi'
14
+ rescue LoadError
15
+ raise LoadError, 'Could not load the required ffi gem, install it with: gem install ffi'
16
+ end
18
17
 
19
- module User32
20
- extend FFI::Library
21
- ffi_lib "user32"
22
- ffi_convention :stdcall
18
+ module User32
19
+ extend FFI::Library
20
+ ffi_lib "user32"
21
+ ffi_convention :stdcall
23
22
 
24
- attach_function :open, :OpenClipboard, [ :long ], :long
25
- attach_function :close, :CloseClipboard, [ ], :long
26
- attach_function :empty, :EmptyClipboard, [ ], :long
27
- attach_function :get, :GetClipboardData, [ :long ], :long
28
- attach_function :set, :SetClipboardData, [ :long, :long ], :long
29
- end
23
+ attach_function :open, :OpenClipboard, [ :long ], :long
24
+ attach_function :close, :CloseClipboard, [ ], :long
25
+ attach_function :empty, :EmptyClipboard, [ ], :long
26
+ attach_function :get, :GetClipboardData, [ :long ], :long
27
+ attach_function :set, :SetClipboardData, [ :long, :long ], :long
28
+ end
30
29
 
31
- module Kernel32
32
- extend FFI::Library
33
- ffi_lib 'kernel32'
34
- ffi_convention :stdcall
30
+ module Kernel32
31
+ extend FFI::Library
32
+ ffi_lib 'kernel32'
33
+ ffi_convention :stdcall
35
34
 
36
- attach_function :lock, :GlobalLock, [ :long ], :pointer
37
- attach_function :unlock, :GlobalUnlock, [ :long ], :long
38
- attach_function :size, :GlobalSize, [ :long ], :long
39
- attach_function :alloc, :GlobalAlloc, [ :long, :long ], :long
40
- end
35
+ attach_function :lock, :GlobalLock, [ :long ], :pointer
36
+ attach_function :unlock, :GlobalUnlock, [ :long ], :long
37
+ attach_function :size, :GlobalSize, [ :long ], :long
38
+ attach_function :alloc, :GlobalAlloc, [ :long, :long ], :long
39
+ end
41
40
 
42
- # see http://www.codeproject.com/KB/clipboard/archerclipboard1.aspx
43
- def paste(_ = nil)
44
- data = ""
45
- if 0 != User32.open( 0 )
46
- hclip = User32.get( CF_UNICODETEXT )
47
- if hclip && 0 != hclip
48
- pointer_to_data = Kernel32.lock( hclip )
49
- # Windows Unicode is ended by two null bytes, so get the whole string
50
- size = Kernel32.size( hclip )
51
- data << pointer_to_data.get_bytes( 0, size - 2 )
52
- data.force_encoding("UTF-16LE")
53
- Kernel32.unlock( hclip )
41
+ # see http://www.codeproject.com/KB/clipboard/archerclipboard1.aspx
42
+ def paste(_ = nil)
43
+ data = ""
44
+ if 0 != User32.open( 0 )
45
+ hclip = User32.get( CF_UNICODETEXT )
46
+ if hclip && 0 != hclip
47
+ pointer_to_data = Kernel32.lock( hclip )
48
+ # Windows Unicode is ended by two null bytes, so get the whole string
49
+ size = Kernel32.size( hclip )
50
+ data << pointer_to_data.get_bytes( 0, size - 2 )
51
+ data.force_encoding("UTF-16LE")
52
+ Kernel32.unlock( hclip )
53
+ end
54
+ User32.close( )
54
55
  end
55
- User32.close( )
56
+ data
56
57
  end
57
- data
58
- end
59
58
 
60
- def clear
61
- if 0 != User32.open( 0 )
62
- User32.empty( )
63
- User32.close( )
59
+ def clear
60
+ if 0 != User32.open( 0 )
61
+ User32.empty( )
62
+ User32.close( )
63
+ end
64
+ paste
64
65
  end
65
- paste
66
- end
67
66
 
68
- def copy(data_to_copy)
69
- if 0 != User32.open( 0 )
70
- User32.empty( )
71
- data = data_to_copy.encode("UTF-16LE") # TODO catch bad encodings
72
- data << 0
73
- handler = Kernel32.alloc( GMEM_MOVEABLE, data.bytesize )
74
- pointer_to_data = Kernel32.lock( handler )
75
- pointer_to_data.put_bytes( 0, data, 0, data.bytesize )
76
- Kernel32.unlock( handler )
77
- User32.set( CF_UNICODETEXT, handler )
78
- User32.close( )
79
- else # don't touch anything
80
- Open3.popen3( 'clip' ){ |input,_,_| input << data_to_copy } # depends on clip (available by default since Vista)
67
+ def copy(data_to_copy)
68
+ if 0 != User32.open( 0 )
69
+ User32.empty( )
70
+ data = data_to_copy.encode("UTF-16LE") # TODO: catch bad encodings
71
+ data << 0
72
+ handler = Kernel32.alloc( GMEM_MOVEABLE, data.bytesize )
73
+ pointer_to_data = Kernel32.lock( handler )
74
+ pointer_to_data.put_bytes( 0, data, 0, data.bytesize )
75
+ Kernel32.unlock( handler )
76
+ User32.set( CF_UNICODETEXT, handler )
77
+ User32.close( )
78
+ else # don't touch anything
79
+ Open3.popen3( 'clip' ){ |input, _, _| input << data_to_copy } # depends on clip (available by default since Vista)
80
+ end
81
+ paste
81
82
  end
82
- paste
83
83
  end
84
84
  end
@@ -3,12 +3,11 @@
3
3
 
4
4
  require File.expand_path('spec/spec_helper')
5
5
 
6
- $os = RbConfig::CONFIG['host_os']
7
-
6
+ os_to_restore = RbConfig::CONFIG['host_os']
8
7
 
9
8
  describe Clipboard do
10
9
  before do
11
- RbConfig::CONFIG['host_os'] = $os
10
+ RbConfig::CONFIG['host_os'] = os_to_restore
12
11
  end
13
12
 
14
13
  it "has a VERSION" do
metadata CHANGED
@@ -1,43 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: clipboard
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jan Lelis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-14 00:00:00.000000000 Z
11
+ date: 2016-07-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: '11'
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: '0'
26
+ version: '11'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rspec
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '2'
33
+ version: '3'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ">="
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '2'
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
43
  email: mail@janlelis.de
@@ -83,7 +83,7 @@ requirements:
83
83
  install xclip'
84
84
  - On Windows, you will need the ffi gem.
85
85
  rubyforge_project:
86
- rubygems_version: 2.5.1
86
+ rubygems_version: 2.4.8
87
87
  signing_key:
88
88
  specification_version: 4
89
89
  summary: Access to the clipboard on Linux, MacOS, Windows, and Cygwin.