Class: Webspicy::Web::Specification
- Inherits:
-
Specification
show all
- Defined in:
- lib/webspicy/web/specification.rb,
lib/webspicy/web/specification/pre.rb,
lib/webspicy/web/specification/post.rb,
lib/webspicy/web/specification/service.rb,
lib/webspicy/web/specification/test_case.rb,
lib/webspicy/web/specification/file_upload.rb,
lib/webspicy/web/specification/post/etag_caching_protocol.rb,
lib/webspicy/web/specification/pre/global_request_headers.rb,
lib/webspicy/web/specification/pre/robust_to_invalid_input.rb,
lib/webspicy/web/specification/post/last_modified_caching_protocol.rb,
lib/webspicy/web/specification/post/semantics_preserved_by_refactoring.rb
Defined Under Namespace
Modules: Post, Pre
Classes: FileUpload, Service, TestCase
Instance Attribute Summary
#config, #location
Class Method Summary
collapse
Instance Method Summary
collapse
#initialize, #locate, #located_at!, #name, #relative_location, #services
#initialize, #method_missing, #to_info
Class Method Details
.info(raw) ⇒ Object
6
7
8
|
# File 'lib/webspicy/web/specification.rb', line 6
def info(raw)
new(raw)
end
|
.singleservice(raw) ⇒ Object
10
11
12
13
14
15
16
17
18
19
|
# File 'lib/webspicy/web/specification.rb', line 10
def singleservice(raw)
converted = {
name: raw[:name],
url: raw[:url],
services: [
Webspicy::Web.service(raw.reject{|k| k==:url or k==:name }, Webspicy.current_scope)
]
}
info(converted)
end
|
Instance Method Details
#instantiate_url(params) ⇒ Object
34
35
36
37
38
39
40
41
|
# File 'lib/webspicy/web/specification.rb', line 34
def instantiate_url(params)
url, rest = self.url, params.dup
url_placeholders.each do |placeholder|
value, rest = (rest, placeholder)
url = url.gsub("{#{placeholder}}", value.to_s)
end
[ url, rest ]
end
|
#to_singleservice ⇒ Object
43
44
45
|
# File 'lib/webspicy/web/specification.rb', line 43
def to_singleservice
raise NotImplementedError
end
|
#url ⇒ Object
22
23
24
|
# File 'lib/webspicy/web/specification.rb', line 22
def url
@raw[:url]
end
|
#url_pattern ⇒ Object
26
27
28
|
# File 'lib/webspicy/web/specification.rb', line 26
def url_pattern
@url_pattern ||= Mustermann.new(url, type: :template)
end
|
#url_placeholders ⇒ Object
30
31
32
|
# File 'lib/webspicy/web/specification.rb', line 30
def url_placeholders
url.scan(/\{([a-zA-Z]+(\.[a-zA-Z]+)*)\}/).map{|x| x.first }
end
|