Project

cog-rb

0.01
No commit activity in last 3 years
No release in over 3 years
Cog command helper library
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Development

~> 1.11

Runtime

~> 11.2
 Project Readme

cog-rb

Simple, opinionated library for building Cog commands in Ruby.

Usage

First, create a file named cog-command at the top level of your project directory. This file should look something like the following, with format replaced with the name of your bundle:

#!/usr/bin/env ruby

# Make sure we're in the top-level directory for the command
# since so many paths are relative.
Dir.chdir(File.dirname(__FILE__))

require 'bundler/setup'
require 'cog'

Cog.bundle('format')

This file will be the target executable for every command in your bundle. The library handles routing commands to the correct class based on the command name. Note: The permissions on this file must allow it to be run by your Relay.

The class that implements your command should be named the same as your command and should be declared in a namespace named after your bundle within the CogCmd toplevel namespace. For instance, if you had a bundle named test and a command named dump, the class that implements the dump command would be called CogCmd::Test::Dump. The implementation for the command would live in lib/cog_cmd/test/dump.rb relative to the location of your cog-command script.

Examples

See the cog-bundles/format repository for an example of this library in action.

Installation

Add this line to your application's Gemfile:

gem 'cog-rb'

And then execute:

$ bundle

Or install it yourself as:

$ gem install cog-rb