Project

stein

0.0
No commit activity in last 3 years
No release in over 3 years
Write Main modes in separate source files
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.3
>= 0

Runtime

>= 0
 Project Readme

Stein

A micro gem that allows Main modes be written in separate files and magically stitched together.

This may become convenient whem your utility becomes monstrously large:

8-foot-tall (2.4 m), hideously ugly creation, with translucent yellowish skin pulled so taut over the body that it "barely disguised the workings of the vessels and muscles underneath"; watery, glowing eyes, flowing black hair, black lips, and prominent white teeth.

Installation

Add this line to your application's Gemfile:

gem 'stein'

And then execute:

$ bundle

Or install it yourself as:

$ gem install stein

Usage

Start with the main "body" of the utility:

bin/frankenstein

#!/usr/bin/env ruby
require 'main'
require 'stein'

$LIB_DIR = File.dirname(File.dirname __FILE__) + '/lib'

Main {
  description "Show how to build a monster utility from a bunch of modes"
  def run ; help! ; end
  Stein.extend self, $LIB_DIR + '/modes'
}

Then place your modes in lib/modes/:

lib/modes/feed.rb

Stein.mode 'feed' do
  description "Go to the village and steal some food"
  def run
    go(village)
    food = steal
    eat(food)
  end
end

That's it.

API Reference

Stein.mode mode_name, &block: can be used in the top level of a mode-file (a ruby file in modes directory). It delegates itself to Main DSL's mode, eventually.

Stein.extend main_module, modes_directory: loads all modes definitions from the directory.

Acknowledgements

Thanks to Ara T. Howard for Main.

Thanks to Mary Shelly for the book.

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request