Project

ground

0.0
No commit activity in last 3 years
No release in over 3 years
A simple ruby web framework
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies
 Project Readme

Gem Version

Ground

Ground is a web framework, no controller, no model, no views and no mvc. Most of the ground codes are inherited from Dun::Activity. So ground is a high unified web framework.

install

gem install ground

or in Gemfile:

gem 'ground'

states

  class SiteIndex < Ground::State
    def call
	  text 'Site Index'
	end
  end

  module Book
    State = Ground::State

    class Index < State
	  def call
	    @books = Book.all
		html erb('views/book/index.html.erb')
	  end
	end

    class Show < State
	  def call
	    @book = Book.find(params[:id])
		html erb('views/book/show.html.erb')
	  end
	end

    class Create < State
	  def call
	    @book = Book.create(params[:book])
		rediret '/books'
	  end
	end

  end

routes

  Ground do
    get '/', SiteIndex
	get '/books', Book::Index
	get '/book/:id', Book::Show
	post '/book', Book::Create
  end

route helpers

  SiteIndex.path     # '/'
  Book::Index.path   # '/books'
  Book::Show.path(2) # '/book/2'
  Book::Create.path  # '/book'

sets

  Ground do
    set :env, (ENV['RACK_ENV'] || 'development').to_s
	set :logger, ::Logger.new(STDOUT)
  en

  Ground.env #=> development
  Ground.logger.info("debug+++")

helpers

  # Book::Index, Book::Show will hava instance method 'hello_ground'
  Ground do
    help Book::Index, Book::Show do

	  def hello_ground
	    'hello ground'
	  end

	end
  end

create a ground app

  module BookStore
	App = Ground 'book store' do
	  use Rack::ShowExceptions
	  use Rack::Static, urls: ['/js', '/css', '/lib', '/partials'], :root => "lib/app"
	  ...
	end
  end

config.ru

  $: << '.'
  require 'app'
  run BookStore::App

Apps using ground