pixo 0.4.0 → 0.4.1

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: ab47761e84f228f514a4e7118207a388cd813463
4
- data.tar.gz: bd2121709d447827d27cf2a1616a65f9eaa7ad35
3
+ metadata.gz: f49c00d86d98cb6be43ae290175313ee7af4b6e5
4
+ data.tar.gz: 40a9255fa51834283531d73a43ecfe8130564a6a
5
5
  SHA512:
6
- metadata.gz: 29ca3f9f59fe05884d3701dcc0b2ed5b977325ffe6ff8586a51994a7f4511eb9762da2d89a307f5191757fae546d4b30b820757e9c27c2129f04018fd0abc955
7
- data.tar.gz: b3db77d49b09d3834c6fe6dd9cba31e87c8a55fc291b79cad665d7a8a0f404a60db491f9f71d995e960d2318d819de4b383d73490e967fe9e08af30d2e99d89a
6
+ metadata.gz: d6196ff2ea3adbfe98a206cd28692b3ffaa9bb600adc91351eda36ba24372a74818c81ea551add51ed7d7ca5070689700a0bf12e7734b78950a9451ea36e89ad
7
+ data.tar.gz: acb04c4a13e8fa2ad1b2101717f3011f59bf6344ff7f3a17dfb59abad7303c6942f2c807d467ec3cab8fc0050d75961c20ae323aca5ba910394dcebf57616f09
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- pixo (0.4.0)
4
+ pixo (0.4.1)
5
5
  concurrent-ruby
6
6
 
7
7
  GEM
@@ -18,4 +18,10 @@ module Pixo
18
18
  end
19
19
  @patterns
20
20
  end
21
+
22
+ def self.load_seed_patterns(renderer)
23
+ Pixo.seed_patterns.each do |name, code|
24
+ renderer.add_pattern(name, code)
25
+ end
26
+ end
21
27
  end
@@ -10,7 +10,7 @@ module Pixo
10
10
 
11
11
  def initialize()
12
12
  super
13
- @procs = Array.new
13
+ @procs = Concurrent::Array.new
14
14
 
15
15
  @procs_lock = Mutex.new
16
16
  @started_latch = Concurrent::CountDownLatch.new(1)
@@ -68,8 +68,6 @@ module Pixo
68
68
  pat.reset_start
69
69
  @active_pattern = pat
70
70
  end
71
-
72
- pattern
73
71
  end
74
72
 
75
73
  def pattern
@@ -9,7 +9,11 @@ module Pixo
9
9
  end
10
10
 
11
11
  def on_key(key, scancode, action, mods)
12
-
12
+ if (action == 0)
13
+ self.pattern = self.list_patterns.sample
14
+ return true
15
+ end
16
+ return false
13
17
  end
14
18
 
15
19
  def list_patterns
@@ -9,7 +9,7 @@ module Pixo::Rpc
9
9
  end
10
10
 
11
11
  def call(service)
12
- service.on_key(@key, @scancode, @action, @mods)
12
+ Thread.new { service.on_key(@key, @scancode, @action, @mods) }
13
13
  self
14
14
  end
15
15
  end
@@ -20,12 +20,13 @@ module Pixo::Rpc
20
20
  message = Marshal.load(Base64.strict_decode64(line.strip))
21
21
  if message.is_a?(Pixo::Rpc::RequestMessage)
22
22
  resp = Pixo::Rpc::ResponseMessage.new(message.data.call(self), message.rid)
23
-
24
- bytes_to_write = Base64.strict_encode64(Marshal.dump(resp))
25
- @pipe_mutex.synchronize do
26
- @writer_pipe.write(bytes_to_write)
27
- @writer_pipe.write($/)
28
- @writer_pipe.flush
23
+ unless message.async
24
+ bytes_to_write = Base64.strict_encode64(Marshal.dump(resp))
25
+ @pipe_mutex.synchronize do
26
+ @writer_pipe.write(bytes_to_write)
27
+ @writer_pipe.write($/)
28
+ @writer_pipe.flush
29
+ end
29
30
  end
30
31
  elsif message.is_a?(Pixo::Rpc::ResponseMessage)
31
32
  @live_requests[message.rid]
@@ -35,6 +36,9 @@ module Pixo::Rpc
35
36
  end
36
37
  rescue EOFError => e
37
38
  rescue IOError => e
39
+ rescue
40
+ STDERR.puts("RUN: #{$!}")
41
+ $!.backtrace.each do |back| STDERR.puts(back) end
38
42
  end
39
43
 
40
44
  def shutdown
@@ -44,7 +48,7 @@ module Pixo::Rpc
44
48
  end
45
49
 
46
50
  def request(message, timeout: 10, async: false)
47
- request = Pixo::Rpc::Request.new(message)
51
+ request = Pixo::Rpc::Request.new(message, async)
48
52
  @live_requests[request.message.rid] = request unless async
49
53
 
50
54
  bytes_to_write = Base64.strict_encode64(Marshal.dump(request.message))
@@ -61,6 +65,9 @@ module Pixo::Rpc
61
65
  end
62
66
 
63
67
  return request.response
68
+ rescue
69
+ STDERR.puts "request: #{$!.inspect}"
70
+ raise
64
71
  ensure
65
72
  @live_requests.delete request.message.rid
66
73
  end
@@ -76,10 +83,10 @@ module Pixo::Rpc
76
83
  attr_reader :response
77
84
  attr_reader :latch
78
85
 
79
- def initialize(data)
80
- @message = Pixo::Rpc::RequestMessage.new(data)
86
+ def initialize(data, async)
87
+ @message = Pixo::Rpc::RequestMessage.new(data, async)
81
88
 
82
- @latch = Concurrent::CountDownLatch.new(1)
89
+ @latch = Concurrent::CountDownLatch.new(1) unless async
83
90
  end
84
91
 
85
92
  def send_result(result)
@@ -98,9 +105,11 @@ module Pixo::Rpc
98
105
  end
99
106
 
100
107
  class RequestMessage < Message
101
- def initialize(data)
108
+ attr_reader :async
109
+ def initialize(data, async)
102
110
  super(data)
103
111
  @rid = "rid_#{SecureRandom.hex(10)}"
112
+ @async = async
104
113
  end
105
114
  end
106
115
 
@@ -1,3 +1,3 @@
1
1
  module Pixo
2
- VERSION = "0.4.0"
2
+ VERSION = "0.4.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pixo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Constantine