Module: FeishuNotifier::EnvFile
- Defined in:
- lib/feishu_notifier/env_file.rb
Class Method Summary collapse
Class Method Details
.load(path) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/feishu_notifier/env_file.rb', line 5 def load(path) return unless File.file?(path) File.readlines(path, chomp: true).each do |line| stripped = line.strip next if stripped.empty? || stripped.start_with?("#") key, value = stripped.split("=", 2) next if key.nil? || value.nil? || key.empty? ENV[key] = unquote(value.strip) end end |
.unquote(value) ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/feishu_notifier/env_file.rb', line 19 def unquote(value) if (value.start_with?('"') && value.end_with?('"')) || (value.start_with?("'") && value.end_with?("'")) value[1...-1] else value end end |