README.md in atd-0.3.1 vs README.md in atd-0.3.2
- old
+ new
@@ -1,8 +1,8 @@
[![build status][build status badge]][build status link] [![coverage report][coverage report badge]][coverage report link] [![gem version][gem version badge]][gem version link] [![documentation coverage][documentation coverage badge]][documentation coverage link]
-[documentation coverage badge]: https://img.shields.io/badge/YARD%20coverage-93.02%-green.svg?style=flat-square
+[documentation coverage badge]: https://img.shields.io/badge/YARD%20coverage-93.18%-green.svg?style=flat-square
[documentation coverage link]: http://izwick-schachter.gitlab.io/atd/YARD/coverage
[build status badge]: https://gitlab.com/izwick-schachter/atd/badges/master/build.svg?style=flat-square
[build status link]: https://gitlab.com/izwick-schachter/atd/commits/master
@@ -17,25 +17,28 @@
- [Installation](#installation)
- [Usage](#usage)
- [Setup](#setup)
- [Routing](#routing)
- [Basic Routing](#basic-routing)
+ - [Serving Files](#serving-files)
- [Advanced Routing](#advanced-routing)
- [DefaultApp](#defaultapp)
- [Inheritance](#inheritance)
+ - [Blocks](#blocks)
- [@http](#http)
+ - [Controllers](#controllers)
- [Apps](#apps)
- [App Creation](#app-creation)
- [Starting the App](#starting-the-app)
- [App Routing](#app-routing)
- [Logging](#logging)
- [Compilation](#compilation)
+- [Design Paradigms](#design-paradigms)
- [Documentation](#documentation)
- [Development](#development)
- [Contributing](#contributing)
-
# ATD
ATD is a new web development backend framework for Ruby. It is built on top of rack, and is meant to be small easy and light. That is why it provides a very minimalist way of writing your backend. It treats a request as a request, without splitting it based on the HTTP method.
## Installation
@@ -62,14 +65,12 @@
$ cd atd
$ bundle exec rake install
This will also allow you to use the current development version (USE WITH CAUTION), and to use that you can `git checkout development` and then `bundle exec rake install`.
-## Usage
+## Setup
-### Setup
-
Setup is as easy as `require "atd"` at the top of whatever file you need it in
## Routing
### Basic Routing
@@ -122,15 +123,25 @@
```ruby
request "/", "Hello World", ignore: :delete
```
+#### Serving Files
+
+All files that you want to serve must be in the `assets` directory if they are, then it is simple to just create a route, and put the filename as the output. For example this will serve `assets/index.html`:
+
+```ruby
+request "/", "index.html"
+```
+
+There are certain modifications which can be made to files between the route being requested and the files being served. That information can be found in the [compilation section](#compilation).
+
### Advanced Routing
#### DefaultApp
-`DefaultApp` is just another app which extends `ATD::App`, it is the app which doesn't have to be written to in `class DefaultApp`, any routes that are created in `main` will be added to `DefaultApp`, well... by default!
+`DefaultApp` is just another app which extends `ATD::App`, it is the app which doesn't have to be written to in `class DefaultApp`, any routes that are created in `main` will be added to `DefaultApp`, well... by default! To find out more about Apps, you can go to the [Apps section](#apps).
#### Inheritance
Whenever you create a route, it is given to an App Class (which inherits from `ATD::App`). This isn't apparent when you create a route in `main`, but even when you do that the route is added to `DefaultApp`. If you are using Apps, than when you create a route in the App Class, that route is given to that Class. When you start the server, it then creates an instance of the App Class and starts it as a rack app. But that is not what the purpose of Apps are.
@@ -195,10 +206,24 @@
@http[:request] # The associated Rack::Request for the request.
```
While you can use `@http[:status_code]` to change the status code, you can also set a status code with `r "/", status_code: 200`. That status code must be >= 100, as per the Rack Specification.
+#### Controllers
+
+ATD also had the capabilities to use controllers. A controller is an object which responds to controller methods, usually a module with `extend self`. Here is an example of an app using controllers:
+
+```ruby
+module MyController
+ def test_route
+ return "You've reached test_route"
+ end
+end
+
+request "/", "MyController#test_route" #=> "You've reached test_route"
+```
+
### Apps
ATD also allows you to use different "apps". Each app is independent of the others and lives is a class with the same name as the app. A file can have any number of apps, each of which can have it's own settings, files, and routes. By default, adding routes to `main` will make them a part of the app `DefaultApp`, which will work fine if you only need one app.
#### App Creation
@@ -265,9 +290,13 @@
end
end
```
The compilation works by going through the file extensions from last to first and running the compilations for each extension in that order. For example `file.html.erb` will first be compiled by the ERB compiler, then the output of the ERB compiler will be compiled by the HTML compiler.
+
+## Design Paradigms
+
+ATD is designed to fit into many different design paradigms, and to allow each person to adopt their own styles while leaving code readable to everyone. Do do this, the code was left fairly unstructured, but [here are a few examples from well known frameworks](https://gitlab.com/izwick-schachter/atd-examples.git).
## Documentation
You can find the YARD docs at http://izwick-schachter.gitlab.io/atd/YARD/.
\ No newline at end of file