Skip to content
Ukagaka SHIORI subsystem 'Sana' MVC Helper
Ruby
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
lib
spec
.gitignore
.rspec
.travis.yml
Gemfile
README.md
Rakefile
appveyor.yml
sana-mvcbase.gemspec

README.md

Sana MVC Base

Gem Gem Gemnasium Inch CI Travis Build Status AppVeyor Build Status codecov.io Code Climate

Ukagaka SHIORI subsystem 'Sana' MVC Helper

Installation

Add this line to your application's Gemfile:

gem 'sana-mvcbase'

And then execute:

$ bundle

Or install it yourself as:

$ gem install sana-mvcbase

Usage

require 'sana-mvcbase'
require 'shiolink'

# define controllers

# for load(), unload()
class DLController < SanaController
  def _load(dirpath)
    MySave.load
    p dirpath
  end

  def _unload
    p :unload
  end
end

# view rendering module
module MyViewModule
  def render_response(name)
    MyView.talk(name || event_id)
  end
end

# view rendering base controller
class MyWithViewController < SanaAnyEventController
  include MyViewModule
end

# normal talk controller
class TalkEventsController < MyWithViewController
  def OnBoot
    @foo = MySave.foo_flag
    @bar = MyModel.bar(params.shell_name)
  end

  def OnFirstBoot
    @foo = MySave.foo_flag
    render :OnBoot
  end
end

# resource controller
class ResourcesController < SanaController
  def homeurl
    "http://www.example.com/foo/"
  end
end

# register routing

router = SanaRouter.new(TalkEventsController)
router.draw do
  controller DLController do
    load
    unload
  end

  controller ResourcesController do
    route :homeurl
  end

  route :OnBoot, {shell_name: 0, halted: 6, halted_ghost_name: 7}

  # OnFirstBoot is not registered but will called with default controller (= TalkEventsController)
end

# app start

sana = Sana.new(router.events)
shiolink = Shiolink.new(sana.method(:load), sana.method(:unload), sana.method(:request))
shiolink.start

API

API Document

License

This is released under MIT License.

You can’t perform that action at this time.