rest_shifter 0.0.16 → 0.0.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7ce74ac48d14e2bccaa1aaa7ca8f0538f44158db
4
- data.tar.gz: f6d0a5b1de3931a0c3e4ea028e25fe18c2722cb2
3
+ metadata.gz: ae98789e7da5e32296f2542c616c09709f0fa686
4
+ data.tar.gz: ea503b73a6471f32675f4ac80f9f6d5cea7afa93
5
5
  SHA512:
6
- metadata.gz: 872091083cb523758a40f6795466519fad06b40c5c92b02ecc5fb872bc1f63c56b5ee2d3608a8a76dae2a97995fbb2250527f8ae12a308dd0e2ff52cec60e087
7
- data.tar.gz: 2eb1d413adc9656b68718644ccf6bfa126b5e7dce5bb8bd43831a1eaa15b11895de29ab11cb59abe99d5210620aa259385b5dd2b6ec9910dd8f1f013bf0c2a75
6
+ metadata.gz: 56b60e234b9aaec4cc1cefaea2e11174714a0c974dc742083d3c101168ed521bc16d67bfb65cdc28b94cfcb7a3bc2f80b8bdad3bcb28972596f8ec11b24cef6a
7
+ data.tar.gz: 0d050b17e94546b608df77f24354a293fa77112b7baa48ca61701b89370a8889f7d1caa1f5c9a78b56530bbe04bd98ef1cf167d13e674535b02ef40a446d4361
data/CHANGES CHANGED
@@ -1,4 +1,8 @@
1
1
 
2
+ ** 0.0.17
3
+ - internal improvements
4
+ -- removing code duplication
5
+
2
6
  ** 0.0.16
3
7
  - Feature
4
8
  -- Adding support to location header
data/README.md CHANGED
@@ -88,6 +88,7 @@ The file looks like this:
88
88
  response_status = "200"
89
89
  response_body = "{ \"hello_world\" : \"Your service is working fine. :D\" }"
90
90
  response_content_type = "application/json"
91
+ response_location = ""
91
92
 
92
93
  You basically change whatever you need to make it look like the expected or desired service. For example, replacint the path by "/clients", and restart rest_shifter, so you have the desired endpoint working as a rest api.
93
94
 
@@ -0,0 +1,9 @@
1
+ method_used = "get"
2
+ path = "/200ok"
3
+ request_accept = ""
4
+ request_content_type = ""
5
+ response_sleep = 0
6
+ response_status = "200"
7
+ response_body = "success"
8
+ response_content_type = ""
9
+ response_location = ""
@@ -0,0 +1,9 @@
1
+ method_used = "get"
2
+ path = "/200sleep2sec"
3
+ request_accept = ""
4
+ request_content_type = ""
5
+ response_sleep = 2
6
+ response_status = "200"
7
+ response_body = "sleep 2 seconds"
8
+ response_content_type = ""
9
+ response_location = ""
@@ -0,0 +1,9 @@
1
+ method_used = "get"
2
+ path = "/201create"
3
+ request_accept = ""
4
+ request_content_type = ""
5
+ response_sleep = 0
6
+ response_status = "201"
7
+ response_body = "created"
8
+ response_content_type = ""
9
+ response_location = ""
@@ -0,0 +1,9 @@
1
+ method_used = "get"
2
+ path = "/202accepted"
3
+ request_accept = ""
4
+ request_content_type = ""
5
+ response_sleep = 0
6
+ response_status = "202"
7
+ response_body = "accepted"
8
+ response_content_type = ""
9
+ response_location = ""
@@ -0,0 +1,9 @@
1
+ method_used = "get"
2
+ path = "/203nonauthoritativeinformation"
3
+ request_accept = ""
4
+ request_content_type = ""
5
+ response_sleep = 0
6
+ response_status = "203"
7
+ response_body = "non authoritative information"
8
+ response_content_type = ""
9
+ response_location = ""
@@ -0,0 +1,9 @@
1
+ method_used = "get"
2
+ path = "/204nocontent"
3
+ request_accept = ""
4
+ request_content_type = ""
5
+ response_sleep = 0
6
+ response_status = "204"
7
+ response_body = "no content"
8
+ response_content_type = ""
9
+ response_location = ""
@@ -0,0 +1,9 @@
1
+ method_used = "get"
2
+ path = "/301movedpermanently"
3
+ request_accept = ""
4
+ request_content_type = ""
5
+ response_sleep = 0
6
+ response_status = "301"
7
+ response_body = "moved permanentely"
8
+ response_content_type = ""
9
+ response_location = ""
@@ -0,0 +1,9 @@
1
+ method_used = "get"
2
+ path = "/302found"
3
+ request_accept = ""
4
+ request_content_type = ""
5
+ response_sleep = 0
6
+ response_status = "302"
7
+ response_body = "found"
8
+ response_content_type = ""
9
+ response_location = ""
@@ -0,0 +1,9 @@
1
+ method_used = "get"
2
+ path = "/303seeothers"
3
+ request_accept = ""
4
+ request_content_type = ""
5
+ response_sleep = 0
6
+ response_status = "303"
7
+ response_body = "see others"
8
+ response_content_type = ""
9
+ response_location = ""
@@ -0,0 +1,9 @@
1
+ method_used = "get"
2
+ path = "/307temporaryredirected"
3
+ request_accept = ""
4
+ request_content_type = ""
5
+ response_sleep = 0
6
+ response_status = "307"
7
+ response_body = "temprarly redirect"
8
+ response_content_type = ""
9
+ response_location = ""
@@ -0,0 +1,9 @@
1
+ method_used = "get"
2
+ path = "/400badrequest"
3
+ request_accept = ""
4
+ request_content_type = ""
5
+ response_sleep = 0
6
+ response_status = "400"
7
+ response_body = "bad request"
8
+ response_content_type = ""
9
+ response_location = ""
@@ -0,0 +1,9 @@
1
+ method_used = "get"
2
+ path = "/404notfound"
3
+ request_accept = ""
4
+ request_content_type = ""
5
+ response_sleep = 0
6
+ response_status = "404"
7
+ response_body = "not found"
8
+ response_content_type = ""
9
+ response_location = ""
@@ -0,0 +1,9 @@
1
+ method_used = "get"
2
+ path = "/500internalservererror"
3
+ request_accept = ""
4
+ request_content_type = ""
5
+ response_sleep = 0
6
+ response_status = "500"
7
+ response_body = "internal server error"
8
+ response_content_type = ""
9
+ response_location = ""
@@ -29,31 +29,31 @@ class Shifter < Sinatra::Base
29
29
  shapes = IceCream::IceCream.new File.join(File.dirname(__FILE__), "../../spec/flavors")
30
30
  end
31
31
 
32
- services = []
32
+ @services = []
33
33
  shapes.all.each do |shape|
34
- services << shapes.flavor(shape.to_s.gsub!("@", "").to_sym)
34
+ @services << shapes.flavor(shape.to_s.gsub!("@", "").to_sym)
35
35
  end
36
36
 
37
- def self.build_services operation
38
- operation.each do |service|
37
+ def self.build_services
38
+ @services.each do |service|
39
39
  if service.request_accept.to_s == ''
40
40
  send(service.method_used.to_sym, service.path) do
41
- response['Location'] = service.response_location unless service.response_location.to_s.empty?
42
- sleep service.response_sleep
43
- status service.response_status
44
- content_type service.response_content_type
45
- service.response_body
41
+ yield self, service
46
42
  end
47
43
  else
48
- send(service.method_used.to_sym, service.path, :provides => service.request_accept.to_s == '' ? "" : service.request_accept) do
49
- response['Location'] = service.response_location unless service.response_location.to_s.empty?
50
- sleep service.response_sleep
51
- status service.response_status
52
- content_type service.response_content_type
53
- service.response_body
44
+ send(service.method_used.to_sym, service.path, :provides => service.request_accept.to_s) do
45
+ yield self, service
54
46
  end
55
47
  end
56
48
  end
57
49
  end
58
- build_services services
50
+
51
+ build_services {
52
+ |current, service|
53
+ current.response['Location'] = service.response_location unless service.response_location.to_s.empty?
54
+ sleep service.response_sleep
55
+ current.status service.response_status
56
+ current.content_type service.response_content_type
57
+ service.response_body
58
+ }
59
59
  end
@@ -1,3 +1,3 @@
1
1
  module RestShifter
2
- VERSION = "0.0.16"
2
+ VERSION = "0.0.17"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rest_shifter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.16
4
+ version: 0.0.17
5
5
  platform: ruby
6
6
  authors:
7
7
  - Camilo Ribeiro
@@ -182,6 +182,19 @@ files:
182
182
  - README.md
183
183
  - Rakefile
184
184
  - bin/rest_shifter
185
+ - examples/200ok.flavor
186
+ - examples/200sleep2sec.flavor
187
+ - examples/201created.flavor
188
+ - examples/202accepted.flavor
189
+ - examples/203nonauthoritativeinformation.flavor
190
+ - examples/204noconten.flavor
191
+ - examples/301movedpermanently.flavor
192
+ - examples/302found.flavor
193
+ - examples/303seeother.flavor
194
+ - examples/307temporaryredirect.flavor
195
+ - examples/400badrequest.flavor
196
+ - examples/404notfound.flavor
197
+ - examples/500internalservererror.flavor
185
198
  - lib/rest_shifter.rb
186
199
  - lib/rest_shifter/commands.rb
187
200
  - lib/rest_shifter/commands/create.rb