conquer 0.1.5 → 0.1.6

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: f3c1a64d3d178c9741a124760335e41fabf441ab
4
- data.tar.gz: 0fa54186efdf8d4e2667c2c7fc1a4af05819a692
3
+ metadata.gz: a15a527b19285a11c3ffdbddfd584e89919e1284
4
+ data.tar.gz: 1750cbf22d392a324221eba39fbee8de49d00882
5
5
  SHA512:
6
- metadata.gz: 09f4311d2dcf2f587fd6957aa9949b293131f07be771099d4d6e0bf1e9579a7a46b0dbdb521076df53abd88195f1543c80cedcd5e10aa937e86a3a4b05d44138
7
- data.tar.gz: 75f2c4b161e6dbf181310036045fca5659e5c9af2a561058e16fdb5c8d7566d580bd3c391329997185302559e53714b7afdbe439d6292be95f5c22da05b6cf72
6
+ metadata.gz: a3f27fd08a6e4576790a75794c8e2acd31300ec42efb69f32fe66dea1502eee73e095931b76f535a6eea4307b5528b4f953a0dda62fafdf17c0c554c8ceb642f
7
+ data.tar.gz: ffd33f86f745f6c4ae443bcb0a4dc49904abd836967cc4fc343d6494fa601d84c82ed9fc60ef3b7914f12138bc08c8cf0ed4132ef144228a2e695b5ab357a049
data/lib/conquer/dsl.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require 'conquer/segment'
2
+ require 'conquer/event_segment'
2
3
  require 'conquer/scroller'
3
4
  require 'conquer/helpers'
4
5
 
@@ -30,6 +31,10 @@ module Conquer
30
31
  every(0, &block)
31
32
  end
32
33
 
34
+ def on(*events, &block)
35
+ @container.register(EventSegment, block, *events)
36
+ end
37
+
33
38
  def scroll(options = {}, &block)
34
39
  scroller = @container.register(Scroller, options)
35
40
  sub_dsl = DSL.new(scroller)
@@ -0,0 +1,41 @@
1
+ require 'celluloid/current'
2
+ require 'conquer/core_ext/numeric'
3
+ require 'conquer/helpers'
4
+
5
+ module Conquer
6
+ class EventSegment
7
+ class Worker
8
+ include Celluloid
9
+ include Celluloid::Notifications
10
+
11
+ def initialize(topic, block, *subscribed_topics)
12
+ @topic = topic
13
+ @block = wrapped_proc(block)
14
+ subscribed_topics.each { |t| subscribe(t, :handle_event) }
15
+ end
16
+
17
+ def handle_event(event, *args)
18
+ publish(@topic, @block.call(event, *args).to_s.chomp)
19
+ end
20
+
21
+ private
22
+
23
+ def wrapped_proc(block)
24
+ proc do |*args|
25
+ Helpers.instance_eval { block.call(*args) }
26
+ end
27
+ end
28
+ end
29
+
30
+ def initialize(topic, interval, block, *subscribed_topics)
31
+ @topic = topic
32
+ @interval = interval
33
+ @block = block
34
+ @subscribed_topics = subscribed_topics
35
+ end
36
+
37
+ def start_worker
38
+ Worker.supervise(args: [@topic, @interval, @block, *@subscribed_topics])
39
+ end
40
+ end
41
+ end
@@ -1,4 +1,10 @@
1
+ require 'celluloid/notifications'
1
2
  module Conquer
2
3
  module Helpers
4
+ module_function
5
+
6
+ def publish(*args)
7
+ Celluloid::Notifications.publish(*args)
8
+ end
3
9
  end
4
10
  end
@@ -1,3 +1,3 @@
1
1
  module Conquer
2
- VERSION = '0.1.5'.freeze
2
+ VERSION = '0.1.6'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: conquer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joakim Reinert
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-11-03 00:00:00.000000000 Z
11
+ date: 2016-11-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -105,6 +105,7 @@ files:
105
105
  - lib/conquer/container.rb
106
106
  - lib/conquer/core_ext/numeric.rb
107
107
  - lib/conquer/dsl.rb
108
+ - lib/conquer/event_segment.rb
108
109
  - lib/conquer/helpers.rb
109
110
  - lib/conquer/rpc.rb
110
111
  - lib/conquer/scroller.rb