Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
d4fa512d
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,发现更多精彩内容 >>
提交
d4fa512d
编写于
4月 04, 2012
作者:
H
Hrvoje Šimić
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
added example, removed blank lines
上级
aeb228c5
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
13 addition
and
14 deletion
+13
-14
railties/lib/rails/generators/actions.rb
railties/lib/rails/generators/actions.rb
+13
-4
railties/lib/rails/generators/base.rb
railties/lib/rails/generators/base.rb
+0
-10
未找到文件。
railties/lib/rails/generators/actions.rb
浏览文件 @
d4fa512d
...
...
@@ -69,6 +69,7 @@ def gem_group(*names, &block)
# ==== Example
#
# add_source "http://gems.github.com/"
#
def
add_source
(
source
,
options
=
{})
log
:source
,
source
...
...
@@ -82,6 +83,16 @@ def add_source(source, options={})
# If options :env is specified, the line is appended to the corresponding
# file in config/environments.
#
# ==== Examples
#
# environment do
# "config.autoload_paths += %W(#{config.root}/extras)"
# end
#
# environment(nil,:env => "development") do
# "config.active_record.observers = :cacher"
# end
#
def
environment
(
data
=
nil
,
options
=
{},
&
block
)
sentinel
=
/class [a-z_:]+ < Rails::Application/i
env_file_sentinel
=
/::Application\.configure do/
...
...
@@ -160,13 +171,13 @@ def lib(filename, data=nil, &block)
# <<-TASK
# namespace :#{project} do
# task :bootstrap do
# puts "
i
like boots!"
# puts "
I
like boots!"
# end
# end
# TASK
# end
#
# rakefile(
"seed.rake", "puts 'im plantin ur seedz'"
)
# rakefile(
'seed.rake', 'puts "I'm planting your seeds"'
)
#
def
rakefile
(
filename
,
data
=
nil
,
&
block
)
log
:rakefile
,
filename
...
...
@@ -265,7 +276,6 @@ def readme(path)
# Define log for backwards compatibility. If just one argument is sent,
# invoke say, otherwise invoke say_status. Differently from say and
# similarly to say_status, this method respects the quiet? option given.
#
def
log
(
*
args
)
if
args
.
size
==
1
say
args
.
first
.
to_s
unless
options
.
quiet?
...
...
@@ -276,7 +286,6 @@ def log(*args)
end
# Add an extension to the given name based on the platform.
#
def
extify
(
name
)
if
RbConfig
::
CONFIG
[
'host_os'
]
=~
/mswin|mingw/
"
#{
name
}
.bat"
...
...
railties/lib/rails/generators/base.rb
浏览文件 @
d4fa512d
...
...
@@ -248,7 +248,6 @@ def self.inherited(base) #:nodoc:
# Check whether the given class names are already taken by user
# application or Ruby on Rails.
#
def
class_collisions
(
*
class_names
)
#:nodoc:
return
unless
behavior
==
:invoke
...
...
@@ -275,13 +274,11 @@ def class_collisions(*class_names) #:nodoc:
end
# Use Rails default banner.
#
def
self
.
banner
"rails generate
#{
namespace
.
sub
(
/^rails:/
,
''
)
}
#{
self
.
arguments
.
map
{
|
a
|
a
.
usage
}
.join(' ')} [options]"
.
gsub
(
/\s+/
,
' '
)
end
# Sets the base_name taking into account the current class namespace.
#
def
self
.
base_name
@base_name
||=
begin
if
base
=
name
.
to_s
.
split
(
'::'
).
first
...
...
@@ -292,7 +289,6 @@ def self.base_name
# Removes the namespaces and get the generator name. For example,
# Rails::Generators::ModelGenerator will return "model" as generator name.
#
def
self
.
generator_name
@generator_name
||=
begin
if
generator
=
name
.
to_s
.
split
(
'::'
).
last
...
...
@@ -304,20 +300,17 @@ def self.generator_name
# Return the default value for the option name given doing a lookup in
# Rails::Generators.options.
#
def
self
.
default_value_for_option
(
name
,
options
)
default_for_option
(
Rails
::
Generators
.
options
,
name
,
options
,
options
[
:default
])
end
# Return default aliases for the option name given doing a lookup in
# Rails::Generators.aliases.
#
def
self
.
default_aliases_for_option
(
name
,
options
)
default_for_option
(
Rails
::
Generators
.
aliases
,
name
,
options
,
options
[
:aliases
])
end
# Return default for the option name given doing a lookup in config.
#
def
self
.
default_for_option
(
config
,
name
,
options
,
default
)
if
generator_name
and
c
=
config
[
generator_name
.
to_sym
]
and
c
.
key?
(
name
)
c
[
name
]
...
...
@@ -331,14 +324,12 @@ def self.default_for_option(config, name, options, default)
end
# Keep hooks configuration that are used on prepare_for_invocation.
#
def
self
.
hooks
#:nodoc:
@hooks
||=
from_superclass
(
:hooks
,
{})
end
# Prepare class invocation to search on Rails namespace if a previous
# added hook is being used.
#
def
self
.
prepare_for_invocation
(
name
,
value
)
#:nodoc:
return
super
unless
value
.
is_a?
(
String
)
||
value
.
is_a?
(
Symbol
)
...
...
@@ -354,7 +345,6 @@ def self.prepare_for_invocation(name, value) #:nodoc:
# Small macro to add ruby as an option to the generator with proper
# default value plus an instance helper method called shebang.
#
def
self
.
add_shebang_option!
class_option
:ruby
,
:type
=>
:string
,
:aliases
=>
"-r"
,
:default
=>
Thor
::
Util
.
ruby_command
,
:desc
=>
"Path to the Ruby binary of your choice"
,
:banner
=>
"PATH"
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录