Class: Backup::Environment
- Inherits:
-
Object
- Object
- Backup::Environment
- Defined in:
- lib/backup/environment.rb
Overview
Reads and filters the user’s environment variables to meet Ruby and Gem requirements to run the application as a cron job
Constant Summary collapse
- VARIABLES =
Contains the environment variable names that are required to run a Ruby application from as a cron job
["RVM_BIN_PATH", "GEM_HOME", "SHELL", "MY_RUBY_HOME", "USER", "RVM_PATH", "RVM_PREFIX", "PATH", "RVM_VERSION", "HOME", "LOGNAME", "GEM_PATH", "RUBY_VERSION"]
Class Method Summary collapse
-
.ruby ⇒ Object
Retrieves the environment variables that are required running a Ruby application as a cron job.
Class Method Details
.ruby ⇒ Object
Retrieves the environment variables that are required running a Ruby application as a cron job. The variable are returned in an Array
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/backup/environment.rb', line 25 def self.ruby file = ".current_environment.tmp" system ("env > #{file}") lines = [] File.open(file, 'r') do |f| while line = f.gets variable = line.chomp.match(/\A\w+(?=\=)/).to_s lines << line.chomp if VARIABLES.find_index variable.upcase end end File.delete file lines end |