Commit 97e61199 authored by Fabio Pelosin's avatar Fabio Pelosin

[#201] Moved version check to repo sub-command

parent 331c95f9
Encoding.default_external = Encoding::UTF_8 if RUBY_VERSION > '1.8.7'
module Pod
VERSION = '0.6.0.a'
VERSION = '0.6.0rc1'
class Informative < StandardError
end
......
......@@ -65,23 +65,9 @@ module Pod
end
def self.run(*argv)
bin_version = Gem::Version.new(VERSION)
last_version = bin_version
Source.all.each { |source|
file = source.repo + 'CocoaPods-version.txt'
next unless file.exist?
repo_min_version = Gem::Version.new(YAML.load_file(file)[:min])
repo_last_version = Gem::Version.new(YAML.load_file(file)[:last])
last_version = repo_last_version if repo_last_version && repo_last_version > last_version
if repo_min_version > bin_version
raise Informative, "\n[!] The repo `#{source}' requires CocoaPods version #{repo_version}\n".red +
"\nPlease, update your gem\n\n"
end
}
puts "\n-> Cocoapods #{last_version} is available \n".green.reversed if last_version > bin_version
Setup.new(ARGV.new).run_if_needed
parse(*argv).run
rescue Interrupt
puts "[!] Cancelled".red
Config.instance.verbose? ? raise : exit(1)
......
......@@ -45,6 +45,7 @@ module Pod
puts "Cloning spec repo `#{@name}' from `#{@url}'" unless config.silent?
config.repos_dir.mkpath
Dir.chdir(config.repos_dir) { git("clone '#{@url}' #{@name}") }
check_versions(dir)
end
def update
......@@ -52,8 +53,24 @@ module Pod
dirs.each do |dir|
puts "Updating spec repo `#{dir.basename}'" unless config.silent?
Dir.chdir(dir) { git("pull") }
check_versions(dir)
end
end
def check_versions(dir)
bin_version = Gem::Version.new(VERSION)
yaml_file = dir + 'CocoaPods-version.yml'
return unless yaml_file.exist?
data = YAML.load_file(yaml_file)
min_version = Gem::Version.new(data[:min])
last_version = Gem::Version.new(data[:last])
if min_version > bin_version
raise Informative,
"\n[!] The `#{dir.basename.to_s}' repo requires CocoaPods #{min_version}\n".red +
"Update Cocoapods, or checkout the appropriate tag/commit in the repo\n\n"
end
puts "Cocoapods #{last_version} is available".green if last_version > bin_version
end
end
end
end
......
......@@ -83,9 +83,5 @@ module Pod
set if text.downcase.include?(query.downcase)
end.compact
end
def to_s
@repo.basename.to_s
end
end
end
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