doc/commands: render `commands_ini` as JSON
authorAlexandre Terrasa <alexandre@moz-code.org>
Wed, 2 May 2018 23:40:23 +0000 (19:40 -0400)
committerAlexandre Terrasa <alexandre@moz-code.org>
Tue, 8 May 2018 19:48:00 +0000 (15:48 -0400)
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

13 files changed:
src/doc/commands/commands_json.nit
src/doc/commands/tests/test_commands_json.nit
src/doc/commands/tests/test_commands_json.sav/test_cmd_ini_clone.res [new file with mode: 0644]
src/doc/commands/tests/test_commands_json.sav/test_cmd_ini_contrib_file.res [new file with mode: 0644]
src/doc/commands/tests/test_commands_json.sav/test_cmd_ini_contrib_file_content.res [new file with mode: 0644]
src/doc/commands/tests/test_commands_json.sav/test_cmd_ini_contributors.res [new file with mode: 0644]
src/doc/commands/tests/test_commands_json.sav/test_cmd_ini_desc.res [new file with mode: 0644]
src/doc/commands/tests/test_commands_json.sav/test_cmd_ini_git.res [new file with mode: 0644]
src/doc/commands/tests/test_commands_json.sav/test_cmd_ini_issues.res [new file with mode: 0644]
src/doc/commands/tests/test_commands_json.sav/test_cmd_ini_license.res [new file with mode: 0644]
src/doc/commands/tests/test_commands_json.sav/test_cmd_ini_license_file.res [new file with mode: 0644]
src/doc/commands/tests/test_commands_json.sav/test_cmd_ini_license_file_content.res [new file with mode: 0644]
src/doc/commands/tests/test_commands_json.sav/test_cmd_ini_maintainer.res [new file with mode: 0644]

index bb04ad8..82571cc 100644 (file)
@@ -19,6 +19,7 @@ import commands::commands_model
 import commands::commands_graph
 import commands::commands_usage
 import commands::commands_catalog
+import commands::commands_ini
 
 import templates::templates_json
 import catalog::catalog_json
@@ -161,3 +162,93 @@ redef class CmdCatalogContributing
                return obj
        end
 end
+
+# CmdIni
+
+redef class CmdIniDescription
+       redef fun to_json do
+               var obj = new JsonObject
+               obj["desc"] = desc
+               return obj
+       end
+end
+
+redef class CmdIniGitUrl
+       redef fun to_json do
+               var obj = new JsonObject
+               obj["url"] = url
+               return obj
+       end
+end
+
+redef class CmdIniCloneCommand
+       redef fun to_json do
+               var obj = new JsonObject
+               obj["command"] = command
+               return obj
+       end
+end
+
+redef class CmdIniIssuesUrl
+       redef fun to_json do
+               var obj = new JsonObject
+               obj["url"] = url
+               return obj
+       end
+end
+
+redef class CmdIniMaintainer
+       redef fun to_json do
+               var obj = new JsonObject
+               obj["maintainer"] = maintainer
+               return obj
+       end
+end
+
+redef class CmdIniContributors
+       redef fun to_json do
+               var obj = new JsonObject
+               obj["contributors"] = contributors
+               return obj
+       end
+end
+
+redef class CmdIniLicense
+       redef fun to_json do
+               var obj = new JsonObject
+               obj["license"] = license
+               return obj
+       end
+end
+
+redef class CmdLicenseFile
+       redef fun to_json do
+               var obj = new JsonObject
+               obj["file"] = file
+               return obj
+       end
+end
+
+redef class CmdLicenseFileContent
+       redef fun to_json do
+               var obj = super.as(JsonObject)
+               obj["content"] = content
+               return obj
+       end
+end
+
+redef class CmdContribFile
+       redef fun to_json do
+               var obj = new JsonObject
+               obj["file"] = file
+               return obj
+       end
+end
+
+redef class CmdContribFileContent
+       redef fun to_json do
+               var obj = super.as(JsonObject)
+               obj["content"] = content
+               return obj
+       end
+end
index be2c235..c5bdd10 100644 (file)
@@ -129,6 +129,78 @@ class TestCommandsJson
                cmd.init_command
                print_json cmd.to_json
        end
+
+       # CmdIni
+
+       fun test_cmd_ini_desc is test do
+               var cmd = new CmdIniDescription(test_view, mentity_name = "test_prog")
+               cmd.init_command
+               print_json cmd.to_json
+       end
+
+       fun test_cmd_ini_git is test do
+               var cmd = new CmdIniGitUrl(test_view, mentity_name = "test_prog")
+               cmd.init_command
+               print_json cmd.to_json
+       end
+
+       fun test_cmd_ini_clone is test do
+               var cmd = new CmdIniCloneCommand(test_view, mentity_name = "test_prog")
+               cmd.init_command
+               print_json cmd.to_json
+       end
+
+       fun test_cmd_ini_issues is test do
+               var cmd = new CmdIniIssuesUrl(test_view, mentity_name = "test_prog")
+               cmd.init_command
+               print_json cmd.to_json
+       end
+
+       fun test_cmd_ini_maintainer is test do
+               var cmd = new CmdIniMaintainer(test_view, mentity_name = "test_prog")
+               cmd.init_command
+               print_json cmd.to_json
+       end
+
+       fun test_cmd_ini_contributors is test do
+               var cmd = new CmdIniContributors(test_view, mentity_name = "test_prog")
+               cmd.init_command
+               print_json cmd.to_json
+       end
+
+       fun test_cmd_ini_license is test do
+               var cmd = new CmdIniLicense(test_view, mentity_name = "test_prog")
+               cmd.init_command
+               print_json cmd.to_json
+       end
+
+       fun test_cmd_ini_license_file is test do
+               var cmd = new CmdLicenseFile(test_view, mentity_name = "test_prog")
+               cmd.init_command
+               cmd.file = cmd.file.as(not null).basename # for testing path
+               print_json cmd.to_json
+       end
+
+       fun test_cmd_ini_license_file_content is test do
+               var cmd = new CmdLicenseFileContent(test_view, mentity_name = "test_prog")
+               cmd.init_command
+               cmd.file = cmd.file.as(not null).basename # for testing path
+               print_json cmd.to_json
+       end
+
+       fun test_cmd_ini_contrib_file is test do
+               var cmd = new CmdContribFile(test_view, mentity_name = "test_prog")
+               cmd.init_command
+               cmd.file = cmd.file.as(not null).basename # for testing path
+               print_json cmd.to_json
+       end
+
+       fun test_cmd_ini_contrib_file_content is test do
+               var cmd = new CmdContribFileContent(test_view, mentity_name = "test_prog")
+               cmd.init_command
+               cmd.file = cmd.file.as(not null).basename # for testing path
+               print_json cmd.to_json
+       end
 end
 
 redef class nitc::Location
diff --git a/src/doc/commands/tests/test_commands_json.sav/test_cmd_ini_clone.res b/src/doc/commands/tests/test_commands_json.sav/test_cmd_ini_clone.res
new file mode 100644 (file)
index 0000000..5b79f05
--- /dev/null
@@ -0,0 +1,3 @@
+{
+       "command": "git clone https://github.com/nitlang/nit.git"
+}
diff --git a/src/doc/commands/tests/test_commands_json.sav/test_cmd_ini_contrib_file.res b/src/doc/commands/tests/test_commands_json.sav/test_cmd_ini_contrib_file.res
new file mode 100644 (file)
index 0000000..3208b3c
--- /dev/null
@@ -0,0 +1,3 @@
+{
+       "file": "CONTRIBUTING.md"
+}
diff --git a/src/doc/commands/tests/test_commands_json.sav/test_cmd_ini_contrib_file_content.res b/src/doc/commands/tests/test_commands_json.sav/test_cmd_ini_contrib_file_content.res
new file mode 100644 (file)
index 0000000..9428e33
--- /dev/null
@@ -0,0 +1,4 @@
+{
+       "file": "CONTRIBUTING.md",
+       "content": "# Contributing rules\n\n* Be nice\n* Be polite\n* Code well\n"
+}
diff --git a/src/doc/commands/tests/test_commands_json.sav/test_cmd_ini_contributors.res b/src/doc/commands/tests/test_commands_json.sav/test_cmd_ini_contributors.res
new file mode 100644 (file)
index 0000000..a0059f2
--- /dev/null
@@ -0,0 +1,3 @@
+{
+       "contributors": ["Riri <riri@example.com>", "Fifi (http://www.example.com/~fifi)", "Loulou"]
+}
diff --git a/src/doc/commands/tests/test_commands_json.sav/test_cmd_ini_desc.res b/src/doc/commands/tests/test_commands_json.sav/test_cmd_ini_desc.res
new file mode 100644 (file)
index 0000000..53d7451
--- /dev/null
@@ -0,0 +1,3 @@
+{
+       "desc": "Dummy program used for testing Nit tools"
+}
diff --git a/src/doc/commands/tests/test_commands_json.sav/test_cmd_ini_git.res b/src/doc/commands/tests/test_commands_json.sav/test_cmd_ini_git.res
new file mode 100644 (file)
index 0000000..35a5579
--- /dev/null
@@ -0,0 +1,3 @@
+{
+       "url": "https://github.com/nitlang/nit.git"
+}
diff --git a/src/doc/commands/tests/test_commands_json.sav/test_cmd_ini_issues.res b/src/doc/commands/tests/test_commands_json.sav/test_cmd_ini_issues.res
new file mode 100644 (file)
index 0000000..d0f97ad
--- /dev/null
@@ -0,0 +1,3 @@
+{
+       "url": "https://github.com/nitlang/nit/issues"
+}
diff --git a/src/doc/commands/tests/test_commands_json.sav/test_cmd_ini_license.res b/src/doc/commands/tests/test_commands_json.sav/test_cmd_ini_license.res
new file mode 100644 (file)
index 0000000..ac64bfe
--- /dev/null
@@ -0,0 +1,3 @@
+{
+       "license": "Apache-2.0"
+}
diff --git a/src/doc/commands/tests/test_commands_json.sav/test_cmd_ini_license_file.res b/src/doc/commands/tests/test_commands_json.sav/test_cmd_ini_license_file.res
new file mode 100644 (file)
index 0000000..900a7ad
--- /dev/null
@@ -0,0 +1,3 @@
+{
+       "file": "LICENSE.md"
+}
diff --git a/src/doc/commands/tests/test_commands_json.sav/test_cmd_ini_license_file_content.res b/src/doc/commands/tests/test_commands_json.sav/test_cmd_ini_license_file_content.res
new file mode 100644 (file)
index 0000000..1ec98c7
--- /dev/null
@@ -0,0 +1,4 @@
+{
+       "file": "LICENSE.md",
+       "content": "# My Custom License\n\nThis is the license content.\n"
+}
diff --git a/src/doc/commands/tests/test_commands_json.sav/test_cmd_ini_maintainer.res b/src/doc/commands/tests/test_commands_json.sav/test_cmd_ini_maintainer.res
new file mode 100644 (file)
index 0000000..226c66d
--- /dev/null
@@ -0,0 +1,3 @@
+{
+       "maintainer": "John Doe <jdoe@example.com> (http://www.example.com/~jdoe), Spider-Man"
+}