Commit 6bedfe0b authored by Victor Ilyukevich's avatar Victor Ilyukevich

added subspecs into pod presenter [#164]

parent 17728443
......@@ -29,6 +29,7 @@ module Pod
result << detail('License', pod.license) if @stats
result << detail('Watchers', pod.github_watchers) if @stats
result << detail('Forks', pod.github_forks) if @stats
result << detail('Sub specs', pod.subspecs)
result
end
......@@ -40,12 +41,20 @@ module Pod
txt.strip.gsub(/(.{1,#{col}})( +|$)\n?|(.{#{col}})/, indent + "\\1\\3\n")
end
def detail(title, string, preferred_indentation = 8)
def detail(title, value, preferred_indentation = 8)
# 8 is the length of Homepage
return '' if !string
return '' if !value
number_of_spaces = ((preferred_indentation - title.length) > 0) ? (preferred_indentation - title.length) : 0
spaces = ' ' * number_of_spaces
" - #{title}: #{spaces + string}\n"
''.tap do |t|
t << " - #{title}:"
if value.class == Array
separator = "\n - "
t << separator + value.join(separator)
else
t << " #{spaces + value}\n"
end
end
end
end
end
......
......@@ -52,6 +52,11 @@ module Pod
spec.license[:type] if spec.license
end
# will return array of all subspecs (recursevly) or nil
def subspecs
(spec.recursive_subspecs.any? && spec.recursive_subspecs) || nil
end
# Statistics information
def creation_date
Pod::Specification::Statistics.instance.creation_date(@set)
......
......@@ -129,6 +129,22 @@ module Pod
end
attr_reader :subspecs
def recursive_subspecs
unless @recursive_subspecs
begin
mapper = lambda do |spec|
spec.subspecs.map do |subspec|
[subspec, *mapper.call(subspec)]
end.flatten
end
@recursive_subspecs = mapper.call self
rescue StandardError
@recursive_subspecs = []
end
end
@recursive_subspecs
end
### Attributes **with** multiple platform support
class PlatformProxy
......
......@@ -32,5 +32,11 @@ describe Pod::Command::Presenter do
output.should.include? 'Watchers: 318'
output.should.include? 'Forks: 42'
end
it "should print at least one subspec" do
presenter = Presenter.new(argv())
output = presenter.describe(Pod::Spec::Set.new(fixture('spec-repos/master/RestKit')))
output.should.include? "RestKit/Network"
end
end
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