Commit 0eadc218 authored by Fabio Pelosin's avatar Fabio Pelosin

[Dependency] indent fetching messages.

parent 7df2566a
......@@ -193,7 +193,7 @@ module Pod
class GitSource < AbstractExternalSource
def copy_external_source_into_sandbox(sandbox, platform)
puts "-> Pre-downloading: '#{name}'" unless config.silent?
UI.info("->".green + " Pre-downloading: '#{name}'") do
target = sandbox.root + name
target.rmtree if target.exist?
downloader = Downloader.for_target(sandbox.root + name, @params)
......@@ -203,6 +203,7 @@ module Pod
local_pod.downloaded = true
end
end
end
def description
"from `#{@params[:git]}'".tap do |description|
......@@ -216,11 +217,12 @@ module Pod
# can be http, file, etc
class PodspecSource < AbstractExternalSource
def copy_external_source_into_sandbox(sandbox, _)
puts "-> Fetching podspec for `#{name}' from: #{@params[:podspec]}" unless config.silent?
UI.info("->".green + " Fetching podspec for `#{name}' from: #{@params[:podspec]}") do
path = @params[:podspec]
path = Pathname.new(path).expand_path if path.start_with?("~")
open(path) { |io| store_podspec(sandbox, io.read) }
end
end
def description
"from `#{@params[:podspec]}'"
......
......@@ -4,9 +4,10 @@ module Pod
autoload :UIPod, 'cocoapods/user_interface/ui_pod'
@indentation_level = 0
@title_level = 0
@title_colors = %w|yellow green|
@title_level = 0
@indentation_level = 0
@treat_titles_as_messages = false
class << self
include Config::Mixin
......@@ -41,12 +42,16 @@ module Pod
# A title oposed to a section is always visible
#
def title(title, verbose_prefix = '', relative_indentation = 2)
if(@treat_titles_as_messages)
message(title, verbose_prefix)
else
title = verbose_prefix + title if config.verbose?
title = "\n#{title}" if @title_level < 2
if (color = @title_colors[@title_level])
title = title.send(color)
end
puts "#{title}"
end
self.indentation_level += relative_indentation
self.title_level += 1
......@@ -73,18 +78,22 @@ module Pod
self.indentation_level -= relative_indentation
end
# Prints a message unless config is silent.
# Prints an info to the user. The info is always displayed.
# It respects the current indentation level only in verbose
# mode.
#
def puts(message = '')
super(message) unless config.silent?
end
# Prints a message respecting the current indentation level and
# wrapping it to the termina width if necessary.
# Any title printed in the optional block is treated as a message.
#
def puts_indented(message = '')
indented = wrap_string(message, " " * self.indentation_level)
def info(message)
indentation = config.verbose? ? self.indentation_level : 0
indented = wrap_string(message, " " * indentation)
puts(indented)
self.indentation_level += 2
@treat_titles_as_messages = true
yield if block_given?
@treat_titles_as_messages = false
self.indentation_level -= 2
end
# Returns a string containing relative location of a path from the Podfile.
......@@ -141,8 +150,34 @@ module Pod
end
end
# Wraps a string with a given indent to the width of the terminal.
# adapted from http://blog.macromates.com/2006/wrapping-text-with-regular-expressions/
# @!group Basic printing
# Prints a message unless config is silent.
#
def puts(message = '')
super(message) unless config.silent?
end
# Prints a message respecting the current indentation level and
# wrapping it to the terminal width if necessary.
#
def puts_indented(message = '')
indented = wrap_string(message, " " * self.indentation_level)
puts(indented)
end
private
# @!group Helpers
# Wraps a string taking into account the width of the terminal and an
# option indent. Adapted from http://blog.macromates.com/2006/wrapping-text-with-regular-expressions/
#
# @param [String] txt The string to wrap
#
# @param [String] indent The string to use to indent the result.
#
# @return [String] The formatted string.
#
def wrap_string(txt, indent = '')
width = `stty size`.split(' ')[1].to_i - indent.length
......
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