class DevTrainingBot::TopicService

Constants

OPEN_TOPICS_REGEX
TOPIC_ITEM_REGEX

Public Class Methods

new(drive_service) click to toggle source
# File lib/dev_training_bot/services/topic_service.rb, line 6
def initialize(drive_service)
  @drive_service = drive_service
end

Public Instance Methods

content() click to toggle source
# File lib/dev_training_bot/services/topic_service.rb, line 15
def content
  @content ||= @drive_service.export_file(ENV['FILE_ID'], 'text/plain', download_dest: StringIO.new)
end
empty?() click to toggle source
# File lib/dev_training_bot/services/topic_service.rb, line 37
def empty?
  topics.empty?
end
to_poll(exclude: []) click to toggle source
# File lib/dev_training_bot/services/topic_service.rb, line 10
def to_poll(exclude: [])
  return '' if empty?
  "\"#{topics.reject { |topic| topic.author.in?(exclude) }.first(10).join('" "')}\""
end
topics() click to toggle source

Returns a list of topics from a string in the following format:

Open Topics

  • David: Browser rendering optimization: how to get silky smooth animations

  • David: The JS Event Loop: what nightmares are made of

  • David: RxJS: Observing the death of Promises

  • David: Intro to vim

  • Mo: Ansible

  • Julio: CSI:RMD Reading error reports like a $BOSS

  • Anthony: SAML

  • Jimmi: Gang of Four Design Patterns in Ruby (possibly in different parts)

@return [string]

# File lib/dev_training_bot/services/topic_service.rb, line 33
def topics
  @topics ||= import.map { |topic| Topic.parse(topic) }
end

Private Instance Methods

import() click to toggle source
# File lib/dev_training_bot/services/topic_service.rb, line 43
def import
  list = content.string[OPEN_TOPICS_REGEX].scan(TOPIC_ITEM_REGEX)
  return [] if list.all?(&:empty?)
  list.sort
end