lotusrb 0.5.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +57 -14
- data/FEATURES.md +21 -0
- data/LICENSE.md +1 -1
- data/README.md +8 -7
- data/bin/lotus +1 -0
- data/lib/lotus.rb +6 -0
- data/lib/lotus/action/csrf_protection.rb +1 -1
- data/lib/lotus/application.rb +4 -4
- data/lib/lotus/application_name.rb +8 -6
- data/lib/lotus/cli.rb +75 -66
- data/lib/lotus/cli_sub_commands/assets.rb +29 -0
- data/lib/lotus/{commands → cli_sub_commands}/db.rb +24 -29
- data/lib/lotus/cli_sub_commands/destroy.rb +102 -0
- data/lib/lotus/cli_sub_commands/generate.rb +127 -0
- data/lib/lotus/commands/assets/precompile.rb +35 -0
- data/lib/lotus/commands/console.rb +28 -8
- data/lib/lotus/commands/db/abstract.rb +6 -2
- data/lib/lotus/commands/db/console.rb +5 -5
- data/lib/lotus/commands/generate/abstract.rb +63 -0
- data/lib/lotus/commands/generate/action.rb +262 -0
- data/lib/lotus/commands/generate/app.rb +116 -0
- data/lib/lotus/commands/generate/mailer.rb +118 -0
- data/lib/lotus/commands/generate/migration.rb +63 -0
- data/lib/lotus/commands/generate/model.rb +96 -0
- data/lib/lotus/commands/new/abstract.rb +128 -0
- data/lib/lotus/commands/new/app.rb +116 -0
- data/lib/lotus/commands/new/container.rb +102 -0
- data/lib/lotus/commands/routes.rb +19 -2
- data/lib/lotus/commands/server.rb +16 -2
- data/lib/lotus/config/framework_configuration.rb +13 -1
- data/lib/lotus/configuration.rb +24 -76
- data/lib/lotus/container.rb +15 -2
- data/lib/lotus/environment.rb +43 -4
- data/lib/lotus/frameworks.rb +1 -0
- data/lib/lotus/generators/action/action_spec.minitest.tt +1 -1
- data/lib/lotus/generators/action/action_spec.rspec.tt +1 -1
- data/lib/lotus/generators/action/view_spec.minitest.tt +1 -1
- data/lib/lotus/generators/action/view_spec.rspec.tt +1 -1
- data/lib/lotus/generators/{slice → app}/.gitkeep.tt +0 -0
- data/lib/lotus/generators/{slice → app}/application.rb.tt +61 -23
- data/lib/lotus/generators/app/config/initializers/.gitkeep +0 -0
- data/lib/lotus/generators/{slice → app}/config/routes.rb.tt +0 -0
- data/lib/lotus/generators/app/favicon.ico +0 -0
- data/lib/lotus/generators/{slice → app}/templates/application.html.erb.tt +2 -1
- data/lib/lotus/generators/app/views/application_layout.rb.tt +7 -0
- data/lib/lotus/generators/application/app/.env.development.tt +1 -0
- data/lib/lotus/generators/application/app/.env.test.tt +1 -0
- data/lib/lotus/generators/application/app/Gemfile.tt +1 -0
- data/lib/lotus/generators/application/app/Rakefile.minitest.tt +1 -0
- data/lib/lotus/generators/application/app/Rakefile.rspec.tt +1 -0
- data/lib/lotus/generators/application/app/config/application.rb.tt +56 -18
- data/lib/lotus/generators/application/app/config/initializers/.gitkeep +0 -0
- data/lib/lotus/generators/application/app/favicon.ico +0 -0
- data/lib/lotus/generators/application/app/gitignore.tt +2 -0
- data/lib/lotus/generators/application/app/lotusrc.tt +3 -3
- data/lib/lotus/generators/application/app/spec_helper.rb.rspec.tt +5 -1
- data/lib/lotus/generators/application/app/templates/application.html.erb.tt +1 -0
- data/lib/lotus/generators/application/container/.env.development.tt +1 -0
- data/lib/lotus/generators/application/container/.env.test.tt +1 -0
- data/lib/lotus/generators/application/container/Gemfile.tt +1 -1
- data/lib/lotus/generators/application/container/Rakefile.minitest.tt +1 -0
- data/lib/lotus/generators/application/container/Rakefile.rspec.tt +1 -0
- data/lib/lotus/generators/application/container/config/initializers/.gitkeep +0 -0
- data/lib/lotus/generators/application/container/gitignore.tt +2 -0
- data/lib/lotus/generators/application/container/lib/chirp/mailers/.gitkeep +0 -0
- data/lib/lotus/generators/application/container/lib/chirp/mailers/templates/.gitkeep +0 -0
- data/lib/lotus/generators/application/container/lotusrc.tt +3 -3
- data/lib/lotus/generators/application/container/spec_helper.rb.rspec.tt +5 -1
- data/lib/lotus/generators/database_config.rb +17 -4
- data/lib/lotus/generators/generatable.rb +51 -0
- data/lib/lotus/generators/generator.rb +35 -0
- data/lib/lotus/generators/test_framework.rb +42 -0
- data/lib/lotus/loader.rb +43 -0
- data/lib/lotus/lotusrc.rb +50 -49
- data/lib/lotus/middleware.rb +28 -10
- data/lib/lotus/rake_helper.rb +68 -0
- data/lib/lotus/rake_tasks.rb +2 -0
- data/lib/lotus/rendering_policy.rb +2 -2
- data/lib/lotus/repositories/car_repository.rb +3 -0
- data/lib/lotus/repositories/name_repository.rb +3 -0
- data/lib/lotus/setup.rb +1 -3
- data/lib/lotus/static.rb +77 -0
- data/lib/lotus/templates/welcome.html.erb +7 -4
- data/lib/lotus/version.rb +1 -1
- data/lib/lotus/views/default.rb +2 -1
- data/lib/lotus/views/default_template_finder.rb +4 -3
- data/lotusrb.gemspec +11 -9
- metadata +79 -60
- data/lib/lotus/commands/generate.rb +0 -97
- data/lib/lotus/commands/new.rb +0 -43
- data/lib/lotus/config/assets.rb +0 -81
- data/lib/lotus/generators/abstract.rb +0 -31
- data/lib/lotus/generators/action.rb +0 -235
- data/lib/lotus/generators/app.rb +0 -39
- data/lib/lotus/generators/app/.gitkeep +0 -1
- data/lib/lotus/generators/application/app.rb +0 -129
- data/lib/lotus/generators/application/container.rb +0 -111
- data/lib/lotus/generators/mailer.rb +0 -112
- data/lib/lotus/generators/migration.rb +0 -58
- data/lib/lotus/generators/model.rb +0 -90
- data/lib/lotus/generators/slice.rb +0 -94
- data/lib/lotus/generators/slice/views/application_layout.rb.tt +0 -7
@@ -0,0 +1,29 @@
|
|
1
|
+
module Lotus
|
2
|
+
class CliSubCommands
|
3
|
+
# A set of subcommands related to assets
|
4
|
+
#
|
5
|
+
# It is run with:
|
6
|
+
#
|
7
|
+
# `bundle exec lotus assets`
|
8
|
+
#
|
9
|
+
# @since 0.6.0
|
10
|
+
# @api private
|
11
|
+
class Assets < Thor
|
12
|
+
namespace :assets
|
13
|
+
|
14
|
+
desc 'precompile', 'precompile assets for deployment'
|
15
|
+
def precompile
|
16
|
+
require 'lotus/commands/assets/precompile'
|
17
|
+
Lotus::Commands::Assets::Precompile.new(options, environment).start
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
# @since 0.6.0
|
23
|
+
# @api private
|
24
|
+
def environment
|
25
|
+
Lotus::Environment.new(options)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -1,116 +1,109 @@
|
|
1
1
|
module Lotus
|
2
|
-
|
2
|
+
class CliSubCommands
|
3
|
+
# A set of subcommands related to DB
|
4
|
+
#
|
5
|
+
# It is run with:
|
6
|
+
#
|
7
|
+
# `bundle exec lotus db`
|
8
|
+
#
|
9
|
+
# @since 0.6.0
|
10
|
+
# @api private
|
3
11
|
class DB < Thor
|
4
12
|
namespace :db
|
5
13
|
|
6
|
-
desc 'db console', 'start DB console'
|
7
|
-
|
8
14
|
desc 'console', 'start DB console'
|
9
15
|
method_option :environment, desc: 'path to environment configuration (config/environment.rb)'
|
10
|
-
|
11
16
|
def console(name = nil)
|
12
17
|
if options[:help]
|
13
18
|
invoke :help, ['console']
|
14
19
|
else
|
15
20
|
require 'lotus/commands/db/console'
|
16
|
-
Lotus::Commands::DB::Console.new(
|
21
|
+
Lotus::Commands::DB::Console.new(options, name).start
|
17
22
|
end
|
18
23
|
end
|
19
24
|
|
20
|
-
desc 'db create', 'create database'
|
21
|
-
|
22
25
|
desc 'create', 'create database for current environment'
|
23
26
|
method_option :environment, desc: 'path to environment configuration (config/environment.rb)'
|
24
|
-
|
25
27
|
def create
|
26
28
|
if options[:help]
|
27
29
|
invoke :help, ['create']
|
28
30
|
else
|
29
31
|
assert_allowed_environment!
|
30
32
|
require 'lotus/commands/db/create'
|
31
|
-
Lotus::Commands::DB::Create.new(
|
33
|
+
Lotus::Commands::DB::Create.new(options).start
|
32
34
|
end
|
33
35
|
end
|
34
36
|
|
35
|
-
desc 'db drop', 'drop database'
|
36
|
-
|
37
37
|
desc 'drop', 'drop database for current environment'
|
38
38
|
method_option :environment, desc: 'path to environment configuration (config/environment.rb)'
|
39
|
-
|
40
39
|
def drop
|
41
40
|
if options[:help]
|
42
41
|
invoke :help, ['drop']
|
43
42
|
else
|
44
43
|
assert_allowed_environment!
|
45
44
|
require 'lotus/commands/db/drop'
|
46
|
-
Lotus::Commands::DB::Drop.new(
|
45
|
+
Lotus::Commands::DB::Drop.new(options).start
|
47
46
|
end
|
48
47
|
end
|
49
48
|
|
50
|
-
desc 'db migrate', 'migrate database'
|
51
|
-
|
52
49
|
desc 'migrate', 'migrate database for current environment'
|
53
50
|
method_option :environment, desc: 'path to environment configuration (config/environment.rb)'
|
54
|
-
|
55
51
|
def migrate(version = nil)
|
56
52
|
if options[:help]
|
57
53
|
invoke :help, ['migrate']
|
58
54
|
else
|
59
55
|
require 'lotus/commands/db/migrate'
|
60
|
-
Lotus::Commands::DB::Migrate.new(
|
56
|
+
Lotus::Commands::DB::Migrate.new(options, version).start
|
61
57
|
end
|
62
58
|
end
|
63
59
|
|
64
|
-
desc 'db apply', 'apply database changes'
|
65
|
-
|
66
60
|
desc 'apply', 'migrate, dump schema, delete migrations (experimental)'
|
67
61
|
method_option :environment, desc: 'path to environment configuration (config/environment.rb)'
|
68
|
-
|
69
62
|
def apply
|
70
63
|
if options[:help]
|
71
64
|
invoke :help, ['apply']
|
72
65
|
else
|
73
66
|
assert_development_environment!
|
74
67
|
require 'lotus/commands/db/apply'
|
75
|
-
Lotus::Commands::DB::Apply.new(
|
68
|
+
Lotus::Commands::DB::Apply.new(options).start
|
76
69
|
end
|
77
70
|
end
|
78
71
|
|
79
|
-
desc 'db prepare', 'prepare database'
|
80
|
-
|
81
72
|
desc 'prepare', 'create and migrate database'
|
82
73
|
method_option :environment, desc: 'path to environment configuration (config/environment.rb)'
|
83
|
-
|
84
74
|
def prepare
|
85
75
|
if options[:help]
|
86
76
|
invoke :help, ['prepare']
|
87
77
|
else
|
88
78
|
assert_allowed_environment!
|
89
79
|
require 'lotus/commands/db/prepare'
|
90
|
-
Lotus::Commands::DB::Prepare.new(
|
80
|
+
Lotus::Commands::DB::Prepare.new(options).start
|
91
81
|
end
|
92
82
|
end
|
93
83
|
|
94
|
-
|
95
|
-
|
84
|
+
# @since 0.6.0
|
85
|
+
# @api private
|
96
86
|
desc 'version', 'current database version'
|
97
87
|
method_option :environment, desc: 'path to environment configuration (config/environment.rb)'
|
98
|
-
|
99
88
|
def version
|
100
89
|
if options[:help]
|
101
90
|
invoke :help, ['version']
|
102
91
|
else
|
103
92
|
require 'lotus/commands/db/version'
|
104
|
-
Lotus::Commands::DB::Version.new(
|
93
|
+
Lotus::Commands::DB::Version.new(options).start
|
105
94
|
end
|
106
95
|
end
|
107
96
|
|
108
97
|
private
|
109
98
|
|
99
|
+
# @since 0.6.0
|
100
|
+
# @api private
|
110
101
|
def environment
|
111
102
|
Lotus::Environment.new(options)
|
112
103
|
end
|
113
104
|
|
105
|
+
# @since 0.6.0
|
106
|
+
# @api private
|
114
107
|
def assert_allowed_environment!
|
115
108
|
if environment.environment?(:production)
|
116
109
|
puts "Can't run this command in production mode"
|
@@ -118,6 +111,8 @@ module Lotus
|
|
118
111
|
end
|
119
112
|
end
|
120
113
|
|
114
|
+
# @since 0.6.0
|
115
|
+
# @api private
|
121
116
|
def assert_development_environment!
|
122
117
|
unless environment.environment?(:development)
|
123
118
|
puts "This command can be ran only in development mode"
|
@@ -0,0 +1,102 @@
|
|
1
|
+
require 'lotus/routing/route'
|
2
|
+
require 'lotus/commands/generate/action'
|
3
|
+
|
4
|
+
module Lotus
|
5
|
+
class CliSubCommands
|
6
|
+
class Destroy < Thor
|
7
|
+
include Thor::Actions
|
8
|
+
namespace :destroy
|
9
|
+
|
10
|
+
desc 'action APPLICATION_NAME CONTROLLER_NAME#ACTION_NAME', 'destroy a lotus action'
|
11
|
+
long_desc <<-EOS
|
12
|
+
`lotus destroy action` will destroy an an action, view and template along with specs and a route.
|
13
|
+
|
14
|
+
For Application architecture the application name is 'app'. For Container architecture the default application is called 'web'.
|
15
|
+
|
16
|
+
> $ lotus destroy action app cars#index
|
17
|
+
|
18
|
+
> $ lotus destroy action other-app cars#index
|
19
|
+
|
20
|
+
> $ lotus destroy action web cars#create --method=post
|
21
|
+
EOS
|
22
|
+
|
23
|
+
method_option :method, desc: "The HTTP method used when the route was generated. Must be one of (#{Lotus::Routing::Route::VALID_HTTP_VERBS.join('/')})", default: Lotus::Commands::Generate::Action::DEFAULT_HTTP_METHOD
|
24
|
+
method_option :url, desc: 'Relative URL for action, will be used for the route', default: nil
|
25
|
+
method_option :template, desc: 'Extension used when the template was generated. Default is defined through your .lotusrc file.'
|
26
|
+
|
27
|
+
def actions(application_name, controller_and_action_name)
|
28
|
+
if options[:help]
|
29
|
+
invoke :help, ['action']
|
30
|
+
else
|
31
|
+
Lotus::Commands::Generate::Action.new(options, application_name, controller_and_action_name).destroy.start
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
desc 'migration NAME', 'destroy a migration'
|
36
|
+
long_desc <<-EOS
|
37
|
+
`lotus destroy migration` will destroy a migration file.
|
38
|
+
|
39
|
+
> $ lotus destroy migration create_books
|
40
|
+
EOS
|
41
|
+
|
42
|
+
def migration(name)
|
43
|
+
if options[:help]
|
44
|
+
invoke :help, ['migration']
|
45
|
+
else
|
46
|
+
require 'lotus/commands/generate/migration'
|
47
|
+
Lotus::Commands::Generate::Migration.new(options, name).destroy.start
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
desc 'model NAME', 'destroy an entity'
|
52
|
+
long_desc <<-EOS
|
53
|
+
`lotus destroy model` will destroy an entity along with repository
|
54
|
+
and corresponding tests
|
55
|
+
|
56
|
+
> $ lotus generate model car
|
57
|
+
EOS
|
58
|
+
|
59
|
+
def model(name)
|
60
|
+
if options[:help]
|
61
|
+
invoke :help, ['model']
|
62
|
+
else
|
63
|
+
require 'lotus/commands/generate/model'
|
64
|
+
Lotus::Commands::Generate::Model.new(options, name).destroy.start
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
desc 'application NAME', 'destroy an application'
|
69
|
+
long_desc <<-EOS
|
70
|
+
`lotus destroy application` will destroy an application, along with templates and specs.
|
71
|
+
|
72
|
+
> $ lotus destroy application api
|
73
|
+
EOS
|
74
|
+
def application(name)
|
75
|
+
if options[:help]
|
76
|
+
invoke :help, ['app']
|
77
|
+
else
|
78
|
+
require 'lotus/commands/generate/app'
|
79
|
+
Lotus::Commands::Generate::App.new(options, name).destroy.start
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
desc 'mailer NAME', 'destroy a mailer'
|
84
|
+
long_desc <<-EOS
|
85
|
+
`lotus destroy mailer` will destroy a mailer, along with templates and specs.
|
86
|
+
|
87
|
+
> $ lotus destroy mailer forgot_password
|
88
|
+
EOS
|
89
|
+
|
90
|
+
def mailer(name)
|
91
|
+
if options[:help]
|
92
|
+
invoke :help, ['mailer']
|
93
|
+
else
|
94
|
+
require 'lotus/commands/generate/mailer'
|
95
|
+
|
96
|
+
options[:behavior] = :revoke
|
97
|
+
Lotus::Commands::Generate::Mailer.new(options, name).destroy.start
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
@@ -0,0 +1,127 @@
|
|
1
|
+
require 'lotus/routing/route'
|
2
|
+
require 'lotus/commands/generate/action'
|
3
|
+
require 'lotus/commands/generate/mailer'
|
4
|
+
|
5
|
+
module Lotus
|
6
|
+
class CliSubCommands
|
7
|
+
# A set of generator subcommands
|
8
|
+
#
|
9
|
+
# It is run with:
|
10
|
+
#
|
11
|
+
# `bundle exec lotus generate`
|
12
|
+
#
|
13
|
+
# @since 0.6.0
|
14
|
+
# @api private
|
15
|
+
class Generate < Thor
|
16
|
+
include Thor::Actions
|
17
|
+
|
18
|
+
namespace :generate
|
19
|
+
|
20
|
+
# @since 0.6.0
|
21
|
+
# @api private
|
22
|
+
desc 'action APPLICATION_NAME CONTROLLER_NAME#ACTION_NAME', 'generate a lotus action'
|
23
|
+
long_desc <<-EOS
|
24
|
+
`lotus generate action` generates an an action, view and template along with specs and a route.
|
25
|
+
|
26
|
+
For Application architecture the application name is 'app'. For Container architecture the default application is called 'web'.
|
27
|
+
|
28
|
+
> $ lotus generate action app cars#index
|
29
|
+
|
30
|
+
> $ lotus generate action other-app cars#index
|
31
|
+
|
32
|
+
> $ lotus generate action web cars#create --method=post
|
33
|
+
EOS
|
34
|
+
method_option :method, desc: "The HTTP method to be used for the generated route. Must be one of (#{Lotus::Routing::Route::VALID_HTTP_VERBS.join('/')})", default: Lotus::Commands::Generate::Action::DEFAULT_HTTP_METHOD
|
35
|
+
method_option :url, desc: 'Relative URL for action, will be used for the route', default: nil
|
36
|
+
method_option :test, desc: 'Defines the testing Framework to be used. Default is defined through your .lotusrc file.'
|
37
|
+
method_option :skip_view, desc: 'Skip the generation of the view. Also skips template generation.', default: false, type: :boolean
|
38
|
+
method_option :template, desc: 'Extension to be used for the generated template. Default is defined through your .lotusrc file.'
|
39
|
+
def actions(application_name = nil, controller_and_action_name)
|
40
|
+
if Lotus::Environment.new(options).container? && application_name.nil?
|
41
|
+
msg = "ERROR: \"lotus generate action\" was called with arguments [\"#{controller_and_action_name}\"]\n" \
|
42
|
+
"Usage: \"lotus action APPLICATION_NAME CONTROLLER_NAME#ACTION_NAME\""
|
43
|
+
fail Error, msg
|
44
|
+
end
|
45
|
+
|
46
|
+
if options[:help]
|
47
|
+
invoke :help, ['action']
|
48
|
+
else
|
49
|
+
Lotus::Commands::Generate::Action.new(options, application_name, controller_and_action_name).start
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
desc 'migration NAME', 'generate a migration'
|
54
|
+
long_desc <<-EOS
|
55
|
+
`lotus generate migration` will generate an empty migration file.
|
56
|
+
|
57
|
+
> $ lotus generate migration do_something
|
58
|
+
EOS
|
59
|
+
def migration(name)
|
60
|
+
if options[:help]
|
61
|
+
invoke :help, ['migration']
|
62
|
+
else
|
63
|
+
require 'lotus/commands/generate/migration'
|
64
|
+
Lotus::Commands::Generate::Migration.new(options, name).start
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
desc 'model NAME', 'generate an entity'
|
69
|
+
long_desc <<-EOS
|
70
|
+
`lotus generate model` will generate an entity along with repository
|
71
|
+
and corresponding tests. The name of the model can contain slashes to
|
72
|
+
indicate module names.
|
73
|
+
|
74
|
+
> $ lotus generate model car
|
75
|
+
|
76
|
+
> $ lotus generate model vehicles/car
|
77
|
+
EOS
|
78
|
+
method_option :test, desc: 'Defines the testing Framework to be used. Default is defined through your .lotusrc file.'
|
79
|
+
def model(name)
|
80
|
+
if options[:help]
|
81
|
+
invoke :help, ['model']
|
82
|
+
else
|
83
|
+
require 'lotus/commands/generate/model'
|
84
|
+
Lotus::Commands::Generate::Model.new(options, name).start
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
desc 'mailer NAME', 'generate a mailer'
|
89
|
+
long_desc <<-EOS
|
90
|
+
`lotus generate mailer` will generate an empty mailer, along with templates and specs.
|
91
|
+
|
92
|
+
> $ lotus generate mailer forgot_password
|
93
|
+
> $ lotus generate mailer forgot_password --to "'log@bookshelf.com'" --from "'support@bookshelf.com'" --subject "'New Password'"
|
94
|
+
EOS
|
95
|
+
method_option :to, desc: 'sender email', default: Lotus::Commands::Generate::Mailer::DEFAULT_TO
|
96
|
+
method_option :from, desc: 'sendee email', default: Lotus::Commands::Generate::Mailer::DEFAULT_FROM
|
97
|
+
method_option :subject, desc: 'email subject', default: Lotus::Commands::Generate::Mailer::DEFAULT_SUBJECT
|
98
|
+
def mailer(name)
|
99
|
+
if options[:help]
|
100
|
+
invoke :help, ['mailer']
|
101
|
+
else
|
102
|
+
Lotus::Commands::Generate::Mailer.new(options, name).start
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
desc 'app APPLICATION_NAME', 'generate an app'
|
107
|
+
long_desc <<-EOS
|
108
|
+
`lotus generate app` creates a new app inside the 'apps' directory.
|
109
|
+
|
110
|
+
It can only be called for lotus applications with container architecture.
|
111
|
+
|
112
|
+
> $ lotus generate app admin
|
113
|
+
|
114
|
+
> $ lotus generate app reporting --application_base_url=/reports
|
115
|
+
EOS
|
116
|
+
method_option :application_base_url, desc: 'Base URL for the new app. If missing, then it is inferred from APPLICATION_NAME'
|
117
|
+
def app(application_name)
|
118
|
+
if options[:help]
|
119
|
+
invoke :help, ['app']
|
120
|
+
else
|
121
|
+
require 'lotus/commands/generate/app'
|
122
|
+
Lotus::Commands::Generate::App.new(options, application_name).start
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'lotus/assets'
|
2
|
+
|
3
|
+
module Lotus
|
4
|
+
module Commands
|
5
|
+
class Assets
|
6
|
+
class Precompile
|
7
|
+
def initialize(options, environment)
|
8
|
+
@options = options
|
9
|
+
@environment = environment
|
10
|
+
end
|
11
|
+
|
12
|
+
def start
|
13
|
+
preload_applications
|
14
|
+
precompile
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def preload_applications
|
20
|
+
@environment.require_application_environment
|
21
|
+
|
22
|
+
if @environment.container?
|
23
|
+
Lotus::Container.new
|
24
|
+
else
|
25
|
+
Lotus::Application.preload!
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def precompile
|
30
|
+
Lotus::Assets.deploy
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -1,5 +1,13 @@
|
|
1
1
|
module Lotus
|
2
2
|
module Commands
|
3
|
+
# REPL that supports different engines.
|
4
|
+
#
|
5
|
+
# It is run with:
|
6
|
+
#
|
7
|
+
# `bundle exec lotus console`
|
8
|
+
#
|
9
|
+
# @since 0.1.0
|
10
|
+
# @api private
|
3
11
|
class Console
|
4
12
|
module Methods
|
5
13
|
def reload!
|
@@ -14,13 +22,21 @@ module Lotus
|
|
14
22
|
'irb' => 'IRB'
|
15
23
|
}.freeze
|
16
24
|
|
25
|
+
DEFAULT_ENGINE = 'irb'.freeze
|
26
|
+
|
27
|
+
# @since 0.1.0
|
17
28
|
attr_reader :options
|
18
29
|
|
19
|
-
|
20
|
-
|
21
|
-
|
30
|
+
# @param options [Hash] Environment's options
|
31
|
+
#
|
32
|
+
# @since 0.1.0
|
33
|
+
# @see Lotus::Environment#initialize
|
34
|
+
def initialize(options)
|
35
|
+
@environment = Lotus::Environment.new(options)
|
36
|
+
@options = @environment.to_options
|
22
37
|
end
|
23
38
|
|
39
|
+
# @since 0.1.0
|
24
40
|
def start
|
25
41
|
# Clear out ARGV so Pry/IRB don't attempt to parse the rest
|
26
42
|
ARGV.shift until ARGV.empty?
|
@@ -33,20 +49,22 @@ module Lotus
|
|
33
49
|
engine.start
|
34
50
|
end
|
35
51
|
|
52
|
+
# @since 0.1.0
|
53
|
+
# @api private
|
36
54
|
def engine
|
37
55
|
load_engine options.fetch(:engine) { engine_lookup }
|
38
56
|
end
|
39
57
|
|
40
58
|
private
|
41
59
|
|
60
|
+
# @since 0.1.0
|
61
|
+
# @api private
|
42
62
|
def engine_lookup
|
43
|
-
(ENGINES.find { |_, klass| Object.const_defined?(klass) } ||
|
44
|
-
end
|
45
|
-
|
46
|
-
def default_engine
|
47
|
-
ENGINES.to_a.last
|
63
|
+
(ENGINES.find { |_, klass| Object.const_defined?(klass) } || DEFAULT_ENGINE).first
|
48
64
|
end
|
49
65
|
|
66
|
+
# @since 0.1.0
|
67
|
+
# @api private
|
50
68
|
def load_engine(engine)
|
51
69
|
require engine
|
52
70
|
rescue LoadError
|
@@ -58,6 +76,8 @@ module Lotus
|
|
58
76
|
)
|
59
77
|
end
|
60
78
|
|
79
|
+
# @since 0.1.0
|
80
|
+
# @api private
|
61
81
|
def load_application
|
62
82
|
if @environment.container?
|
63
83
|
Lotus::Container.new
|