Skip to content

amjd/HackerEarth-Ruby

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

#HackerEarth API wrapper

This is a simple API wrapper for HackerEarth.

###Usage To use this wrapper create an object with the mandatory parameters: API key (secret), source of the file to compile/run, and the language.

hackerearth = HackerEarth.new(secret,source,lang)

Here's a fuller example:

require 'PATH/TO/HackerEarth.rb'
require 'json'

secret = "YOUR_API_KEY"
source = open('test.py').read
lang = "PYTHON"

hackerearth = HackerEarth.new(secret,source,lang)

puts JSON.pretty_generate JSON.parse(hackerearth.run)

####Output

{
  "errors": {
  },
  "code_id": "62202fb",
  "web_link": "http://code.hackerearth.com/62202fb",
  "compile_status": "OK",
  "id": "b63178a",
  "async": 0,
  "message": "OK",
  "run_status": {
    "status": "AC",
    "time_limit": 5,
    "output_html": "Hello&nbsp;John&nbsp;Doe!<br>",
    "memory_limit": 262144,
    "time_used": "0.1007",
    "signal": "OTHER",
    "status_detail": "N/A",
    "output": "Hello John Doe!\n",
    "async": 0,
    "memory_used": "64"
  }
}

###Multiple runs

You can compile/run multiple times by just changing source, language or input like so:

hackerearth.source = open('some_other_file.c').read
hackerearth.lang = 'C'
hackerearth.input = '4 32'

puts JSON.pretty_generate JSON.parse(hackerearth.run)

Or if you want to change any other parameter, just create another object.

##Contribute

Feel free to contribute and submit pull requests.

About

HackerEarth API Wrapper in Ruby

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published