webspicy 0.3.0.pre.rc2 → 0.3.0.pre.rc3

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: d31b169f136144209e61a59ac7c7c848562e5646
4
- data.tar.gz: 2e971cd2cf87bd7215039349257dbe6fe05d0a5c
3
+ metadata.gz: b25073c6397b2720a2c7fd0024cb7a0fa5762f57
4
+ data.tar.gz: 2012c7403444a88649a212d22691e8260d4471c2
5
5
  SHA512:
6
- metadata.gz: 0ac4e3b403070e46f7d85b88289cb81abc375422acf42164eab8ed70145201087bd5affb9fd94d54231f5ac388ee430ce9441f5959c9b372ebcfac2ce06a8bf4
7
- data.tar.gz: f84f29c4023ef02e568b2c8b861a095f8ce118964ffb6cada0a3c3e1c9c6458d0ff5b4ed308e2a77edba6d64695bdb2492073c14977b3d871f72d38fbbfd7fae
6
+ metadata.gz: 5bd05c8199e926768b3bd197a30df9e0b6da4de007e1abcea0661583ebbfea9b5636a89f65c4e65c1f397adb9c2e1d1142b0e04a9d2ee8f2f4a1f6c9d404e2a0
7
+ data.tar.gz: 8a7fee06f727727945247b22a508b5d9566e6a2acc3e8fefba2d6b0b1cc8aca3238ad89f874294801e069dc4d82254e6970d1580968515046761cb5cbeb04faf
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../..
3
3
  specs:
4
- webspicy (0.3.0.pre.rc1)
4
+ webspicy (0.3.0.pre.rc2)
5
5
  finitio (~> 0.5.2)
6
6
  http (~> 2)
7
7
  path (~> 1.3)
@@ -8,18 +8,17 @@ module Webspicy
8
8
 
9
9
  def call
10
10
  config.each_scope do |scope|
11
- client = scope.get_client
12
11
  scope.each_resource_file do |file, folder|
13
12
  RSpec.describe file.relative_to(folder).to_s do
14
13
 
15
14
  it 'meets the formal doc data schema' do
16
- Webspicy.resource(file.load, file)
15
+ Webspicy.resource(file.load, file, scope)
17
16
  end
18
17
 
19
18
  end
20
19
  end
21
- RSpec::Core::Runner.run config.rspec_options
22
20
  end
21
+ RSpec::Core::Runner.run config.rspec_options
23
22
  end
24
23
 
25
24
  end
@@ -26,7 +26,7 @@ module Webspicy
26
26
  config.each_scope(&bl)
27
27
  end
28
28
  else
29
- Webspicy.with_scope_for(self, &bl)
29
+ yield Scope.new(self)
30
30
  end
31
31
  end
32
32
 
@@ -228,7 +228,7 @@ module Webspicy
228
228
  # original.
229
229
  def dup(&bl)
230
230
  super.tap do |d|
231
- d.children = self.children.dup
231
+ d.children = []
232
232
  d.rspec_options = self.rspec_options.dup
233
233
  d.before_listeners = self.before_listeners.dup
234
234
  yield d if block_given?
@@ -30,7 +30,7 @@ module Webspicy
30
30
  def each_resource(&bl)
31
31
  return enum_for(:each_resource) unless block_given?
32
32
  each_resource_file do |file, folder|
33
- yield Webspicy.resource(file.load, file)
33
+ yield Webspicy.resource(file.load, file, self)
34
34
  end
35
35
  end
36
36
 
@@ -90,8 +90,8 @@ module Webspicy
90
90
  end
91
91
  end
92
92
  end
93
- RSpec::Core::Runner.run config.rspec_options
94
93
  end
94
+ RSpec::Core::Runner.run config.rspec_options
95
95
  end
96
96
 
97
97
  end # class Tester
@@ -2,7 +2,7 @@ module Webspicy
2
2
  module Version
3
3
  MAJOR = 0
4
4
  MINOR = 3
5
- TINY = "0-rc2"
5
+ TINY = "0-rc3"
6
6
  end
7
7
  VERSION = "#{Version::MAJOR}.#{Version::MINOR}.#{Version::TINY}"
8
8
  end
data/lib/webspicy.rb CHANGED
@@ -38,40 +38,57 @@ module Webspicy
38
38
 
39
39
  FORMALDOC = Finitio::DEFAULT_SYSTEM.parse (Path.dir/"webspicy/formaldoc.fio").read
40
40
 
41
- def resource(raw, file = nil)
42
- FORMALDOC["Resource"].dress(raw)
41
+ # Returns a default scope instance.
42
+ def default_scope
43
+ Scope.new(Configuration.new)
44
+ end
45
+ module_function :default_scope
46
+
47
+ def resource(raw, file = nil, scope = default_scope)
48
+ with_scope(scope) do
49
+ FORMALDOC["Resource"].dress(raw)
50
+ end
43
51
  end
44
52
  module_function :resource
45
53
 
46
- def service(raw)
47
- FORMALDOC["Service"].dress(raw)
54
+ def service(raw, scope = default_scope)
55
+ with_scope(scope) do
56
+ FORMALDOC["Service"].dress(raw)
57
+ end
48
58
  end
49
59
  module_function :service
50
60
 
51
- def test_case(raw)
52
- FORMALDOC["TestCase"].dress(raw)
61
+ def test_case(raw, scope = default_scope)
62
+ with_scope(scope) do
63
+ FORMALDOC["TestCase"].dress(raw)
64
+ end
53
65
  end
54
66
  module_function :test_case
55
67
 
56
68
  #
57
- # Yields a Scope instance for the configuration passed as parameter.
69
+ # Yields the block after having installed `scope` globally.
58
70
  #
59
71
  # This method makes sure that the scope will also be accessible for
60
72
  # Finitio world schema parsing/dressing. Given that some global state
61
73
  # is required (see "Schema" ADT, the dresser in particular, which calls
62
74
  # `schema` later), the scope is put as a thread-local variable...
63
75
  #
64
- def with_scope_for(config)
65
- scope = set_current_scope(Scope.new(config))
66
- yield scope
76
+ # This method is considered private and should not be used outside of
77
+ # Webspicy itself.
78
+ #
79
+ def with_scope(scope)
80
+ scope = set_current_scope(scope)
81
+ result = yield scope
67
82
  set_current_scope(nil)
83
+ result
68
84
  end
69
- module_function :with_scope_for
85
+ module_function :with_scope
70
86
 
71
87
  #
72
88
  # Sets the current scope.
73
89
  #
74
- # See `with_scope_for`
90
+ # This method is considered private and should not be used outside of
91
+ # Webspicy itself.
75
92
  #
76
93
  def set_current_scope(scope)
77
94
  Thread.current[:webspicy_scope] = scope
@@ -80,7 +97,7 @@ module Webspicy
80
97
 
81
98
  #
82
99
  # Parses a webservice schema (typically input or output) in the context
83
- # of the current scope previously installed using `with_scope_for`.
100
+ # of the current scope previously installed using `with_scope`.
84
101
  #
85
102
  # If no scope has previously been installed, Finitio's default system
86
103
  # is used instead of another schema.
@@ -2,8 +2,6 @@ require 'spec_helper'
2
2
  module Webspicy
3
3
  describe Scope, 'each_resource' do
4
4
 
5
- with_scope_management
6
-
7
5
  let(:scope) {
8
6
  Scope.new(configuration)
9
7
  }
@@ -2,8 +2,6 @@ require 'spec_helper'
2
2
  module Webspicy
3
3
  describe Scope, 'each_service' do
4
4
 
5
- with_scope_management
6
-
7
5
  let(:scope) {
8
6
  Scope.new(configuration)
9
7
  }
@@ -13,20 +13,6 @@ module SpecHelper
13
13
 
14
14
  end
15
15
 
16
- module ScopeManagement
17
-
18
- def with_scope_management
19
- before(:each) {
20
- Webspicy.set_current_scope(scope)
21
- }
22
- after(:each) {
23
- Webspicy.set_current_scope(nil)
24
- }
25
- end
26
-
27
- end
28
-
29
16
  RSpec.configure do |c|
30
17
  c.include SpecHelper
31
- c.extend ScopeManagement
32
18
  end
@@ -112,6 +112,7 @@ module Webspicy
112
112
  let(:original) do
113
113
  Configuration.new(Path.dir/'resource') do |c|
114
114
  c.host = "http://127.0.0.1"
115
+ c.folder 'service'
115
116
  end
116
117
  end
117
118
 
@@ -135,6 +136,11 @@ module Webspicy
135
136
  expect(duped.before_listeners.size).to eq(1)
136
137
  expect(original.before_listeners.size).to eq(0)
137
138
  end
139
+
140
+ it 'empties the children' do
141
+ duped = original.dup
142
+ expect(duped.children).to be_empty
143
+ end
138
144
  end
139
145
 
140
146
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: webspicy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0.pre.rc2
4
+ version: 0.3.0.pre.rc3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bernard Lambeau