Module: Scripter::EnvVariables

Included in:
Base
Defined in:
lib/scripter/env_variables.rb

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(receiver) ⇒ Object



5
6
7
# File 'lib/scripter/env_variables.rb', line 5

def self.included(receiver)
  receiver.extend ClassMethods
end

Instance Method Details

#raw_env_variablesObject



24
25
26
27
28
29
30
31
32
33
# File 'lib/scripter/env_variables.rb', line 24

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) ⇒ Object

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



37
38
39
40
41
42
43
44
45
46
# File 'lib/scripter/env_variables.rb', line 37

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