Commit 2b4a2b0d authored by Fabio Pelosin's avatar Fabio Pelosin

[Style]

parent a19220a2
# This configuration was generated by `rubocop --auto-gen-config` # This configuration was generated by `rubocop --auto-gen-config`
# on 2014-08-20 23:30:36 +0200 using RuboCop version 0.25.0. # on 2014-08-22 22:27:57 +0200 using RuboCop version 0.25.0.
# The point is for the user to remove these configuration records # The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base. # one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new # Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again. # versions of RuboCop, may require this file to be generated again.
# Offense count: 1
Lint/AmbiguousOperator:
Enabled: false
# Offense count: 1
# Cop supports --auto-correct.
Lint/BlockAlignment:
Enabled: false
# Offense count: 2 # Offense count: 2
# Configuration parameters: AlignWith, SupportedStyles. # Configuration parameters: AlignWith, SupportedStyles.
Lint/DefEndAlignment: Lint/DefEndAlignment:
Enabled: false Enabled: false
# Offense count: 2 # Offense count: 10
# Cop supports --auto-correct.
Lint/DeprecatedClassMethods:
Enabled: false
# Offense count: 11
# Configuration parameters: AlignWith, SupportedStyles. # Configuration parameters: AlignWith, SupportedStyles.
Lint/EndAlignment: Lint/EndAlignment:
Enabled: false Enabled: false
# Offense count: 2
Lint/SpaceBeforeFirstArg:
Enabled: false
# Offense count: 1
# Cop supports --auto-correct.
Lint/UnusedMethodArgument:
Enabled: false
# Offense count: 3 # Offense count: 3
Lint/UselessAccessModifier: Lint/UselessAccessModifier:
Enabled: false Enabled: false
...@@ -53,18 +30,18 @@ Metrics/BlockNesting: ...@@ -53,18 +30,18 @@ Metrics/BlockNesting:
# Offense count: 11 # Offense count: 11
# Configuration parameters: CountComments. # Configuration parameters: CountComments.
Metrics/ClassLength: Metrics/ClassLength:
Max: 326 Max: 334
# Offense count: 12 # Offense count: 12
Metrics/CyclomaticComplexity: Metrics/CyclomaticComplexity:
Max: 9 Max: 9
# Offense count: 956 # Offense count: 961
# Configuration parameters: AllowURI. # Configuration parameters: AllowURI.
Metrics/LineLength: Metrics/LineLength:
Max: 1060 Max: 1060
# Offense count: 104 # Offense count: 106
# Configuration parameters: CountComments. # Configuration parameters: CountComments.
Metrics/MethodLength: Metrics/MethodLength:
Max: 39 Max: 39
...@@ -73,226 +50,69 @@ Metrics/MethodLength: ...@@ -73,226 +50,69 @@ Metrics/MethodLength:
Metrics/PerceivedComplexity: Metrics/PerceivedComplexity:
Max: 10 Max: 10
# Offense count: 2
# Cop supports --auto-correct.
Style/Alias:
Enabled: false
# Offense count: 3
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
Style/AndOr:
Enabled: false
# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
Style/BarePercentLiterals:
Enabled: false
# Offense count: 11
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
Style/BracesAroundHashParameters:
Enabled: false
# Offense count: 1
# Configuration parameters: EnforcedStyle, SupportedStyles.
Style/ClassAndModuleChildren:
Enabled: false
# Offense count: 3
# Cop supports --auto-correct.
# Configuration parameters: PreferredMethods.
Style/CollectionMethods:
Enabled: false
# Offense count: 7 # Offense count: 7
# Configuration parameters: Keywords. # Configuration parameters: Keywords.
Style/CommentAnnotation: Style/CommentAnnotation:
Enabled: false Enabled: false
# Offense count: 1
# Cop supports --auto-correct.
Style/CommentIndentation:
Enabled: false
# Offense count: 1 # Offense count: 1
Style/DoubleNegation: Style/DoubleNegation:
Enabled: false Enabled: false
# Offense count: 5
# Cop supports --auto-correct.
Style/EmptyLines:
Enabled: false
# Offense count: 17
# Cop supports --auto-correct.
Style/EmptyLinesAroundBody:
Enabled: false
# Offense count: 1 # Offense count: 1
# Configuration parameters: Exclude. # Configuration parameters: Exclude.
Style/FileName: Style/FileName:
Enabled: false Enabled: false
# Offense count: 1
# Configuration parameters: EnforcedStyle, SupportedStyles.
Style/For:
Enabled: false
# Offense count: 6 # Offense count: 6
# Configuration parameters: AllowedVariables. # Configuration parameters: AllowedVariables.
Style/GlobalVars: Style/GlobalVars:
Enabled: false Enabled: false
# Offense count: 5
# Cop supports --auto-correct.
Style/IndentArray:
Enabled: false
# Offense count: 1
# Cop supports --auto-correct.
Style/IndentationConsistency:
Enabled: false
# Offense count: 6
# Cop supports --auto-correct.
Style/IndentationWidth:
Enabled: false
# Offense count: 1 # Offense count: 1
# Cop supports --auto-correct. # Cop supports --auto-correct.
Style/MethodCallParentheses:
Enabled: false
# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
Style/MethodDefParentheses:
Enabled: false
# Offense count: 1
Style/MultilineIfThen:
Enabled: false
# Offense count: 1
Style/MultilineTernaryOperator:
Enabled: false
# Offense count: 1
# Cop supports --auto-correct.
Style/NegatedWhile:
Enabled: false
# Offense count: 1
# Cop supports --auto-correct.
Style/Not:
Enabled: false
# Offense count: 10
# Cop supports --auto-correct.
# Configuration parameters: PreferredDelimiters. # Configuration parameters: PreferredDelimiters.
Style/PercentLiteralDelimiters: Style/PercentLiteralDelimiters:
Enabled: false Enabled: false
# Offense count: 4
# Cop supports --auto-correct.
# Configuration parameters: AllowMultipleReturnValues.
Style/RedundantReturn:
Enabled: false
# Offense count: 1
# Cop supports --auto-correct.
Style/RedundantSelf:
Enabled: false
# Offense count: 12 # Offense count: 12
# Configuration parameters: MaxSlashes. # Configuration parameters: MaxSlashes.
Style/RegexpLiteral: Style/RegexpLiteral:
Enabled: false Enabled: false
# Offense count: 3
Style/SelfAssignment:
Enabled: false
# Offense count: 6
# Cop supports --auto-correct.
Style/SingleSpaceBeforeFirstArg:
Enabled: false
# Offense count: 3
# Cop supports --auto-correct.
Style/SpaceAfterComma:
Enabled: false
# Offense count: 1 # Offense count: 1
# Cop supports --auto-correct. Style/SelfAssignment:
Style/SpaceAfterControlKeyword:
Enabled: false
# Offense count: 6
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
Style/SpaceBeforeBlockBraces:
Enabled: false
# Offense count: 11
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles, EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters.
Style/SpaceInsideBlockBraces:
Enabled: false
# Offense count: 4
# Cop supports --auto-correct.
Style/SpaceInsideBrackets:
Enabled: false Enabled: false
# Offense count: 34 # Offense count: 28
# Cop supports --auto-correct. # Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces, SupportedStyles. # Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces, SupportedStyles.
Style/SpaceInsideHashLiteralBraces: Style/SpaceInsideHashLiteralBraces:
Enabled: false Enabled: false
# Offense count: 1 # Offense count: 49
# Cop supports --auto-correct.
Style/SpaceInsideParens:
Enabled: false
# Offense count: 160
# Cop supports --auto-correct. # Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles. # Configuration parameters: EnforcedStyle, SupportedStyles.
Style/StringLiterals: Style/StringLiterals:
Enabled: false Enabled: false
# Offense count: 3 # Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
Style/TrailingBlankLines:
Enabled: false
# Offense count: 9
# Cop supports --auto-correct. # Cop supports --auto-correct.
# Configuration parameters: EnforcedStyleForMultiline, SupportedStyles. # Configuration parameters: EnforcedStyleForMultiline, SupportedStyles.
Style/TrailingComma: Style/TrailingComma:
Enabled: false Enabled: false
# Offense count: 22 # Offense count: 17
# Cop supports --auto-correct. # Cop supports --auto-correct.
Style/TrailingWhitespace: Style/TrailingWhitespace:
Enabled: false Enabled: false
# Offense count: 4 # Offense count: 1
# Cop supports --auto-correct. # Cop supports --auto-correct.
# Configuration parameters: ExactNameMatch, AllowPredicates, AllowDSLWriters, Whitelist. # Configuration parameters: ExactNameMatch, AllowPredicates, AllowDSLWriters, Whitelist.
Style/TrivialAccessors: Style/TrivialAccessors:
Enabled: false Enabled: false
# Offense count: 1
# Configuration parameters: EnforcedStyle, SupportedStyles.
Style/VariableName:
Enabled: false
# Offense count: 1 # Offense count: 1
# Cop supports --auto-correct. # Cop supports --auto-correct.
Style/WordArray: Style/WordArray:
......
...@@ -59,7 +59,8 @@ module Pod ...@@ -59,7 +59,8 @@ module Pod
# Uncomment this line to define a global platform for your project # Uncomment this line to define a global platform for your project
# platform :ios, "6.0" # platform :ios, "6.0"
PLATFORM PLATFORM
for target in project.targets
project.targets.each do |target|
podfile << target_module(target) podfile << target_module(target)
end end
podfile << "\n" podfile << "\n"
......
...@@ -18,7 +18,7 @@ module Pod ...@@ -18,7 +18,7 @@ module Pod
self.arguments = [ self.arguments = [
CLAide::Argument.new('NAME', true), CLAide::Argument.new('NAME', true),
CLAide::Argument.new('TEMPLATE_URL', false) CLAide::Argument.new('TEMPLATE_URL', false),
] ]
def initialize(argv) def initialize(argv)
...@@ -29,8 +29,8 @@ module Pod ...@@ -29,8 +29,8 @@ module Pod
def validate! def validate!
super super
help! "A name for the Pod is required." unless @name help! 'A name for the Pod is required.' unless @name
help! "The Pod name cannot contain spaces." if @name.match(/\s/) help! 'The Pod name cannot contain spaces.' if @name.match(/\s/)
help! "The Pod name cannot begin with a '.'" if @name[0, 1] == '.' help! "The Pod name cannot begin with a '.'" if @name[0, 1] == '.'
end end
...@@ -50,9 +50,9 @@ module Pod ...@@ -50,9 +50,9 @@ module Pod
executable :git executable :git
executable :ruby executable :ruby
TEMPLATE_REPO = "https://github.com/CocoaPods/pod-template.git" TEMPLATE_REPO = 'https://github.com/CocoaPods/pod-template.git'
TEMPLATE_INFO_URL = "https://github.com/CocoaPods/pod-template" TEMPLATE_INFO_URL = 'https://github.com/CocoaPods/pod-template'
CREATE_NEW_POD_INFO_URL = "http://guides.cocoapods.org/making/making-a-cocoapod" CREATE_NEW_POD_INFO_URL = 'http://guides.cocoapods.org/making/making-a-cocoapod'
# Clones the template from the remote in the working directory using # Clones the template from the remote in the working directory using
# the name of the Pod. # the name of the Pod.
...@@ -61,7 +61,7 @@ module Pod ...@@ -61,7 +61,7 @@ module Pod
# #
def clone_template def clone_template
UI.section("Cloning `#{template_repo_url}` into `#{@name}`.") do UI.section("Cloning `#{template_repo_url}` into `#{@name}`.") do
git!"clone '#{template_repo_url}' #{@name}" git! "clone '#{template_repo_url}' #{@name}"
end end
end end
...@@ -72,10 +72,10 @@ module Pod ...@@ -72,10 +72,10 @@ module Pod
def configure_template def configure_template
UI.section("Configuring #{@name} template.") do UI.section("Configuring #{@name} template.") do
Dir.chdir(@name) do Dir.chdir(@name) do
if File.exists? "configure" if File.exist?('configure')
system "./configure #{@name}" system("./configure #{@name}")
else else
UI.warn "Template does not have a configure file." UI.warn 'Template does not have a configure file.'
end end
end end
end end
...@@ -109,11 +109,11 @@ module Pod ...@@ -109,11 +109,11 @@ module Pod
DESC DESC
def self.options def self.options
[ ["--quick", "Lint skips checks that would require to download and build the spec"], [['--quick', 'Lint skips checks that would require to download and build the spec'],
["--only-errors", "Lint validates even if warnings are present"], ['--only-errors', 'Lint validates even if warnings are present'],
["--subspec=NAME","Lint validates only the given subspec"], ['--subspec=NAME', 'Lint validates only the given subspec'],
["--no-subspecs", "Lint skips validation of subspecs"], ['--no-subspecs', 'Lint skips validation of subspecs'],
["--no-clean", "Lint leaves the build directory intact for inspection"] ].concat(super) ['--no-clean', 'Lint leaves the build directory intact for inspection']].concat(super)
end end
def initialize(argv) def initialize(argv)
...@@ -153,7 +153,7 @@ module Pod ...@@ -153,7 +153,7 @@ module Pod
message = "#{validator.spec.name} did not pass validation." message = "#{validator.spec.name} did not pass validation."
if @clean if @clean
message << "\nYou can use the `--no-clean` option to inspect " \ message << "\nYou can use the `--no-clean` option to inspect " \
"any issue." 'any issue.'
end end
raise Informative, message raise Informative, message
end end
...@@ -173,19 +173,20 @@ module Pod ...@@ -173,19 +173,20 @@ module Pod
# @raise If multiple podspecs are found. # @raise If multiple podspecs are found.
# #
def podspecs_to_lint def podspecs_to_lint
if !@podspecs_paths.empty? then if !@podspecs_paths.empty?
Array(@podspecs_paths) Array(@podspecs_paths)
else else
podspecs = Pathname.glob(Pathname.pwd + '*.podspec{.yaml,}') podspecs = Pathname.glob(Pathname.pwd + '*.podspec{.yaml,}')
raise Informative, "Unable to find a podspec in the working directory" if podspecs.count.zero? if podspecs.count.zero?
raise Informative, 'Unable to find a podspec in the working ' \
'directory'
end
podspecs podspecs
end end
end end
end end
#-----------------------------------------------------------------------# #-----------------------------------------------------------------------#
end end
end end
end end
...@@ -75,7 +75,8 @@ module Pod ...@@ -75,7 +75,8 @@ module Pod
class Update < Command class Update < Command
include Project include Project
self.summary = 'Update outdated project dependencies and create new Podfile.lock' self.summary = 'Update outdated project dependencies and create new ' \
'Podfile.lock'
self.description = <<-DESC self.description = <<-DESC
Updates the Pods identified by the specified `POD_NAMES`. If no Updates the Pods identified by the specified `POD_NAMES`. If no
...@@ -101,12 +102,19 @@ module Pod ...@@ -101,12 +102,19 @@ module Pod
verify_lockfile_exists! verify_lockfile_exists!
# Check if all given pods are installed # Check if all given pods are installed
missing_pods = @pods.select { |pod| !config.lockfile.pod_names.include?(pod) } missing_pods = @pods.select do |pod|
!config.lockfile.pod_names.include?(pod)
end
if missing_pods.length > 0 if missing_pods.length > 0
raise Informative, (missing_pods.length > 1 \ if missing_pods.length > 1
? 'Pods %s are not installed and cannot be updated' \ message = "Pods `#{missing_pods.join('`, `')}` are not " \
: 'Pod %s is not installed and cannot be updated' 'installed and cannot be updated'
) % missing_pods.map { |p| "`#{p}`" }.join(', ') else
message = "The `#{missing_pods.first}` Pod is not installed " \
'and cannot be updated'
end
raise Informative, message
end end
run_install_with_update(:pods => @pods) run_install_with_update(:pods => @pods)
......
...@@ -51,16 +51,17 @@ module Pod ...@@ -51,16 +51,17 @@ module Pod
# @!group Setup steps # @!group Setup steps
# Migrates any repos from the old directory structure to the new directory # Migrates any repos from the old directory structure to the new
# structure. # directory structure.
#
# @todo: Remove by 1.0
# #
# @return [void]
def migrate_repos def migrate_repos
config.repos_dir.mkpath config.repos_dir.mkpath
Dir.foreach old_master_repo_dir.parent do |repo_dir| Dir.foreach old_master_repo_dir.parent do |repo_dir|
source_repo_dir = old_master_repo_dir.parent + repo_dir source_repo_dir = old_master_repo_dir.parent + repo_dir
target_repo_dir = config.repos_dir + repo_dir target_repo_dir = config.repos_dir + repo_dir
if not repo_dir =~ /\.+/ and source_repo_dir != config.repos_dir if repo_dir !~ /\.+/ && source_repo_dir != config.repos_dir
FileUtils.mv source_repo_dir, target_repo_dir FileUtils.mv source_repo_dir, target_repo_dir
end end
end end
......
This diff is collapsed.
module Pod module Pod
# Stores the global configuration of CocoaPods. # Stores the global configuration of CocoaPods.
# #
class Config class Config
# The default settings for the configuration. # The default settings for the configuration.
# #
# Users can specify custom settings in `~/.cocoapods/config.yaml`. # Users can specify custom settings in `~/.cocoapods/config.yaml`.
...@@ -63,7 +61,6 @@ module Pod ...@@ -63,7 +61,6 @@ module Pod
attr_accessor :integrate_targets attr_accessor :integrate_targets
alias_method :integrate_targets?, :integrate_targets alias_method :integrate_targets?, :integrate_targets
# @return [Bool] Whether the installer should skip the repos update. # @return [Bool] Whether the installer should skip the repos update.
# #
attr_accessor :skip_repo_update attr_accessor :skip_repo_update
...@@ -115,13 +112,13 @@ module Pod ...@@ -115,13 +112,13 @@ module Pod
# files are stored. # files are stored.
# #
def home_dir def home_dir
@home_dir ||= Pathname.new(ENV['CP_HOME_DIR'] || "~/.cocoapods").expand_path @home_dir ||= Pathname.new(ENV['CP_HOME_DIR'] || '~/.cocoapods').expand_path
end end
# @return [Pathname] the directory where the CocoaPods sources are stored. # @return [Pathname] the directory where the CocoaPods sources are stored.
# #
def repos_dir def repos_dir
@repos_dir ||= Pathname.new(ENV['CP_REPOS_DIR'] || "~/.cocoapods/repos").expand_path @repos_dir ||= Pathname.new(ENV['CP_REPOS_DIR'] || '~/.cocoapods/repos').expand_path
end end
attr_writer :repos_dir attr_writer :repos_dir
...@@ -129,7 +126,7 @@ module Pod ...@@ -129,7 +126,7 @@ module Pod
# @return [Pathname] the directory where the CocoaPods templates are stored. # @return [Pathname] the directory where the CocoaPods templates are stored.
# #
def templates_dir def templates_dir
@templates_dir ||= Pathname.new(ENV['CP_TEMPLATES_DIR'] || "~/.cocoapods/templates").expand_path @templates_dir ||= Pathname.new(ENV['CP_TEMPLATES_DIR'] || '~/.cocoapods/templates').expand_path
end end
# @return [Pathname] the root of the CocoaPods installation where the # @return [Pathname] the root of the CocoaPods installation where the
...@@ -138,7 +135,7 @@ module Pod ...@@ -138,7 +135,7 @@ module Pod
def installation_root def installation_root
current_path = Pathname.pwd current_path = Pathname.pwd
unless @installation_root unless @installation_root
while(!current_path.root?) until current_path.root?
if podfile_path_in_dir(current_path) if podfile_path_in_dir(current_path)
@installation_root = current_path @installation_root = current_path
unless current_path == Pathname.pwd unless current_path == Pathname.pwd
...@@ -155,7 +152,7 @@ module Pod ...@@ -155,7 +152,7 @@ module Pod
end end
attr_writer :installation_root attr_writer :installation_root
alias :project_root :installation_root alias_method :project_root, :installation_root
# @return [Pathname] The root of the sandbox. # @return [Pathname] The root of the sandbox.
# #
...@@ -164,7 +161,7 @@ module Pod ...@@ -164,7 +161,7 @@ module Pod
end end
attr_writer :sandbox_root attr_writer :sandbox_root
alias :project_pods_root :sandbox_root alias_method :project_pods_root, :sandbox_root
# @return [Sandbox] The sandbox of the current project. # @return [Sandbox] The sandbox of the current project.
# #
...@@ -215,7 +212,7 @@ module Pod ...@@ -215,7 +212,7 @@ module Pod
# @return [Pathname] # @return [Pathname]
# #
def default_podfile_path def default_podfile_path
@default_podfile_path ||= templates_dir + "Podfile.default" @default_podfile_path ||= templates_dir + 'Podfile.default'
end end
# Returns the path of the default Podfile test pods. # Returns the path of the default Podfile test pods.
...@@ -225,7 +222,7 @@ module Pod ...@@ -225,7 +222,7 @@ module Pod
# @return [Pathname] # @return [Pathname]
# #
def default_test_podfile_path def default_test_podfile_path
@default_test_podfile_path ||= templates_dir + "Podfile.test" @default_test_podfile_path ||= templates_dir + 'Podfile.test'
end end
# @return [Pathname] The file to use a cache of the statistics provider. # @return [Pathname] The file to use a cache of the statistics provider.
...@@ -262,7 +259,7 @@ module Pod ...@@ -262,7 +259,7 @@ module Pod
# @return [Pathname] The path of the file which contains the user settings. # @return [Pathname] The path of the file which contains the user settings.
# #
def user_settings_file def user_settings_file
home_dir + "config.yaml" home_dir + 'config.yaml'
end end
# Sets the values of the attributes with the given hash. # Sets the values of the attributes with the given hash.
...@@ -275,7 +272,7 @@ module Pod ...@@ -275,7 +272,7 @@ module Pod
def configure_with(values_by_key) def configure_with(values_by_key)
return unless values_by_key return unless values_by_key
values_by_key.each do |key, value| values_by_key.each do |key, value|
self.instance_variable_set("@#{key}", value) instance_variable_set("@#{key}", value)
end end
end end
...@@ -327,8 +324,8 @@ module Pod ...@@ -327,8 +324,8 @@ module Pod
# #
# @return [void] # @return [void]
# #
def self.instance=(instance) class << self
@instance = instance attr_writer :instance
end end
# Provides support for accessing the configuration instance in other # Provides support for accessing the configuration instance in other
......
...@@ -15,7 +15,7 @@ module Pod ...@@ -15,7 +15,7 @@ module Pod
end end
def save_as(pathname) def save_as(pathname)
gen_bridge_metadata %{-c "#{search_paths.join(' ')}" -o '#{pathname}' '#{headers.join("' '")}'} gen_bridge_metadata %(-c "#{search_paths.join(' ')}" -o '#{pathname}' '#{headers.join("' '")}')
end end
end end
end end
......
module Pod module Pod
module Generator module Generator
class CopyResourcesScript class CopyResourcesScript
# @return [Array<#to_s>] A list of files relative to the project pods # @return [Array<#to_s>] A list of files relative to the project pods
# root. # root.
# #
...@@ -44,7 +43,7 @@ module Pod ...@@ -44,7 +43,7 @@ module Pod
# #
EXTERNAL_STRINGS_FILE_MIMINUM_DEPLOYMENT_TARGET = { EXTERNAL_STRINGS_FILE_MIMINUM_DEPLOYMENT_TARGET = {
:ios => Version.new('6.0'), :ios => Version.new('6.0'),
:osx => Version.new('10.8') :osx => Version.new('10.8'),
} }
# @return [Bool] Whether the external strings file is supported by the # @return [Bool] Whether the external strings file is supported by the
...@@ -70,14 +69,13 @@ module Pod ...@@ -70,14 +69,13 @@ module Pod
def script def script
script = install_resources_function script = install_resources_function
resources.each do |resource| resources.each do |resource|
script += %Q[install_resource "#{resource}"\n] script += %( install_resource "#{resource}"\n )
end end
script += RSYNC_CALL script += RSYNC_CALL
script += XCASSETS_COMPILE script += XCASSETS_COMPILE
script script
end end
INSTALL_RESOURCES_FUCTION = <<EOS INSTALL_RESOURCES_FUCTION = <<EOS
#!/bin/sh #!/bin/sh
set -e set -e
...@@ -124,7 +122,6 @@ install_resource() ...@@ -124,7 +122,6 @@ install_resource()
} }
EOS EOS
RSYNC_CALL = <<EOS RSYNC_CALL = <<EOS
rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"
...@@ -134,7 +131,6 @@ fi ...@@ -134,7 +131,6 @@ fi
rm -f "$RESOURCES_TO_COPY" rm -f "$RESOURCES_TO_COPY"
EOS EOS
XCASSETS_COMPILE = <<EOS XCASSETS_COMPILE = <<EOS
if [[ -n "${WRAPPER_EXTENSION}" ]] && [ `xcrun --find actool` ] && [ `find . -name '*.xcassets' | wc -l` -ne 0 ] if [[ -n "${WRAPPER_EXTENSION}" ]] && [ `xcrun --find actool` ] && [ `find . -name '*.xcassets' | wc -l` -ne 0 ]
......
module Pod module Pod
module Generator module Generator
# Generates a prefix header file for a Pods library. The prefix header is # Generates a prefix header file for a Pods library. The prefix header is
# generated according to the platform of the target and the pods. # generated according to the platform of the target and the pods.
# #
...@@ -8,7 +7,6 @@ module Pod ...@@ -8,7 +7,6 @@ module Pod
# `Cocoa/Cocoa.h`. # `Cocoa/Cocoa.h`.
# #
class PrefixHeader class PrefixHeader
# @return [Array<FileAccessor>] The file accessors for which to generate # @return [Array<FileAccessor>] The file accessors for which to generate
# the prefix header. # the prefix header.
# #
...@@ -55,10 +53,10 @@ module Pod ...@@ -55,10 +53,10 @@ module Pod
result << "#endif\n" result << "#endif\n"
imports.each do |import| imports.each do |import|
result << %|\n#import "#{import}"| result << %(\n#import "#{import}")
end end
unique_prefix_header_contents = file_accessors.collect do |file_accessor| unique_prefix_header_contents = file_accessors.map do |file_accessor|
file_accessor.spec_consumer.prefix_header_contents file_accessor.spec_consumer.prefix_header_contents
end.compact.uniq end.compact.uniq
...@@ -87,7 +85,6 @@ module Pod ...@@ -87,7 +85,6 @@ module Pod
def save_as(path) def save_as(path)
path.open('w') { |header| header.write(generate) } path.open('w') { |header| header.write(generate) }
end end
end end
end end
end end
...@@ -53,7 +53,7 @@ module Pod ...@@ -53,7 +53,7 @@ module Pod
'HEADER_SEARCH_PATHS' => XCConfigHelper.quote(target.sandbox.public_headers.search_paths), 'HEADER_SEARCH_PATHS' => XCConfigHelper.quote(target.sandbox.public_headers.search_paths),
'PODS_ROOT' => target.relative_pods_root, 'PODS_ROOT' => target.relative_pods_root,
'GCC_PREPROCESSOR_DEFINITIONS' => '$(inherited) COCOAPODS=1', 'GCC_PREPROCESSOR_DEFINITIONS' => '$(inherited) COCOAPODS=1',
'OTHER_CFLAGS' => '$(inherited) ' + XCConfigHelper.quote(header_search_path_flags, '-isystem') 'OTHER_CFLAGS' => '$(inherited) ' + XCConfigHelper.quote(header_search_path_flags, '-isystem'),
) )
target.pod_targets.each do |pod_target| target.pod_targets.each do |pod_target|
......
module Pod module Pod
# @todo: Remove by CocoaPods 1.0
#
class Podfile class Podfile
def config def config
UI.warn 'Podfile#config is deprecated. The config is accessible from ' \ UI.warn 'Podfile#config is deprecated. The config is accessible from ' \
'the parameter passed to the hooks' 'the parameter passed to the hooks'
Config.instance Config.instance
end end
end
class Podfile::TargetDefinition class TargetDefinition
def copy_resources_script_name def copy_resources_script_name
UI.warn 'TargetDefinition#copy_resources_script_name is deprecated. ' \ UI.warn 'TargetDefinition#copy_resources_script_name is deprecated. ' \
'The value is accessible directly from the representation of the ' \ 'The value is accessible directly from the representation of the ' \
...@@ -15,6 +16,7 @@ module Pod ...@@ -15,6 +16,7 @@ module Pod
Config.instance.sandbox.root + "#{label}-resources.sh" Config.instance.sandbox.root + "#{label}-resources.sh"
end end
end end
end
module Hooks module Hooks
# The installer representation to pass to the hooks. # The installer representation to pass to the hooks.
......
...@@ -28,7 +28,6 @@ module Pod ...@@ -28,7 +28,6 @@ module Pod
# source control. # source control.
# #
class Installer class Installer
autoload :AggregateTargetInstaller, 'cocoapods/installer/target_installer/aggregate_target_installer' autoload :AggregateTargetInstaller, 'cocoapods/installer/target_installer/aggregate_target_installer'
autoload :Analyzer, 'cocoapods/installer/analyzer' autoload :Analyzer, 'cocoapods/installer/analyzer'
autoload :FileReferencesInstaller, 'cocoapods/installer/file_references_installer' autoload :FileReferencesInstaller, 'cocoapods/installer/file_references_installer'
...@@ -96,7 +95,7 @@ module Pod ...@@ -96,7 +95,7 @@ module Pod
end end
def prepare def prepare
UI.section "Preparing" do UI.section 'Preparing' do
sandbox.prepare sandbox.prepare
Migrator.migrate(sandbox) Migrator.migrate(sandbox)
end end
...@@ -403,7 +402,7 @@ module Pod ...@@ -403,7 +402,7 @@ module Pod
# @return [void] # @return [void]
# #
def install_libraries def install_libraries
UI.message'- Installing libraries' do UI.message '- Installing libraries' do
pod_targets.sort_by(&:name).each do |pod_target| pod_targets.sort_by(&:name).each do |pod_target|
next if pod_target.target_definition.empty? next if pod_target.target_definition.empty?
target_installer = PodTargetInstaller.new(sandbox, pod_target) target_installer = PodTargetInstaller.new(sandbox, pod_target)
......
...@@ -183,7 +183,7 @@ module Pod ...@@ -183,7 +183,7 @@ module Pod
def header_mappings(headers_sandbox, file_accessor, headers) def header_mappings(headers_sandbox, file_accessor, headers)
consumer = file_accessor.spec_consumer consumer = file_accessor.spec_consumer
dir = headers_sandbox dir = headers_sandbox
dir = dir + consumer.header_dir if consumer.header_dir dir += consumer.header_dir if consumer.header_dir
mappings = {} mappings = {}
headers.each do |header| headers.each do |header|
...@@ -191,7 +191,7 @@ module Pod ...@@ -191,7 +191,7 @@ module Pod
if consumer.header_mappings_dir if consumer.header_mappings_dir
header_mappings_dir = file_accessor.path_list.root + consumer.header_mappings_dir header_mappings_dir = file_accessor.path_list.root + consumer.header_mappings_dir
relative_path = header.relative_path_from(header_mappings_dir) relative_path = header.relative_path_from(header_mappings_dir)
sub_dir = sub_dir + relative_path.dirname sub_dir += relative_path.dirname
end end
mappings[sub_dir] ||= [] mappings[sub_dir] ||= []
mappings[sub_dir] << header mappings[sub_dir] << header
......
...@@ -21,8 +21,8 @@ module Pod ...@@ -21,8 +21,8 @@ module Pod
# Migrates from CocoaPods versions previous to 0.34. # Migrates from CocoaPods versions previous to 0.34.
# #
def migrate_to_0_34(sandbox) def migrate_to_0_34(sandbox)
title_options = { :verbose_prefix => "-> ".green } title_options = { :verbose_prefix => '-> '.green }
UI.titled_section("Migrating to CocoaPods 0.34".green, title_options) do UI.titled_section('Migrating to CocoaPods 0.34'.green, title_options) do
delete(sandbox.root + 'Headers') delete(sandbox.root + 'Headers')
make_path(sandbox.headers_root) make_path(sandbox.headers_root)
......
module Pod module Pod
class Installer class Installer
# Controller class responsible of creating and configuring the static # Controller class responsible of creating and configuring the static
# library target in Pods project. It also creates the support file needed # library target in Pods project. It also creates the support file needed
# by the target. # by the target.
# #
class TargetInstaller class TargetInstaller
# @return [Sandbox] sandbox the sandbox where the support files should # @return [Sandbox] sandbox the sandbox where the support files should
# be generated. # be generated.
# #
...@@ -47,7 +45,6 @@ module Pod ...@@ -47,7 +45,6 @@ module Pod
configuration = @target.add_build_configuration(bc_name, type) configuration = @target.add_build_configuration(bc_name, type)
end end
settings = {} settings = {}
if library.archs if library.archs
settings['ARCHS'] = library.archs settings['ARCHS'] = library.archs
...@@ -126,8 +123,6 @@ module Pod ...@@ -126,8 +123,6 @@ module Pod
end end
#-----------------------------------------------------------------------# #-----------------------------------------------------------------------#
end end
end end
end end
module Pod module Pod
class Installer class Installer
# Creates the targets which aggregate the Pods libraries in the Pods # Creates the targets which aggregate the Pods libraries in the Pods
# project and the relative support files. # project and the relative support files.
# #
class AggregateTargetInstaller < TargetInstaller class AggregateTargetInstaller < TargetInstaller
# Creates the target in the Pods project and the relative support files. # Creates the target in the Pods project and the relative support files.
# #
# @return [void] # @return [void]
...@@ -89,8 +87,8 @@ module Pod ...@@ -89,8 +87,8 @@ module Pod
path = library.copy_resources_script_path path = library.copy_resources_script_path
UI.message "- Generating copy resources script at #{UI.path(path)}" do UI.message "- Generating copy resources script at #{UI.path(path)}" do
file_accessors = library.pod_targets.map(&:file_accessors).flatten file_accessors = library.pod_targets.map(&:file_accessors).flatten
resource_paths = file_accessors.map { |accessor| accessor.resources.flatten.map { |res| res.relative_path_from(project.path.dirname) }}.flatten resource_paths = file_accessors.map { |accessor| accessor.resources.flatten.map { |res| res.relative_path_from(project.path.dirname) } }.flatten
resource_bundles = file_accessors.map { |accessor| accessor.resource_bundles.keys.map {|name| "${BUILT_PRODUCTS_DIR}/#{name}.bundle" } }.flatten resource_bundles = file_accessors.map { |accessor| accessor.resource_bundles.keys.map { |name| "${BUILT_PRODUCTS_DIR}/#{name}.bundle" } }.flatten
resources = [] resources = []
resources.concat(resource_paths) resources.concat(resource_paths)
resources.concat(resource_bundles) resources.concat(resource_bundles)
...@@ -126,7 +124,6 @@ module Pod ...@@ -126,7 +124,6 @@ module Pod
attr_reader :bridge_support_file attr_reader :bridge_support_file
#-----------------------------------------------------------------------# #-----------------------------------------------------------------------#
end end
end end
end end
module Pod module Pod
class Installer class Installer
# Creates the target for the Pods libraries in the Pods project and the # Creates the target for the Pods libraries in the Pods project and the
# relative support files. # relative support files.
# #
class PodTargetInstaller < TargetInstaller class PodTargetInstaller < TargetInstaller
# Creates the target in the Pods project and the relative support files. # Creates the target in the Pods project and the relative support files.
# #
# @return [void] # @return [void]
...@@ -34,12 +32,12 @@ module Pod ...@@ -34,12 +32,12 @@ module Pod
# @return [void] # @return [void]
# #
def add_files_to_build_phases def add_files_to_build_phases
UI.message "- Adding Build files" do UI.message '- Adding Build files' do
library.file_accessors.each do |file_accessor| library.file_accessors.each do |file_accessor|
consumer = file_accessor.spec_consumer consumer = file_accessor.spec_consumer
flags = compiler_flags_for_consumer(consumer) flags = compiler_flags_for_consumer(consumer)
all_source_files = file_accessor.source_files all_source_files = file_accessor.source_files
regular_source_files = all_source_files.reject { |sf| sf.extname == ".d" } regular_source_files = all_source_files.reject { |sf| sf.extname == '.d' }
regular_file_refs = regular_source_files.map { |sf| project.reference_for_path(sf) } regular_file_refs = regular_source_files.map { |sf| project.reference_for_path(sf) }
target.add_file_references(regular_file_refs, flags) target.add_file_references(regular_file_refs, flags)
other_file_refs = (all_source_files - regular_source_files).map { |sf| project.reference_for_path(sf) } other_file_refs = (all_source_files - regular_source_files).map { |sf| project.reference_for_path(sf) }
...@@ -56,11 +54,11 @@ module Pod ...@@ -56,11 +54,11 @@ module Pod
# @return [void] # @return [void]
# #
def add_resources_bundle_targets def add_resources_bundle_targets
UI.message "- Adding resource bundles to Pods project" do UI.message '- Adding resource bundles to Pods project' do
library.file_accessors.each do |file_accessor| library.file_accessors.each do |file_accessor|
file_accessor.resource_bundles.each do |bundle_name, paths| file_accessor.resource_bundles.each do |bundle_name, paths|
# Add a dependency on an existing Resource Bundle target if possible # Add a dependency on an existing Resource Bundle target if possible
if bundle_target = project.targets.detect { |target| target.name == bundle_name } if bundle_target = project.targets.find { |target| target.name == bundle_name }
target.add_dependency(bundle_target) target.add_dependency(bundle_target)
next next
end end
...@@ -125,7 +123,7 @@ module Pod ...@@ -125,7 +123,7 @@ module Pod
ENABLE_OBJECT_USE_OBJC_FROM = { ENABLE_OBJECT_USE_OBJC_FROM = {
:ios => Version.new('6'), :ios => Version.new('6'),
:osx => Version.new('10.8') :osx => Version.new('10.8'),
} }
# Returns the compiler flags for the source files of the given specification. # Returns the compiler flags for the source files of the given specification.
...@@ -176,7 +174,7 @@ module Pod ...@@ -176,7 +174,7 @@ module Pod
if target_definition.inhibits_warnings_for_pod?(consumer.spec.root.name) if target_definition.inhibits_warnings_for_pod?(consumer.spec.root.name)
flags << '-w -Xanalyzer -analyzer-disable-checker' flags << '-w -Xanalyzer -analyzer-disable-checker'
end end
flags * " " flags * ' '
end end
# Adds a reference to the given file in the support group of this target. # Adds a reference to the given file in the support group of this target.
...@@ -193,7 +191,6 @@ module Pod ...@@ -193,7 +191,6 @@ module Pod
end end
#-----------------------------------------------------------------------# #-----------------------------------------------------------------------#
end end
end end
end end
...@@ -186,7 +186,7 @@ module Pod ...@@ -186,7 +186,7 @@ module Pod
if dependency.external_source if dependency.external_source
spec = sandbox.specification(dependency.root_name) spec = sandbox.specification(dependency.root_name)
unless spec unless spec
raise StandardError, "[Bug] Unable to find the specification " \ raise StandardError, '[Bug] Unable to find the specification ' \
"for `#{dependency}`." "for `#{dependency}`."
end end
set = Specification::Set::External.new(spec) set = Specification::Set::External.new(spec)
...@@ -195,7 +195,7 @@ module Pod ...@@ -195,7 +195,7 @@ module Pod
end end
cached_sets[name] = set cached_sets[name] = set
unless set unless set
raise Informative, "Unable to find a specification for " \ raise Informative, 'Unable to find a specification for ' \
"`#{dependency}` depended upon by #{dependent_spec}." "`#{dependency}` depended upon by #{dependent_spec}."
end end
end end
......
...@@ -115,13 +115,13 @@ module Pod ...@@ -115,13 +115,13 @@ module Pod
# @return [Pathname] the path of the manifest. # @return [Pathname] the path of the manifest.
# #
def manifest_path def manifest_path
root + "Manifest.lock" root + 'Manifest.lock'
end end
# @return [Pathname] the path of the Pods project. # @return [Pathname] the path of the Pods project.
# #
def project_path def project_path
root + "Pods.xcodeproj" root + 'Pods.xcodeproj'
end end
# Returns the path for the directory where to store the support files of # Returns the path for the directory where to store the support files of
...@@ -180,7 +180,7 @@ module Pod ...@@ -180,7 +180,7 @@ module Pod
# specifications. # specifications.
# #
def specifications_root def specifications_root
root + "Local Podspecs" root + 'Local Podspecs'
end end
# @return [Pathname] The directory where to store the files generated by # @return [Pathname] The directory where to store the files generated by
...@@ -210,8 +210,6 @@ module Pod ...@@ -210,8 +210,6 @@ module Pod
end end
end end
# Returns the path of the specification for the Pod with the # Returns the path of the specification for the Pod with the
# given name, if one is stored. # given name, if one is stored.
# #
...@@ -247,7 +245,7 @@ module Pod ...@@ -247,7 +245,7 @@ module Pod
# @todo Store all the specifications (including those not originating # @todo Store all the specifications (including those not originating
# from external sources) so users can check them. # from external sources) so users can check them.
# #
def store_podspec(name, podspec, external_source = false, json = false) def store_podspec(name, podspec, _external_source = false, json = false)
file_name = json ? "#{name}.podspec.json" : "#{name}.podspec" file_name = json ? "#{name}.podspec.json" : "#{name}.podspec"
output_path = specifications_root + file_name output_path = specifications_root + file_name
output_path.dirname.mkpath output_path.dirname.mkpath
......
...@@ -124,10 +124,8 @@ module Pod ...@@ -124,10 +124,8 @@ module Pod
# #
# @note Uses the `:path` option of the Podfile. # @note Uses the `:path` option of the Podfile.
# #
attr_writer :local attr_accessor :local
def local? alias_method :local?, :local
@local
end
# @return [Bool] Whether the validator should fail only on errors or also # @return [Bool] Whether the validator should fail only on errors or also
# on warnings. # on warnings.
......
...@@ -30,7 +30,7 @@ module Pod ...@@ -30,7 +30,7 @@ module Pod
@sut.any_instance.stubs(:clone_template) @sut.any_instance.stubs(:clone_template)
dir = SpecHelper.temporary_directory + 'TestPod' dir = SpecHelper.temporary_directory + 'TestPod'
dir.mkpath dir.mkpath
File.stubs(:exists?).with('configure').returns(true) File.stubs(:exist?).with('configure').returns(true)
@sut.any_instance.expects(:system).with('./configure TestPod').once @sut.any_instance.expects(:system).with('./configure TestPod').once
run_command('lib', 'create', 'TestPod') run_command('lib', 'create', 'TestPod')
end end
......
...@@ -68,8 +68,10 @@ module Pod ...@@ -68,8 +68,10 @@ module Pod
it 'for a single missing Pod' do it 'for a single missing Pod' do
Dir.chdir(temporary_directory) do Dir.chdir(temporary_directory) do
exception = lambda { run_command('update', 'Reachability', '--no-repo-update') }.should.raise Informative should.raise Informative do
exception.message.should.include 'Pod `Reachability` is not installed and cannot be updated' run_command('update', 'Reachability', '--no-repo-update')
end.message.should.include 'The `Reachability` Pod is not ' \
'installed and cannot be updated'
end end
end end
......
require File.expand_path('../../../spec_helper', __FILE__) require File.expand_path('../../../spec_helper', __FILE__)
# README!
#
# Adds {Command::Spec::Edit#exec} to fake the {Kernel#exec} call that would
# normally be made during an edit.
#
module Pod
class Command
class Spec
class Edit
def exec(cmd, *args)
UI.puts "#{cmd} #{args.join(' ')}"
raise SystemExit
end
end
end
end
end
module Pod module Pod
describe Command::Spec do describe Command::Spec do
...@@ -254,7 +272,7 @@ module Pod ...@@ -254,7 +272,7 @@ module Pod
end end
it "complains if it can't find a spec file for the given spec" do it "complains if it can't find a spec file for the given spec" do
File.stubs(:exists?).returns(false) File.stubs(:exist?).returns(false)
lambda { command('spec', 'edit', 'AFNetworking').run }.should.raise Informative lambda { command('spec', 'edit', 'AFNetworking').run }.should.raise Informative
File.unstub(:exists?) File.unstub(:exists?)
end end
......
...@@ -65,7 +65,7 @@ CLIntegracon.configure do |c| ...@@ -65,7 +65,7 @@ CLIntegracon.configure do |c|
# Register special handling for YAML files # Register special handling for YAML files
paths = [%r{Podfile\.lock}, %r{Manifest\.lock$}, %r{xcodeproj\.yaml$}] paths = [%r{Podfile\.lock}, %r{Manifest\.lock$}, %r{xcodeproj\.yaml$}]
c.has_special_handling_for *paths do |path| c.has_special_handling_for(*paths) do |path|
if RUBY_VERSION < '1.9' if RUBY_VERSION < '1.9'
nil # CP is not sorting array derived from hashes whose order is nil # CP is not sorting array derived from hashes whose order is
# undefined in 1.8.7 # undefined in 1.8.7
......
...@@ -67,24 +67,6 @@ module Pod ...@@ -67,24 +67,6 @@ module Pod
end end
end end
# README!
#
# Adds {Command::Spec::Edit#exec} to fake the {Kernel#exec} call that would
# normally be made during an edit.
#
module Pod
class Command
class Spec
class Edit
def exec(cmd, *args)
UI.puts "#{cmd} #{args.join(' ')}"
raise SystemExit
end
end
end
end
end
#-----------------------------------------------------------------------------# #-----------------------------------------------------------------------------#
ENV['SKIP_SETUP'] = 'true' ENV['SKIP_SETUP'] = 'true'
......
...@@ -48,11 +48,11 @@ module Pod ...@@ -48,11 +48,11 @@ module Pod
} }
end end
it "checks for JSON podspecs" do it 'checks for JSON podspecs' do
path = config.sandbox.pod_dir('Reachability') path = config.sandbox.pod_dir('Reachability')
podspec_path = path + 'Reachability.podspec.json' podspec_path = path + 'Reachability.podspec.json'
Dir.mkdir(path) Dir.mkdir(path)
File.open(podspec_path, "w") {} File.open(podspec_path, 'w') {}
Pathname.any_instance.stubs(:rmtree) Pathname.any_instance.stubs(:rmtree)
Downloader::Git.any_instance.stubs(:download) Downloader::Git.any_instance.stubs(:download)
config.sandbox.expects(:store_podspec).with('Reachability', podspec_path, true, true) config.sandbox.expects(:store_podspec).with('Reachability', podspec_path, true, true)
......
...@@ -5,20 +5,20 @@ module Pod ...@@ -5,20 +5,20 @@ module Pod
before do before do
params = { :path => fixture('integration/Reachability') } params = { :path => fixture('integration/Reachability') }
dependency = Dependency.new("Reachability", params) dependency = Dependency.new('Reachability', params)
podfile_path = fixture('integration/Podfile') podfile_path = fixture('integration/Podfile')
@subject = ExternalSources.from_dependency(dependency, podfile_path) @subject = ExternalSources.from_dependency(dependency, podfile_path)
end end
it "creates a copy of the podspec" do it 'creates a copy of the podspec' do
@subject.fetch(config.sandbox) @subject.fetch(config.sandbox)
path = config.sandbox.specifications_root + 'Reachability.podspec' path = config.sandbox.specifications_root + 'Reachability.podspec'
path.should.exist? path.should.exist?
end end
it "supports the deprecated local key" do it 'supports the deprecated local key' do
params = { :local => fixture('integration/Reachability') } params = { :local => fixture('integration/Reachability') }
dependency = Dependency.new("Reachability", params) dependency = Dependency.new('Reachability', params)
podfile_path = fixture('integration/Podfile') podfile_path = fixture('integration/Podfile')
@subject = ExternalSources.from_dependency(dependency, podfile_path) @subject = ExternalSources.from_dependency(dependency, podfile_path)
@subject.fetch(config.sandbox) @subject.fetch(config.sandbox)
...@@ -26,24 +26,24 @@ module Pod ...@@ -26,24 +26,24 @@ module Pod
path.should.exist? path.should.exist?
end end
it "returns the description" do it 'returns the description' do
@subject.description.should.match %r|from `.*integration/Reachability`| @subject.description.should.match %r{from `.*integration/Reachability`}
end end
it "marks the Pod as local in the sandbox" do it 'marks the Pod as local in the sandbox' do
@subject.fetch(config.sandbox) @subject.fetch(config.sandbox)
config.sandbox.development_pods.should == { config.sandbox.development_pods.should == {
"Reachability" => fixture('integration/Reachability').to_s 'Reachability' => fixture('integration/Reachability').to_s,
} }
end end
it "raises if the podspec cannot be found" do it 'raises if the podspec cannot be found' do
@subject.stubs(:params).returns(:path => temporary_directory) @subject.stubs(:params).returns(:path => temporary_directory)
should.raise Informative do should.raise Informative do
@subject.fetch(config.sandbox) @subject.fetch(config.sandbox)
end.message.should.match /No podspec found for `Reachability` in `#{temporary_directory}`/ end.message.should.match /No podspec found for `Reachability` in `#{temporary_directory}`/
it "marks a pod as relative" do it 'marks a pod as relative' do
@subject.stubs(:params).returns(:path => './Reachability') @subject.stubs(:params).returns(:path => './Reachability')
Pathname.any_instance.stubs(:exist?).returns(true) Pathname.any_instance.stubs(:exist?).returns(true)
config.sandbox.stubs(:store_podspec) config.sandbox.stubs(:store_podspec)
...@@ -51,7 +51,7 @@ module Pod ...@@ -51,7 +51,7 @@ module Pod
config.sandbox.local_path_was_absolute?('Reachability').should.be.false config.sandbox.local_path_was_absolute?('Reachability').should.be.false
end end
it "marks a pod as absolute" do it 'marks a pod as absolute' do
@subject.stubs(:params).returns(:path => '/path/Reachability') @subject.stubs(:params).returns(:path => '/path/Reachability')
Pathname.any_instance.stubs(:exist?).returns(true) Pathname.any_instance.stubs(:exist?).returns(true)
config.sandbox.stubs(:store_podspec) config.sandbox.stubs(:store_podspec)
...@@ -60,27 +60,27 @@ module Pod ...@@ -60,27 +60,27 @@ module Pod
end end
end end
describe "#podspec_path" do describe '#podspec_path' do
it "handles absolute paths" do it 'handles absolute paths' do
@subject.stubs(:params).returns(:path => fixture('integration/Reachability')) @subject.stubs(:params).returns(:path => fixture('integration/Reachability'))
path = @subject.send(:podspec_path) path = @subject.send(:podspec_path)
path.should == fixture('integration/Reachability/Reachability.podspec') path.should == fixture('integration/Reachability/Reachability.podspec')
end end
it "handles paths when there is no podfile path" do it 'handles paths when there is no podfile path' do
@subject.stubs(:podfile_path).returns(nil) @subject.stubs(:podfile_path).returns(nil)
@subject.stubs(:params).returns(:path => fixture('integration/Reachability')) @subject.stubs(:params).returns(:path => fixture('integration/Reachability'))
path = @subject.send(:podspec_path) path = @subject.send(:podspec_path)
path.should == fixture('integration/Reachability/Reachability.podspec') path.should == fixture('integration/Reachability/Reachability.podspec')
end end
it "handles relative paths" do it 'handles relative paths' do
@subject.stubs(:params).returns(:path => 'Reachability') @subject.stubs(:params).returns(:path => 'Reachability')
path = @subject.send(:podspec_path) path = @subject.send(:podspec_path)
path.should == fixture('integration/Reachability/Reachability.podspec') path.should == fixture('integration/Reachability/Reachability.podspec')
end end
it "expands the tilde" do it 'expands the tilde' do
File.stubs(:exist?).returns(true) File.stubs(:exist?).returns(true)
@subject.stubs(:params).returns(:path => '~/Reachability') @subject.stubs(:params).returns(:path => '~/Reachability')
Pathname.any_instance.stubs(:exist?).returns(true) Pathname.any_instance.stubs(:exist?).returns(true)
...@@ -95,7 +95,7 @@ module Pod ...@@ -95,7 +95,7 @@ module Pod
result.should.be.false result.should.be.false
end end
it "consider relative paths not explicitly set from the current dir" do it 'consider relative paths not explicitly set from the current dir' do
result = @subject.send(:absolute?, './ThirdPartyCode/UrbanAirship') result = @subject.send(:absolute?, './ThirdPartyCode/UrbanAirship')
result.should.be.false result.should.be.false
end end
...@@ -112,4 +112,3 @@ module Pod ...@@ -112,4 +112,3 @@ module Pod
end end
end end
end end
...@@ -5,56 +5,54 @@ module Pod ...@@ -5,56 +5,54 @@ module Pod
before do before do
podspec_path = fixture('integration/Reachability/Reachability.podspec') podspec_path = fixture('integration/Reachability/Reachability.podspec')
dependency = Dependency.new("Reachability", :podspec => podspec_path.to_s) dependency = Dependency.new('Reachability', :podspec => podspec_path.to_s)
podfile_path = fixture('integration/Podfile') podfile_path = fixture('integration/Podfile')
@subject = ExternalSources.from_dependency(dependency, podfile_path) @subject = ExternalSources.from_dependency(dependency, podfile_path)
end end
it "creates a copy of the podspec" do it 'creates a copy of the podspec' do
@subject.fetch(config.sandbox) @subject.fetch(config.sandbox)
path = config.sandbox.specifications_root + 'Reachability.podspec' path = config.sandbox.specifications_root + 'Reachability.podspec'
path.should.exist? path.should.exist?
end end
it "returns the description" do it 'returns the description' do
@subject.description.should.match %r|from `.*Reachability/Reachability.podspec`| @subject.description.should.match %r{from `.*Reachability/Reachability.podspec`}
end end
describe "Helpers" do describe 'Helpers' do
it "handles absolute paths" do it 'handles absolute paths' do
@subject.stubs(:params).returns(:podspec => fixture('integration/Reachability')) @subject.stubs(:params).returns(:podspec => fixture('integration/Reachability'))
path = @subject.send(:podspec_uri) path = @subject.send(:podspec_uri)
path.should == fixture('integration/Reachability/Reachability.podspec').to_s path.should == fixture('integration/Reachability/Reachability.podspec').to_s
end end
it "handles paths when there is no podfile path" do it 'handles paths when there is no podfile path' do
@subject.stubs(:podfile_path).returns(nil) @subject.stubs(:podfile_path).returns(nil)
@subject.stubs(:params).returns(:podspec => fixture('integration/Reachability')) @subject.stubs(:params).returns(:podspec => fixture('integration/Reachability'))
path = @subject.send(:podspec_uri) path = @subject.send(:podspec_uri)
path.should == fixture('integration/Reachability/Reachability.podspec').to_s path.should == fixture('integration/Reachability/Reachability.podspec').to_s
end end
it "handles relative paths" do it 'handles relative paths' do
@subject.stubs(:params).returns(:podspec => 'Reachability') @subject.stubs(:params).returns(:podspec => 'Reachability')
path = @subject.send(:podspec_uri) path = @subject.send(:podspec_uri)
path.should == fixture('integration/Reachability/Reachability.podspec').to_s path.should == fixture('integration/Reachability/Reachability.podspec').to_s
end end
it "expands the tilde" do it 'expands the tilde' do
File.stubs(:exist?).returns(true) File.stubs(:exist?).returns(true)
@subject.stubs(:params).returns(:podspec => '~/Reachability') @subject.stubs(:params).returns(:podspec => '~/Reachability')
path = @subject.send(:podspec_uri) path = @subject.send(:podspec_uri)
path.should == ENV['HOME'] + '/Reachability/Reachability.podspec' path.should == ENV['HOME'] + '/Reachability/Reachability.podspec'
end end
it "handles URLs" do it 'handles URLs' do
@subject.stubs(:params).returns(:podspec => "http://www.example.com/Reachability.podspec") @subject.stubs(:params).returns(:podspec => 'http://www.example.com/Reachability.podspec')
path = @subject.send(:podspec_uri) path = @subject.send(:podspec_uri)
path.should == "http://www.example.com/Reachability.podspec" path.should == 'http://www.example.com/Reachability.podspec'
end end
end end
end end
end end
...@@ -30,10 +30,10 @@ describe Pod::Generator::Markdown do ...@@ -30,10 +30,10 @@ describe Pod::Generator::Markdown do
given_path = @generator.class.path_from_basepath(basepath) given_path = @generator.class.path_from_basepath(basepath)
expected_path = config.sandbox.root + 'Pods-acknowledgements.markdown' expected_path = config.sandbox.root + 'Pods-acknowledgements.markdown'
mockFile = mock file = mock
mockFile.expects(:write).with(equals(@generator.licenses)) file.expects(:write).with(equals(@generator.licenses))
mockFile.expects(:close) file.expects(:close)
File.expects(:new).with(equals(expected_path), equals('w')).returns(mockFile) File.expects(:new).with(equals(expected_path), equals('w')).returns(file)
@generator.save_as(given_path) @generator.save_as(given_path)
end end
end end
require File.expand_path('../../../spec_helper', __FILE__) require File.expand_path('../../../spec_helper', __FILE__)
describe "Pod::Generator::BridgeSupport" do describe 'Pod::Generator::BridgeSupport' do
if `which gen_bridge_metadata`.strip.empty? if `which gen_bridge_metadata`.strip.empty?
puts " ! ".red << "Skipping because the `gen_bridge_metadata` executable can't be found." puts ' ! '.red << "Skipping because the `gen_bridge_metadata` executable can't be found."
else else
it "generates a metadata file with the appropriate search paths" do it 'generates a metadata file with the appropriate search paths' do
headers = %w{ /some/dir/foo.h /some/dir/bar.h /some/other/dir/baz.h }.map { |h| Pathname.new(h) } headers = %w(/some/dir/foo.h /some/dir/bar.h /some/other/dir/baz.h).map { |h| Pathname.new(h) }
generator = Pod::Generator::BridgeSupport.new(headers) generator = Pod::Generator::BridgeSupport.new(headers)
def generator.gen_bridge_metadata(command) expected = %(-c "-I '/some/dir' -I '/some/other/dir'" -o '/path/to/Pods.bridgesupport' '#{headers.join("' '")}')
@command = command generator.expects(:gen_bridge_metadata).with(expected)
end generator.save_as(Pathname.new('/path/to/Pods.bridgesupport'))
generator.save_as(Pathname.new("/path/to/Pods.bridgesupport"))
generator.instance_variable_get(:@command).should ==
%{-c "-I '/some/dir' -I '/some/other/dir'" -o '/path/to/Pods.bridgesupport' '#{headers.join("' '")}'}
end end
end end
end end
...@@ -54,7 +54,7 @@ module Pod ...@@ -54,7 +54,7 @@ module Pod
:libraries => [], :libraries => [],
:frameworks => [], :frameworks => [],
:weak_frameworks => [], :weak_frameworks => [],
:platform_name => :ios :platform_name => :ios,
) )
@sut.add_spec_build_settings_to_xcconfig(consumer, xcconfig) @sut.add_spec_build_settings_to_xcconfig(consumer, xcconfig)
xcconfig.to_hash['OTHER_LDFLAGS'].should == '-framework "SenTestingKit"' xcconfig.to_hash['OTHER_LDFLAGS'].should == '-framework "SenTestingKit"'
...@@ -67,7 +67,7 @@ module Pod ...@@ -67,7 +67,7 @@ module Pod
:libraries => ['xml2'], :libraries => ['xml2'],
:frameworks => [], :frameworks => [],
:weak_frameworks => [], :weak_frameworks => [],
:platform_name => :ios :platform_name => :ios,
) )
@sut.add_spec_build_settings_to_xcconfig(consumer, xcconfig) @sut.add_spec_build_settings_to_xcconfig(consumer, xcconfig)
xcconfig.to_hash['OTHER_LDFLAGS'].should == '-l "xml2"' xcconfig.to_hash['OTHER_LDFLAGS'].should == '-l "xml2"'
...@@ -80,7 +80,7 @@ module Pod ...@@ -80,7 +80,7 @@ module Pod
:libraries => [], :libraries => [],
:frameworks => ['CoreAnimation'], :frameworks => ['CoreAnimation'],
:weak_frameworks => [], :weak_frameworks => [],
:platform_name => :ios :platform_name => :ios,
) )
@sut.add_spec_build_settings_to_xcconfig(consumer, xcconfig) @sut.add_spec_build_settings_to_xcconfig(consumer, xcconfig)
xcconfig.to_hash['OTHER_LDFLAGS'].should == '-framework "CoreAnimation"' xcconfig.to_hash['OTHER_LDFLAGS'].should == '-framework "CoreAnimation"'
...@@ -93,7 +93,7 @@ module Pod ...@@ -93,7 +93,7 @@ module Pod
:libraries => [], :libraries => [],
:frameworks => [], :frameworks => [],
:weak_frameworks => ['iAd'], :weak_frameworks => ['iAd'],
:platform_name => :ios :platform_name => :ios,
) )
@sut.add_spec_build_settings_to_xcconfig(consumer, xcconfig) @sut.add_spec_build_settings_to_xcconfig(consumer, xcconfig)
xcconfig.to_hash['OTHER_LDFLAGS'].should == '-weak_framework "iAd"' xcconfig.to_hash['OTHER_LDFLAGS'].should == '-weak_framework "iAd"'
...@@ -106,7 +106,7 @@ module Pod ...@@ -106,7 +106,7 @@ module Pod
:libraries => [], :libraries => [],
:frameworks => ['SenTestingKit'], :frameworks => ['SenTestingKit'],
:weak_frameworks => [], :weak_frameworks => [],
:platform_name => :ios :platform_name => :ios,
) )
@sut.add_spec_build_settings_to_xcconfig(consumer, xcconfig) @sut.add_spec_build_settings_to_xcconfig(consumer, xcconfig)
xcconfig.to_hash['FRAMEWORK_SEARCH_PATHS'].should.include('SDKROOT') xcconfig.to_hash['FRAMEWORK_SEARCH_PATHS'].should.include('SDKROOT')
...@@ -120,7 +120,7 @@ module Pod ...@@ -120,7 +120,7 @@ module Pod
:libraries => [], :libraries => [],
:frameworks => ['SenTestingKit'], :frameworks => ['SenTestingKit'],
:weak_frameworks => [], :weak_frameworks => [],
:platform_name => :osx :platform_name => :osx,
) )
@sut.add_spec_build_settings_to_xcconfig(consumer, xcconfig) @sut.add_spec_build_settings_to_xcconfig(consumer, xcconfig)
xcconfig.to_hash['FRAMEWORK_SEARCH_PATHS'].should.include('DEVELOPER_LIBRARY_DIR') xcconfig.to_hash['FRAMEWORK_SEARCH_PATHS'].should.include('DEVELOPER_LIBRARY_DIR')
......
...@@ -168,14 +168,14 @@ module Pod ...@@ -168,14 +168,14 @@ module Pod
it 'returns the clean paths' do it 'returns the clean paths' do
@installer.send(:download_source) @installer.send(:download_source)
paths = @installer.send(:clean_paths) paths = @installer.send(:clean_paths)
relative_paths = paths.map { |p| p.gsub("#{temporary_directory}/", '')} relative_paths = paths.map { |p| p.gsub("#{temporary_directory}/", '') }
paths_without_git = relative_paths.reject { |p| p.include? 'Pods/Sources/BananaLib/.git' } paths_without_git = relative_paths.reject { |p| p.include? 'Pods/Sources/BananaLib/.git' }
paths_without_git.sort.should == [ paths_without_git.sort.should == [
"Pods/Sources/BananaLib/BananaLib.podspec", 'Pods/Sources/BananaLib/BananaLib.podspec',
"Pods/Sources/BananaLib/libPusher", 'Pods/Sources/BananaLib/libPusher',
"Pods/Sources/BananaLib/sub-dir", 'Pods/Sources/BananaLib/sub-dir',
"Pods/Sources/BananaLib/sub-dir/sub-dir-2", 'Pods/Sources/BananaLib/sub-dir/sub-dir-2',
"Pods/Sources/BananaLib/sub-dir/sub-dir-2/somefile.txt" 'Pods/Sources/BananaLib/sub-dir/sub-dir-2/somefile.txt',
] ]
end end
...@@ -184,13 +184,13 @@ module Pod ...@@ -184,13 +184,13 @@ module Pod
paths = @installer.send(:used_files) paths = @installer.send(:used_files)
relative_paths = paths.map { |p| p.gsub("#{temporary_directory}/", '') } relative_paths = paths.map { |p| p.gsub("#{temporary_directory}/", '') }
relative_paths.sort.should == [ relative_paths.sort.should == [
"Pods/Sources/BananaLib/Classes/Banana.h", 'Pods/Sources/BananaLib/Classes/Banana.h',
"Pods/Sources/BananaLib/Classes/Banana.m", 'Pods/Sources/BananaLib/Classes/Banana.m',
"Pods/Sources/BananaLib/Classes/BananaLib.pch", 'Pods/Sources/BananaLib/Classes/BananaLib.pch',
"Pods/Sources/BananaLib/Classes/BananaPrivate.h", 'Pods/Sources/BananaLib/Classes/BananaPrivate.h',
"Pods/Sources/BananaLib/LICENSE", 'Pods/Sources/BananaLib/LICENSE',
"Pods/Sources/BananaLib/README", 'Pods/Sources/BananaLib/README',
"Pods/Sources/BananaLib/Resources/logo-sidebar.png" 'Pods/Sources/BananaLib/Resources/logo-sidebar.png',
] ]
end end
...@@ -208,13 +208,13 @@ module Pod ...@@ -208,13 +208,13 @@ module Pod
paths = @installer.send(:used_files) paths = @installer.send(:used_files)
relative_paths = paths.map { |p| p.gsub("#{temporary_directory}/", '') } relative_paths = paths.map { |p| p.gsub("#{temporary_directory}/", '') }
relative_paths.sort.should == [ relative_paths.sort.should == [
"Pods/Sources/BananaLib/Classes/Banana.h", 'Pods/Sources/BananaLib/Classes/Banana.h',
"Pods/Sources/BananaLib/Classes/Banana.m", 'Pods/Sources/BananaLib/Classes/Banana.m',
"Pods/Sources/BananaLib/Classes/BananaLib.pch", 'Pods/Sources/BananaLib/Classes/BananaLib.pch',
"Pods/Sources/BananaLib/Classes/BananaPrivate.h", 'Pods/Sources/BananaLib/Classes/BananaPrivate.h',
"Pods/Sources/BananaLib/LICENSE", 'Pods/Sources/BananaLib/LICENSE',
"Pods/Sources/BananaLib/README", 'Pods/Sources/BananaLib/README',
"Pods/Sources/BananaLib/Resources/logo-sidebar.png" 'Pods/Sources/BananaLib/Resources/logo-sidebar.png',
] ]
end end
......
...@@ -15,7 +15,7 @@ module Pod ...@@ -15,7 +15,7 @@ module Pod
@pod_bundle.client_root = project_path.dirname @pod_bundle.client_root = project_path.dirname
@pod_bundle.user_target_uuids = [@target.uuid] @pod_bundle.user_target_uuids = [@target.uuid]
configuration = Xcodeproj::Config.new( configuration = Xcodeproj::Config.new(
'GCC_PREPROCESSOR_DEFINITIONS' => '$(inherited) COCOAPODS=1' 'GCC_PREPROCESSOR_DEFINITIONS' => '$(inherited) COCOAPODS=1',
) )
@pod_bundle.xcconfigs['Debug'] = configuration @pod_bundle.xcconfigs['Debug'] = configuration
@pod_bundle.xcconfigs['Test'] = configuration @pod_bundle.xcconfigs['Test'] = configuration
......
...@@ -20,7 +20,7 @@ module Pod ...@@ -20,7 +20,7 @@ module Pod
@pod_bundle.client_root = project_path.dirname @pod_bundle.client_root = project_path.dirname
@pod_bundle.user_target_uuids = [@target.uuid] @pod_bundle.user_target_uuids = [@target.uuid]
configuration = Xcodeproj::Config.new( configuration = Xcodeproj::Config.new(
'GCC_PREPROCESSOR_DEFINITIONS' => '$(inherited) COCOAPODS=1' 'GCC_PREPROCESSOR_DEFINITIONS' => '$(inherited) COCOAPODS=1',
) )
@pod_bundle.xcconfigs['Debug'] = configuration @pod_bundle.xcconfigs['Debug'] = configuration
@pod_bundle.xcconfigs['Test'] = configuration @pod_bundle.xcconfigs['Test'] = configuration
......
...@@ -96,7 +96,7 @@ module Pod ...@@ -96,7 +96,7 @@ module Pod
saved = Xcodeproj::Workspace.new_from_xcworkspace(workspace_path) saved = Xcodeproj::Workspace.new_from_xcworkspace(workspace_path)
saved.file_references.map(&:path).should == [ saved.file_references.map(&:path).should == [
'SampleProject/SampleProject.xcodeproj', 'SampleProject/SampleProject.xcodeproj',
"Pods/Pods.xcodeproj" 'Pods/Pods.xcodeproj',
] ]
end end
...@@ -109,7 +109,7 @@ module Pod ...@@ -109,7 +109,7 @@ module Pod
saved = Xcodeproj::Workspace.new_from_xcworkspace(workspace_path) saved = Xcodeproj::Workspace.new_from_xcworkspace(workspace_path)
saved.file_references.map(&:path).should == [ saved.file_references.map(&:path).should == [
'SampleProject/SampleProject.xcodeproj', 'SampleProject/SampleProject.xcodeproj',
"Pods/Pods.xcodeproj" 'Pods/Pods.xcodeproj',
] ]
end end
......
...@@ -210,15 +210,15 @@ module Pod ...@@ -210,15 +210,15 @@ module Pod
platform :ios platform :ios
pod 'JSONKit' pod 'JSONKit'
end end
sources = SourcesManager.sources(['master', 'test_repo']) sources = SourcesManager.sources(%w(master test_repo))
resolver = Resolver.new(config.sandbox, podfile, [], sources) resolver = Resolver.new(config.sandbox, podfile, [], sources)
version = resolver.resolve.values.flatten.first.version version = resolver.resolve.values.flatten.first.version
version.to_s.should.not == "999.999.999" version.to_s.should.not == '999.999.999'
sources = SourcesManager.sources(['test_repo', 'master']) sources = SourcesManager.sources(%w(test_repo master))
resolver = Resolver.new(config.sandbox, podfile, [], sources) resolver = Resolver.new(config.sandbox, podfile, [], sources)
version = resolver.resolve.values.flatten.first.version version = resolver.resolve.values.flatten.first.version
version.to_s.should == "999.999.999" version.to_s.should == '999.999.999'
end end
end end
......
...@@ -35,7 +35,7 @@ module Pod ...@@ -35,7 +35,7 @@ module Pod
#-------------------------------------------------------------------------# #-------------------------------------------------------------------------#
describe "In general" do describe 'In general' do
before do before do
Source::Aggregate.any_instance.stubs(:all).returns([@test_source]) Source::Aggregate.any_instance.stubs(:all).returns([@test_source])
...@@ -43,84 +43,84 @@ module Pod ...@@ -43,84 +43,84 @@ module Pod
#--------------------------------------# #--------------------------------------#
it "returns all the sources" do it 'returns all the sources' do
Source::Aggregate.any_instance.unstub(:all) Source::Aggregate.any_instance.unstub(:all)
SourcesManager.all.map(&:name).should == %w[master test_repo] SourcesManager.all.map(&:name).should == %w(master test_repo)
end end
it "searches for the set of a dependency" do it 'searches for the set of a dependency' do
set = SourcesManager.search(Dependency.new('BananaLib')) set = SourcesManager.search(Dependency.new('BananaLib'))
set.class.should == Specification::Set set.class.should == Specification::Set
set.name.should == 'BananaLib' set.name.should == 'BananaLib'
end end
it "returns nil if it is not able to find a pod for the given dependency" do it 'returns nil if it is not able to find a pod for the given dependency' do
set = SourcesManager.search(Dependency.new('Windows-Lib')) set = SourcesManager.search(Dependency.new('Windows-Lib'))
set.should.be.nil set.should.be.nil
end end
it "searches sets by name" do it 'searches sets by name' do
sets = SourcesManager.search_by_name('BananaLib') sets = SourcesManager.search_by_name('BananaLib')
sets.all?{ |s| s.class == Specification::Set}.should.be.true sets.all? { |s| s.class == Specification::Set }.should.be.true
sets.any?{ |s| s.name == 'BananaLib'}.should.be.true sets.any? { |s| s.name == 'BananaLib' }.should.be.true
end end
it "can perform a full text search of the sets" do it 'can perform a full text search of the sets' do
Source::Aggregate.any_instance.stubs(:all).returns([@test_source]) Source::Aggregate.any_instance.stubs(:all).returns([@test_source])
sets = SourcesManager.search_by_name('Chunky', true) sets = SourcesManager.search_by_name('Chunky', true)
sets.all?{ |s| s.class == Specification::Set}.should.be.true sets.all? { |s| s.class == Specification::Set }.should.be.true
sets.any?{ |s| s.name == 'BananaLib'}.should.be.true sets.any? { |s| s.name == 'BananaLib' }.should.be.true
end end
it "can perform a full text regexp search of the sets" do it 'can perform a full text regexp search of the sets' do
Source::Aggregate.any_instance.stubs(:all).returns([@test_source]) Source::Aggregate.any_instance.stubs(:all).returns([@test_source])
sets = SourcesManager.search_by_name('Ch[aeiou]nky', true) sets = SourcesManager.search_by_name('Ch[aeiou]nky', true)
sets.all?{ |s| s.class == Specification::Set}.should.be.true sets.all? { |s| s.class == Specification::Set }.should.be.true
sets.any?{ |s| s.name == 'BananaLib'}.should.be.true sets.any? { |s| s.name == 'BananaLib' }.should.be.true
end end
it "generates the search index before performing a search if it doesn't exits" do it "generates the search index before performing a search if it doesn't exits" do
Source::Aggregate.any_instance.stubs(:all).returns([@test_source]) Source::Aggregate.any_instance.stubs(:all).returns([@test_source])
Source::Aggregate.any_instance.expects(:generate_search_index).returns({'BananaLib' => {}}) Source::Aggregate.any_instance.expects(:generate_search_index).returns('BananaLib' => {})
Source::Aggregate.any_instance.expects(:update_search_index).never Source::Aggregate.any_instance.expects(:update_search_index).never
SourcesManager.updated_search_index = nil SourcesManager.updated_search_index = nil
sets = SourcesManager.search_by_name('BananaLib', true) sets = SourcesManager.search_by_name('BananaLib', true)
end end
it "updates the search index before performing a search if it exits" do it 'updates the search index before performing a search if it exits' do
File.open(SourcesManager.search_index_path, 'w') { |file| file.write("---\nBananaLib:\n version: 0.0.1") } File.open(SourcesManager.search_index_path, 'w') { |file| file.write("---\nBananaLib:\n version: 0.0.1") }
Source::Aggregate.any_instance.stubs(:all).returns([@test_source]) Source::Aggregate.any_instance.stubs(:all).returns([@test_source])
Source::Aggregate.any_instance.expects(:generate_search_index).never Source::Aggregate.any_instance.expects(:generate_search_index).never
Source::Aggregate.any_instance.expects(:update_search_index).returns({'BananaLib' => {}}) Source::Aggregate.any_instance.expects(:update_search_index).returns('BananaLib' => {})
SourcesManager.updated_search_index = nil SourcesManager.updated_search_index = nil
sets = SourcesManager.search_by_name('BananaLib', true) sets = SourcesManager.search_by_name('BananaLib', true)
end end
it "returns the path of the search index" do it 'returns the path of the search index' do
SourcesManager.unstub(:search_index_path) SourcesManager.unstub(:search_index_path)
path = SourcesManager.search_index_path.to_s path = SourcesManager.search_index_path.to_s
path.should.match %r[Library/Caches/CocoaPods/search_index.yaml] path.should.match %r{Library/Caches/CocoaPods/search_index.yaml}
end end
end end
#-------------------------------------------------------------------------# #-------------------------------------------------------------------------#
describe "Updating Sources" do describe 'Updating Sources' do
extend SpecHelper::TemporaryRepos extend SpecHelper::TemporaryRepos
it "update source backed by a git repository" do it 'update source backed by a git repository' do
set_up_test_repo_for_update set_up_test_repo_for_update
SourcesManager.update(test_repo_path.basename.to_s, true) SourcesManager.update(test_repo_path.basename.to_s, true)
UI.output.should.match /is up to date/ UI.output.should.match /is up to date/
end end
it "uses the only fast forward git option" do it 'uses the only fast forward git option' do
set_up_test_repo_for_update set_up_test_repo_for_update
SourcesManager.expects(:git!).with() { |options| options.should.match /--ff-only/ } SourcesManager.expects(:git!).with { |options| options.should.match /--ff-only/ }
SourcesManager.update(test_repo_path.basename.to_s, true) SourcesManager.update(test_repo_path.basename.to_s, true)
end end
it "prints a warning if the update failed" do it 'prints a warning if the update failed' do
UI.warnings = '' UI.warnings = ''
set_up_test_repo_for_update set_up_test_repo_for_update
Dir.chdir(test_repo_path) do Dir.chdir(test_repo_path) do
...@@ -130,23 +130,23 @@ module Pod ...@@ -130,23 +130,23 @@ module Pod
UI.warnings.should.include('not able to update the `master` repo') UI.warnings.should.include('not able to update the `master` repo')
end end
it "returns whether a source is backed by a git repo" do it 'returns whether a source is backed by a git repo' do
SourcesManager.git_repo?(SourcesManager.master_repo_dir).should.be.true SourcesManager.git_repo?(SourcesManager.master_repo_dir).should.be.true
SourcesManager.git_repo?(Pathname.new('/tmp')).should.be.false SourcesManager.git_repo?(Pathname.new('/tmp')).should.be.false
end end
it "informs the user if there is an update for CocoaPods" do it 'informs the user if there is an update for CocoaPods' do
SourcesManager.stubs(:version_information).returns({ 'last' => '999.0' }) SourcesManager.stubs(:version_information).returns('last' => '999.0')
SourcesManager.check_version_information(temporary_directory) SourcesManager.check_version_information(temporary_directory)
UI.output.should.match /CocoaPods 999.0 is available/ UI.output.should.match /CocoaPods 999.0 is available/
end end
it "raises while asked to version information of a source if it is not compatible" do it 'raises while asked to version information of a source if it is not compatible' do
SourcesManager.stubs(:version_information).returns({ 'min' => '999.0' }) SourcesManager.stubs(:version_information).returns('min' => '999.0')
e = lambda { SourcesManager.check_version_information(temporary_directory) }.should.raise Informative e = lambda { SourcesManager.check_version_information(temporary_directory) }.should.raise Informative
e.message.should.match /Update CocoaPods/ e.message.should.match /Update CocoaPods/
e.message.should.match /(currently using #{Pod::VERSION})/ e.message.should.match /(currently using #{Pod::VERSION})/
SourcesManager.stubs(:version_information).returns({ 'max' => '0.0.1' }) SourcesManager.stubs(:version_information).returns('max' => '0.0.1')
e = lambda { SourcesManager.check_version_information(temporary_directory) }.should.raise Informative e = lambda { SourcesManager.check_version_information(temporary_directory) }.should.raise Informative
e.message.should.match /Update CocoaPods/ e.message.should.match /Update CocoaPods/
e.message.should.match /(currently using #{Pod::VERSION})/ e.message.should.match /(currently using #{Pod::VERSION})/
...@@ -164,23 +164,23 @@ module Pod ...@@ -164,23 +164,23 @@ module Pod
SourcesManager.send(:path_writable?, path).should.be.true SourcesManager.send(:path_writable?, path).should.be.true
end end
it "returns whether a repository is compatible" do it 'returns whether a repository is compatible' do
SourcesManager.stubs(:version_information).returns({ 'min' => '0.0.1' }) SourcesManager.stubs(:version_information).returns('min' => '0.0.1')
SourcesManager.repo_compatible?('stub').should.be.true SourcesManager.repo_compatible?('stub').should.be.true
SourcesManager.stubs(:version_information).returns({ 'max' => '999.0' }) SourcesManager.stubs(:version_information).returns('max' => '999.0')
SourcesManager.repo_compatible?('stub').should.be.true SourcesManager.repo_compatible?('stub').should.be.true
SourcesManager.stubs(:version_information).returns({ 'min' => '999.0' }) SourcesManager.stubs(:version_information).returns('min' => '999.0')
SourcesManager.repo_compatible?('stub').should.be.false SourcesManager.repo_compatible?('stub').should.be.false
SourcesManager.stubs(:version_information).returns({ 'max' => '0.0.1' }) SourcesManager.stubs(:version_information).returns('max' => '0.0.1')
SourcesManager.repo_compatible?('stub').should.be.false SourcesManager.repo_compatible?('stub').should.be.false
end end
it "returns whether there is a CocoaPods update available" do it 'returns whether there is a CocoaPods update available' do
SourcesManager.cocoapods_update?({ 'last' => '0.0.1' }).should.be.false SourcesManager.cocoapods_update?('last' => '0.0.1').should.be.false
SourcesManager.cocoapods_update?({ 'last' => '999.0' }).should.be.true SourcesManager.cocoapods_update?('last' => '999.0').should.be.true
end end
it "it returns an empty array for the version information if the file can't be found" do it "it returns an empty array for the version information if the file can't be found" do
...@@ -191,13 +191,13 @@ module Pod ...@@ -191,13 +191,13 @@ module Pod
#-------------------------------------------------------------------------# #-------------------------------------------------------------------------#
describe "Master repo" do describe 'Master repo' do
it "returns the master repo dir" do it 'returns the master repo dir' do
SourcesManager.master_repo_dir.to_s.should.match /fixtures\/spec-repos\/master/ SourcesManager.master_repo_dir.to_s.should.match /fixtures\/spec-repos\/master/
end end
it "returns whether the master repo is functional" do it 'returns whether the master repo is functional' do
SourcesManager.master_repo_functional?.should.be.true SourcesManager.master_repo_functional?.should.be.true
config.repos_dir = SpecHelper.temporary_directory config.repos_dir = SpecHelper.temporary_directory
SourcesManager.master_repo_functional?.should.be.false SourcesManager.master_repo_functional?.should.be.false
......
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