Class: Restflow::Sequence

Inherits:
Object
  • Object
show all
Defined in:
lib/restflow/sequence.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(execution_dir, description, base_url = nil, &block) ⇒ Sequence

Returns a new instance of Sequence.



27
28
29
30
31
32
33
34
# 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

Instance Attribute Details

#descriptionObject (readonly)

Returns the value of attribute description.



25
26
27
# File 'lib/restflow/sequence.rb', line 25

def description
  @description
end

#responsesObject (readonly)

Returns the value of attribute responses.



25
26
27
# File 'lib/restflow/sequence.rb', line 25

def responses
  @responses
end

Instance Method Details

#base_url(url) ⇒ Object



36
37
38
# File 'lib/restflow/sequence.rb', line 36

def base_url(url)
  @base_url = url
end

#delete(path, data = nil) ⇒ Object



52
53
54
55
56
# 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) ⇒ Object



40
41
42
43
44
# File 'lib/restflow/sequence.rb', line 40

def get(path)
  @response = HTTParty.get("#{@base_url}/#{path}")
  @responses << @response
  @response
end

#htmlObject



68
69
70
# File 'lib/restflow/sequence.rb', line 68

def html
  Nokogiri::HTML(@response.body) 
end

#jsonObject



72
73
74
# File 'lib/restflow/sequence.rb', line 72

def json
  JSON.parse(@response.body) if @response.body
end

#post(path, data) ⇒ Object



46
47
48
49
50
# 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) ⇒ Object



58
59
60
61
62
# File 'lib/restflow/sequence.rb', line 58

def put(path, data)
  @response = send_post_data(:put, path, data)
  @responses << @response
  @response
end

#responseObject



64
65
66
# File 'lib/restflow/sequence.rb', line 64

def response
  @response.body
end

#statusObject



76
77
78
# File 'lib/restflow/sequence.rb', line 76

def status
  @response.code
end