Lotus => Hanami
This commit is contained in:
parent
f68481fce5
commit
a0140d15d6
|
@ -22,7 +22,7 @@ tmp
|
|||
mkmf.log
|
||||
.greenbar
|
||||
.DS_Store
|
||||
.lotusrc
|
||||
.hanamirc
|
||||
test/fixtures/static_assets/public/assets*
|
||||
test/fixtures/static_assets_app/public/assets*
|
||||
test/fixtures/rake/rake_tasks/public/assets*
|
||||
|
|
20
.travis.yml
20
.travis.yml
|
@ -10,23 +10,8 @@ script:
|
|||
- 'bundle install'
|
||||
- './script/ci'
|
||||
rvm:
|
||||
- 2.0.0
|
||||
- 2.1.0
|
||||
- 2.1.1
|
||||
- 2.1.2
|
||||
- 2.1.3
|
||||
- 2.1.4
|
||||
- 2.1.5
|
||||
- 2.1.6
|
||||
- 2.1.7
|
||||
- 2.1.8
|
||||
- 2.2.0
|
||||
- 2.2.1
|
||||
- 2.2.2
|
||||
- 2.2.3
|
||||
- 2.2.4
|
||||
- 2.3.0
|
||||
- rbx-2
|
||||
- 2.2
|
||||
- 2.3
|
||||
- jruby-9000
|
||||
- jruby-9.0.1.0
|
||||
- jruby-9.0.3.0
|
||||
|
@ -35,7 +20,6 @@ rvm:
|
|||
|
||||
matrix:
|
||||
allow_failures:
|
||||
- rvm: rbx-2
|
||||
- rvm: jruby-head
|
||||
- rvm: ruby-head
|
||||
- rvm: jruby-9000
|
||||
|
|
98
CHANGELOG.md
98
CHANGELOG.md
|
@ -1,4 +1,4 @@
|
|||
# Lotus
|
||||
# Hanami
|
||||
A complete web framework for Ruby
|
||||
|
||||
## v0.6.1 - 2016-01-19
|
||||
|
@ -7,7 +7,7 @@ A complete web framework for Ruby
|
|||
- [Anton Davydov] Fix project creation when name contains dashes (eg. `"awesome-project" => "AwesomeProject"`)
|
||||
- [Anton Davydov] Ensure to add assets related entries to `.gitignore` when a project is generated with the `--database` flag
|
||||
- [deepj] Avoid blank lines in generated `Gemfile`
|
||||
- [trexnix] Fix for `lotus destroy app`: it doesn't cause a syntax error in `config/application.rb` anymore
|
||||
- [trexnix] Fix for `hanami destroy app`: it doesn't cause a syntax error in `config/application.rb` anymore
|
||||
- [Serg Ikonnikov & Trung Lê] Ensure console to use the bundled engine
|
||||
|
||||
## v0.6.0 - 2016-01-12
|
||||
|
@ -15,18 +15,18 @@ A complete web framework for Ruby
|
|||
- [Luca Guidi] Introduced configurable assets compressors
|
||||
- [Luca Guidi] Introduced "CDN mode" in order to serve static assets via Content Distribution Networks
|
||||
- [Luca Guidi] Introduced "Digest mode" in production in order to generate and serve assets with checksum suffix
|
||||
- [Luca Guidi] Introduced `lotus assets precompile` command to precompile, minify and append checksum suffix to static assets
|
||||
- [Luca Guidi] Introduced `hanami assets precompile` command to precompile, minify and append checksum suffix to static assets
|
||||
- [Luca Guidi] Send `Content-Cache` HTTP header when serving static assets in production mode
|
||||
- [Luca Guidi] Support new env var `SERVE_STATIC_ASSETS="true"` in order to serve static assets for the entire project
|
||||
- [Luca Guidi] Generate new applications by including `Web::Assets::Helpers` in `view.prepare` block
|
||||
- [Luca Guidi] Introduced new Rake tasks `:preload` and `:environment`
|
||||
- [Luca Guidi] Introduced new Rake tasks `db:migrate` and `assets:precompile` for Rails/Heroku compatibility
|
||||
- [Tadeu Valentt & Lucas Allan Amorin] Added `lotus destroy` command for apps, models, actions, migrations and mailers
|
||||
- [Tadeu Valentt & Lucas Allan Amorin] Added `hanami destroy` command for apps, models, actions, migrations and mailers
|
||||
- [Lucas Allan Amorim] Custom initializers (`apps/web/config/initializers`) they are ran when the project is loaded and about to start
|
||||
- [Trung Lê] Generate mailer templates directory for new projects (eg. `lib/bookshelf/mailers/templates`)
|
||||
- [Tadeu Valentt] Alias `--database` as `-d` for `lotus new`
|
||||
- [Tadeu Valentt] Alias `--arch` as `-a` for `lotus new`
|
||||
- [Sean Collins] Let `lotus generate action` to guess HTTP method (`--method` arg) according to RESTful conventions
|
||||
- [Tadeu Valentt] Alias `--database` as `-d` for `hanami new`
|
||||
- [Tadeu Valentt] Alias `--arch` as `-a` for `hanami new`
|
||||
- [Sean Collins] Let `hanami generate action` to guess HTTP method (`--method` arg) according to RESTful conventions
|
||||
- [Gonzalo Rodríguez-Baltanás Díaz] Generate new applications with default favicon
|
||||
|
||||
### Fixed
|
||||
|
@ -35,13 +35,13 @@ A complete web framework for Ruby
|
|||
- [Lucas Allan Amorim] Add `bundler` as a runtime dependency
|
||||
- [Lucas Allan Amorim] Ensure to load properly Bundler dependencies when starting the application
|
||||
- [Luca Guidi] Ensure sessions to be always available for other middleware in Rack stack of single applications
|
||||
- [Ken Gullaksen] Ensure to specify `LOTUS_PORT` env var from `.env`
|
||||
- [Andrey Deryabin] Fix `lotus new .` and prevent to generate the project in a subdirectory of current one
|
||||
- [Ken Gullaksen] Ensure to specify `HANAMI_PORT` env var from `.env`
|
||||
- [Andrey Deryabin] Fix `hanami new .` and prevent to generate the project in a subdirectory of current one
|
||||
- [Jason Charnes] Validate entity name for model generator
|
||||
- [Caius Durling] Fixed generator for nested actions (eg. `lotus generate action web domains/certs#index`)
|
||||
- [Caius Durling] Fixed generator for nested actions (eg. `hanami generate action web domains/certs#index`)
|
||||
- [Tadeu Valentt] Prevent to generate migrations with the same name
|
||||
- [Luca Guidi] Ensure RSpec examples to be generated with `RSpec.describe` instead of only `describe`
|
||||
- [Andrey Deryabin] Avoid `lotus` command to generate unnecessary `.lotusrc` files
|
||||
- [Andrey Deryabin] Avoid `hanami` command to generate unnecessary `.hanamirc` files
|
||||
- [Jason Charnes] Convert camel case application name into snake case when generating actions (eg. `BeautifulBlossoms` to `beautiful_blossoms`)
|
||||
- [Alfonso Uceda Pompa] Convert dasherized names into underscored names when generating projects (eg. `awesome-project` to `awesome_project`)
|
||||
|
||||
|
@ -64,7 +64,7 @@ A complete web framework for Ruby
|
|||
### Fixed
|
||||
- [Luca Guidi] Handle conflicts between directories with the same name while serving static assets
|
||||
- [Derk-Jan Karrenbeld] Include default value `font-src: self` for CSP HTTP header
|
||||
- [Cam Huynh] Make CLI arguments immutable for `Lotus::Environment`
|
||||
- [Cam Huynh] Make CLI arguments immutable for `Hanami::Environment`
|
||||
- [Andrii Ponomarov] Disable welcome page in test environment
|
||||
- [Alfonso Uceda Pompa] Print error message and exit when no name is provided to model generator
|
||||
|
||||
|
@ -73,14 +73,14 @@ A complete web framework for Ruby
|
|||
|
||||
## v0.4.1 - 2015-07-10
|
||||
### Added
|
||||
- [Trung Lê] Alias `--database` as `--db` for `lotus new`
|
||||
- [Trung Lê] Alias `--database` as `--db` for `hanami new`
|
||||
|
||||
### Fixed
|
||||
- [Alfonso Uceda Pompa] Ensure to load correctly apps in `lotus console`
|
||||
- [Alfonso Uceda Pompa] Ensure to load correctly apps in `hanami console`
|
||||
- [Alfonso Uceda Pompa] Ensure to not duplicate prefix for Container mounted apps (eg `/admin/admin/dashboard`)
|
||||
- [Alfonso Uceda Pompa] Ensure generator for "application" architecture to generate session secret
|
||||
- [Alfonso Uceda Pompa & Trung Lê & Hiếu Nguyễn] Exit unsuccessfully when `lotus generate model` doesn't receive a mandatory name for model
|
||||
- [Miguel Molina] Exit unsuccessfully when `lotus new --database` receives an unknown value
|
||||
- [Alfonso Uceda Pompa & Trung Lê & Hiếu Nguyễn] Exit unsuccessfully when `hanami generate model` doesn't receive a mandatory name for model
|
||||
- [Miguel Molina] Exit unsuccessfully when `hanami new --database` receives an unknown value
|
||||
- [Luca Guidi] Ensure to prepend sessions middleware, so other Rack components can have access to HTTP session
|
||||
|
||||
## v0.4.0 - 2015-06-23
|
||||
|
@ -94,20 +94,20 @@ A complete web framework for Ruby
|
|||
|
||||
### Fixed
|
||||
- [Alfonso Uceda Pompa] Fix generated routes for Container applications mounted on a path different from `/`.
|
||||
- [Luca Guidi] Reading `.lotusrc` pollutes `ENV` with unwanted variables.
|
||||
- [Luca Guidi] Reading `.hanamirc` pollutes `ENV` with unwanted variables.
|
||||
- [Alfonso Uceda Pompa] Added sqlite extension to SQLite/SQLite3 database URL.
|
||||
|
||||
### Changed
|
||||
- [Luca Guidi] `.env`, `.env.development` and `.env.test` are generated and expected to be placed at the root of the project.
|
||||
- [Luca Guidi] Remove database mapping from generated apps.
|
||||
- [Trung Lê & Luca Guidi] Remove default generated from new apps.
|
||||
- [Luca Guidi] New projects should depend on `lotus-model ~> 0.4`
|
||||
- [Luca Guidi] New projects should depend on `hanami-model ~> 0.4`
|
||||
|
||||
## v0.3.2 - 2015-05-22
|
||||
### Added
|
||||
- [Alfonso Uceda Pompa] Automatic secure cookies if the current connection is using HTTPS.
|
||||
- [Alfonso Uceda Pompa] Routing helpers for actions (via `#routes`).
|
||||
- [My Mai] Introduced `Lotus.root`. It returns the top level directory of the project.
|
||||
- [My Mai] Introduced `Hanami.root`. It returns the top level directory of the project.
|
||||
|
||||
### Fixed
|
||||
- [Ngọc Nguyễn] Model generator should use new RSpec syntax.
|
||||
|
@ -118,9 +118,9 @@ A complete web framework for Ruby
|
|||
|
||||
## v0.3.1 - 2015-05-15
|
||||
### Added
|
||||
- [Hiếu Nguyễn] Introduced application generator (eg. `bundle exec lotus generate app admin` creates `apps/admin`).
|
||||
- [Ngọc Nguyễn] Introduced model generator (eg. `bundle exec lotus generate model user` creates entity, repository and test files).
|
||||
- [Ngọc Nguyễn] Introduced `Lotus.env`, `Lotus.env?` for current environment introspection (eg. `Lotus.env?(:test)` or `Lotus.env?(:staging, :production)`)
|
||||
- [Hiếu Nguyễn] Introduced application generator (eg. `bundle exec hanami generate app admin` creates `apps/admin`).
|
||||
- [Ngọc Nguyễn] Introduced model generator (eg. `bundle exec hanami generate model user` creates entity, repository and test files).
|
||||
- [Ngọc Nguyễn] Introduced `Hanami.env`, `Hanami.env?` for current environment introspection (eg. `Hanami.env?(:test)` or `Hanami.env?(:staging, :production)`)
|
||||
- [Miguel Molina] Skip view creation when an action is generated via `--skip-view` CLI arg.
|
||||
|
||||
### Fixed
|
||||
|
@ -128,14 +128,14 @@ 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 project. Eg. `lotus new bookshelf --database=postgresql`
|
||||
- [Luca Guidi] Introduced action generator. Eg. `bundle exec hanami generate action web dashboard#index`
|
||||
- [Alfonso Uceda Pompa] Allow to specify default coookies options in application configuration. Eg. `cookies true, { domain: 'hanamirb.org' }`
|
||||
- [Tom Kadwill] Include `Hanami::Helpers` in views.
|
||||
- [Linus Pettersson] Allow to specify `--database` CLI option when generate a new project. Eg. `hanami new bookshelf --database=postgresql`
|
||||
- [Linus Pettersson] Initialize a Git repository when generating a new project
|
||||
- [Alfonso Uceda Pompa] Produce `.lotusrc` when generating a new project
|
||||
- [Alfonso Uceda Pompa] Produce `.hanamirc` when generating a new project
|
||||
- [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`
|
||||
- [Linus Pettersson] Database console. Run with `bundle exec hanami 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
|
||||
|
@ -145,35 +145,35 @@ A complete web framework for Ruby
|
|||
|
||||
## v0.2.1 - 2015-02-06
|
||||
### Added
|
||||
- [Huy Đỗ] Introduced `Lotus::Logger`
|
||||
- [Jimmy Zhang] `lotus new` accepts a `--path` argument
|
||||
- [Jimmy Zhang] Project generator for the current directory (`lotus new .`). This is useful to provide a web deliverable for existing Ruby gems.
|
||||
- [Huy Đỗ] Introduced `Hanami::Logger`
|
||||
- [Jimmy Zhang] `hanami new` accepts a `--path` argument
|
||||
- [Jimmy Zhang] Project generator for the current directory (`hanami new .`). This is useful to provide a web deliverable for existing Ruby gems.
|
||||
- [Trung Lê] Add example mapping file for project generator: `lib/config/mapping.rb`
|
||||
- [Hiếu Nguyễn] RSpec support for project generator: `--test=rspec` or `--test=minitest` (default)
|
||||
|
||||
### Fixed
|
||||
- [Luca Guidi] `lotus version` to previx `v` (eg `v0.2.1`)
|
||||
- [Luca Guidi] `hanami version` to previx `v` (eg `v0.2.1`)
|
||||
- [Rob Yurkowski] Ensure project name doesn't contain special or forbidden characters
|
||||
- [Luca Guidi] Ensure all the applications are loaded in console
|
||||
- [Trung Lê] Container architecture: preload only `lib/<projectname>/**/*.rb`
|
||||
- [Hiếu Nguyễn] Fixed `lotus new` to print usage when project name isn't provided
|
||||
- [Hiếu Nguyễn] Fixed `hanami new` to print usage when project name isn't provided
|
||||
|
||||
## v0.2.0 - 2014-06-23
|
||||
### Added
|
||||
- [Luca Guidi] Introduced `lotus new` as a command to generate projects. It supports "container" architecture for now.
|
||||
- [Luca Guidi] Show a welcome page when one mounted Lotus application doesn't have routes
|
||||
- [Luca Guidi] Introduced `Lotus::Application.preload!` to preload all the Lotus applications in a given Ruby process. (Bulk `Lotus::Application.load!`)
|
||||
- [Luca Guidi] Introduced `hanami new` as a command to generate projects. It supports "container" architecture for now.
|
||||
- [Luca Guidi] Show a welcome page when one mounted Hanami application doesn't have routes
|
||||
- [Luca Guidi] Introduced `Hanami::Application.preload!` to preload all the Hanami applications in a given Ruby process. (Bulk `Hanami::Application.load!`)
|
||||
- [Trung Lê] Allow browsers to fake non `GET`/`POST` requests via `Rack::MethodOverride`
|
||||
- [Josue Abreu] Allow to define body parses for non `GET` HTTP requests (`body_parsers` configuration)
|
||||
- [Alfonso Uceda Pompa] Allow to toggle static assets serving (`serve_assets` configuration)
|
||||
- [Alfonso Uceda Pompa] Allow to serve assets from multiple sources (`assets` configuration)
|
||||
- [Luca Guidi] Allow to configure `ENV` vars with per environment `.env` files
|
||||
- [Alfonso Uceda Pompa] Introduced `lotus routes` command
|
||||
- [Alfonso Uceda Pompa] Introduced `hanami routes` command
|
||||
- [Luca Guidi] Allow to configure low level settings for MVC frameworks (`model`, `view` and `controller` configuration)
|
||||
- [Luca Guidi] Introduced `Lotus::Container`
|
||||
- [Trung Lê] Include `Lotus::Presenter` as part of the duplicated modules
|
||||
- [Trung Lê] Include `Lotus::Entity` and `Lotus::Repository` as part of the duplicated modules
|
||||
- [Luca Guidi] Introduced code reloading for `lotus server`
|
||||
- [Luca Guidi] Introduced `Hanami::Container`
|
||||
- [Trung Lê] Include `Hanami::Presenter` as part of the duplicated modules
|
||||
- [Trung Lê] Include `Hanami::Entity` and `Hanami::Repository` as part of the duplicated modules
|
||||
- [Luca Guidi] Introduced code reloading for `hanami server`
|
||||
- [Trung Lê] Allow to configure database adapter (`adapter` configuration)
|
||||
- [Luca Guidi & Trung Lê] Allow to configure database mapping (`mapping` configuration)
|
||||
- [Piotr Kurek] Introduced custom templates for non successful responses
|
||||
|
@ -182,10 +182,10 @@ A complete web framework for Ruby
|
|||
- [Josue Abreu] Allow to configure cookies (`cookies` configuration)
|
||||
- [Piotr Kurek] Allow to yield multiple configurations per application, according to the current environment
|
||||
- [David Celis] Allow to configure Rack middleware stack (`middleware` configuration)
|
||||
- [David Celis] Introduced `lotus console` command. It runs the REPL configured in `Gemfile` (eg. pry or ripl). Defaults to IRb.
|
||||
- [Luca Guidi] Introduced `Lotus::Environment` which holds the informations about the current environment, and CLI arguments
|
||||
- [Luca Guidi] Introduced `Lotus::Application.load!` to load and configure an application without requiring user defined code (controllers, views, etc.)
|
||||
- [Leonard Garvey] Introduced `lotus server` command. It runs the application with the Rack server declared in `Gemfile` (eg. puma, thin, unicorn). It defaults to `WEBRick`.
|
||||
- [David Celis] Introduced `hanami console` command. It runs the REPL configured in `Gemfile` (eg. pry or ripl). Defaults to IRb.
|
||||
- [Luca Guidi] Introduced `Hanami::Environment` which holds the informations about the current environment, and CLI arguments
|
||||
- [Luca Guidi] Introduced `Hanami::Application.load!` to load and configure an application without requiring user defined code (controllers, views, etc.)
|
||||
- [Leonard Garvey] Introduced `hanami server` command. It runs the application with the Rack server declared in `Gemfile` (eg. puma, thin, unicorn). It defaults to `WEBRick`.
|
||||
- [Luca Guidi] Official support for MRI 2.1 and 2.2
|
||||
|
||||
### Changed
|
||||
|
@ -196,8 +196,8 @@ A complete web framework for Ruby
|
|||
|
||||
## v0.1.0 - 2014-06-23
|
||||
### Added
|
||||
- [Luca Guidi] Allow to run multiple Lotus applications in the same Ruby process (framework duplication)
|
||||
- [Luca Guidi] Introduced `Lotus::Routes` as factory to generate application URLs
|
||||
- [Luca Guidi] Allow to run multiple Hanami applications in the same Ruby process (framework duplication)
|
||||
- [Luca Guidi] Introduced `Hanami::Routes` as factory to generate application URLs
|
||||
- [Luca Guidi] Allow to configure scheme, host and port (`scheme`, `host` and `port` configuration)
|
||||
- [Luca Guidi] Allow to configure a layout to use for all the views of an application (`layout` configuration)
|
||||
- [Luca Guidi] Allow to configure routes (`routes` configuration)
|
||||
|
@ -205,6 +205,6 @@ A complete web framework for Ruby
|
|||
- [Luca Guidi] Allow to serve static files (`assets` configuration)
|
||||
- [Luca Guidi] Render default pages for non successful responses (eg `404` or `500`)
|
||||
- [Luca Guidi] Allow to configure the root of an application (`root` configuration)
|
||||
- [Luca Guidi] Introduced `Lotus::Configuration`
|
||||
- [Luca Guidi] Introduced `Lotus::Application`
|
||||
- [Luca Guidi] Introduced `Hanami::Configuration`
|
||||
- [Luca Guidi] Introduced `Hanami::Application`
|
||||
- [Luca Guidi] Official support for MRI 2.0
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
Lotus is an open source project and we would love you to help us make it better.
|
||||
Hanami is an open source project and we would love you to help us make it better.
|
||||
|
||||
## Reporting Issues
|
||||
|
||||
|
@ -21,7 +21,7 @@ but we just don't know.
|
|||
|
||||
## Pull requests
|
||||
|
||||
We accept pull requests to Lotus for:
|
||||
We accept pull requests to Hanami for:
|
||||
|
||||
* Adding documentation
|
||||
* Fixing bugs
|
||||
|
@ -47,6 +47,6 @@ request; Questions, clarifications, and so on.
|
|||
|
||||
Some things that will increase the chance that your pull request is accepted:
|
||||
|
||||
* Use Lotus idioms
|
||||
* Use Hanami idioms
|
||||
* Include tests that fail without your code, and pass with it
|
||||
* Update the documentation, guides, etc.
|
||||
|
|
52
FEATURES.md
52
FEATURES.md
|
@ -1,4 +1,4 @@
|
|||
# Lotus
|
||||
# Hanami
|
||||
### A complete web framework for Ruby
|
||||
|
||||
## Features
|
||||
|
@ -20,16 +20,16 @@
|
|||
* `asset_url`
|
||||
- Content Delivery Network (CDN) support for static assets (CDN mode)
|
||||
- Checksum suffix for static assets in production mode (Digest mode)
|
||||
- Support for third party gems as assets distribution channel (eg. `lotus-jquery`)
|
||||
- CLI: `lotus assets` command `precompile`: preprocess, minify and append checksum suffix
|
||||
- CLI: `lotus destroy` destroy apps, models, actions, migrations and mailers
|
||||
- Support for third party gems as assets distribution channel (eg. `hanami-jquery`)
|
||||
- CLI: `hanami assets` command `precompile`: preprocess, minify and append checksum suffix
|
||||
- CLI: `hanami destroy` destroy apps, models, actions, migrations and mailers
|
||||
- Custom initializers (`apps/web/config/initializers`)
|
||||
- Rake tasks `:preload` and `:environment`
|
||||
|
||||
## v0.5.0 - 2015-09-30
|
||||
|
||||
- Mailers
|
||||
- CLI: `lotus generate mailer`
|
||||
- CLI: `hanami generate mailer`
|
||||
- SQL joins
|
||||
- Custom coercers for data mapper
|
||||
|
||||
|
@ -39,7 +39,7 @@
|
|||
|
||||
- Application architecture
|
||||
- Database migrations
|
||||
- CLI: `lotus db` commands: `create`, `drop`, `prepare`, `migrate`, `version`, `apply`.
|
||||
- CLI: `hanami db` commands: `create`, `drop`, `prepare`, `migrate`, `version`, `apply`.
|
||||
- HTML5 Form helpers
|
||||
- Cross Site Request Forgery (CSRF) protection
|
||||
- Force SSL
|
||||
|
@ -50,26 +50,26 @@
|
|||
- Automatic secure cookies
|
||||
- Routing helpers for actions
|
||||
- Send files from actions
|
||||
- `Lotus.root` returns top level directory of the project.
|
||||
- `Hanami.root` returns top level directory of the project.
|
||||
|
||||
## v0.3.1 - 2015-05-15
|
||||
|
||||
- CLI: `lotus generate app admin` creates a new application (`apps/admin`).
|
||||
- CLI: `lotus generate model user`. It generates entity, repository and related unit test files.
|
||||
- `Lotus.env` and `Lotus.env?` for current environment introspection (eg. `Lotus.env?(:test)` or `Lotus.env?(:staging, :production)`)
|
||||
- CLI: `hanami generate app admin` creates a new application (`apps/admin`).
|
||||
- CLI: `hanami generate model user`. It generates entity, repository and related unit test files.
|
||||
- `Hanami.env` and `Hanami.env?` for current environment introspection (eg. `Hanami.env?(:test)` or `Hanami.env?(:staging, :production)`)
|
||||
- Allow repositories to execute raw query/commands against database
|
||||
- Automatic timestamps update for entities
|
||||
– Dirty Tracking for entities (via `Lotus::Entity::DirtyTracking`)
|
||||
– Dirty Tracking for entities (via `Hanami::Entity::DirtyTracking`)
|
||||
- Nested RESTful resource(s)
|
||||
- String pluralization and singularization
|
||||
|
||||
## v0.3.0 - 2015-03-23
|
||||
|
||||
- CLI: `lotus generate action web dashboard#index`. It generates an action, a view, a template, a route and related unit test files.
|
||||
- CLI: `lotus db console`. It starts a database REPL.
|
||||
- CLI: `hanami generate action web dashboard#index`. It generates an action, a view, a template, a route and related unit test files.
|
||||
- CLI: `hanami db console`. It starts a database REPL.
|
||||
- Full featured HTML5 markup generator for views (Eg. `html.div { p "Hello World" }`)
|
||||
- Routing helpers in views and templates (Eg. `routes.home_path`).
|
||||
- `lotus new` supports `--database` (Eg. `lotus new bookshelf --database=postgresql`).
|
||||
- `hanami new` supports `--database` (Eg. `hanami new bookshelf --database=postgresql`).
|
||||
- Initialize a Git repository when generate a new application
|
||||
- Security: XSS (Cross Site Scripting) protections
|
||||
- Security: Clickhijacking protection
|
||||
|
@ -85,23 +85,23 @@
|
|||
## v0.2.1 - 2015-02-06
|
||||
|
||||
- Allow entities to include validations.
|
||||
- `lotus new .` to generate a Lotus application for an existing code base (Eg. a gem that needs a web UI).
|
||||
- `lotus new` supports `--path` (for destination directory), `--test` (to generate Minitest or RSpec boilerplate).
|
||||
- Lotus logger
|
||||
- `hanami new .` to generate a Hanami application for an existing code base (Eg. a gem that needs a web UI).
|
||||
- `hanami new` supports `--path` (for destination directory), `--test` (to generate Minitest or RSpec boilerplate).
|
||||
- Hanami logger
|
||||
|
||||
## v0.2.0 - 2014-12-23
|
||||
|
||||
- Support Minitest as default testing framework (`bundle exec rake` runs the entire test suite of an application).
|
||||
- Support for _Method Override_ technique.
|
||||
- Custom templates for non successful responses (Eg. `404.html.erb`).
|
||||
- Support distinct `.env` files for each Lotus environment.
|
||||
- Allow to configure multiple applications and handle Lotus environments accordingly.
|
||||
- Support distinct `.env` files for each Hanami environment.
|
||||
- Allow to configure multiple applications and handle Hanami environments accordingly.
|
||||
- Allow to configure middleware stack, routes, database mapping and adapter for each application.
|
||||
- Show a welcome page with instructions for new generated apps.
|
||||
- CLI: `lotus routes`. It prints all the routes available for all the applications.
|
||||
- CLI: `lotus new`. It generates a new application which can run multiple Lotus applications (_Container_ architecture).
|
||||
- CLI: `lotus console`. It starts a Ruby REPL. It supports IRB (default), Pry and Ripl.
|
||||
- CLI: `lotus server`. It starts a web server that supports code reloading. It supports all the Rack web servers (default: WEBRick).
|
||||
- CLI: `hanami routes`. It prints all the routes available for all the applications.
|
||||
- CLI: `hanami new`. It generates a new application which can run multiple Hanami applications (_Container_ architecture).
|
||||
- CLI: `hanami console`. It starts a Ruby REPL. It supports IRB (default), Pry and Ripl.
|
||||
- CLI: `hanami server`. It starts a web server that supports code reloading. It supports all the Rack web servers (default: WEBRick).
|
||||
- Database adapters: File system (default for new apps)
|
||||
- Allow to share code for all the views and actions of an application
|
||||
- Reusable validations framework (mixin). It supports: coercions and presence, format, acceptance, size, inclusion, exclusion, confirmation validations.
|
||||
|
@ -117,10 +117,10 @@
|
|||
|
||||
## v0.1.0 - 2014-06-23
|
||||
|
||||
- Run multiple Lotus applications in the same Ruby process
|
||||
- Run multiple Hanami applications in the same Ruby process
|
||||
- Serve static files
|
||||
- Render default pages for non successful responses (404, 500, etc.)
|
||||
- Support multiple Lotus environments (development, test and production)
|
||||
- Support multiple Hanami environments (development, test and production)
|
||||
- Full stack applications
|
||||
- Data mapper
|
||||
- Database adapters: Memory and SQL
|
||||
|
@ -148,7 +148,7 @@
|
|||
- Nested route namespaces
|
||||
- RESTful resource(s), including collection and member actions
|
||||
- Named routes, routes constraints, variables, catch-all
|
||||
- Compatibility with Lotus::Controller
|
||||
- Compatibility with Hanami::Controller
|
||||
- HTTP redirect from the router
|
||||
- HTTP routing compatible with Rack
|
||||
- Thread safety
|
||||
|
|
18
Gemfile
18
Gemfile
|
@ -8,15 +8,15 @@ if !ENV['TRAVIS']
|
|||
end
|
||||
|
||||
gem 'sass'
|
||||
gem 'lotus-utils', '~> 0.6', require: false, github: 'lotus/utils', branch: '0.6.x'
|
||||
gem 'lotus-validations', '~> 0.4', require: false, github: 'lotus/validations', branch: '0.4.x'
|
||||
gem 'lotus-router', '~> 0.5', require: false, github: 'lotus/router', branch: '0.5.x'
|
||||
gem 'lotus-controller', '~> 0.5', require: false, github: 'lotus/controller', branch: '0.5.x'
|
||||
gem 'lotus-view', '~> 0.5', require: false, github: 'lotus/view', branch: '0.5.x'
|
||||
gem 'lotus-model', '~> 0.5', require: false, github: 'lotus/model', branch: '0.5.x'
|
||||
gem 'lotus-helpers', '~> 0.2', require: false, github: 'lotus/helpers', branch: '0.2.x'
|
||||
gem 'lotus-mailer', '~> 0.1', require: false, github: 'lotus/mailer', branch: '0.1.x'
|
||||
gem 'lotus-assets', '~> 0.1', require: false, github: 'lotus/assets', branch: '0.1.x'
|
||||
gem 'hanami-utils', '~> 0.7', require: false, github: 'hanami/utils', branch: '0.7.x'
|
||||
gem 'hanami-validations', '~> 0.5', require: false, github: 'hanami/validations', branch: '0.5.x'
|
||||
gem 'hanami-router', '~> 0.6', require: false, github: 'hanami/router', branch: '0.6.x'
|
||||
gem 'hanami-controller', '~> 0.6', require: false, github: 'hanami/controller', branch: '0.6.x'
|
||||
gem 'hanami-view', '~> 0.6', require: false, github: 'hanami/view', branch: '0.6.x'
|
||||
gem 'hanami-model', '~> 0.6', require: false, github: 'hanami/model', branch: '0.6.x'
|
||||
gem 'hanami-helpers', '~> 0.3', require: false, github: 'hanami/helpers', branch: '0.3.x'
|
||||
gem 'hanami-mailer', '~> 0.2', require: false, github: 'hanami/mailer', branch: '0.2.x'
|
||||
gem 'hanami-assets', '~> 0.2', require: false, github: 'hanami/assets', branch: '0.2.x'
|
||||
|
||||
platforms :ruby do
|
||||
gem 'sqlite3'
|
||||
|
|
73
README.md
73
README.md
|
@ -1,69 +1,69 @@
|
|||
# Lotus
|
||||
# Hanami
|
||||
|
||||
A complete web framework for Ruby
|
||||
The web, with simplicity.
|
||||
|
||||
## Frameworks
|
||||
|
||||
Lotus combines small yet powerful frameworks:
|
||||
Hanami combines small yet powerful frameworks:
|
||||
|
||||
* [**Lotus::Utils**](https://github.com/lotus/utils) - Ruby core extensions and class utilities
|
||||
* [**Lotus::Router**](https://github.com/lotus/router) - Rack compatible HTTP router for Ruby
|
||||
* [**Lotus::Validations**](https://github.com/lotus/validations) - Validations mixin for Ruby objects
|
||||
* [**Lotus::Helpers**](https://github.com/lotus/helpers) - View helpers for Ruby applications
|
||||
* [**Lotus::Mailer**](https://github.com/lotus/mailer) - Mail for Ruby applications
|
||||
* [**Lotus::Model**](https://github.com/lotus/model) - Persistence with entities, repositories and data mapper
|
||||
* [**Lotus::Assets**](https://github.com/lotus/assets) - Assets management for Ruby
|
||||
* [**Lotus::View**](https://github.com/lotus/view) - Presentation with a separation between views and templates
|
||||
* [**Lotus::Controller**](https://github.com/lotus/controller) - Full featured, fast and testable actions for Rack
|
||||
* [**Hanami::Utils**](https://github.com/hanami/utils) - Ruby core extensions and class utilities
|
||||
* [**Hanami::Router**](https://github.com/hanami/router) - Rack compatible HTTP router for Ruby
|
||||
* [**Hanami::Validations**](https://github.com/hanami/validations) - Validations mixin for Ruby objects
|
||||
* [**Hanami::Helpers**](https://github.com/hanami/helpers) - View helpers for Ruby applications
|
||||
* [**Hanami::Mailer**](https://github.com/hanami/mailer) - Mail for Ruby applications
|
||||
* [**Hanami::Model**](https://github.com/hanami/model) - Persistence with entities, repositories and data mapper
|
||||
* [**Hanami::Assets**](https://github.com/hanami/assets) - Assets management for Ruby
|
||||
* [**Hanami::View**](https://github.com/hanami/view) - Presentation with a separation between views and templates
|
||||
* [**Hanami::Controller**](https://github.com/hanami/controller) - Full featured, fast and testable actions for Rack
|
||||
|
||||
These components are designed to be used independently or together in a Lotus application.
|
||||
These components are designed to be used independently or together in a Hanami 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.svg)](http://badge.fury.io/rb/lotusrb)
|
||||
[![Build Status](https://secure.travis-ci.org/lotus/lotus.svg?branch=master)](http://travis-ci.org/lotus/lotus?branch=master)
|
||||
[![Coverage](https://coveralls.io/repos/lotus/lotus/badge.svg?branch=master)](https://coveralls.io/r/lotus/lotus)
|
||||
[![Code Climate](https://codeclimate.com/github/lotus/lotus.svg)](https://codeclimate.com/github/lotus/lotus)
|
||||
[![Dependencies](https://gemnasium.com/lotus/lotus.svg)](https://gemnasium.com/lotus/lotus)
|
||||
[![Inline docs](http://inch-ci.org/github/lotus/lotus.svg)](http://inch-ci.org/github/lotus/lotus)
|
||||
[![Gem Version](https://badge.fury.io/rb/hanami.svg)](http://badge.fury.io/rb/hanami)
|
||||
[![Build Status](https://secure.travis-ci.org/hanami/hanami.svg?branch=master)](http://travis-ci.org/hanami/hanami?branch=master)
|
||||
[![Coverage](https://coveralls.io/repos/hanami/hanami/badge.svg?branch=master)](https://coveralls.io/r/hanami/hanami)
|
||||
[![Code Climate](https://codeclimate.com/github/hanami/hanami.svg)](https://codeclimate.com/github/hanami/hanami)
|
||||
[![Dependencies](https://gemnasium.com/hanami/hanami.svg)](https://gemnasium.com/hanami/hanami)
|
||||
[![Inline docs](http://inch-ci.org/github/hanami/hanami.svg)](http://inch-ci.org/github/hanami/hanami)
|
||||
|
||||
## Contact
|
||||
|
||||
* Home page: http://lotusrb.org
|
||||
* Community: http://lotusrb.org/community
|
||||
* Guides: http://lotusrb.org/guides
|
||||
* 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
|
||||
* Forum: https://discuss.lotusrb.org
|
||||
* Chat: http://chat.lotusrb.org
|
||||
* Home page: http://hanamirb.org
|
||||
* Community: http://hanamirb.org/community
|
||||
* Guides: http://hanamirb.org/guides
|
||||
* Mailing List: http://hanamirb.org/mailing-list
|
||||
* API Doc: http://rdoc.info/gems/hanami
|
||||
* Bugs/Issues: https://github.com/hanami/hanami/issues
|
||||
* Support: http://stackoverflow.com/questions/tagged/hanami
|
||||
* Forum: https://discuss.hanamirb.org
|
||||
* Chat: http://chat.hanamirb.org
|
||||
|
||||
## Rubies
|
||||
|
||||
__Lotus__ supports Ruby (MRI) 2+
|
||||
__Hanami__ supports Ruby (MRI) 2+
|
||||
|
||||
## Installation
|
||||
|
||||
```shell
|
||||
% gem install lotusrb
|
||||
% gem install hanami
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```shell
|
||||
% lotus new bookshelf
|
||||
% hanami new bookshelf
|
||||
% cd bookshelf && bundle
|
||||
% bundle exec lotus server # visit http://localhost:2300
|
||||
% bundle exec hanami server # visit http://localhost:2300
|
||||
```
|
||||
|
||||
Please follow along with the [Getting Started guide](http://lotusrb.org/guides/getting-started).
|
||||
Please follow along with the [Getting Started guide](http://hanamirb.org/guides/getting-started).
|
||||
|
||||
## Community
|
||||
|
||||
We strive for a Community made of **inclusive, helpful and smart people**.
|
||||
We have a [Code of Conduct](http://lotusrb.org/community/#code-of-conduct) to handle controversial cases.
|
||||
We have a [Code of Conduct](http://hanamirb.org/community/#code-of-conduct) to handle controversial cases.
|
||||
In general, we expect **you** to be **nice** with other people.
|
||||
Our hope is for a great software and a great Community.
|
||||
|
||||
|
@ -85,7 +85,7 @@ This Code of Conduct is adapted from the Contributor Covenant, version 1.1.0, av
|
|||
|
||||
## Contributing
|
||||
|
||||
1. Fork it ( https://github.com/lotus/lotus/fork )
|
||||
1. Fork it ( https://github.com/hanami/hanami/fork )
|
||||
2. Create your feature branch (`git checkout -b my-new-feature`)
|
||||
3. Commit your changes (`git commit -am 'Add some feature'`)
|
||||
4. Push to the branch (`git push origin my-new-feature`)
|
||||
|
@ -93,8 +93,9 @@ This Code of Conduct is adapted from the Contributor Covenant, version 1.1.0, av
|
|||
|
||||
## Versioning
|
||||
|
||||
__Lotus__ uses [Semantic Versioning 2.0.0](http://semver.org)
|
||||
__Hanami__ uses [Semantic Versioning 2.0.0](http://semver.org)
|
||||
|
||||
## Copyright
|
||||
|
||||
Copyright © 2014-2016 Luca Guidi – Released under MIT License
|
||||
This project was formerly known as Lotus (`lotusrb`).
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#!/usr/bin/env ruby
|
||||
|
||||
require 'bundler'
|
||||
require 'lotus/cli'
|
||||
Lotus::Cli.start
|
||||
require 'hanami/cli'
|
||||
Hanami::Cli.start
|
|
@ -1,31 +1,31 @@
|
|||
# coding: utf-8
|
||||
lib = File.expand_path('../lib', __FILE__)
|
||||
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
||||
require 'lotus/version'
|
||||
require 'hanami/version'
|
||||
|
||||
Gem::Specification.new do |spec|
|
||||
spec.name = 'lotusrb'
|
||||
spec.version = Lotus::VERSION
|
||||
spec.name = 'hanami'
|
||||
spec.version = Hanami::VERSION
|
||||
spec.authors = ['Luca Guidi', 'Trung Lê', 'Alfonso Uceda Pompa']
|
||||
spec.email = ['me@lucaguidi.com', 'trung.le@ruby-journal.com', 'uceda73@gmail.com']
|
||||
spec.summary = %q{A complete web framework for Ruby}
|
||||
spec.description = %q{A complete web framework for Ruby}
|
||||
spec.homepage = 'http://lotusrb.org'
|
||||
spec.summary = %q{The web, with simplicity.}
|
||||
spec.description = %q{Hanami is a simple and complete web framework for Ruby}
|
||||
spec.homepage = 'http://hanamirb.org'
|
||||
spec.license = 'MIT'
|
||||
|
||||
spec.files = `git ls-files -z -- lib/* bin/* LICENSE.md README.md CHANGELOG.md FEATURES.md lotusrb.gemspec`.split("\x0")
|
||||
spec.files = `git ls-files -z -- lib/* bin/* LICENSE.md README.md CHANGELOG.md FEATURES.md hanami.gemspec`.split("\x0")
|
||||
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
||||
spec.test_files = spec.files.grep(%r{^(test)/})
|
||||
spec.require_paths = ['lib']
|
||||
spec.required_ruby_version = '>= 2.0.0'
|
||||
|
||||
spec.add_dependency 'lotus-utils', '~> 0.6'
|
||||
spec.add_dependency 'lotus-router', '~> 0.5'
|
||||
spec.add_dependency 'lotus-controller', '~> 0.5'
|
||||
spec.add_dependency 'lotus-view', '~> 0.5'
|
||||
spec.add_dependency 'lotus-helpers', '~> 0.2', '>= 0.2.6'
|
||||
spec.add_dependency 'lotus-mailer', '~> 0.1'
|
||||
spec.add_dependency 'lotus-assets', '~> 0.1'
|
||||
spec.add_dependency 'hanami-utils', '~> 0.7'
|
||||
spec.add_dependency 'hanami-router', '~> 0.6'
|
||||
spec.add_dependency 'hanami-controller', '~> 0.6'
|
||||
spec.add_dependency 'hanami-view', '~> 0.6'
|
||||
spec.add_dependency 'hanami-helpers', '~> 0.3'
|
||||
spec.add_dependency 'hanami-mailer', '~> 0.2'
|
||||
spec.add_dependency 'hanami-assets', '~> 0.2'
|
||||
spec.add_dependency 'shotgun', '~> 0.9'
|
||||
spec.add_dependency 'dotenv', '~> 2.0'
|
||||
spec.add_dependency 'thor', '~> 0.19'
|
|
@ -1,14 +1,14 @@
|
|||
require 'lotus/version'
|
||||
require 'lotus/application'
|
||||
require 'lotus/container'
|
||||
require 'lotus/environment'
|
||||
require 'hanami/version'
|
||||
require 'hanami/application'
|
||||
require 'hanami/container'
|
||||
require 'hanami/environment'
|
||||
|
||||
# A complete web framework for Ruby
|
||||
#
|
||||
# @since 0.1.0
|
||||
#
|
||||
# @see http://lotusrb.org
|
||||
module Lotus
|
||||
# @see http://hanamirb.org
|
||||
module Hanami
|
||||
DEFAULT_PUBLIC_DIRECTORY = 'public'.freeze
|
||||
|
||||
# Return root of the project (top level directory).
|
||||
|
@ -18,7 +18,7 @@ module Lotus
|
|||
# @since 0.3.2
|
||||
#
|
||||
# @example
|
||||
# Lotus.root # => #<Pathname:/Users/luca/Code/bookshelf>
|
||||
# Hanami.root # => #<Pathname:/Users/luca/Code/bookshelf>
|
||||
def self.root
|
||||
environment.root
|
||||
end
|
||||
|
@ -33,10 +33,10 @@ module Lotus
|
|||
#
|
||||
# @since 0.3.1
|
||||
#
|
||||
# @see Lotus::Environment#environment
|
||||
# @see Hanami::Environment#environment
|
||||
#
|
||||
# @example
|
||||
# Lotus.env => "development"
|
||||
# Hanami.env => "development"
|
||||
def self.env
|
||||
environment.environment
|
||||
end
|
||||
|
@ -50,28 +50,28 @@ module Lotus
|
|||
#
|
||||
# @since 0.3.1
|
||||
#
|
||||
# @see Lotus.env
|
||||
# @see Hanami.env
|
||||
#
|
||||
# @example Single name
|
||||
# puts ENV['LOTUS_ENV'] # => "development"
|
||||
# puts ENV['HANAMI_ENV'] # => "development"
|
||||
#
|
||||
# Lotus.env?(:development) # => true
|
||||
# Lotus.env?('development') # => true
|
||||
# Hanami.env?(:development) # => true
|
||||
# Hanami.env?('development') # => true
|
||||
#
|
||||
# Lotus.env?(:production) # => false
|
||||
# Hanami.env?(:production) # => false
|
||||
#
|
||||
# @example Multiple names
|
||||
# puts ENV['LOTUS_ENV'] # => "development"
|
||||
# puts ENV['HANAMI_ENV'] # => "development"
|
||||
#
|
||||
# Lotus.env?(:development, :test) # => true
|
||||
# Lotus.env?(:production, :staging) # => false
|
||||
# Hanami.env?(:development, :test) # => true
|
||||
# Hanami.env?(:production, :staging) # => false
|
||||
def self.env?(*names)
|
||||
environment.environment?(*names)
|
||||
end
|
||||
|
||||
# Return environment
|
||||
#
|
||||
# @return [Lotus::Environment] environment
|
||||
# @return [Hanami::Environment] environment
|
||||
#
|
||||
# @api private
|
||||
# @since 0.3.2
|
|
@ -1,6 +1,6 @@
|
|||
require 'securerandom'
|
||||
|
||||
module Lotus
|
||||
module Hanami
|
||||
module Action
|
||||
# Invalid CSRF Token
|
||||
#
|
||||
|
@ -18,7 +18,7 @@ module Lotus
|
|||
#
|
||||
# If the param matches with the challenge token, the flow can continue.
|
||||
# Otherwise the application detects an attack attempt, it reset the session
|
||||
# and <tt>Lotus::Action::InvalidCSRFTokenError</tt> is raised.
|
||||
# and <tt>Hanami::Action::InvalidCSRFTokenError</tt> is raised.
|
||||
#
|
||||
# We can specify a custom handling strategy, by overriding <tt>#handle_invalid_csrf_token</tt>.
|
||||
#
|
||||
|
@ -70,7 +70,7 @@ module Lotus
|
|||
module CSRFProtection
|
||||
# Session and params key for CSRF token.
|
||||
#
|
||||
# This key is shared with <tt>lotus-controller</tt> and <tt>lotus-helpers</tt>
|
||||
# This key is shared with <tt>hanami-controller</tt> and <tt>hanami-helpers</tt>
|
||||
#
|
||||
# @since 0.4.0
|
||||
# @api private
|
||||
|
@ -95,7 +95,7 @@ module Lotus
|
|||
def self.included(action)
|
||||
action.class_eval do
|
||||
before :set_csrf_token, :verify_csrf_token
|
||||
end unless Lotus.env?(:test)
|
||||
end unless Hanami.env?(:test)
|
||||
end
|
||||
|
||||
private
|
||||
|
@ -155,7 +155,7 @@ module Lotus
|
|||
#
|
||||
# Override this method, for custom handling.
|
||||
#
|
||||
# @raise [Lotus::Action::InvalidCSRFTokenError]
|
||||
# @raise [Hanami::Action::InvalidCSRFTokenError]
|
||||
#
|
||||
# @since 0.4.0
|
||||
def handle_invalid_csrf_token
|
|
@ -1,18 +1,18 @@
|
|||
require 'lotus/utils/string'
|
||||
require 'hanami/utils/string'
|
||||
|
||||
module Lotus
|
||||
module Hanami
|
||||
module Action
|
||||
# Routing helper for full stack Lotus web applications.
|
||||
# Routing helper for full stack Hanami web applications.
|
||||
#
|
||||
# For a given application called <tt>Web::Application</tt>, at runtime
|
||||
# Lotus creates a routes factory called <tt>Web::Routes</tt>.
|
||||
# Hanami creates a routes factory called <tt>Web::Routes</tt>.
|
||||
#
|
||||
# Included by default in every controller.
|
||||
#
|
||||
# @since 0.3.2
|
||||
#
|
||||
# @example Usage in controller
|
||||
# require 'lotus'
|
||||
# require 'hanami'
|
||||
#
|
||||
# module Web::Controllers::Protected
|
||||
# class Index
|
|
@ -1,21 +1,21 @@
|
|||
require 'lotus/utils/class_attribute'
|
||||
require 'lotus/frameworks'
|
||||
require 'lotus/configuration'
|
||||
require 'lotus/loader'
|
||||
require 'lotus/logger'
|
||||
require 'lotus/rendering_policy'
|
||||
require 'lotus/middleware'
|
||||
require 'hanami/utils/class_attribute'
|
||||
require 'hanami/frameworks'
|
||||
require 'hanami/configuration'
|
||||
require 'hanami/loader'
|
||||
require 'hanami/logger'
|
||||
require 'hanami/rendering_policy'
|
||||
require 'hanami/middleware'
|
||||
|
||||
module Lotus
|
||||
# A full stack Lotus application
|
||||
module Hanami
|
||||
# A full stack Hanami application
|
||||
#
|
||||
# @since 0.1.0
|
||||
#
|
||||
# @example
|
||||
# require 'lotus'
|
||||
# require 'hanami'
|
||||
#
|
||||
# module Bookshelf
|
||||
# class Application < Lotus::Application
|
||||
# class Application < Hanami::Application
|
||||
# end
|
||||
# end
|
||||
class Application
|
||||
|
@ -29,7 +29,7 @@ module Lotus
|
|||
super
|
||||
|
||||
base.class_eval do
|
||||
include Lotus::Utils::ClassAttribute
|
||||
include Hanami::Utils::ClassAttribute
|
||||
|
||||
class_attribute :configuration
|
||||
self.configuration = Configuration.new
|
||||
|
@ -40,7 +40,7 @@ module Lotus
|
|||
end
|
||||
end
|
||||
|
||||
# Registry of Lotus applications in the current Ruby process
|
||||
# Registry of Hanami applications in the current Ruby process
|
||||
#
|
||||
# @return [Set] a set of all the registered applications
|
||||
#
|
||||
|
@ -60,13 +60,13 @@ module Lotus
|
|||
#
|
||||
# @since 0.1.0
|
||||
#
|
||||
# @see Lotus::Configuration
|
||||
# @see Hanami::Configuration
|
||||
#
|
||||
# @example
|
||||
# require 'lotus'
|
||||
# require 'hanami'
|
||||
#
|
||||
# module Bookshelf
|
||||
# Application < Lotus::Application
|
||||
# Application < Hanami::Application
|
||||
# configure do
|
||||
# # ...
|
||||
# end
|
||||
|
@ -78,16 +78,16 @@ module Lotus
|
|||
|
||||
# Return the routes for this application
|
||||
#
|
||||
# @return [Lotus::Router] a route set
|
||||
# @return [Hanami::Router] a route set
|
||||
#
|
||||
# @since 0.1.0
|
||||
#
|
||||
# @see Lotus::Configuration#routes
|
||||
# @see Hanami::Configuration#routes
|
||||
attr_reader :routes
|
||||
|
||||
# Set the routes for this application
|
||||
#
|
||||
# @param [Lotus::Router]
|
||||
# @param [Hanami::Router]
|
||||
#
|
||||
# @since 0.1.0
|
||||
# @api private
|
||||
|
@ -95,7 +95,7 @@ module Lotus
|
|||
|
||||
# Rendering policy
|
||||
#
|
||||
# @param [Lotus::RenderingPolicy]
|
||||
# @param [Hanami::RenderingPolicy]
|
||||
#
|
||||
# @since 0.2.0
|
||||
# @api private
|
||||
|
@ -103,7 +103,7 @@ module Lotus
|
|||
|
||||
# Initialize and load a new instance of the application
|
||||
#
|
||||
# @return [Lotus::Application] a new instance of the application
|
||||
# @return [Hanami::Application] a new instance of the application
|
||||
#
|
||||
# @since 0.1.0
|
||||
def initialize(options = {})
|
||||
|
@ -114,16 +114,16 @@ module Lotus
|
|||
# Eager load the application configuration, by activating the framework
|
||||
# duplication mechanisms.
|
||||
#
|
||||
# @param application [Lotus::Application, Class<Lotus::Application>]
|
||||
# @param application [Hanami::Application, Class<Hanami::Application>]
|
||||
# @return void
|
||||
#
|
||||
# @since 0.1.1
|
||||
#
|
||||
# @example
|
||||
# require 'lotus'
|
||||
# require 'hanami'
|
||||
#
|
||||
# module OneFile
|
||||
# class Application < Lotus::Application
|
||||
# class Application < Hanami::Application
|
||||
# configure do
|
||||
# routes do
|
||||
# get '/', to: 'dashboard#index'
|
||||
|
@ -144,13 +144,13 @@ module Lotus
|
|||
# end
|
||||
# end
|
||||
def self.load!(application = self)
|
||||
Lotus::Loader.new(application).load!
|
||||
Hanami::Loader.new(application).load!
|
||||
end
|
||||
|
||||
# Preload all the registered applications, by yielding their configurations
|
||||
# and preparing the frameworks.
|
||||
#
|
||||
# This is useful for testing suites, where we want to make Lotus frameworks
|
||||
# This is useful for testing suites, where we want to make Hanami frameworks
|
||||
# ready, but not preload applications code.
|
||||
#
|
||||
# This allows to test components such as views or actions in isolation and
|
||||
|
@ -188,7 +188,7 @@ module Lotus
|
|||
# @since 0.1.0
|
||||
# @api private
|
||||
#
|
||||
# @see Lotus::Application.configuration
|
||||
# @see Hanami::Application.configuration
|
||||
def configuration
|
||||
self.class.configuration
|
||||
end
|
||||
|
@ -202,7 +202,7 @@ module Lotus
|
|||
end
|
||||
|
||||
# Process a request.
|
||||
# This method makes Lotus applications compatible with the Rack protocol.
|
||||
# This method makes Hanami applications compatible with the Rack protocol.
|
||||
#
|
||||
# @param env [Hash] a Rack env
|
||||
#
|
||||
|
@ -211,20 +211,20 @@ module Lotus
|
|||
# @since 0.1.0
|
||||
#
|
||||
# @see http://rack.github.io
|
||||
# @see Lotus::RenderingPolicy#render
|
||||
# @see Lotus::Application#middleware
|
||||
# @see Hanami::RenderingPolicy#render
|
||||
# @see Hanami::Application#middleware
|
||||
def call(env)
|
||||
renderer.render(env, middleware.call(env))
|
||||
end
|
||||
|
||||
# Rack middleware stack
|
||||
#
|
||||
# @return [Lotus::Middleware] the middleware stack
|
||||
# @return [Hanami::Middleware] the middleware stack
|
||||
#
|
||||
# @since 0.1.0
|
||||
# @api private
|
||||
#
|
||||
# @see Lotus::Middleware
|
||||
# @see Hanami::Middleware
|
||||
def middleware
|
||||
@middleware ||= configuration.middleware
|
||||
end
|
|
@ -1,4 +1,4 @@
|
|||
module Lotus
|
||||
module Hanami
|
||||
# An application name.
|
||||
#
|
||||
# @since 0.2.1
|
||||
|
@ -7,7 +7,7 @@ module Lotus
|
|||
# A list of words that are prohibited from forming the application name
|
||||
#
|
||||
# @since 0.2.1
|
||||
RESERVED_WORDS = %w(lotus).freeze
|
||||
RESERVED_WORDS = %w(hanami).freeze
|
||||
|
||||
# Initialize and check against reserved words
|
||||
#
|
||||
|
@ -24,7 +24,7 @@ module Lotus
|
|||
# which is the default output. It must also be transformable into an
|
||||
# environment variable.
|
||||
#
|
||||
# @return [Lotus::ApplicationName] a new instance of the application name
|
||||
# @return [Hanami::ApplicationName] a new instance of the application name
|
||||
#
|
||||
# @since 0.2.1
|
||||
def initialize(name)
|
||||
|
@ -64,7 +64,7 @@ module Lotus
|
|||
# @return [TrueClass, FalseClass] the result of the check
|
||||
#
|
||||
# @example
|
||||
# Lotus::ApplicationName.invalid?("lotus") # => true
|
||||
# Hanami::ApplicationName.invalid?("hanami") # => true
|
||||
#
|
||||
# @since 0.2.1
|
||||
def self.invalid?(name)
|
|
@ -0,0 +1,119 @@
|
|||
require 'thor'
|
||||
require 'hanami/commands/console'
|
||||
require 'hanami/commands/new/app'
|
||||
require 'hanami/commands/new/container'
|
||||
|
||||
module Hanami
|
||||
class Cli < Thor
|
||||
# include Thor::Actions
|
||||
|
||||
desc 'version', 'prints Hanami version'
|
||||
long_desc <<-EOS
|
||||
`hanami version` prints the version of the bundled hanami gem.
|
||||
EOS
|
||||
def version
|
||||
require 'hanami/version'
|
||||
puts "v#{ Hanami::VERSION }"
|
||||
end
|
||||
|
||||
desc 'server', 'starts a hanami server'
|
||||
long_desc <<-EOS
|
||||
`hanami server` starts a server for the current hanami project.
|
||||
|
||||
$ > hanami server
|
||||
|
||||
$ > hanami server -p 4500
|
||||
EOS
|
||||
method_option :port, aliases: '-p', desc: 'The port to run the server on, '
|
||||
method_option :server, desc: 'choose a specific Rack::Handler, e.g. webrick, thin etc'
|
||||
method_option :rackup, desc: 'a rackup configuration file path to load (config.ru)'
|
||||
method_option :host, desc: 'the host address to bind to'
|
||||
method_option :debug, desc: 'turn on debug output'
|
||||
method_option :warn, desc: 'turn on warnings'
|
||||
method_option :daemonize, desc: 'if true, the server will daemonize itself (fork, detach, etc)'
|
||||
method_option :pid, desc: 'path to write a pid file after daemonize'
|
||||
method_option :environment, desc: 'path to environment configuration (config/environment.rb)'
|
||||
method_option :code_reloading, desc: 'code reloading', type: :boolean, default: true
|
||||
method_option :help, desc: 'displays the usage message'
|
||||
def server
|
||||
if options[:help]
|
||||
invoke :help, ['server']
|
||||
else
|
||||
require 'hanami/commands/server'
|
||||
Hanami::Commands::Server.new(options).start
|
||||
end
|
||||
end
|
||||
|
||||
desc 'console', 'starts a hanami console'
|
||||
long_desc <<-EOS
|
||||
`hanami console` starts the interactive hanami console.
|
||||
|
||||
$ > hanami console --engine=pry
|
||||
EOS
|
||||
method_option :environment, desc: 'path to environment configuration (config/environment.rb)'
|
||||
method_option :engine, desc: "choose a specific console engine: (#{Hanami::Commands::Console::ENGINES.keys.join('/')})"
|
||||
method_option :help, desc: 'displays the usage method'
|
||||
def console
|
||||
if options[:help]
|
||||
invoke :help, ['console']
|
||||
else
|
||||
Hanami::Commands::Console.new(options).start
|
||||
end
|
||||
end
|
||||
|
||||
desc 'new APPLICATION_NAME', 'generate a new hanami project'
|
||||
long_desc <<-EOS
|
||||
`hanami new` creates a new hanami project.
|
||||
You can specify various options such as the database to be used as well as the path and architecture.
|
||||
|
||||
$ > hanami new fancy_app --application_name=admin
|
||||
|
||||
$ > hanami new fancy_app --arch=app
|
||||
|
||||
$ > hanami new fancy_app --hanami-head=true
|
||||
EOS
|
||||
method_option :database, aliases: ['-d', '--db'], desc: "application database (#{Hanami::Generators::DatabaseConfig::SUPPORTED_ENGINES.keys.join('/')})", default: Hanami::Generators::DatabaseConfig::DEFAULT_ENGINE
|
||||
method_option :architecture, aliases: ['-a', '--arch'], desc: 'project architecture (container/app)', default: Hanami::Commands::New::Abstract::DEFAULT_ARCHITECTURE
|
||||
method_option :application_name, desc: 'application name, only for container', default: Hanami::Commands::New::Container::DEFAULT_APPLICATION_NAME
|
||||
method_option :application_base_url, desc: 'application base url', default: Hanami::Commands::New::Abstract::DEFAULT_APPLICATION_BASE_URL
|
||||
method_option :test, desc: "project test framework (#{Hanami::Generators::TestFramework::VALID_FRAMEWORKS.join('/')})", default: Hanami::Hanamirc::DEFAULT_TEST_SUITE
|
||||
method_option :hanami_head, desc: 'use Hanami HEAD (true/false)', type: :boolean, default: false
|
||||
method_option :help, desc: 'displays the usage method'
|
||||
def new(application_name)
|
||||
if options[:help]
|
||||
invoke :help, ['new']
|
||||
elsif options[:architecture] == 'app'
|
||||
Hanami::Commands::New::App.new(options, application_name).start
|
||||
else
|
||||
Hanami::Commands::New::Container.new(options, application_name).start
|
||||
end
|
||||
end
|
||||
|
||||
desc 'routes', 'prints the routes'
|
||||
long_desc <<-EOS
|
||||
`hanami routes` outputs all the registered routes to the console.
|
||||
EOS
|
||||
method_option :environment, desc: 'path to environment configuration (config/environment.rb)'
|
||||
method_option :help, desc: 'displays the usage method'
|
||||
def routes
|
||||
if options[:help]
|
||||
invoke :help, ['routes']
|
||||
else
|
||||
require 'hanami/commands/routes'
|
||||
Hanami::Commands::Routes.new(options).start
|
||||
end
|
||||
end
|
||||
|
||||
require 'hanami/cli_sub_commands/db'
|
||||
register Hanami::CliSubCommands::DB, 'db', 'db [SUBCOMMAND]', 'manage set of DB operations'
|
||||
|
||||
require 'hanami/cli_sub_commands/generate'
|
||||
register Hanami::CliSubCommands::Generate, 'generate', 'generate [SUBCOMMAND]', 'generate hanami classes'
|
||||
|
||||
require 'hanami/cli_sub_commands/destroy'
|
||||
register Hanami::CliSubCommands::Destroy, 'destroy', 'destroy [SUBCOMMAND]', 'destroy hanami classes'
|
||||
|
||||
require 'hanami/cli_sub_commands/assets'
|
||||
register Hanami::CliSubCommands::Assets, 'assets', 'assets [SUBCOMMAND]', 'manage assets'
|
||||
end
|
||||
end
|
|
@ -1,10 +1,10 @@
|
|||
module Lotus
|
||||
module Hanami
|
||||
class CliSubCommands
|
||||
# A set of subcommands related to assets
|
||||
#
|
||||
# It is run with:
|
||||
#
|
||||
# `bundle exec lotus assets`
|
||||
# `bundle exec hanami assets`
|
||||
#
|
||||
# @since 0.6.0
|
||||
# @api private
|
||||
|
@ -13,8 +13,8 @@ module Lotus
|
|||
|
||||
desc 'precompile', 'precompile assets for deployment'
|
||||
def precompile
|
||||
require 'lotus/commands/assets/precompile'
|
||||
Lotus::Commands::Assets::Precompile.new(options, environment).start
|
||||
require 'hanami/commands/assets/precompile'
|
||||
Hanami::Commands::Assets::Precompile.new(options, environment).start
|
||||
end
|
||||
|
||||
private
|
||||
|
@ -22,7 +22,7 @@ module Lotus
|
|||
# @since 0.6.0
|
||||
# @api private
|
||||
def environment
|
||||
Lotus::Environment.new(options)
|
||||
Hanami::Environment.new(options)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,10 +1,10 @@
|
|||
module Lotus
|
||||
module Hanami
|
||||
class CliSubCommands
|
||||
# A set of subcommands related to DB
|
||||
#
|
||||
# It is run with:
|
||||
#
|
||||
# `bundle exec lotus db`
|
||||
# `bundle exec hanami db`
|
||||
#
|
||||
# @since 0.6.0
|
||||
# @api private
|
||||
|
@ -17,8 +17,8 @@ module Lotus
|
|||
if options[:help]
|
||||
invoke :help, ['console']
|
||||
else
|
||||
require 'lotus/commands/db/console'
|
||||
Lotus::Commands::DB::Console.new(options, name).start
|
||||
require 'hanami/commands/db/console'
|
||||
Hanami::Commands::DB::Console.new(options, name).start
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -29,8 +29,8 @@ module Lotus
|
|||
invoke :help, ['create']
|
||||
else
|
||||
assert_allowed_environment!
|
||||
require 'lotus/commands/db/create'
|
||||
Lotus::Commands::DB::Create.new(options).start
|
||||
require 'hanami/commands/db/create'
|
||||
Hanami::Commands::DB::Create.new(options).start
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -41,8 +41,8 @@ module Lotus
|
|||
invoke :help, ['drop']
|
||||
else
|
||||
assert_allowed_environment!
|
||||
require 'lotus/commands/db/drop'
|
||||
Lotus::Commands::DB::Drop.new(options).start
|
||||
require 'hanami/commands/db/drop'
|
||||
Hanami::Commands::DB::Drop.new(options).start
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -52,8 +52,8 @@ module Lotus
|
|||
if options[:help]
|
||||
invoke :help, ['migrate']
|
||||
else
|
||||
require 'lotus/commands/db/migrate'
|
||||
Lotus::Commands::DB::Migrate.new(options, version).start
|
||||
require 'hanami/commands/db/migrate'
|
||||
Hanami::Commands::DB::Migrate.new(options, version).start
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -64,8 +64,8 @@ module Lotus
|
|||
invoke :help, ['apply']
|
||||
else
|
||||
assert_development_environment!
|
||||
require 'lotus/commands/db/apply'
|
||||
Lotus::Commands::DB::Apply.new(options).start
|
||||
require 'hanami/commands/db/apply'
|
||||
Hanami::Commands::DB::Apply.new(options).start
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -76,8 +76,8 @@ module Lotus
|
|||
invoke :help, ['prepare']
|
||||
else
|
||||
assert_allowed_environment!
|
||||
require 'lotus/commands/db/prepare'
|
||||
Lotus::Commands::DB::Prepare.new(options).start
|
||||
require 'hanami/commands/db/prepare'
|
||||
Hanami::Commands::DB::Prepare.new(options).start
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -89,8 +89,8 @@ module Lotus
|
|||
if options[:help]
|
||||
invoke :help, ['version']
|
||||
else
|
||||
require 'lotus/commands/db/version'
|
||||
Lotus::Commands::DB::Version.new(options).start
|
||||
require 'hanami/commands/db/version'
|
||||
Hanami::Commands::DB::Version.new(options).start
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -99,7 +99,7 @@ module Lotus
|
|||
# @since 0.6.0
|
||||
# @api private
|
||||
def environment
|
||||
Lotus::Environment.new(options)
|
||||
Hanami::Environment.new(options)
|
||||
end
|
||||
|
||||
# @since 0.6.0
|
|
@ -0,0 +1,102 @@
|
|||
require 'hanami/routing/route'
|
||||
require 'hanami/commands/generate/action'
|
||||
|
||||
module Hanami
|
||||
class CliSubCommands
|
||||
class Destroy < Thor
|
||||
include Thor::Actions
|
||||
namespace :destroy
|
||||
|
||||
desc 'action APPLICATION_NAME CONTROLLER_NAME#ACTION_NAME', 'destroy a hanami action'
|
||||
long_desc <<-EOS
|
||||
`hanami destroy action` will destroy an an action, view and template along with specs and a route.
|
||||
|
||||
For Application architecture the application name is 'app'. For Container architecture the default application is called 'web'.
|
||||
|
||||
> $ hanami destroy action app cars#index
|
||||
|
||||
> $ hanami destroy action other-app cars#index
|
||||
|
||||
> $ hanami destroy action web cars#create --method=post
|
||||
EOS
|
||||
|
||||
method_option :method, desc: "The HTTP method used when the route was generated. Must be one of (#{Hanami::Routing::Route::VALID_HTTP_VERBS.join('/')})", default: Hanami::Commands::Generate::Action::DEFAULT_HTTP_METHOD
|
||||
method_option :url, desc: 'Relative URL for action, will be used for the route', default: nil
|
||||
method_option :template, desc: 'Extension used when the template was generated. Default is defined through your .hanamirc file.'
|
||||
|
||||
def actions(application_name, controller_and_action_name)
|
||||
if options[:help]
|
||||
invoke :help, ['action']
|
||||
else
|
||||
Hanami::Commands::Generate::Action.new(options, application_name, controller_and_action_name).destroy.start
|
||||
end
|
||||
end
|
||||
|
||||
desc 'migration NAME', 'destroy a migration'
|
||||
long_desc <<-EOS
|
||||
`hanami destroy migration` will destroy a migration file.
|
||||
|
||||
> $ hanami destroy migration create_books
|
||||
EOS
|
||||
|
||||
def migration(name)
|
||||
if options[:help]
|
||||
invoke :help, ['migration']
|
||||
else
|
||||
require 'hanami/commands/generate/migration'
|
||||
Hanami::Commands::Generate::Migration.new(options, name).destroy.start
|
||||
end
|
||||
end
|
||||
|
||||
desc 'model NAME', 'destroy an entity'
|
||||
long_desc <<-EOS
|
||||
`hanami destroy model` will destroy an entity along with repository
|
||||
and corresponding tests
|
||||
|
||||
> $ hanami generate model car
|
||||
EOS
|
||||
|
||||
def model(name)
|
||||
if options[:help]
|
||||
invoke :help, ['model']
|
||||
else
|
||||
require 'hanami/commands/generate/model'
|
||||
Hanami::Commands::Generate::Model.new(options, name).destroy.start
|
||||
end
|
||||
end
|
||||
|
||||
desc 'application NAME', 'destroy an application'
|
||||
long_desc <<-EOS
|
||||
`hanami destroy application` will destroy an application, along with templates and specs.
|
||||
|
||||
> $ hanami destroy application api
|
||||
EOS
|
||||
def application(name)
|
||||
if options[:help]
|
||||
invoke :help, ['app']
|
||||
else
|
||||
require 'hanami/commands/generate/app'
|
||||
Hanami::Commands::Generate::App.new(options, name).destroy.start
|
||||
end
|
||||
end
|
||||
|
||||
desc 'mailer NAME', 'destroy a mailer'
|
||||
long_desc <<-EOS
|
||||
`hanami destroy mailer` will destroy a mailer, along with templates and specs.
|
||||
|
||||
> $ hanami destroy mailer forgot_password
|
||||
EOS
|
||||
|
||||
def mailer(name)
|
||||
if options[:help]
|
||||
invoke :help, ['mailer']
|
||||
else
|
||||
require 'hanami/commands/generate/mailer'
|
||||
|
||||
options[:behavior] = :revoke
|
||||
Hanami::Commands::Generate::Mailer.new(options, name).destroy.start
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,127 @@
|
|||
require 'hanami/routing/route'
|
||||
require 'hanami/commands/generate/action'
|
||||
require 'hanami/commands/generate/mailer'
|
||||
|
||||
module Hanami
|
||||
class CliSubCommands
|
||||
# A set of generator subcommands
|
||||
#
|
||||
# It is run with:
|
||||
#
|
||||
# `bundle exec hanami generate`
|
||||
#
|
||||
# @since 0.6.0
|
||||
# @api private
|
||||
class Generate < Thor
|
||||
include Thor::Actions
|
||||
|
||||
namespace :generate
|
||||
|
||||
# @since 0.6.0
|
||||
# @api private
|
||||
desc 'action APPLICATION_NAME CONTROLLER_NAME#ACTION_NAME', 'generate a hanami action'
|
||||
long_desc <<-EOS
|
||||
`hanami generate action` generates an an action, view and template along with specs and a route.
|
||||
|
||||
For Application architecture the application name is 'app'. For Container architecture the default application is called 'web'.
|
||||
|
||||
> $ hanami generate action app cars#index
|
||||
|
||||
> $ hanami generate action other-app cars#index
|
||||
|
||||
> $ hanami generate action web cars#create --method=post
|
||||
EOS
|
||||
method_option :method, desc: "The HTTP method to be used for the generated route. Must be one of (#{Hanami::Routing::Route::VALID_HTTP_VERBS.join('/')})", default: Hanami::Commands::Generate::Action::DEFAULT_HTTP_METHOD
|
||||
method_option :url, desc: 'Relative URL for action, will be used for the route', default: nil
|
||||
method_option :test, desc: 'Defines the testing Framework to be used. Default is defined through your .hanamirc file.'
|
||||
method_option :skip_view, desc: 'Skip the generation of the view. Also skips template generation.', default: false, type: :boolean
|
||||
method_option :template, desc: 'Extension to be used for the generated template. Default is defined through your .hanamirc file.'
|
||||
def actions(application_name = nil, controller_and_action_name)
|
||||
if Hanami::Environment.new(options).container? && application_name.nil?
|
||||
msg = "ERROR: \"hanami generate action\" was called with arguments [\"#{controller_and_action_name}\"]\n" \
|
||||
"Usage: \"hanami action APPLICATION_NAME CONTROLLER_NAME#ACTION_NAME\""
|
||||
fail Error, msg
|
||||
end
|
||||
|
||||
if options[:help]
|
||||
invoke :help, ['action']
|
||||
else
|
||||
Hanami::Commands::Generate::Action.new(options, application_name, controller_and_action_name).start
|
||||
end
|
||||
end
|
||||
|
||||
desc 'migration NAME', 'generate a migration'
|
||||
long_desc <<-EOS
|
||||
`hanami generate migration` will generate an empty migration file.
|
||||
|
||||
> $ hanami generate migration do_something
|
||||
EOS
|
||||
def migration(name)
|
||||
if options[:help]
|
||||
invoke :help, ['migration']
|
||||
else
|
||||
require 'hanami/commands/generate/migration'
|
||||
Hanami::Commands::Generate::Migration.new(options, name).start
|
||||
end
|
||||
end
|
||||
|
||||
desc 'model NAME', 'generate an entity'
|
||||
long_desc <<-EOS
|
||||
`hanami generate model` will generate an entity along with repository
|
||||
and corresponding tests. The name of the model can contain slashes to
|
||||
indicate module names.
|
||||
|
||||
> $ hanami generate model car
|
||||
|
||||
> $ hanami generate model vehicles/car
|
||||
EOS
|
||||
method_option :test, desc: 'Defines the testing Framework to be used. Default is defined through your .hanamirc file.'
|
||||
def model(name)
|
||||
if options[:help]
|
||||
invoke :help, ['model']
|
||||
else
|
||||
require 'hanami/commands/generate/model'
|
||||
Hanami::Commands::Generate::Model.new(options, name).start
|
||||
end
|
||||
end
|
||||
|
||||
desc 'mailer NAME', 'generate a mailer'
|
||||
long_desc <<-EOS
|
||||
`hanami generate mailer` will generate an empty mailer, along with templates and specs.
|
||||
|
||||
> $ hanami generate mailer forgot_password
|
||||
> $ hanami generate mailer forgot_password --to "'log@bookshelf.com'" --from "'support@bookshelf.com'" --subject "'New Password'"
|
||||
EOS
|
||||
method_option :to, desc: 'sender email', default: Hanami::Commands::Generate::Mailer::DEFAULT_TO
|
||||
method_option :from, desc: 'sendee email', default: Hanami::Commands::Generate::Mailer::DEFAULT_FROM
|
||||
method_option :subject, desc: 'email subject', default: Hanami::Commands::Generate::Mailer::DEFAULT_SUBJECT
|
||||
def mailer(name)
|
||||
if options[:help]
|
||||
invoke :help, ['mailer']
|
||||
else
|
||||
Hanami::Commands::Generate::Mailer.new(options, name).start
|
||||
end
|
||||
end
|
||||
|
||||
desc 'app APPLICATION_NAME', 'generate an app'
|
||||
long_desc <<-EOS
|
||||
`hanami generate app` creates a new app inside the 'apps' directory.
|
||||
|
||||
It can only be called for hanami applications with container architecture.
|
||||
|
||||
> $ hanami generate app admin
|
||||
|
||||
> $ hanami generate app reporting --application_base_url=/reports
|
||||
EOS
|
||||
method_option :application_base_url, desc: 'Base URL for the new app. If missing, then it is inferred from APPLICATION_NAME'
|
||||
def app(application_name)
|
||||
if options[:help]
|
||||
invoke :help, ['app']
|
||||
else
|
||||
require 'hanami/commands/generate/app'
|
||||
Hanami::Commands::Generate::App.new(options, application_name).start
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,6 +1,6 @@
|
|||
require 'lotus/assets'
|
||||
require 'hanami/assets'
|
||||
|
||||
module Lotus
|
||||
module Hanami
|
||||
module Commands
|
||||
class Assets
|
||||
class Precompile
|
||||
|
@ -20,14 +20,14 @@ module Lotus
|
|||
@environment.require_application_environment
|
||||
|
||||
if @environment.container?
|
||||
Lotus::Container.new
|
||||
Hanami::Container.new
|
||||
else
|
||||
Lotus::Application.preload!
|
||||
Hanami::Application.preload!
|
||||
end
|
||||
end
|
||||
|
||||
def precompile
|
||||
Lotus::Assets.deploy
|
||||
Hanami::Assets.deploy
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,10 +1,10 @@
|
|||
module Lotus
|
||||
module Hanami
|
||||
module Commands
|
||||
# REPL that supports different engines.
|
||||
#
|
||||
# It is run with:
|
||||
#
|
||||
# `bundle exec lotus console`
|
||||
# `bundle exec hanami console`
|
||||
#
|
||||
# @since 0.1.0
|
||||
# @api private
|
||||
|
@ -30,9 +30,9 @@ module Lotus
|
|||
# @param options [Hash] Environment's options
|
||||
#
|
||||
# @since 0.1.0
|
||||
# @see Lotus::Environment#initialize
|
||||
# @see Hanami::Environment#initialize
|
||||
def initialize(options)
|
||||
@environment = Lotus::Environment.new(options)
|
||||
@environment = Hanami::Environment.new(options)
|
||||
@options = @environment.to_options
|
||||
end
|
||||
|
||||
|
@ -80,9 +80,9 @@ module Lotus
|
|||
# @api private
|
||||
def load_application
|
||||
if @environment.container?
|
||||
Lotus::Container.new
|
||||
Hanami::Container.new
|
||||
else
|
||||
Lotus::Application.preload_applications!
|
||||
Hanami::Application.preload_applications!
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,4 +1,4 @@
|
|||
module Lotus
|
||||
module Hanami
|
||||
module Commands
|
||||
class DB
|
||||
class Abstract
|
||||
|
@ -6,7 +6,7 @@ module Lotus
|
|||
|
||||
def initialize(options)
|
||||
@options = options
|
||||
@environment = Lotus::Environment.new(options)
|
||||
@environment = Hanami::Environment.new(options)
|
||||
@environment.require_application_environment
|
||||
end
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
require 'hanami/commands/db/abstract'
|
||||
|
||||
module Hanami
|
||||
module Commands
|
||||
class DB
|
||||
class Apply < Abstract
|
||||
def start
|
||||
require 'hanami/model/migrator'
|
||||
Hanami::Model::Migrator.apply
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,7 +1,7 @@
|
|||
require 'lotus/utils/class'
|
||||
require 'lotus/commands/db/abstract'
|
||||
require 'hanami/utils/class'
|
||||
require 'hanami/commands/db/abstract'
|
||||
|
||||
module Lotus
|
||||
module Hanami
|
||||
module Commands
|
||||
class DB
|
||||
class Console < Abstract
|
||||
|
@ -21,11 +21,11 @@ module Lotus
|
|||
|
||||
def config
|
||||
if name
|
||||
app_constant = Lotus::Utils::Class.load_from_pattern!(Lotus::Utils::String.new(name).classify)
|
||||
Lotus::Utils::Class.load_from_pattern!("#{app_constant}::Application").load!
|
||||
Lotus::Utils::Class.load_from_pattern!("#{app_constant}::Model").configuration
|
||||
app_constant = Hanami::Utils::Class.load_from_pattern!(Hanami::Utils::String.new(name).classify)
|
||||
Hanami::Utils::Class.load_from_pattern!("#{app_constant}::Application").load!
|
||||
Hanami::Utils::Class.load_from_pattern!("#{app_constant}::Model").configuration
|
||||
else
|
||||
Lotus::Model.configuration
|
||||
Hanami::Model.configuration
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -38,7 +38,7 @@ module Lotus
|
|||
end
|
||||
|
||||
def adapter_class
|
||||
Lotus::Utils::Class.load_from_pattern!(adapter_config.class_name, Lotus::Model::Adapters)
|
||||
Hanami::Utils::Class.load_from_pattern!(adapter_config.class_name, Hanami::Model::Adapters)
|
||||
end
|
||||
|
||||
def connection_string
|
|
@ -0,0 +1,14 @@
|
|||
require 'hanami/commands/db/abstract'
|
||||
|
||||
module Hanami
|
||||
module Commands
|
||||
class DB
|
||||
class Create < Abstract
|
||||
def start
|
||||
require 'hanami/model/migrator'
|
||||
Hanami::Model::Migrator.create
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,14 @@
|
|||
require 'hanami/commands/db/abstract'
|
||||
|
||||
module Hanami
|
||||
module Commands
|
||||
class DB
|
||||
class Drop < Abstract
|
||||
def start
|
||||
require 'hanami/model/migrator'
|
||||
Hanami::Model::Migrator.drop
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,6 +1,6 @@
|
|||
require 'lotus/commands/db/abstract'
|
||||
require 'hanami/commands/db/abstract'
|
||||
|
||||
module Lotus
|
||||
module Hanami
|
||||
module Commands
|
||||
class DB
|
||||
class Migrate < Abstract
|
||||
|
@ -10,8 +10,8 @@ module Lotus
|
|||
end
|
||||
|
||||
def start
|
||||
require 'lotus/model/migrator'
|
||||
Lotus::Model::Migrator.migrate(version: @version)
|
||||
require 'hanami/model/migrator'
|
||||
Hanami::Model::Migrator.migrate(version: @version)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,14 @@
|
|||
require 'hanami/commands/db/abstract'
|
||||
|
||||
module Hanami
|
||||
module Commands
|
||||
class DB
|
||||
class Prepare < Abstract
|
||||
def start
|
||||
require 'hanami/model/migrator'
|
||||
Hanami::Model::Migrator.prepare
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,14 @@
|
|||
require 'hanami/commands/db/abstract'
|
||||
|
||||
module Hanami
|
||||
module Commands
|
||||
class DB
|
||||
class Version < Abstract
|
||||
def start
|
||||
require 'hanami/model/migrator'
|
||||
puts Hanami::Model::Migrator.version
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,20 +1,20 @@
|
|||
require 'lotus/environment'
|
||||
require 'lotus/generators/generatable'
|
||||
require 'lotus/generators/test_framework'
|
||||
require 'lotus/version'
|
||||
require 'lotus/utils/string'
|
||||
require 'hanami/environment'
|
||||
require 'hanami/generators/generatable'
|
||||
require 'hanami/generators/test_framework'
|
||||
require 'hanami/version'
|
||||
require 'hanami/utils/string'
|
||||
|
||||
module Lotus
|
||||
module Hanami
|
||||
module Commands
|
||||
class Generate
|
||||
class Abstract
|
||||
|
||||
include Lotus::Generators::Generatable
|
||||
include Hanami::Generators::Generatable
|
||||
|
||||
attr_reader :options, :target_path
|
||||
|
||||
def initialize(options)
|
||||
@options = Lotus::Utils::Hash.new(options).symbolize!
|
||||
@options = Hanami::Utils::Hash.new(options).symbolize!
|
||||
assert_options!
|
||||
|
||||
@target_path = Pathname.pwd
|
||||
|
@ -28,19 +28,19 @@ module Lotus
|
|||
private
|
||||
|
||||
def test_framework
|
||||
@test_framework ||= Lotus::Generators::TestFramework.new(lotusrc, options[:test])
|
||||
@test_framework ||= Hanami::Generators::TestFramework.new(hanamirc, options[:test])
|
||||
end
|
||||
|
||||
def lotusrc_options
|
||||
lotusrc.options
|
||||
def hanamirc_options
|
||||
hanamirc.options
|
||||
end
|
||||
|
||||
def lotusrc
|
||||
@lotusrc ||= Lotusrc.new(target_path)
|
||||
def hanamirc
|
||||
@hanamirc ||= Hanamirc.new(target_path)
|
||||
end
|
||||
|
||||
def environment
|
||||
@environment ||= Lotus::Environment.new(options)
|
||||
@environment ||= Hanami::Environment.new(options)
|
||||
end
|
||||
|
||||
def template_engine
|
||||
|
@ -48,7 +48,7 @@ module Lotus
|
|||
end
|
||||
|
||||
def default_template_engine
|
||||
lotusrc_options.fetch(:template)
|
||||
hanamirc_options.fetch(:template)
|
||||
end
|
||||
|
||||
def assert_options!
|
|
@ -1,7 +1,7 @@
|
|||
require 'lotus/commands/generate/abstract'
|
||||
require 'lotus/routing/route'
|
||||
require 'hanami/commands/generate/abstract'
|
||||
require 'hanami/routing/route'
|
||||
|
||||
module Lotus
|
||||
module Hanami
|
||||
module Commands
|
||||
class Generate
|
||||
class Action < Abstract
|
||||
|
@ -179,8 +179,8 @@ module Lotus
|
|||
# @since 0.5.0
|
||||
# @api private
|
||||
def assert_http_method!
|
||||
if !Lotus::Routing::Route::VALID_HTTP_VERBS.include?(http_method.upcase)
|
||||
existing_http_methods = Lotus::Routing::Route::VALID_HTTP_VERBS
|
||||
if !Hanami::Routing::Route::VALID_HTTP_VERBS.include?(http_method.upcase)
|
||||
existing_http_methods = Hanami::Routing::Route::VALID_HTTP_VERBS
|
||||
raise ArgumentError.new("Unknown HTTP method '#{http_method}', please use one of #{ existing_http_methods.join('/') }.")
|
||||
end
|
||||
end
|
|
@ -1,8 +1,8 @@
|
|||
require 'lotus/commands/generate/abstract'
|
||||
require 'lotus/application_name'
|
||||
require 'hanami/commands/generate/abstract'
|
||||
require 'hanami/application_name'
|
||||
require 'securerandom'
|
||||
|
||||
module Lotus
|
||||
module Hanami
|
||||
module Commands
|
||||
class Generate
|
||||
class App < Abstract
|
||||
|
@ -65,7 +65,7 @@ module Lotus
|
|||
end
|
||||
|
||||
def add_mount_app
|
||||
generator.inject_into_file base_path.join('config/environment.rb'), after: /Lotus::Container.configure do/ do |match|
|
||||
generator.inject_into_file base_path.join('config/environment.rb'), after: /Hanami::Container.configure do/ do |match|
|
||||
"\n mount #{ classified_app_name }::Application, at: '#{ application_base_url }'"
|
||||
end
|
||||
end
|
|
@ -1,6 +1,6 @@
|
|||
require "lotus/commands/generate/abstract"
|
||||
require "hanami/commands/generate/abstract"
|
||||
|
||||
module Lotus
|
||||
module Hanami
|
||||
module Commands
|
||||
class Generate
|
||||
# @since 0.5.0
|
|
@ -1,6 +1,6 @@
|
|||
require 'lotus/commands/generate/abstract'
|
||||
require 'hanami/commands/generate/abstract'
|
||||
|
||||
module Lotus
|
||||
module Hanami
|
||||
module Commands
|
||||
class Generate
|
||||
class Migration < Abstract
|
||||
|
@ -42,14 +42,14 @@ module Lotus
|
|||
end
|
||||
|
||||
def existing_migration_path
|
||||
Dir.glob("#{Lotus::Model.configuration.migrations}/[0-9]*_#{underscored_name}.rb").first
|
||||
Dir.glob("#{Hanami::Model.configuration.migrations}/[0-9]*_#{underscored_name}.rb").first
|
||||
end
|
||||
|
||||
def new_migration_path
|
||||
timestamp = Time.now.utc.strftime(TIMESTAMP_FORMAT)
|
||||
filename = FILENAME_PATTERN % { timestamp: timestamp, name: underscored_name}
|
||||
|
||||
Lotus::Model.configuration.migrations.join(filename)
|
||||
Hanami::Model.configuration.migrations.join(filename)
|
||||
end
|
||||
|
||||
def assert_migration_name!
|
|
@ -1,6 +1,6 @@
|
|||
require 'lotus/commands/generate/abstract'
|
||||
require 'hanami/commands/generate/abstract'
|
||||
|
||||
module Lotus
|
||||
module Hanami
|
||||
module Commands
|
||||
class Generate
|
||||
class Model < Abstract
|
|
@ -1,16 +1,16 @@
|
|||
require 'shellwords'
|
||||
require 'lotus/application_name'
|
||||
require 'lotus/generators/database_config'
|
||||
require 'lotus/generators/generatable'
|
||||
require 'lotus/generators/test_framework'
|
||||
require 'lotus/utils/hash'
|
||||
require 'hanami/application_name'
|
||||
require 'hanami/generators/database_config'
|
||||
require 'hanami/generators/generatable'
|
||||
require 'hanami/generators/test_framework'
|
||||
require 'hanami/utils/hash'
|
||||
|
||||
module Lotus
|
||||
module Hanami
|
||||
module Commands
|
||||
class New
|
||||
class Abstract
|
||||
|
||||
include Lotus::Generators::Generatable
|
||||
include Hanami::Generators::Generatable
|
||||
|
||||
DEFAULT_ARCHITECTURE = 'container'.freeze
|
||||
DEFAULT_APPLICATION_BASE_URL = '/'.freeze
|
||||
|
@ -18,16 +18,16 @@ module Lotus
|
|||
attr_reader :options, :target_path, :database_config
|
||||
|
||||
def initialize(options, name)
|
||||
@options = Lotus::Utils::Hash.new(options).symbolize!
|
||||
@options = Hanami::Utils::Hash.new(options).symbolize!
|
||||
@name = name
|
||||
@options[:database] ||= Lotus::Generators::DatabaseConfig::DEFAULT_ENGINE
|
||||
@options[:database] ||= Hanami::Generators::DatabaseConfig::DEFAULT_ENGINE
|
||||
|
||||
assert_options!
|
||||
assert_name!
|
||||
assert_architecture!
|
||||
|
||||
@lotus_model_version = '~> 0.5'
|
||||
@database_config = Lotus::Generators::DatabaseConfig.new(options[:database], app_name)
|
||||
@hanami_model_version = '~> 0.5'
|
||||
@database_config = Hanami::Generators::DatabaseConfig.new(options[:database], app_name)
|
||||
end
|
||||
|
||||
def start
|
||||
|
@ -42,11 +42,11 @@ module Lotus
|
|||
private
|
||||
|
||||
def test_framework
|
||||
@test_framework ||= Lotus::Generators::TestFramework.new(lotusrc, options[:test])
|
||||
@test_framework ||= Hanami::Generators::TestFramework.new(hanamirc, options[:test])
|
||||
end
|
||||
|
||||
def lotusrc
|
||||
@lotusrc ||= Lotusrc.new(Pathname.new('.'))
|
||||
def hanamirc
|
||||
@hanamirc ||= Hanamirc.new(Pathname.new('.'))
|
||||
end
|
||||
|
||||
def start_in_app_dir
|
||||
|
@ -89,12 +89,12 @@ module Lotus
|
|||
File.directory?(target.join('.git'))
|
||||
end
|
||||
|
||||
def lotus_model_version
|
||||
@lotus_model_version
|
||||
def hanami_model_version
|
||||
@hanami_model_version
|
||||
end
|
||||
|
||||
def lotus_head?
|
||||
options.fetch(:lotus_head, false)
|
||||
def hanami_head?
|
||||
options.fetch(:hanami_head, false)
|
||||
end
|
||||
|
||||
def architecture
|
|
@ -1,6 +1,6 @@
|
|||
require 'lotus/commands/new/abstract'
|
||||
require 'hanami/commands/new/abstract'
|
||||
|
||||
module Lotus
|
||||
module Hanami
|
||||
module Commands
|
||||
class New
|
||||
class App < Abstract
|
||||
|
@ -23,11 +23,11 @@ module Lotus
|
|||
upcase_app_name: upcase_app_name,
|
||||
classified_app_name: classified_app_name,
|
||||
application_base_url: application_base_url,
|
||||
lotus_head: lotus_head?,
|
||||
hanami_head: hanami_head?,
|
||||
test: test_framework.framework,
|
||||
database: database_config.type,
|
||||
database_config: database_config.to_hash,
|
||||
lotus_model_version: lotus_model_version,
|
||||
hanami_model_version: hanami_model_version,
|
||||
}
|
||||
end
|
||||
|
||||
|
@ -38,7 +38,7 @@ module Lotus
|
|||
private
|
||||
|
||||
def add_application_templates
|
||||
add_mapping('lotusrc.tt', '.lotusrc')
|
||||
add_mapping('hanamirc.tt', '.hanamirc')
|
||||
add_mapping('.env.tt', '.env')
|
||||
add_mapping('.env.development.tt', '.env.development')
|
||||
add_mapping('.env.test.tt', '.env.test')
|
|
@ -1,7 +1,7 @@
|
|||
require 'lotus/commands/generate/app'
|
||||
require 'lotus/commands/new/abstract'
|
||||
require 'hanami/commands/generate/app'
|
||||
require 'hanami/commands/new/abstract'
|
||||
|
||||
module Lotus
|
||||
module Hanami
|
||||
module Commands
|
||||
class New
|
||||
class Container < Abstract
|
||||
|
@ -19,11 +19,11 @@ module Lotus
|
|||
def template_options
|
||||
{
|
||||
app_name: app_name,
|
||||
lotus_head: lotus_head?,
|
||||
hanami_head: hanami_head?,
|
||||
test: test_framework.framework,
|
||||
database: database_config.type,
|
||||
database_config: database_config.to_hash,
|
||||
lotus_model_version: lotus_model_version,
|
||||
hanami_model_version: hanami_model_version,
|
||||
}
|
||||
end
|
||||
|
||||
|
@ -35,7 +35,7 @@ module Lotus
|
|||
private
|
||||
|
||||
def add_application_templates
|
||||
add_mapping('lotusrc.tt', '.lotusrc')
|
||||
add_mapping('hanamirc.tt', '.hanamirc')
|
||||
add_mapping('.env.tt', '.env')
|
||||
add_mapping('.env.development.tt', '.env.development')
|
||||
add_mapping('.env.test.tt', '.env.test')
|
||||
|
@ -80,7 +80,7 @@ module Lotus
|
|||
end
|
||||
|
||||
def generate_app
|
||||
Lotus::Commands::Generate::App.new(app_options, app_slice_name).start
|
||||
Hanami::Commands::Generate::App.new(app_options, app_slice_name).start
|
||||
end
|
||||
|
||||
def app_options
|
|
@ -1,10 +1,10 @@
|
|||
module Lotus
|
||||
module Hanami
|
||||
module Commands
|
||||
# Display application/container routes.
|
||||
#
|
||||
# It is run with:
|
||||
#
|
||||
# `bundle exec lotus routes`
|
||||
# `bundle exec hanami routes`
|
||||
#
|
||||
# @since 0.1.0
|
||||
# @api private
|
||||
|
@ -12,9 +12,9 @@ module Lotus
|
|||
# @param options [Hash] Environment's options
|
||||
#
|
||||
# @since 0.1.0
|
||||
# @see Lotus::Environment#initialize
|
||||
# @see Hanami::Environment#initialize
|
||||
def initialize(options)
|
||||
@environment = Lotus::Environment.new(options)
|
||||
@environment = Hanami::Environment.new(options)
|
||||
@environment.require_application_environment
|
||||
end
|
||||
|
||||
|
@ -31,9 +31,9 @@ module Lotus
|
|||
# @api private
|
||||
def app
|
||||
if @environment.container?
|
||||
Lotus::Container.new
|
||||
Hanami::Container.new
|
||||
else
|
||||
Lotus::Application.applications.first.new
|
||||
Hanami::Application.applications.first.new
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,12 +1,12 @@
|
|||
require 'rack'
|
||||
|
||||
module Lotus
|
||||
module Hanami
|
||||
module Commands
|
||||
# Rack compatible server.
|
||||
#
|
||||
# It is run with:
|
||||
#
|
||||
# `bundle exec lotus server`
|
||||
# `bundle exec hanami server`
|
||||
#
|
||||
# It runs the application, by using the server specified in your `Gemfile`
|
||||
# (eg. Puma or Unicorn).
|
||||
|
@ -22,9 +22,9 @@ module Lotus
|
|||
# @param options [Hash] Environment's options
|
||||
#
|
||||
# @since 0.1.0
|
||||
# @see Lotus::Environment#initialize
|
||||
# @see Hanami::Environment#initialize
|
||||
def initialize(options)
|
||||
@_env = Lotus::Environment.new(options)
|
||||
@_env = Hanami::Environment.new(options)
|
||||
@options = _extract_options(@_env)
|
||||
|
||||
if code_reloading?
|
|
@ -1,6 +1,6 @@
|
|||
require 'lotus/config/mapper'
|
||||
require 'hanami/config/mapper'
|
||||
|
||||
module Lotus
|
||||
module Hanami
|
||||
module Config
|
||||
# Define configuration of application of
|
||||
# a specific environment
|
|
@ -1,4 +1,4 @@
|
|||
module Lotus
|
||||
module Hanami
|
||||
module Config
|
||||
# Cookies configuration
|
||||
#
|
||||
|
@ -21,7 +21,7 @@ module Lotus
|
|||
# Eg. alert(document.cookie) will fail
|
||||
#
|
||||
# @param options [Hash, TrueClass, FalseClass] optional cookies options
|
||||
# @param configuration [Lotus::Configuration] the application configuration
|
||||
# @param configuration [Hanami::Configuration] the application configuration
|
||||
#
|
||||
# @since 0.3.0
|
||||
# @api private
|
||||
|
@ -31,7 +31,7 @@ module Lotus
|
|||
#
|
||||
# @example Enable cookies with boolean
|
||||
# module Web
|
||||
# class Application < Lotus::Application
|
||||
# class Application < Hanami::Application
|
||||
# configure do
|
||||
# # ...
|
||||
# cookies true
|
||||
|
@ -41,7 +41,7 @@ module Lotus
|
|||
#
|
||||
# @example Enable cookies with options
|
||||
# module Web
|
||||
# class Application < Lotus::Application
|
||||
# class Application < Hanami::Application
|
||||
# configure do
|
||||
# # ...
|
||||
# cookies max_age: 300
|
|
@ -1,4 +1,4 @@
|
|||
module Lotus
|
||||
module Hanami
|
||||
module Config
|
||||
# Collects all the settings for a given framework configuration and then
|
||||
# forwards them when the application is loaded.
|
|
@ -1,6 +1,6 @@
|
|||
require 'lotus/utils/load_paths'
|
||||
require 'hanami/utils/load_paths'
|
||||
|
||||
module Lotus
|
||||
module Hanami
|
||||
module Config
|
||||
# Define the load paths where the application should load
|
||||
#
|
|
@ -1,8 +1,8 @@
|
|||
require 'lotus/utils/kernel'
|
||||
require 'hanami/utils/kernel'
|
||||
|
||||
module Lotus
|
||||
module Hanami
|
||||
module Config
|
||||
# Define a mapping for Lotus::Model
|
||||
# Define a mapping for Hanami::Model
|
||||
#
|
||||
# @since 0.1.0
|
||||
# @api private
|
|
@ -1,6 +1,6 @@
|
|||
require 'lotus/config/mapper'
|
||||
require 'hanami/config/mapper'
|
||||
|
||||
module Lotus
|
||||
module Hanami
|
||||
module Config
|
||||
class Mapping < Mapper
|
||||
private
|
|
@ -1,6 +1,6 @@
|
|||
require 'lotus/config/mapper'
|
||||
require 'hanami/config/mapper'
|
||||
|
||||
module Lotus
|
||||
module Hanami
|
||||
module Config
|
||||
# Defines a route set
|
||||
#
|
|
@ -1,4 +1,4 @@
|
|||
module Lotus
|
||||
module Hanami
|
||||
module Config
|
||||
# Security policies are stored here.
|
||||
#
|
||||
|
@ -7,13 +7,13 @@ module Lotus
|
|||
# @since 0.3.0
|
||||
# @api private
|
||||
#
|
||||
# @see Lotus::Loader#_configure_controller_framework!
|
||||
# @see Hanami::Loader#_configure_controller_framework!
|
||||
X_FRAME_OPTIONS_HEADER = 'X-Frame-Options'.freeze
|
||||
|
||||
# @since 0.3.0
|
||||
# @api private
|
||||
#
|
||||
# @see Lotus::Loader#_configure_controller_framework!
|
||||
# @see Hanami::Loader#_configure_controller_framework!
|
||||
CONTENT_SECURITY_POLICY_HEADER = 'Content-Security-Policy'.freeze
|
||||
|
||||
# X-Frame-Options headers' value
|
|
@ -1,7 +1,7 @@
|
|||
require 'ipaddr'
|
||||
require 'lotus/utils/string'
|
||||
require 'hanami/utils/string'
|
||||
|
||||
module Lotus
|
||||
module Hanami
|
||||
module Config
|
||||
# Sessions configuration
|
||||
#
|
||||
|
@ -25,7 +25,7 @@ module Lotus
|
|||
#
|
||||
# @param adapter [Symbol,String,Class] the session adapter
|
||||
# @param options [Hash] the optional session options
|
||||
# @param configuration [Lotus::Configuration] the application configuration
|
||||
# @param configuration [Hanami::Configuration] the application configuration
|
||||
#
|
||||
# @since 0.2.0
|
||||
# @api private
|
File diff suppressed because it is too large
Load Diff
|
@ -1,19 +1,19 @@
|
|||
require 'thread'
|
||||
require 'rack/builder'
|
||||
require 'lotus/router'
|
||||
require 'hanami/router'
|
||||
|
||||
module Lotus
|
||||
module Hanami
|
||||
class Container
|
||||
class Router < ::Lotus::Router
|
||||
class Router < ::Hanami::Router
|
||||
def mount(app, options)
|
||||
app = app.new(path_prefix: options.fetch(:at)) if lotus_app?(app)
|
||||
app = app.new(path_prefix: options.fetch(:at)) if hanami_app?(app)
|
||||
super(app, options)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def lotus_app?(app)
|
||||
app.ancestors.include? Lotus::Application
|
||||
def hanami_app?(app)
|
||||
app.ancestors.include? Hanami::Application
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -48,9 +48,9 @@ module Lotus
|
|||
@builder = ::Rack::Builder.new
|
||||
@routes = Router.new(&@@configuration)
|
||||
|
||||
if Lotus.environment.serve_static_assets?
|
||||
require 'lotus/static'
|
||||
@builder.use Lotus::Static
|
||||
if Hanami.environment.serve_static_assets?
|
||||
require 'hanami/static'
|
||||
@builder.use Hanami::Static
|
||||
end
|
||||
|
||||
@builder.run @routes
|
|
@ -1,12 +1,12 @@
|
|||
require 'thread'
|
||||
require 'pathname'
|
||||
require 'dotenv'
|
||||
require 'lotus/utils'
|
||||
require 'lotus/utils/hash'
|
||||
require 'lotus/lotusrc'
|
||||
require 'hanami/utils'
|
||||
require 'hanami/utils/hash'
|
||||
require 'hanami/hanamirc'
|
||||
|
||||
module Lotus
|
||||
# Define and expose information about the Lotus environment.
|
||||
module Hanami
|
||||
# Define and expose information about the Hanami environment.
|
||||
#
|
||||
# @since 0.1.0
|
||||
# @api private
|
||||
|
@ -17,13 +17,13 @@ module Lotus
|
|||
# @api private
|
||||
RACK_ENV = 'RACK_ENV'.freeze
|
||||
|
||||
# Standard Lotus ENV key
|
||||
# Standard Hanami ENV key
|
||||
#
|
||||
# @since 0.1.0
|
||||
# @api private
|
||||
LOTUS_ENV = 'LOTUS_ENV'.freeze
|
||||
HANAMI_ENV = 'HANAMI_ENV'.freeze
|
||||
|
||||
# Default Lotus environment
|
||||
# Default Hanami environment
|
||||
#
|
||||
# @since 0.1.0
|
||||
# @api private
|
||||
|
@ -59,11 +59,11 @@ module Lotus
|
|||
# @api private
|
||||
DEFAULT_CONFIG = 'config'.freeze
|
||||
|
||||
# Standard Lotus host ENV key
|
||||
# Standard Hanami host ENV key
|
||||
#
|
||||
# @since 0.1.0
|
||||
# @api private
|
||||
LOTUS_HOST = 'LOTUS_HOST'.freeze
|
||||
HANAMI_HOST = 'HANAMI_HOST'.freeze
|
||||
|
||||
# Default HTTP host
|
||||
#
|
||||
|
@ -77,13 +77,13 @@ module Lotus
|
|||
# @api private
|
||||
LISTEN_ALL_HOST = '0.0.0.0'.freeze
|
||||
|
||||
# Standard Lotus port ENV key
|
||||
# Standard Hanami port ENV key
|
||||
#
|
||||
# @since 0.1.0
|
||||
# @api private
|
||||
LOTUS_PORT = 'LOTUS_PORT'.freeze
|
||||
HANAMI_PORT = 'HANAMI_PORT'.freeze
|
||||
|
||||
# Default Lotus HTTP port
|
||||
# Default Hanami HTTP port
|
||||
#
|
||||
# @since 0.1.0
|
||||
# @api private
|
||||
|
@ -131,13 +131,13 @@ module Lotus
|
|||
# @api private
|
||||
SERVE_STATIC_ASSETS_ENABLED = 'true'.freeze
|
||||
|
||||
# Initialize a Lotus environment
|
||||
# Initialize a Hanami environment
|
||||
#
|
||||
# It accepts an optional set of configurations from the CLI commands.
|
||||
# Those settings override the defaults defined by this object.
|
||||
#
|
||||
# When initialized, it sets standard `ENV` variables for Rack and Lotus,
|
||||
# such as `RACK_ENV` and `LOTUS_ENV`.
|
||||
# When initialized, it sets standard `ENV` variables for Rack and Hanami,
|
||||
# such as `RACK_ENV` and `HANAMI_ENV`.
|
||||
#
|
||||
# It also evaluates configuration from `.env` and `.env.<environment>`
|
||||
# located under the config directory. All the settings in those files will
|
||||
|
@ -149,12 +149,12 @@ module Lotus
|
|||
# @param options [Hash] override default options for various environment
|
||||
# attributes
|
||||
#
|
||||
# @return [Lotus::Environment] the environment
|
||||
# @return [Hanami::Environment] the environment
|
||||
#
|
||||
# @see Lotus::Commands::Console
|
||||
# @see Lotus::Commands::Routes
|
||||
# @see Lotus::Commands::Server
|
||||
# @see Lotus::Environment#config
|
||||
# @see Hanami::Commands::Console
|
||||
# @see Hanami::Commands::Routes
|
||||
# @see Hanami::Commands::Server
|
||||
# @see Hanami::Environment#config
|
||||
#
|
||||
# @example Define ENV variables from .env
|
||||
#
|
||||
|
@ -171,29 +171,29 @@ module Lotus
|
|||
# # % cat .env.development
|
||||
# # FOO="ok"
|
||||
#
|
||||
# require 'lotus/environment'
|
||||
# require 'hanami/environment'
|
||||
#
|
||||
# env = Lotus::Environment.new
|
||||
# env = Hanami::Environment.new
|
||||
# env.environment # => "development"
|
||||
#
|
||||
# # Framework defined ENV vars
|
||||
# ENV['LOTUS_ENV'] # => "development"
|
||||
# ENV['HANAMI_ENV'] # => "development"
|
||||
# ENV['RACK_ENV'] # => "development"
|
||||
#
|
||||
# ENV['LOTUS_HOST'] # => "localhost"
|
||||
# ENV['LOTUS_PORT'] # => "2300"
|
||||
# ENV['HANAMI_HOST'] # => "localhost"
|
||||
# ENV['HANAMI_PORT'] # => "2300"
|
||||
#
|
||||
# # User defined ENV vars
|
||||
# ENV['FOO'] # => "ok"
|
||||
# ENV['XYZ'] # => "yes"
|
||||
#
|
||||
# # Lotus::Environment evaluates `.env` first as master configuration.
|
||||
# # Hanami::Environment evaluates `.env` first as master configuration.
|
||||
# # Then it evaluates `.env.development` because the current environment
|
||||
# # is "development". The settings defined in this last file override
|
||||
# # the one defined in the parent (eg `FOO` is overwritten). All the
|
||||
# # other settings (eg `XYZ`) will be left untouched.
|
||||
def initialize(options = {})
|
||||
@options = Lotus::Lotusrc.new(root).options
|
||||
@options = Hanami::Hanamirc.new(root).options
|
||||
@options.merge! Utils::Hash.new(options.clone).symbolize!
|
||||
@mutex = Mutex.new
|
||||
@mutex.synchronize { set_env_vars! }
|
||||
|
@ -203,25 +203,25 @@ module Lotus
|
|||
#
|
||||
# In order to decide the value, it looks up to the following `ENV` vars:
|
||||
#
|
||||
# * LOTUS_ENV
|
||||
# * HANAMI_ENV
|
||||
# * RACK_ENV
|
||||
#
|
||||
# If those are missing it falls back to the defalt one: `"development"`.
|
||||
#
|
||||
# Rack environment `"deployment"` is translated to Lotus `"production"`.
|
||||
# Rack environment `"deployment"` is translated to Hanami `"production"`.
|
||||
#
|
||||
# @return [String] the current environment
|
||||
#
|
||||
# @since 0.1.0
|
||||
#
|
||||
# @see Lotus::Environment::DEFAULT_ENV
|
||||
# @see Hanami::Environment::DEFAULT_ENV
|
||||
def environment
|
||||
@environment ||= ENV[LOTUS_ENV] || rack_env || DEFAULT_ENV
|
||||
@environment ||= ENV[HANAMI_ENV] || rack_env || DEFAULT_ENV
|
||||
end
|
||||
|
||||
# @since 0.3.1
|
||||
#
|
||||
# @see Lotus.env?(name)
|
||||
# @see Hanami.env?(name)
|
||||
def environment?(*names)
|
||||
names.map(&:to_s).include?(environment)
|
||||
end
|
||||
|
@ -241,7 +241,7 @@ module Lotus
|
|||
# Application's root
|
||||
#
|
||||
# It defaults to the current working directory.
|
||||
# Lotus assumes that all the commands are executed from there.
|
||||
# Hanami assumes that all the commands are executed from there.
|
||||
#
|
||||
# @return [Pathname] application's root
|
||||
#
|
||||
|
@ -267,8 +267,8 @@ module Lotus
|
|||
#
|
||||
# @since 0.2.0
|
||||
#
|
||||
# @see Lotus::Environment::DEFAULT_CONFIG
|
||||
# @see Lotus::Environment#root
|
||||
# @see Hanami::Environment::DEFAULT_CONFIG
|
||||
# @see Hanami::Environment#root
|
||||
def config
|
||||
@config ||= root.join(@options.fetch(:config) { DEFAULT_CONFIG })
|
||||
end
|
||||
|
@ -278,7 +278,7 @@ module Lotus
|
|||
# In order to decide the value, it looks up the following sources:
|
||||
#
|
||||
# * CLI option `host`
|
||||
# * LOTUS_HOST ENV var
|
||||
# * HANAMI_HOST ENV var
|
||||
#
|
||||
# If those are missing it falls back to the following defaults:
|
||||
#
|
||||
|
@ -289,11 +289,11 @@ module Lotus
|
|||
#
|
||||
# @since 0.1.0
|
||||
#
|
||||
# @see Lotus::Environment::DEFAULT_HOST
|
||||
# @see Lotus::Environment::LISTEN_ALL_HOST
|
||||
# @see Hanami::Environment::DEFAULT_HOST
|
||||
# @see Hanami::Environment::LISTEN_ALL_HOST
|
||||
def host
|
||||
@host ||= @options.fetch(:host) {
|
||||
ENV[LOTUS_HOST] || default_host
|
||||
ENV[HANAMI_HOST] || default_host
|
||||
}
|
||||
end
|
||||
|
||||
|
@ -302,7 +302,7 @@ module Lotus
|
|||
# In order to decide the value, it looks up the following sources:
|
||||
#
|
||||
# * CLI option `port`
|
||||
# * LOTUS_PORT ENV var
|
||||
# * HANAMI_PORT ENV var
|
||||
#
|
||||
# If those are missing it falls back to the default one: `2300`.
|
||||
#
|
||||
|
@ -310,9 +310,9 @@ module Lotus
|
|||
#
|
||||
# @since 0.1.0
|
||||
#
|
||||
# @see Lotus::Environment::DEFAULT_PORT
|
||||
# @see Hanami::Environment::DEFAULT_PORT
|
||||
def port
|
||||
@port ||= @options.fetch(:port) { ENV[LOTUS_PORT] || DEFAULT_PORT }.to_i
|
||||
@port ||= @options.fetch(:port) { ENV[HANAMI_PORT] || DEFAULT_PORT }.to_i
|
||||
end
|
||||
|
||||
# Path to the Rack configuration file
|
||||
|
@ -349,7 +349,7 @@ module Lotus
|
|||
#
|
||||
# @since 0.1.0
|
||||
#
|
||||
# @see Lotus::Environment::DEFAULT_ENVIRONMENT_CONFIG
|
||||
# @see Hanami::Environment::DEFAULT_ENVIRONMENT_CONFIG
|
||||
def env_config
|
||||
root.join(@options.fetch(:environment) { config.join(DEFAULT_ENVIRONMENT_CONFIG) })
|
||||
end
|
||||
|
@ -380,8 +380,8 @@ module Lotus
|
|||
#
|
||||
# @since 0.2.0
|
||||
#
|
||||
# @see Lotus::Commands::Server
|
||||
# @see Lotus::Environment::CODE_RELOADING
|
||||
# @see Hanami::Commands::Server
|
||||
# @see Hanami::Environment::CODE_RELOADING
|
||||
def code_reloading?
|
||||
# JRuby doesn't implement fork that's why shotgun cannot be used.
|
||||
if Utils.jruby?
|
||||
|
@ -396,7 +396,7 @@ module Lotus
|
|||
# @api private
|
||||
def architecture
|
||||
@options.fetch(:architecture) {
|
||||
puts "Cannot recognize Lotus architecture, please check `.lotusrc'"
|
||||
puts "Cannot recognize Hanami architecture, please check `.hanamirc'"
|
||||
exit 1
|
||||
}
|
||||
end
|
||||
|
@ -426,7 +426,7 @@ module Lotus
|
|||
|
||||
# Serialize the most relevant settings into a Hash
|
||||
#
|
||||
# @return [Lotus::Utils::Hash]
|
||||
# @return [Hanami::Utils::Hash]
|
||||
#
|
||||
# @since 0.1.0
|
||||
# @api private
|
||||
|
@ -447,15 +447,15 @@ module Lotus
|
|||
# @api private
|
||||
def set_env_vars!
|
||||
set_application_env_vars!
|
||||
set_lotus_env_vars!
|
||||
set_hanami_env_vars!
|
||||
end
|
||||
|
||||
# @since 0.2.0
|
||||
# @api private
|
||||
def set_lotus_env_vars!
|
||||
ENV[LOTUS_ENV] = ENV[RACK_ENV] = environment
|
||||
ENV[LOTUS_HOST] = host
|
||||
ENV[LOTUS_PORT] = port.to_s
|
||||
def set_hanami_env_vars!
|
||||
ENV[HANAMI_ENV] = ENV[RACK_ENV] = environment
|
||||
ENV[HANAMI_HOST] = host
|
||||
ENV[HANAMI_PORT] = port.to_s
|
||||
end
|
||||
|
||||
# @since 0.2.0
|
|
@ -0,0 +1,14 @@
|
|||
require 'hanami/router'
|
||||
require 'hanami/view'
|
||||
require 'hanami/controller'
|
||||
require 'hanami/action/glue'
|
||||
require 'hanami/action/csrf_protection'
|
||||
require 'hanami/mailer'
|
||||
require 'hanami/mailer/glue'
|
||||
require 'hanami/assets'
|
||||
|
||||
Hanami::Controller.configure do
|
||||
prepare do
|
||||
include Hanami::Action::Glue
|
||||
end
|
||||
end
|
|
@ -3,7 +3,7 @@ require_relative '<%= config[:relative_view_path] %>'
|
|||
|
||||
describe <%= config[:app] %>::Views::<%= config[:controller] %>::<%= config[:action] %> do
|
||||
let(:exposures) { Hash[foo: 'bar'] }
|
||||
let(:template) { Lotus::View::Template.new('<%= config[:template_path] %>') }
|
||||
let(:template) { Hanami::View::Template.new('<%= config[:template_path] %>') }
|
||||
let(:view) { <%= config[:app] %>::Views::<%= config[:controller] %>::<%= config[:action] %>.new(template, exposures) }
|
||||
let(:rendered) { view.render }
|
||||
|
|
@ -2,7 +2,7 @@ require_relative '<%= config[:relative_view_path] %>'
|
|||
|
||||
RSpec.describe <%= config[:app] %>::Views::<%= config[:controller] %>::<%= config[:action] %> do
|
||||
let(:exposures) { Hash[foo: 'bar'] }
|
||||
let(:template) { Lotus::View::Template.new('<%= config[:template_path] %>') }
|
||||
let(:template) { Hanami::View::Template.new('<%= config[:template_path] %>') }
|
||||
let(:view) { described_class.new(template, exposures) }
|
||||
let(:rendered) { view.render }
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
require 'lotus/helpers'
|
||||
require 'lotus/assets'
|
||||
require 'hanami/helpers'
|
||||
require 'hanami/assets'
|
||||
|
||||
module <%= config[:classified_app_name] %>
|
||||
class Application < Lotus::Application
|
||||
class Application < Hanami::Application
|
||||
configure do
|
||||
##
|
||||
# BASIC
|
||||
|
@ -23,7 +23,7 @@ module <%= config[:classified_app_name] %>
|
|||
|
||||
# Handle exceptions with HTTP statuses (true) or don't catch them (false).
|
||||
# Defaults to true.
|
||||
# See: http://www.rubydoc.info/gems/lotus-controller/#Exceptions_management
|
||||
# See: http://www.rubydoc.info/gems/hanami-controller/#Exceptions_management
|
||||
#
|
||||
# handle_exceptions true
|
||||
|
||||
|
@ -32,7 +32,7 @@ module <%= config[:classified_app_name] %>
|
|||
#
|
||||
|
||||
# Routes definitions for this application
|
||||
# See: http://www.rubydoc.info/gems/lotus-router#Usage
|
||||
# See: http://www.rubydoc.info/gems/hanami-router#Usage
|
||||
#
|
||||
routes 'config/routes'
|
||||
|
||||
|
@ -127,7 +127,7 @@ module <%= config[:classified_app_name] %>
|
|||
# * :yui
|
||||
# * :closure
|
||||
#
|
||||
# See: http://lotusrb.org/guides/assets/compressors
|
||||
# See: http://hanamirb.org/guides/assets/compressors
|
||||
#
|
||||
# In order to skip JavaScript compression comment the following line
|
||||
javascript_compressor :builtin
|
||||
|
@ -140,7 +140,7 @@ module <%= config[:classified_app_name] %>
|
|||
# * :yui
|
||||
# * :sass
|
||||
#
|
||||
# See: http://lotusrb.org/guides/assets/compressors
|
||||
# See: http://hanamirb.org/guides/assets/compressors
|
||||
#
|
||||
# In order to skip stylesheet compression comment the following line
|
||||
stylesheet_compressor :builtin
|
||||
|
@ -209,7 +209,7 @@ module <%= config[:classified_app_name] %>
|
|||
# Configure the code that will yield each time <%= config[:classified_app_name] %>::Action is included
|
||||
# This is useful for sharing common functionality
|
||||
#
|
||||
# See: http://www.rubydoc.info/gems/lotus-controller#Configuration
|
||||
# See: http://www.rubydoc.info/gems/hanami-controller#Configuration
|
||||
controller.prepare do
|
||||
# include MyAuthentication # included in all the actions
|
||||
# before :authenticate! # run an authentication before callback
|
||||
|
@ -218,9 +218,9 @@ module <%= config[:classified_app_name] %>
|
|||
# Configure the code that will yield each time <%= config[:classified_app_name] %>::View is included
|
||||
# This is useful for sharing common functionality
|
||||
#
|
||||
# See: http://www.rubydoc.info/gems/lotus-view#Configuration
|
||||
# See: http://www.rubydoc.info/gems/hanami-view#Configuration
|
||||
view.prepare do
|
||||
include Lotus::Helpers
|
||||
include Hanami::Helpers
|
||||
include <%= config[:classified_app_name] %>::Assets::Helpers
|
||||
end
|
||||
end
|
||||
|
@ -252,17 +252,17 @@ module <%= config[:classified_app_name] %>
|
|||
assets do
|
||||
# Don't compile static assets in production mode (eg. Sass, ES6)
|
||||
#
|
||||
# See: http://www.rubydoc.info/gems/lotus-assets#Configuration
|
||||
# See: http://www.rubydoc.info/gems/hanami-assets#Configuration
|
||||
compile false
|
||||
|
||||
# Use digest file name for asset paths
|
||||
#
|
||||
# See: http://lotusrb.org/guides/assets/digest
|
||||
# See: http://hanamirb.org/guides/assets/digest
|
||||
digest true
|
||||
|
||||
# Content Delivery Network (CDN)
|
||||
#
|
||||
# See: http://lotusrb.org/guides/assets/content-delivery-network
|
||||
# See: http://hanamirb.org/guides/assets/content-delivery-network
|
||||
#
|
||||
# scheme 'https'
|
||||
# host 'cdn.example.org'
|
|
@ -0,0 +1,2 @@
|
|||
# Configure your routes here
|
||||
# See: http://www.rubydoc.info/gems/hanami-router/#Usage
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
|
@ -0,0 +1,37 @@
|
|||
source 'https://rubygems.org'
|
||||
|
||||
gem 'bundler'
|
||||
gem 'rake'
|
||||
|
||||
<%- if config[:hanami_head] -%>
|
||||
gem 'hanami-utils', require: false, github: 'hanami/utils'
|
||||
gem 'hanami-router', require: false, github: 'hanami/router'
|
||||
gem 'hanami-validations', require: false, github: 'hanami/validations'
|
||||
gem 'hanami-helpers', require: false, github: 'hanami/helpers'
|
||||
gem 'hanami-controller', require: false, github: 'hanami/controller'
|
||||
gem 'hanami-view', require: false, github: 'hanami/view'
|
||||
gem 'hanami-model', require: false, github: 'hanami/model'
|
||||
gem 'hanami-mailer', require: false, github: 'hanami/mailer'
|
||||
gem 'hanami-assets', require: false, github: 'hanami/assets'
|
||||
gem 'hanami', github: 'hanami/hanami'
|
||||
<%- else -%>
|
||||
gem 'hanami', '<%= Hanami::VERSION %>'
|
||||
gem 'hanami-model', '<%= config[:hanami_model_version] %>'
|
||||
<%- end -%>
|
||||
|
||||
<%- if config[:database_config][:gem] -%>
|
||||
gem '<%= config[:database_config][:gem] %>'
|
||||
<%- end -%>
|
||||
|
||||
group :test do
|
||||
<%- if config[:test] == 'rspec' -%>
|
||||
gem 'rspec'
|
||||
<%- else -%>
|
||||
gem 'minitest'
|
||||
<%- end -%>
|
||||
gem 'capybara'
|
||||
end
|
||||
|
||||
group :production do
|
||||
# gem 'puma'
|
||||
end
|
|
@ -1,5 +1,5 @@
|
|||
require 'rake'
|
||||
require 'lotus/rake_tasks'
|
||||
require 'hanami/rake_tasks'
|
||||
require 'rake/testtask'
|
||||
|
||||
Rake::TestTask.new do |t|
|
|
@ -1,5 +1,5 @@
|
|||
require 'rake'
|
||||
require 'lotus/rake_tasks'
|
||||
require 'hanami/rake_tasks'
|
||||
require 'rspec/core/rake_task'
|
||||
|
||||
RSpec::Core::RakeTask.new(:spec)
|
|
@ -1,8 +1,8 @@
|
|||
require 'lotus/helpers'
|
||||
require 'lotus/assets'
|
||||
require 'hanami/helpers'
|
||||
require 'hanami/assets'
|
||||
|
||||
module <%= config[:classified_app_name] %>
|
||||
class Application < Lotus::Application
|
||||
class Application < Hanami::Application
|
||||
configure do
|
||||
##
|
||||
# BASIC
|
||||
|
@ -23,7 +23,7 @@ module <%= config[:classified_app_name] %>
|
|||
|
||||
# Handle exceptions with HTTP statuses (true) or don't catch them (false).
|
||||
# Defaults to true.
|
||||
# See: http://www.rubydoc.info/gems/lotus-controller/
|
||||
# See: http://www.rubydoc.info/gems/hanami-controller/
|
||||
|
||||
# Exceptions_management
|
||||
#
|
||||
|
@ -34,7 +34,7 @@ module <%= config[:classified_app_name] %>
|
|||
#
|
||||
|
||||
# Routes definitions for this application
|
||||
# See: http://www.rubydoc.info/gems/lotus-router#Usage
|
||||
# See: http://www.rubydoc.info/gems/hanami-router#Usage
|
||||
#
|
||||
routes 'config/routes'
|
||||
|
||||
|
@ -124,7 +124,7 @@ module <%= config[:classified_app_name] %>
|
|||
# * :yui
|
||||
# * :closure
|
||||
#
|
||||
# See: http://lotusrb.org/guides/assets/compressors
|
||||
# See: http://hanamirb.org/guides/assets/compressors
|
||||
#
|
||||
# In order to skip JavaScript compression comment the following line
|
||||
javascript_compressor :builtin
|
||||
|
@ -137,7 +137,7 @@ module <%= config[:classified_app_name] %>
|
|||
# * :yui
|
||||
# * :sass
|
||||
#
|
||||
# See: http://lotusrb.org/guides/assets/compressors
|
||||
# See: http://hanamirb.org/guides/assets/compressors
|
||||
#
|
||||
# In order to skip stylesheet compression comment the following line
|
||||
stylesheet_compressor :builtin
|
||||
|
@ -206,7 +206,7 @@ module <%= config[:classified_app_name] %>
|
|||
# Configure the code that will yield each time <%= config[:classified_app_name] %>::Action is included
|
||||
# This is useful for sharing common functionality
|
||||
#
|
||||
# See: http://www.rubydoc.info/gems/lotus-controller#Configuration
|
||||
# See: http://www.rubydoc.info/gems/hanami-controller#Configuration
|
||||
controller.prepare do
|
||||
# include MyAuthentication # included in all the actions
|
||||
# before :authenticate! # run an authentication before callback
|
||||
|
@ -215,9 +215,9 @@ module <%= config[:classified_app_name] %>
|
|||
# Configure the code that will yield each time <%= config[:classified_app_name] %>::View is included
|
||||
# This is useful for sharing common functionality
|
||||
#
|
||||
# See: http://www.rubydoc.info/gems/lotus-view#Configuration
|
||||
# See: http://www.rubydoc.info/gems/hanami-view#Configuration
|
||||
view.prepare do
|
||||
include Lotus::Helpers
|
||||
include Hanami::Helpers
|
||||
include <%= config[:classified_app_name] %>::Assets::Helpers
|
||||
end
|
||||
end
|
||||
|
@ -249,17 +249,17 @@ module <%= config[:classified_app_name] %>
|
|||
assets do
|
||||
# Don't compile static assets in production mode (eg. Sass, ES6)
|
||||
#
|
||||
# See: http://www.rubydoc.info/gems/lotus-assets#Configuration
|
||||
# See: http://www.rubydoc.info/gems/hanami-assets#Configuration
|
||||
compile false
|
||||
|
||||
# Use digest file name for asset paths
|
||||
#
|
||||
# See: http://lotusrb.org/guides/assets/digest
|
||||
# See: http://hanamirb.org/guides/assets/digest
|
||||
digest true
|
||||
|
||||
# Content Delivery Network (CDN)
|
||||
#
|
||||
# See: http://lotusrb.org/guides/assets/content-delivery-network
|
||||
# See: http://hanamirb.org/guides/assets/content-delivery-network
|
||||
#
|
||||
# scheme 'https'
|
||||
# host 'cdn.example.org'
|
|
@ -1,5 +1,5 @@
|
|||
require 'rubygems'
|
||||
require 'bundler/setup'
|
||||
require 'lotus/setup'
|
||||
require 'hanami/setup'
|
||||
require_relative '../lib/<%= config[:app_name] %>'
|
||||
require_relative '../config/application'
|
|
@ -0,0 +1,2 @@
|
|||
# Configure your routes here
|
||||
# See: http://www.rubydoc.info/gems/hanami-router/#Usage
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
|
@ -0,0 +1,3 @@
|
|||
<%= Hanami::Hanamirc::ARCHITECTURE_KEY %>=<%= Hanami::Hanamirc::APP_ARCHITECTURE %>
|
||||
<%= Hanami::Hanamirc::TEST_KEY %>=<%= config[:test] %>
|
||||
<%= Hanami::Hanamirc::TEMPLATE_KEY %>=<%= Hanami::Hanamirc::DEFAULT_TEMPLATE %>
|
|
@ -1,8 +1,8 @@
|
|||
require 'lotus/model'
|
||||
require 'lotus/mailer'
|
||||
require 'hanami/model'
|
||||
require 'hanami/mailer'
|
||||
Dir["#{ __dir__ }/<%= config[:app_name] %>/**/*.rb"].each { |file| require_relative file }
|
||||
|
||||
Lotus::Model.configure do
|
||||
Hanami::Model.configure do
|
||||
# Database adapter
|
||||
#
|
||||
# Available options:
|
||||
|
@ -47,10 +47,10 @@ Lotus::Model.configure do
|
|||
end
|
||||
end.load!
|
||||
|
||||
Lotus::Mailer.configure do
|
||||
Hanami::Mailer.configure do
|
||||
root "#{ __dir__ }/<%= config[:app_name] %>/mailers"
|
||||
|
||||
# See http://lotusrb.org/guides/mailers/delivery
|
||||
# See http://hanamirb.org/guides/mailers/delivery
|
||||
delivery do
|
||||
development :test
|
||||
test :test
|
|
@ -1,7 +1,7 @@
|
|||
# Require this file for unit tests
|
||||
ENV['LOTUS_ENV'] ||= 'test'
|
||||
ENV['HANAMI_ENV'] ||= 'test'
|
||||
|
||||
require_relative '../config/environment'
|
||||
require 'minitest/autorun'
|
||||
|
||||
Lotus::Application.preload!
|
||||
Hanami::Application.preload!
|
|
@ -1,8 +1,8 @@
|
|||
# Require this file for unit tests
|
||||
ENV['LOTUS_ENV'] ||= 'test'
|
||||
ENV['HANAMI_ENV'] ||= 'test'
|
||||
|
||||
require_relative '../config/environment'
|
||||
Lotus::Application.preload!
|
||||
Hanami::Application.preload!
|
||||
|
||||
Dir[__dir__ + '/support/**/*.rb'].each { |f| require f }
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue