ruby-eval-in 0.0.3 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 471e441f648cbc0697104e3c9ae64e5cbca71493
4
- data.tar.gz: ac9aa91c0890a063ebcedf0c15e9d4d2bd8bda85
2
+ SHA256:
3
+ metadata.gz: 1886aec828d9dc629c2638c9c5af5d6700ddb2d069f048fcc7ce5ea99e35f633
4
+ data.tar.gz: 23f723ee4fa45327f5aa8126ce76ef8b461ac1e1fc56dfc22f224526353bef9e
5
5
  SHA512:
6
- metadata.gz: 7ff2b4ead9829f363de1860b567469a7797113cc7657075fb928483fcb20e6a61ca42d37a2c2b8532373c77e0f85bc1dcb65503e5d59eef3631e49c09d8aef08
7
- data.tar.gz: dc528bb4125dcfc67ab254f908a2d5349bf8634bb91eddcde7c3daa8a8d9b8f5ceae122e68c483d54cf618f5a4388c5c3f880bef53e850d515a3416956872451
6
+ metadata.gz: 382700474e8545c199c3f8d52b3420ebcb80eaed956fcb357e38b17fb60904798c2fb50fad95af449684220fd33232f78368b255ce75faabe1bb3b3d5fdcd339
7
+ data.tar.gz: 7a070fa3b4a84d14d7da47aaf4ba83625cc2735e604742abd466cc73df5774c8745e620c2009feff0dc09d40d34e7235baf91e0159b59bdfc6e5188bad1a073a
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
- The MIT License (MIT)
1
+ The MIT License (MIT) with restrictions
2
2
 
3
- Copyright (c) 2015 William Woodruff <william @ tuffbizz.com>
3
+ Copyright (c) 2020 William Woodruff <william @ yossarian.net>
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -18,4 +18,31 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
18
  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
19
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
20
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- THE SOFTWARE.
21
+ THE SOFTWARE.
22
+
23
+ The following terms additionally apply and override any above terms for
24
+ applicable parties:
25
+
26
+ You may not use, copy, modify, merge, publish, distribute, sublicense,
27
+ and/or sell copies of the Software in a military or law enforcement context,
28
+ defined as follows:
29
+
30
+ 1. A military context is a professional context where the intended application
31
+ of the Software is integration or use with or by military software, tools
32
+ (software or hardware), or personnel. This includes contractors and
33
+ subcontractors as well as research affiliates of any military organization.
34
+
35
+ 2. A law enforcement context is a professional context where the intended
36
+ application of the Software is integration or use with or by law enforcement
37
+ software, tools (software or hardware), or personnel. This includes
38
+ contractors and subcontractors as well as research affiliates of any law
39
+ enforcement organization.
40
+
41
+ Entities that sell or license to military or law enforcement organizations
42
+ may use the Software under the original terms, but only in contexts that do
43
+ not assist or supplement the sold or licensed product.
44
+
45
+ Students and academics who are affiliated with research institutions may use
46
+ the Software under the original terms, but only in contexts that do not assist
47
+ or supplement collaboration or affiliation with any military or law
48
+ enforcement organization.
data/README.md CHANGED
@@ -1,8 +1,9 @@
1
1
  ruby-eval-in
2
2
  ============
3
3
 
4
+ ![license](https://raster.shields.io/badge/license-MIT%20with%20restrictions-green.png)
4
5
  [![Gem Version](https://badge.fury.io/rb/ruby-eval-in.svg)](http://badge.fury.io/rb/ruby-eval-in)
5
- [![Build Status](https://drone.io/github.com/woodruffw/ruby-eval-in/status.png)](https://drone.io/github.com/woodruffw/ruby-eval-in/latest)
6
+ [![Build Status](https://travis-ci.org/woodruffw/ruby-eval-in.svg?branch=master)](https://travis-ci.org/woodruffw/ruby-eval-in)
6
7
 
7
8
  A basic Ruby interface to the [eval.in](https://eval.in) online evaluation
8
9
  service.
@@ -1,21 +1,22 @@
1
- # eval-in.rb
2
- # Author: William Woodruff
3
- # A Ruby interface to the eval.in (https://eval.in) service.
1
+ # frozen_string_literal: true
4
2
 
5
- require "eval-in/result"
6
- require "eval-in/exceptions"
3
+ require_relative "eval-in/result"
4
+ require_relative "eval-in/exceptions"
7
5
 
8
6
  # The primary namespace.
9
7
  # @author William Woodruff
10
8
  # @since 0.0.1
11
9
  module EvalIn
12
- # Evaluate some code in a given language.
13
- # @example
14
- # EvalIn.eval(:ruby, 'puts "Hello, World"') # => #<EvalIn::Result:0xNN>
15
- # @param [Symbol, String] lang the language to execute in
16
- # @param [String] code the program code to execute
17
- # @return [EvalIn::Result] the execution results
18
- def self.eval(lang, code)
19
- EvalIn::Result.new(lang.to_s.downcase, code)
20
- end
10
+ # The library's current version.
11
+ VERSION = "0.0.8"
12
+
13
+ # Evaluate some code in a given language.
14
+ # @example
15
+ # EvalIn.eval(:ruby, 'puts "Hello, World"') # => #<EvalIn::Result:0xNN>
16
+ # @param [Symbol, String] lang the language to execute in
17
+ # @param [String] code the program code to execute
18
+ # @return [EvalIn::Result] the execution results
19
+ def self.eval(lang, code)
20
+ EvalIn::Result.new(lang.to_s.downcase, code)
21
+ end
21
22
  end
@@ -1,26 +1,28 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module EvalIn
2
- # A parent Error class for all eval-in errors.
3
- class EvalInError < RuntimeError
4
- end
4
+ # A parent Error class for all eval-in errors.
5
+ class EvalInError < RuntimeError
6
+ end
5
7
 
6
- # Raised when an error occurs during connection.
7
- class ConnectionError < EvalInError
8
- def initialize(error)
9
- super "Connection error: #{error.to_s}"
10
- end
11
- end
8
+ # Raised when an error occurs during connection.
9
+ class ConnectionError < EvalInError
10
+ def initialize(error)
11
+ super "Connection error: #{error}"
12
+ end
13
+ end
12
14
 
13
- # Raised when EvalIn.{EvalIn.eval} is given a bad input language.
14
- class BadLanguageError < EvalInError
15
- def initialize(lang)
16
- super "No such language: #{lang}"
17
- end
18
- end
15
+ # Raised when EvalIn.{EvalIn.eval} is given a bad input language.
16
+ class BadLanguageError < EvalInError
17
+ def initialize(lang)
18
+ super "No such language: #{lang}"
19
+ end
20
+ end
19
21
 
20
- # Raised when EvalIn.{EvalIn.eval} is given blank or whitespace-only code.
21
- class EmptyCodeError < EvalInError
22
- def initialize
23
- super "The code may not be empty"
24
- end
25
- end
22
+ # Raised when EvalIn.{EvalIn.eval} is given blank or whitespace-only code.
23
+ class EmptyCodeError < EvalInError
24
+ def initialize
25
+ super "The code may not be empty"
26
+ end
27
+ end
26
28
  end
@@ -1,89 +1,86 @@
1
- require 'nokogiri'
2
- require 'net/http'
3
- require 'uri'
1
+ # frozen_string_literal: true
2
+
3
+ require "nokogiri"
4
+ require "net/http"
5
+ require "uri"
4
6
 
5
7
  module EvalIn
6
- # A representation of a result produced by an eval.in query.
7
- class Result
8
- # @private
9
- URL = URI("https://eval.in")
8
+ # A representation of a result produced by an eval.in query.
9
+ class Result
10
+ # @private
11
+ URL = URI("https://eval.in")
10
12
 
11
- # The languages supported by eval.in.
12
- # Any of these keys or values will work for the lang parameter in
13
- # {EvalIn.eval}.
14
- LANGS = {
15
- "c" => "c/gcc-4.9.1",
16
- "c++" => "c++/gcc-4.9.1",
17
- "coffeescript" => "coffeescript/node-0.10.29-coffee-1.7.1",
18
- "fortran" => "fortran/f95-4.4.3",
19
- "haskell" => "haskell/hugs98-sep-2006",
20
- "io" => "io/io-20131204",
21
- "js" => "javascript/node-0.10.29",
22
- "lua" => "lua/lua-5.2.3",
23
- "ocaml" => "ocaml/ocaml-4.01.0",
24
- "php" => "php/php-5.5.14",
25
- "pascal" => "pascal/fpc-2.6.4",
26
- "perl" => "perl/perl-5.20.0",
27
- "python" => "python/cpython-3.4.1",
28
- "python2" => "python/cpython-2.7.8",
29
- "ruby" => "ruby/mri-2.2",
30
- "slash" => "slash/slash-head",
31
- "nasm" => "assembly/nasm-2.07"
32
- }
13
+ # The languages supported by eval.in.
14
+ # Any of these keys or values will work for the lang parameter in
15
+ # {EvalIn.eval}.
16
+ LANGS = {
17
+ "c" => "c/gcc-4.9.1",
18
+ "c++" => "c++/gcc-4.9.1",
19
+ "coffeescript" => "coffeescript/node-0.10.29-coffee-1.7.1",
20
+ "fortran" => "fortran/f95-4.4.3",
21
+ "haskell" => "haskell/hugs98-sep-2006",
22
+ "io" => "io/io-20131204",
23
+ "js" => "javascript/node-0.10.29",
24
+ "lua" => "lua/lua-5.2.3",
25
+ "ocaml" => "ocaml/ocaml-4.01.0",
26
+ "php5" => "php/php-5.6.23",
27
+ "php7" => "php/php-7.0.8",
28
+ "pascal" => "pascal/fpc-2.6.4",
29
+ "perl" => "perl/perl-5.20.0",
30
+ "python" => "python/cpython-3.4.1",
31
+ "python2" => "python/cpython-2.7.8",
32
+ "racket" => "racket/racket-6.10.1",
33
+ "ruby" => "ruby/mri-2.4",
34
+ "slash" => "slash/slash-head",
35
+ "nasm" => "assembly/nasm-2.07",
36
+ }.freeze
33
37
 
34
- # @return [String] the expanded language used in execution
35
- # @example
36
- # result.language # => "ruby/mri-2.2"
37
- attr_reader :language
38
+ # @return [String] the expanded language used in execution
39
+ # @example
40
+ # result.language # => "ruby/mri-2.2"
41
+ attr_reader :language
38
42
 
39
- # @return [String] the program code used in execution
40
- # @example
41
- # result.code # => "puts \"hello\""
42
- attr_reader :code
43
+ # @return [String] the program code used in execution
44
+ # @example
45
+ # result.code # => "puts \"hello\""
46
+ attr_reader :code
43
47
 
44
- # @return [String] any output produced by the program
45
- # @example
46
- # result.output # => "hello\n"
47
- attr_reader :output
48
+ # @return [String] any output produced by the program
49
+ # @example
50
+ # result.output # => "hello\n"
51
+ attr_reader :output
48
52
 
49
- # @return [String] the program's exit status
50
- # @example
51
- # result.status # => "OK (0 sec real, 0 sec wall, 8 MB, 16 syscalls)"
52
- attr_reader :status
53
+ # @return [String] the program's exit status
54
+ # @example
55
+ # result.status # => "OK (0 sec real, 0 sec wall, 8 MB, 16 syscalls)"
56
+ attr_reader :status
53
57
 
54
- # @return [URI] a permalink to the output webpage
55
- # @example
56
- # result.url # => #<URI::HTTPS https://eval.in/xxxxxx>
57
- attr_reader :url
58
+ # @return [URI] a permalink to the output webpage
59
+ # @example
60
+ # result.url # => #<URI::HTTPS https://eval.in/xxxxxx>
61
+ attr_reader :url
58
62
 
59
- # @private
60
- def initialize(lang, code)
61
- if LANGS.key?(lang)
62
- lang = LANGS[lang]
63
- elsif !LANGS.value?(lang)
64
- raise BadLanguageError.new(lang)
65
- end
63
+ # @private
64
+ def initialize(lang, code)
65
+ if LANGS.key?(lang)
66
+ lang = LANGS[lang]
67
+ elsif !LANGS.value?(lang)
68
+ raise BadLanguageError, lang
69
+ end
66
70
 
67
- raise EmptyCodeError.new if code.strip.empty?
71
+ raise EmptyCodeError if code.strip.empty?
68
72
 
69
- @lang = lang
70
- @code = code
73
+ @lang = lang
74
+ @code = code
71
75
 
72
- result = Net::HTTP.post_form(URL,
73
- "execute" => "on",
74
- "lang" => lang,
75
- "code" => code
76
- )
76
+ result = Net::HTTP.post_form(URL, "execute" => "on", "lang" => lang, "code" => code)
77
77
 
78
- if result.is_a? Net::HTTPFound
79
- @url = URI(result["location"])
78
+ raise ConnectionError, result unless result.is_a? Net::HTTPFound
80
79
 
81
- html = Nokogiri::HTML(Net::HTTP.get(@url))
82
- @output = html.css("pre").last.text
83
- @status = html.css("p")[1].text
84
- else
85
- raise ConnectionError.new(result)
86
- end
87
- end
88
- end
80
+ @url = URI(result["location"])
81
+ html = Nokogiri::HTML(Net::HTTP.get(@url))
82
+ @output = html.css("pre").last.text
83
+ @status = html.css("p")[1].text
84
+ end
85
+ end
89
86
  end
metadata CHANGED
@@ -1,27 +1,27 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-eval-in
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - William Woodruff
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-07 00:00:00.000000000 Z
11
+ date: 2020-06-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  description: A Ruby interface to https://eval.in/.
@@ -40,7 +40,7 @@ files:
40
40
  - lib/eval-in/result.rb
41
41
  homepage: https://github.com/woodruffw/ruby-eval-in
42
42
  licenses:
43
- - MIT
43
+ - Nonstandard
44
44
  metadata: {}
45
45
  post_install_message:
46
46
  rdoc_options: []
@@ -50,15 +50,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
50
50
  requirements:
51
51
  - - ">="
52
52
  - !ruby/object:Gem::Version
53
- version: 2.0.0
53
+ version: '2.3'
54
54
  required_rubygems_version: !ruby/object:Gem::Requirement
55
55
  requirements:
56
56
  - - ">="
57
57
  - !ruby/object:Gem::Version
58
58
  version: '0'
59
59
  requirements: []
60
- rubyforge_project:
61
- rubygems_version: 2.4.5.1
60
+ rubygems_version: 3.1.2
62
61
  signing_key:
63
62
  specification_version: 4
64
63
  summary: ruby-eval-in - A Ruby interface to https://eval.in/.