lotusrb 0.5.0 → 0.6.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 +57 -14
- data/FEATURES.md +21 -0
- data/LICENSE.md +1 -1
- data/README.md +8 -7
- data/bin/lotus +1 -0
- data/lib/lotus.rb +6 -0
- data/lib/lotus/action/csrf_protection.rb +1 -1
- data/lib/lotus/application.rb +4 -4
- data/lib/lotus/application_name.rb +8 -6
- data/lib/lotus/cli.rb +75 -66
- data/lib/lotus/cli_sub_commands/assets.rb +29 -0
- data/lib/lotus/{commands → cli_sub_commands}/db.rb +24 -29
- data/lib/lotus/cli_sub_commands/destroy.rb +102 -0
- data/lib/lotus/cli_sub_commands/generate.rb +127 -0
- data/lib/lotus/commands/assets/precompile.rb +35 -0
- data/lib/lotus/commands/console.rb +28 -8
- data/lib/lotus/commands/db/abstract.rb +6 -2
- data/lib/lotus/commands/db/console.rb +5 -5
- data/lib/lotus/commands/generate/abstract.rb +63 -0
- data/lib/lotus/commands/generate/action.rb +262 -0
- data/lib/lotus/commands/generate/app.rb +116 -0
- data/lib/lotus/commands/generate/mailer.rb +118 -0
- data/lib/lotus/commands/generate/migration.rb +63 -0
- data/lib/lotus/commands/generate/model.rb +96 -0
- data/lib/lotus/commands/new/abstract.rb +128 -0
- data/lib/lotus/commands/new/app.rb +116 -0
- data/lib/lotus/commands/new/container.rb +102 -0
- data/lib/lotus/commands/routes.rb +19 -2
- data/lib/lotus/commands/server.rb +16 -2
- data/lib/lotus/config/framework_configuration.rb +13 -1
- data/lib/lotus/configuration.rb +24 -76
- data/lib/lotus/container.rb +15 -2
- data/lib/lotus/environment.rb +43 -4
- data/lib/lotus/frameworks.rb +1 -0
- 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 +1 -1
- data/lib/lotus/generators/action/view_spec.rspec.tt +1 -1
- data/lib/lotus/generators/{slice → app}/.gitkeep.tt +0 -0
- data/lib/lotus/generators/{slice → app}/application.rb.tt +61 -23
- data/lib/lotus/generators/app/config/initializers/.gitkeep +0 -0
- data/lib/lotus/generators/{slice → app}/config/routes.rb.tt +0 -0
- data/lib/lotus/generators/app/favicon.ico +0 -0
- data/lib/lotus/generators/{slice → app}/templates/application.html.erb.tt +2 -1
- data/lib/lotus/generators/app/views/application_layout.rb.tt +7 -0
- data/lib/lotus/generators/application/app/.env.development.tt +1 -0
- data/lib/lotus/generators/application/app/.env.test.tt +1 -0
- data/lib/lotus/generators/application/app/Gemfile.tt +1 -0
- data/lib/lotus/generators/application/app/Rakefile.minitest.tt +1 -0
- data/lib/lotus/generators/application/app/Rakefile.rspec.tt +1 -0
- data/lib/lotus/generators/application/app/config/application.rb.tt +56 -18
- data/lib/lotus/generators/application/app/config/initializers/.gitkeep +0 -0
- data/lib/lotus/generators/application/app/favicon.ico +0 -0
- data/lib/lotus/generators/application/app/gitignore.tt +2 -0
- data/lib/lotus/generators/application/app/lotusrc.tt +3 -3
- data/lib/lotus/generators/application/app/spec_helper.rb.rspec.tt +5 -1
- data/lib/lotus/generators/application/app/templates/application.html.erb.tt +1 -0
- data/lib/lotus/generators/application/container/.env.development.tt +1 -0
- data/lib/lotus/generators/application/container/.env.test.tt +1 -0
- data/lib/lotus/generators/application/container/Gemfile.tt +1 -1
- data/lib/lotus/generators/application/container/Rakefile.minitest.tt +1 -0
- data/lib/lotus/generators/application/container/Rakefile.rspec.tt +1 -0
- data/lib/lotus/generators/application/container/config/initializers/.gitkeep +0 -0
- data/lib/lotus/generators/application/container/gitignore.tt +2 -0
- data/lib/lotus/generators/application/container/lib/chirp/mailers/.gitkeep +0 -0
- data/lib/lotus/generators/application/container/lib/chirp/mailers/templates/.gitkeep +0 -0
- data/lib/lotus/generators/application/container/lotusrc.tt +3 -3
- data/lib/lotus/generators/application/container/spec_helper.rb.rspec.tt +5 -1
- data/lib/lotus/generators/database_config.rb +17 -4
- data/lib/lotus/generators/generatable.rb +51 -0
- data/lib/lotus/generators/generator.rb +35 -0
- data/lib/lotus/generators/test_framework.rb +42 -0
- data/lib/lotus/loader.rb +43 -0
- data/lib/lotus/lotusrc.rb +50 -49
- data/lib/lotus/middleware.rb +28 -10
- data/lib/lotus/rake_helper.rb +68 -0
- data/lib/lotus/rake_tasks.rb +2 -0
- data/lib/lotus/rendering_policy.rb +2 -2
- data/lib/lotus/repositories/car_repository.rb +3 -0
- data/lib/lotus/repositories/name_repository.rb +3 -0
- data/lib/lotus/setup.rb +1 -3
- data/lib/lotus/static.rb +77 -0
- data/lib/lotus/templates/welcome.html.erb +7 -4
- data/lib/lotus/version.rb +1 -1
- data/lib/lotus/views/default.rb +2 -1
- data/lib/lotus/views/default_template_finder.rb +4 -3
- data/lotusrb.gemspec +11 -9
- metadata +79 -60
- data/lib/lotus/commands/generate.rb +0 -97
- data/lib/lotus/commands/new.rb +0 -43
- data/lib/lotus/config/assets.rb +0 -81
- data/lib/lotus/generators/abstract.rb +0 -31
- data/lib/lotus/generators/action.rb +0 -235
- data/lib/lotus/generators/app.rb +0 -39
- data/lib/lotus/generators/app/.gitkeep +0 -1
- data/lib/lotus/generators/application/app.rb +0 -129
- data/lib/lotus/generators/application/container.rb +0 -111
- data/lib/lotus/generators/mailer.rb +0 -112
- data/lib/lotus/generators/migration.rb +0 -58
- data/lib/lotus/generators/model.rb +0 -90
- data/lib/lotus/generators/slice.rb +0 -94
- data/lib/lotus/generators/slice/views/application_layout.rb.tt +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 14dca86469ca5f5042c6bc2ea9e31ebaad01d19a
|
4
|
+
data.tar.gz: 0f6cbdd53e4f2c60a666fe1d691e4fda872a4f95
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b134692103f23248c496e9f4bdac72c1cd3d1b8b31961c0aa1823da8c9d25e13351f57200ac81ebed0b66361e51990b1ab5497945b79529b9d0f65e887d262c7
|
7
|
+
data.tar.gz: d47a47dd5fa20eeb449c5ee48d0e3c712f3e4eeaa62929e2329e4fb413a31ed15a1b4562ad357f936d6e56a1eaeb17e122144261579b8f4a9fc7b9eb4add653c
|
data/CHANGELOG.md
CHANGED
@@ -1,9 +1,52 @@
|
|
1
1
|
# Lotus
|
2
2
|
A complete web framework for Ruby
|
3
3
|
|
4
|
+
## v0.6.0 - 2016-01-12
|
5
|
+
### Added
|
6
|
+
- [Luca Guidi] Introduced configurable assets compressors
|
7
|
+
- [Luca Guidi] Introduced "CDN mode" in order to serve static assets via Content Distribution Networks
|
8
|
+
- [Luca Guidi] Introduced "Digest mode" in production in order to generate and serve assets with checksum suffix
|
9
|
+
- [Luca Guidi] Introduced `lotus assets precompile` command to precompile, minify and append checksum suffix to static assets
|
10
|
+
- [Luca Guidi] Send `Content-Cache` HTTP header when serving static assets in production mode
|
11
|
+
- [Luca Guidi] Support new env var `SERVE_STATIC_ASSETS="true"` in order to serve static assets for the entire project
|
12
|
+
- [Luca Guidi] Generate new applications by including `Web::Assets::Helpers` in `view.prepare` block
|
13
|
+
- [Luca Guidi] Introduced new Rake tasks `:preload` and `:environment`
|
14
|
+
- [Luca Guidi] Introduced new Rake tasks `db:migrate` and `assets:precompile` for Rails/Heroku compatibility
|
15
|
+
- [Tadeu Valentt & Lucas Allan Amorin] Added `lotus destroy` command for apps, models, actions, migrations and mailers
|
16
|
+
- [Lucas Allan Amorim] Custom initializers (`apps/web/config/initializers`) they are ran when the project is loaded and about to start
|
17
|
+
- [Trung Lê] Generate mailer templates directory for new projects (eg. `lib/bookshelf/mailers/templates`)
|
18
|
+
- [Tadeu Valentt] Alias `--database` as `-d` for `lotus new`
|
19
|
+
- [Tadeu Valentt] Alias `--arch` as `-a` for `lotus new`
|
20
|
+
- [Sean Collins] Let `lotus generate action` to guess HTTP method (`--method` arg) according to RESTful conventions
|
21
|
+
- [Gonzalo Rodríguez-Baltanás Díaz] Generate new applications with default favicon
|
22
|
+
|
23
|
+
### Fixed
|
24
|
+
- [Neil Matatall] Use "secure compare" for CSRF tokens in order to prevent timing attacks
|
25
|
+
- [Bernardo Farah] Fix support for chunked response body (via `Rack::Chunked::Body`)
|
26
|
+
- [Lucas Allan Amorim] Add `bundler` as a runtime dependency
|
27
|
+
- [Lucas Allan Amorim] Ensure to load properly Bundler dependencies when starting the application
|
28
|
+
- [Luca Guidi] Ensure sessions to be always available for other middleware in Rack stack of single applications
|
29
|
+
- [Ken Gullaksen] Ensure to specify `LOTUS_PORT` env var from `.env`
|
30
|
+
- [Andrey Deryabin] Fix `lotus new .` and prevent to generate the project in a subdirectory of current one
|
31
|
+
- [Jason Charnes] Validate entity name for model generator
|
32
|
+
- [Caius Durling] Fixed generator for nested actions (eg. `lotus generate action web domains/certs#index`)
|
33
|
+
- [Tadeu Valentt] Prevent to generate migrations with the same name
|
34
|
+
- [Luca Guidi] Ensure RSpec examples to be generated with `RSpec.describe` instead of only `describe`
|
35
|
+
- [Andrey Deryabin] Avoid `lotus` command to generate unnecessary `.lotusrc` files
|
36
|
+
- [Jason Charnes] Convert camel case application name into snake case when generating actions (eg. `BeautifulBlossoms` to `beautiful_blossoms`)
|
37
|
+
- [Alfonso Uceda Pompa] Convert dasherized names into underscored names when generating projects (eg. `awesome-project` to `awesome_project`)
|
38
|
+
|
39
|
+
### Changed
|
40
|
+
- [Sean Collins] Welcome page shows current year in copyright notes
|
41
|
+
- [Luca Guidi] Add `/public/assets*` to `.gitignore` of new projects
|
42
|
+
- [Luca Guidi] Removed support for `default_format` in favor of `default_request_format`
|
43
|
+
- [Luca Guidi] Removed support for `apps/web/public` in favor of `apps/web/assets` as assets sources for applications
|
44
|
+
- [Luca Guidi] Removed support for `serve_assets` for single applications in order to global static assets server enabled via `SERVE_STATIC_ASSETS` env var
|
45
|
+
- [Luca Guidi] `assets` configuration in `apps/web/application.rb` now accepts a block to configure sources and other settings
|
46
|
+
|
4
47
|
## v0.5.0 - 2015-09-30
|
5
48
|
### Added
|
6
|
-
- [Ines Coelho & Rosa Faria]
|
49
|
+
- [Ines Coelho & Rosa Faria] Introduced mailers support
|
7
50
|
- [Theo Felippe] Added configuration entries: `#default_request_format` and `default_response_format`
|
8
51
|
- [Rodrigo Panachi] Introduced `logger` configuration for applications, to be used like this: `Web::Logger.debug`
|
9
52
|
- [Ben Lovell] Simpler and less verbose RSpec tests
|
@@ -26,7 +69,7 @@ A complete web framework for Ruby
|
|
26
69
|
### Fixed
|
27
70
|
- [Alfonso Uceda Pompa] Ensure to load correctly apps in `lotus console`
|
28
71
|
- [Alfonso Uceda Pompa] Ensure to not duplicate prefix for Container mounted apps (eg `/admin/admin/dashboard`)
|
29
|
-
- [Alfonso Uceda Pompa] Ensure generator for application
|
72
|
+
- [Alfonso Uceda Pompa] Ensure generator for "application" architecture to generate session secret
|
30
73
|
- [Alfonso Uceda Pompa & Trung Lê & Hiếu Nguyễn] Exit unsuccessfully when `lotus generate model` doesn't receive a mandatory name for model
|
31
74
|
- [Miguel Molina] Exit unsuccessfully when `lotus new --database` receives an unknown value
|
32
75
|
- [Luca Guidi] Ensure to prepend sessions middleware, so other Rack components can have access to HTTP session
|
@@ -49,7 +92,7 @@ A complete web framework for Ruby
|
|
49
92
|
- [Luca Guidi] `.env`, `.env.development` and `.env.test` are generated and expected to be placed at the root of the project.
|
50
93
|
- [Luca Guidi] Remove database mapping from generated apps.
|
51
94
|
- [Trung Lê & Luca Guidi] Remove default generated from new apps.
|
52
|
-
- [Luca Guidi] New
|
95
|
+
- [Luca Guidi] New projects should depend on `lotus-model ~> 0.4`
|
53
96
|
|
54
97
|
## v0.3.2 - 2015-05-22
|
55
98
|
### Added
|
@@ -79,9 +122,9 @@ A complete web framework for Ruby
|
|
79
122
|
- [Luca Guidi] Introduced action generator. Eg. `bundle exec lotus generate action web dashboard#index`
|
80
123
|
- [Alfonso Uceda Pompa] Allow to specify default coookies options in application configuration. Eg. `cookies true, { domain: 'lotusrb.org' }`
|
81
124
|
- [Tom Kadwill] Include `Lotus::Helpers` in views.
|
82
|
-
- [Linus Pettersson] Allow to specify `--database` CLI option when generate a new
|
83
|
-
- [Linus Pettersson] Initialize a Git repository when generating a new
|
84
|
-
- [Alfonso Uceda Pompa] Produce `.lotusrc` when generating a new
|
125
|
+
- [Linus Pettersson] Allow to specify `--database` CLI option when generate a new project. Eg. `lotus new bookshelf --database=postgresql`
|
126
|
+
- [Linus Pettersson] Initialize a Git repository when generating a new project
|
127
|
+
- [Alfonso Uceda Pompa] Produce `.lotusrc` when generating a new project
|
85
128
|
- [Alfonso Uceda Pompa] Security HTTP headers. `X-Frame-Options` and `Content-Security-Policy` are now enabled by default.
|
86
129
|
- [Linus Pettersson] Database console. Run with `bundle exec lotus db console`
|
87
130
|
- [Luca Guidi] Dynamic finders for relative and absolute routes. It implements method missing: `Web::Routes.home_path` will resolve to `Web::Routes.path(:home)`.
|
@@ -95,21 +138,21 @@ A complete web framework for Ruby
|
|
95
138
|
### Added
|
96
139
|
- [Huy Đỗ] Introduced `Lotus::Logger`
|
97
140
|
- [Jimmy Zhang] `lotus new` accepts a `--path` argument
|
98
|
-
- [Jimmy Zhang]
|
99
|
-
- [Trung Lê] Add example mapping file for
|
100
|
-
- [Hiếu Nguyễn] RSpec support for
|
141
|
+
- [Jimmy Zhang] Project generator for the current directory (`lotus new .`). This is useful to provide a web deliverable for existing Ruby gems.
|
142
|
+
- [Trung Lê] Add example mapping file for project generator: `lib/config/mapping.rb`
|
143
|
+
- [Hiếu Nguyễn] RSpec support for project generator: `--test=rspec` or `--test=minitest` (default)
|
101
144
|
|
102
145
|
### Fixed
|
103
146
|
- [Luca Guidi] `lotus version` to previx `v` (eg `v0.2.1`)
|
104
|
-
- [Rob Yurkowski] Ensure
|
147
|
+
- [Rob Yurkowski] Ensure project name doesn't contain special or forbidden characters
|
105
148
|
- [Luca Guidi] Ensure all the applications are loaded in console
|
106
|
-
- [Trung Lê] Container architecture: preload only `lib/<
|
107
|
-
- [Hiếu Nguyễn] Fixed `lotus new` to print usage when
|
149
|
+
- [Trung Lê] Container architecture: preload only `lib/<projectname>/**/*.rb`
|
150
|
+
- [Hiếu Nguyễn] Fixed `lotus new` to print usage when project name isn't provided
|
108
151
|
|
109
152
|
## v0.2.0 - 2014-06-23
|
110
153
|
### Added
|
111
|
-
- [Luca Guidi] Introduced `lotus new` as a command to generate
|
112
|
-
- [Luca Guidi] Show a welcome page when
|
154
|
+
- [Luca Guidi] Introduced `lotus new` as a command to generate projects. It supports "container" architecture for now.
|
155
|
+
- [Luca Guidi] Show a welcome page when one mounted Lotus application doesn't have routes
|
113
156
|
- [Luca Guidi] Introduced `Lotus::Application.preload!` to preload all the Lotus applications in a given Ruby process. (Bulk `Lotus::Application.load!`)
|
114
157
|
- [Trung Lê] Allow browsers to fake non `GET`/`POST` requests via `Rack::MethodOverride`
|
115
158
|
- [Josue Abreu] Allow to define body parses for non `GET` HTTP requests (`body_parsers` configuration)
|
data/FEATURES.md
CHANGED
@@ -3,6 +3,27 @@
|
|
3
3
|
|
4
4
|
## Features
|
5
5
|
|
6
|
+
## v0.6.0 - 2016-01-12
|
7
|
+
|
8
|
+
- Assets preprocessors support (eg. Sass, ES6, Opal, Less, CoffeScript..)
|
9
|
+
- Assets compressors (eg. YUI, UglifyJS2, Google Closure Compiler, Sass..)
|
10
|
+
- Assets helpers:
|
11
|
+
* `javascript`
|
12
|
+
* `stylesheet`
|
13
|
+
* `favicon`
|
14
|
+
* `image`
|
15
|
+
* `video`
|
16
|
+
* `audio`
|
17
|
+
* `asset_path`
|
18
|
+
* `asset_url`
|
19
|
+
- Content Delivery Network (CDN) support for static assets (CDN mode)
|
20
|
+
- Checksum suffix for static assets in production mode (Digest mode)
|
21
|
+
- Support for third party gems as assets distribution channel (eg. `lotus-jquery`)
|
22
|
+
- CLI: `lotus assets` command `precompile`: preprocess, minify and append checksum suffix
|
23
|
+
- CLI: `lotus destroy` destroy apps, models, actions, migrations and mailers
|
24
|
+
- Custom initializers (`apps/web/config/initializers`)
|
25
|
+
- Rake tasks `:preload` and `:environment`
|
26
|
+
|
6
27
|
## v0.5.0 - 2015-09-30
|
7
28
|
|
8
29
|
- Mailers
|
data/LICENSE.md
CHANGED
data/README.md
CHANGED
@@ -12,6 +12,7 @@ Lotus combines small yet powerful frameworks:
|
|
12
12
|
* [**Lotus::Helpers**](https://github.com/lotus/helpers) - View helpers for Ruby applications
|
13
13
|
* [**Lotus::Mailer**](https://github.com/lotus/mailer) - Mail for Ruby applications
|
14
14
|
* [**Lotus::Model**](https://github.com/lotus/model) - Persistence with entities, repositories and data mapper
|
15
|
+
* [**Lotus::Assets**](https://github.com/lotus/assets) - Assets management for Ruby
|
15
16
|
* [**Lotus::View**](https://github.com/lotus/view) - Presentation with a separation between views and templates
|
16
17
|
* [**Lotus::Controller**](https://github.com/lotus/controller) - Full featured, fast and testable actions for Rack
|
17
18
|
|
@@ -20,12 +21,12 @@ If you aren't familiar with them, please take time to go through their READMEs.
|
|
20
21
|
|
21
22
|
## Status
|
22
23
|
|
23
|
-
[![Gem Version](https://badge.fury.io/rb/lotusrb.
|
24
|
-
[![Build Status](https://secure.travis-ci.org/lotus/lotus.
|
25
|
-
[![Coverage](https://coveralls.io/repos/lotus/lotus/badge.
|
26
|
-
[![Code Climate](https://codeclimate.com/github/lotus/lotus.
|
27
|
-
[![Dependencies](https://gemnasium.com/lotus/lotus.
|
28
|
-
[![Inline docs](http://inch-ci.org/github/lotus/lotus.
|
24
|
+
[![Gem Version](https://badge.fury.io/rb/lotusrb.svg)](http://badge.fury.io/rb/lotusrb)
|
25
|
+
[![Build Status](https://secure.travis-ci.org/lotus/lotus.svg?branch=master)](http://travis-ci.org/lotus/lotus?branch=master)
|
26
|
+
[![Coverage](https://coveralls.io/repos/lotus/lotus/badge.svg?branch=master)](https://coveralls.io/r/lotus/lotus)
|
27
|
+
[![Code Climate](https://codeclimate.com/github/lotus/lotus.svg)](https://codeclimate.com/github/lotus/lotus)
|
28
|
+
[![Dependencies](https://gemnasium.com/lotus/lotus.svg)](https://gemnasium.com/lotus/lotus)
|
29
|
+
[![Inline docs](http://inch-ci.org/github/lotus/lotus.svg)](http://inch-ci.org/github/lotus/lotus)
|
29
30
|
|
30
31
|
## Contact
|
31
32
|
|
@@ -96,4 +97,4 @@ __Lotus__ uses [Semantic Versioning 2.0.0](http://semver.org)
|
|
96
97
|
|
97
98
|
## Copyright
|
98
99
|
|
99
|
-
Copyright © 2014-
|
100
|
+
Copyright © 2014-2016 Luca Guidi – Released under MIT License
|
data/bin/lotus
CHANGED
data/lib/lotus.rb
CHANGED
@@ -9,6 +9,8 @@ require 'lotus/environment'
|
|
9
9
|
#
|
10
10
|
# @see http://lotusrb.org
|
11
11
|
module Lotus
|
12
|
+
DEFAULT_PUBLIC_DIRECTORY = 'public'.freeze
|
13
|
+
|
12
14
|
# Return root of the project (top level directory).
|
13
15
|
#
|
14
16
|
# @return [Pathname] root path
|
@@ -21,6 +23,10 @@ module Lotus
|
|
21
23
|
environment.root
|
22
24
|
end
|
23
25
|
|
26
|
+
def self.public_directory
|
27
|
+
root.join(DEFAULT_PUBLIC_DIRECTORY)
|
28
|
+
end
|
29
|
+
|
24
30
|
# Return the current environment
|
25
31
|
#
|
26
32
|
# @return [String] the current environment
|
@@ -129,7 +129,7 @@ module Lotus
|
|
129
129
|
# @api private
|
130
130
|
def invalid_csrf_token?
|
131
131
|
verify_csrf_token? &&
|
132
|
-
session[CSRF_TOKEN]
|
132
|
+
! ::Rack::Utils.secure_compare(session[CSRF_TOKEN], params[CSRF_TOKEN])
|
133
133
|
end
|
134
134
|
|
135
135
|
# Generates a random CSRF Token
|
data/lib/lotus/application.rb
CHANGED
@@ -134,9 +134,9 @@ module Lotus
|
|
134
134
|
# end
|
135
135
|
#
|
136
136
|
# module Controllers::Dashboard
|
137
|
-
#
|
137
|
+
# class Index
|
138
|
+
# include OneFile::Action
|
138
139
|
#
|
139
|
-
# action 'Index' do
|
140
140
|
# def call(params)
|
141
141
|
# self.body = 'Hello!'
|
142
142
|
# end
|
@@ -211,10 +211,10 @@ module Lotus
|
|
211
211
|
# @since 0.1.0
|
212
212
|
#
|
213
213
|
# @see http://rack.github.io
|
214
|
+
# @see Lotus::RenderingPolicy#render
|
214
215
|
# @see Lotus::Application#middleware
|
215
216
|
def call(env)
|
216
|
-
renderer.render(env,
|
217
|
-
middleware.call(env))
|
217
|
+
renderer.render(env, middleware.call(env))
|
218
218
|
end
|
219
219
|
|
220
220
|
# Rack middleware stack
|
@@ -9,7 +9,6 @@ module Lotus
|
|
9
9
|
# @since 0.2.1
|
10
10
|
RESERVED_WORDS = %w(lotus).freeze
|
11
11
|
|
12
|
-
|
13
12
|
# Initialize and check against reserved words
|
14
13
|
#
|
15
14
|
# An application name needs to be translated in quite a few ways:
|
@@ -33,9 +32,10 @@ module Lotus
|
|
33
32
|
ensure_validity!
|
34
33
|
end
|
35
34
|
|
36
|
-
|
37
35
|
# Returns the cleaned application name.
|
38
36
|
#
|
37
|
+
# @return [String] the santized name
|
38
|
+
#
|
39
39
|
# @example
|
40
40
|
# ApplicationName.new("my-App ").to_s # => "my-app"
|
41
41
|
#
|
@@ -44,10 +44,11 @@ module Lotus
|
|
44
44
|
@name
|
45
45
|
end
|
46
46
|
|
47
|
-
|
48
47
|
# Returns the application name uppercased with non-alphanumeric characters
|
49
48
|
# as underscores.
|
50
49
|
#
|
50
|
+
# @return [String] the upcased name
|
51
|
+
#
|
51
52
|
# @example
|
52
53
|
# ApplicationName.new("my-app").to_env_s => "MY_APP"
|
53
54
|
#
|
@@ -56,10 +57,12 @@ module Lotus
|
|
56
57
|
@name.upcase.gsub(/\W/, '_')
|
57
58
|
end
|
58
59
|
|
59
|
-
|
60
60
|
# Returns true if a potential application name matches one of the reserved
|
61
61
|
# words.
|
62
62
|
#
|
63
|
+
# @param name [String] the application name
|
64
|
+
# @return [TrueClass, FalseClass] the result of the check
|
65
|
+
#
|
63
66
|
# @example
|
64
67
|
# Lotus::ApplicationName.invalid?("lotus") # => true
|
65
68
|
#
|
@@ -68,7 +71,6 @@ module Lotus
|
|
68
71
|
RESERVED_WORDS.include?(name)
|
69
72
|
end
|
70
73
|
|
71
|
-
|
72
74
|
private
|
73
75
|
|
74
76
|
# Raises RuntimeError with explanation if the provided name is invalid.
|
@@ -83,7 +85,6 @@ module Lotus
|
|
83
85
|
end
|
84
86
|
end
|
85
87
|
|
86
|
-
|
87
88
|
# Cleans a string to be a functioning application name.
|
88
89
|
#
|
89
90
|
# @api private
|
@@ -94,6 +95,7 @@ module Lotus
|
|
94
95
|
.strip
|
95
96
|
.gsub(/\s/, '_')
|
96
97
|
.gsub(/_{2,}/, '_')
|
98
|
+
.gsub(/-/, '_')
|
97
99
|
end
|
98
100
|
end
|
99
101
|
end
|
data/lib/lotus/cli.rb
CHANGED
@@ -1,110 +1,119 @@
|
|
1
1
|
require 'thor'
|
2
|
-
require 'lotus/
|
3
|
-
require 'lotus/
|
2
|
+
require 'lotus/commands/console'
|
3
|
+
require 'lotus/commands/new/app'
|
4
|
+
require 'lotus/commands/new/container'
|
4
5
|
|
5
6
|
module Lotus
|
6
7
|
class Cli < Thor
|
7
|
-
include Thor::Actions
|
8
|
+
# include Thor::Actions
|
8
9
|
|
9
10
|
desc 'version', 'prints Lotus version'
|
11
|
+
long_desc <<-EOS
|
12
|
+
`lotus version` prints the version of the bundled lotus gem.
|
13
|
+
EOS
|
10
14
|
def version
|
15
|
+
require 'lotus/version'
|
11
16
|
puts "v#{ Lotus::VERSION }"
|
12
17
|
end
|
13
18
|
|
14
19
|
desc 'server', 'starts a lotus server'
|
15
|
-
|
16
|
-
|
17
|
-
method_option :rackup, desc: 'a rackup configuration file path to load (config.ru)'
|
18
|
-
method_option :host, desc: 'the host address to bind to'
|
19
|
-
method_option :debug, desc: 'turn on debug output'
|
20
|
-
method_option :warn, desc: 'turn on warnings'
|
21
|
-
method_option :daemonize, desc: 'if true, the server will daemonize itself (fork, detach, etc)'
|
22
|
-
method_option :pid, desc: 'path to write a pid file after daemonize'
|
23
|
-
method_option :environment, desc: 'path to environment configuration (config/environment.rb)'
|
24
|
-
method_option :code_reloading, desc: 'code reloading', type: :boolean, default: true
|
25
|
-
method_option :help, aliases: '-h', desc: 'displays the usage message'
|
20
|
+
long_desc <<-EOS
|
21
|
+
`lotus server` starts a server for the current lotus project.
|
26
22
|
|
23
|
+
$ > lotus server
|
24
|
+
|
25
|
+
$ > lotus server -p 4500
|
26
|
+
EOS
|
27
|
+
method_option :port, aliases: '-p', desc: 'The port to run the server on, '
|
28
|
+
method_option :server, desc: 'choose a specific Rack::Handler, e.g. webrick, thin etc'
|
29
|
+
method_option :rackup, desc: 'a rackup configuration file path to load (config.ru)'
|
30
|
+
method_option :host, desc: 'the host address to bind to'
|
31
|
+
method_option :debug, desc: 'turn on debug output'
|
32
|
+
method_option :warn, desc: 'turn on warnings'
|
33
|
+
method_option :daemonize, desc: 'if true, the server will daemonize itself (fork, detach, etc)'
|
34
|
+
method_option :pid, desc: 'path to write a pid file after daemonize'
|
35
|
+
method_option :environment, desc: 'path to environment configuration (config/environment.rb)'
|
36
|
+
method_option :code_reloading, desc: 'code reloading', type: :boolean, default: true
|
37
|
+
method_option :help, desc: 'displays the usage message'
|
27
38
|
def server
|
28
39
|
if options[:help]
|
29
40
|
invoke :help, ['server']
|
30
41
|
else
|
31
42
|
require 'lotus/commands/server'
|
32
|
-
Lotus::Commands::Server.new(
|
43
|
+
Lotus::Commands::Server.new(options).start
|
33
44
|
end
|
34
45
|
end
|
35
46
|
|
36
47
|
desc 'console', 'starts a lotus console'
|
37
|
-
|
38
|
-
|
39
|
-
method_option :help, aliases: '-h', desc: 'displays the usage method'
|
48
|
+
long_desc <<-EOS
|
49
|
+
`lotus console` starts the interactive lotus console.
|
40
50
|
|
51
|
+
$ > lotus console --engine=pry
|
52
|
+
EOS
|
53
|
+
method_option :environment, desc: 'path to environment configuration (config/environment.rb)'
|
54
|
+
method_option :engine, desc: "choose a specific console engine: (#{Lotus::Commands::Console::ENGINES.keys.join('/')})", default: Lotus::Commands::Console::DEFAULT_ENGINE
|
55
|
+
method_option :help, desc: 'displays the usage method'
|
41
56
|
def console
|
42
57
|
if options[:help]
|
43
58
|
invoke :help, ['console']
|
44
59
|
else
|
45
|
-
|
46
|
-
Lotus::Commands::Console.new(environment).start
|
60
|
+
Lotus::Commands::Console.new(options).start
|
47
61
|
end
|
48
62
|
end
|
49
63
|
|
50
|
-
desc '
|
51
|
-
|
52
|
-
|
64
|
+
desc 'new APPLICATION_NAME', 'generate a new lotus project'
|
65
|
+
long_desc <<-EOS
|
66
|
+
`lotus new` creates a new lotus project.
|
67
|
+
You can specify various options such as the database to be used as well as the path and architecture.
|
53
68
|
|
54
|
-
|
55
|
-
if options[:help]
|
56
|
-
invoke :help, ['routes']
|
57
|
-
else
|
58
|
-
require 'lotus/commands/routes'
|
59
|
-
Lotus::Commands::Routes.new(environment).start
|
60
|
-
end
|
61
|
-
end
|
69
|
+
$ > lotus new fancy_app --application_name=admin
|
62
70
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
method_option :
|
68
|
-
method_option :
|
69
|
-
method_option :
|
70
|
-
method_option :
|
71
|
-
method_option :
|
72
|
-
|
73
|
-
|
74
|
-
|
71
|
+
$ > lotus new fancy_app --arch=app
|
72
|
+
|
73
|
+
$ > lotus new fancy_app --lotus-head=true
|
74
|
+
EOS
|
75
|
+
method_option :database, aliases: ['-d', '--db'], desc: "application database (#{Lotus::Generators::DatabaseConfig::SUPPORTED_ENGINES.keys.join('/')})", default: Lotus::Generators::DatabaseConfig::DEFAULT_ENGINE
|
76
|
+
method_option :architecture, aliases: ['-a', '--arch'], desc: 'project architecture (container/app)', default: Lotus::Commands::New::Abstract::DEFAULT_ARCHITECTURE
|
77
|
+
method_option :application_name, desc: 'application name, only for container', default: Lotus::Commands::New::Container::DEFAULT_APPLICATION_NAME
|
78
|
+
method_option :application_base_url, desc: 'application base url', default: Lotus::Commands::New::Abstract::DEFAULT_APPLICATION_BASE_URL
|
79
|
+
method_option :test, desc: "project test framework (#{Lotus::Generators::TestFramework::VALID_FRAMEWORKS.join('/')})", default: Lotus::Lotusrc::DEFAULT_TEST_SUITE
|
80
|
+
method_option :lotus_head, desc: 'use Lotus HEAD (true/false)', type: :boolean, default: false
|
81
|
+
method_option :help, desc: 'displays the usage method'
|
82
|
+
def new(application_name)
|
83
|
+
if options[:help]
|
75
84
|
invoke :help, ['new']
|
85
|
+
elsif options[:architecture] == 'app'
|
86
|
+
Lotus::Commands::New::App.new(options, application_name).start
|
76
87
|
else
|
77
|
-
|
78
|
-
Lotus::Commands::New.new(name, environment, self).start
|
88
|
+
Lotus::Commands::New::Container.new(options, application_name).start
|
79
89
|
end
|
80
90
|
end
|
81
91
|
|
82
|
-
desc '
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
method_option :
|
87
|
-
method_option :
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
# @api private
|
92
|
-
def generate(type = nil, app_name = nil, name = nil)
|
93
|
-
if options[:help] || (type.nil? && app_name.nil? && name.nil?)
|
94
|
-
invoke :help, ['generate']
|
92
|
+
desc 'routes', 'prints the routes'
|
93
|
+
long_desc <<-EOS
|
94
|
+
`lotus routes` outputs all the registered routes to the console.
|
95
|
+
EOS
|
96
|
+
method_option :environment, desc: 'path to environment configuration (config/environment.rb)'
|
97
|
+
method_option :help, desc: 'displays the usage method'
|
98
|
+
def routes
|
99
|
+
if options[:help]
|
100
|
+
invoke :help, ['routes']
|
95
101
|
else
|
96
|
-
require 'lotus/commands/
|
97
|
-
Lotus::Commands::
|
102
|
+
require 'lotus/commands/routes'
|
103
|
+
Lotus::Commands::Routes.new(options).start
|
98
104
|
end
|
99
105
|
end
|
100
106
|
|
101
|
-
require 'lotus/
|
102
|
-
register Lotus::
|
107
|
+
require 'lotus/cli_sub_commands/db'
|
108
|
+
register Lotus::CliSubCommands::DB, 'db', 'db [SUBCOMMAND]', 'manage set of DB operations'
|
103
109
|
|
104
|
-
|
110
|
+
require 'lotus/cli_sub_commands/generate'
|
111
|
+
register Lotus::CliSubCommands::Generate, 'generate', 'generate [SUBCOMMAND]', 'generate lotus classes'
|
105
112
|
|
106
|
-
|
107
|
-
|
108
|
-
|
113
|
+
require 'lotus/cli_sub_commands/destroy'
|
114
|
+
register Lotus::CliSubCommands::Destroy, 'destroy', 'destroy [SUBCOMMAND]', 'destroy lotus classes'
|
115
|
+
|
116
|
+
require 'lotus/cli_sub_commands/assets'
|
117
|
+
register Lotus::CliSubCommands::Assets, 'assets', 'assets [SUBCOMMAND]', 'manage assets'
|
109
118
|
end
|
110
119
|
end
|