Sha256: 46e0c1a864d5fad9ffe6bcfc2d28e983821711c9afb2c41c31119e25dcf3deca

Contents?: true

Size: 1.55 KB

Versions: 1

Compression:

Stored size: 1.55 KB

Contents

module Gatling
 module Configuration

    class << self

      attr_accessor :reference_image_path, :trainer_toggle

      attr_reader :paths

      def reference_image_path
        @reference_image_path ||= set_default_path
      end

      def paths
        Hash[reference:reference_image_path,
        candidate:File.join(reference_image_path, 'candidate'),
        diff:File.join(reference_image_path, 'diff'),
        temp:File.join(reference_image_path, 'temp')]
      end

      def trainer_toggle
        @trainer_value = ENV['GATLING_TRAINER']

        case @trainer_value
          when nil
            @trainer_value = nil
          when 'true'
            @trainer_value = true
          when 'false'
            @trainer_value = false
          else
            @trainer_value = false
            puts 'Unknown GATLING_TRAINER argument. Please supply true, false or nil. DEFAULTING TO FALSE'
        end
        @trainer_toggle ||= @trainer_value ||= false
      end

      def path_from_type(type)
        if paths.keys.include? type
          return paths[type]
        else
          raise "Unkown image type '#{type}'"
        end
      end

      private

      def set_default_path
        begin
        @reference_image_path ||= File.join(Rails.root, 'spec/reference_images')
        rescue
          @reference_image_path = 'spec/reference_images'
          puts "Currently defaulting to #{@reference_image_path}. Overide this by setting Gatling::Configuration.reference_image_path=[refpath]"
        end
        @reference_image_path
      end
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gatling-1.0.7 lib/gatling/config.rb