From 9f564f0c74a8cc3a47331fbc082dff0afb50da4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eloy=20Dur=C3=A1n?= Date: Wed, 26 Feb 2014 13:50:06 +0100 Subject: [PATCH] [Command] Use Motion::Util::Version to compare. --- lib/motion/command/update.rb | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/lib/motion/command/update.rb b/lib/motion/command/update.rb index 00000484..25ad8a21 100644 --- a/lib/motion/command/update.rb +++ b/lib/motion/command/update.rb @@ -22,12 +22,11 @@ # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. require 'motion/project/builder' +require 'motion/util/version' module Motion; class Command class Update < Command self.summary = 'Update the software.' - # TODO make more elaborate - # self.description = '...' def self.options [ @@ -65,12 +64,6 @@ module Motion; class Command Motion::Version end - def latest_version?(product, latest) - product = product.split(".") - latest = latest.split(".") - (product[0].to_i >= latest[0].to_i) && (product[1].to_i >= latest[1].to_i) - end - def curl(cmd) resp = `/usr/bin/curl --connect-timeout 60 #{cmd}` if $?.exitstatus != 0 @@ -89,7 +82,7 @@ module Motion; class Command latest_version, message = File.read(update_check_file).split('|', 2) message ||= '' - unless latest_version?(product_version, latest_version) + if Util::Version.new(latest_version) > Util::Version.new(product_version) message = "A new version of RubyMotion is available. Run `sudo motion update' to upgrade.\n" + message end message.strip!