Sinatra错误与dashingio和rest-client

时间:2015-10-20 16:00:44

标签: ruby gem sinatra rest-client dashing

我在dashingio工作中使用rest-client。自从为rest-client添加代码后,我在dashing start

上收到以下错误
/Users/emcevoy/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/sinatra-1.4.6/lib/sinatra/base.rb:1595:in `define_method': tried to create Proc object without a block (ArgumentError)

的Gemfile

source 'https://rubygems.org'

gem 'dashing'

## Remove this if you don't need a twitter widget.
gem 'twitter', '>= 5.9.0'

myjob.rb

  require "rubygems"
  require "json"
  require "rest-client"
  require "requests"
  require "pp"
...
  def post(theJson)
    theUrl = $location + $endpoint.to_str
    begin
        response = RestClient.post(theUrl, theJson, :content_type => :json)
        if(response.code > 204)
            $stderr.puts("Failed to post Json to endpoint " + theUrl + "\nReturn code: " + response.code.to_s)
            exit 1
        end
    rescue Errno::ECONNREFUSED
        $stderr.puts("Server refusing connection!")
        exit 1
    end
    if(JSON.parse(response).has_key?("error")) then
        $stderr.puts("Returned an error...")
        $stderr.puts JSON.parse(response)["error"]
        exit 1
    end
    return(response)
  end

0 个答案:

没有答案