Module: Dapp::Dapp::Shellout::Base
Class Method Summary collapse
Instance Method Summary collapse
- #shellout(*args, **kwargs) ⇒ Object
- #shellout!(*args, **kwargs) ⇒ Object
- #shellout_pack(command) ⇒ Object
Class Method Details
.default_env_keys ⇒ Object
45 46 47 |
# File 'lib/dapp/dapp/shellout/base.rb', line 45 def default_env_keys @default_env_keys ||= [] end |
.included(base) ⇒ Object
41 42 43 |
# File 'lib/dapp/dapp/shellout/base.rb', line 41 def included(base) base.extend(self) end |
Instance Method Details
#shellout(*args, **kwargs) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/dapp/dapp/shellout/base.rb', line 7 def shellout(*args, **kwargs) env = nil Base.default_env_keys.each do |env_key| env_key = env_key.to_s.upcase env ||= {} env[env_key] = ENV[env_key] end param_env = (kwargs.delete(:env) || kwargs.delete(:environment)) param_env = param_env.map { |key, value| [key.to_s.upcase, value.to_s] }.to_h if param_env env = (env || {}).merge(param_env) if param_env kwargs[:env] = env if env do_shellout = -> { ::Mixlib::ShellOut.new(*args, timeout: 3600, **kwargs).run_command } if defined? ::Bundler ::Bundler.with_clean_env { do_shellout.call } else do_shellout.call end end |
#shellout!(*args, **kwargs) ⇒ Object
30 31 32 33 34 |
# File 'lib/dapp/dapp/shellout/base.rb', line 30 def shellout!(*args, **kwargs) shellout_with_logging(**kwargs) do || shellout(*args, **).tap(&:error!) end end |
#shellout_pack(command) ⇒ Object
36 37 38 |
# File 'lib/dapp/dapp/shellout/base.rb', line 36 def shellout_pack(command) "eval $(echo #{Base64.strict_encode64(command)} | base64 --decode)" end |