Commit 3f214a9b authored by Marius Rackwitz's avatar Marius Rackwitz

[Command] Extract Options::RepoUpdate

parent 674f6a7c
......@@ -14,6 +14,7 @@ module Pod
end
class Command < CLAide::Command
require 'cocoapods/command/options/repo_update'
require 'cocoapods/command/options/project_directory'
include Options
......
module Pod
class Command
class Install < Command
include RepoUpdate
include ProjectDirectory
self.summary = 'Install project dependencies to Podfile.lock versions'
......@@ -25,15 +26,12 @@ module Pod
def self.options
[
['--repo-update', 'Force running `pod repo update` before install'],
].concat(super)
end
def initialize(argv)
config.skip_repo_update = !argv.flag?('repo-update', false)
super
].concat(super).reject { |(name, _)| name == '--no-repo-update' }
end
def run
config.skip_repo_update = !repo_update?(:default => false)
verify_podfile_exists!
installer = installer_for_config
installer.update = false
......
module Pod
class Command
module Options
# Provides support for commands to skip updating the spec repositories.
#
module RepoUpdate
module Options
def options
[
['--no-repo-update', 'Skip running `pod repo update` before install'],
].concat(super)
end
end
def self.included(base)
base.extend(Options)
end
def repo_update?(default: false)
if @repo_update.nil?
default
else
@repo_update
end
end
def initialize(argv)
@repo_update = argv.flag?('repo-update')
super
end
end
end
end
end
module Pod
class Command
class Outdated < Command
include RepoUpdate
include ProjectDirectory
self.summary = 'Show outdated project dependencies'
......@@ -10,17 +11,6 @@ module Pod
spec repos, not those from local/external sources or `:head` versions.
DESC
def self.options
[
['--no-repo-update', 'Skip running `pod repo update` before install'],
].concat(super)
end
def initialize(argv)
config.skip_repo_update = !argv.flag?('repo-update', !config.skip_repo_update)
super
end
# Run the command
#
# @todo the command report new dependencies added to the Podfile as
......@@ -103,7 +93,7 @@ module Pod
def spec_sets
@spec_sets ||= begin
analyzer.send(:update_repositories) unless config.skip_repo_update?
analyzer.send(:update_repositories) if repo_update?(:default => true)
aggregate = Source::Aggregate.new(analyzer.sources)
installed_pods.map do |pod_name|
aggregate.search(Dependency.new(pod_name))
......
module Pod
class Command
class Update < Command
include RepoUpdate
include ProjectDirectory
self.summary = 'Update outdated project dependencies and create new ' \
......@@ -18,14 +19,7 @@ module Pod
CLAide::Argument.new('POD_NAMES', false, true),
]
def self.options
[
['--no-repo-update', 'Skip running `pod repo update` before install'],
].concat(super)
end
def initialize(argv)
config.skip_repo_update = !argv.flag?('repo-update', !config.skip_repo_update)
@pods = argv.arguments! unless argv.arguments.empty?
super
end
......@@ -51,6 +45,8 @@ module Pod
end
def run
config.skip_repo_update = !repo_update?(:default => true)
verify_podfile_exists!
installer = installer_for_config
......
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