conquer 0.1.5 → 0.1.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 +4 -4
- data/lib/conquer/dsl.rb +5 -0
- data/lib/conquer/event_segment.rb +41 -0
- data/lib/conquer/helpers.rb +6 -0
- data/lib/conquer/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a15a527b19285a11c3ffdbddfd584e89919e1284
|
|
4
|
+
data.tar.gz: 1750cbf22d392a324221eba39fbee8de49d00882
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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
|
data/lib/conquer/helpers.rb
CHANGED
data/lib/conquer/version.rb
CHANGED
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.
|
|
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-
|
|
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
|