lita-heroku 0.1.7 → 0.1.8
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/lita/handlers/heroku.rb +41 -7
- data/lita-heroku.gemspec +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d69b82f19f129ff76107502cb2de9966a49c11bd
|
4
|
+
data.tar.gz: b25de92fe6c4cbb20d1324cf9ae2b439a3aad41d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b2c5dcd64e72a8085923b6e69a60fcb2746bd73315f27f40eea6fd595faaaf4906739021c9e53000b8e18a1f5b1b4990dcbfa7a29d3fcf57701ac15e92ef67be
|
7
|
+
data.tar.gz: fba3ca5fd26a6b1ca5eeae0387213fa471bbc51ef782e37c1c4437e904a3f974ed30cd20329440187bb12adca135bd4b43c10ad402483125449225a051105af5
|
data/lib/lita/handlers/heroku.rb
CHANGED
@@ -18,13 +18,7 @@ module Lita
|
|
18
18
|
if command.start_with? "deploy"
|
19
19
|
heroku_deploy response
|
20
20
|
else
|
21
|
-
|
22
|
-
response_text = "```\n"
|
23
|
-
response_text += stdout
|
24
|
-
response_text += stderr
|
25
|
-
response_text += "Exited with status #{status.exitstatus}" unless status.exitstatus.zero?
|
26
|
-
response_text += "```"
|
27
|
-
response.reply response_text
|
21
|
+
stream_command response, "#{heroku_bin} #{command} -a #{config.app_prefix}#{environment}"
|
28
22
|
end
|
29
23
|
end
|
30
24
|
|
@@ -54,6 +48,7 @@ module Lita
|
|
54
48
|
build_response = JSON.parse build_response
|
55
49
|
|
56
50
|
$stdout.puts build_response
|
51
|
+
|
57
52
|
if build_response.key?("build") && build_response["build"]["status"] == "pending"
|
58
53
|
response_text = "Deploying #{branch} to #{app_name}. "
|
59
54
|
if config.bitly_access_token
|
@@ -72,6 +67,45 @@ module Lita
|
|
72
67
|
JSON.parse `#{cmd}`
|
73
68
|
end
|
74
69
|
|
70
|
+
private
|
71
|
+
|
72
|
+
def stream_command response, command
|
73
|
+
channel = response.message.source.room
|
74
|
+
|
75
|
+
Open3.popen2e(command) do |stdin, stdout_and_stderr, thread|
|
76
|
+
response.reply "```\nStarting `#{command.gsub "\n", '\\n'}`:\n```"
|
77
|
+
timestamp, text = get_last_message channel
|
78
|
+
|
79
|
+
last_update = Time.now.to_i - 2
|
80
|
+
text_response = String.new
|
81
|
+
|
82
|
+
while line = stdout_and_stderr.gets
|
83
|
+
text.gsub!("```", "")
|
84
|
+
text += line
|
85
|
+
text_response = "```#{text}```"
|
86
|
+
if Time.now.to_i - last_update > 2
|
87
|
+
last_update = Time.now.to_i
|
88
|
+
update_response channel, timestamp, text_response
|
89
|
+
end
|
90
|
+
end
|
91
|
+
update_response channel, timestamp, text_response
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
def update_response channel, timestamp, text
|
96
|
+
robot.chat_service.api.send(
|
97
|
+
:call_api, "chat.update", { channel: channel, ts: timestamp, as_user: true, text: text }
|
98
|
+
)
|
99
|
+
end
|
100
|
+
|
101
|
+
def get_last_message channel
|
102
|
+
# Would be nice if we could get this from the `response.reply`
|
103
|
+
msg = robot.chat_service.api.send(
|
104
|
+
:call_api, "im.history", { channel: channel, count: 1 } # Probably need to filter
|
105
|
+
)
|
106
|
+
[msg["messages"][0]["ts"], msg["messages"][0]["text"]]
|
107
|
+
end
|
108
|
+
|
75
109
|
Lita.register_handler(self)
|
76
110
|
end
|
77
111
|
end
|
data/lita-heroku.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lita-heroku
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eric Boehs
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-04-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: lita
|