Sha256: a7c61e7100743286db333792044e246c9ba5b5e5700b3ef1bbe29b9c690055dd
Contents?: true
Size: 968 Bytes
Versions: 1
Compression:
Stored size: 968 Bytes
Contents
class Exercism class Api def self.conn conn = Faraday.new(:url => Exercism.url) do |c| c.use Faraday::Adapter::NetHttp end end def self.fetch_for(user, path) response = conn.get do |req| req.url '/api/v1/user/assignments/current' req.headers['User-Agent'] = "exercism-CLI v#{Exercism::VERSION}" req.params['key'] = user.key end Assignment.save(JSON.parse(response.body), path) end def self.submit(filename, options) user = options[:for] path = File.join(filename) contents = File.read path response = conn.post do |req| req.url '/api/v1/user/assignments' req.headers['Accept'] = 'application/json' req.headers['Content-Type'] = 'application/json' req.headers['User-Agent'] = "exercism-CLI v#{Exercism::VERSION}" req.body = {code: contents, key: user.key, path: path}.to_json end response end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
exercism-0.0.5 | lib/exercism/api.rb |