Navigation Menu

Skip to content

Commit

Permalink
[ci skip] CHANGELOG, README and API docs for v0.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jodosha committed Mar 21, 2015
1 parent 8952352 commit e6d2746
Show file tree
Hide file tree
Showing 8 changed files with 110 additions and 43 deletions.
17 changes: 17 additions & 0 deletions CHANGELOG.md
@@ -1,6 +1,23 @@
# Lotus
A complete web framework for Ruby

## v0.3.0 - 2015-03-23
### Added
- [Luca Guidi] Introduced action generator. Eg. `bundle exec lotus generate action web dashboard#index`
- [Alfonso Uceda Pompa] Allow to specify default coookies options in application configuration. Eg. `cookies true, { domain: 'lotusrb.org' }`
- [Tom Kadwill] Include `Lotus::Helpers` in views.
- [Linus Pettersson] Allow to specify `--database` CLI option when generate a new application. Eg. `lotus new bookshelf --database=postgresql`
- [Linus Pettersson] Initialize a Git repository when generating a new application
- [Alfonso Uceda Pompa] Produce `.lotusrc` when generating a new application
- [Alfonso Uceda Pompa] Security HTTP headers. `X-Frame-Options` and `Content-Security-Policy` are now enabled by default.
- [Linus Pettersson] Database console. Run with `bundle exec lotus db console`
- [Luca Guidi] Dynamic finders for relative and absolute routes. It implements method missing: `Web::Routes.home_path` will resolve to `Web::Routes.path(:home)`.

### Changed
[Alfonso Uceda Pompa] Cookies will send `HttpOnly` by default. This is for security reasons.
- [Jan Lelis] Enable `templates` configuration for new generated apps
- [Mark Connell] Change SQLite file extension from `.db` to `.sqlite3`

## v0.2.1 - 2015-02-06
### Added
- [Huy Đỗ] Introduced `Lotus::Logger`
Expand Down
55 changes: 53 additions & 2 deletions README.md
Expand Up @@ -9,6 +9,7 @@ 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
Expand All @@ -33,7 +34,8 @@ If you aren't familiar with them, please take time to go through their READMEs.
* 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

Expand Down Expand Up @@ -290,6 +292,22 @@ module Bookshelf
#
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 #
#############################
Expand All @@ -301,7 +319,7 @@ module Bookshelf
# 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)
Expand Down Expand Up @@ -344,6 +362,31 @@ It supports **code reloading** feature by default, useful for development purpos
% 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**.
Expand All @@ -352,6 +395,14 @@ It starts a REPL, by using the engine defined in your `Gemfile`. It defaults to
% 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
Expand Down
8 changes: 4 additions & 4 deletions lib/lotus/config/cookies.rb
Expand Up @@ -2,15 +2,15 @@ module Lotus
module Config
# Cookies configuration
#
# @since x.x.x
# @since 0.3.0
# @api private
class Cookies

# Return the routes for this application
#
# @return [Hash] options for cookies
#
# @since x.x.x
# @since 0.3.0
# @api private
attr_reader :default_options

Expand All @@ -23,7 +23,7 @@ class Cookies
# @param enabled [TrueClass, FalseClass] enable cookies
# @param options [Hash] optional cookies options
#
# @since x.x.x
# @since 0.3.0
# @api private
#
# @see https://github.com/rack/rack/blob/master/lib/rack/utils.rb #set_cookie_header!
Expand All @@ -37,7 +37,7 @@ def initialize(enabled = false, options = {})
#
# @return [TrueClass, FalseClass] enabled cookies
#
# @since x.x.x
# @since 0.3.0
# @api private
def enabled?
!!@enabled
Expand Down
11 changes: 5 additions & 6 deletions lib/lotus/config/security.rb
Expand Up @@ -2,15 +2,15 @@ module Lotus
module Config
# Security policies are stored here.
#
# @since x.x.x
# @since 0.3.0
class Security
# @since x.x.x
# @since 0.3.0
# @api private
#
# @see Lotus::Loader#_configure_controller_framework!
X_FRAME_OPTIONS_HEADER = 'X-Frame-Options'.freeze

# @since x.x.x
# @since 0.3.0
# @api private
#
# @see Lotus::Loader#_configure_controller_framework!
Expand All @@ -26,7 +26,7 @@ class Security
# Gets the value
# @return [String] X-Frame-Options header's value
#
# @since x.x.x
# @since 0.3.0
def x_frame_options(value = nil)
if value.nil?
@x_frame_options
Expand All @@ -35,7 +35,6 @@ def x_frame_options(value = nil)
end
end


# Content-Policy-Security headers' value
#
# @overload content_security_policy(value)
Expand All @@ -46,7 +45,7 @@ def x_frame_options(value = nil)
# Gets the value
# @return [String] Content-Security-Policy header's value
#
# @since x.x.x
# @since 0.3.0
def content_security_policy(value = nil)
if value.nil?
@content_security_policy
Expand Down
30 changes: 15 additions & 15 deletions lib/lotus/configuration.rb
Expand Up @@ -37,7 +37,6 @@ def initialize
# set a path for the specific environment.
#
# @param environment [Symbol,nil] the configuration environment name
# @param environment [String,nil] the configuration path of a specific environment
# @param blk [Proc] the configuration block
#
# @return [self]
Expand Down Expand Up @@ -75,7 +74,7 @@ def load!(namespace = nil)
#
# @return [Lotus::Config::Security]
#
# @since x.x.x
# @since 0.3.0
#
# @see Lotus::Config::Security
#
Expand Down Expand Up @@ -1175,14 +1174,15 @@ def port(value = nil)
# setting helps to understand the namespace where to find applications'
# controllers and actions.
#
# By default this equals to `"Controllers::%{controller}::%{action}"`
# By default this equals to <tt>"Controllers::%{controller}::%{action}"</tt>
# That means controllers must be structured like this:
# `Bookshelf::Controllers::Dashboard::Index`, where `Bookshelf` is the
# application module, `Controllers` is the first value specified in the
# pattern, `Dashboard` the controller and `Index` the action.
# <tt>Bookshelf::Controllers::Dashboard::Index</tt>, where <tt>Bookshelf</tt>
# is the application module, <tt>Controllers</tt> is the first value
# specified in the pattern, <tt>Dashboard</tt> the controller and
# <tt>Index</tt> the action.
#
# This pattern MUST always contain `"%{controller}"` and `%{action}`.
# This pattern SHOULD be used accordingly to `#view_pattern` value.
# This pattern MUST always contain <tt>"%{controller}"</tt> and <tt>%{action}</tt>.
# This pattern SHOULD be used accordingly to <tt>#view_pattern</tt> value.
#
# This is part of a DSL, for this reason when this method is called with
# an argument, it will set the corresponding instance variable. When
Expand Down Expand Up @@ -1308,15 +1308,15 @@ def controller_pattern(value = nil)
# setting helps to understand the namespace where to find applications'
# views:.
#
# By default this equals to `"Views::%{controller}::%{action}"`
# By default this equals to <tt>"Views::%{controller}::%{action}"</tt>
# That means views must be structured like this:
# `Bookshelf::Views::Dashboard::Index`, where `Bookshelf` is the
# application module, `Views` is the first value specified in the
# pattern, `Dashboard` a module corresponding to the controller name
# and `Index` the view, corresponding to the action name.
# <tt>Bookshelf::Views::Dashboard::Index</tt>, where <tt>Bookshelf</tt> is
# the application module, <tt>Views</tt> is the first value specified in the
# pattern, <tt>Dashboard</tt> a module corresponding to the controller name
# and <tt>Index</tt> the view, corresponding to the action name.
#
# This pattern MUST always contain `"%{controller}"` and `%{action}`.
# This pattern SHOULD be used accordingly to `#controller_pattern` value.
# This pattern MUST always contain <tt>"%{controller}"</tt> and <tt>%{action}</tt>.
# This pattern SHOULD be used accordingly to <tt>#controller_pattern</tt> value.
#
# This is part of a DSL, for this reason when this method is called with
# an argument, it will set the corresponding instance variable. When
Expand Down
26 changes: 13 additions & 13 deletions lib/lotus/lotusrc.rb
Expand Up @@ -4,60 +4,60 @@
module Lotus
# Create and read the .lotusrc file in the root of the application
#
# @since x.x.x
# @since 0.3.0
# @api private
class Lotusrc
# Lotusrc name file
#
# @since x.x.x
# @since 0.3.0
# @api private
#
# @see Lotus::Lotusrc#path_file
FILE_NAME = '.lotusrc'.freeze

# Architecture default value
#
# @since x.x.x
# @since 0.3.0
# @api private
#
# @see Lotus::Lotusrc#read
DEFAULT_ARCHITECTURE = 'container'.freeze

# Architecture key for writing the lotusrc file
#
# @since x.x.x
# @since 0.3.0
# @api private
#
# @see Lotus::Lotusrc#read
ARCHITECTURE_KEY = 'architecture'.freeze

# Test suite default value
#
# @since x.x.x
# @since 0.3.0
# @api private
#
# @see Lotus::Lotusrc#read
DEFAULT_TEST_SUITE = 'minitest'.freeze

# Test suite key for writing the lotusrc file
#
# @since x.x.x
# @since 0.3.0
# @api private
#
# @see Lotus::Lotusrc#read
TEST_KEY = 'test'.freeze

# Template default value
#
# @since x.x.x
# @since 0.3.0
# @api private
#
# @see Lotus::Lotusrc#read
DEFAULT_TEMPLATE = 'erb'.freeze

# Template key for writing the lotusrc file
#
# @since x.x.x
# @since 0.3.0
# @api private
#
# @see Lotus::Lotusrc#read
Expand All @@ -66,8 +66,8 @@ class Lotusrc
# Initialize Lotusrc class with application's root and enviroment options.
# Create the lotusrc file if it doesn't exist in the root given.
#
# @param [Pathname] Application's root
# @param [Hash] Environment's options
# @param root [Pathname] Application's root
# @param options [Hash] Environment's options
#
# @see Lotus::Environment#initialize
def initialize(root, options = {})
Expand Down Expand Up @@ -102,7 +102,7 @@ def read

# Create lotusrc file if exists
#
# @since x.x.x
# @since 0.3.0
# @api private
#
# @see Lotus::Lotusrc::DEFAULT_ARCHITECTURE
Expand All @@ -123,7 +123,7 @@ def create

# Check if lotusrc file exists
#
# @since x.x.x
# @since 0.3.0
# @api private
#
# @return [Boolean] lotusrc file's path existing
Expand All @@ -133,7 +133,7 @@ def exists?

# Return the lotusrc file's path
#
# @since x.x.x
# @since 0.3.0
# @api private
#
# @return [Pathname] lotusrc file's path
Expand Down
4 changes: 2 additions & 2 deletions lib/lotus/middleware.rb
Expand Up @@ -55,8 +55,8 @@ def call(env)
# Add a middleware to the stack.
#
# @param middleware [Object] a Rack middleware
# @param *args [Array] optional arguments to pass to the Rack middleware
# @param &blk [Proc] an optional block to pass to the Rack middleware
# @param args [Array] optional arguments to pass to the Rack middleware
# @param blk [Proc] an optional block to pass to the Rack middleware
#
# @return [Array] the middleware that was added
#
Expand Down
2 changes: 1 addition & 1 deletion lib/lotus/routes.rb
Expand Up @@ -136,7 +136,7 @@ def url(name, *args)
end

protected
# @since x.x.x
# @since 0.3.0
# @api private
def method_missing(m, *args)
named_route, type = m.to_s.split(/\_(path|url)\z/)
Expand Down

0 comments on commit e6d2746

Please sign in to comment.