Project

tgauge

0.0
No commit activity in last 3 years
No release in over 3 years
Allows you to build a simple webapp
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.13
~> 10.0

Runtime

>= 4.2.5.1, ~> 4.2
~> 0.7
~> 0.18
~> 0.10.3
>= 1.6.4, ~> 1.6
~> 0.19
 Project Readme

TGauge

TGauge is a lightweight Ruby MVC / ORM gem.

Installation

  1. gem install tgauge

Usage

New Project

  • tgauge new [PROJ NAME]
    • Creates a new project directory with [PROJ NAME] as the name
  • tgauge new [PROJ NAME] true
    • Creates a new project directoryy with [PROJ NAME] with React.js folders
  • tgauge server
    • Runs the server

Generate (g)

  • tgauge g migration [name]
    • Creates an empty SQL file in db/migrations/ with a timestamp.
  • tgauge g controller [name]
    • Creates a controller file with a directory in views.
  • tgauge g model [name]
    • Creates a model file and a migration file.
  • tgauge g component [name] [path]
    • Creates a component file with name at path "./frontend/component/[path]"
  • tgauge g container [name] [path]
    • Creates a container and component file with name at path "./frontend/component/[path]"

Database (db)

  • tgauge db create
    • Sets up the database
  • tgauge db seed
    • Seeds the database from db/seeds
  • tgauge db migrate
    • Runs any migrations in db/migrations/
  • tgauge db reset
    • Creates / migrates / seeds the database

Functionality

Controllers

  • session
    • Controllers have access to the session cookie
  • flash
    • Controllers have access to a flash object that persists the data for only one call.
  • CSRF Protection
    • Each controller authenticates for CSRF attacks. This can be disabled by setting the check_authenticity_token variable to false.

Routes

  • Add the controller's routes through the config/routes.rb
    • The format should be as follows.
      • get Regexp.new("^/MODEL/$"), CONTROLLER, :index
    • You can use get, post, put, and delete routes.

ORM

  • Available functions
    • validates
      • runs the list of functions before each save
Usage:

validates: :method_name1, :method_name2
  • attr_reader
    • Creates a function that gives lets you fetch the data from an instance variable
Usage:

attr_reader :name1, :name2
def [name]
  @name
end
  • attr_accessor
    • Uses attr_reader to create a fetch function for an instance variable.
    • Creates a function that gives lets you set the data from an instance variable.
Usage:

attr_accessor :name1, :name2
def [name]= (val)
  @name = val
end
  • destroy_all
    • Destroys each item in the associated table.
Usage:

Model.destroy_all
  • find
    • Find's a specific item in the associated table with the id of the input.
Usage:

Model.find(id#)
  • all
    • Gets all items in the associated table.
Usage:

Model.all
  • new
    • Creates a new instance of the Model.
Usage:

Model.new(options_hash)
  • save
    • Saves the instance of the Model into the table.
Usage:

Model.new(options_hash).save
  • create
    • Creates a new instance of Model and then saves it.
Usage:

Model.create(options_hash)
  • where
    • Finds items with the condition provided.
Usage:

Model.where(attr: val)
  • Models are able to associate with other models.
    • Models can have a belongs_to association with another model.
    • Models can have a have_many or has_one association with another model.
    • Models can have a through relationship to another model.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/nryulkim/TGauge.