Module: Webspicy
- Defined in:
- lib/webspicy.rb,
lib/webspicy/scope.rb,
lib/webspicy/client.rb,
lib/webspicy/tester.rb,
lib/webspicy/checker.rb,
lib/webspicy/version.rb,
lib/webspicy/resource.rb,
lib/webspicy/configuration.rb,
lib/webspicy/tester/asserter.rb,
lib/webspicy/resource/service.rb,
lib/webspicy/tester/assertions.rb,
lib/webspicy/client/http_client.rb,
lib/webspicy/client/rack_test_client.rb,
lib/webspicy/resource/service/test_case.rb,
lib/webspicy/resource/service/invocation.rb
Defined Under Namespace
Modules: Version Classes: Checker, Client, Configuration, HttpClient, RackTestClient, Resource, Scope, Tester
Constant Summary collapse
- ROOT_FOLDER =
About folders
Path.backfind('.[Gemfile]')
- EXAMPLES_FOLDER =
ROOT_FOLDER/'examples'
- FORMALDOC =
About formal doc and resources defined there
Finitio::DEFAULT_SYSTEM.parse (Path.dir/"webspicy/formaldoc.fio").read
- LOGGER =
Logging facade
::Logger.new(STDOUT)
- VERSION =
"#{Version::MAJOR}.#{Version::MINOR}.#{Version::TINY}"
Class Method Summary collapse
-
.current_scope ⇒ Object
Returns the current scope or a default one is none has been previously installed using ‘set_current_scope` or `with_scope`.
- .debug(*args, &bl) ⇒ Object
-
.default_scope ⇒ Object
Returns a default scope instance.
- .info(*args, &bl) ⇒ Object
- .resource(raw, file = nil, scope = default_scope) ⇒ Object
-
.schema(fio) ⇒ Object
Parses a webservice schema (typically input or output) in the context of the current scope previously installed using ‘with_scope`.
- .service(raw, scope = default_scope) ⇒ Object
-
.set_current_scope(scope) ⇒ Object
Sets the current scope.
- .test_case(raw, scope = default_scope) ⇒ Object
-
.with_scope(scope) ⇒ Object
Yields the block after having installed ‘scope` globally.
Class Method Details
.current_scope ⇒ Object
Returns the current scope or a default one is none has been previously installed using ‘set_current_scope` or `with_scope`
91 92 93 |
# File 'lib/webspicy.rb', line 91 def current_scope Thread.current[:webspicy_scope] || default_scope end |
.debug(*args, &bl) ⇒ Object
135 136 137 |
# File 'lib/webspicy.rb', line 135 def debug(*args, &bl) LOGGER && LOGGER.debug(*args, &bl) end |
.default_scope ⇒ Object
Returns a default scope instance.
42 43 44 |
# File 'lib/webspicy.rb', line 42 def default_scope Scope.new(Configuration.new) end |
.info(*args, &bl) ⇒ Object
130 131 132 |
# File 'lib/webspicy.rb', line 130 def info(*args, &bl) LOGGER && LOGGER.info(*args, &bl) end |
.resource(raw, file = nil, scope = default_scope) ⇒ Object
47 48 49 50 51 |
# File 'lib/webspicy.rb', line 47 def resource(raw, file = nil, scope = default_scope) with_scope(scope) do FORMALDOC["Resource"].dress(raw) end end |
.schema(fio) ⇒ Object
Parses a webservice schema (typically input or output) in the context of the current scope previously installed using ‘with_scope`.
If no scope has previously been installed, Finitio’s default system is used instead of another schema.
114 115 116 117 118 119 120 |
# File 'lib/webspicy.rb', line 114 def schema(fio) if scope = Thread.current[:webspicy_scope] scope.parse_schema(fio) else Finitio::DEFAULT_SYSTEM.parse(fio) end end |
.service(raw, scope = default_scope) ⇒ Object
54 55 56 57 58 |
# File 'lib/webspicy.rb', line 54 def service(raw, scope = default_scope) with_scope(scope) do FORMALDOC["Service"].dress(raw) end end |
.set_current_scope(scope) ⇒ Object
Sets the current scope.
This method is considered private and should not be used outside of Webspicy itself.
102 103 104 |
# File 'lib/webspicy.rb', line 102 def set_current_scope(scope) Thread.current[:webspicy_scope] = scope end |
.test_case(raw, scope = default_scope) ⇒ Object
61 62 63 64 65 |
# File 'lib/webspicy.rb', line 61 def test_case(raw, scope = default_scope) with_scope(scope) do FORMALDOC["TestCase"].dress(raw) end end |
.with_scope(scope) ⇒ Object
Yields the block after having installed ‘scope` globally.
This method makes sure that the scope will also be accessible for Finitio world schema parsing/dressing. Given that some global state is required (see “Schema” ADT, the dresser in particular, which calls ‘schema` later), the scope is put as a thread-local variable…
This method is considered private and should not be used outside of Webspicy itself.
79 80 81 82 83 84 |
# File 'lib/webspicy.rb', line 79 def with_scope(scope) scope = set_current_scope(scope) result = yield scope set_current_scope(nil) result end |