Skip to content

Commit 205a56a

Browse files
committed
refactor: rename parsed field
1 parent 0278133 commit 205a56a

File tree

4 files changed

+13
-13
lines changed

4 files changed

+13
-13
lines changed

lib/algora/integrations/github/command.ex

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,10 @@ defmodule Algora.Github.Command do
4949
|> ignore()
5050
|> concat(ignore(whitespace()))
5151
|> choice([
52-
amount() |> concat(ignore(whitespace())) |> concat(username()),
53-
username() |> concat(ignore(whitespace())) |> concat(amount()),
52+
amount() |> concat(ignore(whitespace())) |> concat(recipient()),
53+
recipient() |> concat(ignore(whitespace())) |> concat(amount()),
5454
amount(),
55-
username()
55+
recipient()
5656
])
5757
|> tag(:tip)
5858
|> label(@usage.tip)

lib/algora/integrations/github/poller/comment_consumer.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ defmodule Algora.Github.Poller.CommentConsumer do
2626

2727
defp run_command({:tip, args}, ticket_ref, _comment) do
2828
amount = Keyword.get(args, :amount)
29-
recipient = Keyword.get(args, :username)
29+
recipient = Keyword.get(args, :recipient)
3030
owner = Keyword.get(ticket_ref, :owner)
3131
repo = Keyword.get(ticket_ref, :repo)
3232
number = Keyword.get(ticket_ref, :number)

lib/algora/shared/parser.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ defmodule Algora.Parser do
2121
|> label("amount (e.g. 1000 or 1,000.00)")
2222
end
2323

24-
def username do
24+
def recipient do
2525
"@"
2626
|> string()
2727
|> ignore()
2828
|> concat(word_chars())
29-
|> unwrap_and_tag(:username)
29+
|> unwrap_and_tag(:recipient)
3030
|> label("username starting with @")
3131
end
3232

test/algora/github/command_test.exs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,12 @@ defmodule Algora.Github.CommandTest do
4949

5050
describe "parse/1 with tip command" do
5151
test "parses tip with amount first" do
52-
assert {:ok, %{tip: [{:amount, ~M[100]usd}, {:username, "user"}]}} ==
52+
assert {:ok, %{tip: [{:amount, ~M[100]usd}, {:recipient, "user"}]}} ==
5353
Command.parse("/tip 100 @user")
5454
end
5555

56-
test "parses tip with username first" do
57-
assert {:ok, %{tip: [{:username, "user"}, {:amount, ~M[100]usd}]}} ==
56+
test "parses tip with recipient first" do
57+
assert {:ok, %{tip: [{:recipient, "user"}, {:amount, ~M[100]usd}]}} ==
5858
Command.parse("/tip @user 100")
5959
end
6060

@@ -63,8 +63,8 @@ defmodule Algora.Github.CommandTest do
6363
Command.parse("/tip 100")
6464
end
6565

66-
test "parses tip with only username" do
67-
assert {:ok, %{tip: [{:username, "user"}]}} ==
66+
test "parses tip with only recipient" do
67+
assert {:ok, %{tip: [{:recipient, "user"}]}} ==
6868
Command.parse("/tip @user")
6969
end
7070
end
@@ -126,15 +126,15 @@ defmodule Algora.Github.CommandTest do
126126
assert {:ok,
127127
%{
128128
bounty: [{:amount, Money.new!(100, :USD)}],
129-
tip: [{:amount, Money.new!(50, :USD)}, {:username, "user"}]
129+
tip: [{:amount, Money.new!(50, :USD)}, {:recipient, "user"}]
130130
}} == Command.parse("/bounty 100 /tip 50 @user")
131131
end
132132

133133
test "handles text between commands" do
134134
assert {:ok,
135135
%{
136136
bounty: [{:amount, Money.new!(100, :USD)}],
137-
tip: [{:username, "user"}, {:amount, Money.new!(50, :USD)}]
137+
tip: [{:recipient, "user"}, {:amount, Money.new!(50, :USD)}]
138138
}} == Command.parse("Hello /bounty 100 world /tip @user 50")
139139
end
140140
end

0 commit comments

Comments
 (0)