Skip to content

Commit

Permalink
Move the result helpers into the result file
Browse files Browse the repository at this point in the history
  • Loading branch information
joshkalpin committed Dec 7, 2013
1 parent fb4d69f commit b63f2e0
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 50 deletions.
50 changes: 0 additions & 50 deletions lib/cocoapods-core/specification/linter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -446,56 +446,6 @@ def frameworks_invalid?(frameworks)
def libraries_invalid?(libs)
libs.any? { |lib| lib.end_with?('.a', '.dylib') || lib.start_with?('lib') }
end

#-----------------------------------------------------------------------#

# !@group Result Helpers

private

# Adds an error result with the given message.
#
# @param [String] message
# The message of the result.
#
# @return [void]
#
def error(message)
add_result(:error, message)
end

# Adds an warning result with the given message.
#
# @param [String] message
# The message of the result.
#
# @return [void]
#
def warning(message)
add_result(:warning, message)
end

# Adds a result of the given type with the given message. If there is a
# current platform it is added to the result. If a result with the same
# type and the same message is already available the current platform is
# added to the existing result.
#
# @param [Symbol] type
# The type of the result (`:error`, `:warning`).
#
# @param [String] message
# The message of the result.
#
# @return [void]
#
def add_result(type, message)
result = results.find { |r| r.type == type && r.message == message }
unless result
result = Result.new(type, message)
results << result
end
result.platforms << consumer.platform_name if consumer
end
end
end
end
Expand Down
46 changes: 46 additions & 0 deletions lib/cocoapods-core/specification/linter/result.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,52 @@ def to_s
r
end
end

private

# Adds an error result with the given message.
#
# @param [String] message
# The message of the result.
#
# @return [void]
#
def error(message)
add_result(:error, message)
end

# Adds an warning result with the given message.
#
# @param [String] message
# The message of the result.
#
# @return [void]
#
def warning(message)
add_result(:warning, message)
end

# Adds a result of the given type with the given message. If there is a
# current platform it is added to the result. If a result with the same
# type and the same message is already available the current platform is
# added to the existing result.
#
# @param [Symbol] type
# The type of the result (`:error`, `:warning`).
#
# @param [String] message
# The message of the result.
#
# @return [void]
#
def add_result(type, message)
result = results.find { |r| r.type == type && r.message == message }
unless result
result = Result.new(type, message)
results << result
end
result.platforms << consumer.platform_name if consumer
end
end
end
end

0 comments on commit b63f2e0

Please sign in to comment.