rosetta

RosettaCode helper library for Arturo

rosetta code

rosetta.art

RosettaCode helper for Arturo



What does this package do?

This package provides a comprehensive RosettaCode API wrapper for Arturo, enabling easy interaction with the RosettaCode wiki. It handles authentication, task retrieval, solution parsing, as well as structured access to task content/categories/examples/etc.

How do I use it?

Simply import it and start exploring RosettaCode tasks:

import 'rosetta!

; Connect to RosettaCode
rc: to :Rosetta []!

; Get all implemented tasks for Arturo
tasks: rc\implemented "Arturo"
print ["Arturo has" size tasks "implementations"]

; Get information about a specific task
task: last tasks
print task\description

; Get the Arturo solution
if solution: <= task\solution "Arturo" [
    loop solution\code 'code ->
        print code
]

; Find tasks without Arturo implementation
unimpl: rc\unimplemented "Arturo"
print ["Missing implementations:" size unimpl]

; Get draft tasks
drafts: rc\drafts
print ["Draft tasks:" size drafts]

Type reference

🔹 Rosetta

The main RosettaCode API client

Constructor

to :Rosetta []

Fields

  • \wiki - underlying MediaWiki API client
  • \loggedIn - authentication status

Methods

login

Authenticate with RosettaCode.

login username :string password :string
Returns
  • :logical - true if authentication successful, false otherwise
task

Retrieve task content.

task title :string
Returns
  • :rcTask - task object with parsed content
  • :null - task not found or request failure
implemented

Get all tasks with implementations for given language.

implemented lang :string
Returns
  • :block - array of :rcTask objects
unimplemented

Find all tasks without implementation for given language.

unimplemented lang :string
Returns
  • :block - array of :rcTask objects
drafts

Get draft programming tasks.

drafts
Returns
  • :block - array of :rcTask objects

🔹 rcTask

Represents a RosettaCode task with its content, solutions, and metadata

Constructor

to :rcTask [wiki :MW, title :string]

Fields

  • \wiki - MediaWiki API client reference
  • \title - task title

Methods

content

Get task content, loading from wiki if needed.

content
Returns
  • :string - task wikitext content
  • :null - request failure
draft?

Check if task is a draft.

draft?
Returns
  • :logical - true if task is a draft
  • :null - content not available
description

Get task description.

description
Returns
  • :string - task description (text before first solution)
  • :null - content not available
categories

Get task categories.

categories
Returns
  • :block - array of category names
  • :null - content not available
solutions

Get all language solutions.

solutions
Returns
  • :block - array of :rcSolution objects
  • :null - content not available
solution

Get solution for specific language.

solution lang :string
Returns
  • :rcSolution - solution object for the specified language
  • :null - language not found or content not available

🔹 rcSolution

Represents a language solution with extracted code and output

Constructor

to :rcSolution [language :string, content :string]

Fields

  • \language - programming language name
  • \code - array of extracted code blocks (from <syntaxhighlight> tags)
  • \output - extracted output text (from {{out}} section)

Tip
All task data is lazily loaded and cached! The first call to \content, \solutions, etc. fetches and parses the content, then subsequent calls use the cached data. 😉


License

MIT License

Copyright (c) 2025 Yanis Zafirópulos

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

  -
  
  1
Version
0.1.0Latest
License
MIT

Executable?
No
Requires
Arturo > 0.9.83