Module: DataShifter::Internal::Env

Defined in:
lib/data_shifter/internal/env.rb

Overview

Environment variable parsing utilities. All methods are stateless module functions.

Class Method Summary collapse

Class Method Details

.continue_from_idObject

Get CONTINUE_FROM environment variable value. Returns nil if not set or empty.



35
36
37
# File 'lib/data_shifter/internal/env.rb', line 35

def continue_from_id
  ENV.fetch("CONTINUE_FROM", nil).presence
end

.dry_run?Boolean

Determine dry_run mode from environment variables. COMMIT=1 or COMMIT=true means dry_run=false DRY_RUN=false means dry_run=false; default is true

Returns:

  • (Boolean)


13
14
15
16
17
18
19
# File 'lib/data_shifter/internal/env.rb', line 13

def dry_run?
  if ENV["COMMIT"].present?
    !%w[1 true].include?(ENV["COMMIT"].to_s.downcase)
  else
    ENV.fetch("DRY_RUN", "true") == "true"
  end
end

.status_interval_secondsObject

Parse STATUS_INTERVAL environment variable, falling back to config. Returns nil if not set/invalid and config is nil.



23
24
25
26
27
28
29
30
31
# File 'lib/data_shifter/internal/env.rb', line 23

def status_interval_seconds
  if ENV["STATUS_INTERVAL"].present?
    Integer(ENV.fetch("STATUS_INTERVAL", nil), 10)
  else
    DataShifter.config.status_interval_seconds
  end
rescue ArgumentError
  DataShifter.config.status_interval_seconds
end