Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
d22859ed
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 搜索 >>
提交
d22859ed
编写于
5月 21, 2012
作者:
P
Piotr Sarnacki
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #6150 from avakhov/dbconsole-fixes
Rails db console improvements
上级
1447aca7
1fed1f14
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
38 addition
and
10 deletion
+38
-10
railties/lib/rails/commands/console.rb
railties/lib/rails/commands/console.rb
+1
-1
railties/lib/rails/commands/dbconsole.rb
railties/lib/rails/commands/dbconsole.rb
+7
-2
railties/lib/rails/commands/runner.rb
railties/lib/rails/commands/runner.rb
+1
-1
railties/test/commands/dbconsole_test.rb
railties/test/commands/dbconsole_test.rb
+29
-6
未找到文件。
railties/lib/rails/commands/console.rb
浏览文件 @
d22859ed
...
...
@@ -22,7 +22,7 @@ def options
options
=
{}
OptionParser
.
new
do
|
opt
|
opt
.
banner
=
"Usage: console [environment] [options]"
opt
.
banner
=
"Usage:
rails
console [environment] [options]"
opt
.
on
(
'-s'
,
'--sandbox'
,
'Rollback database modifications on exit.'
)
{
|
v
|
options
[
:sandbox
]
=
v
}
opt
.
on
(
"-e"
,
"--environment=name"
,
String
,
"Specifies the environment to run this console under (test/development/production)."
,
...
...
railties/lib/rails/commands/dbconsole.rb
浏览文件 @
d22859ed
...
...
@@ -42,7 +42,7 @@ def start
include_password
=
false
options
=
{}
OptionParser
.
new
do
|
opt
|
opt
.
banner
=
"Usage: dbconsole [environment] [options]"
opt
.
banner
=
"Usage:
rails
dbconsole [environment] [options]"
opt
.
on
(
"-p"
,
"--include-password"
,
"Automatically provide the password from database.yml"
)
do
|
v
|
include_password
=
true
end
...
...
@@ -56,6 +56,11 @@ def start
options
[
'header'
]
=
h
end
opt
.
on
(
"-h"
,
"--help"
,
"Show this help message."
)
do
puts
opt
exit
end
opt
.
parse!
(
arguments
)
abort
opt
.
to_s
unless
(
0
..
1
).
include?
(
arguments
.
size
)
end
...
...
@@ -96,7 +101,7 @@ def start
args
<<
"-
#{
options
[
'mode'
]
}
"
if
options
[
'mode'
]
args
<<
"-header"
if
options
[
'header'
]
args
<<
config
[
'database'
]
args
<<
File
.
expand_path
(
config
[
'database'
],
Rails
.
root
)
find_cmd_and_exec
(
'sqlite3'
,
*
args
)
...
...
railties/lib/rails/commands/runner.rb
浏览文件 @
d22859ed
...
...
@@ -9,7 +9,7 @@
end
ARGV
.
clone
.
options
do
|
opts
|
opts
.
banner
=
"Usage: runner [options] ('Some.ruby(code)' or a filename)"
opts
.
banner
=
"Usage: r
ails r
unner [options] ('Some.ruby(code)' or a filename)"
opts
.
separator
""
...
...
railties/test/commands/dbconsole_test.rb
浏览文件 @
d22859ed
...
...
@@ -92,20 +92,25 @@ def test_sqlite
end
def
test_sqlite3
dbconsole
.
expects
(
:find_cmd_and_exec
).
with
(
'sqlite3'
,
'db'
)
start
(
adapter:
'sqlite3'
,
database:
'db'
)
dbconsole
.
expects
(
:find_cmd_and_exec
).
with
(
'sqlite3'
,
Rails
.
root
.
join
(
'db.sqlite3'
).
to_s
)
start
(
adapter:
'sqlite3'
,
database:
'db
.sqlite3
'
)
assert
!
aborted
end
def
test_sqlite3_mode
dbconsole
.
expects
(
:find_cmd_and_exec
).
with
(
'sqlite3'
,
'-html'
,
'db'
)
start
({
adapter:
'sqlite3'
,
database:
'db'
},
[
'--mode'
,
'html'
])
dbconsole
.
expects
(
:find_cmd_and_exec
).
with
(
'sqlite3'
,
'-html'
,
Rails
.
root
.
join
(
'db.sqlite3'
).
to_s
)
start
({
adapter:
'sqlite3'
,
database:
'db
.sqlite3
'
},
[
'--mode'
,
'html'
])
assert
!
aborted
end
def
test_sqlite3_header
dbconsole
.
expects
(
:find_cmd_and_exec
).
with
(
'sqlite3'
,
'-header'
,
'db'
)
start
({
adapter:
'sqlite3'
,
database:
'db'
},
[
'--header'
])
dbconsole
.
expects
(
:find_cmd_and_exec
).
with
(
'sqlite3'
,
'-header'
,
Rails
.
root
.
join
(
'db.sqlite3'
).
to_s
)
start
({
adapter:
'sqlite3'
,
database:
'db.sqlite3'
},
[
'--header'
])
end
def
test_sqlite3_db_absolute_path
dbconsole
.
expects
(
:find_cmd_and_exec
).
with
(
'sqlite3'
,
'/tmp/db.sqlite3'
)
start
(
adapter:
'sqlite3'
,
database:
'/tmp/db.sqlite3'
)
assert
!
aborted
end
...
...
@@ -127,6 +132,24 @@ def test_unknown_command_line_client
assert_match
/Unknown command-line client for db/
,
output
end
def
test_print_help_short
stdout
=
capture
(
:stdout
)
do
start
({},
[
'-h'
])
end
assert
aborted
assert_equal
''
,
output
assert_match
/Usage:.*dbconsole/
,
stdout
end
def
test_print_help_long
stdout
=
capture
(
:stdout
)
do
start
({},
[
'--help'
])
end
assert
aborted
assert_equal
''
,
output
assert_match
/Usage:.*dbconsole/
,
stdout
end
private
attr_reader
:aborted
,
:output
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录