module Scripter::EnvVariables

Public Class Methods

included(receiver) click to toggle source
# File lib/scripter/env_variables.rb, line 4
def self.included(receiver)
  receiver.extend ClassMethods
end

Public Instance Methods

raw_env_variables() click to toggle source
# File lib/scripter/env_variables.rb, line 23
def raw_env_variables
  @raw_env_variables ||= begin
    raw_env_variables = command_line_arguments.select{|arg| arg.include?('=')}.map do |arg|
      key, value = arg.split("=")
      nomalized_key = key.downcase.to_sym
      [nomalized_key, value]
    end
    Hash[raw_env_variables]
  end
end
type_cast_env_variable(name, value) click to toggle source

You can override this method in order to add additional typecasts for custom params, but don’t forget to call super in else block of your switch statement

# File lib/scripter/env_variables.rb, line 36
def type_cast_env_variable(name, value)
  case name
  when :date
    ::Date.parse(value, false) unless value.to_s.empty?
  when :dry_run, :force_run, :use_cache
    !value.to_s.empty?
  else
    value
  end
end

Private Instance Methods

command_line_arguments() click to toggle source
# File lib/scripter/env_variables.rb, line 49
def command_line_arguments
  @command_line_arguments ||= ARGV
end