Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
d5bd4b25
R
rails
项目概览
张重言
/
rails
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rails
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
d5bd4b25
编写于
9月 05, 2016
作者:
K
Kasper Timm Hansen
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Run engine commands through command infrastructure.
上级
6813edc7
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
54 addition
and
14 deletion
+54
-14
railties/lib/rails/command/actions.rb
railties/lib/rails/command/actions.rb
+30
-6
railties/lib/rails/command/base.rb
railties/lib/rails/command/base.rb
+5
-0
railties/lib/rails/commands/help/USAGE
railties/lib/rails/commands/help/USAGE
+12
-1
railties/lib/rails/commands/rake/rake_command.rb
railties/lib/rails/commands/rake/rake_command.rb
+4
-2
railties/lib/rails/engine/commands.rb
railties/lib/rails/engine/commands.rb
+2
-4
railties/lib/rails/engine/commands_tasks.rb
railties/lib/rails/engine/commands_tasks.rb
+1
-1
未找到文件。
railties/lib/rails/command/actions.rb
浏览文件 @
d5bd4b25
module
Rails
module
Rails
module
Command
module
Command
module
Actions
module
Actions
private
# Change to the application's path if there is no config.ru file in current directory.
# Change to the application's path if there is no config.ru file in current directory.
# This allows us to run `rails server` from other directories, but still get
# This allows us to run `rails server` from other directories, but still get
# the main config.ru and properly set the tmp directory.
# the main config.ru and properly set the tmp directory.
def
set_application_directory!
def
set_application_directory!
Dir
.
chdir
(
File
.
expand_path
(
"../../"
,
APP_PATH
))
unless
File
.
exist?
(
File
.
expand_path
(
"config.ru"
))
Dir
.
chdir
(
File
.
expand_path
(
"../../"
,
APP_PATH
))
unless
File
.
exist?
(
File
.
expand_path
(
"config.ru"
))
end
if
defined?
(
ENGINE_PATH
)
def
require_application_and_environment!
require
ENGINE_PATH
end
end
def
load_tasks
Rake
.
application
.
init
(
"rails"
)
Rake
.
application
.
load_rakefile
end
def
load_generators
engine
=
::
Rails
::
Engine
.
find
(
ENGINE_ROOT
)
Rails
::
Generators
.
namespace
=
engine
.
railtie_namespace
engine
.
load_generators
end
else
def
require_application_and_environment!
def
require_application_and_environment!
require
APP_PATH
require
APP_PATH
Rails
.
application
.
require_environment!
Rails
.
application
.
require_environment!
end
end
def
load_tasks
Rails
.
application
.
load_tasks
end
def
load_generators
Rails
.
application
.
load_generators
end
end
end
end
end
end
end
end
railties/lib/rails/command/base.rb
浏览文件 @
d5bd4b25
...
@@ -15,6 +15,11 @@ class Error < Thor::Error # :nodoc:
...
@@ -15,6 +15,11 @@ class Error < Thor::Error # :nodoc:
include
Actions
include
Actions
class
<<
self
class
<<
self
# Returns true when the app is a Rails engine.
def
engine?
defined?
(
ENGINE_ROOT
)
end
# Tries to get the description from a USAGE file one folder above the command
# Tries to get the description from a USAGE file one folder above the command
# root.
# root.
def
desc
(
usage
=
nil
,
description
=
nil
)
def
desc
(
usage
=
nil
,
description
=
nil
)
...
...
railties/lib/rails/commands/help/USAGE
浏览文件 @
d5bd4b25
Usage: bin/rails COMMAND [args] [options]
Usage: bin/rails COMMAND [args] [options]
<% if engine? %>
The common Rails commands available for engines are:
generate Generate new code (short-cut alias: "g")
destroy Undo code generated with "generate" (short-cut alias: "d")
test Run tests (short-cut alias: "t")
All commands can be run with -h for more information.
If you want to run any commands that need to be run in context
of the application, like `bin/rails server` or `bin/rails console`,
you should do it from the application's directory (typically test/dummy).
<% else %>
The most common rails commands are:
The most common rails commands are:
generate Generate new code (short-cut alias: "g")
generate Generate new code (short-cut alias: "g")
console Start the Rails console (short-cut alias: "c")
console Start the Rails console (short-cut alias: "c")
...
@@ -11,6 +22,6 @@ The most common rails commands are:
...
@@ -11,6 +22,6 @@ The most common rails commands are:
new application called MyApp in "./my_app"
new application called MyApp in "./my_app"
All commands can be run with -h (or --help) for more information.
All commands can be run with -h (or --help) for more information.
<% end %>
In addition to those commands, there are:
In addition to those commands, there are:
railties/lib/rails/commands/rake/rake_command.rb
浏览文件 @
d5bd4b25
module
Rails
module
Rails
module
Command
module
Command
class
RakeCommand
<
Base
class
RakeCommand
<
Base
extend
Rails
::
Command
::
Actions
namespace
"rake"
namespace
"rake"
class
<<
self
class
<<
self
...
@@ -27,12 +29,12 @@ def rake_tasks
...
@@ -27,12 +29,12 @@ def rake_tasks
return
@rake_tasks
if
defined?
(
@rake_tasks
)
return
@rake_tasks
if
defined?
(
@rake_tasks
)
ActiveSupport
::
Deprecation
.
silence
do
ActiveSupport
::
Deprecation
.
silence
do
Rails
::
Command
.
require_application_and_environment!
require_application_and_environment!
end
end
Rake
::
TaskManager
.
record_task_metadata
=
true
Rake
::
TaskManager
.
record_task_metadata
=
true
Rake
.
application
.
instance_variable_set
(
:@name
,
"rails"
)
Rake
.
application
.
instance_variable_set
(
:@name
,
"rails"
)
Rails
.
application
.
load_tasks
load_tasks
@rake_tasks
=
Rake
.
application
.
tasks
.
select
(
&
:comment
)
@rake_tasks
=
Rake
.
application
.
tasks
.
select
(
&
:comment
)
end
end
...
...
railties/lib/rails/engine/commands.rb
浏览文件 @
d5bd4b25
require
"rails/engine/commands_tasks"
require
"rails/command"
ARGV
<<
"--help"
if
ARGV
.
empty?
aliases
=
{
aliases
=
{
"g"
=>
"generate"
,
"g"
=>
"generate"
,
...
@@ -11,4 +9,4 @@
...
@@ -11,4 +9,4 @@
command
=
ARGV
.
shift
command
=
ARGV
.
shift
command
=
aliases
[
command
]
||
command
command
=
aliases
[
command
]
||
command
Rails
::
Engine
::
CommandsTasks
.
new
(
ARGV
).
run_command!
(
command
)
Rails
::
Command
.
invoke
command
,
ARGV
railties/lib/rails/engine/commands_tasks.rb
浏览文件 @
d5bd4b25
...
@@ -26,7 +26,7 @@ def command_whitelist
...
@@ -26,7 +26,7 @@ def command_whitelist
def
help_message
def
help_message
<<-
EOT
.
strip_heredoc
<<-
EOT
.
strip_heredoc
Usage: rails COMMAND [ARGS]
Usage:
bin/
rails COMMAND [ARGS]
The common Rails commands available for engines are:
The common Rails commands available for engines are:
generate Generate new code (short-cut alias: "g")
generate Generate new code (short-cut alias: "g")
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录