mirror of
https://github.com/zhigang1992/RubyMotion.git
synced 2026-04-27 22:41:16 +08:00
[Command] Use Motion::Util::Version to compare.
This commit is contained in:
@@ -22,12 +22,11 @@
|
|||||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
require 'motion/project/builder'
|
require 'motion/project/builder'
|
||||||
|
require 'motion/util/version'
|
||||||
|
|
||||||
module Motion; class Command
|
module Motion; class Command
|
||||||
class Update < Command
|
class Update < Command
|
||||||
self.summary = 'Update the software.'
|
self.summary = 'Update the software.'
|
||||||
# TODO make more elaborate
|
|
||||||
# self.description = '...'
|
|
||||||
|
|
||||||
def self.options
|
def self.options
|
||||||
[
|
[
|
||||||
@@ -65,12 +64,6 @@ module Motion; class Command
|
|||||||
Motion::Version
|
Motion::Version
|
||||||
end
|
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)
|
def curl(cmd)
|
||||||
resp = `/usr/bin/curl --connect-timeout 60 #{cmd}`
|
resp = `/usr/bin/curl --connect-timeout 60 #{cmd}`
|
||||||
if $?.exitstatus != 0
|
if $?.exitstatus != 0
|
||||||
@@ -89,7 +82,7 @@ module Motion; class Command
|
|||||||
|
|
||||||
latest_version, message = File.read(update_check_file).split('|', 2)
|
latest_version, message = File.read(update_check_file).split('|', 2)
|
||||||
message ||= ''
|
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
|
message = "A new version of RubyMotion is available. Run `sudo motion update' to upgrade.\n" + message
|
||||||
end
|
end
|
||||||
message.strip!
|
message.strip!
|
||||||
|
|||||||
Reference in New Issue
Block a user