Guest User

Untitled

a guest
Jan 18th, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. class URIHandlerDSL
  2. def initialize(content_type, &block)
  3. @content_type = content_type
  4. @block = block
  5. end
  6. end
  7.  
  8. class ResourceDSL
  9. def initialize(name, &block)
  10. @name = name
  11. instance_eval &block
  12. end
  13.  
  14. def uri_template(uri)
  15. @uri = uri
  16. end
  17.  
  18. def automatic_caching
  19. @automatic_caching = true
  20. end
  21.  
  22. def cache_expiry(mins)
  23. @cache_expiry_minutes = mins
  24. end
  25.  
  26. def get (content_type, &block)
  27. URIHandlerDSL.new(content_type, &block)
  28. end
  29. end
  30.  
  31. class RestAssureServerDSL
  32.  
  33. def initialize(name, &block)
  34. @name = name
  35. instance_eval &block
  36. end
  37.  
  38. def server_version(ver)
  39. @version = ver
  40. end
  41.  
  42. def base_address(addr)
  43. @base_address = addr
  44. end
  45.  
  46. def allow_response_compression
  47. @allow_response_compress = true
  48. end
  49.  
  50. def resource(name, &block)
  51. ResourceDSL.new(name, &block)
  52. end
  53.  
  54. def run
  55. puts 'Server running: ' + @name
  56. end
  57.  
  58. end
  59.  
  60. def rest_assure(name, &block)
  61. RestAssureServerDSL.new(name, &block)
  62. end
  63.  
  64. load 'server.rb'
Add Comment
Please, Sign In to add comment