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

Attributes inherited from Specification

#config, #location

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Specification

#initialize, #locate, #located_at!, #name, #relative_location, #services

Methods included from Support::DataObject

#initialize, #method_missing, #to_info

Constructor Details

This class inherits a constructor from Webspicy::Specification

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Webspicy::Support::DataObject

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 = extract_placeholder_value(rest, placeholder)
    url = url.gsub("{#{placeholder}}", value.to_s)
  end
  [ url, rest ]
end

#to_singleserviceObject

Raises:

  • (NotImplementedError)


43
44
45
# File 'lib/webspicy/web/specification.rb', line 43

def to_singleservice
  raise NotImplementedError
end

#urlObject



22
23
24
# File 'lib/webspicy/web/specification.rb', line 22

def url
  @raw[:url]
end

#url_patternObject



26
27
28
# File 'lib/webspicy/web/specification.rb', line 26

def url_pattern
  @url_pattern ||= Mustermann.new(url, type: :template)
end

#url_placeholdersObject



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