cinch-evalso 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +38 -0
- data/Rakefile +1 -0
- data/cinch-evalso.gemspec +23 -0
- data/lib/cinch/plugins/evalso.rb +58 -0
- metadata +94 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 2f6e48f7e63cca5d96256c41d86c9698236c8374
|
4
|
+
data.tar.gz: bc77ff47f57e392c72fde5401c8e50059b9dfda0
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 23fef9f4fbabae262da4f17b331e73aeb5a09bbacdecb3a66c7ce827a023ab3e69ae1187f3b6ca55cb5594d1d5854882e00d69e8f59759d9763c70b9719577bb
|
7
|
+
data.tar.gz: c724de5b72c68b30d296b4e3bb2e628be83d7e29d6202fa8ca4d30717d1cd8ccbcb9082774372e56dc0937b632a95d27f699e63f8d1a396f142c69d5dd281bea
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Serguey Parkhomovsky
|
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,38 @@
|
|
1
|
+
# cinch-evalso
|
2
|
+
|
3
|
+
The Cinch eval.so plugin. Send requests to the eval.so API for processing.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Install the gem
|
8
|
+
|
9
|
+
```
|
10
|
+
gem install cinch-evalso
|
11
|
+
```
|
12
|
+
|
13
|
+
## Example
|
14
|
+
|
15
|
+
```ruby
|
16
|
+
require 'cinch'
|
17
|
+
require 'cinch/plugins/evalso'
|
18
|
+
|
19
|
+
bot = Cinch::Bot.new do
|
20
|
+
configure do |c|
|
21
|
+
c.server = "irc.freenode.org"
|
22
|
+
c.channels = ["#cinch-bots"]
|
23
|
+
c.plugin.plugins = [Cinch::Plugins::EvalSo]
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
bot.start
|
28
|
+
```
|
29
|
+
|
30
|
+
## Usage
|
31
|
+
|
32
|
+
```!langs``` Prints out a list of the languages available from the eval.so API
|
33
|
+
|
34
|
+
```!eval {language} {code}``` Evaluates code using the eval.so API
|
35
|
+
|
36
|
+
## License
|
37
|
+
|
38
|
+
This plugin is licensed under the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "cinch-evalso"
|
7
|
+
spec.version = "0.1.1"
|
8
|
+
spec.authors = ["Serguey Parkhomovsky"]
|
9
|
+
spec.email = ["xindigo@gmail.com"]
|
10
|
+
spec.homepage = "https://github.com/sparkhom/cinch-evalso"
|
11
|
+
spec.description = %q{Cinch plugin to evaluate code with different languages using the eval.so API}
|
12
|
+
spec.summary = %q{Cinch plugin to query the eval.so API}
|
13
|
+
spec.license = "MIT"
|
14
|
+
|
15
|
+
spec.files = `git ls-files`.split($/)
|
16
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
|
+
spec.require_paths = ["lib"]
|
19
|
+
|
20
|
+
spec.add_dependency "cinch"
|
21
|
+
spec.add_dependency "httparty"
|
22
|
+
spec.add_dependency "gist"
|
23
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require 'cinch'
|
2
|
+
require 'httparty'
|
3
|
+
require 'gist'
|
4
|
+
|
5
|
+
module Cinch
|
6
|
+
module Plugins
|
7
|
+
class EvalSo
|
8
|
+
include Cinch::Plugin, HTTParty
|
9
|
+
|
10
|
+
base_uri 'eval.so'
|
11
|
+
format :json
|
12
|
+
|
13
|
+
match /eval ([\S]+) (.+)/, method: :eval
|
14
|
+
match /langs/, method: :langs
|
15
|
+
|
16
|
+
# Initializes the class and caches a list of languages from teh eval.so API
|
17
|
+
def initialize(*args)
|
18
|
+
super
|
19
|
+
@langs = self.class.get('/api/languages')
|
20
|
+
end
|
21
|
+
|
22
|
+
# Print out a list of languages
|
23
|
+
def langs(m)
|
24
|
+
m.reply 'Available languages: ' + @langs.keys.join(', ')
|
25
|
+
end
|
26
|
+
|
27
|
+
# Evaluate code using the eval.so API
|
28
|
+
# Params:
|
29
|
+
# +m+:: +Cinch::Message+ object
|
30
|
+
# +lang+:: The language for code to be evaluated with
|
31
|
+
# +code+:: The code to be evaluated
|
32
|
+
def eval(m, lang, code)
|
33
|
+
options = { :body => {:language => lang, :code => code }.to_json, :headers => { 'Content-Type' => 'application/json' }}
|
34
|
+
res = self.class.post('/api/evaluate', options)
|
35
|
+
# Eval.so brought back an error, print it out and return
|
36
|
+
if res.has_key? 'error'
|
37
|
+
m.reply 'Error: ' + res['error'], true
|
38
|
+
return
|
39
|
+
end
|
40
|
+
|
41
|
+
# Print stderr if stdout is empty
|
42
|
+
if res['stdout'].empty?
|
43
|
+
output = res['stderr']
|
44
|
+
else
|
45
|
+
output = res['stdout']
|
46
|
+
end
|
47
|
+
|
48
|
+
# According to RFC 2812, the maximum line length on IRC is 510 characters, minus the carriage return
|
49
|
+
# In order to not spam the channel, if the output is greater than one line, convert it to a gist
|
50
|
+
if output.length > 510
|
51
|
+
m.reply Gist.gist(output, filename: 'result', description: code)['html_url'], true
|
52
|
+
else
|
53
|
+
m.reply output, true
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
metadata
ADDED
@@ -0,0 +1,94 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: cinch-evalso
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Serguey Parkhomovsky
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-06-22 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: cinch
|
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: httparty
|
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: gist
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: Cinch plugin to evaluate code with different languages using the eval.so
|
56
|
+
API
|
57
|
+
email:
|
58
|
+
- xindigo@gmail.com
|
59
|
+
executables: []
|
60
|
+
extensions: []
|
61
|
+
extra_rdoc_files: []
|
62
|
+
files:
|
63
|
+
- .gitignore
|
64
|
+
- Gemfile
|
65
|
+
- LICENSE.txt
|
66
|
+
- README.md
|
67
|
+
- Rakefile
|
68
|
+
- cinch-evalso.gemspec
|
69
|
+
- lib/cinch/plugins/evalso.rb
|
70
|
+
homepage: https://github.com/sparkhom/cinch-evalso
|
71
|
+
licenses:
|
72
|
+
- MIT
|
73
|
+
metadata: {}
|
74
|
+
post_install_message:
|
75
|
+
rdoc_options: []
|
76
|
+
require_paths:
|
77
|
+
- lib
|
78
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
84
|
+
requirements:
|
85
|
+
- - '>='
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '0'
|
88
|
+
requirements: []
|
89
|
+
rubyforge_project:
|
90
|
+
rubygems_version: 2.0.3
|
91
|
+
signing_key:
|
92
|
+
specification_version: 4
|
93
|
+
summary: Cinch plugin to query the eval.so API
|
94
|
+
test_files: []
|