diff --git a/lib/gold_miner.rb b/lib/gold_miner.rb index 88da9d6..b9e3dbd 100644 --- a/lib/gold_miner.rb +++ b/lib/gold_miner.rb @@ -6,33 +6,33 @@ Zeitwerk::Loader.for_gem.setup -module GoldMiner - extend self - - def mine_in(slack_channel, slack_client: GoldMiner::Slack::Client, env_file: ".env") - Dotenv.load!(env_file) - - prepare(slack_client) - .fmap { |client| explore(slack_channel, client) } - end - - def smith_blog_post(gold_container, ...) - BlogPostSmith.new(...).smith(gold_container) - end - - def distribute(blog_post) - TerminalDistributor.new.distribute(blog_post) - end - - private - - def prepare(slack_client) - slack_client.build(api_token: ENV["SLACK_API_TOKEN"]) - end - - def explore(slack_channel, slack_client) - SlackExplorer - .new(slack_client, AuthorConfig.default) - .explore(slack_channel, start_on: Helpers::Time.last_friday) +class GoldMiner + class << self + def mine_in(slack_channel, slack_client: GoldMiner::Slack::Client, env_file: ".env") + Dotenv.load!(env_file) + + prepare(slack_client) + .fmap { |client| explore(slack_channel, client) } + end + + def smith_blog_post(gold_container, ...) + BlogPostSmith.new(...).smith(gold_container) + end + + def distribute(blog_post) + TerminalDistributor.new.distribute(blog_post) + end + + private + + def prepare(slack_client) + slack_client.build(api_token: ENV["SLACK_API_TOKEN"]) + end + + def explore(slack_channel, slack_client) + SlackExplorer + .new(slack_client, AuthorConfig.default) + .explore(slack_channel, start_on: Helpers::Time.last_friday) + end end end diff --git a/lib/gold_miner/author.rb b/lib/gold_miner/author.rb index 03a06ee..b861f59 100644 --- a/lib/gold_miner/author.rb +++ b/lib/gold_miner/author.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module GoldMiner +class GoldMiner Author = Data.define(:id, :name, :link) do alias_method :to_s, :name diff --git a/lib/gold_miner/author_config.rb b/lib/gold_miner/author_config.rb index fbb1f21..49cb76b 100644 --- a/lib/gold_miner/author_config.rb +++ b/lib/gold_miner/author_config.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module GoldMiner +class GoldMiner class AuthorConfig DEFAULT_AUTHOR_LINK = "#to-do" DEFAULT_CONFIG_PATH = "lib/config/author_config.yml" diff --git a/lib/gold_miner/blog_post.rb b/lib/gold_miner/blog_post.rb index 732d3cf..88ecaf4 100644 --- a/lib/gold_miner/blog_post.rb +++ b/lib/gold_miner/blog_post.rb @@ -2,7 +2,7 @@ require "async" -module GoldMiner +class GoldMiner class BlogPost def initialize(slack_channel:, gold_nuggets:, since:, writer: SimpleWriter.new) @slack_channel = slack_channel diff --git a/lib/gold_miner/blog_post/open_ai_writer.rb b/lib/gold_miner/blog_post/open_ai_writer.rb index c6680bc..557adb0 100644 --- a/lib/gold_miner/blog_post/open_ai_writer.rb +++ b/lib/gold_miner/blog_post/open_ai_writer.rb @@ -2,7 +2,7 @@ require "json" -module GoldMiner +class GoldMiner class BlogPost class OpenAiWriter def initialize(open_ai_api_token:, fallback_writer:, open_ai_client: OpenAI::Client) diff --git a/lib/gold_miner/blog_post/simple_writer.rb b/lib/gold_miner/blog_post/simple_writer.rb index 44c018e..3121001 100644 --- a/lib/gold_miner/blog_post/simple_writer.rb +++ b/lib/gold_miner/blog_post/simple_writer.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module GoldMiner +class GoldMiner class BlogPost class SimpleWriter def initialize(topic_extractor: TopicExtractor) diff --git a/lib/gold_miner/blog_post/simple_writer/topic_extractor.rb b/lib/gold_miner/blog_post/simple_writer/topic_extractor.rb index b576a92..0d12669 100644 --- a/lib/gold_miner/blog_post/simple_writer/topic_extractor.rb +++ b/lib/gold_miner/blog_post/simple_writer/topic_extractor.rb @@ -1,4 +1,4 @@ -module GoldMiner +class GoldMiner class BlogPost class SimpleWriter module TopicExtractor diff --git a/lib/gold_miner/blog_post/writer.rb b/lib/gold_miner/blog_post/writer.rb index 7dbf703..df0ea14 100644 --- a/lib/gold_miner/blog_post/writer.rb +++ b/lib/gold_miner/blog_post/writer.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module GoldMiner +class GoldMiner class BlogPost module Writer def self.from_env diff --git a/lib/gold_miner/blog_post_smith.rb b/lib/gold_miner/blog_post_smith.rb index 81195f4..61ef1e4 100644 --- a/lib/gold_miner/blog_post_smith.rb +++ b/lib/gold_miner/blog_post_smith.rb @@ -1,4 +1,4 @@ -module GoldMiner +class GoldMiner class BlogPostSmith def initialize(blog_post_class: BlogPost, blog_post_writer: BlogPost::Writer.from_env) @blog_post_class = blog_post_class diff --git a/lib/gold_miner/gold_container.rb b/lib/gold_miner/gold_container.rb index efcff20..17381f2 100644 --- a/lib/gold_miner/gold_container.rb +++ b/lib/gold_miner/gold_container.rb @@ -1,3 +1,3 @@ -module GoldMiner +class GoldMiner GoldContainer = Data.define(:gold_nuggets, :origin, :packing_date) end diff --git a/lib/gold_miner/gold_nugget.rb b/lib/gold_miner/gold_nugget.rb index 7434500..3f44ff1 100644 --- a/lib/gold_miner/gold_nugget.rb +++ b/lib/gold_miner/gold_nugget.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module GoldMiner +class GoldMiner GoldNugget = Data.define(:content, :author, :source) do def as_conversation <<~MARKDOWN diff --git a/lib/gold_miner/helpers.rb b/lib/gold_miner/helpers.rb index 315b1f6..80f13f7 100644 --- a/lib/gold_miner/helpers.rb +++ b/lib/gold_miner/helpers.rb @@ -1,4 +1,4 @@ -module GoldMiner +class GoldMiner module Helpers module Time def self.pretty_date(date) diff --git a/lib/gold_miner/slack/client.rb b/lib/gold_miner/slack/client.rb index 8ed3311..25122d0 100644 --- a/lib/gold_miner/slack/client.rb +++ b/lib/gold_miner/slack/client.rb @@ -3,7 +3,7 @@ require "dry/monads" require "slack-ruby-client" -module GoldMiner +class GoldMiner class Slack::Client extend Dry::Monads[:result] diff --git a/lib/gold_miner/slack/message.rb b/lib/gold_miner/slack/message.rb index bd963cd..4584fd3 100644 --- a/lib/gold_miner/slack/message.rb +++ b/lib/gold_miner/slack/message.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module GoldMiner +class GoldMiner module Slack Message = Data.define(:id, :text, :user, :permalink) do alias_method :[], :public_send diff --git a/lib/gold_miner/slack/messages_query.rb b/lib/gold_miner/slack/messages_query.rb index e10413b..e3031a1 100644 --- a/lib/gold_miner/slack/messages_query.rb +++ b/lib/gold_miner/slack/messages_query.rb @@ -1,4 +1,4 @@ -module GoldMiner +class GoldMiner module Slack class MessagesQuery attr_reader :channel, :start_date, :topic, :reaction diff --git a/lib/gold_miner/slack/user.rb b/lib/gold_miner/slack/user.rb index 60d5fbd..c2b7882 100644 --- a/lib/gold_miner/slack/user.rb +++ b/lib/gold_miner/slack/user.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module GoldMiner +class GoldMiner module Slack User = Data.define(:id, :name, :username) end diff --git a/lib/gold_miner/slack_explorer.rb b/lib/gold_miner/slack_explorer.rb index 470e09a..89de85b 100644 --- a/lib/gold_miner/slack_explorer.rb +++ b/lib/gold_miner/slack_explorer.rb @@ -1,6 +1,6 @@ require "async" -module GoldMiner +class GoldMiner class SlackExplorer def initialize(slack_client, author_config) @slack = slack_client diff --git a/lib/gold_miner/terminal_distributor.rb b/lib/gold_miner/terminal_distributor.rb index 2c4f9a8..ffb10c7 100644 --- a/lib/gold_miner/terminal_distributor.rb +++ b/lib/gold_miner/terminal_distributor.rb @@ -1,4 +1,4 @@ -module GoldMiner +class GoldMiner class TerminalDistributor def distribute(blog_post) puts blog_post diff --git a/lib/gold_miner/version.rb b/lib/gold_miner/version.rb index 7420a40..c9c1cd2 100644 --- a/lib/gold_miner/version.rb +++ b/lib/gold_miner/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true -module GoldMiner +class GoldMiner VERSION = "0.1.0" end