Skip to content

Commit 354adc4

Browse files
committed
node.name
1 parent 30ac882 commit 354adc4

File tree

6 files changed

+23
-7
lines changed

6 files changed

+23
-7
lines changed

.github/workflows/test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ jobs:
1414
- uses: actions/checkout@v3
1515
- uses: erlef/setup-beam@v1
1616
with:
17-
otp-version: "27.0"
17+
otp-version: "28"
1818
rebar3-version: "3"
19-
gleam-version: "1.10.0"
19+
gleam-version: "1.11.0"
2020
- run: gleam test
2121
- run: gleam format --check src test

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
## v1.0.0-rc2 - Unreleased
44

5+
- The `gleam/erlang/node` function gains the `name` function.
56
- `process.receive` will now panic if given a non-named subject that is not
67
owned by the current process.
78

gleam.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ links = [
99
{ title = "Website", href = "https://gleam.run" },
1010
{ title = "Sponsor", href = "https://github.com/sponsors/lpil" },
1111
]
12-
gleam = ">= 1.7.0"
12+
gleam = ">= 1.11.0"
1313

1414
[dependencies]
1515
gleam_stdlib = ">= 0.53.0 and < 2.0.0"

manifest.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
# You typically do not need to edit this file
33

44
packages = [
5-
{ name = "gleam_stdlib", version = "0.58.0", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "091F2D2C4A3A4E2047986C47E2C2C9D728A4E068ABB31FDA17B0D347E6248467" },
6-
{ name = "gleeunit", version = "1.3.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleeunit", source = "hex", outer_checksum = "0E6C83834BA65EDCAAF4FE4FB94AC697D9262D83E6F58A750D63C9F6C8A9D9FF" },
5+
{ name = "gleam_stdlib", version = "0.60.0", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "621D600BB134BC239CB2537630899817B1A42E60A1D46C5E9F3FAE39F88C800B" },
6+
{ name = "gleeunit", version = "1.4.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleeunit", source = "hex", outer_checksum = "12A8A2B510D7063547CD73AE5345544AE92124247A82F46B05F5B0913EE28BC8" },
77
]
88

99
[requirements]

src/gleam/erlang/node.gleam

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,14 @@ pub type ConnectError {
5050
///
5151
@external(erlang, "gleam_erlang_ffi", "connect_node")
5252
pub fn connect(node: Atom) -> Result(Node, ConnectError)
53+
54+
/// Get the atom name of a node.
55+
///
56+
/// ## Examples
57+
///
58+
/// ```gleam
59+
/// assert name(my_node) == atom.create("app1@localhost")
60+
/// ```
61+
///
62+
@external(erlang, "gleam_erlang_ffi", "identity")
63+
pub fn name(node: Node) -> Atom

test/gleam/erlang/node_tests.gleam

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import gleam/erlang/node
66
pub fn self_test() {
77
let a = node.self()
88
let b = node.self()
9-
let assert True = a == b
9+
assert a == b
1010
}
1111

1212
pub fn visible_test() {
@@ -15,5 +15,9 @@ pub fn visible_test() {
1515

1616
pub fn connect_not_alive_test() {
1717
let name = atom.create("not_found@localhost")
18-
let assert Error(node.LocalNodeIsNotAlive) = node.connect(name)
18+
assert node.connect(name) == Error(node.LocalNodeIsNotAlive)
19+
}
20+
21+
pub fn name_test() {
22+
assert node.name(node.self()) == atom.create("nonode@nohost")
1923
}

0 commit comments

Comments
 (0)