clippy 1.0.1 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -1,2 +1,2 @@
1
- source :rubygems
1
+ source "https://rubygems.org"
2
2
  gemspec
data/License CHANGED
@@ -1,18 +1,19 @@
1
- Copyright (c) 2011-2012 Jordon Bedwell
1
+ Copyright (c) 2011-2013 Jordon Bedwell
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining a copy of
4
- this software and associated documentation files (the "Software"), to deal in the
5
- Software without restriction, including without limitation the rights to use,
6
- copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
7
- Software, and to permit persons to whom the Software is furnished to do so,
8
- subject to the following conditions:
4
+ this software and associated documentation files (the "Software"), to deal in
5
+ the Software without restriction, including without limitation the rights to
6
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
7
+ of the Software, and to permit persons to whom the Software is furnished to do
8
+ so, subject to the following conditions:
9
9
 
10
10
  The above copyright notice and this permission notice shall be included in all
11
11
  copies or substantial portions of the Software.
12
12
 
13
13
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
14
  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
15
- FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
16
- COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
17
- AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
18
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
15
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
+ SOFTWARE.
data/Rakefile CHANGED
@@ -1,10 +1,5 @@
1
- require "rubygems/package_task"
2
- require "rake/testtask"
1
+ require "rspec/core/rake_task"
3
2
 
4
- task :default => [:test]
5
- task :spec => :test
6
-
7
- Rake::TestTask.new { |t| t.verbose, t.pattern = true, "tests/**/*.rb" }
8
- Gem::PackageTask.new(eval(IO.read("clippy.gemspec"))) do |pkg|
9
- pkg.need_tar, pkg.need_zip = true
10
- end
3
+ task :default => [:spec]
4
+ task :test => :spec
5
+ RSpec::Core::RakeTask.new :spec
data/Readme.md CHANGED
@@ -1,16 +1,15 @@
1
1
  Clippy is a cross-platform clipboard utility and script for Ruby.
2
2
 
3
- [![Code Climate](https://codeclimate.com/badge.png)](https://codeclimate.com/github/envygeeks/clippy)
3
+ [![Build Status](https://travis-ci.org/envygeeks/clippy.png?branch=master)](https://travis-ci.org/envygeeks/clippy) [![Coverage Status](https://coveralls.io/repos/envygeeks/clippy/badge.png?branch=master)](https://coveralls.io/r/envygeeks/clippy) [![Code Climate](https://codeclimate.com/github/envygeeks/clippy.png)](https://codeclimate.com/github/envygeeks/clippy) [![Dependency Status](https://gemnasium.com/envygeeks/clippy.png)](https://gemnasium.com/envygeeks/clippy)
4
4
 
5
5
  ---
6
6
  * Requirements:
7
- * Ruby1.9+ or JRuby in 1.9+
8
7
  * Any Linux distro with xsel or xclip.
8
+ * Ruby1.9+, Ruby2.0+ or JRuby in 1.9+
9
9
  * Any OS X version that supports pbcopy.
10
10
  * At least Windows Vista if you are on Windows.
11
- * Development:
12
- * Rake
13
- * Minitest
11
+
12
+ *Right now there is a bug with jRuby that causes Clippy to fail, this bug is inside of Open3.popen3 where jRuby actually short-circuits and does not meet the same guidelines as Ruby1.9+, you can see the progress of this bug at: http://jira.codehaus.org/browse/JRUBY-6409*
14
13
 
15
14
  ---
16
15
  Examples:
@@ -28,12 +27,11 @@ Clippy.copy('#1')
28
27
  Clippy.paste and Clippy.clear
29
28
  ```
30
29
 
31
- <pre>
32
- Clippy v1.0.1 by Envygeeks
33
- --no-encoding Encoding
34
- --paste Paste
35
- --help This
36
- --clear Clear
37
- --copy Copy
38
- --version Version
39
- </pre>
30
+ ```
31
+ Clippy v2.0.0: Clippy [--copy [< File] ['Text']]
32
+ --paste Paste
33
+ --help This
34
+ --clear Clear
35
+ --version Version
36
+ --copy Copy a String or STDIN
37
+ ```
data/bin/clippy CHANGED
@@ -4,32 +4,16 @@ $:.unshift(File.expand_path("../../lib", __FILE__))
4
4
  require "optparse"
5
5
  require "clippy"
6
6
 
7
- do_return = nil
8
- did_cmd = nil
9
7
  OptionParser.new do |opts|
10
- opts.banner = "Clippy v#{Clippy.version} by Envygeeks"
11
- opts.on("--no-encoding", "Encoding") { Clippy.encode = false }
12
- opts.on("--paste", "Paste") { do_return = Clippy.paste }
13
- opts.on("--help", "This") { do_return = opts }
14
- opts.on("--clear", "Clear") { did_cmd = Clippy.clear }
8
+ opts.banner = "Clippy v#{Clippy::VERSION}: Clippy [--copy [< File] ['Text']]"
15
9
 
16
- opts.on("--copy", "Copy") do
17
- if ARGV.count > 1
18
- raise RuntimeError, "More than one arg is not allowable.", "Clippy"
19
- end
10
+ opts.on("--paste", "Paste") { $stdout.puts Clippy.paste }
11
+ opts.on("--help", "This") { $stdout.puts opts }
12
+ opts.on("--clear", "Clear") { exit Clippy.clear ? 0 : 1 }
13
+ opts.on("--version", "Version") { $stdout.puts Clippy::VERSION }
20
14
 
21
- text = ARGF.readlines.join if ARGV.count == 0
22
- text = ARGV.first.dup if ARGV.count == 1
23
- did_cmd = Clippy.copy(text)
15
+ opts.on("--copy", "Copy a String or STDIN") do
16
+ ($stdout.puts "More than one arg is not allowable" and exit 1) if ARGV.count > 1
17
+ exit Clippy.copy(ARGV.count == 0 ? ARGF.readlines.join : ARGV.first.dup) ? 0 : 1
24
18
  end
25
-
26
- opts.on("--version", "version") { do_return = Clippy.version }
27
19
  end.parse!
28
-
29
- if do_return.nil? and did_cmd.nil?
30
- system("#{File.expand_path(__FILE__)} --help")
31
- else
32
- if do_return
33
- $stdout.puts do_return
34
- end
35
- end
@@ -1,221 +1,75 @@
1
+ require_relative "clippy/version"
1
2
  require "rbconfig"
3
+ require "open3"
2
4
 
3
- if RbConfig::CONFIG["host_os"] !~ /mswin|mingw32/
4
- require "open3"
5
- else
5
+ if RbConfig::CONFIG["host_os"] =~ /mswin|mingw32/
6
6
  require "Win32API"
7
- require "tempfile"
8
7
  end
9
8
 
10
- class Object
11
- ##
12
- # ---
13
- # Hood jacked from Rails.
14
- ##
15
-
16
- def blank?
17
- (respond_to?(:empty?)) ? (empty?) : (!self)
9
+ module Clippy module_function
10
+ class UnknownClipboardError < StandardError
11
+ def initialize
12
+ super "Unknown clipboard. Clippy requires xclip, xsel or pbcopy"
13
+ end
18
14
  end
19
- end
20
15
 
21
- class Clippy
22
- private_class_method :new
23
- @@encode = true
24
-
25
- [:UnsupportedOS, :UnknownClipboard, :InvalidEncoding].each do |status|
26
- const_set(status, Class.new(StandardError))
16
+ CommandArgs = {
17
+ "windows" => "",
18
+ "xsel"=> {
19
+ "stdin" => " -ib",
20
+ "stdout" => " -ob"
21
+ },
22
+ "pbcopy"=> {
23
+ "stdin"=> "",
24
+ "stdout"=> ""
25
+ },
26
+ "xclip"=> {
27
+ "stdin" => " -i -selection clipboard",
28
+ "stdout" => " -o -selection clipboard"
29
+ }
30
+ }
31
+
32
+ def windows?
33
+ RbConfig::CONFIG["host_os"] =~ /mswin|mingw32/
27
34
  end
28
35
 
29
- class << self
30
- VERSION = "1.0.1"
31
- def version
32
- VERSION
33
- end
34
-
35
- ##
36
- # ---
37
- # Doesn't work on Windows.
38
- ##
39
-
40
- def binary_exist?(bin = nil)
41
- if bin
42
- system("which #{bin} > /dev/null 2>&1")
43
- end
44
- end
45
-
46
- def encode=(value)
47
- if [TrueClass, FalseClass].include?(value.class)
48
- @@encode = value
49
- end
50
- end
51
-
52
- def copy(data)
53
- ##
54
- # ---
55
- # Always convert to a string and convert \n to \r\n because shit like
56
- # Pidgin, Empathy, aMSN and other fucking clients have no idea what the
57
- # hell \n is for, that or they just ignore it like jackasses, jackasses.
58
-
59
- data = data.to_s unless data.is_a?(String)
60
- data.gsub!(/\n/, "\r\n")
61
-
62
- if RbConfig::CONFIG["host_os"] =~ /mswin|mingw32/
63
- if system("clip /? > NUL")
64
- begin
65
- tmpfile = Tempfile.new("clippy")
66
- tmpfile.write(data)
67
- tmpfile.flush
68
- system("clip < #{tmpfile.path}")
69
- ensure
70
- tmpfile.close(true)
71
- end
72
- else
73
- raise(UnsupportedOS, "Your Windows version is too old.", "Clippy")
74
- end
75
- else
76
- status = 0
77
- case true
78
- ##
79
- # ---
80
- # xsel is a Linux utility.
81
- # apt-get install xsel.
82
-
83
- when binary_exist?("xsel")
84
- ["-p", "-b", "-s"].each do |opt|
85
- Open3.popen3("xsel -i #{opt}") do |stdin, _, _, thread|
86
- stdin << data
87
- stdin.close
88
- status = thread.value
89
- end
90
- end
91
-
92
- ##
93
- # ---
94
- # pbpaste is for Mac's though it could change.
95
- # I don't know if it has multiple-boards.
96
- ##
97
-
98
- when binary_exist?("pbcopy")
99
- Open3.popen3("pbcopy") do |stdin, _, _, thread|
100
- stdin << data
101
- stdin.close
102
- status = thread.value
103
- end
104
-
105
- ##
106
- # ---
107
- # xclip is a Linux utitily.
108
- # apt-get install xclip.
109
- ##
110
-
111
- when binary_exist?("xclip")
112
- ["primary", "secondary", "clipboard"].each do |opt|
113
- Open3.popen3("xclip -i -selection #{opt}") do
114
- |stdin, _, _, thread|
115
- stdin << data
116
- stdin.close
117
- status = thread.value
118
- end
119
- end
120
- else
121
- raise(UnknownClipboard, "Clippy requires xsel, xclip or pbcopy.")
122
- end
123
- end
36
+ def copy(data)
37
+ run_command("stdin", $/ != "\r\n" ? data.to_s.gsub($/, "\r\n") : data)[0] == 0 ? true : false
38
+ end
124
39
 
125
- (status != 0) ? (false) : (data)
40
+ def paste
41
+ if windows?
42
+ Win32API.new("user32", "OpenClipboard", "L", "I").call(0)
43
+ data = Win32API.new("user32", "GetClipboardData", "I", "P").call(1) || ""
44
+ Win32API.new("user32", "CloseClipboard", [], "I").call
45
+ else
46
+ cmd = run_command("stdout")
47
+ cmd[0] == 0 ? ((cmd[1].nil? || cmd[1].empty?) ? nil : cmd[1]) : false
126
48
  end
49
+ end
127
50
 
128
- def paste(encoding = nil, which = nil)
129
- which = "clipboard" if encoding.blank? && which.blank?
130
- if ["clipboard", "primary", "secondary"].include?(encoding)
131
- which, encoding = encoding, nil
132
- else
133
- if encoding && @@encode && defined?(Encoding)
134
- unless Encoding.list.map(&:to_s).include?(encoding)
135
- raise InvalidEncoding, "Unsupported encoding selected", "Clippy"
136
- end
137
- end
138
- end
51
+ def clear
52
+ (copy("").nil?) ? true : false
53
+ end
139
54
 
140
- if RbConfig::CONFIG["host_os"] =~ /mswin|mingw32/
141
- Win32API.new("user32", "OpenClipboard", "L", "I").call(0)
142
- data = Win32API.new("user32", "GetClipboardData", "I", "P").call(1) || ""
143
- Win32API.new("user32", "CloseClipboard", [], "I").call
55
+ def binary
56
+ @binary ||= if windows?
57
+ "clip"
58
+ else
59
+ case true
60
+ when system("which xclip > /dev/null 2>&1") then "xclip"
61
+ when system("which xsel > /dev/null 2>&1") then "xsel"
62
+ when system("which pbcopy > /dev/null 2>&1") then "pbcopy"
144
63
  else
145
- case true
146
- ##
147
- # ---
148
- # xsel is a Linux utility.
149
- # apt-get install xsel.
150
-
151
- when binary_exist?("xsel")
152
- cmd, data = "xsel -o", ""
153
-
154
- case which
155
- when "clipboard" then cmd+= " -b"
156
- when "primary" then cmd+= " -p"
157
- when "secondary" then cmd+= " -s"
158
- end
159
-
160
- Open3.popen3(cmd) { |_, stdout, _|
161
- data = stdout.read }
162
-
163
- ##
164
- # ---
165
- # pbpaste is for Mac's though it could change.
166
- # I don't know if it has multiple-boards.
167
- ##
168
-
169
- when binary_exist?("pbpaste")
170
- data = ""
171
-
172
- Open3.popen3("pbpaste") { |_, stdout, _|
173
- data = stdout.read || "" }
174
-
175
- ##
176
- # ---
177
- # xclip is a Linux utitily.
178
- # apt-get install xclip.
179
- ##
180
-
181
- when binary_exist?("xclip")
182
- cmd, data = "xclip -o -selection", ""
183
-
184
- case which
185
- when "clipboard" then cmd+= " clipboard"
186
- when "primary" then cmd+= " primary"
187
- when "secondary" then cmd+= " secondary"
188
- end
189
-
190
- Open3.popen3(cmd) do |_, stdout, _|
191
- data = stdout.read || ""
192
- end
193
- else
194
- raise RuntimeError, "Unable to find a supported clipboard", "Clippy"
195
- end
64
+ raise UnknownClipboardError
196
65
  end
197
-
198
- if @@encode && defined?(Encoding) && encoding
199
- if data.encoding.name != Encoding.default_external
200
- data.encode(encoding)
201
- end
202
- end
203
-
204
- (data.blank?) ? (nil) : (data)
205
66
  end
67
+ end
206
68
 
207
- def clear
208
- if RbConfig::CONFIG["host_os"] =~ /mswin|mingw32/
209
- Win32API.new("user32", "OpenClipboard", "L", "I").call(0)
210
- Win32API.new("user32", "EmptyClipboard", [], "I").call
211
- Win32API.new("user32", "CloseClipboard", [], "I").call
212
- else
213
- if copy("")
214
- return true
215
- end
216
- end
217
-
218
- false
219
- end
69
+ def run_command(type, data = "")
70
+ stdin, stdout, stderr, pid = Open3.popen3(binary + CommandArgs[binary][type])
71
+ type == "stdin" ? stdin.puts(data) : out = stdout.read.strip
72
+ [stdin, stdout, stderr].each { |m| m.close }
73
+ [pid.value, type == "stdin" ? data : out]
220
74
  end
221
75
  end
@@ -0,0 +1,3 @@
1
+ module Clippy
2
+ VERSION = "2.0.0"
3
+ end
metadata CHANGED
@@ -1,104 +1,164 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: clippy
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
5
- prerelease:
4
+ version: 2.0.0
5
+ prerelease:
6
6
  platform: ruby
7
7
  authors:
8
8
  - Jordon Bedwell
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-12-10 00:00:00.000000000 Z
12
+ date: 2013-05-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
- name: pry
16
- requirement: !ruby/object:Gem::Requirement
15
+ name: coveralls
16
+ version_requirements: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - ">="
19
+ - !ruby/object:Gem::Version
20
+ version: !binary |-
21
+ MA==
17
22
  none: false
23
+ requirement: !ruby/object:Gem::Requirement
18
24
  requirements:
19
- - - ! '>='
25
+ - - ">="
20
26
  - !ruby/object:Gem::Version
21
- version: '0'
22
- type: :development
27
+ version: !binary |-
28
+ MA==
29
+ none: false
23
30
  prerelease: false
31
+ type: :development
32
+ - !ruby/object:Gem::Dependency
33
+ name: popen4
24
34
  version_requirements: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - ">="
37
+ - !ruby/object:Gem::Version
38
+ version: !binary |-
39
+ MA==
25
40
  none: false
41
+ requirement: !ruby/object:Gem::Requirement
26
42
  requirements:
27
- - - ! '>='
43
+ - - ">="
28
44
  - !ruby/object:Gem::Version
29
- version: '0'
45
+ version: !binary |-
46
+ MA==
47
+ none: false
48
+ prerelease: false
49
+ type: :runtime
30
50
  - !ruby/object:Gem::Dependency
31
51
  name: rake
32
- requirement: !ruby/object:Gem::Requirement
52
+ version_requirements: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: !binary |-
57
+ MA==
33
58
  none: false
59
+ requirement: !ruby/object:Gem::Requirement
34
60
  requirements:
35
- - - ! '>='
61
+ - - ">="
36
62
  - !ruby/object:Gem::Version
37
- version: '0'
38
- type: :development
63
+ version: !binary |-
64
+ MA==
65
+ none: false
39
66
  prerelease: false
67
+ type: :development
68
+ - !ruby/object:Gem::Dependency
69
+ name: simplecov
40
70
  version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: !binary |-
75
+ MA==
41
76
  none: false
77
+ requirement: !ruby/object:Gem::Requirement
42
78
  requirements:
43
- - - ! '>='
79
+ - - ">="
44
80
  - !ruby/object:Gem::Version
45
- version: '0'
81
+ version: !binary |-
82
+ MA==
83
+ none: false
84
+ prerelease: false
85
+ type: :development
46
86
  - !ruby/object:Gem::Dependency
47
- name: minitest
48
- requirement: !ruby/object:Gem::Requirement
87
+ name: guard-rspec
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ requirements:
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ version: !binary |-
93
+ MA==
49
94
  none: false
95
+ requirement: !ruby/object:Gem::Requirement
50
96
  requirements:
51
- - - ! '>='
97
+ - - ">="
52
98
  - !ruby/object:Gem::Version
53
- version: '0'
54
- type: :development
99
+ version: !binary |-
100
+ MA==
101
+ none: false
55
102
  prerelease: false
103
+ type: :development
104
+ - !ruby/object:Gem::Dependency
105
+ name: luna-rspec-formatters
56
106
  version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: !binary |-
111
+ MA==
57
112
  none: false
113
+ requirement: !ruby/object:Gem::Requirement
58
114
  requirements:
59
- - - ! '>='
115
+ - - ">="
60
116
  - !ruby/object:Gem::Version
61
- version: '0'
117
+ version: !binary |-
118
+ MA==
119
+ none: false
120
+ prerelease: false
121
+ type: :development
62
122
  description: A utility to access the systems clipboard.
63
123
  email:
64
- - jordon@envygeeks.com
124
+ - envygeeks@gmail.com
65
125
  executables:
66
126
  - clippy
67
127
  extensions: []
68
128
  extra_rdoc_files: []
69
129
  files:
70
- - clippy.gemspec
71
- - lib/clippy.rb
72
- - Gemfile.lock
73
- - Rakefile
74
- - tests/clippy.rb
75
130
  - Readme.md
76
- - Gemfile
77
131
  - License
132
+ - Rakefile
133
+ - Gemfile
134
+ - lib/clippy.rb
135
+ - lib/clippy/version.rb
78
136
  - bin/clippy
79
137
  homepage: https://github.com/envygeeks/clippy
80
138
  licenses:
81
139
  - MIT
82
- post_install_message:
140
+ post_install_message:
83
141
  rdoc_options: []
84
142
  require_paths:
85
143
  - lib
86
144
  required_ruby_version: !ruby/object:Gem::Requirement
87
- none: false
88
145
  requirements:
89
- - - ! '>='
146
+ - - ">="
90
147
  - !ruby/object:Gem::Version
91
- version: '0'
92
- required_rubygems_version: !ruby/object:Gem::Requirement
148
+ version: !binary |-
149
+ MA==
93
150
  none: false
151
+ required_rubygems_version: !ruby/object:Gem::Requirement
94
152
  requirements:
95
- - - ! '>='
153
+ - - ">="
96
154
  - !ruby/object:Gem::Version
97
- version: '0'
155
+ version: !binary |-
156
+ MA==
157
+ none: false
98
158
  requirements: []
99
- rubyforge_project:
159
+ rubyforge_project:
100
160
  rubygems_version: 1.8.24
101
- signing_key:
161
+ signing_key:
102
162
  specification_version: 3
103
163
  summary: A utility to access the systems clipboard.
104
164
  test_files: []
@@ -1,26 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- clippy (1.0.1)
5
-
6
- GEM
7
- remote: http://rubygems.org/
8
- specs:
9
- coderay (1.0.8)
10
- method_source (0.8.1)
11
- minitest (3.3.0)
12
- pry (0.9.10)
13
- coderay (~> 1.0.5)
14
- method_source (~> 0.8)
15
- slop (~> 3.3.1)
16
- rake (0.9.2.2)
17
- slop (3.3.3)
18
-
19
- PLATFORMS
20
- ruby
21
-
22
- DEPENDENCIES
23
- clippy!
24
- minitest
25
- pry
26
- rake
@@ -1,24 +0,0 @@
1
- $:.unshift(File.expand_path("../lib", __FILE__))
2
- require "clippy"
3
-
4
- Gem::Specification.new do |spec|
5
- spec.version = Clippy.version
6
- spec.license = "MIT"
7
- spec.name = "clippy"
8
- spec.has_rdoc = false
9
- spec.files = Dir["**/*"]
10
- spec.require_paths = ["lib"]
11
- spec.executables = ["clippy"]
12
- spec.authors = ["Jordon Bedwell"]
13
- spec.email = ["jordon@envygeeks.com"]
14
- spec.add_development_dependency("pry")
15
- spec.add_development_dependency("rake")
16
- spec.add_development_dependency("minitest")
17
- spec.homepage = "https://github.com/envygeeks/clippy"
18
- spec.summary = "A utility to access the systems clipboard."
19
- spec.description = "A utility to access the systems clipboard."
20
-
21
- if RUBY_PLATFORM =~ /mswin/
22
- spec.required_ruby_version = '>= 1.9.1'
23
- end
24
- end
@@ -1,60 +0,0 @@
1
- $:.unshift(File.expand_path("../../lib", __FILE__))
2
- require "minitest/autorun"
3
- require "minitest/pride"
4
- require "minitest/spec"
5
- require "clippy"
6
-
7
- describe Clippy do subject { Clippy }
8
- it "must have a proper version" do
9
- Clippy.version.split(".").delete_if { |val|
10
- val =~ /pre\d+/ }.length.must_equal(3)
11
- end
12
-
13
- describe ".copy" do
14
- it "must be able to copy" do
15
- subject.clear.must_equal(true)
16
- subject.copy("example").must_equal("example")
17
- end
18
-
19
- it "it must copy from the binary" do
20
- subject.clear.must_equal(true)
21
- data, status = "example", 1
22
- Open3.popen3(File.expand_path("../../bin/clippy --copy", __FILE__)) do
23
- |stdin, _, _, thread|
24
- stdin << data
25
- stdin.close
26
- status = thread.value
27
- end
28
-
29
- status.must_equal(0)
30
- subject.paste.must_equal("example")
31
- end
32
- end
33
-
34
- describe ".paste" do
35
- it "must be able to paste" do
36
- subject.clear.must_equal(true)
37
- subject.copy("example")
38
- subject.paste.must_equal("example")
39
- end
40
-
41
- it "must be able to paste from the binary" do
42
- subject.clear.must_equal(true)
43
- data, status = "", 1
44
- subject.copy("example").must_equal("example")
45
- Open3.popen3(File.expand_path("../../bin/clippy --paste", __FILE__)) {
46
- |_, stdout, _, thread|
47
- data = stdout.read; status = thread.value }
48
-
49
- status.must_equal(0)
50
- data.strip.must_equal("example")
51
- end
52
- end
53
-
54
- describe ".clear" do
55
- it "should be able to clear the clipboard" do
56
- subject.copy("example")
57
- subject.clear.must_equal(true)
58
- end
59
- end
60
- end