Module: Idlc::Utility

Includes:
Helpers
Defined in:
lib/idlc-sdk-core/utility.rb

Defined Under Namespace

Classes: MissingCredentials, MissingVersionFile

Class Method Summary collapse

Methods included from Helpers

debug, err, msg, stderr, stdout, system_command

Class Method Details

.check_for_credsObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/idlc-sdk-core/utility.rb', line 9

def check_for_creds
  creds_fmt = {
    'AWS_ACCESS_ID' => 'AWS_ACCESS_KEY_ID',
    'AWS_SECRET_KEY' => 'AWS_SECRET_ACCESS_KEY'
  }
  creds_fmt.each do |old_fmt, new_fmt|
    if ENV.include? new_fmt
      next
    elsif ENV.include?(old_fmt) && !ENV.include?(new_fmt)
      ENV[new_fmt] = ENV[old_fmt]
    elsif !ENV.include?(old_fmt) || !ENV.include?(new_fmt)
      raise MissingCredentials, "#{new_fmt} is not set."
    end
  end
end

.major_minor(version) ⇒ Object



37
38
39
40
41
# File 'lib/idlc-sdk-core/utility.rb', line 37

def major_minor(version)
  # Strip build number from version number. The migration scripts only include
  # major.minor.patch
  version.split('.')[0..1].join('.')
end

.major_minor_patch(version) ⇒ Object



31
32
33
34
35
# File 'lib/idlc-sdk-core/utility.rb', line 31

def major_minor_patch(version)
  # Strip build number from version number. The migration scripts only include
  # major.minor.patch
  version.split('.')[0..2].join('.')
end

.set_global_version(filename) ⇒ Object



25
26
27
28
29
# File 'lib/idlc-sdk-core/utility.rb', line 25

def set_global_version(filename)
  filename = ENV['VERSION_FILE'] if ENV.include? 'VERSION_FILE'
  Idlc::Helpers.debug('WARNING: Not using a global version file') unless File.exist? filename
  YAML.load_file(filename)['version'] if File.exist? filename
end