LoginSignup
1

More than 5 years have passed since last update.

Rubotyでideoneの採点を行う

Last updated at Posted at 2014-12-13

https://github.com/cielavenir/codeiq_problems/blob/master/q1169/check.rb
をRuboty対応してみた。

URL

Base

ruboty-gen gemを使いましたが、Handlerが状態を持つため、Actionはバッサリ削除してしまいました。
こういう場合、どうするのが良いのでしょうね。

あと、gemspecに書いてあるとおり、savonが必要です。

Config

  • IDEONE_USER/IDEONE_PASS: ideoneのユーザー名とAPIパスワード。
    • 同じユーザー名からは1ヶ月に1000回しかAPIリクエストできないらしい?ので注意。

[150109追記] APIパスワードについて

  • 150107の更新により、APIパスワードの設定が必要になりました。
  1. ideoneのフッターの「api」をクリックします。
  2. Pay-As-You-Goの「Continue」をクリックします。
  3. 適当に入力します。とりあえずどのように知ったかはspojを入れておきましたが、別になんでも良いかと…。
  4. APIパスワードをこの画面で設定しても反映されないようなので、チェックは入れずに「Subscribe」します。
  5. my accountのsettingをクリックします。
  6. Ideone API Passwordを設定します。
  • 以上の情報はNeoCat氏から提供いただきました。感謝します。

Usage

  • /ideone languages/

言語一覧を返す。

   7: Ada (gnat-4.6)
  13: Assembler (nasm-2.10.01)
  45: Assembler (gcc-4.8.1)
 104: AWK (gawk) (gawk-3.1.6)
(snip)
  • /ideone setinput ?(?<input_uri>\S*)/

stdinを保存する。
input_uri: 入力ファイル(空文字列ならクリア)
open-uriなKernel.openを使うので、入力ファイルはhttp://も指定できる。以下同様。

  • /ideone submit (?<language>\S+) (?<source_uri>\S+) ?(?<input_uri>\S*)/

language: ID(数値)または言語名(文字列)。言語名の場合、記号類(/[\s\(\)\.]/)を除いて最大先頭一致のものを使用する。
source_uri: ソースファイル
input_uri: 入力ファイル(空文字列ならsetinputの内容を使用)

languageの例。

7 => Ada (gnat-4.6)
Ada => Ada (gnat-4.6)
ada => Ada (gnat-4.6)
asseml => Assembler (nasm-2.10.01)
assemblerg => Assembler (gcc-4.8.1)
c => C (gcc-4.8.1)
c+ => C++ 4.3.2 (gcc-4.3.2)
c++48 => C++ 4.8.1 (gcc-4.8.1)
javas => JavaScript (rhino) (rhino-1.7R4)
javascripts => JavaScript (spidermonkey) (spidermonkey-1.7)
r => R (R-2.11.1)
ru => Ruby (ruby-1.9.3)
  • /ideone view ?(?<id>\w*)/

id: ideone ID(空文字列なら直前のsubmitで返されたIDを使用)
※これをActionで実現するにはActionにselfかコールバック関数を渡す必要があるわけですが。難しいですね。

Example

$ IDEONE_USER=ciel0______ IDEONE_PASS=_______ ruboty
> ruboty ideone setinput /path/to/codeiq_base32/data.in
Input set.
> ruboty ideone submit ru /path/to/codeiq_base32/base32.rb
http://ideone.com/Sdsoiw
> ruboty ideone view
CodeIQ is a service in which you can check your programming skill. There are so many problems such as algorithms, mathematics, data sciences, and even security! The unique point is that (unlike other e-learnings) you can receive feedback comment from human, which will be helpful for your study. So, let's go for it!
> exit
$

Appendix

/opt/local/lib/libiconv.dylibがgem install nokogiri -- --with-iconv-dir=/opt/localから認識されない不具合で1時間ほど悩んだ
(すでに1.6.3.1がインストールされていたが、bundle installでこけないようにしなければならない)。
結局/usr/local配下にsymlink張って無理やり通したけど、正しい解決策は何なのでしょうね…。

ところで、rubotyはbundle installしないと動かないみたいだからよかったけど、savonとmechanizeを両方インストールするとsavonがバグる不具合があるっぽい。
https://github.com/sparklemotion/mechanize/issues/407

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
1