From 0d1188631e400c1733ad893cc07bfb050bd9664f Mon Sep 17 00:00:00 2001 From: Louis Pilfold Date: Fri, 31 Dec 2021 16:07:45 +0000 Subject: Convert to use Gleam build tool --- .gitignore | 1 + gleam.toml | 16 ++++++++++++++++ manifest.toml | 13 +++++++++++++ rebar.config | 13 ------------- rebar.lock | 11 ----------- src/gleam_json.app.src | 15 --------------- src/gleam_json.gleam | 3 --- test/gleam/json_test.gleam | 37 ------------------------------------- test/gleam_json_test.gleam | 42 ++++++++++++++++++++++++++++++++++++++++++ 9 files changed, 72 insertions(+), 79 deletions(-) create mode 100644 manifest.toml delete mode 100644 rebar.config delete mode 100644 rebar.lock delete mode 100644 src/gleam_json.app.src delete mode 100644 src/gleam_json.gleam delete mode 100644 test/gleam/json_test.gleam create mode 100644 test/gleam_json_test.gleam diff --git a/.gitignore b/.gitignore index 3e67663..918808c 100644 --- a/.gitignore +++ b/.gitignore @@ -19,3 +19,4 @@ gen log logs rebar3.crashdump +build diff --git a/gleam.toml b/gleam.toml index 7b25c8d..c5f59c3 100644 --- a/gleam.toml +++ b/gleam.toml @@ -1 +1,17 @@ name = "gleam_json" +version = "0.1.0" +licences = ["Apache-2.0"] +description = "Work with JSON in Gleam" + +repository = { type = "github", user = "gleam", repo = "json" } +links = [ + { title = "Website", href = "https://gleam.run" }, + { title = "Sponsor", href = "https://github.com/sponsors/lpil" }, +] + +[dependencies] +gleam_stdlib = "~> 0.18" +jsone = "~> 1.7" + +[dev-dependencies] +gleeunit = "~> 0.5" diff --git a/manifest.toml b/manifest.toml new file mode 100644 index 0000000..5fc0b3b --- /dev/null +++ b/manifest.toml @@ -0,0 +1,13 @@ +# This file was generated by Gleam +# You typically do not need to edit this file + +packages = [ + { name = "gleam_stdlib", version = "0.18.1", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "763ECD87D54D08755EE4C8551720D122FDCA47F61D1CA8AF23B19A90395A7468" }, + { name = "gleeunit", version = "0.5.1", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleeunit", source = "hex", outer_checksum = "F7FA7477D930178C1E59519DBDB5E086BE3A6B65F015B67DA94D30A323062154" }, + { name = "jsone", version = "1.7.0", build_tools = ["rebar3"], requirements = [], otp_app = "jsone", source = "hex", outer_checksum = "A3A33712EE6BC8BE10CFA21C7C425A299DE4C5A8533F9F931E577A6D0E8F5DBD" }, +] + +[requirements] +gleam_stdlib = "~> 0.18" +gleeunit = "~> 0.5" +jsone = "~> 1.7" diff --git a/rebar.config b/rebar.config deleted file mode 100644 index b311899..0000000 --- a/rebar.config +++ /dev/null @@ -1,13 +0,0 @@ -{erl_opts, [debug_info]}. -{src_dirs, ["src", "gen/src"]}. - -{profiles, [ - {test, [{src_dirs, ["src", "test", "gen/src", "gen/test"]}]} -]}. - -{project_plugins, [rebar_gleam, rebar3_hex]}. - -{deps, [ - {gleam_stdlib, "0.15.0"}, - {jsone, "1.5.7"} -]}. diff --git a/rebar.lock b/rebar.lock deleted file mode 100644 index 1a490f6..0000000 --- a/rebar.lock +++ /dev/null @@ -1,11 +0,0 @@ -{"1.2.0", -[{<<"gleam_stdlib">>,{pkg,<<"gleam_stdlib">>,<<"0.15.0">>},0}, - {<<"jsone">>,{pkg,<<"jsone">>,<<"1.5.7">>},0}]}. -[ -{pkg_hash,[ - {<<"gleam_stdlib">>, <<"7979CDEA88D206250845F129A342C82FB04DA5DFD4ECE3CC5C6A1E3983117D15">>}, - {<<"jsone">>, <<"036EC290BF3B2B3348B2EEC199A0FCDA62CE296AB6B736A403A6A440C5203618">>}]}, -{pkg_hash_ext,[ - {<<"gleam_stdlib">>, <<"22B54D25271227B20E28B3DB341E39FEB04DB88D10A01AA7537F5FFD428CB0D2">>}, - {<<"jsone">>, <<"5F146CBF953469667EEE145FB066D6EE6B9B181BCFD547295317526E7464D732">>}]} -]. diff --git a/src/gleam_json.app.src b/src/gleam_json.app.src deleted file mode 100644 index 030b214..0000000 --- a/src/gleam_json.app.src +++ /dev/null @@ -1,15 +0,0 @@ -{application, gleam_json, - [{description, "A Gleam program"}, - {vsn, "0.1.0"}, - {registered, []}, - {applications, - [kernel, - stdlib, - gleam_stdlib - ]}, - {env,[]}, - {modules, []}, - - {licenses, ["Apache 2.0"]}, - {links, []} -]}. diff --git a/src/gleam_json.gleam b/src/gleam_json.gleam deleted file mode 100644 index b4c61d2..0000000 --- a/src/gleam_json.gleam +++ /dev/null @@ -1,3 +0,0 @@ -pub fn hello_world() -> String { - "Hello, from gleam_json!" -} diff --git a/test/gleam/json_test.gleam b/test/gleam/json_test.gleam deleted file mode 100644 index 8d3c9d4..0000000 --- a/test/gleam/json_test.gleam +++ /dev/null @@ -1,37 +0,0 @@ -import gleam/dynamic -import gleam/option.{None, Some} -import gleam/result -import gleam/json -import gleam/should - -pub fn decode_test() { - json.decode("5") - |> result.map(dynamic.from) - |> should.equal(Ok(dynamic.from(5))) - - json.decode(".") - |> result.nil_error() - |> should.equal(Error(Nil)) -} - -pub fn encode_test() { - json.string("hello") - |> json.encode() - |> should.equal("\"hello\"") - - json.null() - |> json.encode() - |> should.equal("null") - - json.object([#("foo", json.int(5))]) - |> json.encode() - |> should.equal("{\"foo\":5}") - - json.nullable(Some(5), json.int) - |> json.encode() - |> should.equal("5") - - json.nullable(None, json.int) - |> json.encode() - |> should.equal("null") -} diff --git a/test/gleam_json_test.gleam b/test/gleam_json_test.gleam new file mode 100644 index 0000000..162fa6e --- /dev/null +++ b/test/gleam_json_test.gleam @@ -0,0 +1,42 @@ +import gleam/dynamic +import gleam/option.{None, Some} +import gleam/result +import gleam/json +import gleeunit/should +import gleeunit + +pub fn main() { + gleeunit.main() +} + +pub fn decode_test() { + json.decode("5") + |> result.map(dynamic.from) + |> should.equal(Ok(dynamic.from(5))) + + json.decode(".") + |> result.nil_error() + |> should.equal(Error(Nil)) +} + +pub fn encode_test() { + json.string("hello") + |> json.encode() + |> should.equal("\"hello\"") + + json.null() + |> json.encode() + |> should.equal("null") + + json.object([#("foo", json.int(5))]) + |> json.encode() + |> should.equal("{\"foo\":5}") + + json.nullable(Some(5), json.int) + |> json.encode() + |> should.equal("5") + + json.nullable(None, json.int) + |> json.encode() + |> should.equal("null") +} -- cgit v1.2.3