Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
C
cocoapods
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gengmeiios
cocoapods
Commits
042790e9
Commit
042790e9
authored
Mar 22, 2012
by
Fabio Pelosin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Tweaks to regex and coloring
parent
9d87bf40
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
14 deletions
+5
-14
search.rb
lib/cocoapods/command/search.rb
+5
-14
No files found.
lib/cocoapods/command/search.rb
View file @
042790e9
...
@@ -23,22 +23,13 @@ module Pod
...
@@ -23,22 +23,13 @@ module Pod
end
end
end
end
def
colorize
(
text
,
color_code
)
"
\e
[
#{
color_code
}
m
#{
text
}
\e
[0m"
end
def
red
(
text
);
colorize
(
text
,
31
);
end
def
green
(
text
);
colorize
(
text
,
32
);
end
def
yellow
(
text
);
colorize
(
text
,
33
);
end
def
wrap_text
(
txt
,
col
=
80
)
def
wrap_text
(
txt
,
col
=
80
)
txt
.
gsub
(
/(.{1,
#{
col
}
})( +|$\n?)|(.{1,
#{
col
}
})/
,
txt
.
gsub
(
/(.{1,
#{
col
}
})( +|$\n?)|(.{1,
#{
col
}
})/
,
"
\\
1
\\
3
\n
"
)
"
\\
1
\\
3
\n
"
)
end
end
def
run
def
run
Source
.
search_by_name
(
@query
.
strip
,
@full_text_search
).
each
do
|
set
|
Source
.
search_by_name
(
@query
.
strip
,
@full_text_search
).
each
do
|
set
|
puts
green
(
"-->
#{
set
.
name
}
(
#{
set
.
versions
.
reverse
.
join
(
", "
)
}
)"
)
puts
"
\e
[32m-->
#{
set
.
name
}
(
#{
set
.
versions
.
reverse
.
join
(
", "
)
}
)
\e
[0m"
puts
"
#{
wrap_text
(
set
.
specification
.
summary
).
strip
}
"
puts
"
#{
wrap_text
(
set
.
specification
.
summary
).
strip
}
"
puts
" - Homepage:
#{
set
.
specification
.
homepage
}
"
puts
" - Homepage:
#{
set
.
specification
.
homepage
}
"
...
@@ -50,8 +41,8 @@ module Pod
...
@@ -50,8 +41,8 @@ module Pod
original_url
,
username
,
reponame
=
*
(
url
.
match
(
/[:\/](\w+)\/(\w+).git/
).
to_a
)
original_url
,
username
,
reponame
=
*
(
url
.
match
(
/[:\/](\w+)\/(\w+).git/
).
to_a
)
if
original_url
if
original_url
repo_info
=
`curl -s -m 2 http://github.com/api/v2/json/repos/show/
#{
username
}
/
#{
reponame
}
`
repo_info
=
`curl -s -m 2 http://github.com/api/v2/json/repos/show/
#{
username
}
/
#{
reponame
}
`
watchers
=
repo_info
.
match
(
/\"watchers\"
:
([0-9]+)/
).
to_a
[
1
]
watchers
=
repo_info
.
match
(
/\"watchers\"
\W*:\W*
([0-9]+)/
).
to_a
[
1
]
forks
=
repo_info
.
match
(
/\"forks\"
:
([0-9]+)/
).
to_a
[
1
]
forks
=
repo_info
.
match
(
/\"forks\"
\W*:\W*
([0-9]+)/
).
to_a
[
1
]
puts
" - Watchers: "
+
watchers
if
watchers
puts
" - Watchers: "
+
watchers
if
watchers
puts
" - Forks: "
+
forks
if
forks
puts
" - Forks: "
+
forks
if
forks
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment