Class: Apadmi::Grout::FilenameUtils

Inherits:
Object
  • Object
show all
Defined in:
lib/apadmi/grout/utils/filename_utils.rb

Overview

Generic Filename Utils

Class Method Summary collapse

Class Method Details

.binary_output_filename(options = {}) ⇒ String

Constructs a standard Apadmi filename for a build output binary

Parameters:

  • options (Hash) (defaults to: {})

    the options to create a filename with

Options Hash (options):

  • :client_name (String)

    The client name

  • :product_name (String)

    The product name

  • :platform (String)

    The product's platform

  • :version (String)

    Version number

  • :build_number (String)

    Build number

  • :data (String) — default: Today

    The date for the file

  • :suffix (String)

    Suffix to identify what this output is (e.g. SOURCE, UAT, QA, DEV)

Returns:

  • (String)

    A filename formatted such as “Apadmi-Grout-Ruby-v1.0.0(2921)-2021-06-22-DEV”



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/apadmi/grout/utils/filename_utils.rb', line 17

def self.binary_output_filename(options = {})
  client_name = options[:client_name]
  raise ":client_name shouldn't be empty" if client_name.blank?

  product_name = options[:product_name]
  raise ":product_name shouldn't be empty" if product_name.blank?

  platform = options[:platform]
  raise ":platform shouldn't be empty" if platform.blank?

  version = options[:version]
  raise ":version shouldn't be empty" if version.blank?

  build_number = options[:build_number]
  raise ":build_number shouldn't be empty" if build_number.blank?

  date = options[:date] || Time.now.strftime("%Y-%m-%d")
  suffix = ("-#{options[:suffix]}" unless options[:suffix].blank?) || ""

  "#{client_name}-#{product_name}-#{platform}-v#{version}(#{build_number})-#{date}#{suffix}"
end