lib/pybossa-api.rb in pybossa-api-0.0.1 vs lib/pybossa-api.rb in pybossa-api-0.0.2

- old
+ new

@@ -1,21 +1,16 @@ -$LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__))) unless $LOAD_PATH.include?(File.expand_path(File.dirname(__FILE__))) +require 'json' require 'httparty' require 'sanitize' -require 'yajl' module PyBossa - autoload :App, 'pybossa-api/app' - autoload :Task, 'pybossa-api/task' - autoload :TaskRun, 'pybossa-api/task_run' - # A Ruby wrapper for the PyBossa API. # @see http://docs.pybossa.com/en/latest/model.html#restful-api class API include HTTParty - base_uri 'pybossa.com/api' + base_uri 'crowdcrafting.org/api' class Error < StandardError; end class << self attr_accessor :api_key @@ -92,15 +87,19 @@ def request(http_method, path, opts) opts[:api_key] ||= api_key if api_key response = if [:get, :delete].include? http_method send http_method, path, :query => opts else - send http_method, path, :query => {:api_key => opts.delete(:api_key)}, :body => Yajl::Encoder.encode(opts), :headers => {'Content-type' => 'application/json'} + send http_method, path, :query => {:api_key => opts.delete(:api_key)}, :body => JSON.dump(opts), :headers => {'Content-type' => 'application/json'} end unless [200, 204].include? response.response.code.to_i raise PyBossa::API::Error.new Sanitize.clean(response.response.body) end response.parsed_response end end end end + +require 'pybossa-api/app' +require 'pybossa-api/task' +require 'pybossa-api/task_run'