Sha256: 1c93c740813f96b8a5fdb77d96412d338395eb70530abaa54f2c184d6746b579

Contents?: true

Size: 427 Bytes

Versions: 9

Compression:

Stored size: 427 Bytes

Contents

# frozen_string_literal: true

require "securerandom"

module Helpers
  module_function

  def strip_str_and_validate(str)
    return str if str.nil?

    str = str.strip
    str.empty? ? nil : str
  end

  def random_four_digits
    SecureRandom.random_number(1000..9999)
  end

  def normalize_command_name(name)
    name.to_s.tr("_", "-")
  end

  def normalize_option_name(name)
    "--#{name.to_s.tr('_', '-')}"
  end
end

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
cpflow-4.1.0 lib/core/helpers.rb
cpflow-4.0.1 lib/core/helpers.rb
cpflow-4.0.0 lib/core/helpers.rb
cpflow-3.0.1 lib/core/helpers.rb
cpflow-3.0.0 lib/core/helpers.rb
cpl-2.2.4 lib/core/helpers.rb
cpl-2.2.2 lib/core/helpers.rb
cpl-2.2.1 lib/core/helpers.rb
cpl-2.2.0 lib/core/helpers.rb