Sha256: d52fdf5b9220979b68670f1ef776112e5fe3fa3d4c7abca92f63260a8975966b

Contents?: true

Size: 1.98 KB

Versions: 2

Compression:

Stored size: 1.98 KB

Contents

$lib = File.expand_path('../lib', File.dirname(__FILE__))


require "Processors/SlackProcessor"
require "Models/Processor"
require "time"

class ReviewFetcher

    attr_accessor :config, :platform, :processors, :logger

    def execute()

    end

    def registerProcessor(processor)
        processors.append(processor)
    end

    def processReviews(reviews, platform)
        processors.each do |processor|
            begin
                reviews = processor.processReviews(reviews, platform)
            rescue => e
                errorMessage = "# Processor Error"
                errorMessage += "#Error Message:  #{e.message}\n"
                errorMessage += "#Error Class: #{e.class}\n"
                errorMessage += "#Backtrace Start#\n#{e.backtrace.join("\n")}\n#Backtrace End#\n"
                logger.logError(errorMessage)
            end
        end
    end

    def sendWelcomMessage()
        slackProcessor = processors.find { |processor| processor.is_a?(SlackProcessor) }
        if !slackProcessor.nil?
            slackProcessor.sendWelcomMessage(platform)
        end
    end

    def setSentWelcomeMessage()
        basePath = "#{config.baseExecutePath}/latestCheckTimestamp/"
        Helper.createDirIfNotExist(basePath)
        File.open("#{basePath}/#{platform}Welcome", 'w') { |file| file.write("") }
    end

    def isSentWelcomeMessage()
        filePath = "#{config.baseExecutePath}/latestCheckTimestamp/#{platform}Welcome"
        return File.exists?(filePath)
    end

    def setPlatformLatestCheckTimestamp(timestamp)
        basePath = "#{config.baseExecutePath}/latestCheckTimestamp/"
        Helper.createDirIfNotExist(basePath)
        File.open("#{basePath}/#{platform}", 'w') { |file| file.write(timestamp) }
    end

    def getPlatformLatestCheckTimestamp()
        filePath = "#{config.baseExecutePath}/latestCheckTimestamp/#{platform}"
        if File.exists?(filePath)
            return File.read(filePath).to_i
        else
            return 0
        end
    end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ZReviewTender-1.3.8 lib/Models/ReviewFetcher.rb
ZReviewTender-1.3.7 lib/Models/ReviewFetcher.rb