sphereengine-ruby 1.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 438e5cd04721c438f2dbf2b97cb775d64b8d51a7
4
+ data.tar.gz: 752040f86c15e853468fdde94ded4457736c534d
5
+ SHA512:
6
+ metadata.gz: 2123927f7403bc71ca6ae21dd8d668a82e8365ee5cc2837b09e6c0b40f28522f32370de6fda4d310c1fe82e32dfefabfb21c8ea2b3209c28fb0f1b85e135b00e
7
+ data.tar.gz: e3f9e803852cd02f0fb79a34e67aa9677568c2a89c7446a6f0efa7b8397b06afa351c7ecf7f369bc5d435993394ed29d961c80b2e8fa8d4a3b73cfc6d2fadb3a
data/README.md ADDED
@@ -0,0 +1,9 @@
1
+ # SphereEngine ruby client gem
2
+
3
+ ![Build Status](https://travis-ci.org/eXiga/sphereengine-ruby.svg?branch=master)
4
+ [![Coverage Status](https://coveralls.io/repos/eXiga/sphereengine-ruby/badge.svg?branch=master)](https://coveralls.io/r/eXiga/sphereengine-ruby?branch=master)
5
+
6
+ A Ruby interface to the SphereEngine API.
7
+
8
+ ## Installation
9
+ gem install sphereengine-ruby
@@ -0,0 +1,2 @@
1
+ require 'sphereengine-ruby/client'
2
+ require 'sphereengine-ruby/request'
@@ -0,0 +1,46 @@
1
+ require 'json'
2
+
3
+ module SphereEngine
4
+ class SphereEngineClient
5
+ attr_accessor :access_token
6
+
7
+ def initialize(token)
8
+ @access_token = token
9
+ end
10
+
11
+ def test_connection
12
+ uri = URI(SphereEngine::Request::BASE_URL + SphereEngine::Request::TEST_ENDPOINT)
13
+ uri.query = URI.encode_www_form({"access_token" => access_token})
14
+ JSON.parse Net::HTTP.get_response(uri).body
15
+ end
16
+
17
+ def languages
18
+ uri = URI(SphereEngine::Request::BASE_URL + SphereEngine::Request::LANGUAGES_ENDPOINT)
19
+ uri.query = URI.encode_www_form({"access_token" => access_token})
20
+ JSON.parse Net::HTTP.get_response(uri).body
21
+ end
22
+
23
+ def send_submission(source_code, language, input)
24
+ uri = URI(SphereEngine::Request::BASE_URL + SphereEngine::Request::SUBMISSIONS_ENDPOINT)
25
+ uri.query = URI.encode_www_form({"access_token" => access_token})
26
+ response = Net::HTTP.post_form(uri, {'sourceCode' => source_code, 'language' => language, 'input' => input})
27
+ JSON.parse response.body
28
+ end
29
+
30
+ def fetch_submission(id, with_source = true,
31
+ with_input = true,
32
+ with_output = true,
33
+ with_stderr = true,
34
+ with_cmpinfo = true)
35
+ uri = URI(SphereEngine::Request::BASE_URL +
36
+ SphereEngine::Request::FETCH_SUBMISSION_ENDPOINT.sub(':id', id.to_s))
37
+ uri.query = URI.encode_www_form({"access_token" => access_token,
38
+ "withSource" => with_source,
39
+ "withInput" => with_input,
40
+ "withOutput" => with_output,
41
+ "withStderr" => with_stderr,
42
+ "withCmpinfo" => with_cmpinfo})
43
+ JSON.parse Net::HTTP.get_response(uri).body
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,9 @@
1
+ module SphereEngine
2
+ module Request
3
+ BASE_URL = 'http://api.compilers.sphere-engine.com/api/v3'
4
+ TEST_ENDPOINT = '/test?'
5
+ LANGUAGES_ENDPOINT = '/languages?'
6
+ SUBMISSIONS_ENDPOINT = '/submissions?'
7
+ FETCH_SUBMISSION_ENDPOINT = '/submissions/:id?'
8
+ end
9
+ end
@@ -0,0 +1,5 @@
1
+ module SphereEngine
2
+ module Version
3
+ STRING = '1.0.0'
4
+ end
5
+ end
@@ -0,0 +1,15 @@
1
+ $LOAD_PATH.unshift File.expand_path('../lib', __FILE__)
2
+ require 'sphereengine-ruby/version'
3
+
4
+ Gem::Specification.new do |s|
5
+ s.name = 'sphereengine-ruby'
6
+ s.version = SphereEngine::Version::STRING
7
+ s.platform = Gem::Platform::RUBY
8
+ s.license = 'MIT'
9
+ s.authors = ['Anton Kostenich']
10
+ s.email = 'anton.kostenich@hotmail.com'
11
+ s.homepage = 'https://github.com/eXiga/sphereengine-ruby'
12
+ s.summary = "sphereengine-ruby-#{SphereEngine::Version::STRING}"
13
+ s.description = 'Ruby client for SphereEngine service'
14
+ s.files = %w(README.md sphereengine-ruby.gemspec) + Dir['lib/**/*.rb']
15
+ end
metadata ADDED
@@ -0,0 +1,49 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sphereengine-ruby
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Anton Kostenich
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-05-18 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Ruby client for SphereEngine service
14
+ email: anton.kostenich@hotmail.com
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - README.md
20
+ - lib/sphereengine-ruby.rb
21
+ - lib/sphereengine-ruby/client.rb
22
+ - lib/sphereengine-ruby/request.rb
23
+ - lib/sphereengine-ruby/version.rb
24
+ - sphereengine-ruby.gemspec
25
+ homepage: https://github.com/eXiga/sphereengine-ruby
26
+ licenses:
27
+ - MIT
28
+ metadata: {}
29
+ post_install_message:
30
+ rdoc_options: []
31
+ require_paths:
32
+ - lib
33
+ required_ruby_version: !ruby/object:Gem::Requirement
34
+ requirements:
35
+ - - ">="
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ required_rubygems_version: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: '0'
43
+ requirements: []
44
+ rubyforge_project:
45
+ rubygems_version: 2.4.5
46
+ signing_key:
47
+ specification_version: 4
48
+ summary: sphereengine-ruby-1.0.0
49
+ test_files: []