Sha256: b542adc112222aa7588c56e965f3c1dad7db55fbce6e50c1ad415c3c3ba877ae

Contents?: true

Size: 842 Bytes

Versions: 3

Compression:

Stored size: 842 Bytes

Contents

module CommandKit
  #
  # Provides access to environment variables.
  #
  # ## Examples
  #
  #     class MyCmd
  #       include CommandKit::Env
  #
  #       def main
  #         home = env['HOME']
  #         # ...
  #       end
  #     end
  #
  # ## Testing
  #
  # Can be initialized with a custom `env` hash for testing purposes.
  #
  #     MyCmd.new(env: {...})
  #
  module Env
    # The environment variables hash.
    #
    # @return [Hash{String => String}]
    attr_reader :env

    #
    # Initializes {#env}.
    #
    # @param [Hash{String => String}] env
    #   The given environment for the command. Defaults to the global `ENV`.
    #
    # @param [Hash{Symbol => Object}] kwargs
    #   Additional keyword arguments.
    #
    def initialize(env: ENV, **kwargs)
      @env = env

      super(**kwargs)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
command_kit-0.1.0.rc1 lib/command_kit/env.rb
command_kit-0.1.0.pre2 lib/command_kit/env.rb
command_kit-0.1.0.pre1 lib/command_kit/env.rb