Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

プラグイン構成要素別に基底モジュールを作成・整理 #154

Merged
merged 53 commits into from
Aug 5, 2019

Conversation

koi-chan
Copy link
Member

@koi-chan koi-chan commented Jul 24, 2019

fix #133, #75

機能的にひと段落したので、このあたりで master にマージしたいと思います。

プラグイン構成要素であるアダプタ(IRC用・Discord用)とジェネレータそれぞれのための、基底クラス的なモジュールを作成しました。
また、既存のプラグインも、今回作成した基底モジュールを使うように変更しました。
作成した基底モジュールは以下の通りです。

  • Adapter
    • IrcAdapter
    • DiscordAdapter
  • Generator

同時に、issue #132 を解決しています。
プラグインアダプタに与える設定に、起動時に指定される設定 ID を追加したうえで、設定を一つの構造体にまとめました。

koi-chan and others added 26 commits July 18, 2019 10:32
Util::NoticeOnEachChannel#notice_on_each_channel メソッドに相当する機能を、IrcPlugin#send_notice メソッドに統合した。
これで、NOTICE コマンド関連の全てのメソッドは、IrcPlugin#send_notice メソッドだけを呼び出せば良いようになった。
* case を使うときに Object#class メソッドを使わないようにした
* param == Klass を、param.kind_of?(Klass) にした
各プラグインのアダプタークラスで ConfigurableAdapter モジュールを MIX-IN する必要がなくなった。
* lib/rgrb/plugin/cre_twitter_citation/generator.rb
* lib/rgrb/plugin/random_generator/generator.rb
* lib/rgrb/plugin/server_connection_report/mail_generator.rb
* lib/rgrb/plugin/trpg/detatoko/generator.rb
テストのために毎回無駄なインスタンス化を行なっている
…struct-plugin-configs

アダプターの設定を渡すオブジェクトを Hash から Struct に変更
…namespace-and-path

モジュール本体の名前空間・ファイルパスを変更
@koi-chan koi-chan changed the title プラグイン構成要素別ni基底モジュールを作成 プラグイン構成要素別に基底モジュールを作成・整理 Jul 24, 2019
@koi-chan koi-chan self-assigned this Jul 24, 2019
@koi-chan koi-chan added this to the v1.1.0 milestone Jul 24, 2019
Copy link
Member

@ochaochaocha3 ochaochaocha3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

全体を確認しました。各問題が解決されたので、大丈夫だと思います。

super

@version_and_commit_id = get_version_and_commit_id
logger.warn("BCDice を読み込みました: #{bcdice_version}")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

各問題を解決したので大丈夫だと思っていましたが、テストを実行するとここの loggernil になっているためにエラーとなるようです(initialize 前に logger を設定できないため)。このタイミングでのログ記録はなかなか難しそうです…

@koi-chan koi-chan force-pushed the arrange-plugin-adapter-module branch from aa2bb0a to d3f88da Compare July 27, 2019 03:16
@ochaochaocha3
Copy link
Member

あとは #155 (comment) の内容で一回PR作ります。それがうまく動いたらこれをマージして、続いて #155 のリトライができそうです。

テストを簡潔に書けるようにする。
また、共通のロガーを用意することで、プラグインごとにロガーを
作らなくてもよくする。
refs #155

v1.0.6までと同様に、アダプタをロガーとして使う。
このようにすると、ログにプラグイン名が出力されるため、どのプラグイン
からログが出力されたかが分かりやすい。
ただし、現段階ではアダプタをロガーとして使えるのはIRCアダプタのみで
あるため、今後のコミットでDiscordアダプタもロガーとして使えるように
する。
refs #155

* IRCアダプタ:アダプタ自身
* Discordアダプタ:ボット側で生成したロガー
@ochaochaocha3
Copy link
Member

#164 で、ジェネレータに渡すロガー関連の処理が簡潔になりました。一方で、でテストコードが実行されなくなった問題が見つかったため、#165 を立てました。それぞれご確認よろしくお願いします。

koi-chan and others added 5 commits August 2, 2019 02:36
…rename-spec

fix #165 : SPEC ファイルの名前の誤った変更を修正
…default_logger

ジェネレータに渡すロガー関連の処理の簡略化
基底モジュールには `logger_for_generator` が存在せず、テストでエラーが
発生するため、IrcAdapter、DiscordAdapterといった具体的なモジュールの
テストに変える。
…fix_plugin_base_spec

plugin_base_spec: IRC、Discordアダプタのテストに変更する
@ochaochaocha3
Copy link
Member

いろいろありましたが、#168 でテストが通ったので、ここでマージします。

@koi-chan
Copy link
Member Author

koi-chan commented Aug 5, 2019

よろしくお願いします。

@ochaochaocha3 ochaochaocha3 merged commit f38ed57 into master Aug 5, 2019
@koi-chan koi-chan deleted the arrange-plugin-adapter-module branch September 25, 2019 13:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

プラグイン構成要素別の、基底クラス的に使うモジュールを作成する
2 participants