Skip to content

Commit 983d81f

Browse files
committed
Hello, Joe!
0 parents  commit 983d81f

File tree

8 files changed

+117
-0
lines changed

8 files changed

+117
-0
lines changed

.github/workflows/test.yml

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: test
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
- main
8+
pull_request:
9+
10+
jobs:
11+
test:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/[email protected]
15+
- uses: erlef/[email protected]
16+
with:
17+
otp-version: "25.2"
18+
gleam-version: "0.25.3"
19+
rebar3-version: "3"
20+
# elixir-version: "1.14.2"
21+
- run: gleam format --check src test
22+
- run: gleam deps download
23+
- run: gleam test

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
*.beam
2+
*.ez
3+
build
4+
erl_crash.dump

README.md

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# sqlight
2+
3+
[![Package Version](https://img.shields.io/hexpm/v/sqlight)](https://hex.pm/packages/sqlight)
4+
[![Hex Docs](https://img.shields.io/badge/hex-docs-ffaff3)](https://hexdocs.pm/sqlight/)
5+
6+
A Gleam project
7+
8+
## Quick start
9+
10+
```sh
11+
gleam run # Run the project
12+
gleam test # Run the tests
13+
gleam shell # Run an Erlang shell
14+
```
15+
16+
## Installation
17+
18+
If available on Hex this package can be added to your Gleam project:
19+
20+
```sh
21+
gleam add sqlight
22+
```
23+
24+
and its documentation can be found at <https://hexdocs.pm/sqlight>.

gleam.toml

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name = "sqlight"
2+
version = "0.1.0"
3+
description = "A Gleam project"
4+
5+
# Fill out these fields if you intend to generate HTML documentation or publish
6+
# your project to the Hex package manager.
7+
#
8+
# licences = ["Apache-2.0"]
9+
# repository = { type = "github", user = "username", repo = "project" }
10+
# links = [{ title = "Website", href = "https://gleam.run" }]
11+
12+
[dependencies]
13+
gleam_stdlib = "~> 0.25"
14+
esqlite = "~> 0.8"
15+
16+
[dev-dependencies]
17+
gleeunit = "~> 0.7"

manifest.toml

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# This file was generated by Gleam
2+
# You typically do not need to edit this file
3+
4+
packages = [
5+
{ name = "esqlite", version = "0.8.5", build_tools = ["rebar3"], requirements = [], otp_app = "esqlite", source = "hex", outer_checksum = "75F0DCAB190A09842B1D9305765C026D8AA2ED7C98EFF272DFB529CAC99B0742" },
6+
{ name = "gleam_stdlib", version = "0.25.0", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "AD0F89928E0B919C8F8EDF640484633B28DBF88630A9E6AE504617A3E3E5B9A2" },
7+
{ name = "gleeunit", version = "0.8.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleeunit", source = "hex", outer_checksum = "A1170754BF54F5DD6E9EF392FB1DC612528B007CCBE41B52F0C5453254708490" },
8+
]
9+
10+
[requirements]
11+
esqlite = "~> 0.8"
12+
gleam_stdlib = "~> 0.25"
13+
gleeunit = "~> 0.7"

src/sqlight.gleam

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
pub external type Connection
2+
3+
pub type Error {
4+
No
5+
}
6+
7+
// TODO: document
8+
// TODO: test
9+
pub external fn open(String) -> Result(Connection, Error) =
10+
"sqlight_ffi" "open"
11+
12+
pub external fn close(Connection) -> Result(Nil, Error) =
13+
"sqlight_ffi" "close"

src/sqlight_ffi.erl

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
-module(sqlight_ffi).
2+
3+
-export([open/1, close/1]).
4+
5+
open(FileName) ->
6+
Chars = unicode:characters_to_list(FileName),
7+
esqlite3:open(Chars).
8+
9+
close(Connection) ->
10+
% TODO: support returning errors
11+
ok = esqlite3:close(Connection),
12+
{ok, nil}.

test/sqlight_test.gleam

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import sqlight
2+
import gleeunit
3+
4+
pub fn main() {
5+
gleeunit.main()
6+
}
7+
8+
pub fn open_test() {
9+
assert Ok(conn) = sqlight.open("file:open_test?mode=memory")
10+
assert Ok(Nil) = sqlight.close(conn)
11+
}

0 commit comments

Comments
 (0)