Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[UI] General improvements.

  • Loading branch information...
commit 39528ee5dddc816b50f040d0a6b5678bf9de2409 1 parent 0eadc21
@fabiopelosin fabiopelosin authored
View
27 lib/cocoapods/downloader/git.rb
@@ -14,7 +14,7 @@ class Git < Downloader
def download
create_cache unless cache_exist?
- UI.section(' > Cloning git repo', '', 3) do
+ UI.section(' > Cloning git repo', '', 1) do
if options[:tag]
download_tag
elsif options[:branch]
@@ -30,7 +30,7 @@ def download
end
def create_cache
- UI.section " > Creating cache git repo (#{cache_path})"
+ UI.section(" > Creating cache git repo (#{cache_path})",'',1)
cache_path.rmtree if cache_path.exist?
cache_path.mkpath
git! %Q|clone --mirror "#{url}" "#{cache_path}"|
@@ -74,15 +74,16 @@ def caches_size
end
def update_cache
- UI.section " > Updating cache git repo (#{cache_path})"
- Dir.chdir(cache_path) do
- if git("config core.bare").chomp == "true"
- git! "remote update"
- else
- git! "reset --hard HEAD"
- git! "clean -d -x -f"
- git! "pull origin master"
- git! "fetch --tags"
+ UI.section(" > Updating cache git repo (#{cache_path})",'',1) do
+ Dir.chdir(cache_path) do
+ if git("config core.bare").chomp == "true"
+ git! "remote update"
+ else
+ git! "reset --hard HEAD"
+ git! "clean -d -x -f"
+ git! "pull origin master"
+ git! "fetch --tags"
+ end
end
end
end
@@ -152,7 +153,9 @@ def download_branch
end
def clone(from, to)
- git! %Q|clone "#{from}" "#{to}"|
+ UI.section(" > Cloning to Pods folder",'',1) do
+ git! %Q|clone "#{from}" "#{to}"|
+ end
end
end
View
2  lib/cocoapods/installer.rb
@@ -141,9 +141,9 @@ def install!
@lockfile = Lockfile.generate(@podfile, specs_by_target.values.flatten)
@lockfile.write_to_disk(config.project_lockfile)
end
+ end
UserProjectIntegrator.new(@podfile).integrate! if config.integrate_targets?
- end
end
def run_pre_install_hooks
View
41 lib/cocoapods/installer/user_project_integrator.rb
@@ -51,7 +51,7 @@ def create_workspace!
workspace << project_path unless workspace.include?(project_path)
end
unless workspace_path.exist? || config.silent?
- puts "[!] From now on use `#{workspace_path.basename}'."
+ UI.notice "From now on use `#{workspace_path.basename}'."
end
workspace.save_as(workspace_path)
end
@@ -69,20 +69,30 @@ def inspect
"#<#{self.class} for target `#{@target_definition.label}'>"
end
+ # Integrates the user project targets. Only the targets that do **not**
+ # already have the Pods library in their frameworks build phase are
+ # processed.
+ #
+ # @return [void]
+ #
def integrate!
return if targets.empty?
- unless Config.instance.silent?
- puts "-> Integrating `#{@target_definition.lib_name}' into #{'target'.pluralize(targets.size)} " \
- "`#{targets.map(&:name).to_sentence}' of Xcode project `#{user_project_path.basename}'.".green
+ UI.section ("Integrating `#{@target_definition.lib_name}' into #{'target'.pluralize(targets.size)} " \
+ "`#{targets.map(&:name).to_sentence}' of Xcode project #{UI.path user_project_path}.") do
+ add_xcconfig_base_configuration
+ add_pods_library
+ add_copy_resources_script_phase
+ user_project.save_as(@target_definition.user_project.path)
end
-
- add_xcconfig_base_configuration
- add_pods_library
- add_copy_resources_script_phase
- user_project.save_as(@target_definition.user_project.path)
end
+ # @return [Pathname] the path of the user project.
+ #
+ # @raises If the path doesn't exits.
+ #
+ # @raises If the project is implicit and there are multiple projects.
+ #
def user_project_path
if path = @target_definition.user_project.path
unless path.exist?
@@ -96,6 +106,8 @@ def user_project_path
end
end
+ # @return [Xcodeproj::Project] Returns the project of the user.
+ #
def user_project
@user_project ||= Xcodeproj::Project.new(user_project_path)
end
@@ -152,13 +164,10 @@ def add_xcconfig_base_configuration
config.base_configuration = xcconfig
end
- unless config.silent?
- config_build_names_by_overriden_key.each do |key, config_build_names|
- name = "#{target.attributes["name"]} [#{config_build_names.join(' - ')}]"
- puts "\n[!] The target `#{name}' overrides the `#{key}' build setting defined in `#{@target_definition.xcconfig_relative_path}'.".yellow
- puts " - Use the `$(inherited)' flag, or"
- puts " - Remove the build settings from the target."
- end
+ config_build_names_by_overriden_key.each do |key, config_build_names|
+ name = "#{target.attributes["name"]} [#{config_build_names.join(' - ')}]"
+ actions = [ "Use the `$(inherited)' flag, or", "Remove the build settings from the target." ]
+ UI.warn("The target `#{name}' overrides the `#{key}' build setting defined in `#{@target_definition.xcconfig_relative_path}'.", actions)
end
end
end
View
30 lib/cocoapods/user_interface.rb
@@ -6,7 +6,7 @@ class UserInterface
@title_colors = %w|yellow green|
@title_level = 0
- @indentation_level = 0
+ @indentation_level = 2
@treat_titles_as_messages = false
class << self
@@ -25,7 +25,7 @@ class << self
# TODO: refactor to title (for always visible titles like search)
# and sections (titles that reppresent collapsible sections).
#
- def section(title, verbose_prefix = '', relative_indentation = 2)
+ def section(title, verbose_prefix = '', relative_indentation = 0)
if config.verbose?
title(title, verbose_prefix, relative_indentation)
elsif title_level < 2
@@ -96,6 +96,32 @@ def info(message)
self.indentation_level -= 2
end
+ # Prints an important message to the user.
+ #
+ # @param [String] message The message to print.
+ #
+ # return [void]
+ #
+ def notice(message)
+ puts("\n[!] #{message}".green)
+ end
+
+ # Prints an important warning to the user optionally followed by actions
+ # that the user should take.
+ #
+ # @param [String] message The message to print.
+ # @param [Actions] actions The actions that the user should take.
+ #
+ # return [void]
+ #
+ def warn(message, actions)
+ puts("\n[!] #{message}".yellow)
+ actions.each do |action|
+ indented = wrap_string(action, " - ")
+ puts(indented)
+ end
+ end
+
# Returns a string containing relative location of a path from the Podfile.
# The returned path is quoted. If the argument is nit it returns the
# empty string.
Please sign in to comment.
Something went wrong with that request. Please try again.