Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
github
hub
提交
e16b8478
H
hub
项目概览
github
/
hub
接近 1 年 前同步成功
通知
3
Star
22523
Fork
2406
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
H
hub
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
e16b8478
编写于
12月 08, 2009
作者:
C
Chris Wanstrath
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
no more colors :(
上级
272a9ef3
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
0 addition
and
80 deletion
+0
-80
lib/hub.rb
lib/hub.rb
+0
-1
lib/hub/colors.rb
lib/hub/colors.rb
+0
-79
未找到文件。
lib/hub.rb
浏览文件 @
e16b8478
...
...
@@ -3,4 +3,3 @@ require 'hub/args'
require
'hub/commands'
require
'hub/runner'
require
'hub/standalone'
require
'hub/colors'
lib/hub/colors.rb
已删除
100644 → 0
浏览文件 @
272a9ef3
# http://github.com/defunkt/colored
module
Colored
extend
self
COLORS
=
{
'black'
=>
30
,
'red'
=>
31
,
'green'
=>
32
,
'yellow'
=>
33
,
'blue'
=>
34
,
'magenta'
=>
35
,
'cyan'
=>
36
,
'white'
=>
37
}
EXTRAS
=
{
'clear'
=>
0
,
'bold'
=>
1
,
'underline'
=>
4
,
'reversed'
=>
7
}
COLORS
.
each
do
|
color
,
value
|
define_method
(
color
)
do
colorize
(
self
,
:foreground
=>
color
)
end
define_method
(
"on_
#{
color
}
"
)
do
colorize
(
self
,
:background
=>
color
)
end
COLORS
.
each
do
|
highlight
,
value
|
next
if
color
==
highlight
define_method
(
"
#{
color
}
_on_
#{
highlight
}
"
)
do
colorize
(
self
,
:foreground
=>
color
,
:background
=>
highlight
)
end
end
end
EXTRAS
.
each
do
|
extra
,
value
|
next
if
extra
==
'clear'
define_method
(
extra
)
do
colorize
(
self
,
:extra
=>
extra
)
end
end
define_method
(
:to_eol
)
do
tmp
=
sub
(
/^(\e\[[\[\e0-9;m]+m)/
,
"
\\
1
\e
[2K"
)
if
tmp
==
self
return
"
\e
[2K"
<<
self
end
tmp
end
def
colorize
(
string
,
options
=
{})
return
string
unless
$stdout
.
tty?
colored
=
[
color
(
options
[
:foreground
]),
color
(
"on_
#{
options
[
:background
]
}
"
),
extra
(
options
[
:extra
])].
compact
*
''
colored
<<
string
colored
<<
extra
(
:clear
)
end
def
colors
@@colors
||=
COLORS
.
keys
.
sort
end
def
extra
(
extra_name
)
extra_name
=
extra_name
.
to_s
"
\e
[
#{
EXTRAS
[
extra_name
]
}
m"
if
EXTRAS
[
extra_name
]
end
def
color
(
color_name
)
background
=
color_name
.
to_s
=~
/on_/
color_name
=
color_name
.
to_s
.
sub
(
'on_'
,
''
)
return
unless
color_name
&&
COLORS
[
color_name
]
"
\e
[
#{
COLORS
[
color_name
]
+
(
background
?
10
:
0
)
}
m"
end
end
unless
Object
.
const_defined?
:Colored
String
.
send
(
:include
,
Colored
)
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录