Class: Zillabyte::Command::Download
- Defined in:
- lib/zillabyte/cli/download.rb
Overview
HIDDEN: downloads the zillabyte openGMB jar
Constant Summary collapse
- MIN_LOCAL_JAR_VERSION =
"0.0.3"
- LATEST_JAR_VERSION =
"0.9.41"
- MIN_JAVA_VERSION =
"1.7.0"
Constants inherited from Base
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#jar(local = false) ⇒ Object
–local # HIDDEN.
Methods inherited from Base
Methods included from Helpers
#app, #ask, #command, #create_git_remote, #display, #error, #extract_app_from_git_config, #extract_app_in_dir, #format_with_bang, #friendly_dir, #get_flow_ui_link, #get_info, #get_rich_info, #git, #handle_downloading_manifest, #has_git?, #longest, #read_multiline, #truncate_message, #version_okay?, #with_tty
Constructor Details
This class inherits a constructor from Zillabyte::Command::Base
Instance Method Details
#jar(local = false) ⇒ Object
–local # HIDDEN
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/zillabyte/cli/download.rb', line 12 def jar(local = false) local = true if [:local] # Check that java exists display "Checking Java Runtime Environment version..." java_version = `java -version 2>&1` match = /(\d+\.\d+\.\d+)/.match(java_version) if match java_version = match.captures.first display "JRE #{java_version} found." if !version_okay?(java_version, MIN_JAVA_VERSION) display "Your version of the Java Runtime Environment, #{java_version}, is incompatible with the Zillabyte jar. Please install JRE version > #{MIN_JAVA_VERSION}. JRE 1.7 can be downloaded from http://www.oracle.com/technetwork/java/javase/downloads/jre7-downloads-1880261.html." return end else display "Java Runtime Environment not found. Please install JRE version > #{MIN_JAVA_VERSION}. JRE 1.7 can be downloaded from http://www.oracle.com/technetwork/java/javase/downloads/jre7-downloads-1880261.html." return end # Create the jar home if it doesn't exist require ('fileutils') jar_home = "#{Dir.home}/.zillabyte/jars" FileUtils.mkdir_p(jar_home) # Check the jar version jars = Dir.glob("#{jar_home}/*.jar") current_jar_version = "0.0.0" if local # For zb engineers: use dev open_gmb jar from local repo # Delete old jar(s) FileUtils.rm_rf("#{jar_home}/.", secure: true) if !jars.empty? # Copy new jar from gmb `cp ~/zb1/motherbrain/target/#{LATEST_JAR_VERSION}.jar #{jar_home}` current_jar_version = LATEST_JAR_VERSION else if !jars.empty? current_jar_version = /^(\d+\.\d+\.\d+)\.jar$/.match(jars.first.split("/").last).captures.first display "Found Zillabyte jar version #{current_jar_version}." end if jars.size > 1 or !version_okay?(current_jar_version, MIN_LOCAL_JAR_VERSION) # delete the old jar(s) FileUtils.rm_rf("#{jar_home}/.", secure: true) if !jars.empty? # download the new jar display "The Zillabyte jar was not found or your jar is outdated. Downloading the latest Zillabyte local jar..." `cd #{jar_home} && curl -O https://s3.amazonaws.com/downloads.zillabyte.com/#{LATEST_JAR_VERSION}.jar` error("Jar download failed! (Attempted to download to ~/.zillabyte/jars/)") if !File.exists? "#{jar_home}/#{LATEST_JAR_VERSION}.jar" current_jar_version = LATEST_JAR_VERSION end end # Return the jar path "#{jar_home}/#{current_jar_version}.jar" end |