Class: ReviewFetcher

Inherits:
Object
  • Object
show all
Defined in:
lib/Models/ReviewFetcher.rb

Direct Known Subclasses

AndroidFetcher, AppleFetcher

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#configObject

Returns the value of attribute config.



11
12
13
# File 'lib/Models/ReviewFetcher.rb', line 11

def config
  @config
end

#loggerObject

Returns the value of attribute logger.



11
12
13
# File 'lib/Models/ReviewFetcher.rb', line 11

def logger
  @logger
end

#platformObject

Returns the value of attribute platform.



11
12
13
# File 'lib/Models/ReviewFetcher.rb', line 11

def platform
  @platform
end

#processorsObject

Returns the value of attribute processors.



11
12
13
# File 'lib/Models/ReviewFetcher.rb', line 11

def processors
  @processors
end

Instance Method Details

#executeObject



13
14
15
# File 'lib/Models/ReviewFetcher.rb', line 13

def execute()

end

#getPlatformLatestCheckTimestampObject



59
60
61
62
63
64
65
66
# File 'lib/Models/ReviewFetcher.rb', line 59

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

#isSentWelcomeMessageObject



48
49
50
51
# File 'lib/Models/ReviewFetcher.rb', line 48

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

#processReviews(reviews, platform) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/Models/ReviewFetcher.rb', line 21

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

#registerProcessor(processor) ⇒ Object



17
18
19
# File 'lib/Models/ReviewFetcher.rb', line 17

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

#sendWelcomMessageObject



35
36
37
38
39
40
# File 'lib/Models/ReviewFetcher.rb', line 35

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

#setPlatformLatestCheckTimestamp(timestamp) ⇒ Object



53
54
55
56
57
# File 'lib/Models/ReviewFetcher.rb', line 53

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

#setSentWelcomeMessageObject



42
43
44
45
46
# File 'lib/Models/ReviewFetcher.rb', line 42

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