Module: CommandKit::Env
- Defined in:
- lib/command_kit/env.rb,
lib/command_kit/env/home.rb,
lib/command_kit/env/path.rb
Overview
Provides access to environment variables.
Examples
class MyCmd
include CommandKit::Env
def run
home = env['HOME']
# ...
end
end
Testing
Can be initialized with a custom env
hash for testing purposes.
MyCmd.new(env: {...})
Defined Under Namespace
Instance Attribute Summary collapse
-
#env ⇒ Hash{String => String}
readonly
The environment variables hash.
Instance Method Summary collapse
-
#initialize(env: ENV, **kwargs) ⇒ Object
Initializes #env.
Instance Attribute Details
#env ⇒ Hash{String => String} (readonly)
The environment variables hash.
28 29 30 |
# File 'lib/command_kit/env.rb', line 28 def env @env end |
Instance Method Details
#initialize(env: ENV, **kwargs) ⇒ Object
Initializes #env.
41 42 43 44 45 |
# File 'lib/command_kit/env.rb', line 41 def initialize(env: ENV, **kwargs) @env = env super(**kwargs) end |