ideone-ruby-api 2.1.1 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: fe66c0214bb53eac469fc0310a3b9e4feeb7b332
4
- data.tar.gz: 432c3df8fee8bccaca2cadd2851c31404dc8a97b
2
+ SHA256:
3
+ metadata.gz: ae499139e4d34d05e5b81cf2a6bb3be8e41c5ba9f9c6c0bee03419520cd99a2d
4
+ data.tar.gz: 9adab8cca279d0116ba074e5b0478541173f52bf521b9501d5e8829fe792ac91
5
5
  SHA512:
6
- metadata.gz: 6b2b0b316f5058b52ed0189cd84a9aea54b6c0706e65b2f95cb361199d37f6f266659e29a991fc4fa6383b108563f4e75d369934ec80c3823f3d4fb22b7b9337
7
- data.tar.gz: f645f9a9103acc6d6e5fe79658d393742ca7c372870a1ed9440e45a3fdf7a12393d35b52b8b7d2b6b5c2ba95abc8f2451b70dacfb7f0e8da24fe221492dbad39
6
+ metadata.gz: d8b7e2a3a2707aeede565903f5e001ae5c53e22f6fdc620c96577ba09ef32745250499e3e0cc0b8602d8e890feb28387e80e39c59e3cbdda1e59b807bdfd0692
7
+ data.tar.gz: 207780d43873f9f9730dc5a4ebb24eb1247e671585ada92521e4fc4abce523d4d15f00ebb927f816d3556eea27decf920d346b1e3d98d7922ea0f1f65dd07622
data/CHANGELOG.md ADDED
@@ -0,0 +1,17 @@
1
+ # Changelog
2
+
3
+ ## 3.0.0
4
+
5
+ - Require Ruby 3.4 or newer. Developed and CI-tested on Ruby 4.0.
6
+ - Upgrade Savon to `~> 2.17` and add the `cgi` gem (removed from default gems in Ruby 4.0).
7
+ - Call the Ideone SOAP API over HTTPS (`https://ideone.com/api/1/service.wsdl`).
8
+ - Replace Jeweler-generated packaging with a hand-maintained gemspec.
9
+ - Replace Travis CI with GitHub Actions (Ruby 3.4 and 4.0).
10
+ - Use Minitest 6 and WebMock for the test suite.
11
+ - Stop treating every Ideone error as `Ideone::AuthError`. Authentication failures still raise `AuthError`; other API errors raise `Ideone::Error`.
12
+ - Stop mutating shared request state between calls.
13
+ - Read credentials from `IDEONE_USER` / `IDEONE_PASSWORD` in optional live tests instead of hardcoding them.
14
+
15
+ ## 2.1.2
16
+
17
+ - Last Jeweler-era release (2014-05-10).
data/LICENSE.txt CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2011 Kenny Meyer
1
+ Copyright (c) 2011-2026 Kenny Meyer
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.md ADDED
@@ -0,0 +1,130 @@
1
+ # ideone-ruby-api
2
+
3
+ [![CI](https://github.com/kennym/ideone-ruby-api/actions/workflows/ci.yml/badge.svg)](https://github.com/kennym/ideone-ruby-api/actions/workflows/ci.yml)
4
+ [![Gem Version](https://badge.fury.io/rb/ideone-ruby-api.svg)](https://badge.fury.io/rb/ideone-ruby-api)
5
+
6
+ Ruby bindings for the [Ideone](https://ideone.com) SOAP API — an online compiler and pastebin.
7
+
8
+ Requires **Ruby 3.4+**. Developed on **Ruby 4.0**.
9
+
10
+ ## Ideone API status
11
+
12
+ The SOAP service this gem wraps is still live. The original operations
13
+ (`testFunction`, `getLanguages`, `createSubmission`, `getSubmissionStatus`,
14
+ `getSubmissionDetails`) still work:
15
+
16
+ | | |
17
+ |---|---|
18
+ | WSDL | `https://ideone.com/api/1/service.wsdl` |
19
+ | Endpoint | `https://ideone.com/api/1/service` |
20
+
21
+ [Sphere Engine](https://sphere-engine.com) no longer develops this SOAP API.
22
+ They recommend the [Compilers REST API v4](https://docs.sphere-engine.com/compilers/api/overview-version-4)
23
+ for new products. This gem stays on Ideone SOAP so existing callers keep working.
24
+
25
+ The old PDF (`http://ideone.com/files/ideone-api.pdf`) is gone.
26
+
27
+ ## Installation
28
+
29
+ ```ruby
30
+ # Gemfile
31
+ gem "ideone-ruby-api"
32
+ ```
33
+
34
+ ```bash
35
+ gem install ideone-ruby-api
36
+ ```
37
+
38
+ ## Usage
39
+
40
+ ```ruby
41
+ require "ideone"
42
+
43
+ client = Ideone.new("username", "password")
44
+
45
+ # Log SOAP traffic
46
+ client = Ideone.new("username", "password", true)
47
+
48
+ link = client.create_submission("puts 'hello, world'", 17) # 17 = Ruby
49
+ # => "TOKEN"
50
+
51
+ client.submission_status(link)
52
+ # => { status: 0, result: 15 }
53
+
54
+ client.submission_details(link)
55
+ # => { "error" => "OK", "langName" => "Ruby", "output" => "hello, world\n", ... }
56
+
57
+ client.languages
58
+ # => { "1" => "C++ (gcc 8.3)", "17" => "Ruby (ruby 2.5.5)", "116" => "Python 3 (python 3.12)", ... }
59
+
60
+ client.test
61
+ # => { "error" => "OK", "moreHelp" => "ideone.com", "pi" => "3.14",
62
+ # "answerToLifeAndEverything" => "42", "oOok" => true }
63
+ ```
64
+
65
+ ### Language ids
66
+
67
+ Call `languages` for the current list. As of 2026-09 these still match the old docs:
68
+
69
+ | Id | Language |
70
+ |---:|---|
71
+ | 1 | C++ (gcc 8.3) |
72
+ | 17 | Ruby (ruby 2.5.5) |
73
+ | 116 | Python 3 (python 3.12) |
74
+
75
+ ### Submission status and result
76
+
77
+ `submission_status` returns integers:
78
+
79
+ **status** (execution stage)
80
+
81
+ | Value | Meaning |
82
+ |---:|---|
83
+ | < 0 | waiting in queue |
84
+ | 0 | finished |
85
+ | 1 | compiling |
86
+ | 3 | running |
87
+
88
+ **result** (when status is 0)
89
+
90
+ | Value | Meaning |
91
+ |---:|---|
92
+ | 11 | compilation error |
93
+ | 12 | runtime error |
94
+ | 13 | time limit exceeded |
95
+ | 15 | success |
96
+ | 17 | memory limit exceeded |
97
+ | 19 | illegal system call |
98
+ | 20 | internal error |
99
+
100
+ Poll until `status == 0` before reading output from `submission_details`.
101
+
102
+ ### Errors
103
+
104
+ - `Ideone::AuthError` — Ideone returned `AUTH_ERROR`
105
+ - `Ideone::Error` — any other API or transport failure
106
+
107
+ ## Development
108
+
109
+ ```bash
110
+ bundle install
111
+ bundle exec rake
112
+ ```
113
+
114
+ Default tests are mocked (WebMock) and do not call Ideone.
115
+
116
+ ```bash
117
+ IDEONE_USER=you IDEONE_PASSWORD=secret bundle exec rake
118
+ ```
119
+
120
+ CI runs on Ruby 3.4 and 4.0.
121
+
122
+ ## Similar projects
123
+
124
+ - https://github.com/maveonair/ccpacona
125
+ - https://github.com/jonathanperret/ideone.rb
126
+ - https://github.com/Pistos/ideone-gem
127
+
128
+ ## License
129
+
130
+ Copyright (c) 2011-2026 Kenny Meyer. See [LICENSE.txt](LICENSE.txt).
@@ -1,3 +1,6 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Ideone
2
- class AuthError < StandardError; end
4
+ class Error < StandardError; end
5
+ class AuthError < Error; end
3
6
  end
@@ -1,9 +1,11 @@
1
- class Ideone
1
+ # frozen_string_literal: true
2
+
3
+ module Ideone
2
4
  module Version
3
- MAJOR = 2
4
- MINOR = 1
5
- PATCH = 1
5
+ MAJOR = 3
6
+ MINOR = 0
7
+ PATCH = 0
6
8
 
7
- STRING = [MAJOR, MINOR, PATCH].compact.join('.')
9
+ STRING = [MAJOR, MINOR, PATCH].join(".")
8
10
  end
9
11
  end
data/lib/ideone.rb CHANGED
@@ -1,139 +1,145 @@
1
- # This program is a Ruby API to the Ideone web service. For more
2
- # information about the Ideone API consult
3
- # http://ideone.com/files/ideone-api.pdf
1
+ # frozen_string_literal: true
2
+
3
+ # Ruby bindings for the Ideone SOAP API.
4
+ # See https://ideone.com/api/1/service.wsdl
4
5
  #
5
- # Author:: Kenny Meyer (kenny@kennymeyer.net)
6
- # Copyright:: Copyright (c) 2014
7
- # License:: Distributes under the same terms as Ruby
6
+ # Author:: Kenny Meyer (kenny@kennymeyer.net)
7
+ # Copyright:: Copyright (c) 2011-2026
8
+ # License:: MIT
8
9
 
9
- require_relative 'ideone/exceptions'
10
- require 'savon' # SOAP Client
10
+ require "savon"
11
+ require_relative "ideone/exceptions"
12
+ require_relative "ideone/version"
11
13
 
12
14
  module Ideone
13
- def self.new(username, password, verbose=false)
14
- return Ideone::Client.new(username, password, verbose)
15
+ def self.new(username, password, verbose = false, **options)
16
+ Client.new(username, password, verbose, **options)
15
17
  end
16
18
 
17
19
  class Client
18
- def initialize(username=nil, password=nil, verbose=false)
19
- @client = Savon.client(wsdl: "http://ideone.com/api/1/service.wsdl", log: verbose)
20
+ WSDL_URL = "https://ideone.com/api/1/service.wsdl"
21
+
22
+ def initialize(username = nil, password = nil, verbose = false, wsdl: WSDL_URL)
23
+ @client = Savon.client(
24
+ wsdl: wsdl,
25
+ log: verbose,
26
+ convert_request_keys_to: :none,
27
+ follow_redirects: true
28
+ )
20
29
  @languages_cache = nil
21
- @request_body = {
22
- :user => username,
23
- :pass => password,
30
+ @credentials = {
31
+ user: username,
32
+ pass: password
24
33
  }
25
34
  end
26
35
 
27
- def create_submission(source_code, lang_id, std_input="", run=true,
28
- is_private=false)
29
- request_body = @request_body
30
- request_body[:sourceCode] = source_code
31
- request_body[:language] = lang_id
32
- request_body[:input] = std_input
33
- request_body[:run] = run
34
- request_body[:private] = is_private
35
-
36
- response = call_request(:create_submission)
37
-
38
- return response.to_hash[:create_submission_response][:return][:item][1][:value]
36
+ def create_submission(source_code, lang_id, std_input = "", run = true,
37
+ is_private = false)
38
+ map = response_map(
39
+ call_request(:create_submission, {
40
+ sourceCode: source_code,
41
+ language: lang_id,
42
+ input: std_input,
43
+ run: run,
44
+ private: is_private
45
+ }),
46
+ :create_submission_response
47
+ )
48
+ map["link"]
39
49
  end
40
50
 
41
51
  def submission_status(link)
42
- request_body = @request_body
43
- request_body[:link] = link
52
+ map = response_map(
53
+ call_request(:get_submission_status, { link: link }),
54
+ :get_submission_status_response
55
+ )
44
56
 
45
- response = call_request(:get_submission_status)
46
-
47
- status = response.to_hash[:get_submission_status_response][:return][:item][1][:value].to_i
48
- result = response.to_hash[:get_submission_status_response][:return][:item][2][:value].to_i
49
-
50
- if status < 0
51
- status = -1
52
- end
57
+ status = map["status"].to_i
58
+ result = map["result"].to_i
59
+ status = -1 if status < 0
53
60
 
54
- return { :status => status, :result => result }
61
+ { status: status, result: result }
55
62
  end
56
63
 
57
64
  def submission_details(link,
58
- with_source=true,
59
- with_input=true,
60
- with_output=true,
61
- with_stderr=true,
62
- with_cmpinfo=true)
63
- request_body = @request_body
64
- request_body[:link] = link
65
- request_body[:withSource] = with_source
66
- request_body[:withInput] = with_input
67
- request_body[:withOutput] = with_output
68
- request_body[:withStderr] = with_stderr
69
- request_body[:withCmpinfo] = with_cmpinfo
70
-
71
- response = call_request(:get_submission_details, :message => request_body)
72
-
73
- details = response.to_hash[:get_submission_details_response][:return][:item]
74
-
75
- create_dict(details)
65
+ with_source = true,
66
+ with_input = true,
67
+ with_output = true,
68
+ with_stderr = true,
69
+ with_cmpinfo = true)
70
+ response_map(
71
+ call_request(:get_submission_details, {
72
+ link: link,
73
+ withSource: with_source,
74
+ withInput: with_input,
75
+ withOutput: with_output,
76
+ withStderr: with_stderr,
77
+ withCmpinfo: with_cmpinfo
78
+ }),
79
+ :get_submission_details_response
80
+ )
76
81
  end
77
82
 
78
- # Get a list of supported languages and cache it.
79
83
  def languages
80
- unless @languages_cache
81
- response = call_request(:get_languages)
82
-
83
- languages = response.to_hash[:get_languages_response][:return][:item][1][:value][:item]
84
- # Create a sorted hash
85
- @languages_cache = Hash[create_dict(languages).sort_by{|k,v| k.to_i}]
84
+ @languages_cache ||= begin
85
+ map = response_map(call_request(:get_languages), :get_languages_response)
86
+ create_dict(array_wrap(nested_items(map["languages"]))).sort_by { |k, _| k.to_i }.to_h
86
87
  end
87
- return @languages_cache
88
88
  end
89
89
 
90
- # A test function that always returns the same thing.
91
90
  def test
92
- response = call_request(:test_function)
93
-
94
- items = response.to_hash[:test_function_response][:return][:item]
95
-
96
- return create_dict(items)
91
+ response_map(call_request(:test_function), :test_function_response)
97
92
  end
98
93
 
99
94
  private
100
95
 
96
+ def call_request(api_endpoint, extra = {})
97
+ response = @client.call(api_endpoint, message: @credentials.merge(extra))
98
+ check_error(response, :"#{api_endpoint}_response")
99
+ response
100
+ rescue Savon::Error => e
101
+ raise Error, e.message
102
+ end
103
+
101
104
  def check_error(response, function_response)
102
- error = get_error(response.to_hash, function_response)
103
- if error != 'OK'
104
- raise Ideone::AuthError, "Invalid Ideone credentials provided"
105
+ error = response_map(response, function_response)["error"]
106
+ return if error == "OK"
107
+
108
+ if error == "AUTH_ERROR"
109
+ raise AuthError, "Invalid Ideone credentials provided"
105
110
  end
111
+
112
+ raise Error, error.to_s
106
113
  end
107
114
 
108
- def call_request(api_endpoint)
109
- begin
110
- response = @client.call(api_endpoint, :message => @request_body)
111
- rescue Exception => e
112
- raise e
113
- end
114
- check_error(response, "#{api_endpoint}_response".to_sym)
115
- return response
115
+ def response_map(response, function_response)
116
+ items = response.to_hash.dig(function_response, :return, :item)
117
+ raise Error, "Unexpected response from Ideone API" if items.nil?
118
+
119
+ create_dict(array_wrap(items))
116
120
  end
117
121
 
118
- def get_error(response, function_response)
119
- begin
120
- return response[function_response][:return][:item][0][:value]
121
- rescue
122
- return response[function_response][:return][:item][:value]
122
+ def create_dict(items)
123
+ items.each_with_object({}) do |item, dict|
124
+ dict[item[:key]] = normalize_value(item[:value])
123
125
  end
124
126
  end
125
127
 
126
- def create_dict(items)
127
- dict = {}
128
+ def nested_items(value)
129
+ return value[:item] if value.is_a?(Hash) && value.key?(:item)
128
130
 
129
- items.each do |item|
130
- key = item[:key]
131
- value = item[:value]
132
- value = "" if value == {:"@xsi:type"=>"xsd:string"}
133
- dict[key] = value
134
- end
131
+ value
132
+ end
133
+
134
+ def array_wrap(value)
135
+ value.is_a?(Array) ? value : [value]
136
+ end
137
+
138
+ def normalize_value(value)
139
+ return "" if value.nil?
140
+ return "" if value.is_a?(Hash) && value.keys.all? { |key| key.to_s.start_with?("@") }
135
141
 
136
- dict
142
+ value
137
143
  end
138
144
  end
139
145
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ideone-ruby-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.1
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kenny Meyer
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2014-05-10 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: savon
@@ -16,68 +15,92 @@ dependencies:
16
15
  requirements:
17
16
  - - "~>"
18
17
  - !ruby/object:Gem::Version
19
- version: 2.3.3
18
+ version: '2.17'
20
19
  type: :runtime
21
20
  prerelease: false
22
21
  version_requirements: !ruby/object:Gem::Requirement
23
22
  requirements:
24
23
  - - "~>"
25
24
  - !ruby/object:Gem::Version
26
- version: 2.3.3
25
+ version: '2.17'
27
26
  - !ruby/object:Gem::Dependency
28
- name: jeweler
27
+ name: cgi
29
28
  requirement: !ruby/object:Gem::Requirement
30
29
  requirements:
31
30
  - - "~>"
32
31
  - !ruby/object:Gem::Version
33
- version: 2.0.1
32
+ version: '0.5'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '0.5'
40
+ - !ruby/object:Gem::Dependency
41
+ name: minitest
42
+ requirement: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: '6.0'
47
+ type: :development
48
+ prerelease: false
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '6.0'
54
+ - !ruby/object:Gem::Dependency
55
+ name: rake
56
+ requirement: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: '13.4'
34
61
  type: :development
35
62
  prerelease: false
36
63
  version_requirements: !ruby/object:Gem::Requirement
37
64
  requirements:
38
65
  - - "~>"
39
66
  - !ruby/object:Gem::Version
40
- version: 2.0.1
67
+ version: '13.4'
41
68
  - !ruby/object:Gem::Dependency
42
- name: test-unit
69
+ name: webmock
43
70
  requirement: !ruby/object:Gem::Requirement
44
71
  requirements:
45
72
  - - "~>"
46
73
  - !ruby/object:Gem::Version
47
- version: '2.3'
74
+ version: '3.26'
48
75
  type: :development
49
76
  prerelease: false
50
77
  version_requirements: !ruby/object:Gem::Requirement
51
78
  requirements:
52
79
  - - "~>"
53
80
  - !ruby/object:Gem::Version
54
- version: '2.3'
55
- description: 'A better Ruby binding for the Ideone API '
56
- email: kenny@kennymeyer.net
81
+ version: '3.26'
82
+ description: A Ruby binding for the Ideone SOAP API (online compiler / pastebin).
83
+ email:
84
+ - kenny@kennymeyer.net
57
85
  executables: []
58
86
  extensions: []
59
- extra_rdoc_files:
60
- - LICENSE.txt
61
- - README.rdoc
87
+ extra_rdoc_files: []
62
88
  files:
63
- - ".document"
64
- - ".travis.yml"
65
- - Gemfile
89
+ - CHANGELOG.md
66
90
  - LICENSE.txt
67
- - README.rdoc
68
- - Rakefile
69
- - VERSION
70
- - ideone-ruby-api.gemspec
91
+ - README.md
71
92
  - lib/ideone.rb
72
93
  - lib/ideone/exceptions.rb
73
94
  - lib/ideone/version.rb
74
- - test/helper.rb
75
- - test/test_ideone-ruby-api.rb
76
- homepage: http://github.com/kennym/ideone-ruby-api
95
+ homepage: https://github.com/kennym/ideone-ruby-api
77
96
  licenses:
78
97
  - MIT
79
- metadata: {}
80
- post_install_message:
98
+ metadata:
99
+ homepage_uri: https://github.com/kennym/ideone-ruby-api
100
+ source_code_uri: https://github.com/kennym/ideone-ruby-api/tree/master
101
+ changelog_uri: https://github.com/kennym/ideone-ruby-api/blob/master/CHANGELOG.md
102
+ bug_tracker_uri: https://github.com/kennym/ideone-ruby-api/issues
103
+ rubygems_mfa_required: 'true'
81
104
  rdoc_options: []
82
105
  require_paths:
83
106
  - lib
@@ -85,16 +108,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
85
108
  requirements:
86
109
  - - ">="
87
110
  - !ruby/object:Gem::Version
88
- version: '0'
111
+ version: '3.4'
89
112
  required_rubygems_version: !ruby/object:Gem::Requirement
90
113
  requirements:
91
114
  - - ">="
92
115
  - !ruby/object:Gem::Version
93
116
  version: '0'
94
117
  requirements: []
95
- rubyforge_project:
96
- rubygems_version: 2.2.2
97
- signing_key:
118
+ rubygems_version: 4.0.20
98
119
  specification_version: 4
99
- summary: Ruby binding for Ideone API
120
+ summary: Ruby binding for the Ideone API
100
121
  test_files: []
data/.document DELETED
@@ -1,5 +0,0 @@
1
- lib/**/*.rb
2
- bin/*
3
- -
4
- features/**/*.feature
5
- LICENSE.txt
data/.travis.yml DELETED
@@ -1,5 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 1.9.2
4
- - 1.9.3
5
- - 2.0.0
data/Gemfile DELETED
@@ -1,12 +0,0 @@
1
- source "http://rubygems.org"
2
- # Add dependencies required to use your gem here.
3
- # Example:
4
- # gem "activesupport", ">= 2.3.5"
5
- gem "savon", "~> 2.3.3"
6
-
7
- # Add dependencies to develop your gem here.
8
- # Include everything needed to run rake, tests, features, etc.
9
- group :development do
10
- gem "jeweler", "~> 2.0.1"
11
- gem "test-unit", "~> 2.3"
12
- end
data/README.rdoc DELETED
@@ -1,85 +0,0 @@
1
- = ideone-ruby-api
2
-
3
- {<img src="https://secure.travis-ci.org/kennym/ideone-ruby-api.png" />}[http://travis-ci.org/kennym/ideone-ruby-api]
4
- {<img src="https://badge.fury.io/rb/ideone-ruby-api.png" alt="Gem Version" />}[http://badge.fury.io/rb/ideone-ruby-api]
5
- {<img src="https://ga-beacon.appspot.com/UA-48308186-1/ideone-ruby-api/README.rdoc" alt="GA analytics" />}[https://ga-beacon.appspot.com/UA-48308186-1/ideone-ruby-api/README.rdoc]
6
-
7
- Ideone is a pastebin, as well as an online compiler and debugger. This
8
- project is a Ruby binding to the Ideone API.
9
-
10
- Requires Ruby =>1.9.2
11
-
12
- == Usage
13
-
14
- require 'ideone'
15
-
16
- # Authenticate with Ideone
17
- i = Ideone.new('username', 'password')
18
- => #<Ideone:0x000000021dfd88 ... >
19
-
20
- # Enable logging by setting flag to `true`
21
- i = Ideone.new('username', 'password', true)
22
- => #<Ideone:0x000000021dfd88 ... >
23
-
24
- # Create submission
25
- source_code = "puts 'hello, world'"
26
- i.create_submission(source_code,
27
- 17) # Ruby
28
- => 'TOKEN'
29
-
30
- # Get submission status
31
- i.submission_status("TOKEN")
32
- => {:status=>0, :result=>15}
33
-
34
- # Get all available languages
35
- i.languages
36
- => {"1"=>"C++ (gcc-4.3.4)", "2"=>"Pascal (gpc) (gpc 20070904)",
37
- "3"=>"Perl (perl 5.12.1)", "4"=>"Python (python 2.6.4)"
38
-
39
- # Test that everything's working
40
- i.test
41
- => {"error"=>"OK",
42
- "moreHelp"=>"ideone.com",
43
- "pi"=>"3.14",
44
- "answerToLifeAndEverything"=>"42",
45
- "oOok"=>true}
46
-
47
- == Similar projects
48
-
49
- * https://github.com/maveonair/ccpacona
50
- * https://github.com/jonathanperret/ideone.rb
51
- * https://github.com/Pistos/ideone-gem/blob/master/lib/ideone.rb
52
-
53
- I stole the best ideas from each of the above projects, which, I
54
- think, makes it much more robust, and it includes tests (which
55
- actually pass).
56
-
57
- == Running the test suite
58
-
59
- To run the test suite, please fill out USER and PASS in test/test_ideone-ruby-api.rb
60
-
61
- Then, you can run `rake test`
62
-
63
- == In the wild
64
-
65
- * Nejupy ( https://github.com/kennym/nejupy-ruby )
66
-
67
- == Contributing to ideone-ruby-api
68
-
69
- * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
70
- * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
71
- * Fork the project
72
- * Start a feature/bugfix branch
73
- * Commit and push until you are happy with your contribution
74
- * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
75
- * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
76
-
77
- == References
78
-
79
- * http://ideone.com/files/ideone-api.pdf
80
-
81
- == Copyright
82
-
83
- Copyright (c) 2011-2014 Kenny Meyer. See LICENSE.txt for
84
- further details.
85
-
data/Rakefile DELETED
@@ -1,47 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require 'rubygems'
4
- require 'bundler'
5
- begin
6
- Bundler.setup(:default, :development)
7
- rescue Bundler::BundlerError => e
8
- $stderr.puts e.message
9
- $stderr.puts "Run `bundle install` to install missing gems"
10
- exit e.status_code
11
- end
12
- require 'rake'
13
-
14
- require 'jeweler'
15
- require './lib/ideone/version.rb'
16
- Jeweler::Tasks.new do |gem|
17
- # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
18
- gem.version = Ideone::Version::STRING
19
- gem.name = "ideone-ruby-api"
20
- gem.homepage = "http://github.com/kennym/ideone-ruby-api"
21
- gem.license = "MIT"
22
- gem.summary = "Ruby binding for Ideone API"
23
- gem.description = "A better Ruby binding for the Ideone API "
24
- gem.email = "kenny@kennymeyer.net"
25
- gem.authors = ["Kenny Meyer"]
26
- # dependencies defined in Gemfile
27
- end
28
- Jeweler::RubygemsDotOrgTasks.new
29
-
30
- require 'rake/testtask'
31
- Rake::TestTask.new(:test) do |test|
32
- test.libs << 'lib' << 'test'
33
- test.pattern = 'test/**/test_*.rb'
34
- test.verbose = true
35
- end
36
-
37
- task :default => :test
38
-
39
- require 'rdoc/task'
40
- Rake::RDocTask.new do |rdoc|
41
- version = File.exist?('VERSION') ? File.read('VERSION') : ""
42
-
43
- rdoc.rdoc_dir = 'rdoc'
44
- rdoc.title = "ideone-ruby-api #{version}"
45
- rdoc.rdoc_files.include('README*')
46
- rdoc.rdoc_files.include('lib/**/*.rb')
47
- end
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 2.0.0
@@ -1,59 +0,0 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
- # -*- encoding: utf-8 -*-
5
- # stub: ideone-ruby-api 2.1.1 ruby lib
6
-
7
- Gem::Specification.new do |s|
8
- s.name = "ideone-ruby-api"
9
- s.version = "2.1.1"
10
-
11
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
- s.require_paths = ["lib"]
13
- s.authors = ["Kenny Meyer"]
14
- s.date = "2014-05-10"
15
- s.description = "A better Ruby binding for the Ideone API "
16
- s.email = "kenny@kennymeyer.net"
17
- s.extra_rdoc_files = [
18
- "LICENSE.txt",
19
- "README.rdoc"
20
- ]
21
- s.files = [
22
- ".document",
23
- ".travis.yml",
24
- "Gemfile",
25
- "LICENSE.txt",
26
- "README.rdoc",
27
- "Rakefile",
28
- "VERSION",
29
- "ideone-ruby-api.gemspec",
30
- "lib/ideone.rb",
31
- "lib/ideone/exceptions.rb",
32
- "lib/ideone/version.rb",
33
- "test/helper.rb",
34
- "test/test_ideone-ruby-api.rb"
35
- ]
36
- s.homepage = "http://github.com/kennym/ideone-ruby-api"
37
- s.licenses = ["MIT"]
38
- s.rubygems_version = "2.2.2"
39
- s.summary = "Ruby binding for Ideone API"
40
-
41
- if s.respond_to? :specification_version then
42
- s.specification_version = 4
43
-
44
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
45
- s.add_runtime_dependency(%q<savon>, ["~> 2.3.3"])
46
- s.add_development_dependency(%q<jeweler>, ["~> 2.0.1"])
47
- s.add_development_dependency(%q<test-unit>, ["~> 2.3"])
48
- else
49
- s.add_dependency(%q<savon>, ["~> 2.3.3"])
50
- s.add_dependency(%q<jeweler>, ["~> 2.0.1"])
51
- s.add_dependency(%q<test-unit>, ["~> 2.3"])
52
- end
53
- else
54
- s.add_dependency(%q<savon>, ["~> 2.3.3"])
55
- s.add_dependency(%q<jeweler>, ["~> 2.0.1"])
56
- s.add_dependency(%q<test-unit>, ["~> 2.3"])
57
- end
58
- end
59
-
data/test/helper.rb DELETED
@@ -1,17 +0,0 @@
1
- require 'rubygems'
2
- require 'bundler'
3
- begin
4
- Bundler.setup(:default, :development)
5
- rescue Bundler::BundlerError => e
6
- $stderr.puts e.message
7
- $stderr.puts "Run `bundle install` to install missing gems"
8
- exit e.status_code
9
- end
10
- require 'test/unit'
11
-
12
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
13
- $LOAD_PATH.unshift(File.dirname(__FILE__))
14
- require 'ideone'
15
-
16
- class Test::Unit::TestCase
17
- end
@@ -1,79 +0,0 @@
1
- require 'helper'
2
-
3
- USER = 'humpydumpy' # YOUR IDEONE USER
4
- PASS = 'testing' # YOUR IDEONE PASSWORD
5
-
6
- class TestIdeoneRubyApi < Test::Unit::TestCase
7
- def test_initialize
8
- omit_if(USER.empty? || PASS.empty?, "Specify ideone USER and PASS")
9
-
10
- instance = Ideone::Client.new
11
- assert_not_nil(instance)
12
-
13
- instance = Ideone::Client.new(USER, PASS)
14
- assert_not_nil(instance)
15
- end
16
-
17
- def test_ideone_test
18
- omit_if(USER.empty? || PASS.empty?, "Specify ideone USER and PASS")
19
-
20
- instance = Ideone::Client.new(USER, PASS)
21
-
22
- result = instance.test
23
-
24
- def compare_intersecting_keys(a, b)
25
- (a.keys & b.keys).all? {|k| a[k] == b[k]}
26
- end
27
-
28
- assert compare_intersecting_keys(result,{"error"=>"OK", "moreHelp"=>"ideone.com", "pi"=>"3.14", "answerToLifeAndEverything"=>"42", "oOok"=>true}) == true
29
- assert_not_nil result
30
- end
31
-
32
- def test_languages
33
- omit_if(USER.empty? || PASS.empty?, "Specify ideone USER and PASS")
34
-
35
- instance = Ideone::Client.new(USER, PASS)
36
-
37
- result = instance.languages
38
-
39
- assert result.count > 10
40
- assert_not_nil result
41
- end
42
-
43
- def test_create_submission
44
- omit_if(USER.empty? || PASS.empty?, "Specify ideone USER and PASS")
45
-
46
- instance = Ideone::Client.new(USER, PASS)
47
-
48
- code = <<-eos
49
- puts "This is a test submission created from ideone-ruby-api. https://github.com/kennym/ideone-gem/blob/master/lib/ideone.rb"
50
- eos
51
- result = instance.create_submission(code, 17)
52
-
53
- assert result.is_a?(String)
54
- assert_not_nil result
55
- end
56
-
57
- def test_submission_status
58
- omit_if(USER.empty? || PASS.empty?, "Specify ideone USER and PASS")
59
-
60
- instance = Ideone::Client.new(USER, PASS)
61
-
62
- result = instance.submission_status("PD2kqM")
63
-
64
- assert_not_nil result
65
- assert_not_nil result[:status]
66
- assert_not_nil result[:result]
67
- end
68
-
69
- def test_submission_details
70
- omit_if(USER.empty? || PASS.empty?, "Specify ideone USER and PASS")
71
-
72
- instance = Ideone::Client.new(USER, PASS)
73
-
74
- result = instance.submission_details("PD2kqM")
75
-
76
- assert result.count == 16
77
- assert_not_nil result
78
- end
79
- end