No longer importing xml module.
h3rald h3rald@h3rald.com
Sun, 29 Sep 2024 11:27:40 +0200
5 files changed,
46 insertions(+),
38 deletions(-)
M
minpkg/lib/min_xml.nim
→
minpkg/lib/min_xml.nim
@@ -103,34 +103,34 @@ except CatchableError:
let msg = getCurrentExceptionMsg() raiseInvalid(msg) - def.symbol("xcomment") do (i: In): + def.symbol("comment") do (i: In): let vals = i.expect("'sym") i.push i.newXDict(newComment(vals[0].getString)) - def.symbol("xcdata") do (i: In): + def.symbol("cdata") do (i: In): let vals = i.expect("'sym") i.push i.newXDict(newCData(vals[0].getString)) - def.symbol("xtext") do (i: In): + def.symbol("text") do (i: In): let vals = i.expect("'sym") i.push i.newXDict(newText(vals[0].getString)) - def.symbol("xentity") do (i: In): + def.symbol("entity") do (i: In): let vals = i.expect("'sym") i.push i.newXDict(newEntity(vals[0].getString)) - def.symbol("xentity2utf8") do (i: In): + def.symbol("entity2utf8") do (i: In): let vals = i.expect("dict:xml-entity") var entity = i.dget(vals[0], "text").getString # Strip & and ; entity = entity[1..entity.len-2] i.push entity.entityToUtf8.newVal - def.symbol("xescape") do (i: In): + def.symbol("escape") do (i: In): let vals = i.expect("'sym") i.push vals[0].getString.escape.newVal - def.symbol("xelement") do (i: In): + def.symbol("element") do (i: In): let vals = i.expect("'sym") i.push i.newXDict(newElement(vals[0].getString))@@ -140,14 +140,14 @@ let xdict = vals[0]
let xml = i.newXml(xdict) i.push ($xml).newVal - def.symbol("xquery") do (i: In): + def.symbol("query") do (i: In): let vals = i.expect("'sym", "dict:xml-element") let xdict = vals[1] let query = vals[0].getString let root = i.newXml(xdict) i.push i.newXDict(root.querySelector(query)) - def.symbol("xqueryall") do (i: In): + def.symbol("query-all") do (i: In): let vals = i.expect("'sym", "dict:xml-element") let xdict = vals[1] let query = vals[0].getString
M
next-release.md
→
next-release.md
@@ -43,20 +43,30 @@ - **dict** module: renamed **dpick** to **dict.pick**
- **dict** module: renamed **dtype** to **dict.type** - The **sys** module is no longer imported. - The **dstore** module has been renamed to **store**, and is no longer imported. -- **store** mdule: renamed **dsinit** to **store.init** -- **store** mdule: renamed **dsget** to **store.get** -- **store** mdule: renamed **dshas?** to **store.has?** -- **store** mdule: renamed **dsput** to **store.put** -- **store** mdule: renamed **dspost** to **store.post** -- **store** mdule: renamed **dsdelete** to **store.delete** -- **store** mdule: renamed **dsquery** to **store.query** -- **store** mdule: renamed **dswrite** to **store.write** -- **store** mdule: renamed **dsread** to **store.read** +- **store** module: renamed **dsinit** to **store.init** +- **store** module: renamed **dsget** to **store.get** +- **store** module: renamed **dshas?** to **store.has?** +- **store** module: renamed **dsput** to **store.put** +- **store** module: renamed **dspost** to **store.post** +- **store** module: renamed **dsdelete** to **store.delete** +- **store** module: renamed **dsquery** to **store.query** +- **store** module: renamed **dswrite** to **store.write** +- **store** module: renamed **dsread** to **store.read** - The **crypto** module is no longer imported. - The **math** module is no longer imported. - **math** module: renamed **r2g** to **math.r2d** - The **net** module is no longer imported. - The **http** module is no longer imported. +- The **xml** module is no longer imported. +- **xml** module: renamed **xcomment** to **xml.comment** +- **xml** module: renamed **xentity** to **xml.entity** +- **xml** module: renamed **xtext** to **xml.text** +- **xml** module: renamed **xentity2utf8** to **xml.entity2utf8** +- **xml** module: renamed **xcdata** to **xml.cdata** +- **xml** module: renamed **xescape** to **xml.escape** +- **xml** module: renamed **xelement** to **xml.element** +- **xml** module: renamed **xquery** to **xml.query** +- **xml** module: renamed **xqueryall** to **xml.query-all**
M
prelude.min
→
prelude.min
@@ -1,4 +1,2 @@
-; Imports -'xml import ; Unseal prompt symbol 'prompt unseal-symbol
M
tasks/github.min
→
tasks/github.min
@@ -1,1 +1,1 @@
-#!/usr/bin/env min "_helpers" require :helpers 'helpers import "next-release.md" fs.read escape :release-body "tasks/data/draft-release.json" fs.read :draft-release-template config "version" dict.get :min-version env "github-token" dict.get :token draft-release-template ("version" min-version "body" release-body) =% :draft-release-body {} "application/vnd.github.v3+json" "Accept" dict.set "token $#" (token) =% "Authorization" dict.set :headers ( symbol handle-errors (dict :response ==>) ( response to-json "response.json" fs.write response "status" dict.get :status (status 300 >) ( response "body" dict.get from-json :body body "message" dict.get :message status string @status "Error $#: $#" (status message) =% io.error status int exit ) when ) ) :: ;; Handles HTTP errors. ( symbol gh-req (dict :data ==> dict|quot :result) ( data "endpoint" dict.get :endpoint "api" :subdomain (data 'subdomain dict.has?) (data "subdomain" dict.get @subdomain) when "https://$#.github.com/repos/h3rald/min$#" (subdomain endpoint) =% :url {} url "url" dict.set data "method" dict.get "method" dict.set (data 'headers dict.has?) (data "headers" dict.get "headers" dict.set) (headers "headers" dict.set) if (data 'body dict.has?) (data "body" dict.get "body" dict.set) when http.request :response response "status" dict.get :status response "body" dict.get :body response handle-errors (body length 0 >) (body from-json) ({}) if @result ) ) :: ;; Execute a request using the Github API. ( symbol get-assets (dict :data ==> quot :result) ( data "id" dict.get :id {} "/releases/$#/assets" (id) =% "endpoint" dict.set "GET" "method" dict.set gh-req @result ) ) :: ;; Retrieve the assets from an existing Github release. ( symbol delete-assets (dict :config ==>) ( config get-assets :assets config "id" dict.get :id assets ("id" dict.get) map :assets-ids assets-ids ( :asset {} "/releases/assets/$#" (asset) =% "endpoint" dict.set "DELETE" "method" dict.set gh-req stack.pop ) foreach ) ) :: ;; Delete all assets from an existing Github release. #|| Tasks ||# ( symbol draft (==>) ( {} "/releases" "endpoint" dict.set "POST" "method" dict.set draft-release-body "body" dict.set gh-req "id" dict.get string :id ;; Save Release ID to min.yml config id "id" dict.set to-yaml "min.yml" fs.write "Draft release v$# ($#) created successfully" (min-version id) =% io.notice! ) ) :: ;; Creates a new draft release on Github. ( symbol update (==>) ( config "id" dict.get :id {} "/releases/$#" (id) =% "endpoint" dict.set "PATCH" "method" dict.set draft-release-body "body" dict.set gh-req "id" dict.get string :id "Draft release v$# ($#) updated successfully" (min-version id) =% io.notice! ) ) :: ;; Updates the text of the current draft Github release. ( symbol assets (==>) ( config get-assets =assets assets size :total "are" :verb (total 1 ==) ("is" @verb) when "There $# $# assets in release v$#" (verb total min-version) =% io.notice! assets ("name" dict.get () stack.cons "- $#" stack.swap % io.notice!) foreach ) ) :: ;; Retrieve a list of all the assets of the current draft Github release. ( symbol upload (==>) ( config "id" dict.get :id config delete-assets sys.pwd sys.ls ("\\.zip$" match?) filter ( fs.filename :file "Uploading: $#" (file) =% io.notice! file fs.read :body headers "application/zip" "Content-Type" dict.set :asset-headers {} "/releases/$#/assets?name=$#" (id file) =% "endpoint" dict.set asset-headers "headers" dict.set "uploads" "subdomain" dict.set "POST" "method" dict.set body "body" dict.set gh-req stack.pop ) foreach ) ) :: ;; Uploads all assets to the current draft Github release, deleting any existing asset. +#!/usr/bin/env min "_helpers" require :helpers 'helpers import "next-release.md" fs.read xml.escape :release-body "tasks/data/draft-release.json" fs.read :draft-release-template config "version" dict.get :min-version env "github-token" dict.get :token draft-release-template ("version" min-version "body" release-body) =% :draft-release-body {} "application/vnd.github.v3+json" "Accept" dict.set "token $#" (token) =% "Authorization" dict.set :headers ( symbol handle-errors (dict :response ==>) ( response to-json "response.json" fs.write response "status" dict.get :status (status 300 >) ( response "body" dict.get from-json :body body "message" dict.get :message status string @status "Error $#: $#" (status message) =% io.error status int exit ) when ) ) :: ;; Handles HTTP errors. ( symbol gh-req (dict :data ==> dict|quot :result) ( data "endpoint" dict.get :endpoint "api" :subdomain (data 'subdomain dict.has?) (data "subdomain" dict.get @subdomain) when "https://$#.github.com/repos/h3rald/min$#" (subdomain endpoint) =% :url {} url "url" dict.set data "method" dict.get "method" dict.set (data 'headers dict.has?) (data "headers" dict.get "headers" dict.set) (headers "headers" dict.set) if (data 'body dict.has?) (data "body" dict.get "body" dict.set) when http.request :response response "status" dict.get :status response "body" dict.get :body response handle-errors (body length 0 >) (body from-json) ({}) if @result ) ) :: ;; Execute a request using the Github API. ( symbol get-assets (dict :data ==> quot :result) ( data "id" dict.get :id {} "/releases/$#/assets" (id) =% "endpoint" dict.set "GET" "method" dict.set gh-req @result ) ) :: ;; Retrieve the assets from an existing Github release. ( symbol delete-assets (dict :config ==>) ( config get-assets :assets config "id" dict.get :id assets ("id" dict.get) map :assets-ids assets-ids ( :asset {} "/releases/assets/$#" (asset) =% "endpoint" dict.set "DELETE" "method" dict.set gh-req stack.pop ) foreach ) ) :: ;; Delete all assets from an existing Github release. #|| Tasks ||# ( symbol draft (==>) ( {} "/releases" "endpoint" dict.set "POST" "method" dict.set draft-release-body "body" dict.set gh-req "id" dict.get string :id ;; Save Release ID to min.yml config id "id" dict.set to-yaml "min.yml" fs.write "Draft release v$# ($#) created successfully" (min-version id) =% io.notice! ) ) :: ;; Creates a new draft release on Github. ( symbol update (==>) ( config "id" dict.get :id {} "/releases/$#" (id) =% "endpoint" dict.set "PATCH" "method" dict.set draft-release-body "body" dict.set gh-req "id" dict.get string :id "Draft release v$# ($#) updated successfully" (min-version id) =% io.notice! ) ) :: ;; Updates the text of the current draft Github release. ( symbol assets (==>) ( config get-assets =assets assets size :total "are" :verb (total 1 ==) ("is" @verb) when "There $# $# assets in release v$#" (verb total min-version) =% io.notice! assets ("name" dict.get () stack.cons "- $#" stack.swap % io.notice!) foreach ) ) :: ;; Retrieve a list of all the assets of the current draft Github release. ( symbol upload (==>) ( config "id" dict.get :id config delete-assets sys.pwd sys.ls ("\\.zip$" match?) filter ( fs.filename :file "Uploading: $#" (file) =% io.notice! file fs.read :body headers "application/zip" "Content-Type" dict.set :asset-headers {} "/releases/$#/assets?name=$#" (id file) =% "endpoint" dict.set asset-headers "headers" dict.set "uploads" "subdomain" dict.set "POST" "method" dict.set body "body" dict.set gh-req stack.pop ) foreach ) ) :: ;; Uploads all assets to the current draft Github release, deleting any existing asset.
M
tests/xml.min
→
tests/xml.min
@@ -4,48 +4,48 @@
"xml" test.describe - ("test" xentity "text" dict.get "test" ==) test.assert + ("test" xml.entity "text" dict.get "test" ==) test.assert - ("test" xcomment "text" dict.get "test" ==) test.assert + ("test" xml.comment "text" dict.get "test" ==) test.assert - ("test" xtext "text" dict.get "test" ==) test.assert + ("test" xml.text "text" dict.get "test" ==) test.assert - ("test" xcdata "text" dict.get "test" ==) test.assert + ("test" xml.cdata "text" dict.get "test" ==) test.assert - ("test" xelement "tag" dict.get "test" ==) test.assert + ("test" xml.element "tag" dict.get "test" ==) test.assert ( - "test" xelement :xnode + "test" xml.element :xnode xnode {"a" :attr1} "attributes" dict.set @xnode - "a1" xelement :child - "text..." xtext :text + "a1" xml.element :child + "text..." xml.text :text xnode (child text) => "children" dict.set @xnode - xnode to-xml + xnode xml.to-xml "<test attr1=\"a\"><a1 />text...</test>" == ) test.assert ( - "<ul><li class='test'>yes</li><li class='test'>...</li><li>no</li></ul>" from-xml :xnode - xnode "li.test" xquery + "<ul><li class='test'>yes</li><li class='test'>...</li><li>no</li></ul>" xml.from-xml :xnode + xnode "li.test" xml.query "children" dict.get first "text" dict.get "yes" == ) test.assert ( - "<ul><li class='test'>yes</li><li class='test'>...</li><li>no</li></ul>" from-xml :xnode - xnode "li.test" xqueryall + "<ul><li class='test'>yes</li><li class='test'>...</li><li>no</li></ul>" xml.from-xml :xnode + xnode "li.test" xml.query-all size 2 == ) test.assert ( - "<b>this is a test</b><img src='test.jpg'><i>©</i>" from-html :xnode - xnode to-xml "<document>\n <b>this is a test</b>\n <img src=\"test.jpg\" />\n <i>&copy</i>\n</document>" == + "<b>this is a test</b><img src='test.jpg'><i>©</i>" xml.from-html :xnode + xnode xml.to-xml "<document>\n <b>this is a test</b>\n <img src=\"test.jpg\" />\n <i>&copy</i>\n</document>" == ) test.assert ( - ">" xentity xentity2utf8 ">" == + ">" xml.entity xml.entity2utf8 ">" == ) test.assert ( - "This is a <i>test</i>" xescape "This is a <i>test</i>" == + "This is a <i>test</i>" xml.escape "This is a <i>test</i>" == ) test.assert test.report