Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
df50e306
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,发现更多精彩内容 >>
提交
df50e306
编写于
11月 02, 2013
作者:
J
Jon Leighton
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Install Spring preloader when generating new applications
上级
d5332de3
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
71 addition
and
7 deletion
+71
-7
railties/CHANGELOG.md
railties/CHANGELOG.md
+7
-0
railties/lib/rails/generators/app_base.rb
railties/lib/rails/generators/app_base.rb
+25
-1
railties/lib/rails/generators/rails/app/app_generator.rb
railties/lib/rails/generators/rails/app/app_generator.rb
+1
-0
railties/test/generators/app_generator_test.rb
railties/test/generators/app_generator_test.rb
+28
-0
railties/test/generators/shared_generator_tests.rb
railties/test/generators/shared_generator_tests.rb
+10
-6
未找到文件。
railties/CHANGELOG.md
浏览文件 @
df50e306
*
The
[
Spring application
preloader
](
https://github.com/jonleighton/spring
)
is now installed
by default for new applications. It uses the development group of
the Gemfile, so will not be installed in production.
*Jon Leighton*
*
Uses .railsrc while creating new plugin if it is available.
Fixes #10700.
...
...
railties/lib/rails/generators/app_base.rb
浏览文件 @
df50e306
...
...
@@ -47,6 +47,9 @@ def self.add_shared_options_for(name)
class_option
:skip_sprockets
,
type: :boolean
,
aliases:
'-S'
,
default:
false
,
desc:
'Skip Sprockets files'
class_option
:skip_spring
,
type: :boolean
,
default:
false
,
desc:
"Don't install Spring application preloader"
class_option
:database
,
type: :string
,
aliases:
'-d'
,
default:
'sqlite3'
,
desc:
"Preconfigure for selected database (options:
#{
DATABASES
.
join
(
'/'
)
}
)"
...
...
@@ -109,6 +112,7 @@ def gemfile_entries
jbuilder_gemfile_entry
,
sdoc_gemfile_entry
,
platform_dependent_gemfile_entry
,
spring_gemfile_entry
,
@extra_entries
].
flatten
.
find_all
(
&
@gem_filter
)
end
...
...
@@ -365,6 +369,12 @@ def javascript_runtime_gemfile_entry
end
end
def
spring_gemfile_entry
return
[]
unless
spring_install?
comment
=
'Spring speeds up development by keeping your application running in the background. Read more: https://github.com/jonleighton/spring'
GemfileEntry
.
new
(
'spring'
,
nil
,
comment
,
group: :development
)
end
def
bundle_command
(
command
)
say_status
:run
,
"bundle
#{
command
}
"
...
...
@@ -388,8 +398,22 @@ def bundle_command(command)
end
end
def
bundle_install?
!
(
options
[
:skip_gemfile
]
||
options
[
:skip_bundle
]
||
options
[
:pretend
])
end
def
spring_install?
!
options
[
:skip_spring
]
&&
Process
.
respond_to?
(
:fork
)
end
def
run_bundle
bundle_command
(
'install'
)
unless
options
[
:skip_gemfile
]
||
options
[
:skip_bundle
]
||
options
[
:pretend
]
bundle_command
(
'install'
)
if
bundle_install?
end
def
generate_spring_binstubs
if
bundle_install?
&&
spring_install?
bundle_command
(
"exec spring binstub --all"
)
end
end
def
empty_directory_with_keep_file
(
destination
,
config
=
{})
...
...
railties/lib/rails/generators/rails/app/app_generator.rb
浏览文件 @
df50e306
...
...
@@ -237,6 +237,7 @@ def delete_js_folder_skipping_javascript
public_task
:run_bundle
public_task
:replay_template
public_task
:generate_spring_binstubs
protected
...
...
railties/test/generators/app_generator_test.rb
浏览文件 @
df50e306
...
...
@@ -437,6 +437,34 @@ def test_application_name_with_spaces
assert_file
"foo bar/config/initializers/session_store.rb"
,
/key: '_foo_bar/
end
def
test_spring
run_generator
assert_file
"Gemfile"
,
/gem 'spring'/
end
def
test_spring_binstubs
generator
.
stubs
(
:bundle_command
).
with
(
'install'
)
generator
.
expects
(
:bundle_command
).
with
(
'exec spring binstub --all'
).
once
quietly
{
generator
.
invoke_all
}
end
def
test_spring_no_fork
Process
.
stubs
(
:respond_to?
).
with
(
:fork
).
returns
(
false
)
run_generator
assert_file
"Gemfile"
do
|
content
|
assert_no_match
(
/spring/
,
content
)
end
end
def
test_skip_spring
run_generator
[
destination_root
,
"--skip-spring"
]
assert_file
"Gemfile"
do
|
content
|
assert_no_match
(
/spring/
,
content
)
end
end
protected
def
action
(
*
args
,
&
block
)
...
...
railties/test/generators/shared_generator_tests.rb
浏览文件 @
df50e306
...
...
@@ -26,11 +26,17 @@ def test_skeleton_is_created
default_files
.
each
{
|
path
|
assert_file
path
}
end
def
test_generation_runs_bundle_install
generator
([
destination_root
]).
expects
(
:bundle_command
).
with
(
'install'
).
once
def
assert_generates_with_bundler
(
options
=
{})
generator
([
destination_root
],
options
)
generator
.
expects
(
:bundle_command
).
with
(
'install'
).
once
generator
.
stubs
(
:bundle_command
).
with
(
'exec spring binstub --all'
)
quietly
{
generator
.
invoke_all
}
end
def
test_generation_runs_bundle_install
assert_generates_with_bundler
end
def
test_plugin_new_generate_pretend
run_generator
[
"testapp"
,
"--pretend"
]
default_files
.
each
{
|
path
|
assert_no_file
File
.
join
(
"testapp"
,
path
)
}
...
...
@@ -96,15 +102,13 @@ def test_template_is_executed_when_supplied_an_https_path
end
def
test_dev_option
generator
([
destination_root
],
dev:
true
).
expects
(
:bundle_command
).
with
(
'install'
).
once
quietly
{
generator
.
invoke_all
}
assert_generates_with_bundler
dev:
true
rails_path
=
File
.
expand_path
(
'../../..'
,
Rails
.
root
)
assert_file
'Gemfile'
,
/^gem\s+["']rails["'],\s+path:\s+["']
#{
Regexp
.
escape
(
rails_path
)
}
["']$/
end
def
test_edge_option
generator
([
destination_root
],
edge:
true
).
expects
(
:bundle_command
).
with
(
'install'
).
once
quietly
{
generator
.
invoke_all
}
assert_generates_with_bundler
edge:
true
assert_file
'Gemfile'
,
%r{^gem
\s
+["']rails["'],
\s
+github:
\s
+["']
#{
Regexp
.
escape
(
"rails/rails"
)
}
["']$}
end
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录