https://github.com/operable/cog-rb
Simple, opinionated library for building Cog bundles in Ruby
https://github.com/operable/cog-rb
Last synced: 11 months ago
JSON representation
Simple, opinionated library for building Cog bundles in Ruby
- Host: GitHub
- URL: https://github.com/operable/cog-rb
- Owner: operable
- License: other
- Created: 2016-05-23T19:47:19.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2017-02-21T20:25:02.000Z (about 9 years ago)
- Last Synced: 2025-04-14T19:56:44.815Z (11 months ago)
- Language: Ruby
- Homepage:
- Size: 62.5 KB
- Stars: 6
- Watchers: 1
- Forks: 2
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.MD
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this 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:
```ruby
#!/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](https://github.com/cog-bundles/format) repository for an example of this library in action.
## Installation
Add this line to your application's Gemfile:
```ruby
gem 'cog-rb'
```
And then execute:
$ bundle
Or install it yourself as:
$ gem install cog-rb