repp 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/repp.rb +1 -0
- data/lib/repp/event/ticker.rb +1 -1
- data/lib/repp/handler/slack.rb +17 -2
- data/lib/repp/ticker.rb +33 -0
- data/lib/repp/version.rb +1 -1
- data/repp.gemspec +1 -0
- metadata +17 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2e3c9fcf4aecdd0f0e0445d854b0492b89eba86d71ce0fc7d4995c59663ce267
|
4
|
+
data.tar.gz: 7bc30cfdbc22ceba44b53d08af8a7116c34fdf43232a4bc721aa9c756c00cb5c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6d941084b8fc8f4de2476c33215470e493b7c32c324ee63e7be38cd36d1663a1ba66ef32f3279456aae14925523773dd77cdb332d9e66e2522eb77622b93af31
|
7
|
+
data.tar.gz: ed6e768bc83262116b4148409b40a6b6ce8297fe3232fcc28f821c9a476a01b91827f0b5c551de6d2217719d2b778f4ac443dceb765f74fba23588685e2ff4d0
|
data/lib/repp.rb
CHANGED
data/lib/repp/event/ticker.rb
CHANGED
data/lib/repp/handler/slack.rb
CHANGED
@@ -27,7 +27,7 @@ module Repp
|
|
27
27
|
|
28
28
|
def handle
|
29
29
|
client.on :message do |data|
|
30
|
-
reply_to = data.text.scan(REPLY_REGEXP).map do |node|
|
30
|
+
reply_to = (data.text || "").scan(REPLY_REGEXP).map do |node|
|
31
31
|
user = users.find { |u| u.id == node.first }
|
32
32
|
user ? user.name : nil
|
33
33
|
end
|
@@ -64,7 +64,22 @@ module Repp
|
|
64
64
|
end
|
65
65
|
@client = ::Slack::RealTime::Client.new
|
66
66
|
@web_client = ::Slack::Web::Client.new
|
67
|
-
|
67
|
+
|
68
|
+
application = app.new
|
69
|
+
@ticker = Ticker.task(application) do |res|
|
70
|
+
if res.first
|
71
|
+
if res.last && res.last[:dest_channel]
|
72
|
+
channel_to_post = res.last[:dest_channel]
|
73
|
+
@web_client.chat_postMessage(text: res.first, channel: channel_to_post, as_user: true)
|
74
|
+
else
|
75
|
+
message = "Need 'dest_to:' option to every or cron job like:\n" +
|
76
|
+
"every 1.hour, dest_to: 'channel_name' do"
|
77
|
+
$stderr.puts(message)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
@ticker.run!
|
82
|
+
handler = SlackMessageHandler.new(@client, @web_client, application)
|
68
83
|
handler.handle
|
69
84
|
end
|
70
85
|
|
data/lib/repp/ticker.rb
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'concurrent'
|
2
|
+
module Repp
|
3
|
+
class Ticker
|
4
|
+
def self.task(app, &block)
|
5
|
+
Task.app = app
|
6
|
+
new(&block)
|
7
|
+
end
|
8
|
+
|
9
|
+
class Task
|
10
|
+
include Concurrent::Async
|
11
|
+
|
12
|
+
class << self
|
13
|
+
def app=(app); @app = app end
|
14
|
+
def app; @app end
|
15
|
+
end
|
16
|
+
|
17
|
+
def tick(event)
|
18
|
+
Task.app.call(event)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def initialize(&block)
|
23
|
+
@block = block
|
24
|
+
end
|
25
|
+
|
26
|
+
def run!
|
27
|
+
@task = Concurrent::TimerTask.new(execution_interval: 1) do
|
28
|
+
@block.call(Task.new.tick(Event::Ticker.new(body: Time.now)))
|
29
|
+
end
|
30
|
+
@task.execute
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
data/lib/repp/version.rb
CHANGED
data/repp.gemspec
CHANGED
@@ -24,6 +24,7 @@ Gem::Specification.new do |spec|
|
|
24
24
|
spec.add_dependency "eventmachine", "~> 1.2"
|
25
25
|
spec.add_dependency "slack-ruby-client", "~> 0.11"
|
26
26
|
spec.add_dependency "faye-websocket", "~> 0.10"
|
27
|
+
spec.add_dependency "concurrent-ruby", "~> 1.0"
|
27
28
|
|
28
29
|
spec.add_development_dependency "bundler", "~> 1.16"
|
29
30
|
spec.add_development_dependency "rake", "~> 10.0"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: repp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- kinoppyd
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-09-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: eventmachine
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0.10'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: concurrent-ruby
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.0'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: bundler
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -116,6 +130,7 @@ files:
|
|
116
130
|
- lib/repp/handler.rb
|
117
131
|
- lib/repp/handler/shell.rb
|
118
132
|
- lib/repp/handler/slack.rb
|
133
|
+
- lib/repp/ticker.rb
|
119
134
|
- lib/repp/version.rb
|
120
135
|
- repp.gemspec
|
121
136
|
homepage: https://github.com/kinoppyd/repp
|