pastehub 0.2.6 → 0.4.0

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,15 +1,7 @@
1
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=
2
+ SHA1:
3
+ metadata.gz: 42857483fdc84f96368d04ba528141a859d6e16d
4
+ data.tar.gz: 164089c90b685d3a6d4af4bd0c755581366f047b
5
+ SHA512:
6
+ metadata.gz: 5a495f3dddc74bf8e4c5839735f665aa96695fa7a514a7a619309e99c054382d749646df12f56370fd38a810043afbc4c1eae267c5ffa9589de0871d7b41c7f9
7
+ data.tar.gz: e3f3d0dd045c300eab8f0e8fbff536facaa47b07b940c0e50980f17278f5dfef96a095b018057a0058efa189b9fc9ad420c108ef2b44d60b143a9a9b531def24
data/README.md CHANGED
@@ -4,29 +4,24 @@ PasteHub
4
4
 
5
5
  ## Concept
6
6
 
7
- Cloud-based cross-platform clipboard (copy and paste) service.
7
+ Cross-platform clipboard (copy and paste) sync tool.
8
8
 
9
9
  ![image](./doc/client/pastehub_architecture.png)
10
10
 
11
- ## Open Source
12
-
13
- This software is distributed under the BSD-style license.
14
-
15
11
  ## Support OS
16
12
 
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
13
+ type | OS's clipboard | Emacs kill-ring | vim |
14
+ ---------------|----------------|--------------------|-----------|
15
+ MacOSX(gem) | OK | OK | OK |
16
+ Windows(gem) | OK | not yet | not yet |
17
+ Linux(gem) | not yet | OK | OK |
25
18
 
26
19
  ## Documents
27
20
 
28
- + [Registration](./doc/client/Registration.md)
29
- + [MacOSX](./doc/client/setup_MacOSX.md)
30
- + [Linux](./doc/client/setup_Linux.md)
31
21
  + [RubyGems](./doc/client/ruby_gems.md)
32
22
  + [Setup Emacs](./doc/client/setup_emacs.md)
23
+ + [Setup Vim](./doc/client/setup_vim.md)
24
+
25
+ ## Open Source
26
+
27
+ This software is distributed under the BSD-style license.
data/Rakefile CHANGED
@@ -2,7 +2,7 @@
2
2
  # Rakefile for PasteHub
3
3
  # Release Engineering:
4
4
  # 1. edit the VERSION.yml file
5
- # 2. rake test && rake gemspec && rake build
5
+ # 2. rake test && rake gemspec && gem build pastehub.gemspec
6
6
  # to generate pastehub-x.x.x.gem
7
7
  # 3. install pastehub-x.x.x.gem to clean environment and test
8
8
  # 4. rake release
@@ -13,37 +13,28 @@
13
13
  # 2. fake_dynamo --port 4567
14
14
 
15
15
 
16
- USERNAME_A='userA'
17
- USERNAME_B='userB'
18
- SETENV_A="export PASTEHUB_USER=userA ; export PASTEHUB_SECRET_KEY='ZGFiYTRkNDg5MzA0YTA0Y2ExYzQ2MGFiNjM0YjFlNzJlMzcyZDVhZg=='"
19
-
20
16
  require 'rake'
21
17
  begin
22
18
  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
19
+ Jeweler::Tasks.new do |gemspec|
20
+ gemspec.name = 'pastehub'
21
+ gemspec.summary = "PasteHub is cloud-based cross-platform clipboard sync."
22
+ gemspec.description = "PasteHub is cloud-based cross-platform clipboard sync."
23
+ gemspec.email = "kiyoka@sumibi.org"
24
+ gemspec.license = 'New BSD'
25
+ gemspec.homepage = "http://github.com/kiyoka/pastehub"
26
+ gemspec.authors = ["Kiyoka Nishiyama"]
27
+ gemspec.files = FileList['Rakefile',
28
+ '.gemtest',
29
+ 'VERSION.yml',
30
+ 'README.txt',
31
+ 'bin/*',
32
+ 'lib/*.rb',
33
+ 'lib/*/*.rb',
34
+ ].to_a
35
+ gemspec.add_dependency( "json", "1.8.1")
36
+ gemspec.add_dependency( "clipboard", "1.0.5" )
37
+ gemspec.add_dependency( "ffi", "1.9.3")
47
38
  end
48
39
  rescue LoadError
49
40
  puts 'Jeweler2 not available. If you want to build a gemfile, please install with "sudo gem install jeweler2"'
@@ -54,17 +45,14 @@ end
54
45
 
55
46
 
56
47
  task :test do
57
- sh "rm -f /tmp/usertmp.db"
58
- sh "ruby -I ./lib `which rspec` -b ./test/libstore_spec.rb "
59
48
  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 "
49
+ sh "ruby -I ./lib `which rspec` -b ./test/libconfig2_spec.rb "
50
+ sh "/bin/rm -rf /tmp/home/user1"
64
51
  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 "
52
+ sh "/bin/rm -rf /tmp/home/user1"
53
+ sh "ruby -I ./lib `which rspec` -b ./test/libclientsync_spec.rb "
54
+ sh "ruby -I ./lib `which rspec` -b ./test/libsyncentry_spec.rb "
55
+ # sh "ruby -I ./lib `which rspec` -b ./test/libutil_spec.rb "
68
56
  end
69
57
 
70
58
  task :win32_test do
@@ -84,36 +72,9 @@ task :win32_test do
84
72
 
85
73
  end
86
74
 
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
75
 
115
76
  task :sync do
116
- sh "ruby -I ./lib bin/PastehubSync"
77
+ sh "ruby -I ./lib bin/PastehubSync -v"
117
78
  end
118
79
 
119
80
  task :macruby_sync do
@@ -125,22 +86,14 @@ task :syncA do
125
86
  end
126
87
 
127
88
  task :postA1 do
128
- sh SETENV_A + "; echo 'aaa1' | ruby -I ./lib bin/pastehubPost"
89
+ sh "echo 'aaa1' | ruby -I ./lib bin/pastehubPost"
129
90
  end
130
91
 
131
92
  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"
93
+ sh "echo 'The quick brown fox jumps over the lazy dog and run' | ruby -I ./lib bin/pastehubPost"
137
94
  end
138
95
 
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"
96
+ task :getA do
97
+ sh "ruby -I ./lib bin/pastehubGet time"
98
+ sh "ruby -I ./lib bin/pastehubGet get"
146
99
  end
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  :major: 0
3
- :minor: 2
4
- :patch: 6
3
+ :minor: 4
4
+ :patch: 0
@@ -3,7 +3,7 @@
3
3
  #
4
4
  # PastehubSync - PasteHub's sync program for UNIX client.
5
5
  #
6
- # Copyright (c) 2009-2011 Kiyoka Nishiyama <kiyoka@sumibi.org>
6
+ # Copyright (c) 2013-2014 Kiyoka Nishiyama <kiyoka@sumibi.org>
7
7
  #
8
8
  # Redistribution and use in source and binary forms, with or without
9
9
  # modification, are permitted provided that the following conditions
@@ -37,71 +37,97 @@ require 'thread'
37
37
  require 'pastehub'
38
38
 
39
39
  PasteHub::Config.instance.loadClient
40
- RETRY_INTERVAL = 60
41
40
 
42
41
 
43
- def setup
42
+ def setup( argv )
44
43
  if not PasteHub.setupDirectory( )
45
44
  exit( 1 )
46
45
  end
47
- return PasteHub.signIn( )
46
+
47
+ if 0 < argv.size
48
+ case argv[0]
49
+ when "batch"
50
+ return [ :ok, PasteHub.hostname( ) ]
51
+ else
52
+ exit( 1 )
53
+ end
54
+ else
55
+ return [ :ok, PasteHub.hostname( ) ]
56
+ end
48
57
  end
49
58
 
50
- def main
51
- ret = setup()
52
- username = ret[0]
53
- secretKey = ret[1]
54
- password = ret[2]
59
+ def main( argv )
60
+ params = OptionParser.getopts( argv, "v" )
61
+ config = PasteHub::Config.instance()
62
+ if params[ 'v' ]
63
+ config.setVerbose( true )
64
+ end
65
+
66
+ ret = setup( argv )
67
+ errorCode = ret[0]
68
+ hostname = ret[1]
69
+
70
+ if not :ok == errorCode
71
+ exit( 1 )
72
+ end
55
73
 
56
74
  # save pid file
57
75
  PasteHub.savePid( Process.pid )
58
76
 
59
77
  # 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 )
78
+ clientSync = PasteHub::ClientSync.new( hostname, 1.0 )
79
+
80
+ # add notification handler
81
+ receiveNotifyFunc =
82
+ case RbConfig::CONFIG['host_os']
83
+ when /^darwin/
84
+ # MacOS X
85
+ notifier_path = RbConfig::CONFIG['bindir'] + "/" + "terminal-notifier"
86
+ if File.exist?( notifier_path )
87
+ STDERR.puts( "Info: found terminal-notifier for MacOS X." )
88
+ lambda { |x|
89
+ str = if config.notifyMessageMax < x.size
90
+ x[0...config.notifyMessageMax] + " ..."
91
+ else
92
+ x
93
+ end
94
+ command = sprintf( "%s -title 'PasteHub' -message '\\%s' ", notifier_path, str )
95
+ system( command )
77
96
  }
97
+ else
98
+ nil
78
99
  end
100
+ else
101
+ lambda { |x| STDERR.puts '<< COUNTUP >>' }
102
+ end
79
103
 
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
104
+ clientSync.addNoitfyCallback( receiveNotifyFunc )
86
105
 
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
106
+ while true
107
+ signals = 0
108
+
109
+ case RbConfig::CONFIG['host_os']
110
+ when /mingw32|mswin|windows/i
111
+ # Windows
112
+ else
113
+ # Other
114
+ Signal.trap( :SIGUSR1 ) {
115
+ STDERR.puts( "Info: caught USR1 signal." )
116
+ signals += 1
117
+ }
118
+ Signal.trap( :SIGTERM ) {
119
+ STDERR.puts( "Info: caught TERM signal to terminate." )
120
+ exit( 0 )
121
+ }
122
+ end
123
+
124
+ if hostname
125
+ threads = []
126
+ threads.push(Thread.new { clientSync.sync_main( ) })
127
+ threads.push(Thread.new { clientSync.clipboard_check( ) })
128
+ threads.each {|t| t.join}
103
129
  end
104
130
  end
105
131
  end
106
132
 
107
- main
133
+ main( ARGV )
@@ -1,7 +1,9 @@
1
+ #!/usr/bin/env ruby
2
+ # -*- coding: utf-8 -*-
1
3
  #
2
- # store.rb - PasteHub's storage sync library
4
+ # pastehubGet - PasteHub's get utility for UNIX client.
3
5
  #
4
- # Copyright (c) 2009-2011 Kiyoka Nishiyama <kiyoka@sumibi.org>
6
+ # Copyright (c) 2009-2014 Kiyoka Nishiyama <kiyoka@sumibi.org>
5
7
  #
6
8
  # Redistribution and use in source and binary forms, with or without
7
9
  # modification, are permitted provided that the following conditions
@@ -31,53 +33,49 @@
31
33
  # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32
34
  #
33
35
  #
36
+ require 'pastehub'
34
37
 
35
- module PasteHub
38
+ def print_latest( command )
39
+ hostname = PasteHub.hostname
40
+ config = PasteHub::Config.instance()
36
41
 
37
- class LocalStore
38
- def initialize( username, reader = false )
39
- @db = PasteHub::LocalDB.new( PasteHub::Config.instance.localDbPath )
40
- @db.open( username, reader )
41
- end
42
-
43
- def getList
44
- @db.getList()
45
- end
46
-
47
- def getServerList
48
- @db.getServerList()
49
- end
50
-
51
- def top
52
- lst = @db.getList( 1 )
53
- if 0 < lst.size
54
- [ lst.first, @db.getValue( lst.first ) ]
55
- else
56
- [ nil, nil ]
57
- end
58
- end
59
-
60
- def getValue( key )
61
- @db.getValue( key.dup )
62
- end
42
+ cs = PasteHub::ClientSync.new( hostname, 1 )
63
43
 
64
- def latest
65
- [ @db.getValue( PasteHub::SERVER_DATE_KEY ).to_s,
66
- @db.getValue( PasteHub::LOCAL_DATE_KEY ).to_s ]
44
+ # print latest entry data
45
+ result = cs.get_latest_entry( )
46
+ case command
47
+ when "time"
48
+ if result
49
+ puts cs.get_latest_entry( )[0]['create_unixtime']
50
+ else
51
+ puts '0'
67
52
  end
68
-
69
- def insertValue( key, value )
70
- @db.insertValue( key, value )
71
- end
72
-
73
- def close
74
- @db.close
75
- end
76
-
77
- def clear
78
- @db.clear
53
+ when "get"
54
+ if result
55
+ print cs.get_latest_entry( )[1]
56
+ else
57
+ puts ''
79
58
  end
59
+ end
60
+ end
80
61
 
62
+ def main
63
+ if 0 == ARGV.length
64
+ STDERR.puts "clientGet [command] [arg]"
65
+ STDERR.puts " 1) clientGet time"
66
+ STDERR.puts " 2) clientGet get"
67
+ exit 1
81
68
  end
82
69
 
70
+ command = ARGV[0].downcase
71
+ case command
72
+ when "time"
73
+ print_latest( command )
74
+ when "get"
75
+ print_latest( command )
76
+ else
77
+ STDERR.puts "unknown command [#{command}]"
78
+ end
83
79
  end
80
+
81
+ main