ruboty-ideone 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +14 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +31 -0
- data/Rakefile +2 -0
- data/lib/ruboty/handlers/ideone.rb +177 -0
- data/lib/ruboty/ideone/version.rb +5 -0
- data/lib/ruboty/ideone.rb +8 -0
- data/ruboty-ideone.gemspec +25 -0
- metadata +109 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 2437948e2ffc3563f40d64f439284f5f46daf3ff
|
4
|
+
data.tar.gz: 53d19ddac91f32faa132c567b77747e6585f4915
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: fb2751170938cc3476e50caf54e8bbac4634dd10a92e3638fc1214f44154d92efa4b43115f65904ef4d9d4c6d545649e9ec786e03a29312a08fd034c07df35f7
|
7
|
+
data.tar.gz: 7cd6686a2d4cc52d51174907c232499a1666abc99baabd77d6cbb56feffc1116ceb290b71b906cd6e01a285a32161b0ba3866fbf254afa11de55239bf8fdd295
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 cielavenir
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# Ruboty::Ideone
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'ruboty-ideone'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install ruboty-ideone
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
TODO: Write usage instructions here
|
24
|
+
|
25
|
+
## Contributing
|
26
|
+
|
27
|
+
1. Fork it ( https://github.com/[my-github-username]/ruboty-ideone/fork )
|
28
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
29
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
30
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
31
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,177 @@
|
|
1
|
+
#coding:utf-8
|
2
|
+
require 'open-uri'
|
3
|
+
require 'rubygems'
|
4
|
+
require 'savon'
|
5
|
+
|
6
|
+
#クラス変数を使いたいので、Actionを切り出すことは不可能
|
7
|
+
module Ruboty
|
8
|
+
module Handlers
|
9
|
+
class Ideone < Base
|
10
|
+
LANGUAGES=[
|
11
|
+
{:key=>"7", :value=>"Ada (gnat-4.6)"},
|
12
|
+
{:key=>"13", :value=>"Assembler (nasm-2.10.01)"},
|
13
|
+
{:key=>"45", :value=>"Assembler (gcc-4.8.1)"},
|
14
|
+
{:key=>"104", :value=>"AWK (gawk) (gawk-3.1.6)"},
|
15
|
+
{:key=>"105", :value=>"AWK (mawk) (mawk-1.3.3)"},
|
16
|
+
{:key=>"28", :value=>"Bash (bash 4.0.35)"},
|
17
|
+
{:key=>"110", :value=>"bc (bc-1.06.95)"},
|
18
|
+
{:key=>"12", :value=>"Brainf**k (bff-1.0.3.1)"},
|
19
|
+
{:key=>"11", :value=>"C (gcc-4.8.1)"},
|
20
|
+
{:key=>"27", :value=>"C# (mono-2.8)"},
|
21
|
+
{:key=>"41", :value=>"C++ 4.3.2 (gcc-4.3.2)"},
|
22
|
+
{:key=>"1", :value=>"C++ 4.8.1 (gcc-4.8.1)"},
|
23
|
+
{:key=>"44", :value=>"C++11 (gcc-4.8.1)"},
|
24
|
+
{:key=>"34", :value=>"C99 strict (gcc-4.8.1)"},
|
25
|
+
{:key=>"14", :value=>"CLIPS (clips 6.24)"},
|
26
|
+
{:key=>"111", :value=>"Clojure (clojure 1.5.0-RC2)"},
|
27
|
+
{:key=>"118", :value=>"COBOL (open-cobol-1.0)"},
|
28
|
+
{:key=>"106", :value=>"COBOL 85 (tinycobol-0.65.9)"},
|
29
|
+
{:key=>"32", :value=>"Common Lisp (clisp) (clisp 2.47)"},
|
30
|
+
{:key=>"102", :value=>"D (dmd) (dmd-2.042)"},
|
31
|
+
{:key=>"36", :value=>"Erlang (erl-5.7.3)"},
|
32
|
+
{:key=>"124", :value=>"F# (fsharp-2.0.0)"},
|
33
|
+
{:key=>"123", :value=>"Factor (factor-0.93)"},
|
34
|
+
{:key=>"125", :value=>"Falcon (falcon-0.9.6.6)"},
|
35
|
+
{:key=>"107", :value=>"Forth (gforth-0.7.0)"},
|
36
|
+
{:key=>"5", :value=>"Fortran (gfortran-4.8)"},
|
37
|
+
{:key=>"114", :value=>"Go (1.0.3)"},
|
38
|
+
{:key=>"121", :value=>"Groovy (groovy-2.1.6)"},
|
39
|
+
{:key=>"21", :value=>"Haskell (ghc-7.6.3)"},
|
40
|
+
{:key=>"16", :value=>"Icon (iconc 9.4.3)"},
|
41
|
+
{:key=>"9", :value=>"Intercal (c-intercal 28.0-r1)"},
|
42
|
+
{:key=>"10", :value=>"Java (sun-jdk-1.7.0_25)"},
|
43
|
+
{:key=>"55", :value=>"Java7 (sun-jdk-1.7.0_10)"},
|
44
|
+
{:key=>"35", :value=>"JavaScript (rhino) (rhino-1.7R4)"},
|
45
|
+
{:key=>"112", :value=>"JavaScript (spidermonkey) (spidermonkey-1.7)"},
|
46
|
+
{:key=>"26", :value=>"Lua (luac 5.1.4)"},
|
47
|
+
{:key=>"30", :value=>"Nemerle (ncc 0.9.3)"},
|
48
|
+
{:key=>"25", :value=>"Nice (nicec 0.9.6)"},
|
49
|
+
{:key=>"122", :value=>"Nimrod (nimrod-0.8.8)"},
|
50
|
+
{:key=>"56", :value=>"Node.js (0.8.11)"},
|
51
|
+
{:key=>"43", :value=>"Objective-C (gcc-4.5.1)"},
|
52
|
+
{:key=>"8", :value=>"Ocaml (ocamlopt 3.10.2)"},
|
53
|
+
{:key=>"127", :value=>"Octave (3.6.2)"},
|
54
|
+
{:key=>"119", :value=>"Oz (mozart-1.4.0)"},
|
55
|
+
{:key=>"57", :value=>"PARI/GP (2.5.1)"},
|
56
|
+
{:key=>"22", :value=>"Pascal (fpc) (fpc 2.6.2)"},
|
57
|
+
{:key=>"2", :value=>"Pascal (gpc) (gpc 20070904)"},
|
58
|
+
{:key=>"3", :value=>"Perl (perl 5.16.2)"},
|
59
|
+
{:key=>"54", :value=>"Perl 6 (rakudo-2010.08)"},
|
60
|
+
{:key=>"29", :value=>"PHP (php 5.4.4)"},
|
61
|
+
{:key=>"19", :value=>"Pike (pike 7.6.86)"},
|
62
|
+
{:key=>"108", :value=>"Prolog (gnu) (gprolog-1.3.1)"},
|
63
|
+
{:key=>"15", :value=>"Prolog (swi) (swipl 5.6.64)"},
|
64
|
+
{:key=>"4", :value=>"Python (python 2.7.3)"},
|
65
|
+
{:key=>"116", :value=>"Python 3 (python-3.2.3)"},
|
66
|
+
{:key=>"117", :value=>"R (R-2.11.1)"},
|
67
|
+
{:key=>"17", :value=>"Ruby (ruby-1.9.3)"},
|
68
|
+
{:key=>"39", :value=>"Scala (scala-2.10.2)"},
|
69
|
+
{:key=>"33", :value=>"Scheme (guile) (guile 1.8.5)"},
|
70
|
+
{:key=>"23", :value=>"Smalltalk (gst 3.1)"},
|
71
|
+
{:key=>"40", :value=>"SQL (sqlite3-3.7.3)"},
|
72
|
+
{:key=>"38", :value=>"Tcl (tclsh 8.5.7)"},
|
73
|
+
{:key=>"62", :value=>"Text (text 6.10)"},
|
74
|
+
{:key=>"115", :value=>"Unlambda (unlambda-2.0.0)"},
|
75
|
+
{:key=>"101", :value=>"VB.NET (mono-2.4.2.3)"},
|
76
|
+
{:key=>"6", :value=>"Whitespace (wspace 0.3)"}
|
77
|
+
]
|
78
|
+
|
79
|
+
def initialize(*__reserved__)
|
80
|
+
super
|
81
|
+
@client=Savon.client(log:false,wsdl:'http://ideone.com/api/1/service.wsdl')
|
82
|
+
@user=ENV['IDEONE_USER']
|
83
|
+
@pass=ENV['IDEONE_PASS']
|
84
|
+
@input=nil
|
85
|
+
@current_submission=nil
|
86
|
+
|
87
|
+
@languages=LANGUAGES
|
88
|
+
end
|
89
|
+
def read_uri(uri)
|
90
|
+
return nil if !uri||uri.empty?
|
91
|
+
Kernel.open(uri){|f|
|
92
|
+
return f.read
|
93
|
+
}
|
94
|
+
end
|
95
|
+
|
96
|
+
on /ideone languages/, name: 'languages', description: 'show languages'
|
97
|
+
on /ideone setinput ?(?<input_uri>\S*)/, name: 'setinput', description: 'set input'
|
98
|
+
on /ideone submit (?<language>\w+) (?<source_uri>\S+) ?(?<input_uri>\S*)/, name: 'submit', description: 'send code via uri'
|
99
|
+
on /ideone view ?(?<id>\w*)/, name: 'view', description: 'view submission'
|
100
|
+
def languages(message)
|
101
|
+
resp=@client.call(:get_languages,message:{user:@user,pass:@pass})
|
102
|
+
item=resp.body[:get_languages_response][:return][:item][1][:value]
|
103
|
+
if item&&item[:item]
|
104
|
+
message.reply item[:item].map{|e|"#{'%4d:'%e[:key]} #{e[:value]}\n"}.join
|
105
|
+
end
|
106
|
+
end
|
107
|
+
def setinput(message)
|
108
|
+
#input_uri: 入力ファイル(空文字列ならクリア)
|
109
|
+
if !message[:input_uri]||message[:input_uri].empty?
|
110
|
+
@input=nil
|
111
|
+
message.reply 'Input cleared.'
|
112
|
+
else
|
113
|
+
@input=read_uri(message[:input_uri])
|
114
|
+
message.reply 'Input set.'
|
115
|
+
end
|
116
|
+
end
|
117
|
+
def submit(message)
|
118
|
+
#language: ID(数値)または言語名(文字列)。言語名の場合、記号類を除いて最大先頭一致のものを使用する。
|
119
|
+
#source_uri: ソースファイル
|
120
|
+
#input_uri: 入力ファイル(空文字列ならsetinputの内容を使用)
|
121
|
+
input=message[:input_uri]&&!message[:input_uri].empty? ? read_uri(message[:input_uri]) : @input
|
122
|
+
#guess lang
|
123
|
+
lang=message[:language]
|
124
|
+
if lang.to_i>0
|
125
|
+
lang=lang.to_i
|
126
|
+
else
|
127
|
+
lang=lang.downcase.gsub(/\W/,'')
|
128
|
+
lang=@languages.max_by{|e|
|
129
|
+
_e=e[:value].downcase.gsub(/\W/,'')
|
130
|
+
lang.size.downto(1).find{|i|_e.start_with?(lang[0,i])}||-1
|
131
|
+
}[:key].to_i
|
132
|
+
end
|
133
|
+
resp=@client.call(:create_submission,message:{
|
134
|
+
user:@user,pass:@pass,source_code:read_uri(message[:source_uri]),input:input,run:true,private:true,language:lang
|
135
|
+
})
|
136
|
+
result=Hash[*resp.body[:create_submission_response][:return][:item].flat_map{|e|[e[:key],e[:value]]}]
|
137
|
+
if result['error']=='AUTH_ERROR'
|
138
|
+
message.reply '[Ruboty::Ideone] wrong authentication'
|
139
|
+
elsif result['error']!='OK'
|
140
|
+
message.reply '[Ruboty::Ideone] something wrong happened in submission'
|
141
|
+
else
|
142
|
+
@current_submission=result['link']
|
143
|
+
message.reply 'http://ideone.com/'+result['link']
|
144
|
+
end
|
145
|
+
end
|
146
|
+
def view(message)
|
147
|
+
#id: ideone ID(空文字列なら直前のsubmitで返されたIDを使用)
|
148
|
+
submission=message[:id]&&!message[:id].empty? ? message[:id] : @current_submission
|
149
|
+
resp=@client.call(:get_submission_details,message:{
|
150
|
+
user:@user,pass:@pass,link:submission,with_output:true
|
151
|
+
})
|
152
|
+
result=Hash[*resp.body[:get_submission_details_response][:return][:item].flat_map{|e|[e[:key],e[:value]]}]
|
153
|
+
if result['status'].to_i<0
|
154
|
+
message.reply '[Ruboty::Ideone] waiting for compilation'
|
155
|
+
elsif result['status'].to_i==1
|
156
|
+
message.reply '[Ruboty::Ideone] compiling'
|
157
|
+
elsif result['status'].to_i==3
|
158
|
+
message.reply '[Ruboty::Ideone] running'
|
159
|
+
elsif result['error']!='OK'
|
160
|
+
message.reply '[Ruboty::Ideone] something wrong happened in execution'
|
161
|
+
elsif result['result']=='15'
|
162
|
+
message.reply result['output']
|
163
|
+
else
|
164
|
+
message.reply('[Ruboty::Ideone] '+[
|
165
|
+
0=>'not running',
|
166
|
+
11=>'compilation error',
|
167
|
+
12=>'runtime error',
|
168
|
+
13=>'time limit exceeded',
|
169
|
+
17=>'memory limit exceeded',
|
170
|
+
19=>'illegal system call',
|
171
|
+
20=>'internal error',
|
172
|
+
][result['result'].to_i])
|
173
|
+
end
|
174
|
+
end
|
175
|
+
end
|
176
|
+
end
|
177
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'ruboty/ideone/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "ruboty-ideone"
|
8
|
+
spec.version = Ruboty::Ideone::VERSION
|
9
|
+
spec.authors = ["cielavenir"]
|
10
|
+
spec.email = ["cielartisan@gmail.com"]
|
11
|
+
spec.summary = "Ruboty Ideone"
|
12
|
+
spec.description = "Ruboty Ideone"
|
13
|
+
spec.homepage = "https://github.com/"+spec.authors.first+"/"+spec.name
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_runtime_dependency "ruboty"
|
22
|
+
spec.add_runtime_dependency "savon"
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
24
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
25
|
+
end
|
metadata
ADDED
@@ -0,0 +1,109 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ruboty-ideone
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- cielavenir
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-12-11 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: ruboty
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: savon
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.7'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.7'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '10.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '10.0'
|
69
|
+
description: Ruboty Ideone
|
70
|
+
email:
|
71
|
+
- cielartisan@gmail.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- .gitignore
|
77
|
+
- Gemfile
|
78
|
+
- LICENSE.txt
|
79
|
+
- README.md
|
80
|
+
- Rakefile
|
81
|
+
- lib/ruboty/handlers/ideone.rb
|
82
|
+
- lib/ruboty/ideone.rb
|
83
|
+
- lib/ruboty/ideone/version.rb
|
84
|
+
- ruboty-ideone.gemspec
|
85
|
+
homepage: https://github.com/cielavenir/ruboty-ideone
|
86
|
+
licenses:
|
87
|
+
- MIT
|
88
|
+
metadata: {}
|
89
|
+
post_install_message:
|
90
|
+
rdoc_options: []
|
91
|
+
require_paths:
|
92
|
+
- lib
|
93
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - '>='
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '0'
|
98
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - '>='
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
103
|
+
requirements: []
|
104
|
+
rubyforge_project:
|
105
|
+
rubygems_version: 2.0.14
|
106
|
+
signing_key:
|
107
|
+
specification_version: 4
|
108
|
+
summary: Ruboty Ideone
|
109
|
+
test_files: []
|