lotusrb 0.3.2 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +20 -0
- data/FEATURES.md +17 -0
- data/README.md +16 -355
- data/lib/lotus.rb +0 -1
- data/lib/lotus/action/csrf_protection.rb +167 -0
- data/lib/lotus/application.rb +3 -1
- data/lib/lotus/cli.rb +14 -13
- data/lib/lotus/commands/console.rb +1 -1
- data/lib/lotus/commands/db.rb +102 -0
- data/lib/lotus/commands/db/abstract.rb +15 -0
- data/lib/lotus/commands/db/apply.rb +14 -0
- data/lib/lotus/commands/db/console.rb +1 -5
- data/lib/lotus/commands/db/create.rb +14 -0
- data/lib/lotus/commands/db/drop.rb +14 -0
- data/lib/lotus/commands/db/migrate.rb +19 -0
- data/lib/lotus/commands/db/prepare.rb +14 -0
- data/lib/lotus/commands/db/version.rb +14 -0
- data/lib/lotus/commands/generate.rb +20 -20
- data/lib/lotus/commands/new.rb +1 -0
- data/lib/lotus/commands/routes.rb +1 -2
- data/lib/lotus/configuration.rb +29 -0
- data/lib/lotus/container.rb +19 -3
- data/lib/lotus/environment.rb +62 -9
- data/lib/lotus/frameworks.rb +1 -0
- data/lib/lotus/generators/action.rb +46 -10
- data/lib/lotus/generators/action/action_spec.minitest.tt +1 -1
- data/lib/lotus/generators/action/action_spec.rspec.tt +1 -1
- data/lib/lotus/generators/action/view_spec.minitest.tt +2 -1
- data/lib/lotus/generators/action/view_spec.rspec.tt +2 -1
- data/lib/lotus/generators/app.rb +39 -0
- data/lib/lotus/generators/app/.gitkeep +1 -0
- data/lib/lotus/generators/application/app.rb +184 -0
- data/lib/lotus/generators/application/app/.env.development.tt +3 -0
- data/lib/lotus/generators/application/app/.env.test.tt +3 -0
- data/lib/lotus/generators/application/{container/config → app}/.env.tt +0 -0
- data/lib/lotus/generators/application/app/.gitkeep +1 -0
- data/lib/lotus/generators/application/app/Gemfile.tt +35 -0
- data/lib/lotus/generators/application/app/Rakefile.minitest.tt +10 -0
- data/lib/lotus/generators/application/app/Rakefile.rspec.tt +5 -0
- data/lib/lotus/generators/application/app/apps/.gitkeep.tt +1 -0
- data/lib/lotus/generators/application/app/capybara.rb.rspec.tt +8 -0
- data/lib/lotus/generators/application/app/config.ru.tt +3 -0
- data/lib/lotus/generators/application/app/config/application.rb.tt +227 -0
- data/lib/lotus/generators/application/app/config/environment.rb.tt +5 -0
- data/lib/lotus/generators/application/app/config/routes.rb.tt +2 -0
- data/lib/lotus/generators/application/app/db/.gitkeep +1 -0
- data/lib/lotus/generators/application/app/features_helper.rb.minitest.tt +11 -0
- data/lib/lotus/generators/application/app/features_helper.rb.rspec.tt +12 -0
- data/lib/lotus/generators/application/app/gitignore.tt +2 -0
- data/lib/lotus/generators/application/app/lib/app_name.rb.tt +47 -0
- data/lib/lotus/generators/application/app/lib/chirp/entities/.gitkeep +1 -0
- data/lib/lotus/generators/application/app/lib/chirp/repositories/.gitkeep +1 -0
- data/lib/lotus/generators/application/app/lib/config/mapping.rb.tt +7 -0
- data/lib/lotus/generators/application/app/lotusrc.tt +3 -0
- data/lib/lotus/generators/application/app/rspec.rspec.tt +2 -0
- data/lib/lotus/generators/application/app/schema.sql.tt +0 -0
- data/lib/lotus/generators/application/app/spec_helper.rb.minitest.tt +7 -0
- data/lib/lotus/generators/application/app/spec_helper.rb.rspec.tt +100 -0
- data/lib/lotus/generators/application/app/templates/application.html.erb.tt +9 -0
- data/lib/lotus/generators/application/app/views/application_layout.rb.tt +7 -0
- data/lib/lotus/generators/application/container.rb +37 -13
- data/lib/lotus/generators/application/container/{config/.env.development.tt → .env.development.tt} +0 -0
- data/lib/lotus/generators/application/container/{config/.env.test.tt → .env.test.tt} +0 -0
- data/lib/lotus/generators/application/container/.env.tt +1 -0
- data/lib/lotus/generators/application/container/lib/app_name.rb.tt +9 -0
- data/lib/lotus/generators/application/container/schema.sql.tt +0 -0
- data/lib/lotus/generators/migration.rb +58 -0
- data/lib/lotus/generators/migration/migration.rb.tt +4 -0
- data/lib/lotus/generators/model.rb +10 -7
- data/lib/lotus/generators/slice.rb +4 -12
- data/lib/lotus/generators/slice/application.rb.tt +3 -19
- data/lib/lotus/generators/slice/config/routes.rb.tt +1 -7
- data/lib/lotus/loader.rb +15 -1
- data/lib/lotus/lotusrc.rb +8 -3
- data/lib/lotus/templates/{welcome.html → welcome.html.erb} +4 -3
- data/lib/lotus/version.rb +1 -1
- data/lib/lotus/welcome.rb +20 -1
- data/lotusrb.gemspec +5 -5
- metadata +67 -18
- data/lib/lotus/generators/slice/action.rb.tt +0 -8
- data/lib/lotus/generators/slice/config/mapping.rb.tt +0 -13
- data/lib/lotus/generators/slice/templates/template.html.erb.tt +0 -2
- data/lib/lotus/generators/slice/view.rb.tt +0 -5
- data/lib/lotus/logger.rb +0 -141
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 52e1d51949b1c0cdaa5dfe36c2758dc9e82624b9
|
4
|
+
data.tar.gz: 8a743bcca2c6ae96f85179b38383e0dfe99b2af1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dc6bf38f66898013a9192239faface94696b5032996c02f77866eb174bfe4242a7ac64f8642d6a67a228947562dfb59bf6cbd57f31919cd5b2e33ddcc2a5fb61
|
7
|
+
data.tar.gz: 25ef374ff36f82fcfc98aa74c0b5e5d5323ca1403d35686370a3b792be7054a990012702bae2b2d3910d64047341a1ef6c62216f43188305e4aae6a25ee8cfe5
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,26 @@
|
|
1
1
|
# Lotus
|
2
2
|
A complete web framework for Ruby
|
3
3
|
|
4
|
+
## v0.4.0 - 2015-06-23
|
5
|
+
### Added
|
6
|
+
- [Luca Guidi] Database migrations and new CLI commands for database operations
|
7
|
+
- [Luca Guidi] Cross Site Request Forgery (CSRF) protection
|
8
|
+
- [Hiếu Nguyễn & Luca Guidi] Application Architecture
|
9
|
+
- [Alfonso Uceda Pompa] Force SSL for applications
|
10
|
+
- [Luca Guidi] Introduced `--url` CLI argument for action generator
|
11
|
+
- [Luca Guidi] Added `rendered` "let" variable for new generated tests for views
|
12
|
+
|
13
|
+
### Fixed
|
14
|
+
- [Alfonso Uceda Pompa] Fix generated routes for Container applications mounted on a path different from `/`.
|
15
|
+
- [Luca Guidi] Reading `.lotusrc` pollutes `ENV` with unwanted variables.
|
16
|
+
- [Alfonso Uceda Pompa] Added sqlite extension to SQLite/SQLite3 database URL.
|
17
|
+
|
18
|
+
### Changed
|
19
|
+
- [Luca Guidi] `.env`, `.env.development` and `.env.test` are generated and expected to be placed at the root of the project.
|
20
|
+
- [Luca Guidi] Remove database mapping from generated apps.
|
21
|
+
- [Trung Lê & Luca Guidi] Remove default generated from new apps.
|
22
|
+
- [Luca Guidi] New application should depend on `lotus-model ~> 0.4`
|
23
|
+
|
4
24
|
## v0.3.2 - 2015-05-22
|
5
25
|
### Added
|
6
26
|
- [Alfonso Uceda Pompa] Automatic secure cookies if the current connection is using HTTPS.
|
data/FEATURES.md
CHANGED
@@ -3,6 +3,23 @@
|
|
3
3
|
|
4
4
|
## Features
|
5
5
|
|
6
|
+
## v0.4.0 - 2015-06-23
|
7
|
+
|
8
|
+
- Application architecture
|
9
|
+
- Database migrations
|
10
|
+
- CLI: `lotus db` commands: `create`, `drop`, `prepare`, `migrate`, `version`, `apply`.
|
11
|
+
- HTML5 Form helpers
|
12
|
+
- Cross Site Request Forgery (CSRF) protection
|
13
|
+
- Force SSL
|
14
|
+
- Number formatting helper
|
15
|
+
|
16
|
+
## v0.3.2 - 2015-05-22
|
17
|
+
|
18
|
+
- Automatic secure cookies
|
19
|
+
- Routing helpers for actions
|
20
|
+
- Send files from actions
|
21
|
+
- `Lotus.root` returns top level directory of the project.
|
22
|
+
|
6
23
|
## v0.3.1 - 2015-05-15
|
7
24
|
|
8
25
|
- CLI: `lotus generate app admin` creates a new application (`apps/admin`).
|
data/README.md
CHANGED
@@ -29,6 +29,8 @@ If you aren't familiar with them, please take time to go through their READMEs.
|
|
29
29
|
## Contact
|
30
30
|
|
31
31
|
* Home page: http://lotusrb.org
|
32
|
+
* Community: http://lotusrb.org/community
|
33
|
+
* Guides: http://lotusrb.org/guides
|
32
34
|
* Mailing List: http://lotusrb.org/mailing-list
|
33
35
|
* API Doc: http://rdoc.info/gems/lotusrb
|
34
36
|
* Bugs/Issues: https://github.com/lotus/lotus/issues
|
@@ -54,371 +56,30 @@ __Lotus__ supports Ruby (MRI) 2+
|
|
54
56
|
% bundle exec lotus server # visit http://localhost:2300
|
55
57
|
```
|
56
58
|
|
57
|
-
|
59
|
+
Please follow along with the [Getting Started guide](http://lotusrb.org/guides/getting-started).
|
58
60
|
|
59
|
-
|
60
|
-
It scales from **single file HTTP endpoints** to **multiple applications in the same Ruby process**.
|
61
|
+
## Community
|
61
62
|
|
62
|
-
|
63
|
-
|
64
|
-
|
63
|
+
We strive for a Community made of **inclusive, helpful and smart people**.
|
64
|
+
We have a [Code of Conduct](http://lotusrb.org/community/#code-of-conduct) to handle controversial cases.
|
65
|
+
In general, we expect **you** to be **nice** with other people.
|
66
|
+
Our hope is for a great software and a great Community.
|
65
67
|
|
66
|
-
|
67
|
-
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**.
|
68
|
+
### Contributor Code of Conduct
|
68
69
|
|
69
|
-
|
70
|
-
It allows multiple copies of the framework and multiple applications to run in the **same Ruby process**.
|
71
|
-
In other words, Lotus applications are ready to be split into smaller parts, but these parts can coexist in the same heap space.
|
70
|
+
As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
|
72
71
|
|
73
|
-
|
74
|
-
For this reason Lotus is shipped with code generators.
|
72
|
+
We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
|
75
73
|
|
74
|
+
Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
|
76
75
|
|
77
|
-
|
76
|
+
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
|
78
77
|
|
79
|
-
|
78
|
+
This code of conduct applies both within project spaces and in public spaces when an individual is representing the project or its community.
|
80
79
|
|
81
|
-
|
80
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
|
82
81
|
|
83
|
-
|
84
|
-
|
85
|
-
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.
|
86
|
-
|
87
|
-
It's based on a few simple concepts: **use cases** and **applications**.
|
88
|
-
Use cases (features) should be implemented in `lib/` with a combination of pure objects and the needed Ruby gems.
|
89
|
-
One or more Lotus applications live in `apps/`. They are isolated from each other, and depend only on the code in `lib/`.
|
90
|
-
|
91
|
-
Each application should serve only one purpose: user-facing web application, administrative backend, JSON API, metrics dashboard, etc.
|
92
|
-
|
93
|
-
This architecture has important advantages:
|
94
|
-
|
95
|
-
* **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.
|
96
|
-
* **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.
|
97
|
-
* **Applications are built like gems.** This eases the process of packaging and sharing them among projects, without the need for many dependencies.
|
98
|
-
* **Avoid monoliths**. Each Lotus application under `apps/` is a candidate for later extraction into a separated [_microservice_](http://martinfowler.com/articles/microservices.html).
|
99
|
-
|
100
|
-
The last point is crucial. In the early days of a new project it is convenient to build and deploy all the code together.
|
101
|
-
However, as time passes, it can become nearly impossible to extract sets of cohesive functionalities into separated deliverables.
|
102
|
-
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.
|
103
|
-
|
104
|
-
Here's the name _**container**_: a Lotus _"shell"_ that can run multiple micro applications in the same process.
|
105
|
-
|
106
|
-
```shell
|
107
|
-
% lotus new pocket --arch=container
|
108
|
-
% lotus new pocket # --arch=container is the default
|
109
|
-
```
|
110
|
-
|
111
|
-
Read more about this [architecture](https://github.com/lotus/lotus/wiki/Container-architecture).
|
112
|
-
|
113
|
-
### _Application_ architecture
|
114
|
-
|
115
|
-
_upcoming_
|
116
|
-
|
117
|
-
### _Micro_ architecture
|
118
|
-
|
119
|
-
_upcoming_
|
120
|
-
|
121
|
-
## Conventions
|
122
|
-
|
123
|
-
* Lotus expects controllers, actions and views to have a specific pattern (see [Configuration](#configuration) for customizations)
|
124
|
-
* 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`.
|
125
|
-
* The template name must reflect the name of the corresponding view: `Bookshelf::Views::Dashboard::Index` for `dashboard/index.html.erb`.
|
126
|
-
* All static files are served by the internal Rack middleware stack.
|
127
|
-
* The application expects to find static files under `public/` (see `Configuration#assets`)
|
128
|
-
* If the public folder doesn't exist, it doesn't serve static files.
|
129
|
-
|
130
|
-
## Non-Conventions
|
131
|
-
|
132
|
-
* The application structure can be organized according to developer needs.
|
133
|
-
* No file-to-name convention: modules and classes can live in one or multiple files.
|
134
|
-
* No autoloading paths. They must be explicitly configured.
|
135
|
-
|
136
|
-
## Configuration
|
137
|
-
|
138
|
-
<a name="configuration"></a>
|
139
|
-
|
140
|
-
A Lotus application can be configured with a DSL that determines its behavior.
|
141
|
-
|
142
|
-
```ruby
|
143
|
-
require 'lotus'
|
144
|
-
|
145
|
-
module Bookshelf
|
146
|
-
class Application < Lotus::Application
|
147
|
-
configure do
|
148
|
-
########################
|
149
|
-
# BASIC CONFIGURATIONS #
|
150
|
-
########################
|
151
|
-
|
152
|
-
# Determines the root of the application (optional)
|
153
|
-
# Argument: String, Pathname, defaults to Dir.pwd
|
154
|
-
#
|
155
|
-
root 'path/to/root' # or __root__
|
156
|
-
|
157
|
-
# The relative load paths where the application will recursively load the code (mandatory)
|
158
|
-
# Argument: String, Array<String>, defaults to empty set
|
159
|
-
#
|
160
|
-
load_paths << [
|
161
|
-
'controllers',
|
162
|
-
'views'
|
163
|
-
]
|
164
|
-
|
165
|
-
# Handle exceptions with HTTP statuses (true) or don't catch them (false)
|
166
|
-
# Argument: boolean, defaults to true
|
167
|
-
#
|
168
|
-
handle_exceptions true
|
169
|
-
|
170
|
-
#######################
|
171
|
-
# HTTP CONFIGURATIONS #
|
172
|
-
#######################
|
173
|
-
|
174
|
-
# The route set (mandatory)
|
175
|
-
# Argument: Proc with the routes definition
|
176
|
-
#
|
177
|
-
routes do
|
178
|
-
get '/', to: 'home#index'
|
179
|
-
end
|
180
|
-
|
181
|
-
# The route set (mandatory) (alternative usage)
|
182
|
-
# Argument: A relative path where to find the routes definition
|
183
|
-
#
|
184
|
-
routes 'config/routes'
|
185
|
-
|
186
|
-
# URI scheme used by the routing system to generate absolute URLs (optional)
|
187
|
-
# Argument: A string, default to "http"
|
188
|
-
#
|
189
|
-
scheme 'https'
|
190
|
-
|
191
|
-
# URI host used by the routing system to generate absolute URLs (optional)
|
192
|
-
# Argument: A string, default to "localhost"
|
193
|
-
#
|
194
|
-
host 'bookshelf.org'
|
195
|
-
|
196
|
-
# URI port used by the routing system to generate absolute URLs (optional)
|
197
|
-
# Argument: An object coercible to integer, default to 80 if the scheme is http and 443 if it's https
|
198
|
-
# This SHOULD be configured only in case the application listens to that non standard ports
|
199
|
-
#
|
200
|
-
port 2323
|
201
|
-
|
202
|
-
# Toggle cookies (optional)
|
203
|
-
# Argument: A [`TrueClass`, `FalseClass`], default to `FalseClass`.
|
204
|
-
#
|
205
|
-
cookies true
|
206
|
-
|
207
|
-
# Toggle sessions (optional)
|
208
|
-
# Argument: Symbol the Rack session adapter
|
209
|
-
# A Hash with options
|
210
|
-
#
|
211
|
-
sessions :cookie, secret: ENV['SESSIONS_SECRET']
|
212
|
-
|
213
|
-
# Default format for the requests that don't specify an HTTP_ACCEPT header (optional)
|
214
|
-
# Argument: A symbol representation of a mime type, default to :html
|
215
|
-
#
|
216
|
-
default_format :json
|
217
|
-
|
218
|
-
# Rack middleware configuration (optional)
|
219
|
-
#
|
220
|
-
middleware.use Rack::Protection
|
221
|
-
|
222
|
-
# HTTP Body parsers (optional)
|
223
|
-
# Parse non GET responses body for a specific mime type
|
224
|
-
# Argument: Symbol, which represent the format of the mime type (only `:json` is supported)
|
225
|
-
# Object, the parser
|
226
|
-
#
|
227
|
-
body_parsers :json, MyXMLParser.new
|
228
|
-
|
229
|
-
###########################
|
230
|
-
# DATABASE CONFIGURATIONS #
|
231
|
-
###########################
|
232
|
-
|
233
|
-
# Configure a database adapter (optional)
|
234
|
-
# Argument: A Hash with the settings
|
235
|
-
# type: Symbol, :file_system, :memory and :sql
|
236
|
-
# uri: String, 'file:///db/bookshelf'
|
237
|
-
# 'memory://localhost/bookshelf'
|
238
|
-
# 'sqlite:memory:'
|
239
|
-
# 'sqlite://db/bookshelf.sqlite3'
|
240
|
-
# 'postgres://localhost/bookshelf'
|
241
|
-
# 'mysql://localhost/bookshelf'
|
242
|
-
#
|
243
|
-
adapter type: :file_system, uri: ENV['DATABASE_URL']
|
244
|
-
|
245
|
-
# Configure a database mapping (optional)
|
246
|
-
# Argument: Proc
|
247
|
-
#
|
248
|
-
mapping do
|
249
|
-
collection :users do
|
250
|
-
entity User
|
251
|
-
repository UserRepository
|
252
|
-
|
253
|
-
attribute :id, Integer
|
254
|
-
attribute :name, String
|
255
|
-
end
|
256
|
-
end
|
257
|
-
|
258
|
-
# Configure a database mapping (optional, alternative usage)
|
259
|
-
# Argument: A relative path where to find the mapping definitions
|
260
|
-
#
|
261
|
-
mapping 'config/mapping'
|
262
|
-
|
263
|
-
############################
|
264
|
-
# TEMPLATES CONFIGURATIONS #
|
265
|
-
############################
|
266
|
-
|
267
|
-
# The layout to be used by all the views (optional)
|
268
|
-
# Argument: A Symbol that indicates the name, default to nil
|
269
|
-
#
|
270
|
-
layout :application # Will look for Bookshelf::Views::ApplicationLayout
|
271
|
-
|
272
|
-
# The relative path where to find the templates (optional)
|
273
|
-
# Argument: A string with the relative path, default to the root of the app
|
274
|
-
#
|
275
|
-
templates 'templates'
|
276
|
-
|
277
|
-
#########################
|
278
|
-
# ASSETS CONFIGURATIONS #
|
279
|
-
#########################
|
280
|
-
|
281
|
-
# Specify sources for assets (optional)
|
282
|
-
# Argument: String, Array<String>, defaults to 'public'
|
283
|
-
#
|
284
|
-
assets << [
|
285
|
-
'public',
|
286
|
-
'vendor/assets'
|
287
|
-
]
|
288
|
-
|
289
|
-
# Enabling serving assets (optional)
|
290
|
-
# Argument: boolean, defaults to false
|
291
|
-
#
|
292
|
-
serve_assets true
|
293
|
-
|
294
|
-
###########################
|
295
|
-
# SECURITY CONFIGURATIONS #
|
296
|
-
###########################
|
297
|
-
|
298
|
-
# Set a default value for X-Frame-Options HTTP header
|
299
|
-
# Argument: String
|
300
|
-
# Remove this line to disable this feature
|
301
|
-
#
|
302
|
-
security.x_frame_options "DENY"
|
303
|
-
|
304
|
-
# Set a default value for Content-Security-Policy HTTP header
|
305
|
-
# Argument: String
|
306
|
-
# Remove this line to disable this feature
|
307
|
-
#
|
308
|
-
security.content_security_policy "default-src 'none'; script-src 'self'; connect-src 'self'; img-src 'self'; style-src 'self';"
|
309
|
-
|
310
|
-
#############################
|
311
|
-
# FRAMEWORKS CONFIGURATIONS #
|
312
|
-
#############################
|
313
|
-
|
314
|
-
# Low level configuration for Lotus::View (optional)
|
315
|
-
# The given block will be yielded every time `Lotus::View` is included.
|
316
|
-
# This is helpful to share logic between views
|
317
|
-
# See the related documentation
|
318
|
-
# Argument: Proc
|
319
|
-
#
|
320
|
-
view.prepare do
|
321
|
-
include Lotus::Helpers # they will be included in all the views
|
322
|
-
end
|
323
|
-
|
324
|
-
# Low level configuration for Lotus::Controller (optional)
|
325
|
-
# Argument: Proc
|
326
|
-
controller.prepare do
|
327
|
-
include Authentication # included by all the actions
|
328
|
-
before :authenticate! # run auth logic before each action
|
329
|
-
end
|
330
|
-
end
|
331
|
-
|
332
|
-
###############################
|
333
|
-
# ENVIRONMENTS CONFIGURATIONS #
|
334
|
-
###############################
|
335
|
-
|
336
|
-
configure :development do
|
337
|
-
# override the general configuration only for the development environment
|
338
|
-
handle_exceptions false
|
339
|
-
serve_assets true
|
340
|
-
end
|
341
|
-
|
342
|
-
configure :test do
|
343
|
-
# override the general configuration only for the test environment
|
344
|
-
host 'test.host'
|
345
|
-
end
|
346
|
-
end
|
347
|
-
end
|
348
|
-
```
|
349
|
-
|
350
|
-
## Command line
|
351
|
-
|
352
|
-
Lotus provides a few command line utilities:
|
353
|
-
|
354
|
-
### Server
|
355
|
-
|
356
|
-
It looks at the `config.ru` file in the root of the application, and starts the Rack server defined in your `Gemfile` (eg. puma, thin, unicorn). It defaults to WEBRick.
|
357
|
-
|
358
|
-
It supports **code reloading** feature by default, useful for development purposes.
|
359
|
-
|
360
|
-
```shell
|
361
|
-
% bundle exec lotus server
|
362
|
-
```
|
363
|
-
|
364
|
-
### Generators
|
365
|
-
|
366
|
-
#### Action generator
|
367
|
-
|
368
|
-
It generates an **action**, a **view**, a **template**, a **route** and the relative unit tests.
|
369
|
-
|
370
|
-
```shell
|
371
|
-
% bundle exec lotus generate action web dashboard#index
|
372
|
-
```
|
373
|
-
|
374
|
-
The `web` argument is the name of the application under `apps/`.
|
375
|
-
The `dashboard#index` argument is the name of the controller and the name of the action.
|
376
|
-
|
377
|
-
It generates Minitest/RSpec files according to `test` setting in `.lotusrc`.
|
378
|
-
It generates an empty template with the template engine extension (`template`) setting in `.lotusrc`.
|
379
|
-
|
380
|
-
It generates the following files:
|
381
|
-
|
382
|
-
* `apps/web/controllers/dashboard/index.rb`
|
383
|
-
* `spec/web/controllers/dashboard/index_spec.rb`
|
384
|
-
* `apps/web/views/dashboard/index.rb`
|
385
|
-
* `spec/web/views/dashboard/index_spec.rb`
|
386
|
-
* `apps/web/templates/dashboard/index.html.erb` (**empty file**)
|
387
|
-
* Amend `apps/web/config/routes.rb` with a new route
|
388
|
-
|
389
|
-
### Console
|
390
|
-
|
391
|
-
It starts a REPL, by using the engine defined in your `Gemfile`. It defaults to IRB. **Run it from the root of the application**.
|
392
|
-
|
393
|
-
```shell
|
394
|
-
% bundle exec lotus console
|
395
|
-
```
|
396
|
-
|
397
|
-
### Database console
|
398
|
-
|
399
|
-
It starts a database REPL, by looking at your database configuration under `lib/. **Run it from the root of the application**.
|
400
|
-
|
401
|
-
```shell
|
402
|
-
% bundle exec lotus db console
|
403
|
-
```
|
404
|
-
|
405
|
-
It supports **code reloading** via the `reload!` command.
|
406
|
-
|
407
|
-
### Routes
|
408
|
-
|
409
|
-
It prints the routes defined by the Lotus application(s).
|
410
|
-
|
411
|
-
```shell
|
412
|
-
% bundle exec lotus routes
|
413
|
-
```
|
414
|
-
|
415
|
-
### Version
|
416
|
-
|
417
|
-
It prints the current Lotus version.
|
418
|
-
|
419
|
-
```shell
|
420
|
-
% bundle exec lotus version
|
421
|
-
```
|
82
|
+
This Code of Conduct is adapted from the Contributor Covenant, version 1.1.0, available from http://contributor-covenant.org/version/1/1/0/
|
422
83
|
|
423
84
|
## Contributing
|
424
85
|
|