Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
5d63a36a
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,发现更多精彩内容 >>
提交
5d63a36a
编写于
12月 15, 2010
作者:
P
Piotr Sarnacki
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Generate javascripts in engine with --mountable option
上级
0e5ee9af
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
70 addition
and
5 deletion
+70
-5
railties/lib/rails/generators/app_base.rb
railties/lib/rails/generators/app_base.rb
+6
-0
railties/lib/rails/generators/rails/app/app_generator.rb
railties/lib/rails/generators/rails/app/app_generator.rb
+0
-5
railties/lib/rails/generators/rails/plugin_new/plugin_new_generator.rb
...rails/generators/rails/plugin_new/plugin_new_generator.rb
+35
-0
railties/test/generators/plugin_new_generator_test.rb
railties/test/generators/plugin_new_generator_test.rb
+29
-0
未找到文件。
railties/lib/rails/generators/app_base.rb
浏览文件 @
5d63a36a
...
...
@@ -171,6 +171,12 @@ def bundle_if_dev_or_edge
def
dev_or_edge?
options
.
dev?
||
options
.
edge?
end
def
empty_directory_with_gitkeep
(
destination
,
config
=
{})
empty_directory
(
destination
,
config
)
create_file
(
"
#{
destination
}
/.gitkeep"
)
unless
options
[
:skip_git
]
end
end
end
end
railties/lib/rails/generators/rails/app/app_generator.rb
浏览文件 @
5d63a36a
...
...
@@ -317,11 +317,6 @@ def mysql_socket
].
find
{
|
f
|
File
.
exist?
(
f
)
}
unless
RbConfig
::
CONFIG
[
'host_os'
]
=~
/mswin|mingw/
end
def
empty_directory_with_gitkeep
(
destination
,
config
=
{})
empty_directory
(
destination
,
config
)
create_file
(
"
#{
destination
}
/.gitkeep"
)
unless
options
[
:skip_git
]
end
def
get_builder_class
defined?
(
::
AppBuilder
)
?
::
AppBuilder
:
Rails
::
AppBuilder
end
...
...
railties/lib/rails/generators/rails/plugin_new/plugin_new_generator.rb
浏览文件 @
5d63a36a
...
...
@@ -88,6 +88,29 @@ def test_dummy_clean
end
end
def
stylesheets
empty_directory_with_gitkeep
"public/stylesheets"
if
options
[
:mountable
]
end
def
javascripts
return
unless
options
[
:mountable
]
empty_directory
"
#{
app_templates_dir
}
/public/javascripts"
unless
options
[
:skip_javascript
]
copy_file
"
#{
app_templates_dir
}
/public/javascripts/
#{
options
[
:javascript
]
}
.js"
,
"public/javascripts/
#{
options
[
:javascript
]
}
.js"
copy_file
"
#{
app_templates_dir
}
/public/javascripts/
#{
options
[
:javascript
]
}
_ujs.js"
,
"public/javascripts/rails.js"
if
options
[
:prototype
]
copy_file
"
#{
app_templates_dir
}
/public/javascripts/controls.js"
,
"public/javascripts/controls.js"
copy_file
"
#{
app_templates_dir
}
/public/javascripts/dragdrop.js"
,
"public/javascripts/dragdrop.js"
copy_file
"
#{
app_templates_dir
}
/public/javascripts/effects.js"
,
"public/javascripts/effects.js"
end
end
copy_file
"
#{
app_templates_dir
}
/public/javascripts/application.js"
,
"public/javascripts/application.js"
end
def
script
(
force
=
false
)
directory
"script"
,
:force
=>
force
do
|
content
|
"
#{
shebang
}
\n
"
+
content
...
...
@@ -143,6 +166,14 @@ def create_lib_files
build
(
:lib
)
end
def
create_public_stylesheets_files
build
(
:stylesheets
)
end
def
create_javascript_files
build
(
:javascripts
)
end
def
create_script_files
build
(
:script
)
end
...
...
@@ -163,6 +194,10 @@ def finish_template
public_task
:apply_rails_template
,
:bundle_if_dev_or_edge
protected
def
app_templates_dir
"../../app/templates"
end
def
create_dummy_app
(
path
=
nil
)
dummy_path
(
path
)
if
path
...
...
railties/test/generators/plugin_new_generator_test.rb
浏览文件 @
5d63a36a
...
...
@@ -91,6 +91,35 @@ def test_ensure_that_database_option_is_passed_to_app_generator
assert_file
"test/dummy/config/database.yml"
,
/postgres/
end
def
test_skipping_javascripts_without_mountable_option
run_generator
assert_no_file
"public/javascripts/prototype.js"
assert_no_file
"public/javascripts/rails.js"
assert_no_file
"public/javascripts/controls.js"
assert_no_file
"public/javascripts/dragdrop.js"
assert_no_file
"public/javascripts/dragdrop.js"
assert_no_file
"public/javascripts/application.js"
end
def
test_javascripts_generation
run_generator
[
destination_root
,
"--mountable"
]
assert_file
"public/javascripts/rails.js"
assert_file
"public/javascripts/prototype.js"
assert_file
"public/javascripts/controls.js"
assert_file
"public/javascripts/dragdrop.js"
assert_file
"public/javascripts/dragdrop.js"
assert_file
"public/javascripts/application.js"
end
def
test_skip_javascripts
run_generator
[
destination_root
,
"--skip-javascript"
,
"--mountable"
]
assert_no_file
"public/javascripts/prototype.js"
assert_no_file
"public/javascripts/rails.js"
assert_no_file
"public/javascripts/controls.js"
assert_no_file
"public/javascripts/dragdrop.js"
assert_no_file
"public/javascripts/dragdrop.js"
end
def
test_ensure_that_javascript_option_is_passed_to_app_generator
run_generator
[
destination_root
,
"--javascript"
,
"jquery"
]
assert_file
"test/dummy/public/javascripts/jquery.js"
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录