Sha256: 4d7d21a0e80690de60775f50c1f120ceb8563cf85aa0db189ad91b213886133f

Contents?: true

Size: 1.04 KB

Versions: 4

Compression:

Stored size: 1.04 KB

Contents

module DeepTest
  module Distributed
    class ShellEnvironment
      def self.like_login
        login_env = new
        login_env.include_first '/etc/profile'
        login_env.include_first '~/.profile', '~/.bash_profile',  '~/.bashrc'
        login_env
      end

      def initialize
        @source_file_lists = []
      end

      def include_first(*filenames)
        source_file_lists << SourceFileList.new(filenames)
      end

      def to_s
        source_file_lists.join(" && ")
      end

      def ==(other)
        source_file_lists == other.source_file_lists
      end

      attr_reader :source_file_lists
      protected :source_file_lists

      class SourceFileList
        def initialize(filenames)
          @filenames = filenames
        end

        def to_s
          "if" + 
          filenames.map {|f| " [[ -f #{f} ]]; then . #{f}; "}.join("elif") +
          "fi"
        end

        def ==(other)
          filenames == other.filenames
        end

        attr_reader :filenames
        protected :filenames
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
deep_test_pre-2.0 lib/deep_test/distributed/shell_environment.rb
jstorimer-deep-test-2.0.0 lib/deep_test/distributed/shell_environment.rb
jstorimer-deep-test-0.2.0 lib/deep_test/distributed/shell_environment.rb
jstorimer-deep-test-0.1.0 lib/deep_test/distributed/shell_environment.rb