Sha256: 6fd1ae92febcbe95f1a7f99de428ecbe70ab2898938d5772969faa6e29e585a5

Contents?: true

Size: 1.41 KB

Versions: 13

Compression:

Stored size: 1.41 KB

Contents

require 'drb/drb'
require 'fileutils'
require 'json'
require 'colorize'

require 'henry/input'
require 'henry/logger'
require 'henry/logger_service'

module Henry

  # Henry Environmet.
  # To be used as proxy to access the Task execution params from the tests
  class Environment

    # The path to the default file export directory
    #
    # @return [String]
    DEFAULT_OUTPUT_DIRECTORY = ".output"

    def self.config
      @@config ||= Henry::Config.import!.params 
    end

    # Imports and returs the Task execution parameters.
    # 
    # @return [Hash] the Task execution parameters
    def self.params
      @@params ||= Input.import!.params 
    end

    # Gets the Task Logger instance vis DBr.
    #
    # @return [Logger] the Task Logger instance.
    def self.logger
      Logger.new
      #return DRbObject.new_with_uri(LoggerService::DRB_URI)
    end

    # Copies the file from the given path to the default export directory
    #
    # @param [String] path the path of the file to be exported.
    def self.export_file(path)
      FileUtils.mkdir_p(Henry::Environment.output_path)
      FileUtils.copy_file(path, "#{Henry::Environment.output_path}/#{File.basename(path)}")
    end

    # Returns the current output path for attachments.
    #
    # @param [String] the attachments path.
    def self.output_path
      "#{Henry::Environment.config['output_directory']}/output" || DEFAULT_OUTPUT_DIRECTORY
    end

  end

end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
henry-container-0.1.65 lib/henry/environment.rb
henry-container-0.1.61 lib/henry/environment.rb
henry-container-0.1.60 lib/henry/environment.rb
henry-container-0.1.59 lib/henry/environment.rb
henry-container-0.1.58 lib/henry/environment.rb
henry-container-0.1.57 lib/henry/environment.rb
henry-container-0.1.56 lib/henry/environment.rb
henry-container-0.1.55 lib/henry/environment.rb
henry-container-0.1.54 lib/henry/environment.rb
henry-container-0.1.53 lib/henry/environment.rb
henry-container-0.1.52 lib/henry/environment.rb
henry-container-0.1.51 lib/henry/environment.rb
henry-container-0.1.50 lib/henry/environment.rb