Sha256: e886bb5de48bb1a3525924fa99d67aea057e4e8df812c5ef305d5c6061c03173

Contents?: true

Size: 1.6 KB

Versions: 2

Compression:

Stored size: 1.6 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|
            reviews = processor.processReviews(reviews, platform)
        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.6 lib/Models/ReviewFetcher.rb
ZReviewTender-1.3.5 lib/Models/ReviewFetcher.rb