Commit 5fb94da0 authored by Fabio Pelosin's avatar Fabio Pelosin

[#177] @alloy's suggestions

parent 9bb3e73e
...@@ -12,13 +12,13 @@ module Pod ...@@ -12,13 +12,13 @@ module Pod
end end
def self.options def self.options
" --extended Show details that require network access (like GitHub stats)\n" + " --stats Show additional stats (like GitHub watchers and forks)\n" +
" --full Search by name, summary, and description\n" " --full Search by name, summary, and description\n"
super super
end end
def initialize(argv) def initialize(argv)
@extended = argv.option('--extended') @stats = argv.option('--stats')
@full_text_search = argv.option('--full') @full_text_search = argv.option('--full')
unless @query = argv.arguments.first unless @query = argv.arguments.first
super super
...@@ -31,7 +31,9 @@ module Pod ...@@ -31,7 +31,9 @@ module Pod
puts_wrapped_text(set.specification.summary) puts_wrapped_text(set.specification.summary)
puts_detail('Homepage', set.specification.homepage) puts_detail('Homepage', set.specification.homepage)
print_extended_info(set.specification.source) if @extended source = set.specification.source.values[0]
puts_detail('Source', source)
puts_github_info(source) if @stats
puts puts
end end
...@@ -45,18 +47,13 @@ module Pod ...@@ -45,18 +47,13 @@ module Pod
def puts_detail(title,string) def puts_detail(title,string)
return if !string return if !string
# 8 is the length of homepage which might be displayed alone
number_of_spaces = ((8 - title.length) > 0) ? (8 - title.length) : 0 number_of_spaces = ((8 - title.length) > 0) ? (8 - title.length) : 0
spaces = ' ' * number_of_spaces spaces = ' ' * number_of_spaces
puts " - #{title}: #{spaces + string}" puts " - #{title}: #{spaces + string}"
end end
def print_extended_info(source) def puts_github_info(url)
source_url = source[:git] || source[:hg] || source[:svn] || source[:local]
puts_detail('Source', source_url)
print_github_info(source_url) if source_url =~ /github.com/
end
def print_github_info(url)
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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment