Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
940da7d9
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,体验更适合开发者的 AI 搜索 >>
提交
940da7d9
编写于
3月 24, 2013
作者:
G
Gabe Kopley
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Put coffee-rails in top-level of generated Gemfile
v3 of pull request based on additional feedback from
@jeremy
上级
592b4b40
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
43 addition
and
16 deletion
+43
-16
railties/CHANGELOG.md
railties/CHANGELOG.md
+12
-0
railties/lib/rails/generators/app_base.rb
railties/lib/rails/generators/app_base.rb
+27
-15
railties/test/generators/app_generator_test.rb
railties/test/generators/app_generator_test.rb
+4
-1
未找到文件。
railties/CHANGELOG.md
浏览文件 @
940da7d9
## Rails 4.0.0 (unreleased) ##
*
Allow vanilla apps to render CoffeeScript templates in production
Vanilla apps already render CoffeeScript templates in development and test
environments. With this change, the production behavior matches that of
the other environments.
Effectively, this meant moving coffee-rails (and the JavaScript runtime on
which it is dependent) from the :assets group to the top-level of the
generated Gemfile.
*Gabe Kopley*
*
`Rails.version`
now returns an instance of
`Gem::Version`
*Charlie Somerville*
...
...
railties/lib/rails/generators/app_base.rb
浏览文件 @
940da7d9
...
...
@@ -178,29 +178,25 @@ def assets_gemfile_entry
return
if
options
[
:skip_sprockets
]
gemfile
=
if
options
.
dev?
||
options
.
edge?
<<-
GEMFILE
<<-
GEMFILE
.
gsub
(
/^ {12}/
,
''
)
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sprockets-rails', github: 'rails/sprockets-rails'
gem 'sass-rails', github: 'rails/sass-rails'
gem 'coffee-rails', github: 'rails/coffee-rails'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
#{
javascript_runtime_gemfile_entry
}
#{
coffee_gemfile_entry
if
options
[
:skip_javascript
]
}
#{
javascript_runtime_gemfile_entry
(
2
)
if
options
[
:skip_javascript
]
}
gem 'uglifier', '>= 1.0.3'
end
GEMFILE
else
<<-
GEMFILE
<<-
GEMFILE
.
gsub
(
/^ {12}/
,
''
)
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '~> 4.0.0.beta1'
gem 'coffee-rails', '~> 4.0.0.beta1'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
#{
javascript_runtime_gemfile_entry
}
#{
coffee_gemfile_entry
if
options
[
:skip_javascript
]
}
#{
javascript_runtime_gemfile_entry
(
2
)
if
options
[
:skip_javascript
]
}
gem 'uglifier', '>= 1.0.3'
end
GEMFILE
...
...
@@ -209,11 +205,23 @@ def assets_gemfile_entry
gemfile
.
strip_heredoc
.
gsub
(
/^[ \t]*$/
,
''
)
end
def
coffee_gemfile_entry
if
options
.
dev?
||
options
.
edge?
"gem 'coffee-rails', github: 'rails/coffee-rails'"
else
"gem 'coffee-rails', '~> 4.0.0.beta1'"
end
end
def
javascript_gemfile_entry
args
=
{
'jquery'
=>
", github: 'rails/jquery-rails'"
}
unless
options
[
:skip_javascript
]
<<-
GEMFILE
.
strip_heredoc
<<-
GEMFILE
.
gsub
(
/^ {12}/
,
''
).
strip_heredoc
#{
javascript_runtime_gemfile_entry
}
# Use CoffeeScript for .js.coffee assets and views
#{
coffee_gemfile_entry
}
gem '
#{
options
[
:javascript
]
}
-rails'
#{
args
[
options
[
:javascript
]]
}
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
...
...
@@ -222,12 +230,16 @@ def javascript_gemfile_entry
end
end
def
javascript_runtime_gemfile_entry
if
defined?
(
JRUBY_VERSION
)
"gem 'therubyrhino'
\n
"
def
javascript_runtime_gemfile_entry
(
n_spaces
=
0
)
runtime
=
if
defined?
(
JRUBY_VERSION
)
"gem 'therubyrhino'"
else
"# gem 'therubyracer', platforms: :ruby
\n
"
"# gem 'therubyracer', platforms: :ruby"
end
<<-
GEMFILE
.
gsub
(
/^ {10}/
,
''
)
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
#{
" "
*
n_spaces
}#{
runtime
}
GEMFILE
end
def
bundle_command
(
command
)
...
...
railties/test/generators/app_generator_test.rb
浏览文件 @
940da7d9
...
...
@@ -232,8 +232,8 @@ def test_generator_if_skip_sprockets_is_given
end
assert_file
"Gemfile"
do
|
content
|
assert_no_match
(
/sass-rails/
,
content
)
assert_no_match
(
/coffee-rails/
,
content
)
assert_no_match
(
/uglifier/
,
content
)
assert_match
(
/coffee-rails/
,
content
)
end
assert_file
"config/environments/development.rb"
do
|
content
|
assert_no_match
(
/config\.assets\.debug = true/
,
content
)
...
...
@@ -293,6 +293,9 @@ def test_javascript_is_skipped_if_required
assert_file
"app/assets/javascripts/application.js"
do
|
contents
|
assert_no_match
%r{^//=
\s
+require
\s
}
,
contents
end
assert_file
"Gemfile"
do
|
content
|
assert_match
(
/coffee-rails/
,
content
)
end
end
def
test_inclusion_of_debugger
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录