= Capsium
Capsium: Common architecture for portable secure information interchange and unified management.
Capsium is designed to facilitate the creation, management and deployment of content packages with ease.
This gem provides a structured way to handle content, data, and metadata for various applications.
== Test it out!
Or:
$ wget https://github.com/capsiums/cap-story/releases/download/v0.9.0/story_of_claire-0.9.0.cap $ capsium reactor serve story_of_claire-0.9.0.cap $ open http://localhost:8864
== Building the mn-samples-iso cap package
Download the mn-samples-iso built site: https://github.com/metanorma/mn-samples-iso/actions/runs/8862815829/artifacts/1453746303[mn-samples-iso-Linux].
Then run these commands:
== Installation
To install the Capsium gem, add it to your Gemfile:
Then, run the following command to install it:
Alternatively, you can install the gem directly using:
== What is a Capsium package?
A Capsium package is a structured collection of content, data, metadata, and routing information. It is designed to encapsulate all resources needed for a particular application or service in a well-organized format. A package typically includes:
== What is a Capsium reactor?
A Capsium reactor is a runtime environment that serves Capsium packages. It reads the package configuration and starts a server that can handle HTTP requests according to the routes defined in the package. The reactor ensures that the content and data within the package are served correctly, allowing for easy integration and deployment of packaged applications.
== CLI: Package
To pack a package, you need to define the content, data, metadata, routes, and storage configurations. Once defined, you can use the Capsium command-line interface (CLI) to create and manage your packages.
Capsium provides a CLI to help you pack and manage your packages. Here are some common commands:
capsium package new my_package
capsium package my_package
capsium package add content example.html example.css example.js
capsium package add data animals.yaml
capsium package add metadata name=sample_package version=0.1.0
capsium package add route /=example.html /index=index.html /api/v1/data/animals={type:dataset,name:animals}
=== Packing a package
To pack an existing Capsium package directory, use the following command:
This command will pack your package into a single file with the filename:
{package-name}-{package-version}.cap
{package-path}/metadata.json
pack
command====
unpack
command====
== CLI: Reactor
=== Starting a reactor on your package
To start a Capsium reactor on your package, use the following command:
== Programmatically managing packages
You can also create, load, and use packages programmatically within your Ruby application.
=== Creating packages
require 'capsium'
package = Capsium::Package.new( name: 'sample_package', version: '0.1.0', content: { 'example.html' => 'text/html', 'example.css' => 'text/css', 'example.js' => 'application/javascript' }, data: { 'animals.yaml' => { 'animals' => [ { 'name' => 'Lion', 'type' => 'Mammal', 'habitat' => 'Savannah' }, { 'name' => 'Eagle', 'type' => 'Bird', 'habitat' => 'Mountains' }, { 'name' => 'Shark', 'type' => 'Fish', 'habitat' => 'Ocean' } ] } }, metadata: { 'name' => 'sample_package', 'version' => '0.1.0', 'dependencies' => [] }, routes: { '/' => 'example.html', '/index' => 'index.html', '/index.html' => 'index.html', '/example.css' => 'example.css', '/example.js' => 'example.js', '/api/v1/data/animals' => { 'type' => 'dataset', 'name' => 'animals' } }, storage: { 'datasets' => [ { 'name' => 'animals', 'source' => 'data/animals.yaml', 'format' => 'yaml', 'schema' => 'data/animals_schema.yaml' } ] } )
=== Loading packages
To load an existing package from a JSON file, you can use the Capsium::Package.new(path)
method:
require 'capsium'
package = Capsium::Package.new(path)
=== Using packages in your program
Once you have created or loaded a package, you can use it within your Ruby application to access its content, data, and other properties.
puts "Package Name: #{package.metadata['name']}" puts "Package Version: #{package.metadata['version']}"
package.content.each do |filename, content_type| puts "Content File: #{filename}, Content Type: #{content_type}" end
animals_data = package.data['animals.yaml'] puts "Animals Data: #{animals_data.inspect}"
package.routes.each do |route, destination| puts "Route: #{route}, Destination: #{destination}" end
== Contributing
We welcome contributions to the Capsium gem. If you would like to contribute, please fork the repository and submit a pull request.
=== Running tests
To run the tests, use the following command:
== License
Copyright Ribose.
Capsium is released under the MIT License. See the LICENSE file for more details.