holoserve 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -29,7 +29,9 @@ To start up an empty Holoserve instance, type...
29
29
 
30
30
  To load a server layout and define a situation during start up, use these parameters.
31
31
 
32
- holoserve -l layouts.yml -s backend_without_users
32
+ holoserve -l layout.yaml -s backend_without_users
33
+
34
+ Notice, that the layout file must have either the <tt>.yaml</tt> or the <tt>.json</tt> extension.
33
35
 
34
36
  == Control routes
35
37
 
@@ -58,6 +60,10 @@ Sets the current situation.
58
60
 
59
61
  Returns the name of the current situation.
60
62
 
63
+ === DELETE /_control/situation
64
+
65
+ Clears the current situation.
66
+
61
67
  ==== Response example
62
68
 
63
69
  backend_without_users
@@ -17,13 +17,18 @@ class Holoserve::Configuration
17
17
  @layout = Holoserve::Tool::Hash::KeySymbolizer.new(hash_or_array).hash
18
18
  end
19
19
 
20
+ def clear_layout!
21
+ self.layout = nil
22
+ end
23
+
20
24
  def situation=(value)
21
25
  @situation = value.to_sym
22
26
  logger.info "made '#{value}' the current situation"
23
27
  end
24
28
 
25
- def clear_layout!
26
- self.layout = nil
29
+ def clear_situation!
30
+ @situation = nil
31
+ logger.info "cleared the current situation"
27
32
  end
28
33
 
29
34
  def load_layout_from_yaml_file(file)
@@ -47,6 +47,10 @@ class Holoserve::Interface::Control < Sinatra::Base
47
47
  configuration.situation.to_s
48
48
  end
49
49
 
50
+ delete "/_control/situation" do
51
+ configuration.clear_situation!
52
+ end
53
+
50
54
  get "/_control/bucket/requests" do
51
55
  respond_json bucket.requests
52
56
  end
@@ -10,8 +10,7 @@ class Holoserve::Interface::Fake
10
10
  history.pair_names << name
11
11
  logger.info "received handled request with name '#{name}'"
12
12
  end
13
- responses = pair[:responses]
14
- response = Holoserve::Tool::Merger.new(responses[:default] || { }, responses[configuration.situation.to_sym] || { }).result
13
+ response = compose_response pair
15
14
  if response.empty?
16
15
  logger.warn "received request #{pair[:name]} with undefined response"
17
16
  not_found
@@ -27,6 +26,13 @@ class Holoserve::Interface::Fake
27
26
 
28
27
  private
29
28
 
29
+ def compose_response(pair)
30
+ responses = pair[:responses]
31
+ response_default = responses[:default] || { }
32
+ response_situation = (configuration.situation && responses[configuration.situation.to_sym]) || { }
33
+ Holoserve::Tool::Merger.new(response_default, response_situation).result
34
+ end
35
+
30
36
  def not_found
31
37
  [ 404, { "Content-Type" => "text/plain" }, [ "no response found for this request" ] ]
32
38
  end
@@ -27,7 +27,7 @@ class Holoserve::Response::Composer
27
27
  elsif @response.has_key?(:json)
28
28
  JSON.dump @response[:json]
29
29
  else
30
- nil
30
+ ""
31
31
  end
32
32
  end
33
33
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: holoserve
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-01-16 00:00:00.000000000 Z
12
+ date: 2012-02-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rack
16
- requirement: &70247827043580 !ruby/object:Gem::Requirement
16
+ requirement: &70196505909820 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70247827043580
24
+ version_requirements: *70196505909820
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: sinatra
27
- requirement: &70247827042840 !ruby/object:Gem::Requirement
27
+ requirement: &70196505909260 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70247827042840
35
+ version_requirements: *70196505909260
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: unicorn
38
- requirement: &70247827042360 !ruby/object:Gem::Requirement
38
+ requirement: &70196505908780 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *70247827042360
46
+ version_requirements: *70196505908780
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: transport
49
- requirement: &70247827041740 !ruby/object:Gem::Requirement
49
+ requirement: &70196505908180 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *70247827041740
57
+ version_requirements: *70196505908180
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: cucumber
60
- requirement: &70247827041200 !ruby/object:Gem::Requirement
60
+ requirement: &70196505907560 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '0'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *70247827041200
68
+ version_requirements: *70196505907560
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rspec
71
- requirement: &70247827040660 !ruby/object:Gem::Requirement
71
+ requirement: &70196505907080 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: '0'
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *70247827040660
79
+ version_requirements: *70196505907080
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: transport
82
- requirement: &70247827040180 !ruby/object:Gem::Requirement
82
+ requirement: &70196505906560 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ! '>='
@@ -87,10 +87,10 @@ dependencies:
87
87
  version: '0'
88
88
  type: :development
89
89
  prerelease: false
90
- version_requirements: *70247827040180
90
+ version_requirements: *70196505906560
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: oauth
93
- requirement: &70247827039660 !ruby/object:Gem::Requirement
93
+ requirement: &70196505906040 !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
96
96
  - - ! '>='
@@ -98,7 +98,7 @@ dependencies:
98
98
  version: '0'
99
99
  type: :development
100
100
  prerelease: false
101
- version_requirements: *70247827039660
101
+ version_requirements: *70196505906040
102
102
  description: This tool can be used to fake webservice APIs for testing proposals.
103
103
  email: philipp.bruell@skrill.com
104
104
  executables:
@@ -147,7 +147,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
147
147
  version: '0'
148
148
  segments:
149
149
  - 0
150
- hash: 460979945885990413
150
+ hash: -388162576537081624
151
151
  required_rubygems_version: !ruby/object:Gem::Requirement
152
152
  none: false
153
153
  requirements: