wireless 0.0.2 → 0.1.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: 15c44fc9bf9e10af9c1a9d8d0241e2a808a7dfabdadd895581271f6fa076fdbc
4
- data.tar.gz: 3159342e5f335e4a9b92fd6c09556c4fbb39af17bc5fada60737e0ad3150ac0f
3
+ metadata.gz: ffbbea2456c108c04b1bcb959103f81a238ca8156b3d7e7390ea6c553b66dc1d
4
+ data.tar.gz: 6ef79cfcd3509264b9390764efbea408cfd17f098d1370808bb92eb220c65297
5
5
  SHA512:
6
- metadata.gz: 0ded107266b0b9cf0d6a279a5609e102603b9e14e9a09a8b72684d5239b3bae6b61e623bf20297dba65b92d93e93f5c3a66ef5b7197b5d1030778c213eafec93
7
- data.tar.gz: 22276968eb991723ced37a404b4e8aa0a805ccf3ca5b69746431712323bd3290235fd91b7535e9c59180ea82c40badfc59df8bec29ac2e93d736f2809fbf2d0d
6
+ metadata.gz: caf86c14536dd9ea51b3c516047f6c3c3f05d6f9dfc87e5f4c5b86d000836d5c51cc748cf2ab4771f158bdfed6413d3f580dd576b75e1a8acae75c3844360adc
7
+ data.tar.gz: 7508d42b402fa09f3f77c9bbed5a7c264259a536d4562746cd9e94fa666365714e38622fbe2cb22cd64b177a0da5d73c4fcd20a25a366f6f64d00377fdf049d3
@@ -1,3 +1,9 @@
1
+ ## 0.1.0 - 2020-05-18
2
+
3
+ - **breaking change**: bump minimum ruby version from 2.3 -> 2.5
4
+ - bump dependencies
5
+ - documentation fixes
6
+
1
7
  ## 0.0.2 - 2018-06-17
2
8
 
3
9
  * fix import aliasing
data/README.md CHANGED
@@ -3,8 +3,7 @@
3
3
  [![Build Status](https://travis-ci.org/chocolateboy/wireless.svg)](https://travis-ci.org/chocolateboy/wireless)
4
4
  [![Gem Version](https://img.shields.io/gem/v/wireless.svg)](https://rubygems.org/gems/wireless)
5
5
 
6
- <!-- START doctoc generated TOC please keep comment here to allow auto update -->
7
- <!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
6
+ <!-- toc -->
8
7
 
9
8
  - [NAME](#name)
10
9
  - [INSTALLATION](#installation)
@@ -13,6 +12,7 @@
13
12
  - [WHY?](#why)
14
13
  - [Why Wireless?](#why-wireless)
15
14
  - [Why Service Locators?](#why-service-locators)
15
+ - [COMPATIBILITY](#compatibility)
16
16
  - [VERSION](#version)
17
17
  - [SEE ALSO](#see-also)
18
18
  - [Gems](#gems)
@@ -20,7 +20,7 @@
20
20
  - [AUTHOR](#author)
21
21
  - [COPYRIGHT AND LICENSE](#copyright-and-license)
22
22
 
23
- <!-- END doctoc generated TOC please keep comment here to allow auto update -->
23
+ <!-- tocstop -->
24
24
 
25
25
  # NAME
26
26
 
@@ -87,51 +87,59 @@ which has the following features:
87
87
 
88
88
  * Simplicity
89
89
 
90
- It's just an object which dependencies can be added to and retrieved from. It can
91
- be passed around and stored like any other object. No "injection", no containers,
92
- no framework, no dependencies.
90
+ It's just an object which dependencies can be added to and retrieved from.
91
+ It can be passed around and stored like any other object. No "injection",
92
+ containers, framework, or dependencies.
93
93
 
94
- * Inclusion
94
+ * Convenience
95
95
 
96
- Inclusion of dependency getters into a class or module with control over their visibility.
96
+ Include dependency getters into a class or module with control over their
97
+ visibility.
97
98
 
98
99
  * Laziness
99
100
 
100
- As well as dependencies being resolved lazily, they can also be *registered* lazily i.e.
101
- at the point of creation, rather than forcing everything to be declared up-front.
101
+ As well as being resolved lazily, dependencies can also be *registered*
102
+ lazily, i.e. at the point of creation. There's no need to declare
103
+ everything up front.
102
104
 
103
105
  * Safety
104
106
 
105
- Dependency resolution is thread-safe. Dependency cycles are checked and raise a fatal
106
- error as soon as they are detected.
107
+ Dependency resolution is thread-safe. Dependency cycles are checked and
108
+ raise a fatal error as soon as they are detected.
107
109
 
108
110
  # WHY?
109
111
 
110
112
  ## Why Wireless?
111
113
 
112
- I wanted a simple service locator like [DiFtw](https://github.com/jhollinger/ruby-diftw),
113
- with cycle detection and control over the [visibility of getters](https://github.com/jhollinger/ruby-diftw/issues/1).
114
+ I wanted a simple service locator like
115
+ [DiFtw](https://github.com/jhollinger/ruby-diftw), with cycle detection and
116
+ control over the [visibility of getters](https://github.com/jhollinger/ruby-diftw/issues/1).
114
117
 
115
118
  ## Why Service Locators?
116
119
 
117
120
  Service locators make it easy to handle shared (AKA
118
- [cross-cutting](https://en.wikipedia.org/wiki/Cross-cutting_concern)) dependencies i.e.
119
- values and services that are required by multiple otherwise-unrelated parts of a system.
120
- Examples include:
121
+ [cross-cutting](https://en.wikipedia.org/wiki/Cross-cutting_concern))
122
+ dependencies i.e. values and services that are required by multiple
123
+ otherwise-unrelated parts of a system. Examples include:
121
124
 
122
125
  * logging
123
126
  * configuration data
124
127
  * storage backends
125
128
  * authorisation
126
129
 
127
- Rather than wiring these dependencies together manually, service locators allow them to be
128
- registered and retrieved in a declarative way. This is similar to the difference between
129
- imperative build tools like Ant or Gulp and declarative build tools like Make or Rake, which
130
- allow prerequisites to be acquired on-demand, without micromanaging their construction or connections.
130
+ Rather than wiring these dependencies together manually, service locators allow
131
+ them to be registered and retrieved in a declarative way. This is similar to
132
+ the difference between imperative build tools like Ant or Gulp, and declarative
133
+ build tools like Make or Rake, which allow prerequisites to be acquired without
134
+ coordinating their construction.
135
+
136
+ # COMPATIBILITY
137
+
138
+ - [Maintained ruby versions](https://www.ruby-lang.org/en/downloads/branches/)
131
139
 
132
140
  # VERSION
133
141
 
134
- 0.0.2
142
+ 0.1.0
135
143
 
136
144
  # SEE ALSO
137
145
 
@@ -139,6 +147,7 @@ allow prerequisites to be acquired on-demand, without micromanaging their constr
139
147
 
140
148
  - [Canister](https://github.com/mlibrary/canister) - a simple service-locator inspired by Jim Weirich's [article](https://archive.li/shxeA) on Dependency Injection
141
149
  - [DiFtw](https://github.com/jhollinger/ruby-diftw) - the original inspiration for this module: a similar API with a focus on testing/mocking
150
+ - [dry-container](https://github.com/dry-rb/dry-container) - a standalone service-locator which can also be paired with a [dependency injector](https://github.com/dry-rb/dry-auto_inject)
142
151
 
143
152
  ## Articles
144
153
 
@@ -151,7 +160,7 @@ allow prerequisites to be acquired on-demand, without micromanaging their constr
151
160
 
152
161
  # COPYRIGHT AND LICENSE
153
162
 
154
- Copyright © 2018 by chocolateboy.
163
+ Copyright © 2018-2020 by chocolateboy.
155
164
 
156
165
  This is free software; you can redistribute it and/or modify it under the
157
- terms of the [Artistic License 2.0](http://www.opensource.org/licenses/artistic-license-2.0.php).
166
+ terms of the [Artistic License 2.0](https://www.opensource.org/licenses/artistic-license-2.0.php).
@@ -12,7 +12,7 @@ module Wireless
12
12
  # - retrieve a value from a key-indexed store when the key doesn't exist
13
13
  # - write a value when the key exists and the store doesn't allow replacements
14
14
  #
15
- # Can be passed a message, the receiver the lookup failed on and the key. All
15
+ # Can be passed a message, the receiver the lookup failed on, and the key. All
16
16
  # are optional and default to nil.
17
17
  #
18
18
  # XXX eventually (i.e. in ruby 2.6), this can be a subclass of (or replaced by)
@@ -9,7 +9,7 @@ module Wireless
9
9
  # which either resolve the dependency every time (factory) or once (singleton).
10
10
  #
11
11
  # A class can be supplied instead of the block, in which case it is equivalent to
12
- # a block which calls +new+ on the class e.g.:
12
+ # a block which calls +new+ on the class, e.g.:
13
13
  #
14
14
  # WL = Wireless.new do
15
15
  # on(:foo, Foo)
@@ -39,8 +39,8 @@ module Wireless
39
39
  @registry[name.to_sym] = Resolver::Factory.new(block || klass)
40
40
  end
41
41
 
42
- # Returns true if a service with the specified name has been registered, false
43
- # otherwise
42
+ # Returns true if a dependency with the specified name has been registered,
43
+ # false otherwise
44
44
  def include?(key)
45
45
  @registry.include?(key)
46
46
  end
@@ -52,7 +52,7 @@ module Wireless
52
52
  end
53
53
 
54
54
  # Takes an array or hash specifying the dependencies to export, and returns
55
- # a module which exposes those dependencies as getters.
55
+ # a module which defines getters for those dependencies.
56
56
  #
57
57
  # class Test
58
58
  # # hash (specify visibilities)
@@ -70,7 +70,7 @@ module Wireless
70
70
  # with { visibility => imports } pairs, where imports is an array of import
71
71
  # specifiers. An import specifier is a symbol (method name == dependency name)
72
72
  # or a hash with { dependency_name => method_name } pairs (aliases). If
73
- # there's only one import specifier, its enclosing array can be omitted e.g.:
73
+ # there's only one import specifier, its enclosing array can be omitted, e.g.:
74
74
  #
75
75
  # include Services.mixin(private: :foo, protected: { :baz => :quux })
76
76
  #
@@ -88,8 +88,9 @@ module Wireless
88
88
  raise ArgumentError, "invalid mixin argument: expected array or hash, got: #{args.class}"
89
89
  end
90
90
 
91
- # slurp each array of name (symbol) or name => alias (hash) imports into
92
- # a normalized hash of { dependency_name => method_name } pairs e.g.:
91
+ # slurp each array of name (symbol) or name => alias (hash) import
92
+ # specifiers into a normalized hash of { dependency_name => method_name }
93
+ # pairs, e.g.:
93
94
  #
94
95
  # before:
95
96
  #
@@ -99,19 +100,10 @@ module Wireless
99
100
  #
100
101
  # { :foo => :foo, :bar => :baz, :quux => :quux }
101
102
 
102
- # XXX transform_values isn't available in ruby 2.3 and we don't want to
103
- # pull in ActiveSupport just for one method (on this occasion)
104
- #
105
- # args = DEFAULT_EXPORTS.merge(args).transform_values do |exports|
106
- # exports = [exports] unless exports.is_a?(Array)
107
- # exports.reduce({}) do |a, b|
108
- # a.merge(b.is_a?(Hash) ? b : { b => b })
109
- # end
110
- # end
111
-
112
- args = DEFAULT_EXPORTS.merge(args).each_with_object({}) do |(key, exports), merged|
103
+ # XXX transform_values requires ruby >= 2.5
104
+ args = DEFAULT_EXPORTS.merge(args).transform_values do |exports|
113
105
  exports = [exports] unless exports.is_a?(Array)
114
- merged[key] = exports.reduce({}) do |a, b|
106
+ exports.reduce({}) do |a, b|
115
107
  a.merge(b.is_a?(Hash) ? b : { b => b })
116
108
  end
117
109
  end
@@ -4,7 +4,7 @@ module Wireless
4
4
  # The registry is a key/value store (Hash) whose keys are symbols and whose values
5
5
  # are instances of this class. Resolvers are responsible for returning their
6
6
  # dependencies, which they do by calling their corresponding blocks. They can wrap
7
- # additional behaviors around this call e.g. singletons (Wireless::Resolver::Singleton)
7
+ # additional behaviors around this call, e.g. singletons (Wireless::Resolver::Singleton)
8
8
  # cache the result so that the block is only called once.
9
9
  class Resolver
10
10
  def initialize(block = nil)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Wireless
4
- VERSION = '0.0.2'
4
+ VERSION = '0.1.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wireless
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - chocolateboy
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-06-17 00:00:00.000000000 Z
11
+ date: 2020-05-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -16,84 +16,84 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.16'
19
+ version: '2.1'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.16'
26
+ version: '2.1'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: minitest
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '5.11'
33
+ version: '5.14'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '5.11'
40
+ version: '5.14'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: minitest-power_assert
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 0.3.0
47
+ version: '0.3'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 0.3.0
54
+ version: '0.3'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: minitest-reporters
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '1.3'
61
+ version: '1.4'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '1.3'
68
+ version: '1.4'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rake
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '10.0'
75
+ version: '13.0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '10.0'
82
+ version: '13.0'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: rubocop
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: 0.54.0
89
+ version: '0.83'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: 0.54.0
96
+ version: '0.83'
97
97
  description:
98
98
  email: chocolate@cpan.org
99
99
  executables: []
@@ -128,15 +128,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
128
128
  requirements:
129
129
  - - ">="
130
130
  - !ruby/object:Gem::Version
131
- version: '0'
131
+ version: 2.5.0
132
132
  required_rubygems_version: !ruby/object:Gem::Requirement
133
133
  requirements:
134
134
  - - ">="
135
135
  - !ruby/object:Gem::Version
136
136
  version: '0'
137
137
  requirements: []
138
- rubyforge_project:
139
- rubygems_version: 2.7.7
138
+ rubygems_version: 3.1.2
140
139
  signing_key:
141
140
  specification_version: 4
142
141
  summary: A lightweight, declarative dependency-provider