Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
d5bdf31d
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,发现更多精彩内容 >>
提交
d5bdf31d
编写于
6月 25, 2009
作者:
J
José Valim
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Refactoring out descriptions.
上级
6e6c0117
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
18 addition
and
27 deletion
+18
-27
railties/lib/generators/base.rb
railties/lib/generators/base.rb
+18
-7
railties/lib/generators/erb/mailer/mailer_generator.rb
railties/lib/generators/erb/mailer/mailer_generator.rb
+0
-5
railties/lib/generators/test_unit/mailer/mailer_generator.rb
railties/lib/generators/test_unit/mailer/mailer_generator.rb
+0
-5
railties/lib/generators/test_unit/observer/observer_generator.rb
...s/lib/generators/test_unit/observer/observer_generator.rb
+0
-5
railties/lib/generators/test_unit/plugin/plugin_generator.rb
railties/lib/generators/test_unit/plugin/plugin_generator.rb
+0
-5
未找到文件。
railties/lib/generators/base.rb
浏览文件 @
d5bdf31d
...
...
@@ -15,17 +15,28 @@ def self.source_root
@source_root
||=
File
.
expand_path
(
File
.
join
(
File
.
dirname
(
__FILE__
),
base_name
,
generator_name
,
'templates'
))
end
# Tries to get the description from a USAGE file one folder above the source
# root otherwise uses a default description.
#
def
self
.
desc
(
description
=
nil
)
return
super
if
description
usage
=
File
.
join
(
source_root
,
".."
,
"USAGE"
)
@desc
||=
if
File
.
exist?
(
usage
)
File
.
read
(
usage
)
else
"Description:
\n
Create
#{
base_name
.
humanize
.
downcase
}
files for
#{
generator_name
}
generator."
end
end
# Convenience method to get the namespace from the class name. It's the
# same as Thor default except that the Generator at the end of the class
# is removed.
#
def
self
.
namespace
(
name
=
nil
)
#:nodoc:
if
name
super
else
def
self
.
namespace
(
name
=
nil
)
return
super
if
name
@namespace
||=
"
#{
base_name
}
:generators:
#{
generator_name
}
"
end
end
protected
...
...
@@ -70,7 +81,7 @@ def self.banner
# Sets the base_name taking into account the current class namespace.
#
def
self
.
base_name
#:nodoc:
def
self
.
base_name
@base_name
||=
self
.
name
.
split
(
'::'
).
first
.
underscore
end
...
...
railties/lib/generators/erb/mailer/mailer_generator.rb
浏览文件 @
d5bdf31d
...
...
@@ -3,11 +3,6 @@ module Generators
class
MailerGenerator
<
Base
argument
:actions
,
:type
=>
:array
,
:default
=>
[]
desc
<<
DESC
Description:
Create Template engine files for mailer generator.
DESC
def
create_view_files
actions
.
each
do
|
action
|
@action
,
@path
=
action
,
File
.
join
(
file_path
,
action
)
...
...
railties/lib/generators/test_unit/mailer/mailer_generator.rb
浏览文件 @
d5bdf31d
...
...
@@ -3,11 +3,6 @@ module Generators
class
MailerGenerator
<
Base
argument
:actions
,
:type
=>
:array
,
:default
=>
[]
desc
<<
DESC
Description:
Create TestUnit files for mailer generator.
DESC
def
create_test_files
template
"unit_test.rb"
,
File
.
join
(
'test'
,
'unit'
,
class_path
,
"
#{
file_name
}
_test.rb"
)
end
...
...
railties/lib/generators/test_unit/observer/observer_generator.rb
浏览文件 @
d5bdf31d
module
TestUnit
module
Generators
class
ObserverGenerator
<
Base
desc
<<
DESC
Description:
Create TestUnit files for observer generator.
DESC
def
create_test_files
template
'unit_test.rb'
,
File
.
join
(
'test'
,
'unit'
,
class_path
,
"
#{
file_name
}
_observer_test.rb"
)
end
...
...
railties/lib/generators/test_unit/plugin/plugin_generator.rb
浏览文件 @
d5bdf31d
module
TestUnit
module
Generators
class
PluginGenerator
<
Base
desc
<<
DESC
Description:
Create TestUnit files for plugin generator.
DESC
def
create_test_files
directory
'test'
end
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录