class Restflow::Sequence
Attributes
description[R]
responses[R]
Public Class Methods
new(execution_dir, description, base_url = nil, &block)
click to toggle source
# File lib/restflow/sequence.rb, line 27 def initialize(execution_dir, description, base_url = nil, &block) @responses = [] @execution_dir = execution_dir @base_url = base_url if base_url @description = description raise "Sequence block is empty!!" unless block instance_eval &block end
Public Instance Methods
base_url(url)
click to toggle source
# File lib/restflow/sequence.rb, line 36 def base_url(url) @base_url = url end
delete(path, data = nil)
click to toggle source
# File lib/restflow/sequence.rb, line 52 def delete(path, data = nil) @response = send_post_data(:delete, path, data) @responses << @response @response end
get(path)
click to toggle source
# File lib/restflow/sequence.rb, line 40 def get(path) @response = HTTParty.get("#{@base_url}/#{path}") @responses << @response @response end
html()
click to toggle source
# File lib/restflow/sequence.rb, line 68 def html Nokogiri::HTML(@response.body) end
json()
click to toggle source
# File lib/restflow/sequence.rb, line 72 def json JSON.parse(@response.body) if @response.body end
post(path, data)
click to toggle source
# File lib/restflow/sequence.rb, line 46 def post(path, data) @response = send_post_data(:post, path, data) @responses << @response @response end
put(path, data)
click to toggle source
# File lib/restflow/sequence.rb, line 58 def put(path, data) @response = send_post_data(:put, path, data) @responses << @response @response end
response()
click to toggle source
# File lib/restflow/sequence.rb, line 64 def response @response.body end
status()
click to toggle source
# File lib/restflow/sequence.rb, line 76 def status @response.code end
Private Instance Methods
send_post_data(verb, path, post_data)
click to toggle source
# File lib/restflow/sequence.rb, line 82 def send_post_data(verb, path, post_data) if post_data.is_a?(Hash) file_path = File.expand_path(post_data[:file], @execution_dir) body = File.new(file_path).read else body = post_data end HTTParty.send(verb, "#{@base_url}/#{path}", :body => body) end