No description, website, or topics provided.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
bin
lib
so-fetch
views
.gitignore
Gemfile
Gemfile.lock
README.MD

README.MD

Mover

Mover is a lightweight framework written in Ruby. ControllerBase provides a base controller class, Router provides routing functionality, receiving HTTP requests and responding with the appropriate Views.

ControllerBase

Core Features

By extending ControllerBase, custom controllers have access to the following methods:

  • redirect_to(url): redirects to the url passed in as an argument.
  • render(template_name): uses ERB to evaluate and read templates and passes the rendered html views to render_content.
  • render_content(content, content_type): adds content and content_type arguments in formulation of the response.
  • session: objects saved as cookies to persist in the user's browser.
  • invoke_action(action_name): calls action_name method on the controller through the Router to render a response.
def render(template_name)
  controller_name = self.class.name.underscore
  contents = ERB.new(
    File.read(
      "views/#{controller_name}/#{template_name}.html.erb"
    )
  ).result(binding)

  content_type = "text/html"
  render_content(contents, content_type)
end

Router

Provides functionality to direct requests made to the appropriate Controller actions.

def draw(&proc)
  self.instance_eval(&proc)
end

[:get, :post, :put, :delete].each do |http_method|
  define_method(http_method) do |pattern, controller_class, action_name|
    add_route(
    pattern,
    http_method,
    controller_class,
    action_name)
  end
end

Uses meta-programming and draw to populate the Router with possible routes.

Future Directions for the Project

Configuring Database Access

Using a lightweight ORM, implement a database to be used for rendering data onto templates.

Gem

To create access to Mover through the gem install function.

Views

Create basic templates to demo MVC and ORM.