Sha256: da38167223a7dba67bd64f37b055d35a7536e7081111f501d727d28d45e0cc4e

Contents?: true

Size: 1.5 KB

Versions: 10

Compression:

Stored size: 1.5 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
      if ENV['DRB_LOGGER_URI']
        return @@logger ||= DRbObject.new_with_uri(ENV['DRB_LOGGER_URI'])
      end
      
      return @@logger ||= Logger.new
    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
      File.path("#{Henry::Environment.config['output_directory']}/output" || DEFAULT_OUTPUT_DIRECTORY)
    end

  end

end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
henry-container-0.1.75 lib/henry/environment.rb
henry-container-0.1.74 lib/henry/environment.rb
henry-container-0.1.73 lib/henry/environment.rb
henry-container-0.1.72 lib/henry/environment.rb
henry-container-0.1.71 lib/henry/environment.rb
henry-container-0.1.70 lib/henry/environment.rb
henry-container-0.1.69 lib/henry/environment.rb
henry-container-0.1.68 lib/henry/environment.rb
henry-container-0.1.67 lib/henry/environment.rb
henry-container-0.1.66 lib/henry/environment.rb