diff options
Diffstat (limited to 'stdlib/source/program/aedifex/metadata')
-rw-r--r-- | stdlib/source/program/aedifex/metadata/artifact.lux | 60 | ||||
-rw-r--r-- | stdlib/source/program/aedifex/metadata/snapshot.lux | 184 |
2 files changed, 122 insertions, 122 deletions
diff --git a/stdlib/source/program/aedifex/metadata/artifact.lux b/stdlib/source/program/aedifex/metadata/artifact.lux index aa7b9abce..cf9a34b58 100644 --- a/stdlib/source/program/aedifex/metadata/artifact.lux +++ b/stdlib/source/program/aedifex/metadata/artifact.lux @@ -29,7 +29,7 @@ {#group Group #name Name #versions (List Version) - #last-updated Instant}) + #last_updated Instant}) (def: (pad value) (-> Nat Text) @@ -37,23 +37,23 @@ (format "0" (%.nat value)) (%.nat value))) -(def: (date-format value) +(def: (date_format value) (%.Format Date) (format (|> value date.year year.value .nat %.nat) (|> value date.month month.number ..pad) - (|> value date.day-of-month ..pad))) + (|> value date.day_of_month ..pad))) -(def: (time-format value) +(def: (time_format value) (%.Format Time) (let [(^slots [#time.hour #time.minute #time.second]) (time.clock value)] (format (..pad hour) (..pad minute) (..pad second)))) -(def: (instant-format value) +(def: (instant_format value) (%.Format Instant) - (format (..date-format (instant.date value)) - (..time-format (instant.time value)))) + (format (..date_format (instant.date value)) + (..time_format (instant.time value)))) (template [<definition> <tag>] [(def: <definition> xml.Tag ["" <tag>])] @@ -63,7 +63,7 @@ [<version> "version"] [<versioning> "versioning"] [<versions> "versions"] - [<last-updated> "lastUpdated"] + [<last_updated> "lastUpdated"] [<metadata> "metadata"] ) @@ -72,26 +72,26 @@ (-> <type> XML) (|>> <pre> #xml.Text list (#xml.Node <tag> xml.attributes)))] - [write-group Group ..<group> (|>)] - [write-name Name ..<name> (|>)] - [write-version Version ..<version> (|>)] - [write-last-updated Instant ..<last-updated> ..instant-format] + [write_group Group ..<group> (|>)] + [write_name Name ..<name> (|>)] + [write_version Version ..<version> (|>)] + [write_last_updated Instant ..<last_updated> ..instant_format] ) -(def: write-versions +(def: write_versions (-> (List Version) XML) - (|>> (list\map ..write-version) (#xml.Node ..<versions> xml.attributes))) + (|>> (list\map ..write_version) (#xml.Node ..<versions> xml.attributes))) (def: #export (write value) (-> Metadata XML) (#xml.Node ..<metadata> xml.attributes - (list (..write-group (get@ #group value)) - (..write-name (get@ #name value)) + (list (..write_group (get@ #group value)) + (..write_name (get@ #name value)) (#xml.Node ..<versioning> xml.attributes - (list (..write-versions (get@ #versions value)) - (..write-last-updated (get@ #last-updated value))))))) + (list (..write_versions (get@ #versions value)) + (..write_last_updated (get@ #last_updated value))))))) (def: (sub tag parser) (All [a] (-> xml.Tag (Parser a) (Parser a))) @@ -103,17 +103,17 @@ (-> xml.Tag (Parser Text)) (..sub tag <xml>.text)) -(def: date-parser +(def: date_parser (<text>.Parser Date) (do <>.monad [year (<>.codec n.decimal (<text>.exactly 4 <text>.decimal)) year (<>.lift (year.year (.int year))) month (<>.codec n.decimal (<text>.exactly 2 <text>.decimal)) - month (<>.lift (month.by-number month)) - day-of-month (<>.codec n.decimal (<text>.exactly 2 <text>.decimal))] - (<>.lift (date.date year month day-of-month)))) + month (<>.lift (month.by_number month)) + day_of_month (<>.codec n.decimal (<text>.exactly 2 <text>.decimal))] + (<>.lift (date.date year month day_of_month)))) -(def: time-parser +(def: time_parser (<text>.Parser Time) (do <>.monad [hour (<>.codec n.decimal (<text>.exactly 2 <text>.decimal)) @@ -123,15 +123,15 @@ {#time.hour hour #time.minute minute #time.second second - #time.milli-second 0})))) + #time.milli_second 0})))) -(def: last-updated-parser +(def: last_updated_parser (Parser Instant) (<text>.embed (do <>.monad - [date ..date-parser - time ..time-parser] - (wrap (instant.from-date-time date time))) - (..text ..<last-updated>))) + [date ..date_parser + time ..time_parser] + (wrap (instant.from_date_time date time))) + (..text ..<last_updated>))) (def: #export parser (Parser Metadata) @@ -144,7 +144,7 @@ (<| <xml>.somewhere (..sub ..<versions>) (<>.many (..text ..<version>))) - (<xml>.somewhere ..last-updated-parser) + (<xml>.somewhere ..last_updated_parser) )) ))) diff --git a/stdlib/source/program/aedifex/metadata/snapshot.lux b/stdlib/source/program/aedifex/metadata/snapshot.lux index 1919d06ca..ea6ce4719 100644 --- a/stdlib/source/program/aedifex/metadata/snapshot.lux +++ b/stdlib/source/program/aedifex/metadata/snapshot.lux @@ -30,19 +30,19 @@ (def: snapshot "SNAPSHOT") -(type: #export Time-Stamp +(type: #export Time_Stamp Instant) (type: #export Build Nat) (type: #export Versioning - {#time-stamp Time-Stamp + {#time_stamp Time_Stamp #build Build #snapshot (List Type)}) (type: #export Value - [Version Time-Stamp Build]) + [Version Time_Stamp Build]) (type: #export Metadata {#group Group @@ -56,44 +56,44 @@ (format "0" (%.nat value)) (%.nat value))) -(def: (date-format value) +(def: (date_format value) (%.Format Date) (format (|> value date.year year.value .nat %.nat) (|> value date.month month.number ..pad) - (|> value date.day-of-month ..pad))) + (|> value date.day_of_month ..pad))) -(def: (time-format value) +(def: (time_format value) (%.Format Time) (let [(^slots [#time.hour #time.minute #time.second]) (time.clock value)] (format (..pad hour) (..pad minute) (..pad second)))) -(def: (instant-format value) +(def: (instant_format value) (%.Format Instant) - (format (..date-format (instant.date value)) - (..time-format (instant.time value)))) + (format (..date_format (instant.date value)) + (..time_format (instant.time value)))) (template [<separator> <name>] [(def: <name> <separator>)] - ["." time-stamp-separator] - ["-" value-separator] + ["." time_stamp_separator] + ["-" value_separator] ) -(def: (time-stamp-format value) - (%.Format Time-Stamp) - (format (..date-format (instant.date value)) - ..time-stamp-separator - (..time-format (instant.time value)))) +(def: (time_stamp_format value) + (%.Format Time_Stamp) + (format (..date_format (instant.date value)) + ..time_stamp_separator + (..time_format (instant.time value)))) -(def: (value-format [version time-stamp build]) +(def: (value_format [version time_stamp build]) (%.Format Value) - (format (text.replace-all ..snapshot - (..time-stamp-format time-stamp) + (format (text.replace_all ..snapshot + (..time_stamp_format time_stamp) version) - ..value-separator + ..value_separator (%.nat build))) (template [<definition> <tag>] @@ -102,14 +102,14 @@ [<group> "groupId"] [<name> "artifactId"] [<version> "version"] - [<last-updated> "lastUpdated"] + [<last_updated> "lastUpdated"] [<metadata> "metadata"] [<versioning> "versioning"] [<snapshot> "snapshot"] [<timestamp> "timestamp"] - [<build-number> "buildNumber"] - [<snapshot-versions> "snapshotVersions"] - [<snapshot-version> "snapshotVersion"] + [<build_number> "buildNumber"] + [<snapshot_versions> "snapshotVersions"] + [<snapshot_version> "snapshotVersion"] [<extension> "extension"] [<value> "value"] [<updated> "updated"] @@ -120,44 +120,44 @@ (-> <type> XML) (|>> <pre> #xml.Text list (#xml.Node <tag> xml.attributes)))] - [write-group Group ..<group> (|>)] - [write-name Name ..<name> (|>)] - [write-version Version ..<version> (|>)] - [write-last-updated Instant ..<last-updated> ..instant-format] - [write-time-stamp Instant ..<timestamp> ..time-stamp-format] - [write-build-number Nat ..<build-number> %.nat] - [write-extension Type ..<extension> (|>)] - [write-value Value ..<value> ..value-format] - [write-updated Instant ..<updated> ..instant-format] + [write_group Group ..<group> (|>)] + [write_name Name ..<name> (|>)] + [write_version Version ..<version> (|>)] + [write_last_updated Instant ..<last_updated> ..instant_format] + [write_time_stamp Instant ..<timestamp> ..time_stamp_format] + [write_build_number Nat ..<build_number> %.nat] + [write_extension Type ..<extension> (|>)] + [write_value Value ..<value> ..value_format] + [write_updated Instant ..<updated> ..instant_format] ) -(def: (write-snapshot value type) +(def: (write_snapshot value type) (-> Value Type XML) - (<| (#xml.Node ..<snapshot-version> xml.attributes) - (list (..write-extension type) - (..write-value value) - (let [[version time-stamp build] value] - (..write-updated time-stamp))))) + (<| (#xml.Node ..<snapshot_version> xml.attributes) + (list (..write_extension type) + (..write_value value) + (let [[version time_stamp build] value] + (..write_updated time_stamp))))) -(def: (write-versioning version (^slots [#time-stamp #build #snapshot])) +(def: (write_versioning version (^slots [#time_stamp #build #snapshot])) (-> Version Versioning XML) (<| (#xml.Node ..<versioning> xml.attributes) (list (<| (#xml.Node ..<snapshot> xml.attributes) - (list (..write-time-stamp time-stamp) - (..write-build-number build))) - (..write-last-updated time-stamp) - (<| (#xml.Node ..<snapshot-versions> xml.attributes) - (list\map (..write-snapshot [version time-stamp build]) + (list (..write_time_stamp time_stamp) + (..write_build_number build))) + (..write_last_updated time_stamp) + (<| (#xml.Node ..<snapshot_versions> xml.attributes) + (list\map (..write_snapshot [version time_stamp build]) snapshot))))) (def: #export (write (^slots [#group #name #version #versioning])) (-> Metadata XML) (#xml.Node ..<metadata> xml.attributes - (list (..write-group group) - (..write-name name) - (..write-version version) - (..write-versioning version versioning)))) + (list (..write_group group) + (..write_name name) + (..write_version version) + (..write_versioning version versioning)))) (def: (sub tag parser) (All [a] (-> xml.Tag (Parser a) (Parser a))) @@ -169,17 +169,17 @@ (-> xml.Tag (Parser Text)) (..sub tag <xml>.text)) -(def: date-parser +(def: date_parser (<text>.Parser Date) (do <>.monad [year (<>.codec n.decimal (<text>.exactly 4 <text>.decimal)) year (<>.lift (year.year (.int year))) month (<>.codec n.decimal (<text>.exactly 2 <text>.decimal)) - month (<>.lift (month.by-number month)) - day-of-month (<>.codec n.decimal (<text>.exactly 2 <text>.decimal))] - (<>.lift (date.date year month day-of-month)))) + month (<>.lift (month.by_number month)) + day_of_month (<>.codec n.decimal (<text>.exactly 2 <text>.decimal))] + (<>.lift (date.date year month day_of_month)))) -(def: time-parser +(def: time_parser (<text>.Parser Time) (do <>.monad [hour (<>.codec n.decimal (<text>.exactly 2 <text>.decimal)) @@ -189,69 +189,69 @@ {#time.hour hour #time.minute minute #time.second second - #time.milli-second 0})))) + #time.milli_second 0})))) -(def: last-updated-parser +(def: last_updated_parser (Parser Instant) (<text>.embed (do <>.monad - [date ..date-parser - time ..time-parser] - (wrap (instant.from-date-time date time))) - (..text ..<last-updated>))) + [date ..date_parser + time ..time_parser] + (wrap (instant.from_date_time date time))) + (..text ..<last_updated>))) -(def: time-stamp-parser - (Parser Time-Stamp) +(def: time_stamp_parser + (Parser Time_Stamp) (<text>.embed (do <>.monad - [date ..date-parser - _ (<text>.this ..time-stamp-separator) - time ..time-parser] - (wrap (instant.from-date-time date time))) + [date ..date_parser + _ (<text>.this ..time_stamp_separator) + time ..time_parser] + (wrap (instant.from_date_time date time))) (..text ..<timestamp>))) -(def: build-parser +(def: build_parser (Parser Build) (<text>.embed (<>.codec n.decimal (<text>.many <text>.decimal)) - (..text ..<build-number>))) + (..text ..<build_number>))) -(exception: #export (time-stamp-mismatch {expected Time-Stamp} {actual Text}) +(exception: #export (time_stamp_mismatch {expected Time_Stamp} {actual Text}) (exception.report - ["Expected time-stamp" (instant-format expected)] + ["Expected time-stamp" (instant_format expected)] ["Actual time-stamp" actual])) -(exception: #export (value-mismatch {expected Value} {actual Text}) +(exception: #export (value_mismatch {expected Value} {actual Text}) (exception.report - ["Expected" (..value-format expected)] + ["Expected" (..value_format expected)] ["Actual" actual])) -(def: (snapshot-parser expected) +(def: (snapshot_parser expected) (-> Value (Parser Type)) - (<| (..sub ..<snapshot-version>) + (<| (..sub ..<snapshot_version>) (do <>.monad - [#let [[version time-stamp build] expected] + [#let [[version time_stamp build] expected] updated (<xml>.somewhere (..text ..<updated>)) - _ (<>.assert (exception.construct ..time-stamp-mismatch [time-stamp updated]) - (\ text.equivalence = (instant-format time-stamp) updated)) + _ (<>.assert (exception.construct ..time_stamp_mismatch [time_stamp updated]) + (\ text.equivalence = (instant_format time_stamp) updated)) actual (<xml>.somewhere (..text ..<value>)) - _ (<>.assert (exception.construct ..value-mismatch [expected actual]) - (\ text.equivalence = (..value-format expected) actual))] + _ (<>.assert (exception.construct ..value_mismatch [expected actual]) + (\ text.equivalence = (..value_format expected) actual))] (<xml>.somewhere (..text ..<extension>))))) -(def: (versioning-parser version) +(def: (versioning_parser version) (-> Version (Parser Versioning)) (<| (..sub ..<versioning>) (do <>.monad - [[time-stamp build] (<| <xml>.somewhere + [[time_stamp build] (<| <xml>.somewhere (..sub ..<snapshot>) - (<>.and (<xml>.somewhere ..time-stamp-parser) - (<xml>.somewhere ..build-parser))) - last-updated (<xml>.somewhere ..last-updated-parser) - _ (<>.assert (exception.construct ..time-stamp-mismatch [time-stamp (instant-format last-updated)]) - (\ instant.equivalence = time-stamp last-updated)) + (<>.and (<xml>.somewhere ..time_stamp_parser) + (<xml>.somewhere ..build_parser))) + last_updated (<xml>.somewhere ..last_updated_parser) + _ (<>.assert (exception.construct ..time_stamp_mismatch [time_stamp (instant_format last_updated)]) + (\ instant.equivalence = time_stamp last_updated)) snapshot (<| <xml>.somewhere - (..sub ..<snapshot-versions>) - (<>.some (..snapshot-parser [version time-stamp build])))] - (wrap {#time-stamp time-stamp + (..sub ..<snapshot_versions>) + (<>.some (..snapshot_parser [version time_stamp build])))] + (wrap {#time_stamp time_stamp #build build #snapshot snapshot})))) @@ -262,13 +262,13 @@ [group (<xml>.somewhere (..text ..<group>)) name (<xml>.somewhere (..text ..<name>)) version (<xml>.somewhere (..text ..<version>)) - versioning (<xml>.somewhere (..versioning-parser version))] + versioning (<xml>.somewhere (..versioning_parser version))] (wrap {#group group #name name #version version #versioning versioning})))) -(def: versioning-equivalence +(def: versioning_equivalence (Equivalence Versioning) ($_ product.equivalence instant.equivalence @@ -282,5 +282,5 @@ text.equivalence text.equivalence text.equivalence - ..versioning-equivalence + ..versioning_equivalence )) |