copier 1.0 → 1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/lib/copier.rb +14 -0
  2. data/spec/copier_spec.rb +26 -0
  3. metadata +5 -3
data/lib/copier.rb ADDED
@@ -0,0 +1,14 @@
1
+ module Copier
2
+ class NotSupported < StandardError; end
3
+ end
4
+
5
+ def Copier(text)
6
+ case RUBY_PLATFORM
7
+ when /darwin/
8
+ IO.popen('pbcopy', 'w') {|io| io.write text }
9
+ when /cygwin/
10
+ File.open('/dev/clipboard', 'wb') {|io| io.write text.gsub("\x0A", "\n") }
11
+ else
12
+ raise Copier::NotSupported, RUBY_PLATFORM + " is not supported yet by Copier."
13
+ end
14
+ end
@@ -0,0 +1,26 @@
1
+ unless respond_to? :require_relative
2
+ def require_relative(o)
3
+ require File.dirname(__FILE__) + "/#{o}"
4
+ end
5
+ end
6
+
7
+ require_relative '../lib/copier'
8
+
9
+ describe 'Copier()' do
10
+ it 'copies text on Mac OS X' do
11
+ pending 'This platform is not Mac OS X, so you cannot run this case now' unless
12
+ /darwin/ =~ RUBY_PLATFORM
13
+ a = rand.to_s
14
+ Copier(a)
15
+ `pbpaste`.chomp.should == a
16
+ end
17
+
18
+ it 'copies text on Windows (cygwin)' do
19
+ pending 'This platform is not Windows (cygwin), so you cannot run this case now' unless
20
+ /cygwin/ =~ RUBY_PLATFORM
21
+ a = rand.to_s
22
+ Copier(a)
23
+ #`pbpaste`.chomp.should == a
24
+ pending 'Please fill this case... I dont know how to paste text'
25
+ end
26
+ end
metadata CHANGED
@@ -4,8 +4,8 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 1
7
- - 0
8
- version: "1.0"
7
+ - 1
8
+ version: "1.1"
9
9
  platform: ruby
10
10
  authors:
11
11
  - ujihisa
@@ -13,7 +13,7 @@ autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
15
 
16
- date: 2010-07-27 00:00:00 -07:00
16
+ date: 2010-07-28 00:00:00 -07:00
17
17
  default_executable:
18
18
  dependencies: []
19
19
 
@@ -26,7 +26,9 @@ extensions: []
26
26
  extra_rdoc_files:
27
27
  - README.md
28
28
  files:
29
+ - lib/copier.rb
29
30
  - README.md
31
+ - spec/copier_spec.rb
30
32
  has_rdoc: true
31
33
  homepage: https://github.com/ujihisa/copier
32
34
  licenses: []