From: Jean Privat Date: Tue, 15 May 2018 22:52:05 +0000 (-0400) Subject: Merge: lib/md5: nitunitize tests X-Git-Url: http://nitlanguage.org?hp=5d820da8b3a2df9cd7152ac51d48e2a491e27f5b Merge: lib/md5: nitunitize tests Signed-off-by: Alexandre Terrasa Pull-Request: #2694 --- diff --git a/.gitignore b/.gitignore index dc1e54b..c4cb96e 100644 --- a/.gitignore +++ b/.gitignore @@ -41,6 +41,8 @@ csrc2/ lib/*.log lib/*.dot +lib/*/bin + examples/*/doc examples/*/bin diff --git a/contrib/action_nitro/package.ini b/contrib/action_nitro/package.ini index bcd9ef0..cf42196 100644 --- a/contrib/action_nitro/package.ini +++ b/contrib/action_nitro/package.ini @@ -3,6 +3,7 @@ name=action_nitro tags=example maintainer=Alexis Laferrière license=Apache-2.0 +desc=Action Nitro! an action platformer where you jump from plane to plane to reach the ISS and defeat the bad guys [upstream] browse=https://github.com/nitlang/nit/tree/master/contrib/action_nitro/ git=https://github.com/nitlang/nit.git diff --git a/contrib/asteronits/package.ini b/contrib/asteronits/package.ini index 2ef165c..e32fcca 100644 --- a/contrib/asteronits/package.ini +++ b/contrib/asteronits/package.ini @@ -3,6 +3,7 @@ name=asteronits tags=example maintainer=Alexis Laferrière license=Apache-2.0 +desc=Sample portable 2D game implemented with the `simple_2d` API of gamnit [upstream] browse=https://github.com/nitlang/nit/tree/master/contrib/asteronits/ git=https://github.com/nitlang/nit.git diff --git a/contrib/benitlux/package.ini b/contrib/benitlux/package.ini index 38eeee8..8ad0390 100644 --- a/contrib/benitlux/package.ini +++ b/contrib/benitlux/package.ini @@ -3,6 +3,7 @@ name=benitlux tags=mobile,web maintainer=Alexis Laferrière license=Apache-2.0 +desc=An unofficial app and mailing list to keep faithful bargoers informed of the beers available at the excellent Brasserie Bénélux [upstream] browse=https://github.com/nitlang/nit/tree/master/contrib/benitlux/ git=https://github.com/nitlang/nit.git diff --git a/contrib/brainfuck/Makefile b/contrib/brainfuck/Makefile new file mode 100644 index 0000000..f478a7a --- /dev/null +++ b/contrib/brainfuck/Makefile @@ -0,0 +1,38 @@ +# This file is part of NIT ( http://www.nitlanguage.org ). +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +NITC ?= nitc +NITLS ?= nitls +NITUNIT ?= nitunit +NITDOC ?= nitdoc + +.PHONY: all +all: bin/brainfuck + +bin/brainfuck: $(shell $(NITLS) -M brainfuck.nit) + mkdir -p bin/ + $(NITC) brainfuck.nit -o bin/brainfuck + +.PHONY: check +check: + $(NITUNIT) . + +.PHONY: doc +doc: + $(NITDOC) . -o doc/ + +.PHONY: clean +clean: + rm -rf bin/ + rm -rf doc/ diff --git a/contrib/brainfuck/README.md b/contrib/brainfuck/README.md index 8715228..c327550 100644 --- a/contrib/brainfuck/README.md +++ b/contrib/brainfuck/README.md @@ -28,7 +28,7 @@ Brainfuck a small instruction set, only eight instructions : First, compile the interpreter with the Nit compiler/interpreter, and launch the program on a brainfuck source file for interpretation. Example: -~~~ +~~~sh nitc ./brainfuck.nit ./brainfuck ./examples/hello.bf ~~~ diff --git a/contrib/brainfuck/package.ini b/contrib/brainfuck/package.ini index 59c69b6..6522f47 100644 --- a/contrib/brainfuck/package.ini +++ b/contrib/brainfuck/package.ini @@ -3,6 +3,7 @@ name=brainfuck tags=language maintainer=Lucas Bajolet license=Apache-2.0 +desc=Brainfuck, a simple Brainfuck interpreter written in Nit [upstream] browse=https://github.com/nitlang/nit/tree/master/contrib/brainfuck/ git=https://github.com/nitlang/nit.git diff --git a/contrib/github_merge/Makefile b/contrib/github_merge/Makefile new file mode 100644 index 0000000..4ac8326 --- /dev/null +++ b/contrib/github_merge/Makefile @@ -0,0 +1,38 @@ +# This file is part of NIT ( http://www.nitlanguage.org ). +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +NITC ?= nitc +NITLS ?= nitls +NITUNIT ?= nitunit +NITDOC ?= nitdoc + +.PHONY: all +all: bin/github_merge + +bin/github_merge: $(shell $(NITLS) -M github_merge.nit) + mkdir -p bin/ + $(NITC) github_merge.nit -o bin/github_merge + +.PHONY: check +check: + $(NITUNIT) . + +.PHONY: doc +doc: + $(NITDOC) . -o doc/ + +.PHONY: clean +clean: + rm -rf bin/ + rm -rf doc/ diff --git a/contrib/github_merge.nit b/contrib/github_merge/github_merge.nit similarity index 93% rename from contrib/github_merge.nit rename to contrib/github_merge/github_merge.nit index ca61f39..f0717ff 100644 --- a/contrib/github_merge.nit +++ b/contrib/github_merge/github_merge.nit @@ -17,7 +17,7 @@ module github_merge import github::github_curl import template -import opts +import config redef class Object # Factorize cast @@ -102,11 +102,23 @@ var opt_query = new OptionString("Query to get issues (e.g. label=ok_will_merge) var opt_keepgoing = new OptionBool("Skip merge conflicts", "-k", "--keep-going") var opt_all = new OptionBool("Merge all", "-a", "--all") var opt_status = new OptionArray("A status context that must be \"success\" (e.g. default)", "--status") -var opts = new OptionContext -opts.add_option(opt_repo, opt_auth, opt_query, opt_status, opt_all, opt_keepgoing) -opts.parse(sys.args) -var args = opts.rest +var usage = new Buffer +usage.append "Usage: github_merge [OPTION]... \n" +usage.append "Query the Github PR API to perform a merge." + +var config = new Config +config.tool_description = usage.write_to_string +config.add_option(opt_repo, opt_auth, opt_query, opt_status, opt_all, opt_keepgoing) + +config.parse_options(sys.args) + +if config.opt_help.value then + config.usage + exit 0 +end + +var args = config.args var auth = opt_auth.value or else "" if auth == "" then auth = get_github_oauth @@ -183,4 +195,3 @@ for arg in args do print "The merge is made" mergemsg.write_to(stdout) end - diff --git a/contrib/github_merge/man/github_merge.man b/contrib/github_merge/man/github_merge.man new file mode 100644 index 0000000..3709f5c --- /dev/null +++ b/contrib/github_merge/man/github_merge.man @@ -0,0 +1,30 @@ +# NAME + +github_merge - Query the Github PR API to perform a merge. + +# SYNOPSIS + +github_merge [OPTION]... + +# OPTIONS + +### `-h`, `-?`, `--help` +Show this help message. + +### `-r`, `--repo` +Repository (e.g. nitlang/nit). + +### `--auth` +OAuth token. + +### `-q`, `--query` +Query to get issues (e.g. label=ok_will_merge). + +### `--status` +A status context that must be "success" (e.g. default). + +### `-a`, `--all` +Merge all. + +### `-k`, `--keep-going` +Skip merge conflicts. \ No newline at end of file diff --git a/contrib/github_merge.ini b/contrib/github_merge/package.ini similarity index 75% rename from contrib/github_merge.ini rename to contrib/github_merge/package.ini index 8f206bf..ae4f313 100644 --- a/contrib/github_merge.ini +++ b/contrib/github_merge/package.ini @@ -3,9 +3,10 @@ name=github_merge tags=cli maintainer=Jean Privat license=Apache-2.0 +desc=Query the Github PR API to perform a merge [upstream] -browse=https://github.com/nitlang/nit/tree/master/contrib/github_merge.nit +browse=https://github.com/nitlang/nit/tree/master/contrib/github_merge/ git=https://github.com/nitlang/nit.git -git.directory=contrib/github_merge.nit +git.directory=contrib/github_merge/ homepage=http://nitlanguage.org issues=https://github.com/nitlang/nit/issues diff --git a/contrib/github_search_for_jni/Makefile b/contrib/github_search_for_jni/Makefile index c1c24a0..91bbb76 100644 --- a/contrib/github_search_for_jni/Makefile +++ b/contrib/github_search_for_jni/Makefile @@ -1,3 +1,38 @@ -default: - mkdir -p bin - nitc -o bin/github_search_for_jni src/github_search_for_jni.nit +# This file is part of NIT ( http://www.nitlanguage.org ). +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +NITC ?= nitc +NITLS ?= nitls +NITUNIT ?= nitunit +NITDOC ?= nitdoc + +.PHONY: all +all: bin/github_search_for_jni + +bin/github_search_for_jni: $(shell $(NITLS) -M src/github_search_for_jni.nit) + mkdir -p bin/ + $(NITC) src/github_search_for_jni.nit -o bin/github_search_for_jni + +.PHONY: check +check: + $(NITUNIT) . + +.PHONY: doc +doc: + $(NITDOC) . -o doc/ + +.PHONY: clean +clean: + rm -rf bin/ + rm -rf doc/ diff --git a/contrib/github_search_for_jni/package.ini b/contrib/github_search_for_jni/package.ini index 0196d6f..41cda29 100644 --- a/contrib/github_search_for_jni/package.ini +++ b/contrib/github_search_for_jni/package.ini @@ -3,6 +3,7 @@ name=github_search_for_jni tags=cli maintainer=Alexis Laferrière license=Apache-2.0 +desc=Seach Github for repositories possibly using the JNI [upstream] browse=https://github.com/nitlang/nit/tree/master/contrib/github_search_for_jni/ git=https://github.com/nitlang/nit.git diff --git a/contrib/header_keeper/Makefile b/contrib/header_keeper/Makefile index ca099e4..b8ea6ee 100644 --- a/contrib/header_keeper/Makefile +++ b/contrib/header_keeper/Makefile @@ -1,8 +1,43 @@ -bin/header_keeper: - mkdir -p bin - nitc --dir bin src/header_keeper.nit +# This file is part of NIT ( http://www.nitlanguage.org ). +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +NITC ?= nitc +NITLS ?= nitls +NITUNIT ?= nitunit +NITDOC ?= nitdoc + +.PHONY: all +all: bin/header_keeper + +bin/header_keeper: $(shell $(NITLS) -M src/header_keeper.nit) + mkdir -p bin/ + $(NITC) src/header_keeper.nit -o bin/header_keeper + +.PHONY: check check: tests + $(NITUNIT) . + +.PHONY: tests tests: bin/header_keeper gcc -E /usr/include/SDL/SDL_image.h | bin/header_keeper SDL_image.h gcc -E /usr/include/GLES2/gl2.h | bin/header_keeper gl2.h + +.PHONY: doc +doc: + $(NITDOC) . -o doc/ + +.PHONY: clean +clean: + rm -rf bin/ + rm -rf doc/ diff --git a/contrib/header_keeper/package.ini b/contrib/header_keeper/package.ini index 549bbb6..37939c7 100644 --- a/contrib/header_keeper/package.ini +++ b/contrib/header_keeper/package.ini @@ -3,6 +3,7 @@ name=header_keeper tags=devel,cli maintainer=Alexis Laferrière license=Apache-2.0 +desc=Filter preprocessed C-like header files to remove included files [upstream] browse=https://github.com/nitlang/nit/tree/master/contrib/header_keeper/ git=https://github.com/nitlang/nit.git diff --git a/contrib/inkscape_tools/Makefile b/contrib/inkscape_tools/Makefile index 9ca428b..d66e588 100644 --- a/contrib/inkscape_tools/Makefile +++ b/contrib/inkscape_tools/Makefile @@ -1,5 +1,42 @@ -all: - mkdir -p bin - nitc --dir bin src/svg_to_png_and_nit.nit src/svg_to_icons.nit +# This file is part of NIT ( http://www.nitlanguage.org ). +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. -.PHONY: bin/svg_to_png_and_nit +NITC ?= nitc +NITLS ?= nitls +NITUNIT ?= nitunit +NITDOC ?= nitdoc + +.PHONY: all +all: bin/svg_to_icons bin/svg_to_png_and_nit + +bin/svg_to_icons: $(shell $(NITLS) -M src/svg_to_icons.nit) + mkdir -p bin/ + $(NITC) src/svg_to_icons.nit -o bin/svg_to_icons + +bin/svg_to_png_and_nit: $(shell $(NITLS) -M src/svg_to_png_and_nit.nit) + mkdir -p bin/ + $(NITC) src/svg_to_png_and_nit.nit -o bin/svg_to_png_and_nit + +.PHONY: check +check: + $(NITUNIT) . + +.PHONY: doc +doc: + $(NITDOC) . -o doc/ + +.PHONY: clean +clean: + rm -rf bin/ + rm -rf doc/ diff --git a/contrib/inkscape_tools/package.ini b/contrib/inkscape_tools/package.ini index f553cd5..99b3739 100644 --- a/contrib/inkscape_tools/package.ini +++ b/contrib/inkscape_tools/package.ini @@ -3,6 +3,7 @@ name=inkscape_tools tags=devel,cli maintainer=Alexis Laferrière license=Apache-2.0 +desc=tools to extract images from SVG files: `svg_to_icons` for app icons and `svg_to_png_and_nit` for game sprites [upstream] browse=https://github.com/nitlang/nit/tree/master/contrib/inkscape_tools/ git=https://github.com/nitlang/nit.git diff --git a/contrib/jwrapper/package.ini b/contrib/jwrapper/package.ini index adaed16..c01dace 100644 --- a/contrib/jwrapper/package.ini +++ b/contrib/jwrapper/package.ini @@ -3,6 +3,7 @@ name=jwrapper tags=java,devel,cli maintainer=Alexis Laferrière license=Apache-2.0 +desc=Generator of Nit extern classes to wrap Java APIs [upstream] browse=https://github.com/nitlang/nit/tree/master/contrib/jwrapper/ git=https://github.com/nitlang/nit.git diff --git a/contrib/memplot/Makefile b/contrib/memplot/Makefile new file mode 100644 index 0000000..43f84e6 --- /dev/null +++ b/contrib/memplot/Makefile @@ -0,0 +1,38 @@ +# This file is part of NIT ( http://www.nitlanguage.org ). +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +NITC ?= nitc +NITLS ?= nitls +NITUNIT ?= nitunit +NITDOC ?= nitdoc + +.PHONY: all +all: bin/memplot + +bin/memplot: $(shell $(NITLS) -M memplot.nit) + mkdir -p bin/ + $(NITC) memplot.nit -o bin/memplot + +.PHONY: check +check: + $(NITUNIT) . + +.PHONY: doc +doc: + $(NITDOC) . -o doc/ + +.PHONY: clean +clean: + rm -rf bin/ + rm -rf doc/ diff --git a/contrib/memplot/package.ini b/contrib/memplot/package.ini index fa7a860..70ee425 100644 --- a/contrib/memplot/package.ini +++ b/contrib/memplot/package.ini @@ -3,6 +3,7 @@ name=memplot tags=devel maintainer=Jean Privat license=Apache-2.0 +desc=Program to transform `memory.log` files produced by `nitc --trace-memory` into a csv file [upstream] browse=https://github.com/nitlang/nit/tree/master/contrib/memplot/ git=https://github.com/nitlang/nit.git diff --git a/contrib/model_viewer/package.ini b/contrib/model_viewer/package.ini index 27b87f8..397fc2a 100644 --- a/contrib/model_viewer/package.ini +++ b/contrib/model_viewer/package.ini @@ -3,10 +3,11 @@ name=model_viewer tags=example maintainer=Alexis Laferrière license=Apache-2.0 +desc=Sample portable 3D app implemented with the gamnit depth framework [upstream] browse=https://github.com/nitlang/nit/tree/master/contrib/model_viewer/ git=https://github.com/nitlang/nit.git -git.directory=contrib/asteronits/ +git.directory=contrib/model_viewer/ homepage=http://nitlanguage.org issues=https://github.com/nitlang/nit/issues apk=http://nitlanguage.org/fdroid/apk/model_viewer.apk diff --git a/contrib/neo_doxygen/Makefile b/contrib/neo_doxygen/Makefile index d628914..ccda8cb 100644 --- a/contrib/neo_doxygen/Makefile +++ b/contrib/neo_doxygen/Makefile @@ -4,7 +4,7 @@ # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, @@ -12,30 +12,49 @@ # See the License for the specific language governing permissions and # limitations under the License. -NITC=nitc -NITC_FLAGS=--dir bin +NITC ?= nitc +NITLS ?= nitls +NITUNIT ?= nitunit +NITDOC ?= nitdoc + NEO4J_DIR=/var/lib/neo4j OLD_PWD=${PWD} -.PHONY: bin reset-neo run-tests tests +.PHONY: all +all: bin/neo_doxygen + +bin/neo_doxygen: $(shell $(NITLS) -M src/neo_doxygen.nit) + mkdir -p bin/ + $(NITC) src/neo_doxygen.nit -o bin/neo_doxygen -# Compile the tool. -bin: - mkdir -p bin - $(NITC) $(NITC_FLAGS) src/neo_doxygen.nit +.PHONY: check +check: + $(NITUNIT) . # Reset the local graph. +.PHONY: reset-neo reset-neo: sudo -u neo4j "${NEO4J_DIR}/bin/neo4j" stop \ - && sudo -u neo4j rm -rf "${NEO4J_DIR}/data/graph.db" \ - && sudo -u neo4j "${NEO4J_DIR}/bin/neo4j" start + && sudo -u neo4j rm -rf "${NEO4J_DIR}/data/graph.db" \ + && sudo -u neo4j "${NEO4J_DIR}/bin/neo4j" start # Regenerate the XML documents in `tests`. +.PHONY: tests tests: $(MAKE) -C tests # Run the tests. +.PHONY: run-tests run-tests: cd ../../tests; \ - ./tests.sh ../contrib/neo_doxygen/src/tests/neo_doxygen_*.nit ; \ - cd "${OLD_PWD}" + ./tests.sh ../contrib/neo_doxygen/src/tests/neo_doxygen_*.nit ; \ + cd "${OLD_PWD}" + +.PHONY: doc +doc: + $(NITDOC) . -o doc/ + +.PHONY: clean +clean: + rm -rf bin/ + rm -rf doc/ diff --git a/contrib/neo_doxygen/package.ini b/contrib/neo_doxygen/package.ini index 7ca5877..3abb23b 100644 --- a/contrib/neo_doxygen/package.ini +++ b/contrib/neo_doxygen/package.ini @@ -3,6 +3,7 @@ name=neo_doxygen tags=devel,cli maintainer=Jean-Christophe Beaupré license=Apache-2.0 +desc=neo_doxygen, a tool to convert a Doxygen XML output into a Neo4j model [upstream] browse=https://github.com/nitlang/nit/tree/master/contrib/neo_doxygen/ git=https://github.com/nitlang/nit.git diff --git a/contrib/nitcc/package.ini b/contrib/nitcc/package.ini index 900f9d7..29af97c 100644 --- a/contrib/nitcc/package.ini +++ b/contrib/nitcc/package.ini @@ -3,6 +3,7 @@ name=nitcc tags=devel,cli maintainer=Jean Privat license=Apache-2.0 +desc=nitcc, a parser and lexer generator for Nit [upstream] browse=https://github.com/nitlang/nit/tree/master/contrib/nitcc/ git=https://github.com/nitlang/nit.git diff --git a/contrib/nitester/Makefile b/contrib/nitester/Makefile index 86e69e1..0181e51 100644 --- a/contrib/nitester/Makefile +++ b/contrib/nitester/Makefile @@ -1,3 +1,38 @@ -all: +# This file is part of NIT ( http://www.nitlanguage.org ). +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +NITC ?= nitc +NITLS ?= nitls +NITUNIT ?= nitunit +NITDOC ?= nitdoc + +.PHONY: all +all: bin/nitester + +bin/nitester: $(shell $(NITLS) -M src/nitester.nit) mkdir -p bin/ - nitc src/nitester.nit -o bin/nitester + $(NITC) src/nitester.nit -o bin/nitester + +.PHONY: check +check: + $(NITUNIT) . + +.PHONY: doc +doc: + $(NITDOC) . -o doc/ + +.PHONY: clean +clean: + rm -rf bin/ + rm -rf doc/ diff --git a/contrib/nitester/package.ini b/contrib/nitester/package.ini index 8c73e01..351f66d 100644 --- a/contrib/nitester/package.ini +++ b/contrib/nitester/package.ini @@ -3,6 +3,7 @@ name=nitester tags=devel,cli maintainer=Alexis Laferrière license=Apache-2.0 +desc=Tester of Nit engines on an MPI cluster [upstream] browse=https://github.com/nitlang/nit/tree/master/contrib/nitester/ git=https://github.com/nitlang/nit.git diff --git a/contrib/nitin/Makefile b/contrib/nitin/Makefile index 940cee6..7868c4a 100644 --- a/contrib/nitin/Makefile +++ b/contrib/nitin/Makefile @@ -1,3 +1,38 @@ -all: - mkdir -p bin - nitc --semi-global nitin.nit -m readline -o bin/nitin +# This file is part of NIT ( http://www.nitlanguage.org ). +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +NITC ?= nitc +NITLS ?= nitls +NITUNIT ?= nitunit +NITDOC ?= nitdoc + +.PHONY: all +all: bin/nitin + +bin/nitin: $(shell $(NITLS) -M nitin.nit) + mkdir -p bin/ + $(NITC) --semi-global nitin.nit -m readline -o bin/nitin + +.PHONY: check +check: + $(NITUNIT) . + +.PHONY: doc +doc: + $(NITDOC) . -o doc/ + +.PHONY: clean +clean: + rm -rf bin/ + rm -rf doc/ diff --git a/contrib/nitin/README.md b/contrib/nitin/README.md index 9b9648c..1a9ae7d 100644 --- a/contrib/nitin/README.md +++ b/contrib/nitin/README.md @@ -162,7 +162,7 @@ A:bar ### Dynamic importation -~~~ +~~~raw -->print([0..10[.to_a.to_json) 1,20--26: Error: method `to_json` does not exists in `Array[Int]`. print([0..10[.to_a.to_json) diff --git a/contrib/nitin/package.ini b/contrib/nitin/package.ini index f8faf18..363112e 100644 --- a/contrib/nitin/package.ini +++ b/contrib/nitin/package.ini @@ -3,6 +3,7 @@ name=nitin tags=devel maintainer=Jean Privat license=GPL-3.0 +desc=An experimental Nit interactive interpreter [upstream] browse=https://github.com/nitlang/nit/tree/master/contrib/nitin/ git=https://github.com/nitlang/nit.git diff --git a/contrib/nitiwiki/Makefile b/contrib/nitiwiki/Makefile index 19c3811..aa4fa12 100644 --- a/contrib/nitiwiki/Makefile +++ b/contrib/nitiwiki/Makefile @@ -1,17 +1,43 @@ -all: nitiwiki bin/nitiwiki_server +# This file is part of NIT ( http://www.nitlanguage.org ). +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. -nitiwiki: - mkdir -p bin - nitc src/nitiwiki.nit -o bin/nitiwiki +NITC ?= nitc +NITLS ?= nitls +NITUNIT ?= nitunit +NITDOC ?= nitdoc -bin/nitiwiki_server: $(shell nitls -M src/wiki_edit.nit) - nitc -o $@ src/wiki_edit.nit +.PHONY: all +all: bin/nitiwiki bin/wiki_edit -check: nitiwiki +bin/nitiwiki: $(shell $(NITLS) -M src/nitiwiki.nit) + mkdir -p bin/ + $(NITC) src/nitiwiki.nit -o bin/nitiwiki + +bin/wiki_edit: $(shell $(NITLS) -M src/wiki_edit.nit) + mkdir -p bin/ + $(NITC) src/wiki_edit.nit -o bin/wiki_edit + +.PHONY: check +check: bin/nitiwiki + $(NITUNIT) . cd tests; make +.PHONY: doc doc: - nitdoc -d doc src/nitiwiki.nit + $(NITDOC) . -o doc/ +.PHONY: clean clean: - rm -rf bin + rm -rf bin/ + rm -rf doc/ diff --git a/contrib/nitiwiki/README.md b/contrib/nitiwiki/README.md index 757fa36..7324487 100644 --- a/contrib/nitiwiki/README.md +++ b/contrib/nitiwiki/README.md @@ -19,16 +19,18 @@ Features: Basic wiki structure: - root - |- assets - |- out - |- pages - |- templates - | |- footer.html - | |- header.html - | |- menu.html - | `- template.html - `- config.ini +~~~raw +root +|- assets +|- out +|- pages +|- templates +| |- footer.html +| |- header.html +| |- menu.html +| `- template.html +`- config.ini +~~~ ### pages @@ -37,14 +39,16 @@ Nitiwiki will render an article for each markdown file found in `pages`. You can categorize your content in sections using sub-folders: - pages - |- section1 - | `- index.md - |- section2 - | `- index.md - |- page1.md - |- page2.md - `- index.md +~~~raw +pages +|- section1 +| `- index.md +|- section2 +| `- index.md +|- page1.md +|- page2.md +`- index.md +~~~ ### assets @@ -53,10 +57,12 @@ This is where you store CSS and JavaScript files used in the design of your site You can also use this directory to put some images or other files that will be used in all your pages. - assets - |- css - |- js - `- logo.png +~~~raw +assets +|- css +|- js +`- logo.png +~~~ ### templates @@ -88,7 +94,9 @@ This is the main config file of your wiki. For more details see [Configure the w Just move to the directory where you want to store your source files and type: - nitiwiki init +~~~sh +nitiwiki init +~~~ This command will import the base structure of your wiki in the current directory. At this point nitiwiki has created the main configuration file of your site: @@ -201,13 +209,17 @@ This nesting of trails can be used to have sections and sub-sections. Once you have done your changes, use: - nitiwiki --status +~~~sh +nitiwiki --status +~~~ This will show the impacts of your changes on the wiki structure. Then type: - nitiwiki --render +~~~sh +nitiwiki --render +~~~ This will the generate the html output of your new content. The option `--force` can be used to regenerate all the wiki. @@ -256,23 +268,25 @@ Additional macros can be used in specialized templates. The template file `template.html` represents the overall structure of your wiki pages. - - - - %TITLE% - - - - %HEADER% - %TOP_MENU% -
- %TRAIL% - %BODY% - %TRAIL% - %FOOTER% -
- - +~~~html + + + + %TITLE% + + + + %HEADER% + %TOP_MENU% +
+ %TRAIL% + %BODY% + %TRAIL% + %FOOTER% +
+ + +~~~ Additionnal macros: @@ -287,20 +301,24 @@ Additionnal macros: The template file `header.html` is generated on top of all the wiki pages. -
- logo -

%SUBTITLE%

-

%TITLE%

-
+~~~html +
+ logo +

%SUBTITLE%

+

%TITLE%

+
+~~~ ### Footer template The template file `footer.html` is generated on the bottom of all the wiki pages. -
-

%TITLE% © %YEAR%

-

last modification %GEN_TIME%

-
+~~~html +
+

%TITLE% © %YEAR%

+

last modification %GEN_TIME%

+
+~~~ Additionnal macros: @@ -313,21 +331,25 @@ The template file `menu.html` contains the menu structure generated on all your Its content can be static: - +~~~html + +~~~ Or dynamic using the macro `MENUS`: - +~~~html + +~~~ ## Advanced usages @@ -343,7 +365,9 @@ in order to correctly pull changes. To automatically update your wiki when changes are pushed on the origin repository you can use the following command in a git hook: - nitiwiki --fetch --render +~~~sh +nitiwiki --fetch --render +~~~ ### Working with a remote server @@ -358,7 +382,9 @@ after changes or set a cron on a different server that you can control. Using the following command in your cron will update the web server instance from git: - nitiwiki --fetch --render --rsync +~~~sh +nitiwiki --fetch --render --rsync +~~~ Be sure to set `wiki.rsync_dir` in order to correctly push your changes. When using `--rsync`, keep in mind that the rendered output must be configured diff --git a/contrib/nitiwiki/man/nitiwiki.man b/contrib/nitiwiki/man/nitiwiki.man new file mode 100644 index 0000000..796ac52 --- /dev/null +++ b/contrib/nitiwiki/man/nitiwiki.man @@ -0,0 +1,42 @@ +# NAME + +nitiwiki - A wiki engine based on markdown files and git. + +# SYNOPSIS + +nitiwiki [OPTION]... + +# OPTIONS + +### `-h`, `-?`, `--help` +Show this help message. + +### `-v` +Verbose level. + +### `-c`, `--config` +Path to config.ini file. + +### `--init` +Initialize a new wiki in the current directory. + +### `--status` +Display wiki status. + +### `-r`, `--render` +Render the out directory from markdown sources. + +### `-f`, `--force` +Force render even if source files are unchanged. + +### `--clean` +Clean the output directory. + +### `-s`, `--rsync` +Synchronize outdir with distant wiki using rsync. + +### `--fetch` +Render local source from git repo. + +### `--nit-dir` +Nit base directory. \ No newline at end of file diff --git a/contrib/nitiwiki/man/wiki_edit.man b/contrib/nitiwiki/man/wiki_edit.man new file mode 100644 index 0000000..a89bb4d --- /dev/null +++ b/contrib/nitiwiki/man/wiki_edit.man @@ -0,0 +1,24 @@ +# NAME + +wiki_edit - Web server to server generated files and modify the wiki from a web form. + +# SYNOPSIS + +wiki_edit [OPTION]... + +# OPTIONS + +### `-h`, `-?`, `--help` +Show this help message. + +### `-c`, `--config` +Path to config.ini file. + +### `--host` +Host to bind the server to. + +### `--port` +Port to bind the server to. + +### `--pass` +Password file path. \ No newline at end of file diff --git a/contrib/nitiwiki/package.ini b/contrib/nitiwiki/package.ini index 83efead..fe14a72 100644 --- a/contrib/nitiwiki/package.ini +++ b/contrib/nitiwiki/package.ini @@ -3,6 +3,7 @@ name=nitiwiki tags=web,cli maintainer=Alexandre Terrasa license=Apache-2.0 +desc=nitiwiki, a simple wiki manager based on markdown [upstream] browse=https://github.com/nitlang/nit/tree/master/contrib/nitiwiki/ git=https://github.com/nitlang/nit.git diff --git a/contrib/nitiwiki/src/nitiwiki.nit b/contrib/nitiwiki/src/nitiwiki.nit index c5c6ebe..02088a5 100644 --- a/contrib/nitiwiki/src/nitiwiki.nit +++ b/contrib/nitiwiki/src/nitiwiki.nit @@ -17,6 +17,7 @@ module nitiwiki import wiki_html import markdown_highlight +import config # Locate nit directory private fun compute_nit_dir(opt_nit_dir: OptionString): String do @@ -68,7 +69,6 @@ private fun check_nit_dir(res: String): Bool do return res.file_exists and "{res}/src/nit.nit".file_exists end -var opt_help = new OptionBool("Display this help message", "-h", "--help") var opt_verbose = new OptionCount("Verbose level", "-v") var opt_config = new OptionString("Path to config.ini file", "-c", "--config") var opt_init = new OptionBool("Initialize a new wiki in the current directory", "--init") @@ -80,20 +80,25 @@ var opt_rsync = new OptionBool("Synchronize outdir with distant wiki using rsync var opt_fetch = new OptionBool("Render local source from git repo", "--fetch") var opt_nit_dir = new OptionString("Nit base directory", "--nit-dir") -var context = new OptionContext -context.add_option(opt_help, opt_verbose, opt_config) -context.add_option(opt_init, opt_status, opt_render, opt_force) -context.add_option(opt_clean, opt_rsync, opt_fetch, opt_nit_dir) -context.parse(args) +var config = new Config +config.add_option(opt_verbose, opt_config) +config.add_option(opt_init, opt_status, opt_render, opt_force) +config.add_option(opt_clean, opt_rsync, opt_fetch, opt_nit_dir) -var config_filename = "config.ini" +var usage = new Buffer +usage.append "Usage: nitiwiki [OPTION]...\n" +usage.append "A wiki engine based on markdown files and git." +config.tool_description = usage.write_to_string + +config.parse_options(args) -# --help -if opt_help.value then - context.usage +if config.opt_help.value then + config.usage exit 0 end +var config_filename = "config.ini" + # --init if opt_init.value then if config_filename.file_exists then @@ -128,8 +133,8 @@ if not config_file.file_exists then exit 0 end -var config = new WikiConfig(config_file) -var wiki = new Nitiwiki(config) +var wiki_config = new WikiConfig(config_file) +var wiki = new Nitiwiki(wiki_config) # --verbose wiki.verbose_level = opt_verbose.value diff --git a/contrib/nitiwiki/src/wiki_base.nit b/contrib/nitiwiki/src/wiki_base.nit index d3adc26..2e93a74 100644 --- a/contrib/nitiwiki/src/wiki_base.nit +++ b/contrib/nitiwiki/src/wiki_base.nit @@ -16,7 +16,6 @@ module wiki_base import template::macro -import opts import ini # A Nitiwiki instance. diff --git a/contrib/nitiwiki/src/wiki_edit.nit b/contrib/nitiwiki/src/wiki_edit.nit index 7dd6012..3b1abb7 100644 --- a/contrib/nitiwiki/src/wiki_edit.nit +++ b/contrib/nitiwiki/src/wiki_edit.nit @@ -18,6 +18,7 @@ module wiki_edit import nitcorn import markdown import md5 +import config intrude import wiki_html @@ -176,9 +177,29 @@ redef class String end end -var config_file_path = "config.ini" -var iface = "localhost:8080" -var password_file_path = "passwords" +var opt_config = new OptionString("Path to config.ini file", "-c", "--config") +var opt_host = new OptionString("Host to bind the server to", "--host") +var opt_port = new OptionInt("Port to bind the server to", 8000, "--port") +var opt_pass = new OptionString("Password file path", "--pass") + +var config = new Config +config.add_option(opt_config, opt_host, opt_port, opt_pass) + +var usage = new Buffer +usage.append "Usage: wiki_edit [OPTION]...\n" +usage.append "Web server to server generated files and modify the wiki from a web form." +config.tool_description = usage.write_to_string + +config.parse_options(args) + +if config.opt_help.value then + config.usage + exit 0 +end + +var config_file_path = opt_config.value or else "config.ini" +var iface = "{opt_host.value or else "localhost"}:{opt_port.value}" +var password_file_path = opt_pass.value or else "passwords" # Load passwords for file var passwords = if password_file_path.file_exists then diff --git a/contrib/nitrpg/Makefile b/contrib/nitrpg/Makefile index ac3f3a8..0270ede 100644 --- a/contrib/nitrpg/Makefile +++ b/contrib/nitrpg/Makefile @@ -1,7 +1,5 @@ # This file is part of NIT ( http://www.nitlanguage.org ). # -# Copyright 2014-2015 Alexandre Terrasa -# # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at @@ -14,23 +12,31 @@ # See the License for the specific language governing permissions and # limitations under the License. -NITC=nitc -NITU=nitunit +NITC ?= nitc +NITLS ?= nitls +NITUNIT ?= nitunit +NITDOC ?= nitdoc -all: listener web +.PHONY: all +all: bin/listener bin/web -listener: - $(NITC) src/listener.nit +bin/listener: $(shell $(NITLS) -M src/listener.nit) + mkdir -p bin/ + $(NITC) src/listener.nit -o bin/listener -web: - $(NITC) src/web.nit +bin/web: $(shell $(NITLS) -M src/web.nit) + mkdir -p bin/ + $(NITC) src/web.nit -o bin/web +.PHONY: check check: - $(NITU) src/game.nit - $(NITU) src/events.nit - $(NITU) src/statistics.nit - $(NITU) src/achievements.nit - $(NITU) src/listener.nit + $(NITUNIT) . + +.PHONY: doc +doc: + $(NITDOC) . -o doc/ +.PHONY: clean clean: - rm listener web + rm -rf bin/ + rm -rf doc/ diff --git a/contrib/nitrpg/package.ini b/contrib/nitrpg/package.ini index 125e96c..7db8f35 100644 --- a/contrib/nitrpg/package.ini +++ b/contrib/nitrpg/package.ini @@ -3,6 +3,7 @@ name=nitrpg tags=devel,web,cli maintainer=Alexandre Terrasa license=Apache-2.0 +desc=NitRPG, a Role Playing Game that takes place on GitHub [upstream] browse=https://github.com/nitlang/nit/tree/master/contrib/nitrpg/ git=https://github.com/nitlang/nit.git diff --git a/contrib/objcwrapper/package.ini b/contrib/objcwrapper/package.ini index e2ef8d3..45be342 100644 --- a/contrib/objcwrapper/package.ini +++ b/contrib/objcwrapper/package.ini @@ -3,6 +3,7 @@ name=objcwrapper tags=devel,cli maintainer=Alexis Laferrière license=Apache-2.0 +desc=Generator of Nit extern classes to wrap Objective-C services [upstream] browse=https://github.com/nitlang/nit/tree/master/contrib/objcwrapper/ git=https://github.com/nitlang/nit.git diff --git a/contrib/opportunity/package.ini b/contrib/opportunity/package.ini index 5f819b4..1c9c3bd 100644 --- a/contrib/opportunity/package.ini +++ b/contrib/opportunity/package.ini @@ -3,6 +3,7 @@ name=opportunity tags=web maintainer=Lucas Bajolet license=Apache-2.0 +desc=Opportunity is a web-application written in Nit to plan meetups with people in real-life (or on the internet, why not !) [upstream] browse=https://github.com/nitlang/nit/tree/master/contrib/opportunity/ git=https://github.com/nitlang/nit.git diff --git a/contrib/pep8analysis/package.ini b/contrib/pep8analysis/package.ini index bbf3802..ca8155c 100644 --- a/contrib/pep8analysis/package.ini +++ b/contrib/pep8analysis/package.ini @@ -3,6 +3,7 @@ name=pep8analysis tags=educ,web,cli maintainer=Alexis Laferrière license=Apache-2.0 +desc=Pep/8 Analysis, a static checker to detect bugs and bad programming practices in Pep/8 programs [source] exclude=src/parser/parser_abs.nit [upstream] diff --git a/contrib/physical_interface_for_mpd_on_rpi/package.ini b/contrib/physical_interface_for_mpd_on_rpi/package.ini index c844171..8b7473d 100644 --- a/contrib/physical_interface_for_mpd_on_rpi/package.ini +++ b/contrib/physical_interface_for_mpd_on_rpi/package.ini @@ -3,6 +3,7 @@ name=physical_interface_for_mpd_on_rpi tags=embedded,cli maintainer=Alexis Laferrière license=Apache-2.0 +desc=Backend to a hardware interface to control an MPD server from a Raspberry Pi [upstream] browse=https://github.com/nitlang/nit/tree/master/contrib/physical_interface_for_mpd_on_rpi/ git=https://github.com/nitlang/nit.git diff --git a/contrib/re_parser/package.ini b/contrib/re_parser/package.ini index bc61d8c..d03f5a7 100644 --- a/contrib/re_parser/package.ini +++ b/contrib/re_parser/package.ini @@ -3,6 +3,7 @@ name=re_parser tags=re maintainer=Alexandre Terrasa license=Apache-2.0 +desc=RE Parser, a simple API for regular expression parsing [upstream] browse=https://github.com/nitlang/nit/tree/master/contrib/re_parser/ git=https://github.com/nitlang/nit.git diff --git a/contrib/refund/Makefile b/contrib/refund/Makefile index 6cbe02f..eae12aa 100644 --- a/contrib/refund/Makefile +++ b/contrib/refund/Makefile @@ -1,7 +1,5 @@ # This file is part of NIT ( http://www.nitlanguage.org ). # -# Copyright 2015 Alexandre Terrasa -# # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at @@ -14,15 +12,29 @@ # See the License for the specific language governing permissions and # limitations under the License. -all: refund +NITC ?= nitc +NITLS ?= nitls +NITUNIT ?= nitunit +NITDOC ?= nitdoc + +.PHONY: all +all: bin/refund -refund: - mkdir -p bin - nitc src/refund.nit -o bin/refund +bin/refund: $(shell $(NITLS) -M src/refund.nit) + mkdir -p bin/ + $(NITC) src/refund.nit -o bin/refund -check: refund +.PHONY: check +check: bin/refund + $(NITUNIT) . cd tests; make +.PHONY: doc +doc: + $(NITDOC) . -o doc/ + +.PHONY: clean clean: - rm -rf bin + rm -rf bin/ + rm -rf doc/ cd tests; make clean diff --git a/contrib/refund/package.ini b/contrib/refund/package.ini index 9332fd0..1db87a8 100644 --- a/contrib/refund/package.ini +++ b/contrib/refund/package.ini @@ -3,6 +3,7 @@ name=refund tags=example,cli maintainer=Alexandre Terrasa license=Apache-2.0 +desc=Insurance refunds calculation tool [upstream] browse=https://github.com/nitlang/nit/tree/master/contrib/refund/ git=https://github.com/nitlang/nit.git diff --git a/contrib/rss_downloader/Makefile b/contrib/rss_downloader/Makefile index d8371a2..851aff5 100644 --- a/contrib/rss_downloader/Makefile +++ b/contrib/rss_downloader/Makefile @@ -1,3 +1,38 @@ -all: +# This file is part of NIT ( http://www.nitlanguage.org ). +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +NITC ?= nitc +NITLS ?= nitls +NITUNIT ?= nitunit +NITDOC ?= nitdoc + +.PHONY: all +all: bin/rss_downloader + +bin/rss_downloader: $(shell $(NITLS) -M src/rss_downloader.nit) mkdir -p bin/ - nitc --dir bin/ src/*.nit + $(NITC) src/rss_downloader.nit -o bin/rss_downloader + +.PHONY: check +check: + $(NITUNIT) . + +.PHONY: doc +doc: + $(NITDOC) . -o doc/ + +.PHONY: clean +clean: + rm -rf bin/ + rm -rf doc/ diff --git a/contrib/rss_downloader/package.ini b/contrib/rss_downloader/package.ini index 2dee4f0..fb18cfc 100644 --- a/contrib/rss_downloader/package.ini +++ b/contrib/rss_downloader/package.ini @@ -3,6 +3,7 @@ name=rss_downloader tags=network,cli maintainer=Alexis Laferrière license=Apache-2.0 +desc=A tool to download files listed in RSS feeds according to local folders [upstream] browse=https://github.com/nitlang/nit/tree/master/contrib/rss_downloader/ git=https://github.com/nitlang/nit.git diff --git a/contrib/shibuqam/package.ini b/contrib/shibuqam/package.ini index 8c619ad..7b74c42 100644 --- a/contrib/shibuqam/package.ini +++ b/contrib/shibuqam/package.ini @@ -3,6 +3,7 @@ name=shibuqam tags=web maintainer=Jean Privat license=Apache-2.0 +desc=Gather the authenticated users on UQAM websites [upstream] browse=https://github.com/nitlang/nit/tree/master/contrib/shibuqam/ git=https://github.com/nitlang/nit.git diff --git a/contrib/simplan/package.ini b/contrib/simplan/package.ini index 1f4e49a..a2e6f70 100644 --- a/contrib/simplan/package.ini +++ b/contrib/simplan/package.ini @@ -3,6 +3,7 @@ name=simplan tags=ai,example,cli maintainer=Jean Privat license=Apache-2.0 +desc=A simple planning problem solver using A* for a robot that delivers parcels [upstream] browse=https://github.com/nitlang/nit/tree/master/contrib/simplan/ git=https://github.com/nitlang/nit.git diff --git a/contrib/sort_downloads/Makefile b/contrib/sort_downloads/Makefile index 903d020..0f0e026 100644 --- a/contrib/sort_downloads/Makefile +++ b/contrib/sort_downloads/Makefile @@ -1,6 +1,42 @@ -build: +# This file is part of NIT ( http://www.nitlanguage.org ). +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +NITC ?= nitc +NITLS ?= nitls +NITUNIT ?= nitunit +NITDOC ?= nitdoc + +.PHONY: all +all: bin/sort_downloads + +bin/sort_downloads: $(shell $(NITLS) -M src/sort_downloads.nit) mkdir -p bin/ - nitc --dir bin/ src/*.nit + $(NITC) src/sort_downloads.nit -o bin/sort_downloads +.PHONY: install install: install bin/sort_downloads /usr/local/bin/ + +.PHONY: check +check: + $(NITUNIT) . + +.PHONY: doc +doc: + $(NITDOC) . -o doc/ + +.PHONY: clean +clean: + rm -rf bin/ + rm -rf doc/ diff --git a/contrib/sort_downloads/README.md b/contrib/sort_downloads/README.md index 0a42ca2..f366b8c 100644 --- a/contrib/sort_downloads/README.md +++ b/contrib/sort_downloads/README.md @@ -46,18 +46,20 @@ Your old hard drive is full and you bought a new one. You now want to copy your If you need more than one configuration, let's say to sort videos, you can use Nit class refinement. Create a separate Nit module next to `src/sort_downloads.nit` named `sort_videos.nit` and use something like: - #!/usr/bin/env nit +~~~nitish +#!/usr/bin/env nit - import sort_downloads +import sort_downloads - redef class Config - redef fun source_dir do return "/media/new-drive/video-downloads" - redef fun dest_dir do return "/media/new-drive/Videos" - redef fun regex_source_dirs do return ["~/Videos", dest_dir] - redef fun elapsed_days do return 0 - end +redef class Config + redef fun source_dir do return "/media/new-drive/video-downloads" + redef fun dest_dir do return "/media/new-drive/Videos" + redef fun regex_source_dirs do return ["~/Videos", dest_dir] + redef fun elapsed_days do return 0 +end - super # this executes the program +super # this executes the program +~~~ ## Sort only older files diff --git a/contrib/sort_downloads/package.ini b/contrib/sort_downloads/package.ini index 2f75eb3..85721ae 100644 --- a/contrib/sort_downloads/package.ini +++ b/contrib/sort_downloads/package.ini @@ -3,6 +3,7 @@ name=sort_downloads tags=cli maintainer=Alexis Laferrière license=Apache-2.0 +desc=Script to sort content of a folder in many folders according to their names [upstream] browse=https://github.com/nitlang/nit/tree/master/contrib/sort_downloads/ git=https://github.com/nitlang/nit.git diff --git a/contrib/tinks/package.ini b/contrib/tinks/package.ini index cf4f9ee..d4daf5f 100644 --- a/contrib/tinks/package.ini +++ b/contrib/tinks/package.ini @@ -3,6 +3,7 @@ name=tinks tags=game maintainer=Alexis Laferrière license=Apache-2.0 +desc=Tinks! a multiplayer crossplatform action game with destructible procedurally generated worlds [upstream] browse=https://github.com/nitlang/nit/tree/master/contrib/tinks/ git=https://github.com/nitlang/nit.git diff --git a/contrib/tnitter/package.ini b/contrib/tnitter/package.ini index 4d7720f..78e5fc4 100644 --- a/contrib/tnitter/package.ini +++ b/contrib/tnitter/package.ini @@ -3,6 +3,7 @@ name=tnitter tags=web,mobile maintainer=Alexis Laferrière license=Apache-2.0 +desc=Tnitter, a Twitter-like micro-blogging platform [upstream] browse=https://github.com/nitlang/nit/tree/master/contrib/tnitter/ git=https://github.com/nitlang/nit.git diff --git a/contrib/wiringPi/examples/shift.nit b/contrib/wiringPi/examples/shift.nit index abb474f..35101fa 100644 --- a/contrib/wiringPi/examples/shift.nit +++ b/contrib/wiringPi/examples/shift.nit @@ -14,7 +14,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -module wiringPi is example +module shift is example import wiringPi diff --git a/contrib/wiringPi/package.ini b/contrib/wiringPi/package.ini index 8afbf8b..a5d2eb8 100644 --- a/contrib/wiringPi/package.ini +++ b/contrib/wiringPi/package.ini @@ -3,6 +3,7 @@ name=wiringPi tags=embedded,wrapper maintainer=Alexandre Terrasa license=Apache-2.0 +desc=wiringPi nit wrapper [upstream] browse=https://github.com/nitlang/nit/tree/master/contrib/wiringPi/ git=https://github.com/nitlang/nit.git diff --git a/contrib/xymus_net/package.ini b/contrib/xymus_net/package.ini index 249a39a..aa3a3b8 100644 --- a/contrib/xymus_net/package.ini +++ b/contrib/xymus_net/package.ini @@ -3,9 +3,10 @@ name=xymus_net tags=web,example maintainer=Alexis Laferrière license=Apache-2.0 +desc=Web server source and config of xymus.net [upstream] -browse=https://github.com/nitlang/nit/tree/master/contrib/xymus.net/ +browse=https://github.com/nitlang/nit/tree/master/contrib/xymus_net/ git=https://github.com/nitlang/nit.git -git.directory=contrib/xymus.net/ +git.directory=contrib/xymus_net/ homepage=http://xymus.net/ issues=https://github.com/nitlang/nit/issues diff --git a/lib/a_star/tests/test_a_star.nit b/lib/a_star/tests/test_a_star.nit new file mode 100644 index 0000000..1830d08 --- /dev/null +++ b/lib/a_star/tests/test_a_star.nit @@ -0,0 +1,301 @@ +# This file is part of NIT (http://www.nitlanguage.org). +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +module test_a_star is test + +import a_star + +class TestAStar + test + + # Graph + # ~~~raw + # a - b + # / / + # c - d - e + # ~~~ + fun case_simple is test do + var graph = new Graph[NamedNode, Link] + + var na = new NamedNode(graph, "a") + var nb = new NamedNode(graph, "b") + var nc = new NamedNode(graph, "c") + var nd = new NamedNode(graph, "d") + var ne = new NamedNode(graph, "e") + + var lab = new Link(graph, na, nb) + var lac = new Link(graph, na, nc) + var lbd = new Link(graph, nb, nd) + var lcd = new Link(graph, nc, nd) + var lde = new Link(graph, nd, ne) + + var context = new ConstantPathContext(graph) + + var path = na.path_to(ne, 100, context) + assert path_to_string(path) == "c, d, e" + end + + # Graph + # ~~~raw + # a - b + # / / + # c - d e + # ~~~ + fun case_failed is test do + var graph = new Graph[NamedNode,Link] + + var na = new NamedNode(graph, "a") + var nb = new NamedNode(graph, "b") + var nc = new NamedNode(graph, "c") + var nd = new NamedNode(graph, "d") + var ne = new NamedNode(graph, "e") + + var lab = new Link(graph, na, nb) + var lac = new Link(graph, na, nc) + var lbd = new Link(graph, nb, nd) + var lcd = new Link(graph, nc, nd) + + var context = new ConstantPathContext(graph) + + var path = na.path_to(ne, 100, context) + assert path_to_string(path) == null + end + + # Weighted graph + # ~~~raw + # a -2- b + # / / + # 3 1 + # / / + # c -3- d -8- e + # ~~~ + fun case_weighted is test do + var graph = new Graph[NamedNode,WeightedLink] + + var na = new NamedNode(graph, "a") + var nb = new NamedNode(graph, "b") + var nc = new NamedNode(graph, "c") + var nd = new NamedNode(graph, "d") + var ne = new NamedNode(graph, "e") + + var lab = new WeightedLink(graph, na, nb, 2) + var lac = new WeightedLink(graph, na, nc, 3) + var lbd = new WeightedLink(graph, nb, nd, 1) + var lcd = new WeightedLink(graph, nc, nd, 3) + var lde = new WeightedLink(graph, nd, ne, 8) + + var context = new WeightedPathContext(graph) + + var path = na.path_to(ne, 100, context) + assert path_to_string(path) == "b, d, e" + end + + # Weighted graph + # ~~~raw + # a -2- b + # / / + # 3 1 + # / / + # c -3- d -8- e + # ~~~ + fun case_weighted_too_long is test do + var graph = new Graph[NamedNode,WeightedLink] + + var na = new NamedNode(graph, "a") + var nb = new NamedNode(graph, "b") + var nc = new NamedNode(graph, "c") + var nd = new NamedNode(graph, "d") + var ne = new NamedNode(graph, "e") + + var lab = new WeightedLink(graph, na, nb, 2) + var lac = new WeightedLink(graph, na, nc, 3) + var lbd = new WeightedLink(graph, nb, nd, 1) + var lcd = new WeightedLink(graph, nc, nd, 3) + var lde = new WeightedLink(graph, nd, ne, 8) + + var context = new WeightedPathContext(graph) + + var path = na.path_to(ne, 5, context) + assert path_to_string(path) == null + end + + # "Big" weighted graph + # ~~~raw + # + # a -2- b -1- f -1- g + # / / \ / + # 3 1 4 1 + # / / \ / + # c -3- d -8- e -2- h -2- i -3- j + # ~~~ + fun case_weighted_big is test do + var graph = new Graph[NamedNode,WeightedLink] + + var na = new NamedNode(graph, "a") + var nb = new NamedNode(graph, "b") + var nc = new NamedNode(graph, "c") + var nd = new NamedNode(graph, "d") + var ne = new NamedNode(graph, "e") + var nf = new NamedNode(graph, "f") + var ng = new NamedNode(graph, "g") + var nh = new NamedNode(graph, "h") + var ni = new NamedNode(graph, "i") + var nj = new NamedNode(graph, "j") + + var lab = new WeightedLink(graph, na, nb, 2) + var lac = new WeightedLink(graph, na, nc, 3) + var lbd = new WeightedLink(graph, nb, nd, 1) + var lcd = new WeightedLink(graph, nc, nd, 3) + var lde = new WeightedLink(graph, nd, ne, 8) + var lbf = new WeightedLink(graph, nb, nf, 1) + var lfg = new WeightedLink(graph, nf, ng, 1) + var leh = new WeightedLink(graph, ne, nh, 2) + var lhi = new WeightedLink(graph, nh, ni, 2) + var lij = new WeightedLink(graph, ni, nj, 3) + var lfh = new WeightedLink(graph, nf, nh, 4) + var lgh = new WeightedLink(graph, ng, nh, 1) + + var context = new WeightedPathContext(graph) + + var path = na.path_to(nj, 100, context) + assert path_to_string(path) == "b, f, g, h, i, j" + end + + # Double-edge graph with coordinates on nodes + # + # ~~~raw + # a--b--d--e + # \ | + # c------f + # ~~~ + fun cases_with_positions_and_heuristic is test do + var graph = new Graph[PositionedNamedNode,PositionedLink] + + var na = new PositionedNamedNode(graph, "a", 0, 0) + var nb = new PositionedNamedNode(graph, "b", 2, 0) + var nc = new PositionedNamedNode(graph, "c", 2, 2) + var nd = new PositionedNamedNode(graph, "d", 5, 0) + var ne = new PositionedNamedNode(graph, "e", 8, 0) + var nf = new PositionedNamedNode(graph, "f", 8, 2) + + var lab = new PositionedLink(graph, na, nb) + var lac = new PositionedLink(graph, na, nc) + var lbd = new PositionedLink(graph, nb, nd) + var lde = new PositionedLink(graph, nd, ne) + var lef = new PositionedLink(graph, ne, nf) + var lcf = new PositionedLink(graph, nc, nf) + + # inverted + var lba = new PositionedLink(graph, nb, na) + var lca = new PositionedLink(graph, nc, na) + var ldb = new PositionedLink(graph, nd, nb) + var led = new PositionedLink(graph, ne, nd) + var lfe = new PositionedLink(graph, nf, ne) + var lfc = new PositionedLink(graph, nf, nc) + + var context = new PositionPathContext(graph) + + assert path_to_string(na.path_to(nf, 100, context)) == "c, f" + assert path_to_string(nf.path_to(na, 100, context)) == "c, a" + assert path_to_string(nc.path_to(ne, 100, context)) == "f, e" + assert path_to_string(nd.path_to(nc, 100, context)) == "b, a, c" + end + + fun path_to_string(path: nullable AStarPath[NamedNode]): nullable String do + if path == null then + return null + else + var names = new Array[String] + while not path.at_end_of_path do + var step = path.step + names.add(step.name) + end + return names.join(", ") + end + end +end + +#redef class Object +# redef fun debug_a_star do return true +#end + +# Simple node with a name +class NamedNode + super Node + + redef type N: NamedNode + + var name: String + + redef fun to_s do return "node:{name}" +end + +# Node with a name and position +class PositionedNamedNode + super NamedNode + + redef type N: PositionedNamedNode + + var x: Int + var y: Int + + redef fun to_s do return "{super}-at-({x},{y})" + + fun dist_with(o: PositionedNamedNode): Int + do + var dx = o.x - x + var dy = o.y - y + var d2 = dx*dx + dy*dy + return d2.sqrt + end +end + +# Link for nodes with a position +class PositionedLink + super Link + + redef type N: PositionedNamedNode +end + +# Context for a graph with positions +class PositionPathContext + super PathContext + + redef type N: PositionedNamedNode + redef type L: PositionedLink + + init do + super + + for l in graph.links do + var this_cost = cost(l) + if this_cost > worst_cost then worst_cost = this_cost + end + end + + redef var worst_cost = 0 + + redef fun cost(link) do return link.from.dist_with(link.to) + + redef fun is_blocked(link) do return false + + redef fun heuristic_cost(a, b) + do + var cost = a.dist_with(b) + if cost > 100 then return 100 + return cost + end + + redef fun worst_heuristic_cost do return 100 +end diff --git a/lib/base64/tests/test_base64.nit b/lib/base64/tests/test_base64.nit new file mode 100644 index 0000000..3e9c8d2 --- /dev/null +++ b/lib/base64/tests/test_base64.nit @@ -0,0 +1,59 @@ +# This file is part of NIT ( http://www.nitlanguage.org ). +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +module test_base64 is test + +import base64 + +class TestBase64 + test + + fun test_encode is test do + assert "".encode_base64 == "" + assert "f".encode_base64 == "Zg==" + assert "fo".encode_base64 == "Zm8=" + assert "foo".encode_base64 == "Zm9v" + assert "foob".encode_base64 == "Zm9vYg==" + assert "fooba".encode_base64 == "Zm9vYmE=" + assert "foobar".encode_base64 == "Zm9vYmFy" + end + + fun test_decode is test do + assert "".decode_base64.to_s == "" + assert "Zg==".decode_base64.to_s == "f" + assert "Zm8=".decode_base64.to_s == "fo" + assert "Zm9v".decode_base64.to_s == "foo" + assert "Zm9vYg==".decode_base64.to_s == "foob" + assert "Zm9vYmE=".decode_base64.to_s == "fooba" + assert "Zm9vYmFy".decode_base64.to_s == "foobar" + + assert "Zm9vYg".decode_base64.to_s == "foob" + assert "Zm9vYmE".decode_base64.to_s == "fooba" + assert "Zm9v*Yg".decode_base64.to_s == "foob" + end + + fun test_is_base64 is test do + assert "Znm=".is_base64 + assert not "Znm===".is_base64 + assert not "Z.sd=".is_base64 + assert not "Z==D".is_base64 + end + + fun test_check_base64 is test do + assert "Znm=".check_base64 == null + assert "Znm===".check_base64.as(not null).to_s == "Invalid padding length" + assert "Z.sd=".check_base64.as(not null).to_s == "Invalid Base64 character at position 1: ." + assert "Z==D".check_base64.as(not null).to_s == "Invalid padding character D at position 3" + end +end diff --git a/lib/core/stream.nit b/lib/core/stream.nit index 2ecf61b..3fc3f30 100644 --- a/lib/core/stream.nit +++ b/lib/core/stream.nit @@ -599,189 +599,6 @@ redef class Text redef fun write_to(stream) do stream.write(self) end -# Input streams with a buffered input for efficiency purposes -abstract class BufferedReader - super Reader - - redef fun raw_read_byte - do - if last_error != null then return -1 - if eof then - last_error = new IOError("Stream has reached eof") - return -1 - end - var c = _buffer[_buffer_pos] - _buffer_pos += 1 - return c.to_i - end - - # Resets the internal buffer - fun buffer_reset do - _buffer_length = 0 - _buffer_pos = 0 - end - - # Peeks up to `n` bytes in the buffer - # - # The operation does not consume the buffer - # - # ~~~nitish - # var x = new FileReader.open("File.txt") - # assert x.peek(5) == x.read(5) - # ~~~ - fun peek(i: Int): Bytes do - if eof then return new Bytes.empty - var remsp = _buffer_length - _buffer_pos - if i <= remsp then - var bf = new Bytes.with_capacity(i) - bf.append_ns_from(_buffer, i, _buffer_pos) - return bf - end - var bf = new Bytes.with_capacity(i) - bf.append_ns_from(_buffer, remsp, _buffer_pos) - _buffer_pos = _buffer_length - read_intern(i - bf.length, bf) - remsp = _buffer_length - _buffer_pos - var full_len = bf.length + remsp - if full_len > _buffer_capacity then - var c = _buffer_capacity - while c < full_len do c = c * 2 + 2 - _buffer_capacity = c - end - var nns = new CString(_buffer_capacity) - bf.items.copy_to(nns, bf.length, 0, 0) - _buffer.copy_to(nns, remsp, _buffer_pos, bf.length) - _buffer = nns - _buffer_pos = 0 - _buffer_length = full_len - return bf - end - - redef fun read_bytes_to_cstring(buf, i) - do - if last_error != null then return 0 - var bbf = new Bytes(buf, 0, i) - return read_intern(i, bbf) - end - - # Fills `buf` with at most `i` bytes read from `self` - private fun read_intern(i: Int, buf: Bytes): Int do - if eof then return 0 - var p = _buffer_pos - var bufsp = _buffer_length - p - if bufsp >= i then - _buffer_pos += i - buf.append_ns_from(_buffer, i, p) - return i - end - _buffer_pos = _buffer_length - var readln = _buffer_length - p - buf.append_ns_from(_buffer, readln, p) - var rd = read_intern(i - readln, buf) - return rd + readln - end - - redef fun read_all_bytes - do - if last_error != null then return new Bytes.empty - var s = new Bytes.with_capacity(10) - var b = _buffer - while not eof do - var j = _buffer_pos - var k = _buffer_length - var rd_sz = k - j - s.append_ns_from(b, rd_sz, j) - _buffer_pos = k - fill_buffer - end - return s - end - - redef fun append_line_to(s) - do - var lb = new Bytes.with_capacity(10) - loop - # First phase: look for a '\n' - var i = _buffer_pos - while i < _buffer_length and _buffer[i] != 0xAu8 do - i += 1 - end - - var eol - if i < _buffer_length then - assert _buffer[i] == 0xAu8 - i += 1 - eol = true - else - eol = false - end - - # if there is something to append - if i > _buffer_pos then - # Copy from the buffer to the string - var j = _buffer_pos - while j < i do - lb.add(_buffer[j]) - j += 1 - end - _buffer_pos = i - else - assert end_reached - s.append lb.to_s - return - end - - if eol then - # so \n is found - s.append lb.to_s - return - else - # so \n is not found - if end_reached then - s.append lb.to_s - return - end - fill_buffer - end - end - end - - redef fun eof - do - if _buffer_pos < _buffer_length then return false - if end_reached then return true - fill_buffer - return _buffer_pos >= _buffer_length and end_reached - end - - # The buffer - private var buffer: CString = new CString(0) - - # The current position in the buffer - private var buffer_pos = 0 - - # Length of the current buffer (i.e. nuber of bytes in the buffer) - private var buffer_length = 0 - - # Capacity of the buffer - private var buffer_capacity = 0 - - # Fill the buffer - protected fun fill_buffer is abstract - - # Has the last fill_buffer reached the end - protected fun end_reached: Bool is abstract - - # Allocate a `_buffer` for a given `capacity`. - protected fun prepare_buffer(capacity: Int) - do - _buffer = new CString(capacity) - _buffer_pos = 0 # need to read - _buffer_length = 0 - _buffer_capacity = capacity - end -end - # A `Stream` that can be written to and read from abstract class Duplex super Reader diff --git a/lib/github/Makefile b/lib/github/Makefile new file mode 100644 index 0000000..9eb7a69 --- /dev/null +++ b/lib/github/Makefile @@ -0,0 +1,38 @@ +# This file is part of NIT ( http://www.nitlanguage.org ). +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +NITC ?= nitc +NITLS ?= nitls +NITUNIT ?= nitunit +NITDOC ?= nitdoc + +.PHONY: all +all: bin/loader + +bin/loader: $(shell $(NITLS) -M loader.nit) + mkdir -p bin/ + $(NITC) loader.nit -o bin/loader + +.PHONY: check +check: + $(NITUNIT) . + +.PHONY: doc +doc: + $(NITDOC) . -o doc/ + +.PHONY: clean +clean: + rm -rf bin/ + rm -rf doc/ diff --git a/lib/github/man/loader.man b/lib/github/man/loader.man new file mode 100644 index 0000000..833d7c7 --- /dev/null +++ b/lib/github/man/loader.man @@ -0,0 +1,54 @@ +# NAME + +loader - Load a GitHub repo into a MongoDb. + +# SYNOPSIS + +loader + +# OPTIONS + +### `-h`, `-?`, `--help` +Show this help message. + +### `--config` +Path to config file. + +### `--db-host` +MongoDb host. + +### `--db-name` +MongoDb database name. + +### `--tokens` +Token list. + +### `--show-wallet` +Show wallet status. + +### `-v`, `--verbose` +Verbosity level. + +### `--no-colors` +Do not use colors in output. + +### `--show-jobs` +Show jobs status. + +### `--no-commits` +Do not load commits from default branch. + +### `--no-issues` +Do not load issues. + +### `--no-comments` +Do not load issue comments. + +### `--no-events` +Do not load issues events. + +### `--from` +Start loading issues from a number. + +### `--clear` +Clear job for given repo name. \ No newline at end of file diff --git a/lib/markdown/Makefile b/lib/markdown/Makefile index 3dcc1cc..4c3ff0d 100644 --- a/lib/markdown/Makefile +++ b/lib/markdown/Makefile @@ -1,6 +1,38 @@ -NITC=nitc +# This file is part of NIT ( http://www.nitlanguage.org ). +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. -all: nitmd +NITC ?= nitc +NITLS ?= nitls +NITUNIT ?= nitunit +NITDOC ?= nitdoc -nitmd: nitmd.nit - ${NITC} $< +.PHONY: all +all: bin/nitmd + +bin/nitmd: $(shell $(NITLS) -M nitmd.nit) + mkdir -p bin/ + $(NITC) nitmd.nit -o bin/nitmd + +.PHONY: check +check: + $(NITUNIT) . + +.PHONY: doc +doc: + $(NITDOC) . -o doc/ + +.PHONY: clean +clean: + rm -rf bin/ + rm -rf doc/ diff --git a/lib/markdown/man/nitmd.man b/lib/markdown/man/nitmd.man new file mode 100644 index 0000000..9574bd0 --- /dev/null +++ b/lib/markdown/man/nitmd.man @@ -0,0 +1,15 @@ +# NAME + +nitmd - Translate Markdown documents to other formats. + +# SYNOPSIS + +nitmd [-t format] + +# OPTIONS + +### `-h`, `-?`, `--help` +Show this help message. + +### `-t`, `--to` +Specify output format (html, md, man). diff --git a/share/man/Makefile b/share/man/Makefile index b42d869..03a7f0f 100644 --- a/share/man/Makefile +++ b/share/man/Makefile @@ -16,7 +16,7 @@ IN=$(wildcard nit*.md) OUT=$(patsubst %.md,man1/%.1,$(IN)) MARKDOWN=../../lib/markdown -NITMD=$(MARKDOWN)/nitmd +NITMD=$(MARKDOWN)/bin/nitmd all: $(OUT) diff --git a/share/man/nitpackage.md b/share/man/nitpackage.md index f49bf26..122ce85 100644 --- a/share/man/nitpackage.md +++ b/share/man/nitpackage.md @@ -54,6 +54,18 @@ Generate package.ini files. ### `--check-ini` Check package.ini files. +### `--gen-makefile` +Generate Makefile files. + +### `--check-makefile` +Check Makefile files. + +### `--check-man` +Check manpages files. + +### `--gen-man` +Generate manpages files. + ### `-f`, `--force` Force update of existing files. diff --git a/src/doc/commands/tests/test_commands_md.nit b/src/doc/commands/tests/test_commands_md.nit index ab8eecd..941c3b2 100644 --- a/src/doc/commands/tests/test_commands_md.nit +++ b/src/doc/commands/tests/test_commands_md.nit @@ -18,7 +18,7 @@ import test_commands intrude import doc::commands::commands_main import doc::commands::commands_md -class TestCommandsHtml +class TestCommandsMd super TestCommands test diff --git a/src/nitpackage.nit b/src/nitpackage.nit index 0e29e89..bb6fb42 100644 --- a/src/nitpackage.nit +++ b/src/nitpackage.nit @@ -16,6 +16,7 @@ module nitpackage import frontend +import doc::commands::commands_main redef class ToolContext # --expand @@ -30,17 +31,31 @@ redef class ToolContext # --force var opt_force = new OptionBool("Force update of existing files", "-f", "--force") - # README handling phase - var readme_phase: Phase = new ReadmePhase(self, null) + # --check-makefile + var opt_check_makefile = new OptionBool("Check Makefile files", "--check-makefile") + + # --gen-makefile + var opt_gen_makefile = new OptionBool("Generate Makefile files", "--gen-makefile") + + # nitpackage phase + var nitpackage_phase: Phase = new NitPackagePhase(self, null) + + # --check-man + var opt_check_man = new OptionBool("Check manpages files", "--check-man") + + # --gen-man + var opt_gen_man = new OptionBool("Generate manpages files", "--gen-man") redef init do super option_context.add_option(opt_expand, opt_force) option_context.add_option(opt_check_ini, opt_gen_ini) + option_context.add_option(opt_check_makefile, opt_gen_makefile) + option_context.add_option(opt_check_man, opt_gen_man) end end -private class ReadmePhase +private class NitPackagePhase super Phase redef fun process_mainmodule(mainmodule, mmodules) do @@ -60,6 +75,18 @@ private class ReadmePhase continue end + # Check package Makefiles + if toolcontext.opt_check_makefile.value then + mpackage.check_makefile(toolcontext, mainmodule) + continue + end + + # Check manpages + if toolcontext.opt_check_man.value then + mpackage.check_man(toolcontext, mainmodule) + continue + end + # Expand packages if toolcontext.opt_expand.value and not mpackage.is_expanded then var path = mpackage.expand @@ -78,6 +105,21 @@ private class ReadmePhase toolcontext.info("generated INI file `{path}`", 0) end end + + # Create Makefile + if toolcontext.opt_gen_makefile.value then + if not mpackage.has_makefile or toolcontext.opt_force.value then + var path = mpackage.gen_makefile(toolcontext.modelbuilder.model, mainmodule) + if path != null then + toolcontext.info("generated Makefile `{path}`", 0) + end + end + end + + # Create manpages + if toolcontext.opt_gen_man.value then + mpackage.gen_man(toolcontext, mainmodule) + end end end @@ -184,7 +226,8 @@ redef class MPackage "package.name", "package.desc", "package.tags", "package.license", "package.maintainer", "package.more_contributors", "upstream.browse", "upstream.git", "upstream.git.directory", - "upstream.homepage", "upstream.issues" + "upstream.homepage", "upstream.issues", "upstream.apk", "upstream.tryit", + "source.exclude" ] private fun check_ini(toolcontext: ToolContext) do @@ -253,6 +296,222 @@ redef class MPackage ini.save return ini_path end + + # Makefile + + # The path to `self` Makefile + fun makefile_path: nullable String do + var path = package_path + if path == null then return null + if not is_expanded then return null + return path / "Makefile" + end + + # Does `self` have a Makefile? + fun has_makefile: Bool do + var makefile_path = self.makefile_path + if makefile_path == null then return false + return makefile_path.file_exists + end + + private fun check_makefile(toolcontext: ToolContext, mainmodule: MModule) do + var model = toolcontext.modelbuilder.model + var filter = new ModelFilter(accept_example = false, accept_test = false) + var view = new ModelView(model, mainmodule, filter) + + var cmd_bin = new CmdMains(view, mentity = self) + var res_bin = cmd_bin.init_command + if not res_bin isa CmdSuccess then return + + for mmodule in cmd_bin.results.as(not null) do + if not mmodule isa MModule then continue + + if mmodule.makefile_path == null then + toolcontext.warning(location, "missing-makefile", + "Warning: no Makefile for executable module `{mmodule.full_name}`") + end + end + end + + private fun gen_makefile(model: Model, mainmodule: MModule): nullable String do + var filter = new ModelFilter(accept_example = false, accept_test = false) + var view = new ModelView(model, mainmodule, filter) + + var pkg_path = package_path.as(not null) + var makefile_path = makefile_path.as(not null) + + var bins = new Array[String] + var cmd_bin = new CmdMains(view, mentity = self) + var res_bin = cmd_bin.init_command + if res_bin isa CmdSuccess then + for mmodule in cmd_bin.results.as(not null) do + if not mmodule isa MModule then continue + var mmodule_makefile = mmodule.makefile_path + if mmodule_makefile != null and mmodule_makefile != makefile_path then continue + + var file = mmodule.location.file + if file == null then continue + # Remove package path prefix + var bin_path = file.filename + if pkg_path.has_suffix("/") then + bin_path = bin_path.replace(pkg_path, "") + else + bin_path = bin_path.replace("{pkg_path}/", "") + end + bins.add bin_path + end + end + + if bins.is_empty then return null + + var make = new NitMakefile(bins) + make.render.write_to_file(makefile_path) + return makefile_path + end + + # Manpages + + # The path to `self` manpage files + private fun man_path: nullable String do + var path = package_path + if path == null then return null + if not is_expanded then return null + return path / "man" + end + + # Does `self` have a manpage files? + private fun has_man: Bool do + var man_path = self.man_path + if man_path == null then return false + return man_path.file_exists + end + + private fun check_man(toolcontext: ToolContext, mainmodule: MModule) do + var model = toolcontext.modelbuilder.model + var filter = new ModelFilter(accept_example = false, accept_test = false) + var view = new ModelView(model, mainmodule, filter) + + var cmd = new CmdMains(view, mentity = self) + var res = cmd.init_command + if not res isa CmdSuccess then return + + for mmodule in cmd.results.as(not null) do + if not mmodule isa MModule then continue + mmodule.check_man(toolcontext) + end + end + + private fun gen_man(toolcontext: ToolContext, mainmodule: MModule) do + var model = toolcontext.modelbuilder.model + var filter = new ModelFilter(accept_example = false, accept_test = false) + var view = new ModelView(model, mainmodule, filter) + + var cmd = new CmdMains(view, mentity = self) + var res = cmd.init_command + if not res isa CmdSuccess then return + + var pkg_man = man_path.as(not null) + for mmodule in cmd.results.as(not null) do + if not mmodule isa MModule then continue + if not has_man then pkg_man.mkdir + mmodule.gen_man(toolcontext) + end + end +end + +redef class MModule + private fun makefile_path: nullable String do + var file = location.file + if file == null then return null + + var dir = file.filename.dirname + var makefile = (dir / "Makefile") + if not makefile.file_exists then return null + + for line in makefile.to_path.read_lines do + if line.has_prefix("{name}:") then return makefile + end + return null + end + + private fun man_path: nullable String do + var mpackage = self.mpackage + if mpackage == null then return null + var path = mpackage.man_path + if path == null then return null + return path / "{name}.man" + end + + # Does `self` have a manpage? + private fun has_man: Bool do + var man_path = self.man_path + if man_path == null then return false + return man_path.file_exists + end + + private fun make_module(toolcontext: ToolContext): Bool do + var mpackage = self.mpackage + if mpackage == null then return false + if not mpackage.is_expanded then return false + + var pkg_path = mpackage.package_path + if pkg_path == null then return false + + var pr = new ProcessReader("sh", "-c", "cd {pkg_path} && make -Bs bin/{name}") + var out = pr.read_all.trim + pr.close + pr.wait + if pr.status > 0 then + toolcontext.error(location, "unable to compile `{name}`") + print out + return false + end + return true + end + + private fun stub_man(toolcontext: ToolContext): nullable String do + if not make_module(toolcontext) then return null + var mpackage = self.mpackage + if mpackage == null then return null + if not mpackage.is_expanded then return null + + var pkg_path = mpackage.package_path + if pkg_path == null then return null + + var pr = new ProcessReader("{pkg_path}/bin/{name}", "--stub-man") + var man = pr.read_all.trim + pr.close + pr.wait + if pr.status > 0 then + toolcontext.error(location, "unable to run `{pkg_path}/bin/{name} --stub-man`") + print man + return null + end + return man + end + + private fun check_man(toolcontext: ToolContext) do + if not has_man then + toolcontext.error(location, "No manpage for bin {full_name}") + return + end + var man_path = self.man_path.as(not null) + var man = stub_man(toolcontext) + if man == null or man.is_empty then return + + var old_man = new ManPage.from_file(self, man_path) + var new_man = new ManPage.from_string(self, man) + old_man.diff(toolcontext, new_man) + end + + private fun gen_man(toolcontext: ToolContext) do + var man = stub_man(toolcontext) + if man == null or man.is_empty then return + var man_path = self.man_path + if man_path == null then return + man.write_to_file(man_path) + toolcontext.info("created manpage `{man_path}`", 0) + end end redef class ConfigTree @@ -287,6 +546,215 @@ redef class ConfigTree end end +# A Makefile for the Nit project +class NitMakefile + + # Nit files to compile + var nit_files: Array[String] + + # List of rules to add in the Makefile + fun rules: Array[MakeRule] do + var rules = new Array[MakeRule] + + var rule_all = new MakeRule("all", is_phony = true) + rules.add rule_all + + for file in nit_files do + var bin = file.basename.strip_extension + + rule_all.deps.add "bin/{bin}" + + var rule = new MakeRule("bin/{bin}") + rule.deps.add "$(shell $(NITLS) -M {file})" + rule.lines.add "mkdir -p bin/" + rule.lines.add "$(NITC) {file} -o bin/{bin}" + rules.add rule + end + + var rule_check = new MakeRule("check", is_phony = true) + rule_check.lines.add "$(NITUNIT) ." + rules.add rule_check + + var rule_doc = new MakeRule("doc", is_phony = true) + rule_doc.lines.add "$(NITDOC) . -o doc/" + rules.add rule_doc + + var rule_clean = new MakeRule("clean", is_phony = true) + if nit_files.not_empty then + rule_clean.lines.add "rm -rf bin/" + end + rule_clean.lines.add "rm -rf doc/" + rules.add rule_clean + + return rules + end + + # Render `self` + fun render: Writable do + var tpl = new Template + tpl.addn """ +# This file is part of NIT ( http://www.nitlanguage.org ). +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License.\n""" + + if nit_files.not_empty then + tpl.addn "NITC ?= nitc" + tpl.addn "NITLS ?= nitls" + end + tpl.addn "NITUNIT ?= nitunit" + tpl.addn "NITDOC ?= nitdoc" + + for rule in rules do + tpl.add "\n{rule.render.write_to_string}" + end + + return tpl + end +end + +# A rule that goes into a Makefile +class MakeRule + + # Rule name + var name: String + + # Is this rule a `.PHONY` one? + var is_phony: Bool = false is optional + + # Rule dependencies + var deps = new Array[String] + + # Rule lines + var lines = new Array[String] + + # Render `self` + fun render: Writable do + var tpl = new Template + if is_phony then + tpl.addn ".PHONY: {name}" + end + tpl.add "{name}:" + if deps.not_empty then + tpl.add " {deps.join(" ")}" + end + tpl.add "\n" + for line in lines do + tpl.addn "\t{line}" + end + return tpl + end +end + +private class ManPage + var mmodule: MModule + var name: nullable String is noinit + var synopsis: nullable String is noinit + var options = new HashMap[Array[String], String] + + init from_file(mmodule: MModule, file: String) do + from_lines(mmodule, file.to_path.read_lines) + end + + init from_string(mmodule: MModule, string: String) do + from_lines(mmodule, string.split("\n")) + end + + init from_lines(mmodule: MModule, lines: Array[String]) do + init mmodule + + var section = null + for i in [0..lines.length[ do + var line = lines[i] + if line.is_empty then continue + + if line == "# NAME" then + section = "name" + continue + end + if line == "# SYNOPSIS" then + section = "synopsis" + continue + end + if line == "# OPTIONS" then + section = "options" + continue + end + + if section == "name" and name == null then + name = line.trim + end + if section == "synopsis" and synopsis == null then + synopsis = line.trim + end + if section == "options" and line.has_prefix("###") then + var opts = new Array[String] + for opt in line.substring(3, line.length).trim.replace("`", "").split(",") do + opts.add opt.trim + end + var desc = "" + if i < lines.length - 1 then + desc = lines[i + 1].trim + end + options[opts] = desc + end + end + end + + fun diff(toolcontext: ToolContext, ref: ManPage) do + if name != ref.name then + toolcontext.warning(mmodule.location, "diff-man", + "Warning: outdated man description. " + + "Expected `{ref.name or else ""}` got `{name or else ""}`.") + end + if synopsis != ref.synopsis then + toolcontext.warning(mmodule.location, "diff-man", + "Warning: outdated man synopsis. " + + "Expected `{ref.synopsis or else ""}` got `{synopsis or else ""}`.") + end + for name, desc in options do + if not ref.options.has_key(name) then + toolcontext.warning(mmodule.location, "diff-man", + "Warning: unknown man option `{name}`.`") + continue + end + var ref_desc = ref.options[name] + if desc != ref_desc then + toolcontext.warning(mmodule.location, "diff-man", + "Warning: outdated man option description. Expected `{ref_desc}` got `{desc}`.") + end + end + for ref_name, ref_desc in ref.options do + if not options.has_key(ref_name) then + toolcontext.warning(mmodule.location, "diff-man", + "Warning: missing man option `{ref_name}`.`") + end + end + end + + redef fun to_s do + var tpl = new Template + tpl.addn "# NAME" + tpl.addn name or else "" + tpl.addn "# SYNOPSIS" + tpl.addn synopsis or else "" + tpl.addn "# OPTIONS" + for name, desc in options do + tpl.addn " * {name}: {desc}" + end + return tpl.write_to_string + end +end + # build toolcontext var toolcontext = new ToolContext var tpl = new Template diff --git a/src/package.ini b/src/package.ini index c7dae85..703c2ed 100644 --- a/src/package.ini +++ b/src/package.ini @@ -3,11 +3,12 @@ name=nitc tags=devel,cli maintainer=Jean Privat license=Apache-2.0 +desc=Nit compiler and tools [source] exclude=parser/parser_abs.nit:parser/.parser-nofact.nit [upstream] -browse=https://github.com/nitlang/nit/tree/master/src +browse=https://github.com/nitlang/nit/tree/master/src/ git=https://github.com/nitlang/nit.git -git.directory=src +git.directory=src/ homepage=http://nitlanguage.org issues=https://github.com/nitlang/nit/issues diff --git a/tests/sav/test_a_star.res b/tests/sav/test_a_star.res deleted file mode 100644 index 68d57f4..0000000 --- a/tests/sav/test_a_star.res +++ /dev/null @@ -1,9 +0,0 @@ -c, d, e -null path -b, d, e -null path -b, f, g, h, i, j -c, f -c, a -f, e -b, a, c diff --git a/tests/sav/test_base64.res b/tests/sav/test_base64.res deleted file mode 100644 index 06bc37f..0000000 --- a/tests/sav/test_base64.res +++ /dev/null @@ -1,27 +0,0 @@ -: -f: Zg== -fo: Zm8= -foo: Zm9v -foob: Zm9vYg== -fooba: Zm9vYmE= -foobar: Zm9vYmFy -: -Zg==: f -Zm8=: fo -Zm9v: foo -Zm9vYg==: foob -Zm9vYmE=: fooba -Zm9vYmFy: foobar -Zm9vYg: foob -Zm9vYmE: fooba -Zm9v*Yg: foob -: -Znm=.is_base64? true -Znm===.is_base64? false -Z.sd=.is_base64? false -Z==D.is_base64? false -: -Znm=: No error -Znm===: Invalid padding length -Z.sd=: Invalid Base64 character at position 1: . -Z==D: Invalid padding character D at position 3 diff --git a/tests/test_a_star.nit b/tests/test_a_star.nit deleted file mode 100644 index 25936f4..0000000 --- a/tests/test_a_star.nit +++ /dev/null @@ -1,299 +0,0 @@ -module test_a_star - -import a_star - -#redef class Object -# redef fun debug_a_star do return true -#end - -# Simple node with a name -class NamedNode - super Node - - redef type N: NamedNode - - var name: String - - init(graph: Graph[N, Link], name: String) - do - self.name = name - super - end - - redef fun to_s do return "node:{name}" -end - -# Node with a name and position -class PositionedNamedNode - super NamedNode - - redef type N: PositionedNamedNode - - var x: Int - var y: Int - - init(graph: Graph[N, Link], name: String, x, y: Int) - do - super - - self.x = x - self.y = y - end - - redef fun to_s do return "{super}-at-({x},{y})" - - fun dist_with(o: PositionedNamedNode): Int - do - var dx = o.x - x - var dy = o.y - y - var d2 = dx*dx + dy*dy - return d2.sqrt - end -end - -# Link for nodes with a position -class PositionedLink - super Link - - redef type N: PositionedNamedNode -end - -# Context for a graph with positions -class PositionPathContext - super PathContext - - redef type N: PositionedNamedNode - redef type L: PositionedLink - - init(graph: Graph[N,L]) - do - super - - for l in graph.links do - var this_cost = cost(l) - if this_cost > worst_cost then worst_cost = this_cost - end - end - - redef var worst_cost = 0 - - redef fun cost(link) do return link.from.dist_with(link.to) - - redef fun is_blocked(link) do return false - - redef fun heuristic_cost(a, b) - do - var cost = a.dist_with(b) - if cost > 100 then return 100 - return cost - end - - redef fun worst_heuristic_cost do return 100 -end - -fun print_path(path: nullable AStarPath[NamedNode]) do if path == null then - print "null path" -else - var names = new Array[String] - while not path.at_end_of_path do - var step = path.step - names.add(step.name) - end - print names.join(", ") -end - -# Graph -# a - b -# / / -# c - d - e -fun case_simple -do - var graph = new Graph[NamedNode, Link] - - var na = new NamedNode(graph, "a") - var nb = new NamedNode(graph, "b") - var nc = new NamedNode(graph, "c") - var nd = new NamedNode(graph, "d") - var ne = new NamedNode(graph, "e") - - var lab = new Link(graph, na, nb) - var lac = new Link(graph, na, nc) - var lbd = new Link(graph, nb, nd) - var lcd = new Link(graph, nc, nd) - var lde = new Link(graph, nd, ne) - - var context = new ConstantPathContext(graph) - - var path = na.path_to(ne, 100, context) - print_path(path) -end - -# Graph -# a - b -# / / -# c - d e -fun case_failed -do - var graph = new Graph[NamedNode,Link] - - var na = new NamedNode(graph, "a") - var nb = new NamedNode(graph, "b") - var nc = new NamedNode(graph, "c") - var nd = new NamedNode(graph, "d") - var ne = new NamedNode(graph, "e") - - var lab = new Link(graph, na, nb) - var lac = new Link(graph, na, nc) - var lbd = new Link(graph, nb, nd) - var lcd = new Link(graph, nc, nd) - - var context = new ConstantPathContext(graph) - - var path = na.path_to(ne, 100, context) - print_path(path) -end - -# Weighted graph -# a -2- b -# / / -# 3 1 -# / / -# c -3- d -8- e -fun case_weighted -do - var graph = new Graph[NamedNode,WeightedLink] - - var na = new NamedNode(graph, "a") - var nb = new NamedNode(graph, "b") - var nc = new NamedNode(graph, "c") - var nd = new NamedNode(graph, "d") - var ne = new NamedNode(graph, "e") - - var lab = new WeightedLink(graph, na, nb, 2) - var lac = new WeightedLink(graph, na, nc, 3) - var lbd = new WeightedLink(graph, nb, nd, 1) - var lcd = new WeightedLink(graph, nc, nd, 3) - var lde = new WeightedLink(graph, nd, ne, 8) - - var context = new WeightedPathContext(graph) - - var path = na.path_to(ne, 100, context) - print_path(path) -end - -# Weighted graph -# a -2- b -# / / -# 3 1 -# / / -# c -3- d -8- e -fun case_weighted_too_long -do - var graph = new Graph[NamedNode,WeightedLink] - - var na = new NamedNode(graph, "a") - var nb = new NamedNode(graph, "b") - var nc = new NamedNode(graph, "c") - var nd = new NamedNode(graph, "d") - var ne = new NamedNode(graph, "e") - - var lab = new WeightedLink(graph, na, nb, 2) - var lac = new WeightedLink(graph, na, nc, 3) - var lbd = new WeightedLink(graph, nb, nd, 1) - var lcd = new WeightedLink(graph, nc, nd, 3) - var lde = new WeightedLink(graph, nd, ne, 8) - - var context = new WeightedPathContext(graph) - - var path = na.path_to(ne, 5, context) - print_path(path) -end - -# "Big" weighted graph -# -# a -2- b -1- f -1- g -# / / \ / -# 3 1 4 1 -# / / \ / -# c -3- d -8- e -2- h -2- i -3- j -# -fun case_weighted_big -do - var graph = new Graph[NamedNode,WeightedLink] - - var na = new NamedNode(graph, "a") - var nb = new NamedNode(graph, "b") - var nc = new NamedNode(graph, "c") - var nd = new NamedNode(graph, "d") - var ne = new NamedNode(graph, "e") - var nf = new NamedNode(graph, "f") - var ng = new NamedNode(graph, "g") - var nh = new NamedNode(graph, "h") - var ni = new NamedNode(graph, "i") - var nj = new NamedNode(graph, "j") - - var lab = new WeightedLink(graph, na, nb, 2) - var lac = new WeightedLink(graph, na, nc, 3) - var lbd = new WeightedLink(graph, nb, nd, 1) - var lcd = new WeightedLink(graph, nc, nd, 3) - var lde = new WeightedLink(graph, nd, ne, 8) - var lbf = new WeightedLink(graph, nb, nf, 1) - var lfg = new WeightedLink(graph, nf, ng, 1) - var leh = new WeightedLink(graph, ne, nh, 2) - var lhi = new WeightedLink(graph, nh, ni, 2) - var lij = new WeightedLink(graph, ni, nj, 3) - var lfh = new WeightedLink(graph, nf, nh, 4) - var lgh = new WeightedLink(graph, ng, nh, 1) - - var context = new WeightedPathContext(graph) - - var path = na.path_to(nj, 100, context) - print_path(path) -end - -# Double-edge graph with coordinates on nodes -# -# a--b--d--e -# \ | -# c------f -# -fun cases_with_positions_and_heuristic -do - var graph = new Graph[PositionedNamedNode,PositionedLink] - - var na = new PositionedNamedNode(graph, "a", 0, 0) - var nb = new PositionedNamedNode(graph, "b", 2, 0) - var nc = new PositionedNamedNode(graph, "c", 2, 2) - var nd = new PositionedNamedNode(graph, "d", 5, 0) - var ne = new PositionedNamedNode(graph, "e", 8, 0) - var nf = new PositionedNamedNode(graph, "f", 8, 2) - - var lab = new PositionedLink(graph, na, nb) - var lac = new PositionedLink(graph, na, nc) - var lbd = new PositionedLink(graph, nb, nd) - var lde = new PositionedLink(graph, nd, ne) - var lef = new PositionedLink(graph, ne, nf) - var lcf = new PositionedLink(graph, nc, nf) - - # inverted - var lba = new PositionedLink(graph, nb, na) - var lca = new PositionedLink(graph, nc, na) - var ldb = new PositionedLink(graph, nd, nb) - var led = new PositionedLink(graph, ne, nd) - var lfe = new PositionedLink(graph, nf, ne) - var lfc = new PositionedLink(graph, nf, nc) - - var context = new PositionPathContext(graph) - - print_path(na.path_to(nf, 100, context)) - print_path(nf.path_to(na, 100, context)) - print_path(nc.path_to(ne, 100, context)) - print_path(nd.path_to(nc, 100, context)) -end - -case_simple -case_failed -case_weighted -case_weighted_too_long -case_weighted_big -cases_with_positions_and_heuristic diff --git a/tests/test_base64.nit b/tests/test_base64.nit deleted file mode 100644 index fb0d769..0000000 --- a/tests/test_base64.nit +++ /dev/null @@ -1,53 +0,0 @@ -# This file is part of NIT ( http://www.nitlanguage.org ). -# -# Copyright 2013 Alexis Laferrière -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import base64 - -print ":" + "".encode_base64 -print "f: " + "f".encode_base64 -print "fo: " + "fo".encode_base64 -print "foo: " + "foo".encode_base64 -print "foob: " + "foob".encode_base64 -print "fooba: " + "fooba".encode_base64 -print "foobar: " + "foobar".encode_base64 - -print ":" + "".decode_base64.to_s -print "Zg==: " + "Zg==".decode_base64.to_s -print "Zm8=: " + "Zm8=".decode_base64.to_s -print "Zm9v: " + "Zm9v".decode_base64.to_s -print "Zm9vYg==: " + "Zm9vYg==".decode_base64.to_s -print "Zm9vYmE=: " + "Zm9vYmE=".decode_base64.to_s -print "Zm9vYmFy: " + "Zm9vYmFy".decode_base64.to_s - -print "Zm9vYg: " + "Zm9vYg".decode_base64.to_s -print "Zm9vYmE: " + "Zm9vYmE".decode_base64.to_s -print "Zm9v*Yg: " + "Zm9v*Yg".decode_base64.to_s - -print ":" -print "Znm=.is_base64? " + "Znm=".is_base64.to_s -print "Znm===.is_base64? " + "Znm===".is_base64.to_s -print "Z.sd=.is_base64? " + "Z.sd=".is_base64.to_s -print "Z==D.is_base64? " + "Z==D".is_base64.to_s - -print ":" -printn "Znm=: " -print "Znm=".check_base64 or else "No error" -printn "Znm===: " -print "Znm===".check_base64 or else "No error" -printn "Z.sd=: " -print "Z.sd=".check_base64 or else "No error" -printn "Z==D: " -print "Z==D".check_base64 or else "No error"