pastehub 0.2.6
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 +15 -0
- data/README.md +32 -0
- data/Rakefile +146 -0
- data/VERSION.yml +4 -0
- data/bin/PastehubSync +107 -0
- data/bin/pastehubDump +114 -0
- data/bin/pastehubPost +63 -0
- data/lib/pastehub.rb +43 -0
- data/lib/pastehub/auth.rb +171 -0
- data/lib/pastehub/client.rb +453 -0
- data/lib/pastehub/clientsync.rb +287 -0
- data/lib/pastehub/clipboard.rb +56 -0
- data/lib/pastehub/config.rb +166 -0
- data/lib/pastehub/crypt.rb +70 -0
- data/lib/pastehub/localdb.rb +187 -0
- data/lib/pastehub/log.rb +95 -0
- data/lib/pastehub/macosx.rb +66 -0
- data/lib/pastehub/masterdb.rb +213 -0
- data/lib/pastehub/store.rb +83 -0
- data/lib/pastehub/util.rb +153 -0
- data/server/masterdb.rb +141 -0
- data/server/notifier.rb +89 -0
- metadata +235 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
ODI0NzYwNDVjOWMxMzY0MjY2NGQ4NmRmODUxNWZkNzYwNDFjZDNjMQ==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
YWY2YjM2MzA1MjYwNThiNTA4ZTcxMDgzZjZlMzZkZTZlODRhN2FjMg==
|
7
|
+
!binary "U0hBNTEy":
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
NTg2M2U3NDc3NGI3MTliNmRjYzFlOTUyNDhkYWNiZDUxM2VhOWY4ODMyZjVj
|
10
|
+
NDU4YzgwOTdlOTlhYTU3ODUwZDc1YTI2MTEyZGIzOTY2MzIzNTY1OGNmYjNl
|
11
|
+
NzUxODFjNjI2MzQxMzM2YTU2MjRkOTBjNDk0NWYxNGViZjMzODA=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
NWJmMDU4YTRkZjE1NTRiNDMzM2U2ODg2ODhkYzc1NmUyZGRmMDU3OGM3OWEy
|
14
|
+
MWNlMmQzMGQ0ZmVkNjQyZmY0M2ZkZWRhMzZlMWFiZDQ4NWRiMDM0MWUyYmI3
|
15
|
+
ZGJkYzhiZGE5NmYyMjJiZWMxYWI5YzNjMzE4ODg4Y2IwMzJhMDM=
|
data/README.md
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
PasteHub
|
2
|
+
=======================
|
3
|
+
|
4
|
+
|
5
|
+
## Concept
|
6
|
+
|
7
|
+
Cloud-based cross-platform clipboard (copy and paste) service.
|
8
|
+
|
9
|
+

|
10
|
+
|
11
|
+
## Open Source
|
12
|
+
|
13
|
+
This software is distributed under the BSD-style license.
|
14
|
+
|
15
|
+
## Support OS
|
16
|
+
|
17
|
+
type | Sync OS's clipboard | Sync Emacs kill-ring
|
18
|
+
---------------|---------------------|----------------------
|
19
|
+
Linux(app) | not yet | OK
|
20
|
+
Linux(gem) | not yet | OK
|
21
|
+
MacOSX(app) | OK | not yet
|
22
|
+
MacOSX(gem) | OK | OK
|
23
|
+
Windows(app) | - | -
|
24
|
+
Windows(gem) | OK | not yet
|
25
|
+
|
26
|
+
## Documents
|
27
|
+
|
28
|
+
+ [Registration](./doc/client/Registration.md)
|
29
|
+
+ [MacOSX](./doc/client/setup_MacOSX.md)
|
30
|
+
+ [Linux](./doc/client/setup_Linux.md)
|
31
|
+
+ [RubyGems](./doc/client/ruby_gems.md)
|
32
|
+
+ [Setup Emacs](./doc/client/setup_emacs.md)
|
data/Rakefile
ADDED
@@ -0,0 +1,146 @@
|
|
1
|
+
# -*- mode: ruby; -*-
|
2
|
+
# Rakefile for PasteHub
|
3
|
+
# Release Engineering:
|
4
|
+
# 1. edit the VERSION.yml file
|
5
|
+
# 2. rake test && rake gemspec && rake build
|
6
|
+
# to generate pastehub-x.x.x.gem
|
7
|
+
# 3. install pastehub-x.x.x.gem to clean environment and test
|
8
|
+
# 4. rake release
|
9
|
+
# 5. gem push pkg/pastehub-x.x.x.gem ( need gem version 1.3.6 or higer. Please "gem update --system" to update )
|
10
|
+
#
|
11
|
+
# Test environment:
|
12
|
+
# 1. gem install fake_dynamo --version 0.1.3
|
13
|
+
# 2. fake_dynamo --port 4567
|
14
|
+
|
15
|
+
|
16
|
+
USERNAME_A='userA'
|
17
|
+
USERNAME_B='userB'
|
18
|
+
SETENV_A="export PASTEHUB_USER=userA ; export PASTEHUB_SECRET_KEY='ZGFiYTRkNDg5MzA0YTA0Y2ExYzQ2MGFiNjM0YjFlNzJlMzcyZDVhZg=='"
|
19
|
+
|
20
|
+
require 'rake'
|
21
|
+
begin
|
22
|
+
require 'jeweler2'
|
23
|
+
['pastehub'].each do |name|
|
24
|
+
Jeweler::Tasks.new do |gemspec|
|
25
|
+
gemspec.name = name
|
26
|
+
gemspec.summary = "PasteHub is cloud-based cross-platform clipboard sync."
|
27
|
+
gemspec.description = "PasteHub is cloud-based cross-platform clipboard sync."
|
28
|
+
gemspec.email = "kiyoka@sumibi.org"
|
29
|
+
gemspec.homepage = "http://github.com/kiyoka/pastehub"
|
30
|
+
gemspec.authors = ["Kiyoka Nishiyama"]
|
31
|
+
gemspec.files = FileList['Rakefile',
|
32
|
+
'.gemtest',
|
33
|
+
'VERSION.yml',
|
34
|
+
'README.txt',
|
35
|
+
'bin/*',
|
36
|
+
'lib/*.rb',
|
37
|
+
'lib/*/*.rb',
|
38
|
+
'server/*.rb'
|
39
|
+
].to_a
|
40
|
+
gemspec.add_development_dependency "rspec"
|
41
|
+
gemspec.add_development_dependency "rake"
|
42
|
+
gemspec.add_dependency "json"
|
43
|
+
gemspec.add_dependency "highline"
|
44
|
+
gemspec.add_dependency( "clipboard", "1.0.5" )
|
45
|
+
gemspec.add_dependency "ffi"
|
46
|
+
end
|
47
|
+
end
|
48
|
+
rescue LoadError
|
49
|
+
puts 'Jeweler2 not available. If you want to build a gemfile, please install with "sudo gem install jeweler2"'
|
50
|
+
end
|
51
|
+
|
52
|
+
task :default => [:test] do
|
53
|
+
end
|
54
|
+
|
55
|
+
|
56
|
+
task :test do
|
57
|
+
sh "rm -f /tmp/usertmp.db"
|
58
|
+
sh "ruby -I ./lib `which rspec` -b ./test/libstore_spec.rb "
|
59
|
+
sh "ruby -I ./lib `which rspec` -b ./test/libconfig_spec.rb "
|
60
|
+
sh "ruby -I ./lib `which rspec` -b ./test/libutil_spec.rb "
|
61
|
+
sh "ruby -I ./lib `which rspec` -b ./test/libcrypt_spec.rb "
|
62
|
+
sh "ruby -I ./lib `which rspec` -b ./test/libauth_spec.rb "
|
63
|
+
sh "ruby -I ./lib `which rspec` -b ./test/libauth2_spec.rb "
|
64
|
+
sh "ruby -I ./lib `which rspec` -b ./test/libclient_spec.rb "
|
65
|
+
sh "ruby -I ./lib `which rspec` -b ./test/liblog_spec.rb "
|
66
|
+
sh "ruby -I ./lib `which rspec` -b ./test/libmasterdb_spec.rb "
|
67
|
+
sh "ruby -I ./lib `which rspec` -b ./test/libuserdb_spec.rb "
|
68
|
+
end
|
69
|
+
|
70
|
+
task :win32_test do
|
71
|
+
sh "rm -f /tmp/usertmp.db"
|
72
|
+
sh "rspec -I ./lib -b ./test/libclipboard_spec.rb "
|
73
|
+
sh "rspec -I ./lib -b ./test/libstore_spec.rb "
|
74
|
+
sh "rspec -I ./lib -b ./test/libconfig_spec.rb "
|
75
|
+
sh "rspec -I ./lib -b ./test/libutil_spec.rb "
|
76
|
+
sh "rspec -I ./lib -b ./test/libcrypt_spec.rb "
|
77
|
+
sh "rspec -I ./lib -b ./test/libauth_spec.rb "
|
78
|
+
# sh "rspec -I ./lib -b ./test/libauth2_spec.rb "
|
79
|
+
sh "rspec -I ./lib -b ./test/libclient_spec.rb "
|
80
|
+
sh "rspec -I ./lib -b ./test/liblog_spec.rb "
|
81
|
+
# sh "rspec -I ./lib -b ./test/libmasterdb_spec.rb "
|
82
|
+
# sh "rspec -I ./lib -b ./test/libuserdb_spec.rb "
|
83
|
+
|
84
|
+
|
85
|
+
end
|
86
|
+
|
87
|
+
task :fluentd_for_test do
|
88
|
+
sh "fluentd -c ./fluentd-conf-for-test/fluent.conf"
|
89
|
+
end
|
90
|
+
|
91
|
+
task :test_u do
|
92
|
+
sh "ruby -I ./lib `which rspec` -b -t users ./test/aws_spec.rb -r ./test/rspec_formatter_for_emacs.rb -f CustomFormatter"
|
93
|
+
end
|
94
|
+
|
95
|
+
task :test_e do
|
96
|
+
sh "ruby -I ./lib `which rspec` -b -t entries ./test/aws_spec.rb -r ./test/rspec_formatter_for_emacs.rb -f CustomFormatter"
|
97
|
+
end
|
98
|
+
|
99
|
+
task :m do
|
100
|
+
sh "vertx run server/masterdb.rb -instance 2"
|
101
|
+
end
|
102
|
+
|
103
|
+
task :n do
|
104
|
+
sh "vertx run server/notifier.rb -instance 2"
|
105
|
+
end
|
106
|
+
|
107
|
+
task :d do
|
108
|
+
sh "ruby -I ./lib server/pastehub-admin gc "
|
109
|
+
end
|
110
|
+
|
111
|
+
task :setupTable do
|
112
|
+
sh "ruby -I ./lib server/pastehub-admin setup "
|
113
|
+
end
|
114
|
+
|
115
|
+
task :sync do
|
116
|
+
sh "ruby -I ./lib bin/PastehubSync"
|
117
|
+
end
|
118
|
+
|
119
|
+
task :macruby_sync do
|
120
|
+
sh "macruby -I ./lib bin/PastehubSync"
|
121
|
+
end
|
122
|
+
|
123
|
+
task :syncA do
|
124
|
+
sh SETENV_A + "; ruby -I ./lib bin/PastehubSync"
|
125
|
+
end
|
126
|
+
|
127
|
+
task :postA1 do
|
128
|
+
sh SETENV_A + "; echo 'aaa1' | ruby -I ./lib bin/pastehubPost"
|
129
|
+
end
|
130
|
+
|
131
|
+
task :postA2 do
|
132
|
+
sh SETENV_A + "; echo 'aaa2' | ruby -I ./lib bin/pastehubPost"
|
133
|
+
end
|
134
|
+
|
135
|
+
task :postB1 do
|
136
|
+
sh "echo 'bbb1' | ruby -I ./lib bin/pastehubPost"
|
137
|
+
end
|
138
|
+
|
139
|
+
task :dumpA do
|
140
|
+
open( "|" + SETENV_A + "; ruby -I ./lib bin/pastehubDump list" ) {|f|
|
141
|
+
firstKey = f.readline.chomp
|
142
|
+
sh SETENV_A + "; ruby -I ./lib bin/pastehubDump get '#{firstKey}'"
|
143
|
+
}
|
144
|
+
sh SETENV_A + "; ruby -I ./lib bin/pastehubDump top"
|
145
|
+
sh SETENV_A + "; ruby -I ./lib bin/pastehubDump latest"
|
146
|
+
end
|
data/VERSION.yml
ADDED
data/bin/PastehubSync
ADDED
@@ -0,0 +1,107 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# -*- coding: utf-8 -*-
|
3
|
+
#
|
4
|
+
# PastehubSync - PasteHub's sync program for UNIX client.
|
5
|
+
#
|
6
|
+
# Copyright (c) 2009-2011 Kiyoka Nishiyama <kiyoka@sumibi.org>
|
7
|
+
#
|
8
|
+
# Redistribution and use in source and binary forms, with or without
|
9
|
+
# modification, are permitted provided that the following conditions
|
10
|
+
# are met:
|
11
|
+
#
|
12
|
+
# 1. Redistributions of source code must retain the above copyright
|
13
|
+
# notice, this list of conditions and the following disclaimer.
|
14
|
+
#
|
15
|
+
# 2. Redistributions in binary form must reproduce the above copyright
|
16
|
+
# notice, this list of conditions and the following disclaimer in the
|
17
|
+
# documentation and/or other materials provided with the distribution.
|
18
|
+
#
|
19
|
+
# 3. Neither the name of the authors nor the names of its contributors
|
20
|
+
# may be used to endorse or promote products derived from this
|
21
|
+
# software without specific prior written permission.
|
22
|
+
#
|
23
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
24
|
+
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
25
|
+
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
26
|
+
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
27
|
+
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
28
|
+
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
29
|
+
# TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
30
|
+
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
31
|
+
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
32
|
+
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
33
|
+
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
34
|
+
#
|
35
|
+
#
|
36
|
+
require 'thread'
|
37
|
+
require 'pastehub'
|
38
|
+
|
39
|
+
PasteHub::Config.instance.loadClient
|
40
|
+
RETRY_INTERVAL = 60
|
41
|
+
|
42
|
+
|
43
|
+
def setup
|
44
|
+
if not PasteHub.setupDirectory( )
|
45
|
+
exit( 1 )
|
46
|
+
end
|
47
|
+
return PasteHub.signIn( )
|
48
|
+
end
|
49
|
+
|
50
|
+
def main
|
51
|
+
ret = setup()
|
52
|
+
username = ret[0]
|
53
|
+
secretKey = ret[1]
|
54
|
+
password = ret[2]
|
55
|
+
|
56
|
+
# save pid file
|
57
|
+
PasteHub.savePid( Process.pid )
|
58
|
+
|
59
|
+
# create clientSync
|
60
|
+
clientSync = PasteHub::ClientSync.new(
|
61
|
+
PasteHub::Config.instance.listItems / 2,
|
62
|
+
PasteHub::Config.instance.localDbPath,
|
63
|
+
0.5 )
|
64
|
+
clientSync.addNoitfyCallback( lambda { puts '<< COUNTUP >>' }, lambda { puts '<< ONLINE >>' }, lambda { puts '<< offline >>' } )
|
65
|
+
|
66
|
+
while true
|
67
|
+
begin
|
68
|
+
|
69
|
+
case RbConfig::CONFIG['host_os']
|
70
|
+
when /mingw32|mswin|windows/i
|
71
|
+
# Windows
|
72
|
+
else
|
73
|
+
# Other
|
74
|
+
Signal.trap( :SIGUSR1 ) {
|
75
|
+
STDERR.puts( "Info: caught signal." )
|
76
|
+
clientSync.syncNow( username, secretKey, password )
|
77
|
+
}
|
78
|
+
end
|
79
|
+
|
80
|
+
if username
|
81
|
+
threads = []
|
82
|
+
threads.push(Thread.new { clientSync.syncMain( username, secretKey, password ) })
|
83
|
+
threads.push(Thread.new { clientSync.clipboardCheck( username, secretKey, password ) })
|
84
|
+
threads.each {|t| t.join}
|
85
|
+
end
|
86
|
+
|
87
|
+
rescue Errno::ECONNREFUSED => e
|
88
|
+
STDERR.puts "retrying... pastehub server is down(1)"
|
89
|
+
sleep RETRY_INTERVAL
|
90
|
+
rescue Errno::ETIMEDOUT => e
|
91
|
+
STDERR.puts "retrying... network is offline(1)"
|
92
|
+
sleep RETRY_INTERVAL
|
93
|
+
rescue SocketError => e
|
94
|
+
STDERR.puts "retrying... network is offline(2)"
|
95
|
+
sleep RETRY_INTERVAL
|
96
|
+
rescue Timeout::Error => e
|
97
|
+
# ONLINE, but server is not helthy
|
98
|
+
STDERR.puts "retrying... pastehub server is down(2)"
|
99
|
+
sleep RETRY_INTERVAL
|
100
|
+
rescue Errno::ECONNRESET => e
|
101
|
+
STDERR.puts "retrying... pastehub server is down(3)"
|
102
|
+
sleep RETRY_INTERVAL
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
main
|
data/bin/pastehubDump
ADDED
@@ -0,0 +1,114 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# -*- coding: utf-8 -*-
|
3
|
+
#
|
4
|
+
# pastehubDump - PasteHub's dump utility for UNIX client.
|
5
|
+
#
|
6
|
+
# Copyright (c) 2009-2011 Kiyoka Nishiyama <kiyoka@sumibi.org>
|
7
|
+
#
|
8
|
+
# Redistribution and use in source and binary forms, with or without
|
9
|
+
# modification, are permitted provided that the following conditions
|
10
|
+
# are met:
|
11
|
+
#
|
12
|
+
# 1. Redistributions of source code must retain the above copyright
|
13
|
+
# notice, this list of conditions and the following disclaimer.
|
14
|
+
#
|
15
|
+
# 2. Redistributions in binary form must reproduce the above copyright
|
16
|
+
# notice, this list of conditions and the following disclaimer in the
|
17
|
+
# documentation and/or other materials provided with the distribution.
|
18
|
+
#
|
19
|
+
# 3. Neither the name of the authors nor the names of its contributors
|
20
|
+
# may be used to endorse or promote products derived from this
|
21
|
+
# software without specific prior written permission.
|
22
|
+
#
|
23
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
24
|
+
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
25
|
+
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
26
|
+
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
27
|
+
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
28
|
+
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
29
|
+
# TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
30
|
+
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
31
|
+
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
32
|
+
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
33
|
+
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
34
|
+
#
|
35
|
+
#
|
36
|
+
require 'pastehub'
|
37
|
+
|
38
|
+
def dumpDb( username, command, key )
|
39
|
+
config = PasteHub::Config.instance
|
40
|
+
config.loadClient
|
41
|
+
|
42
|
+
# open local store
|
43
|
+
store = PasteHub::LocalStore.new( username, true )
|
44
|
+
case command
|
45
|
+
when "list"
|
46
|
+
localList = store.getList()
|
47
|
+
if key and key.match( /^[0-9]+$/ )
|
48
|
+
localList = localList.take( key.to_i )
|
49
|
+
end
|
50
|
+
localList.each { |x|
|
51
|
+
puts x
|
52
|
+
}
|
53
|
+
|
54
|
+
when "slist"
|
55
|
+
serverList = store.getServerList()
|
56
|
+
serverList.each { |x|
|
57
|
+
puts x
|
58
|
+
}
|
59
|
+
|
60
|
+
when "top"
|
61
|
+
pair = store.top()
|
62
|
+
print pair[1] if pair[1]
|
63
|
+
|
64
|
+
when "latest"
|
65
|
+
arr = store.latest()
|
66
|
+
puts 'server=' + arr[0]
|
67
|
+
puts 'local =' + arr[1]
|
68
|
+
|
69
|
+
when "get"
|
70
|
+
print store.getValue( key )
|
71
|
+
end
|
72
|
+
|
73
|
+
store.close()
|
74
|
+
end
|
75
|
+
|
76
|
+
def main
|
77
|
+
username = PasteHub.loadUsername
|
78
|
+
if not username
|
79
|
+
STDERR.puts "clientDump: setup problem. Please setup pastehub application."
|
80
|
+
exit 1
|
81
|
+
end
|
82
|
+
|
83
|
+
if 0 == ARGV.length
|
84
|
+
STDERR.puts "clientDump [command] [arg]"
|
85
|
+
STDERR.puts " 1) clientDump list"
|
86
|
+
STDERR.puts " 2) clientDump slist"
|
87
|
+
STDERR.puts " 3) clientDump get key"
|
88
|
+
STDERR.puts " 4) clientDump top"
|
89
|
+
STDERR.puts " 5) clientDump latest"
|
90
|
+
exit 1
|
91
|
+
end
|
92
|
+
|
93
|
+
command = ARGV[0].downcase
|
94
|
+
case command
|
95
|
+
when "list"
|
96
|
+
dumpDb( username, command, ARGV[1] )
|
97
|
+
when "slist"
|
98
|
+
dumpDb( username, command, "" )
|
99
|
+
when "top"
|
100
|
+
dumpDb( username, command, "" )
|
101
|
+
when "latest"
|
102
|
+
dumpDb( username, command, "" )
|
103
|
+
when "get"
|
104
|
+
if 2 > ARGV.length
|
105
|
+
STDERR.puts "Error: please spacify key."
|
106
|
+
exit 1
|
107
|
+
end
|
108
|
+
dumpDb( username, command, ARGV[1] )
|
109
|
+
else
|
110
|
+
STDERR.puts "unknown command [#{command}]"
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
main
|
data/bin/pastehubPost
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# -*- coding: utf-8 -*-
|
3
|
+
#
|
4
|
+
# pastehubPost - PasteHub's post utility for UNIX client.
|
5
|
+
#
|
6
|
+
# Copyright (c) 2009-2011 Kiyoka Nishiyama <kiyoka@sumibi.org>
|
7
|
+
#
|
8
|
+
# Redistribution and use in source and binary forms, with or without
|
9
|
+
# modification, are permitted provided that the following conditions
|
10
|
+
# are met:
|
11
|
+
#
|
12
|
+
# 1. Redistributions of source code must retain the above copyright
|
13
|
+
# notice, this list of conditions and the following disclaimer.
|
14
|
+
#
|
15
|
+
# 2. Redistributions in binary form must reproduce the above copyright
|
16
|
+
# notice, this list of conditions and the following disclaimer in the
|
17
|
+
# documentation and/or other materials provided with the distribution.
|
18
|
+
#
|
19
|
+
# 3. Neither the name of the authors nor the names of its contributors
|
20
|
+
# may be used to endorse or promote products derived from this
|
21
|
+
# software without specific prior written permission.
|
22
|
+
#
|
23
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
24
|
+
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
25
|
+
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
26
|
+
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
27
|
+
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
28
|
+
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
29
|
+
# TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
30
|
+
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
31
|
+
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
32
|
+
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
33
|
+
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
34
|
+
#
|
35
|
+
#
|
36
|
+
require 'net/http'
|
37
|
+
require 'uri'
|
38
|
+
require 'open-uri'
|
39
|
+
require 'fileutils'
|
40
|
+
require 'pastehub'
|
41
|
+
PasteHub::Config.instance.loadClient
|
42
|
+
|
43
|
+
def main
|
44
|
+
username = PasteHub.loadUsername
|
45
|
+
if not username
|
46
|
+
STDERR.puts "clientPost: setup problem. Please setup pastehub application."
|
47
|
+
exit 1
|
48
|
+
end
|
49
|
+
|
50
|
+
# save to LocalDB
|
51
|
+
data = STDIN.read
|
52
|
+
auth = PasteHub::AuthForClient.new( username, "" )
|
53
|
+
client = PasteHub::Client.new( auth )
|
54
|
+
puts client.localSaveValue( nil, data )
|
55
|
+
|
56
|
+
# singal to pastehubSync
|
57
|
+
pid = PasteHub.loadPid
|
58
|
+
if 0 < pid
|
59
|
+
Process.kill( :SIGUSR1, pid )
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
main
|