Sha256: bf441caabb0d6ae4c82d82eb77616eb73a7ea066df43ec8fad828ab2f4576504

Contents?: true

Size: 931 Bytes

Versions: 18

Compression:

Stored size: 931 Bytes

Contents

module Jack
  class VersionChecker
    REQUIRED_VERSION = "3.1.2"

    def run
      leave("eb cli tool is not installed") unless system("type eb > /dev/null 2>&1")
      leave("eb version is too low") unless check
    end

    def check
      major, minor, patch = parse_version(get_version)
      r_major, r_minor, r_patch = normalize_version(REQUIRED_VERSION)
      (major > r_major) ||
      (major == r_major && minor > r_minor) ||
      (major == r_major && minor == r_minor && patch >= r_patch)
    end

    def get_version
      `eb --version`
    end

    def parse_version(version)
      parsed = version.match(/EB CLI (\d+\.\d+\.\d+)/)[1]
      normalize_version(parsed)
    end

    def normalize_version(parsed)
      parsed.split('.').collect(&:to_i)
    end

    # for specs
    def leave(message='')
      puts("SORRY: #{message}, please install at least version #{REQUIRED_VERSION}")
      exit 0
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
jack-eb-1.0.0 lib/jack/version_checker.rb
jack-eb-0.3.0 lib/jack/version_checker.rb
jack-eb-0.2.0 lib/jack/version_checker.rb
jack-eb-0.1.6 lib/jack/version_checker.rb
jack-eb-0.1.5 lib/jack/version_checker.rb
jack-eb-0.1.4 lib/jack/version_checker.rb
jack-eb-0.1.3 lib/jack/version_checker.rb
jack-eb-0.1.2 lib/jack/version_checker.rb
jack-eb-0.1.1 lib/jack/version_checker.rb
jack-eb-0.1.0 lib/jack/version_checker.rb
jack-eb-0.0.9 lib/jack/version_checker.rb
jack-eb-0.0.8 lib/jack/version_checker.rb
jack-eb-0.0.7 lib/jack/version_checker.rb
jack-eb-0.0.6 lib/jack/version_checker.rb
jack-eb-0.0.4 lib/jack/version_checker.rb
jack-eb-0.0.3 lib/jack/version_checker.rb
jack-eb-0.0.2 lib/jack/version_checker.rb
jack-eb-0.0.1 lib/jack/version_checker.rb