zashoku 1.5.5 → 1.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 770d3ee1cf2f87e16048ee6b4e85c5386396ac57
4
- data.tar.gz: 4eba5da2106507d67008149dd0ed87538dd3e8e0
3
+ metadata.gz: e0db9aff8e20d948bbfeedb2ee251d30d586b9d6
4
+ data.tar.gz: d0af382c8c4f81b56d75ef9a91ac3c56abc797be
5
5
  SHA512:
6
- metadata.gz: 8be103708b5a862b9c26200c18c3eff09eab154efe10f7fd88b9bc7a704ee4997b148cd624aee1105cb6fdb2562b0d3841c1a3e4b76e2f4cb8ebcf02adf91698
7
- data.tar.gz: 1aeec1a3e41021aa32d36d0e88536680df6ca666e343d1c0f8551961049d1740e147b0fb6d2d37eb7e1ec57316a1f72e6f7a5026b25e2144978a7318d58e43ad
6
+ metadata.gz: c6014610f36f4840174e2de7417a3020dd4905219fc0e6de60170227ac5fb1482115175a61db0a0c2523936aa091fd06a450c7f541abcd2487ff2a68c7c30c3a
7
+ data.tar.gz: f6c68b7a354a964f85834e33a76c9ef8134c9f30aff28b0ad8c9d27e2752e3d5d757b540595e23748b8b3dc2b1a2798ddeacd4b8e680a0f1fa0b8ef66d415120
data/lib/constants.rb CHANGED
@@ -3,7 +3,7 @@
3
3
  require_relative 'core/util/util'
4
4
 
5
5
  module Zashoku
6
- Version = [1, 5, 5].freeze
6
+ Version = [1, 6, 0].freeze
7
7
 
8
8
  Root = File.expand_path('../', __dir__)
9
9
 
@@ -46,4 +46,6 @@ module Zashoku
46
46
  LoadPaths = [
47
47
  File.join(Zashoku::CConf[:app][:root], 'modules')
48
48
  ].freeze
49
+
50
+ EOF = 'ZASHOKU_EOF'
49
51
  end
@@ -9,10 +9,13 @@ module Zashoku
9
9
  class Client
10
10
  attr_accessor :callbacks
11
11
 
12
+ BSIZE = 1000000
13
+
12
14
  def initialize(host, port)
13
15
  @host, @port = host, port
14
16
  @socket = connect(@host, @port)
15
17
  @alive = true
18
+ @blocked = false
16
19
 
17
20
  @timeout = 2
18
21
 
@@ -112,6 +115,26 @@ module Zashoku
112
115
  }
113
116
  end
114
117
 
118
+ def command_to_file(file, msg, args = {})
119
+ return unless alive?
120
+ Zashoku.logger.info('stopping client threads from command_to_file')
121
+ stop_threads
122
+ @semaphore.synchronize {
123
+ payload = { 'msg' => msg, 'raw' => true }.merge(args)
124
+ @socket.puts(JSON.generate(payload))
125
+ f = File.open(file, 'w')
126
+ f.sync = true
127
+ loop do
128
+ d = @socket.gets(Zashoku::EOF, BSIZE)
129
+ f.print(d)
130
+ break if d.length < BSIZE
131
+ end
132
+ f.close
133
+ }
134
+ Zashoku.logger.info('re-starting client threads from command_to_file')
135
+ start_threads
136
+ end
137
+
115
138
  def pump_commands!
116
139
  loop do
117
140
  begin
@@ -143,8 +166,6 @@ module Zashoku
143
166
  lost_connection
144
167
  rescue IOError
145
168
  Util.alert("error: socket#{@socket}")
146
- #binding.pry
147
- #exit
148
169
  end
149
170
 
150
171
  def dispatch_events!
@@ -43,7 +43,13 @@ module Zashoku
43
43
  end
44
44
  begin
45
45
  response = @handler.call(message)
46
- client.puts JSON.generate(response: response)
46
+ client.puts(
47
+ if message['raw']
48
+ response + Zashoku::EOF
49
+ else
50
+ JSON.generate(response: response)
51
+ end
52
+ )
47
53
  rescue Errno::EPIPE
48
54
  break
49
55
  else
data/lib/core/view.rb CHANGED
@@ -247,6 +247,7 @@ module Zashoku
247
247
  @attributes
248
248
  )
249
249
 
250
+ return if @items.empty?
250
251
  @items_formatted = Zashoku::Formatter.items(get_format, @items)
251
252
  end
252
253
 
data/lib/daemon.rb CHANGED
@@ -16,7 +16,7 @@ require_relative 'core/module'
16
16
  module Zashoku
17
17
 
18
18
  class<<self
19
- attr_accessor :controllers
19
+ attr_accessor :controllers, :server
20
20
  def command(message)
21
21
  Zashoku.logger.debug("command got #{message}")
22
22
  message = message.keys.map(&:to_sym).zip(message.values).to_h
@@ -27,7 +27,12 @@ module Zashoku
27
27
  else
28
28
  nil
29
29
  end
30
- Zashoku::Util.encode_object(obj)
30
+ if message[:raw]
31
+ Zashoku.logger.info('responding with unencoded object')
32
+ obj
33
+ else
34
+ Zashoku::Util.encode_object(obj)
35
+ end
31
36
  end
32
37
  end
33
38
 
data/lib/viewer.rb CHANGED
@@ -33,9 +33,12 @@ module Zashoku
33
33
 
34
34
  if /^remote::.*/.match?(message[:mod])
35
35
  message[:mod] = message[:mod].gsub('remote::', '')
36
- Zashoku.logger.debug("sending message #{message}")
37
- msg = Zashoku::Util.decode_object(client.command('fwd', message))
38
- msg
36
+ Zashoku.logger.debug("sending remote message #{message}")
37
+ if message[:to_file]
38
+ client.command_to_file(message[:to_file], 'fwd', message)
39
+ else
40
+ Zashoku::Util.decode_object(client.command('fwd', message))
41
+ end
39
42
  else
40
43
  modules[message[:mod]].send(message[:meth], *message[:args])
41
44
  end
@@ -188,9 +191,9 @@ module Zashoku
188
191
  return builtin_command(*cmd.split) if COMMANDS.key?(cmd.split.first)
189
192
  raise "no such command" if cmd.split.length == 1
190
193
  command(*cmd.split) unless cmd.empty?
191
- rescue StandardError => e
192
- Zashoku.logger.error("#{cmd.split} raised an error '#{e}'")
193
- Util.alert("Error: #{e}")
194
+ #rescue StandardError => e
195
+ # Zashoku.logger.error("#{cmd.split} raised an error '#{e}'")
196
+ # Util.alert("Error: #{e}")
194
197
  end
195
198
 
196
199
  def search(*)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zashoku
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.5
4
+ version: 1.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - annacrombie
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-12-04 00:00:00.000000000 Z
11
+ date: 2017-12-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: curses