README.md in lotusrb-0.2.1 vs README.md in lotusrb-0.3.0
- old
+ new
@@ -2,21 +2,23 @@
A complete web framework for Ruby
## Frameworks
-Lotus combines together small but yet powerful frameworks:
+Lotus combines small yet powerful frameworks:
* [**Lotus::Utils**](https://github.com/lotus/utils) - Ruby core extentions and class utilities
* [**Lotus::Router**](https://github.com/lotus/router) - Rack compatible HTTP router for Ruby
* [**Lotus::Validations**](https://github.com/lotus/validations) - Validation mixin for Ruby objects
+* [**Lotus::Helpers**](https://github.com/lotus/helpers) - View helpers for Ruby applications
* [**Lotus::Model**](https://github.com/lotus/model) - Persistence with entities, repositories and data mapper
* [**Lotus::View**](https://github.com/lotus/view) - Presentation with a separation between views and templates
+* [**Lotus::Helpers**](https://github.com/lotus/helpers) - Presentation helpers for views
* [**Lotus::Controller**](https://github.com/lotus/controller) - Full featured, fast and testable actions for Rack
-All those components are designed to be used independently from each other or to work together in a Lotus application.
-If your aren't familiar with them, please take time to go through their READMEs.
+These components are designed to be used independently or together in a Lotus application.
+If you aren't familiar with them, please take time to go through their READMEs.
## Status
[![Gem Version](https://badge.fury.io/rb/lotusrb.png)](http://badge.fury.io/rb/lotusrb)
[![Build Status](https://secure.travis-ci.org/lotus/lotus.png?branch=master)](http://travis-ci.org/lotus/lotus?branch=master)
@@ -30,11 +32,12 @@
* Home page: http://lotusrb.org
* Mailing List: http://lotusrb.org/mailing-list
* API Doc: http://rdoc.info/gems/lotusrb
* Bugs/Issues: https://github.com/lotus/lotus/issues
* Support: http://stackoverflow.com/questions/tagged/lotus-ruby
-* Chat: https://gitter.im/lotus/chat
+* Forum: https://discuss.lotusrb.org
+* Chat: http://chat.lotusrb.org
## Rubies
__Lotus__ supports Ruby (MRI) 2+
@@ -60,47 +63,46 @@
Unlike other Ruby web frameworks, Lotus has **flexible conventions for code structure**.
Developers can arrange the layout of their projects as they prefer.
There is a suggested architecture that can be easily changed with a few settings.
Lotus encourages the use of Ruby namespaces. This is based on the experience of working on dozens of projects.
-By using Ruby namespaces, as your code grows it can be split with less effort. In other words, Lotus is providing gentle guidance for **avoid monolithic applications**.
+By using Ruby namespaces, as your code grows it can be split with less effort. In other words, Lotus is providing gentle guidance for **avoiding monolithic applications**.
Lotus has a smart **mechanism of duplication of its frameworks**.
It allows multiple copies of the framework and multiple applications to run in the **same Ruby process**.
-In other words, Lotus applications are ready to be split into smaller parts but these parts can coexist in the same heap space.
+In other words, Lotus applications are ready to be split into smaller parts, but these parts can coexist in the same heap space.
-All this adaptability can be helpful to bend the framework for your advanced needs, but we recognize the need of a guidance in standard architectures.
+All this adaptability can be helpful to bend the framework for your advanced requirements, but we recognize the need for guidance in standard architectures.
For this reason Lotus is shipped with code generators.
### _Container_ architecture
**TL;DR: Develop your application like a gem. Implement use cases in `lib/`. Use one or more Lotus applications in `apps/`.**
-This is the default architecture.
-When your are about to start a new project use it.
+This is the default architecture. Use it when you are ready to begin a new project.
The core of this architecture lives in `lib/`, where developers should build features **independently from the delivery mechanism**.
-Imagine you are building a personal finance application, and you have a feature called _"register expense"_. This functionality involves `Money` and `Expense` Ruby objects and the need of persisting data into a database. You can have those classes living in `lib/pocket/money.rb` and `lib/pocket/expense.rb` and use [Lotus::Model](https://github.com/lotus/model) to persist them.
+Imagine you are building a personal finance application, and you have a feature called _"register expense."_ This functionality involves `Money` and `Expense` Ruby objects and the need for persisting data into a database. You can have those classes living in `lib/pocket/money.rb` and `lib/pocket/expense.rb` and use [Lotus::Model](https://github.com/lotus/model) to persist them.
It's based on a few simple concepts: **use cases** and **applications**.
Use cases (features) should be implemented in `lib/` with a combination of pure objects and the needed Ruby gems.
-One or more Lotus applications live in `apps/`. They are isolated each other, and depend only on the code in `lib/`.
+One or more Lotus applications live in `apps/`. They are isolated from each other, and depend only on the code in `lib/`.
-Each of them should serve for only one purpose: user facing web application, administrative backend, JSON API, metrics dashboard, etc.
+Each application should serve only one purpose: user-facing web application, administrative backend, JSON API, metrics dashboard, etc.
This architecture has important advantages:
- * **Code reusability.** You can consume a feature from the Web UI or from a HTTP API. Each one can be different Lotus application or simple Rack based endpoints.
+ * **Code reusability.** You can consume a feature from the Web UI or from a HTTP API. Each can be a different Lotus application or simple Rack-based endpoints.
* **Decoupled components.** The core of your application depends only on a few gems and it doesn't need to worry about the Web/HTTP/Console/Background jobs.
- * **Applications are built like a gem**, this ease the process of package them and share between projects, without the need of carry a lot of dependencies.
- * **Avoid monoliths**. Each Lotus application under `apps/` is a candidate for later on extraction into a separated [_microservice_](http://martinfowler.com/articles/microservices.html).
+ * **Applications are built like gems.** This eases the process of packaging and sharing them among projects, without the need for many dependencies.
+ * **Avoid monoliths**. Each Lotus application under `apps/` is a candidate for later extraction into a separated [_microservice_](http://martinfowler.com/articles/microservices.html).
-The last point is crucial. In the early days of a new project is really convenient to build and deploy all the code together.
-But as the time passes, it can become nearly impossible to extract sets of cohesive functionalities into separated deliverables.
-Lotus helps to plan those things ahead of time, but without the burden that is required by those choices, because it support multiple applications natively.
+The last point is crucial. In the early days of a new project it is convenient to build and deploy all the code together.
+However, as time passes, it can become nearly impossible to extract sets of cohesive functionalities into separated deliverables.
+Lotus helps to plan those things ahead of time, but without the burden that is required by those choices, because it supports multiple applications natively.
Here's the name _**container**_: a Lotus _"shell"_ that can run multiple micro applications in the same process.
```shell
% lotus new pocket --arch=container
@@ -120,11 +122,11 @@
## Conventions
* Lotus expects controllers, actions and views to have a specific pattern (see [Configuration](#configuration) for customizations)
* All the commands must be run from the root of the project. If this requirement cannot be satisfied, please hardcode the path with `Configuration#root`.
* The template name must reflect the name of the corresponding view: `Bookshelf::Views::Dashboard::Index` for `dashboard/index.html.erb`.
-* All the static files are served by the internal Rack middleware stack.
+* All static files are served by the internal Rack middleware stack.
* The application expects to find static files under `public/` (see `Configuration#assets`)
* If the public folder doesn't exist, it doesn't serve static files.
## Non-Conventions
@@ -233,11 +235,11 @@
# Argument: A Hash with the settings
# type: Symbol, :file_system, :memory and :sql
# uri: String, 'file:///db/bookshelf'
# 'memory://localhost/bookshelf'
# 'sqlite:memory:'
- # 'sqlite://db/bookshelf.db'
+ # 'sqlite://db/bookshelf.sqlite3'
# 'postgres://localhost/bookshelf'
# 'mysql://localhost/bookshelf'
#
adapter type: :file_system, uri: ENV['DATABASE_URL']
@@ -288,10 +290,26 @@
# Enabling serving assets (optional)
# Argument: boolean, defaults to false
#
serve_assets true
+ ###########################
+ # SECURITY CONFIGURATIONS #
+ ###########################
+
+ # Set a default value for X-Frame-Options HTTP header
+ # Argument: String
+ # Remove this line to disable this feature
+ #
+ security.x_frame_options "DENY"
+
+ # Set a default value for Content-Security-Policy HTTP header
+ # Argument: String
+ # Remove this line to disable this feature
+ #
+ security.content_security_policy "default-src 'none'; script-src 'self'; connect-src 'self'; img-src 'self'; style-src 'self';"
+
#############################
# FRAMEWORKS CONFIGURATIONS #
#############################
# Low level configuration for Lotus::View (optional)
@@ -299,11 +317,11 @@
# This is helpful to share logic between views
# See the related documentation
# Argument: Proc
#
view.prepare do
- include MyCustomRoutingHelpers # included by all the views
+ include Lotus::Helpers # they will be included in all the views
end
# Low level configuration for Lotus::Controller (optional)
# Argument: Proc
controller.prepare do
@@ -342,15 +360,48 @@
```shell
% bundle exec lotus server
```
+### Generators
+
+#### Action generator
+
+It generates an **action**, a **view**, a **template**, a **route** and the relative unit tests.
+
+```shell
+% bundle exec lotus generate action web dashboard#index
+```
+
+The `web` argument is the name of the application under `apps/`.
+The `dashboard#index` argument is the name of the controller and the name of the action.
+
+It generates Minitest/RSpec files according to `test` setting in `.lotusrc`.
+It generates an empty template with the template engine extension (`template`) setting in `.lotusrc`.
+
+It generates the following files:
+
+ * `apps/web/controllers/dashboard/index.rb`
+ * `spec/web/controllers/dashboard/index_spec.rb`
+ * `apps/web/views/dashboard/index.rb`
+ * `spec/web/views/dashboard/index_spec.rb`
+ * `apps/web/templates/dashboard/index.html.erb` (**empty file**)
+ * Amend `apps/web/config/routes.rb` with a new route
+
### Console
-It starts a REPL, by using the engine defined in your `Gemfile`. It defaults to IRb. **Run it from the root of the application**.
+It starts a REPL, by using the engine defined in your `Gemfile`. It defaults to IRB. **Run it from the root of the application**.
```shell
% bundle exec lotus console
+```
+
+### Database console
+
+It starts a database REPL, by looking at your database configuration under `lib/. **Run it from the root of the application**.
+
+```shell
+% bundle exec lotus db console
```
It supports **code reloading** via the `reload!` command.
### Routes