Merge: lib/md5: nitunitize tests
authorJean Privat <jean@pryen.org>
Tue, 15 May 2018 22:52:05 +0000 (18:52 -0400)
committerJean Privat <jean@pryen.org>
Tue, 15 May 2018 22:52:05 +0000 (18:52 -0400)
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

Pull-Request: #2694

74 files changed:
.gitignore
contrib/action_nitro/package.ini
contrib/asteronits/package.ini
contrib/benitlux/package.ini
contrib/brainfuck/Makefile [new file with mode: 0644]
contrib/brainfuck/README.md
contrib/brainfuck/package.ini
contrib/github_merge/Makefile [new file with mode: 0644]
contrib/github_merge/github_merge.nit [moved from contrib/github_merge.nit with 93% similarity]
contrib/github_merge/man/github_merge.man [new file with mode: 0644]
contrib/github_merge/package.ini [moved from contrib/github_merge.ini with 75% similarity]
contrib/github_search_for_jni/Makefile
contrib/github_search_for_jni/package.ini
contrib/header_keeper/Makefile
contrib/header_keeper/package.ini
contrib/inkscape_tools/Makefile
contrib/inkscape_tools/package.ini
contrib/jwrapper/package.ini
contrib/memplot/Makefile [new file with mode: 0644]
contrib/memplot/package.ini
contrib/model_viewer/package.ini
contrib/neo_doxygen/Makefile
contrib/neo_doxygen/package.ini
contrib/nitcc/package.ini
contrib/nitester/Makefile
contrib/nitester/package.ini
contrib/nitin/Makefile
contrib/nitin/README.md
contrib/nitin/package.ini
contrib/nitiwiki/Makefile
contrib/nitiwiki/README.md
contrib/nitiwiki/man/nitiwiki.man [new file with mode: 0644]
contrib/nitiwiki/man/wiki_edit.man [new file with mode: 0644]
contrib/nitiwiki/package.ini
contrib/nitiwiki/src/nitiwiki.nit
contrib/nitiwiki/src/wiki_base.nit
contrib/nitiwiki/src/wiki_edit.nit
contrib/nitrpg/Makefile
contrib/nitrpg/package.ini
contrib/objcwrapper/package.ini
contrib/opportunity/package.ini
contrib/pep8analysis/package.ini
contrib/physical_interface_for_mpd_on_rpi/package.ini
contrib/re_parser/package.ini
contrib/refund/Makefile
contrib/refund/package.ini
contrib/rss_downloader/Makefile
contrib/rss_downloader/package.ini
contrib/shibuqam/package.ini
contrib/simplan/package.ini
contrib/sort_downloads/Makefile
contrib/sort_downloads/README.md
contrib/sort_downloads/package.ini
contrib/tinks/package.ini
contrib/tnitter/package.ini
contrib/wiringPi/examples/shift.nit
contrib/wiringPi/package.ini
contrib/xymus_net/package.ini
lib/a_star/tests/test_a_star.nit [new file with mode: 0644]
lib/base64/tests/test_base64.nit [new file with mode: 0644]
lib/core/stream.nit
lib/github/Makefile [new file with mode: 0644]
lib/github/man/loader.man [new file with mode: 0644]
lib/markdown/Makefile
lib/markdown/man/nitmd.man [new file with mode: 0644]
share/man/Makefile
share/man/nitpackage.md
src/doc/commands/tests/test_commands_md.nit
src/nitpackage.nit
src/package.ini
tests/sav/test_a_star.res [deleted file]
tests/sav/test_base64.res [deleted file]
tests/test_a_star.nit [deleted file]
tests/test_base64.nit [deleted file]

index dc1e54b..c4cb96e 100644 (file)
@@ -41,6 +41,8 @@ csrc2/
 lib/*.log
 lib/*.dot
 
+lib/*/bin
+
 examples/*/doc
 examples/*/bin
 
index bcd9ef0..cf42196 100644 (file)
@@ -3,6 +3,7 @@ name=action_nitro
 tags=example
 maintainer=Alexis Laferrière <alexis.laf@xymus.net>
 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
index 2ef165c..e32fcca 100644 (file)
@@ -3,6 +3,7 @@ name=asteronits
 tags=example
 maintainer=Alexis Laferrière <alexis.laf@xymus.net>
 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
index 38eeee8..8ad0390 100644 (file)
@@ -3,6 +3,7 @@ name=benitlux
 tags=mobile,web
 maintainer=Alexis Laferrière <alexis.laf@xymus.net>
 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 (file)
index 0000000..f478a7a
--- /dev/null
@@ -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/
index 8715228..c327550 100644 (file)
@@ -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
 ~~~
index 59c69b6..6522f47 100644 (file)
@@ -3,6 +3,7 @@ name=brainfuck
 tags=language
 maintainer=Lucas Bajolet <r4pass@hotmail.com>
 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 (file)
index 0000000..4ac8326
--- /dev/null
@@ -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/
similarity index 93%
rename from contrib/github_merge.nit
rename to contrib/github_merge/github_merge.nit
index ca61f39..f0717ff 100644 (file)
@@ -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]... <PR number...>\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 (file)
index 0000000..3709f5c
--- /dev/null
@@ -0,0 +1,30 @@
+# NAME
+
+github_merge - Query the Github PR API to perform a merge.
+
+# SYNOPSIS
+
+github_merge [OPTION]... <PR number...>
+
+# 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
similarity index 75%
rename from contrib/github_merge.ini
rename to contrib/github_merge/package.ini
index 8f206bf..ae4f313 100644 (file)
@@ -3,9 +3,10 @@ name=github_merge
 tags=cli
 maintainer=Jean Privat <jean@pryen.org>
 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
index c1c24a0..91bbb76 100644 (file)
@@ -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/
index 0196d6f..41cda29 100644 (file)
@@ -3,6 +3,7 @@ name=github_search_for_jni
 tags=cli
 maintainer=Alexis Laferrière <alexis.laf@xymus.net>
 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
index ca099e4..b8ea6ee 100644 (file)
@@ -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/
index 549bbb6..37939c7 100644 (file)
@@ -3,6 +3,7 @@ name=header_keeper
 tags=devel,cli
 maintainer=Alexis Laferrière <alexis.laf@xymus.net>
 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
index 9ca428b..d66e588 100644 (file)
@@ -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/
index f553cd5..99b3739 100644 (file)
@@ -3,6 +3,7 @@ name=inkscape_tools
 tags=devel,cli
 maintainer=Alexis Laferrière <alexis.laf@xymus.net>
 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
index adaed16..c01dace 100644 (file)
@@ -3,6 +3,7 @@ name=jwrapper
 tags=java,devel,cli
 maintainer=Alexis Laferrière <alexis.laf@xymus.net>
 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 (file)
index 0000000..43f84e6
--- /dev/null
@@ -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/
index fa7a860..70ee425 100644 (file)
@@ -3,6 +3,7 @@ name=memplot
 tags=devel
 maintainer=Jean Privat <jean@pryen.org>
 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
index 27b87f8..397fc2a 100644 (file)
@@ -3,10 +3,11 @@ name=model_viewer
 tags=example
 maintainer=Alexis Laferrière <alexis.laf@xymus.net>
 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
index d628914..ccda8cb 100644 (file)
@@ -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,
 # 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/
index 7ca5877..3abb23b 100644 (file)
@@ -3,6 +3,7 @@ name=neo_doxygen
 tags=devel,cli
 maintainer=Jean-Christophe Beaupré <jcbrinfo@users.noreply.github.com>
 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
index 900f9d7..29af97c 100644 (file)
@@ -3,6 +3,7 @@ name=nitcc
 tags=devel,cli
 maintainer=Jean Privat <jean@pryen.org>
 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
index 86e69e1..0181e51 100644 (file)
@@ -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/
index 8c73e01..351f66d 100644 (file)
@@ -3,6 +3,7 @@ name=nitester
 tags=devel,cli
 maintainer=Alexis Laferrière <alexis.laf@xymus.net>
 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
index 940cee6..7868c4a 100644 (file)
@@ -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/
index 9b9648c..1a9ae7d 100644 (file)
@@ -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)
index f8faf18..363112e 100644 (file)
@@ -3,6 +3,7 @@ name=nitin
 tags=devel
 maintainer=Jean Privat <jean@pryen.org>
 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
index 19c3811..aa4fa12 100644 (file)
@@ -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/
index 757fa36..7324487 100644 (file)
@@ -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.
 
-       <!DOCTYPE html>
-       <html>
-               <head>
-                       <title>%TITLE%</title>
-                       <link href="%ROOT_URL%/assets/css/main.css" rel="stylesheet">
-               </head>
-               <body>
-                       %HEADER%
-                       %TOP_MENU%
-                       <div>
-                               %TRAIL%
-                               %BODY%
-                               %TRAIL%
-                               %FOOTER%
-                       </div>
-               </body>
-       </html>
+~~~html
+<!DOCTYPE html>
+<html>
+       <head>
+               <title>%TITLE%</title>
+               <link href="%ROOT_URL%/assets/css/main.css" rel="stylesheet">
+       </head>
+       <body>
+               %HEADER%
+               %TOP_MENU%
+               <div>
+                       %TRAIL%
+                       %BODY%
+                       %TRAIL%
+                       %FOOTER%
+               </div>
+       </body>
+</html>
+~~~
 
 Additionnal macros:
 
@@ -287,20 +301,24 @@ Additionnal macros:
 
 The template file `header.html` is generated on top of all the wiki pages.
 
-       <header>
-               <a href="#"><img src="%ROOT_URL%/%LOGO%" alt="logo"/></a>
-               <h2>%SUBTITLE%</h2>
-               <h1>%TITLE%</h1>
-       </header>
+~~~html
+<header>
+       <a href="#"><img src="%ROOT_URL%/%LOGO%" alt="logo"/></a>
+       <h2>%SUBTITLE%</h2>
+       <h1>%TITLE%</h1>
+</header>
+~~~
 
 ### Footer template
 
 The template file `footer.html` is generated on the bottom of all the wiki pages.
 
-       <footer>
-               <p>%TITLE% &copy; %YEAR%</p>
-               <p>last modification %GEN_TIME%</p>
-       </footer>
+~~~html
+<footer>
+       <p>%TITLE% &copy; %YEAR%</p>
+       <p>last modification %GEN_TIME%</p>
+</footer>
+~~~
 
 Additionnal macros:
 
@@ -313,21 +331,25 @@ The template file `menu.html` contains the menu structure generated on all your
 
 Its content can be static:
 
-       <nav class="menu">
-               <ul class="nav navbar-nav">
-                       <li><a href="#">Home</a></li>
-                       <li><a href="#">Page1</a></li>
-                       <li><a href="#">Page2</a></li>
-               </ul>
-       </nav>
+~~~html
+<nav class="menu">
+       <ul class="nav navbar-nav">
+               <li><a href="#">Home</a></li>
+               <li><a href="#">Page1</a></li>
+               <li><a href="#">Page2</a></li>
+       </ul>
+</nav>
+~~~
 
 Or dynamic using the macro `MENUS`:
 
-       <nav class="menu">
-               <ul class="nav navbar-nav">
-               %MENUS%
-               </ul>
-       </nav>
+~~~html
+<nav class="menu">
+       <ul class="nav navbar-nav">
+       %MENUS%
+       </ul>
+</nav>
+~~~
 
 ## 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 (file)
index 0000000..796ac52
--- /dev/null
@@ -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 (file)
index 0000000..a89bb4d
--- /dev/null
@@ -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
index 83efead..fe14a72 100644 (file)
@@ -3,6 +3,7 @@ name=nitiwiki
 tags=web,cli
 maintainer=Alexandre Terrasa <alexandre@moz-code.org>
 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
index c5c6ebe..02088a5 100644 (file)
@@ -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
index d3adc26..2e93a74 100644 (file)
@@ -16,7 +16,6 @@
 module wiki_base
 
 import template::macro
-import opts
 import ini
 
 # A Nitiwiki instance.
index 7dd6012..3b1abb7 100644 (file)
@@ -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
index ac3f3a8..0270ede 100644 (file)
@@ -1,7 +1,5 @@
 # This file is part of NIT ( http://www.nitlanguage.org ).
 #
-# Copyright 2014-2015 Alexandre Terrasa <alexandre@moz-code.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
 # 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/
index 125e96c..7db8f35 100644 (file)
@@ -3,6 +3,7 @@ name=nitrpg
 tags=devel,web,cli
 maintainer=Alexandre Terrasa <alexandre@moz-code.org>
 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
index e2ef8d3..45be342 100644 (file)
@@ -3,6 +3,7 @@ name=objcwrapper
 tags=devel,cli
 maintainer=Alexis Laferrière <alexis.laf@xymus.net>
 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
index 5f819b4..1c9c3bd 100644 (file)
@@ -3,6 +3,7 @@ name=opportunity
 tags=web
 maintainer=Lucas Bajolet <r4pass@hotmail.com>
 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
index bbf3802..ca8155c 100644 (file)
@@ -3,6 +3,7 @@ name=pep8analysis
 tags=educ,web,cli
 maintainer=Alexis Laferrière <alexis.laf@xymus.net>
 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]
index c844171..8b7473d 100644 (file)
@@ -3,6 +3,7 @@ name=physical_interface_for_mpd_on_rpi
 tags=embedded,cli
 maintainer=Alexis Laferrière <alexis.laf@xymus.net>
 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
index bc61d8c..d03f5a7 100644 (file)
@@ -3,6 +3,7 @@ name=re_parser
 tags=re
 maintainer=Alexandre Terrasa <alexandre@moz-code.org>
 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
index 6cbe02f..eae12aa 100644 (file)
@@ -1,7 +1,5 @@
 # This file is part of NIT ( http://www.nitlanguage.org ).
 #
-# Copyright 2015 Alexandre Terrasa <alexandre@moz-code.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
 # 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
index 9332fd0..1db87a8 100644 (file)
@@ -3,6 +3,7 @@ name=refund
 tags=example,cli
 maintainer=Alexandre Terrasa <alexandre@moz-code.org>
 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
index d8371a2..851aff5 100644 (file)
@@ -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/
index 2dee4f0..fb18cfc 100644 (file)
@@ -3,6 +3,7 @@ name=rss_downloader
 tags=network,cli
 maintainer=Alexis Laferrière <alexis.laf@xymus.net>
 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
index 8c619ad..7b74c42 100644 (file)
@@ -3,6 +3,7 @@ name=shibuqam
 tags=web
 maintainer=Jean Privat <jean@pryen.org>
 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
index 1f4e49a..a2e6f70 100644 (file)
@@ -3,6 +3,7 @@ name=simplan
 tags=ai,example,cli
 maintainer=Jean Privat <jean@pryen.org>
 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
index 903d020..0f0e026 100644 (file)
@@ -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/
index 0a42ca2..f366b8c 100644 (file)
@@ -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
 
index 2f75eb3..85721ae 100644 (file)
@@ -3,6 +3,7 @@ name=sort_downloads
 tags=cli
 maintainer=Alexis Laferrière <alexis.laf@xymus.net>
 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
index cf4f9ee..d4daf5f 100644 (file)
@@ -3,6 +3,7 @@ name=tinks
 tags=game
 maintainer=Alexis Laferrière <alexis.laf@xymus.net>
 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
index 4d7720f..78e5fc4 100644 (file)
@@ -3,6 +3,7 @@ name=tnitter
 tags=web,mobile
 maintainer=Alexis Laferrière <alexis.laf@xymus.net>
 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
index abb474f..35101fa 100644 (file)
@@ -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
 
index 8afbf8b..a5d2eb8 100644 (file)
@@ -3,6 +3,7 @@ name=wiringPi
 tags=embedded,wrapper
 maintainer=Alexandre Terrasa <alexandre@moz-code.org>
 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
index 249a39a..aa3a3b8 100644 (file)
@@ -3,9 +3,10 @@ name=xymus_net
 tags=web,example
 maintainer=Alexis Laferrière <alexis.laf@xymus.net>
 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 (file)
index 0000000..1830d08
--- /dev/null
@@ -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 (file)
index 0000000..3e9c8d2
--- /dev/null
@@ -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
index 2ecf61b..3fc3f30 100644 (file)
@@ -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 (file)
index 0000000..9eb7a69
--- /dev/null
@@ -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 (file)
index 0000000..833d7c7
--- /dev/null
@@ -0,0 +1,54 @@
+# NAME
+
+loader - Load a GitHub repo into a MongoDb.
+
+# SYNOPSIS
+
+loader <repo_name>
+
+# 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
index 3dcc1cc..4c3ff0d 100644 (file)
@@ -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 (file)
index 0000000..9574bd0
--- /dev/null
@@ -0,0 +1,15 @@
+# NAME
+
+nitmd - Translate Markdown documents to other formats.
+
+# SYNOPSIS
+
+nitmd [-t format] <file.md>
+
+# OPTIONS
+
+### `-h`, `-?`, `--help`
+Show this help message.
+
+### `-t`, `--to`
+Specify output format (html, md, man).
index b42d869..03a7f0f 100644 (file)
@@ -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)
 
index f49bf26..122ce85 100644 (file)
@@ -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.
 
index ab8eecd..941c3b2 100644 (file)
@@ -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
 
index 0e29e89..bb6fb42 100644 (file)
@@ -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
index c7dae85..703c2ed 100644 (file)
@@ -3,11 +3,12 @@ name=nitc
 tags=devel,cli
 maintainer=Jean Privat <jean@pryen.org>
 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 (file)
index 68d57f4..0000000
+++ /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 (file)
index 06bc37f..0000000
+++ /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 (file)
index 25936f4..0000000
+++ /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 (file)
index fb0d769..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-# This file is part of NIT ( http://www.nitlanguage.org ).
-#
-# Copyright 2013 Alexis Laferrière <alexis.laf@xymus.net>
-#
-# 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"