Skip to content
Permalink
Browse files

Prepare guides for v0.6.0

  • Loading branch information...
jodosha committed Dec 23, 2015
1 parent c2c69ba commit d490d4fbc321130c1d20d21342f20449d485b541
@@ -168,7 +168,7 @@ def encode_text(text)
end

def lotus_version
'0.5.0'
'0.6.0'
end
end

@@ -0,0 +1,24 @@
---
title: Lotus - Guides - Applications Initializers
---

# Initializers

Each single Lotus application within a project can have one or more custom initializers.
They are **optional**.

<p class="notice">
Initializers are optional
</p>

They are run **after** the dependencies, the framework and the application code are loaded, but **before** the server or the console are started.

<p class="convention">
For a given application named <code>Web</code>, they MUST be placed under <code>apps/web/config/initializers</code>.
</p>

Their execution order is alphabetical.

<p class="warning">
Initializers are executed in alphabetical order.
</p>
@@ -0,0 +1,108 @@
---
title: Lotus - Guides - Applications Rake Tasks
---

# Rake Tasks

Lotus ships with default Rake tasks that can be used as _prerequisites_ by developers to build their own tasks.

```shell
% bundle exec rake -T
rake environment # Load the full project
rake preload # Preload project configuration
rake test # Run tests
```

## Environment

This Rake task:

1. Executes all `preload` steps
2. Load all the project code

Use this as a Rake task prerequisite when you **DO** need to access to project code (eg. entites, actions, views, etc..)

### Example

Imagine we want to build a Rake task that is able to access project code (eg. a repository)

```ruby
# Rakefile
task clear_users: :environment do
UserRepository.clear
end
```

```shell
bundle exec rake clear_users
```

<p class="notice">
The <code>:environment</code> Rake loads the entire project. It's slower than <code>:preload</code>, use it when you need to access project code.
</p>

## Preload

This Rake task is a fast way to preload:

* Gem dependencies in `Gemfile`
* The framework
* Project configurations such as env variables and application configurations (eg. `apps/web/application.rb`)

Use this as a Rake task prerequisite when you **DO NOT** need to access to project code (eg. entites, actions, views, etc..)

### Example

Imagine we want to build a Rake task that prints informations about our project:

```ruby
# Rakefile
task print_informations: :preload do
puts ENV['LOTUS_ENV'] # => "development"
puts ENV['BOOKSHELF_DATABASE_URL'] # => "postgres://localhost/bookshelf_development"
puts defined?(User) # => nil
end
```

```shell
% bundle exec rake print_informations
"development"
"postgres://localhost/bookshelf_development"
""
```

<p class="notice">
The <code>:preload</code> Rake task preloads projects and applications configurations. Use it when you need a fast way to access them.
</p>

## Test

This is the default Rake task, it runs the test suite

The following commands are equivalent:

```shell
% bundle exec rake
```

```shell
% bundle exec rake test
```

<p class="convention">
The <code>:test</code> Rake task is the default.
</p>

## Ruby Ecosystem Compatibility

Many Software as a Service (SaaS) of the Ruby ecosystem are modeled after Ruby on Rails.
For instance, Heroku expects to find the following Rake tasks in a Ruby application:

* `db:migrate`
* `assets:precompile`

For Heroku, there isn't a way to customize the deploy, so we're supporting these "standard" Rake tasks from Ruby on Rails.

**If you are in control of your deployment, don't rely on these Rake tasks, but please use `lotus` [command line](/guides/command-line/database), instead.**
@@ -0,0 +1,46 @@
---
title: Lotus - Guides - Assets Content Delivery Network (CDN)
---

# Assets

## Content Delivery Network (CDN)

A Lotus application can serve assets from a [Content Delivery Network](https://en.wikipedia.org/wiki/Content_delivery_network) (CDN).
This feature is useful in _production_ environment, where we want to speed up static assets serving.

In order to take advantage of this feature, we need to specify CDN settings.

```ruby
# apps/web/application.rb
module Web
class Application < Lotus::Application
# ...
configure :production do
scheme 'https'
host 'bookshelf.org'
port 443
assets do
# ...
digest true
# CDN settings
scheme 'https'
host '123.cloudfront.net'
port 443
end
end
end
end
```

Once _CDN mode_ is on, all the [asset helpers](/guides/helpers/assets) will return **absolute URLs**.

```erb
<%= stylesheet 'application.css' %>
```

```html
<link href="https://123.cloudfront.net/assets/application-9ab4d1f57027f0d40738ab8ab70aba86.css" type="text/css" rel="stylesheet">
```

0 comments on commit d490d4f

Please sign in to comment.
You can’t perform that action at this time.