LoginSignup
8
8

More than 5 years have passed since last update.

Ruboty | Configuration | dotenv #ruboty #chatops

Posted at

Ruboty | Configuration | dotenv #ruboty #chatops

概要

Ruboty の設定に関して。

資料

Ruboty の構成要素については、下記記事を参照
Ruboty | 基本構成図解

詳細

Ruboty では、 bot名やデプロイモードなど、設定値は環境変数で設定します。
dotenv gem 経由での環境変数設定を推奨しています。

試行

仕様

RUBOTY_ENV によって、 development と production を切り替えます。
環境変数を直接設定する方法と、
dotenv(.env ファイル) を利用する方法の両方を検証します。

Gemfile

source "https://rubygems.org"

group :development do
  gem "ruboty-google_image"
end

group :production do
  gem "ruboty-lgtm"
end

実行(環境変数で設定)

$ RUBOTY_ENV=development bundle exec ruboty
> ruboty help
ruboty /image( me)? (?<keyword>.+)/ - Search image from Google
ruboty /help( me)?\z/i              - Show this help message
ruboty /ping\z/i                    - Return PONG to PING
ruboty /who am i\?/i                - Answer who you are
> ruboty image 地獄のミサワ
http://img.jigokuno.com/20120502_2462789.gif

development ruboty-google_image

$ RUBOTY_ENV=production ruboty
> ruboty help
ruboty /lgtm( me)? ?(?<keyword>.+)?/ - Generate lgtm image matching with the keyword
ruboty /help( me)?\z/i               - Show this help message
ruboty /ping\z/i                     - Return PONG to PING
ruboty /who am i\?/i                 - Answer who you are
> ruboty lgtm
http://lgtm.herokuapp.com/http://38.media.tumblr.com/1b7fab2dd5e05f6cd3c9617e9a8e2e90/tumblr_mnl78auDq21r3eh5jo2_500.gif

production ruboty-lgtm

実行(.envで設定)

.env(development)

  • .env
RUBOTY_ENV=development
  • 実行
$ ruboty --dotenv
> ruboty help
ruboty /image( me)? (?<keyword>.+)/ - Search image from Google
ruboty /help( me)?\z/i              - Show this help message
ruboty /ping\z/i                    - Return PONG to PING
ruboty /who am i\?/i                - Answer who you are
> ruboty image
> ruboty image 地獄のミサワ
http://ascii.jp/elem/000/000/558/558297/002_185x.gif

development ruboty-google_image

.env(production)

  • .env
RUBOTY_ENV=production
  • 実行
$ ruboty --dotenv
> ruboty help
ruboty /lgtm( me)? ?(?<keyword>.+)?/ - Generate lgtm image matching with the keyword
ruboty /help( me)?\z/i               - Show this help message
ruboty /ping\z/i                     - Return PONG to PING
ruboty /who am i\?/i                 - Answer who you are
> ruboty lgtm
http://lgtm.herokuapp.com/http://33.media.tumblr.com/a6a59c1b3b537ffa26b4f11b505760c0/tumblr_mlr6xd2wdF1r0rp7xo1_500.gif

production ruboty-lgtm

参照

Ruboty GitHub
Ruboty RubyGems
dotenv gem GitHub

8
8
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
8