我尝试在我的类HTTParty中使用FindXYZ扩展Thor,但它不起作用。我只想使用HTTParty get来查询couchdb,我的方法是xyz。
当我尝试运行时,我看到错误找不到get
require 'json'
require 'httparty'
require 'thor'
class FindXyz < Thor
include Thor::Actions
include HTTParty
headers 'Accept' => 'application/json'
server = '192.168.5.50:5984'
user = 'uname'
password = 'passo'
couchdb_url = "http://#{user}:#{password}@#{server}"
basic_auth user, password
base_uri couchdb_url
default_params :output => 'json'
format :json
desc "xyz", "Find scenarios that contains SSL"
method_option :name, :aliases => "-t", :required => true
method_option :location, :aliases => "-s",:required => true
def xyz
name = options[:name]
loc = options[:location]
file_path = File.join(loc, name)
t_json = JSON.parse(File.read(file_path))
t_json["ids"].each do |temp|
path_to_doc = "/test123/#{temp}"
response = get(path_to_doc)
puts "Found => #{temp}" if response.to_s.include?('Birdy')
end #close the loop
end #close the method xyz
end #close class发布于 2012-05-30 03:22:15
试着从课堂外这样做
puts FindXyz.get('....').inspect和HTTParty.get(...)在FinXyz类中
https://stackoverflow.com/questions/10809482
复制相似问题