class Jack::VersionChecker

Constants

REQUIRED_VERSION

Public Instance Methods

check() click to toggle source
# File lib/jack/version_checker.rb, line 11
def check
  major, minor, patch = version_parts(parsed_version)
  r_major, r_minor, r_patch = version_parts(REQUIRED_VERSION)
  (major > r_major) ||
  (major == r_major && minor > r_minor) ||
  (major == r_major && minor == r_minor && patch >= r_patch)
end
get_version() click to toggle source
# File lib/jack/version_checker.rb, line 19
def get_version
  `#{eb_bin} --version`
end
install_instructions() click to toggle source
# File lib/jack/version_checker.rb, line 51
def install_instructions
  if RUBY_PLATFORM =~ /darwin/
    "You can install the eb tool via homebrew:\n\nbrew install awsebcli"
  else
    "Installation instructions: http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/eb-cli3-install.html"
  end
end
leave(message) click to toggle source

for specs

# File lib/jack/version_checker.rb, line 60
def leave(message)
  puts(message)
  exit 0
end
not_installed() click to toggle source
# File lib/jack/version_checker.rb, line 36
def not_installed
  message = "Unable to detect an installation of the eb cli tool. Please install the eb tool.\n\n"
  message << install_instructions
  message
end
parse_version(version) click to toggle source
# File lib/jack/version_checker.rb, line 27
def parse_version(version)
  parsed = version.match(/EB CLI (\d+\.\d+\.\d+)/)[1]
end
parsed_version() click to toggle source
# File lib/jack/version_checker.rb, line 23
def parsed_version
  @parsed_version ||= parse_version(get_version)
end
run() click to toggle source
# File lib/jack/version_checker.rb, line 6
def run
  leave(not_installed) if eb_bin == ""
  leave(version_too_low) unless check
end
version_parts(parsed) click to toggle source
# File lib/jack/version_checker.rb, line 32
def version_parts(parsed)
  parsed.split('.').collect(&:to_i)
end
version_too_low() click to toggle source
# File lib/jack/version_checker.rb, line 42
    def version_too_low
      <<~EOS
        Unable to detect a version of the eb cli tool that works with jack.
        Detected version #{parsed_version}.

        #{install_instructions}
      EOS
    end