https://github.com/gregkrsak/gk-application
A simple state machine framework for creating applications in Ruby. Installable via RubyGems.
https://github.com/gregkrsak/gk-application
ruby state-machine
Last synced: 3 months ago
JSON representation
A simple state machine framework for creating applications in Ruby. Installable via RubyGems.
- Host: GitHub
- URL: https://github.com/gregkrsak/gk-application
- Owner: gregkrsak
- License: other
- Created: 2014-03-09T00:47:47.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2015-04-09T19:28:31.000Z (about 11 years ago)
- Last Synced: 2025-02-18T07:57:17.201Z (over 1 year ago)
- Topics: ruby, state-machine
- Language: Ruby
- Homepage:
- Size: 160 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Gem: gk-application
===================
[](http://badge.fury.io/rb/gk-application)
A simple framework for creating applications in Ruby
----------------------------------------------------
An instance of ```GK::Application``` allows you to easily mange your Ruby application's state, with minimal fuss. Supported states are ```:starting```, ```:running```, ```:stopping``` and ```:stopped```.
Install with gem
----------------
Quick installation with ```gem```:
```bash
gem install gk-application
```
Get started with a new project
------------------------------
Need a project template? No problem:
```bash
ruby -e 'require "rubygems"; require "gk-application"' -e 'GK::Application.new.project'
```
Or using ```irb```:
```
$ irb
irb(main):001:0> require 'rubygems'
=> true
irb(main):002:0> require 'gk-application'
=> true
irb(main):003:0> GK::Application.new.project
=> nil
irb(main):004:0> quit
```
And you'll have a brand-new ```my_app.rb``` ready to go in the current folder!
Here's what an application looks like
-------------------------------------
```ruby
#!/usr/bin/env ruby
require 'gk-application'
my_app = GK::Application.new
my_app.on_starting = proc {
puts 'Starting.'
my_app.state = :running
}
my_app.on_running = proc {
puts 'Running.'
my_app.state = :stopping
}
my_app.on_stopping = proc {
puts 'Stopping.'
my_app.state = :stopped
}
my_app.on_stopped = proc {
puts 'Stopped.'
}
my_app.state = :starting
```