Class: Eye::Dsl::PureOpts
- Inherits:
-
Object
- Object
- Eye::Dsl::PureOpts
- Defined in:
- lib/eye-userenv/extend_eye.rb
Instance Method Summary collapse
Instance Method Details
#set_user_env_from(opts = {}) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/eye-userenv/extend_eye.rb', line 11 def set_user_env_from(opts={}) raise Eye::Dsl::Error, "Missing uid and/or env_file option" unless opts.has_key?(:uid) || opts.has_key?(:env_file) infos = Etc.getpwnam opts[:uid] file_path = File.join(infos.dir, opts[:env_file]) envs = IO.read(file_path).lines.inject({}) do |out, line| if result = /(?<key>\p{Word}*)=(?<value>.*)/.match(line) out[result['key']] = result['value'] end out end env envs end |