-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1290 from operable/peck/cog-info
cog info command
- Loading branch information
Showing
4 changed files
with
83 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
defmodule Cog.Commands.Info do | ||
use Cog.Command.GenCommand.Base, | ||
bundle: Cog.Util.Misc.embedded_bundle | ||
|
||
@description "Display information about the current running instance of Cog." | ||
|
||
@output_example """ | ||
[ | ||
{ | ||
"embedded_bundle_version": "0.18.0", | ||
"elixir_version": "1.3.4", | ||
"cog_version": "0.18.0", | ||
"bundle_config_version": 5 | ||
} | ||
] | ||
""" | ||
|
||
rule "when command is #{Cog.Util.Misc.embedded_bundle}:info allow" | ||
|
||
def handle_message(req, state) do | ||
info = %{ | ||
cog_version: Keyword.get(Mix.Project.config(), :version), | ||
elixir_version: System.build_info().version, | ||
embedded_bundle_version: Application.fetch_env!(:cog, :embedded_bundle_version), | ||
bundle_config_version: Spanner.Config.current_config_version() | ||
} | ||
|
||
{:reply, req.reply_to, "info", info, state} | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
~each var=$results as=info~ | ||
**Cog System Information** | ||
~attachment color="blue"~ | ||
**Cog Version:** ~$info.cog_version~ | ||
**Embedded Bundle Version:** ~$info.embedded_bundle_version~ | ||
**Bundle Config Version:** ~$info.bundle_config_version~ | ||
**Elixir Version:** ~$info.elixir_version~ | ||
~end~ | ||
~end~ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
defmodule Cog.Chat.HipChat.Templates.Embedded.InfoTest do | ||
use Cog.TemplateCase | ||
|
||
test "info template" do | ||
data = %{"results" => [%{"embedded_bundle_version" => "0.18.0", | ||
"elixir_version" => "1.3.4", | ||
"cog_version" => "0.18.0", | ||
"bundle_config_version" => 5}]} | ||
|
||
expected = """ | ||
<strong>Cog System Information</strong><br/>\ | ||
<br/>\ | ||
<strong>Cog Version:</strong> 0.18.0<br/>\ | ||
<strong>Embedded Bundle Version:</strong> 0.18.0<br/>\ | ||
<strong>Bundle Config Version:</strong> 5<br/>\ | ||
<strong>Elixir Version:</strong> 1.3.4 | ||
""" |> String.strip | ||
|
||
assert_rendered_template(:hipchat, :embedded, "info", data, expected) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
defmodule Cog.Chat.Slack.Templates.Embedded.InfoTest do | ||
use Cog.TemplateCase | ||
|
||
test "info template" do | ||
data = %{"results" => [%{"embedded_bundle_version" => "0.18.0", | ||
"elixir_version" => "1.3.4", | ||
"cog_version" => "0.18.0", | ||
"bundle_config_version" => 5}]} | ||
|
||
expected = """ | ||
*Cog System Information* | ||
""" |> String.strip | ||
|
||
attachment = [""" | ||
*Cog Version:* 0.18.0 | ||
*Embedded Bundle Version:* 0.18.0 | ||
*Bundle Config Version:* 5 | ||
*Elixir Version:* 1.3.4 | ||
"""] |> Enum.map(&String.strip/1) | ||
|
||
assert_rendered_template(:slack, :embedded, "info", data, {expected, attachment}) | ||
end | ||
end |