async-service 0.7.0 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8715972e602d996a04c5d8ed36f765eab4e4eda85c5f978cd9d10b66dc48fee3
4
- data.tar.gz: abd69a1148bcb121887aef3943a1a7fea9916d88c8d683ba25f1572a8f869bbb
3
+ metadata.gz: d1e2ef9fcbc4732f3683889f55acfd02fa632aa95189c0767c04c8b24f64eb52
4
+ data.tar.gz: debef0f6bdc887b83dc8ebf1dfbf63bf9ab0591a4b99a52a8c1aa6ccd47a419c
5
5
  SHA512:
6
- metadata.gz: 9e9618479dab469fdc62db4058a25bbe2eccbc2b1c33a6b44af7b277eaa030220cd25dd5b8d720e51b2d964ecd525d123d4d423965920d2c79b4119714a866db
7
- data.tar.gz: c018787aef323da8805c471cc59a5a4fcbe21c83f789fbbbdd24cc37ff6c9b619f58dba04cf023390469632e72f9ccadb00498ef82f9198e50d691612e523b10
6
+ metadata.gz: 0ec21ead9612856e07467c62d3d52fa3452ca7883455f9a67c78743f61a9db512063550356a2ca9b5e374313dfccc64dbe909205c8410b6efd8ccf2b52fc4cc4
7
+ data.tar.gz: 0aa73567ad8f19c62c5c630ae9c4bc02fa5c2ba253a4882326e08b9ce9090c14a4c73e29241320e280136aa23e5e783d6ff7f06b63a3806c2464717c067318db
checksums.yaml.gz.sig CHANGED
Binary file
@@ -5,6 +5,7 @@
5
5
 
6
6
  require_relative 'loader'
7
7
  require_relative 'generic'
8
+ require_relative 'controller'
8
9
 
9
10
  module Async
10
11
  module Service
@@ -33,14 +34,20 @@ module Async
33
34
  @environments.empty?
34
35
  end
35
36
 
36
- def services
37
- return to_enum(:services) unless block_given?
37
+ def services(implementing: nil)
38
+ return to_enum(:services, implementing: implementing) unless block_given?
38
39
 
39
40
  @environments.each do |environment|
41
+ next if implementing and environment.implements?(implementing)
42
+
40
43
  yield Generic.wrap(environment)
41
44
  end
42
45
  end
43
46
 
47
+ def controller(**options)
48
+ Controller.new(self.services(**options).to_a)
49
+ end
50
+
44
51
  # Add the environment to the configuration.
45
52
  def add(environment)
46
53
  @environments << environment
@@ -38,6 +38,10 @@ module Async
38
38
  @services = services
39
39
  end
40
40
 
41
+ # All the services associated with this controller.
42
+ # @attribute [Array(Async::Service::Generic)]
43
+ attr :services
44
+
41
45
  # Start all named services.
42
46
  def start
43
47
  @services.each do |service|
@@ -7,20 +7,26 @@ module Async
7
7
  module Service
8
8
  class Environment
9
9
  class Builder < BasicObject
10
- def self.for(facet = ::Module.new, **values, &block)
11
- builder = self.new(facet)
10
+ def self.for(*facets, **values, &block)
11
+ top = ::Module.new
12
+
13
+ builder = self.new(top)
14
+
15
+ facets.each do |facet|
16
+ builder.include(facet)
17
+ end
12
18
 
13
19
  values.each do |key, value|
14
20
  if value.is_a?(::Proc)
15
- facet.define_method(key, &value)
21
+ builder.method_missing(key, &value)
16
22
  else
17
- facet.define_method(key){value}
23
+ builder.method_missing(key, value)
18
24
  end
19
25
  end
20
26
 
21
27
  builder.instance_exec(&block) if block_given?
22
28
 
23
- return facet
29
+ return top
24
30
  end
25
31
 
26
32
  def initialize(facet = ::Module.new)
@@ -59,6 +65,12 @@ module Async
59
65
  @parent = parent
60
66
  end
61
67
 
68
+ # @attribute [Module] The facet module.
69
+ attr :facet
70
+
71
+ # @attribute [Environment | Nil] The parent environment, if any.
72
+ attr :parent
73
+
62
74
  def included(target)
63
75
  @parent&.included(target)
64
76
  target.include(@facet)
@@ -68,6 +80,10 @@ module Async
68
80
  return self.class.new(Builder.for(...), self)
69
81
  end
70
82
 
83
+ def implements?(interface)
84
+ @facet <= interface
85
+ end
86
+
71
87
  # An evaluator is lazy read-only view of an environment. It memoizes all method calls.
72
88
  class Evaluator
73
89
  def self.wrap(environment)
@@ -5,6 +5,6 @@
5
5
 
6
6
  module Async
7
7
  module Service
8
- VERSION = "0.7.0"
8
+ VERSION = "0.9.0"
9
9
  end
10
10
  end
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: async-service
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
@@ -37,7 +37,7 @@ cert_chain:
37
37
  Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
38
38
  voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
39
39
  -----END CERTIFICATE-----
40
- date: 2024-03-17 00:00:00.000000000 Z
40
+ date: 2024-03-22 00:00:00.000000000 Z
41
41
  dependencies:
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: async
metadata.gz.sig CHANGED
Binary file