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

[Style]

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