copypaste 0.9
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +10 -0
- data/README +26 -0
- data/Rakefile +93 -0
- data/bin/rcopy +12 -0
- data/bin/rcut +12 -0
- data/bin/rpaste +12 -0
- data/lib/copypaste.rb +54 -0
- metadata +83 -0
data/LICENSE
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
Copyright (c) 2010, Lucas Carlson <lucas@rufy.com>
|
2
|
+
All rights reserved.
|
3
|
+
|
4
|
+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
5
|
+
|
6
|
+
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
7
|
+
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
8
|
+
Neither the name of the Lucas Carlson nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
9
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
10
|
+
|
data/README
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
== Welcome to CopyPaste
|
2
|
+
|
3
|
+
CopyPaste provides rcopy, rcut, rpaste unix tools that interact with a central queue server through the memcached protocol
|
4
|
+
|
5
|
+
== Download
|
6
|
+
|
7
|
+
* gem install copypaste
|
8
|
+
* http://github.com/cardmagic/copypaste
|
9
|
+
|
10
|
+
== Usage
|
11
|
+
|
12
|
+
echo "hello world" | rcut # does not print anything, copies data into default buffer
|
13
|
+
rpaste # prints hello world
|
14
|
+
|
15
|
+
echo "hello world" | rcopy mybuf # prints hello world, copies into mybuf buffer
|
16
|
+
rpaste mybuf # prints hello world
|
17
|
+
|
18
|
+
rpaste somebuf && printf '\a' # waits for data in somebuf, then makes the terminal beep
|
19
|
+
echo "woot" | rcut somebuf # prints woot in the other terminal and then the other terminal beeps
|
20
|
+
|
21
|
+
|
22
|
+
== Authors
|
23
|
+
* Lucas Carlson from MOG (mailto:lucas@rufy.com)
|
24
|
+
|
25
|
+
This library is released under the terms of the BSD.
|
26
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,93 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
require 'rake/testtask'
|
4
|
+
require 'rake/rdoctask'
|
5
|
+
require 'rake/gempackagetask'
|
6
|
+
require 'rake/contrib/rubyforgepublisher'
|
7
|
+
require 'lib/copypaste'
|
8
|
+
|
9
|
+
PKG_VERSION = CopyPaste::VERSION
|
10
|
+
|
11
|
+
PKG_FILES = FileList[
|
12
|
+
"lib/**/*", "bin/*", "test/**/*", "[A-Z]*", "Rakefile", "doc/**/*", "examples/**/*"
|
13
|
+
]
|
14
|
+
|
15
|
+
desc "Default Task"
|
16
|
+
task :default => [ :test ]
|
17
|
+
|
18
|
+
# Run the unit tests
|
19
|
+
desc "Run all unit tests"
|
20
|
+
Rake::TestTask.new("test") { |t|
|
21
|
+
t.libs << "lib"
|
22
|
+
t.pattern = 'test/*/*_test.rb'
|
23
|
+
t.verbose = true
|
24
|
+
}
|
25
|
+
|
26
|
+
# Make a console, useful when working on tests
|
27
|
+
desc "Generate a test console"
|
28
|
+
task :console do
|
29
|
+
verbose( false ) { sh "irb -I lib/ -r 'copypaste'" }
|
30
|
+
end
|
31
|
+
|
32
|
+
# Genereate the RDoc documentation
|
33
|
+
desc "Create documentation"
|
34
|
+
Rake::RDocTask.new("doc") { |rdoc|
|
35
|
+
rdoc.title = "CopyPaste - ridiculously easy unix copy and paste functions"
|
36
|
+
rdoc.rdoc_dir = 'doc'
|
37
|
+
rdoc.rdoc_files.include('README')
|
38
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
39
|
+
}
|
40
|
+
|
41
|
+
# Genereate the package
|
42
|
+
spec = Gem::Specification.new do |s|
|
43
|
+
|
44
|
+
#### Basic information.
|
45
|
+
|
46
|
+
s.name = 'copypaste'
|
47
|
+
s.version = PKG_VERSION
|
48
|
+
s.summary = <<-EOF
|
49
|
+
CopyPaste provides rcopy, rcut, rpaste unix tools that interact with a central queue server through the memcached protocol
|
50
|
+
EOF
|
51
|
+
s.description = <<-EOF
|
52
|
+
CopyPaste provides rcopy, rcut, rpaste unix tools that interact with a central queue server through the memcached protocol
|
53
|
+
EOF
|
54
|
+
|
55
|
+
#### Which files are to be included in this gem? Everything! (Except CVS directories.)
|
56
|
+
|
57
|
+
s.files = PKG_FILES
|
58
|
+
|
59
|
+
#### Load-time details: library and application (you will need one or both).
|
60
|
+
|
61
|
+
s.bindir = 'bin'
|
62
|
+
s.executables = ['rcopy', 'rcut', 'rpaste']
|
63
|
+
s.require_path = 'lib'
|
64
|
+
s.autorequire = 'copypaste'
|
65
|
+
s.add_dependency('rconfig', '>= 0.3.2')
|
66
|
+
s.requirements << "Configuration mangement"
|
67
|
+
s.add_dependency('starling', '>= 0.10.1')
|
68
|
+
s.requirements << "Queue service"
|
69
|
+
|
70
|
+
#### Documentation and testing.
|
71
|
+
|
72
|
+
s.has_rdoc = true
|
73
|
+
|
74
|
+
#### Author and project details.
|
75
|
+
|
76
|
+
s.author = "Lucas Carlson"
|
77
|
+
s.email = "lucas@rufy.com"
|
78
|
+
s.homepage = "http://github.com/cardmagic/copypaste"
|
79
|
+
end
|
80
|
+
|
81
|
+
Rake::GemPackageTask.new(spec) do |pkg|
|
82
|
+
pkg.need_zip = true
|
83
|
+
pkg.need_tar = true
|
84
|
+
end
|
85
|
+
|
86
|
+
desc "Report code statistics (KLOCs, etc) from the application"
|
87
|
+
task :stats do
|
88
|
+
require 'code_statistics'
|
89
|
+
CodeStatistics.new(
|
90
|
+
["Library", "lib"],
|
91
|
+
["Units", "test"]
|
92
|
+
).to_s
|
93
|
+
end
|
data/bin/rcopy
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
$:.unshift(File.dirname(__FILE__)+'/../lib') unless
|
3
|
+
$:.include?(File.dirname(__FILE__)+'/../lib') || $:.include?(File.expand_path(File.dirname(__FILE__)+'/../lib'))
|
4
|
+
|
5
|
+
require 'copypaste'
|
6
|
+
|
7
|
+
case (queue = ARGV.shift)
|
8
|
+
when "--setup"
|
9
|
+
CopyPaste.setup
|
10
|
+
else
|
11
|
+
puts CopyPaste.copy(queue, STDIN)
|
12
|
+
end
|
data/bin/rcut
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
$:.unshift(File.dirname(__FILE__)+'/../lib') unless
|
3
|
+
$:.include?(File.dirname(__FILE__)+'/../lib') || $:.include?(File.expand_path(File.dirname(__FILE__)+'/../lib'))
|
4
|
+
|
5
|
+
require 'copypaste'
|
6
|
+
|
7
|
+
case (queue = ARGV.shift)
|
8
|
+
when "--setup"
|
9
|
+
CopyPaste.setup
|
10
|
+
else
|
11
|
+
CopyPaste.copy(queue, STDIN)
|
12
|
+
end
|
data/bin/rpaste
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
$:.unshift(File.dirname(__FILE__)+'/../lib') unless
|
3
|
+
$:.include?(File.dirname(__FILE__)+'/../lib') || $:.include?(File.expand_path(File.dirname(__FILE__)+'/../lib'))
|
4
|
+
|
5
|
+
require 'copypaste'
|
6
|
+
|
7
|
+
case (queue = ARGV.shift)
|
8
|
+
when "--setup"
|
9
|
+
CopyPaste.setup
|
10
|
+
else
|
11
|
+
puts CopyPaste.paste(queue)
|
12
|
+
end
|
data/lib/copypaste.rb
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
$:.unshift(File.dirname(__FILE__))
|
2
|
+
|
3
|
+
require 'starling'
|
4
|
+
require 'rconfig'
|
5
|
+
require 'fileutils'
|
6
|
+
|
7
|
+
class CopyPasteError < StandardError; end
|
8
|
+
class CopyPaste
|
9
|
+
VERSION = "0.9"
|
10
|
+
CONFIGURATION = "#{ENV['HOME']}/.copypaste"
|
11
|
+
|
12
|
+
class << self
|
13
|
+
def copy(queue, io)
|
14
|
+
queue ||= "default"
|
15
|
+
server
|
16
|
+
data = io.read
|
17
|
+
server.set("copypaste-#{queue}", data)
|
18
|
+
data
|
19
|
+
end
|
20
|
+
|
21
|
+
def paste(queue)
|
22
|
+
queue ||= "default"
|
23
|
+
server.get("copypaste-#{queue}")
|
24
|
+
end
|
25
|
+
|
26
|
+
def setup
|
27
|
+
print "What is your starling server address (127.0.0.1:22122): "
|
28
|
+
$stdout.flush
|
29
|
+
server = gets.strip
|
30
|
+
|
31
|
+
if server.empty?
|
32
|
+
server = "127.0.0.1:22122"
|
33
|
+
end
|
34
|
+
if !server.include?(":")
|
35
|
+
server = "#{server}:22122"
|
36
|
+
end
|
37
|
+
|
38
|
+
File.open("#{CONFIGURATION}/config.yml", "w"){|f| f << {"server" => server}.to_yaml }
|
39
|
+
puts "\nSaved to #{CONFIGURATION}/config.yml"
|
40
|
+
end
|
41
|
+
|
42
|
+
def server
|
43
|
+
if RConfig.config == {}
|
44
|
+
puts "Please run #{$0} --setup"
|
45
|
+
exit -1
|
46
|
+
else
|
47
|
+
@@server = Starling.new(RConfig.config.server)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
FileUtils.mkdir_p(CopyPaste::CONFIGURATION)
|
54
|
+
RConfig.config_paths = [CopyPaste::CONFIGURATION, "/etc/copypaste"]
|
metadata
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: copypaste
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: "0.9"
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Lucas Carlson
|
8
|
+
autorequire: copypaste
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2010-04-13 00:00:00 -07:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: rconfig
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 0.3.2
|
24
|
+
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: starling
|
27
|
+
type: :runtime
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.10.1
|
34
|
+
version:
|
35
|
+
description: " CopyPaste provides rcopy, rcut, rpaste unix tools that interact with a central queue server through the memcached protocol\n"
|
36
|
+
email: lucas@rufy.com
|
37
|
+
executables:
|
38
|
+
- rcopy
|
39
|
+
- rcut
|
40
|
+
- rpaste
|
41
|
+
extensions: []
|
42
|
+
|
43
|
+
extra_rdoc_files: []
|
44
|
+
|
45
|
+
files:
|
46
|
+
- lib/copypaste.rb
|
47
|
+
- bin/rcopy
|
48
|
+
- bin/rcut
|
49
|
+
- bin/rpaste
|
50
|
+
- LICENSE
|
51
|
+
- Rakefile
|
52
|
+
- README
|
53
|
+
has_rdoc: true
|
54
|
+
homepage: http://github.com/cardmagic/copypaste
|
55
|
+
licenses: []
|
56
|
+
|
57
|
+
post_install_message:
|
58
|
+
rdoc_options: []
|
59
|
+
|
60
|
+
require_paths:
|
61
|
+
- lib
|
62
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
63
|
+
requirements:
|
64
|
+
- - ">="
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: "0"
|
67
|
+
version:
|
68
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
69
|
+
requirements:
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: "0"
|
73
|
+
version:
|
74
|
+
requirements:
|
75
|
+
- Configuration mangement
|
76
|
+
- Queue service
|
77
|
+
rubyforge_project:
|
78
|
+
rubygems_version: 1.3.5
|
79
|
+
signing_key:
|
80
|
+
specification_version: 3
|
81
|
+
summary: CopyPaste provides rcopy, rcut, rpaste unix tools that interact with a central queue server through the memcached protocol
|
82
|
+
test_files: []
|
83
|
+
|