LoginSignup
2
2

More than 5 years have passed since last update.

ejectフレームワーク

Posted at

ejectフレームワーク

より効率的にejectさせるプログラムを書くために自動処理フレームワークのautomaticrubyにejectプラグインを追加した。

ejectプログラムを作成するときにネックになるのが「何をフックとさせるか」「1回ejectさせたらそのフックは次にejectさせるか、させないか」になると思われる。
例えばjenkinsのビルド失敗RSSを取得したらejectだったり、
Twitterで特定の単語がつぶやかれたらejectだったり等。

より早く、効率的にejectさせる仕組みを作りたいだけなので
rssの取得だったり、Twitterの検索だったり毎回実行させないためにDBに値保存だったりのプログラムを毎回組むのは面倒、もとい非効率的なので
以下のyml形式のファイルを作成してやればejectする仕組みを作成する事ができる。

yml例

jenkinsの失敗ビルド

jenkins_failed_eject.yml
global:
  timezone: Asia/Tokyo
  cache:
    base: /tmp
  log:
    level: info

plugins:
  - module: SubscriptionFeed
    config:
      feeds:
        - http://jenkins.id774.net/jenkins/job/automaticruby-with-ruby2.0/rssFailed

  - module: StorePermalink
    config:
      db: jenkins_failed_eject.db

  - module: PublishEject

Twitterでejectとつぶやかれたときにeject

twisearch_eject.yml
global:
  timezone: Asia/Tokyo
  cache:
    base: /tmp
  log:
    level: info

plugins:
  - module: SubscriptionTwitterSearch
    config:
      consumer_key:       'your_consumer_key'
      consumer_secret:    'your_consumer_secret'
      oauth_token:        'your_oauth_token'
      oauth_token_secret: 'your_oauth_token_secret'
      search:             'eject'
      opt:
        lang : "ja"
        count : 10

  - module: StorePermalink
    config:
      db: twisearch_eject.db

  - module: PublishEject

automaticrubyのインストール

$ git clone git://github.com/automaticruby/automaticruby.git
$ cd automaticruby
$ bundle install --path vendor/gems
$ bin/automatic scaffold
$ bin/automatic -c ~/.automatic/config/example/feed2console.yml

実行

以下で実行できる。cronに登録しておけば定期的に実行される。

$ bin/automatic -c jenkins_failed_eject.yml
$ bin/automatic -c twisearch_eject.yml

これで効率的にejectさせる事ができる。

2
2
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
2
2