dry-auto_inject 0.6.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: 4d3bcb1fb6fde005af77e71608739263f5866bf4cd1b00c4ad7c9cd6d6a6d61a
4
- data.tar.gz: b8eb767e090882f4a6102c594b7e1da1798c550ea0fbfa734a693c032ee2ba3e
3
+ metadata.gz: fbf423b57383e30d33060a0d0566ca2c9d9c451289f38132974325e5d7cdc2b8
4
+ data.tar.gz: a35a4d23402b9b5a1b47de1c953c0e089e646334c1ffffcaa4c320539d8eeecd
5
5
  SHA512:
6
- metadata.gz: fe6dc512e6e3d0de8ca362cb5d34c069dd3f88b1fd90f77056281c073d659003a687195637ef6fbac24763362dc41cc536a24f7ff98cb5225c34856b855ee431
7
- data.tar.gz: a3c1629d8437135fd16c5e02599ed6acf1d6bb55fd114f139855cc1c7ea6275bca9f726a59a9e63668698fe2a7c410d7a5a26485a054936ea5f175b62f7186f7
6
+ metadata.gz: 561d57d6c0aae98c94a6c6121dcd47601178fe37ce3c6077d87f28b85f4da7113112a66efba4c091f50dcbc1983212d2212abacf175845a212064cdbe340a389
7
+ data.tar.gz: 942e8def2974a6d131180ab66e1895ff2104ba960372513edea233598bb65ca52c612f359fcd33a43f698593aad288aa9012b75e29072c8d35e0a3af0bde87ae
data/CHANGELOG.md CHANGED
@@ -1,8 +1,59 @@
1
- # 0.6.0 / 2018-11-29
1
+ <!--- DO NOT EDIT THIS FILE - IT'S AUTOMATICALLY GENERATED VIA DEVTOOLS --->
2
+
3
+ ## 0.9.0 2022-01-26
4
+
2
5
 
3
6
  ### Changed
4
7
 
5
- - [BREAKING] 0.6.0 supports Ruby 2.3 and above. If you're on 2.3 keep in mind its EOL is scheduled at the end of March, 2019
8
+ - [BREAKING] Support for ... was changed, now constructors with such signature are not considered
9
+ as pass-through because they can forward arguments to another method (flash-gordon in [#78](https://github.com/dry-rb/dry-auto_inject/pull/78))
10
+
11
+ - [BREAKING] Support for 2.6 was dropped
12
+
13
+ [Compare v0.8.0...v0.9.0](https://github.com/dry-rb/dry-auto_inject/compare/v0.8.0...v0.9.0)
14
+
15
+ ## 0.8.0 2021-06-06
16
+
17
+
18
+ ### Added
19
+
20
+ - Support For `...` passthrough-args (@ytaben)
21
+
22
+ ### Fixed
23
+
24
+ - Constructors with kwargs strategy properly forward blocks to super (mintyfresh in [#68](https://github.com/dry-rb/dry-auto_inject/pull/68))
25
+
26
+ ### Changed
27
+
28
+ - [BREAKING] Support for 2.4 and 2.5 was dropped
29
+
30
+ [Compare v0.7.0...v0.8.0](https://github.com/dry-rb/dry-auto_inject/compare/v0.7.0...v0.8.0)
31
+
32
+ ## 0.7.0 2019-12-28
33
+
34
+
35
+ ### Fixed
36
+
37
+ - Keyword warnings issued by Ruby 2.7 in certain contexts (flash-gordon)
38
+
39
+ ### Changed
40
+
41
+ - [BREAKING] Support for 2.3 was dropped
42
+
43
+ [Compare v0.6.1...v0.7.0](https://github.com/dry-rb/dry-auto_inject/compare/v0.6.1...v0.7.0)
44
+
45
+ ## 0.6.1 2019-04-16
46
+
47
+
48
+ ### Fixed
49
+
50
+ - Allow explicit injection of falsey values (timriley in [#58](https://github.com/dry-rb/dry-auto_inject/pull/58))
51
+
52
+
53
+ [Compare v0.6.0...v0.6.1](https://github.com/dry-rb/dry-auto_inject/compare/v0.6.0...v0.6.1)
54
+
55
+ ## 0.6.0 2018-11-29
56
+
6
57
 
7
58
  ### Added
8
59
 
@@ -12,47 +63,53 @@
12
63
 
13
64
  - A couple of regressions were fixed along the way, see [#46](https://github.com/dry-rb/dry-auto_inject/issues/46) and [#49](https://github.com/dry-rb/dry-auto_inject/issues/49) (flash-gordon + timriley in [#48](https://github.com/dry-rb/dry-auto_inject/pull/48))
14
65
 
66
+ ### Changed
67
+
68
+ - [BREAKING] 0.6.0 supports Ruby 2.3 and above. If you're on 2.3 keep in mind its EOL is scheduled at the end of March, 2019
69
+
15
70
  [Compare v0.5.0...v0.6.0](https://github.com/dry-rb/dry-auto_inject/compare/v0.5.0...v0.6.0)
16
71
 
17
- # 0.5.0 / 2018-11-09
72
+ ## 0.5.0 2018-11-09
73
+
18
74
 
19
75
  ### Changed
20
76
 
21
77
  - Only assign `nil` dependency instance variables from generated `#initialize` if the instance variable has not been previously defined. This improves compatibility with objects initialized in non-conventional ways (see example below) (timriley in [#47](https://github.com/dry-rb/dry-auto_inject/pull/47))
22
78
 
23
- ```ruby
24
- module SomeFramework
25
- class Action
26
- def self.new(configuration:, **args)
27
- # Do some trickery so `#initialize` on subclasses don't need to worry
28
- # about handling a configuration kwarg and passing it to super
29
- allocate.tap do |obj|
30
- obj.instance_variable_set :@configuration, configuration
31
- obj.send :initialize, **args
32
- end
79
+ ```ruby
80
+ module SomeFramework
81
+ class Action
82
+ def self.new(configuration:, **args)
83
+ # Do some trickery so `#initialize` on subclasses don't need to worry
84
+ # about handling a configuration kwarg and passing it to super
85
+ allocate.tap do |obj|
86
+ obj.instance_variable_set :@configuration, configuration
87
+ obj.send :initialize, **args
33
88
  end
34
89
  end
35
90
  end
91
+ end
92
+
93
+ module MyApp
94
+ class Action < SomeFramework::Action
95
+ # Inject the configuration object, which is passed to
96
+ # SomeFramework::Action.new but not all the way through to any subsequent
97
+ # `#initialize` calls
98
+ include Import[configuration: "web.action.configuration"]
99
+ end
36
100
 
37
- module MyApp
38
- class Action < SomeFramework::Action
39
- # Inject the configuration object, which is passed to
40
- # SomeFramework::Action.new but not all the way through to any subsequent
41
- # `#initialize` calls
42
- include Import[configuration: "web.action.configuration"]
43
- end
44
-
45
- class SomeAction < Action
46
- # Subclasses of MyApp::Action don't need to concern themselves with
47
- # `configuration` dependency
48
- include Import["some_repo"]
49
- end
101
+ class SomeAction < Action
102
+ # Subclasses of MyApp::Action don't need to concern themselves with
103
+ # `configuration` dependency
104
+ include Import["some_repo"]
50
105
  end
51
- ```
106
+ end
107
+ ```
52
108
 
53
109
  [Compare v0.4.6...v0.5.0](https://github.com/dry-rb/dry-auto_inject/compare/v0.4.6...v0.5.0)
54
110
 
55
- # 0.4.6 / 2018-03-27
111
+ ## 0.4.6 2018-03-27
112
+
56
113
 
57
114
  ### Changed
58
115
 
@@ -60,37 +117,48 @@
60
117
 
61
118
  [Compare v0.4.5...v0.4.6](https://github.com/dry-rb/dry-auto_inject/compare/v0.4.5...v0.4.6)
62
119
 
63
- # 0.4.5 / 2018-01-02
120
+ ## 0.4.5 2018-01-02
121
+
64
122
 
65
123
  ### Added
66
124
 
67
125
  - Improved handling of kwargs being passed to #initialize’s super method (timriley)
68
126
 
127
+
69
128
  [Compare v0.4.4...v0.4.5](https://github.com/dry-rb/dry-auto_inject/compare/v0.4.4...v0.4.5)
70
129
 
71
- # 0.4.4 / 2017-09-14
130
+ ## 0.4.4 2017-09-14
131
+
72
132
 
73
133
  ### Added
74
134
 
75
135
  - Determine name for dependencies by splitting identifiers on any invalid local variable name characters (e.g. "/", "?", "!"), instead of splitting on dots only (raventid in [#39](https://github.com/dry-rb/dry-auto_inject/pull/39))
76
136
 
77
- # 0.4.3 / 2017-05-27
137
+
138
+ [Compare v0.4.3...v0.4.4](https://github.com/dry-rb/dry-auto_inject/compare/v0.4.3...v0.4.4)
139
+
140
+ ## 0.4.3 2017-05-27
141
+
78
142
 
79
143
  ### Added
80
144
 
81
145
  - Push sequential arguments along with keywords in the kwargs strategy (hbda + vladra in [#32](https://github.com/dry-rb/dry-auto_inject/pull/32))
82
146
 
147
+
83
148
  [Compare v0.4.2...v0.4.3](https://github.com/dry-rb/dry-auto_inject/compare/v0.4.2...v0.4.3)
84
149
 
85
- # 0.4.2 / 2016-10-10
150
+ ## 0.4.2 2016-10-10
151
+
86
152
 
87
153
  ### Fixed
88
154
 
89
155
  - Fixed issue where injectors for different containers could not be used on different classes in an inheritance hierarchy (timriley in [#31](https://github.com/dry-rb/dry-auto_inject/pull/31))
90
156
 
157
+
91
158
  [Compare v0.4.1...v0.4.2](https://github.com/dry-rb/dry-auto_inject/compare/v0.4.1...v0.4.2)
92
159
 
93
- # 0.4.1 / 2016-08-14
160
+ ## 0.4.1 2016-08-14
161
+
94
162
 
95
163
  ### Changed
96
164
 
@@ -98,138 +166,143 @@
98
166
 
99
167
  [Compare v0.4.0...v0.4.1](https://github.com/dry-rb/dry-auto_inject/compare/v0.4.0...v0.4.1)
100
168
 
101
- # 0.4.0 / 2016-07-26
169
+ ## 0.4.0 2016-07-26
170
+
102
171
 
103
172
  ### Added
104
173
 
105
174
  - Support for strategy chaining, which is helpful in opting for alternatives to an application's normal strategy (timriley in [#25](https://github.com/dry-rb/dry-auto_inject/pull/25))
106
175
 
107
- ```ruby
108
- # Define the application's injector with a non-default
109
- MyInject = Dry::AutoInject(MyContainer).hash
176
+ ```ruby
177
+ # Define the application's injector with a non-default
178
+ MyInject = Dry::AutoInject(MyContainer).hash
110
179
 
111
- # Opt for a different strategy in a particular class
112
- class MyClass
113
- include MyInject.args["foo"]
114
- end
180
+ # Opt for a different strategy in a particular class
181
+ class MyClass
182
+ include MyInject.args["foo"]
183
+ end
115
184
 
116
- # You can chain as long as you want (silly example to demonstrate the flexibility)
117
- class OtherClass
118
- include MyInject.args.hash.kwargs.args["foo"]
119
- end
120
- ```
185
+ # You can chain as long as you want (silly example to demonstrate the flexibility)
186
+ class OtherClass
187
+ include MyInject.args.hash.kwargs.args["foo"]
188
+ end
189
+ ```
190
+
191
+ ### Fixed
192
+
193
+ - Fixed issue with kwargs injectors used at multiple points in a class inheritance heirarchy (flash-gordon in [#27](https://github.com/dry-rb/dry-auto_inject/pull/27))
121
194
 
122
195
  ### Changed
123
196
 
124
197
  - Use a `BasicObject`-based environment for the injector builder API instead of the previous `define_singleton_method`-based approach, which had negative performance characteristics (timriley in [#26](https://github.com/dry-rb/dry-auto_inject/pull/26))
125
198
 
126
- ### Fixed
127
-
128
- - Fixed issue with kwargs injectors used at multiple points in a class inheritance heirarchy (flash-gordon in [#27](https://github.com/dry-rb/dry-auto_inject/pull/27))
199
+ [Compare v0.3.0,...v0.4.0](https://github.com/dry-rb/dry-auto_inject/compare/v0.3.0,...v0.4.0)
129
200
 
130
- [Compare v0.3.0...v0.4.0](https://github.com/dry-rb/dry-auto_inject/compare/v0.3.0...v0.4.0)
201
+ ## 0.3.0, 2016-06-02
131
202
 
132
- # 0.3.0, 2016-06-02
133
203
 
134
204
  ### Added
135
205
 
136
- * Support for new `kwargs` and `hash` injection strategies
206
+ - Support for new `kwargs` and `hash` injection strategies
137
207
 
138
- These strategies can be accessed via methods on the main builder object:
208
+ These strategies can be accessed via methods on the main builder object:
139
209
 
140
- ```ruby
141
- MyInject = Dry::AutoInject(my_container)
210
+ ```ruby
211
+ MyInject = Dry::AutoInject(my_container)
142
212
 
143
- class MyClass
144
- include MyInject.hash["my_dep"]
145
- end
146
- ```
147
- * Support for user-provided injection strategies
213
+ class MyClass
214
+ include MyInject.hash["my_dep"]
215
+ end
216
+ ```
217
+ - Support for user-provided injection strategies
148
218
 
149
- All injection strategies are now held in their own `Dry::AutoInject::Strategies` container. You can add register your own strategies to this container, or choose to provide a strategies container of your own:
219
+ All injection strategies are now held in their own `Dry::AutoInject::Strategies` container. You can add register your own strategies to this container, or choose to provide a strategies container of your own:
150
220
 
151
- ```ruby
152
- class CustomStrategy < Module
153
- # Your strategy code goes here :)
154
- end
221
+ ```ruby
222
+ class CustomStrategy < Module
223
+ # Your strategy code goes here :)
224
+ end
155
225
 
156
- # Registering your own strategy (globally)
157
- Dry::AutoInject::Strategies.register :custom, CustomStrategy
226
+ # Registering your own strategy (globally)
227
+ Dry::AutoInject::Strategies.register :custom, CustomStrategy
158
228
 
159
- MyInject = Dry::AutoInject(my_container)
229
+ MyInject = Dry::AutoInject(my_container)
160
230
 
161
- class MyClass
162
- include MyInject.custom["my_dep"]
163
- end
231
+ class MyClass
232
+ include MyInject.custom["my_dep"]
233
+ end
164
234
 
165
- # Providing your own container (keeping the existing strategies in place)
166
- class MyStrategies < Dry::AutoInject::Strategies
167
- register :custom, CustomStrategy
168
- end
235
+ # Providing your own container (keeping the existing strategies in place)
236
+ class MyStrategies < Dry::AutoInject::Strategies
237
+ register :custom, CustomStrategy
238
+ end
169
239
 
170
- MyInject = Dry::AutoInject(my_container, strategies: MyStrategies)
240
+ MyInject = Dry::AutoInject(my_container, strategies: MyStrategies)
171
241
 
172
- class MyClass
173
- include MyInject.custom["my_dep"]
174
- end
242
+ class MyClass
243
+ include MyInject.custom["my_dep"]
244
+ end
175
245
 
176
- # Proiding a completely separated container
177
- class MyStrategies
178
- extend Dry::Container::Mixin
179
- register :custom, CustomStrategy
180
- end
246
+ # Proiding a completely separated container
247
+ class MyStrategies
248
+ extend Dry::Container::Mixin
249
+ register :custom, CustomStrategy
250
+ end
181
251
 
182
- MyInject = Dry::AutoInject(my_container, strategies: MyStrategies)
252
+ MyInject = Dry::AutoInject(my_container, strategies: MyStrategies)
183
253
 
184
- class MyClass
185
- include MyInject.custom["my_dep"]
186
- end
187
- ```
188
- * User-specified aliases for dependencies
254
+ class MyClass
255
+ include MyInject.custom["my_dep"]
256
+ end
257
+ ```
258
+ - User-specified aliases for dependencies
189
259
 
190
- These aliases enable you to specify your own name for dependencies, both for their local readers and their keys in the kwargs- and hash-based initializers. Specify aliases by passing a hash of names:
260
+ These aliases enable you to specify your own name for dependencies, both for their local readers and their keys in the kwargs- and hash-based initializers. Specify aliases by passing a hash of names:
191
261
 
192
- ```ruby
193
- MyInject = Dry::AutoInject(my_container)
262
+ ```ruby
263
+ MyInject = Dry::AutoInject(my_container)
194
264
 
195
- class MyClass
196
- include MyInject[my_dep: "some_other.dep"]
197
-
198
- # Refer to the dependency as `my_dep` inside the class
199
- end
265
+ class MyClass
266
+ include MyInject[my_dep: "some_other.dep"]
200
267
 
201
- # Pass your own replacements using the `my_dep` initializer key
202
- my_obj = MyClass.new(my_dep: something_else)
203
- ```
268
+ # Refer to the dependency as `my_dep` inside the class
269
+ end
204
270
 
205
- A mix of both regular and aliased dependencies can also be injected:
271
+ # Pass your own replacements using the `my_dep` initializer key
272
+ my_obj = MyClass.new(my_dep: something_else)
273
+ ```
206
274
 
207
- ```ruby
208
- include MyInject["some_dep", another_dep: "some_other.dep"]
209
- ```
275
+ A mix of both regular and aliased dependencies can also be injected:
210
276
 
211
- * Inspect the `super` method of the including class’s `#initialize` and send it arguments that will match its own arguments list/arity. This allows auto_inject to be used more easily in existing class inheritance heirarchies.
277
+ ```ruby
278
+ include MyInject["some_dep", another_dep: "some_other.dep"]
279
+ ```
280
+ - Inspect the `super` method of the including class’s `#initialize` and send it arguments that will match its own arguments list/arity. This allows auto_inject to be used more easily in existing class inheritance heirarchies.
212
281
 
213
282
  ### Changed
214
283
 
215
- * `kwargs` is the new default injection strategy
216
- * Rubinius support is not available for the `kwargs` strategy (see [#18](https://github.com/dry-rb/dry-auto_inject/issues/18))
284
+ - `kwargs` is the new default injection strategy
285
+ - Rubinius support is not available for the `kwargs` strategy (see [#18](https://github.com/dry-rb/dry-auto_inject/issues/18))
217
286
 
218
- [Compare v0.2.0...v0.3.0](https://github.com/dry-rb/dry-auto_inject/compare/v0.2.0...v0.3.0)
287
+ [Compare v0.2.0...v0.3.0,](https://github.com/dry-rb/dry-auto_inject/compare/v0.2.0...v0.3.0,)
288
+
289
+ ## 0.2.0 2016-02-09
219
290
 
220
- # v0.2.0 2016-02-09
221
291
 
222
292
  ### Added
223
293
 
224
- * Support for hashes as constructor arguments via `Import.hash` interface (solnic)
294
+ - Support for hashes as constructor arguments via `Import.hash` interface (solnic)
295
+
225
296
 
226
297
  [Compare v0.1.0...v0.2.0](https://github.com/dry-rb/dry-auto_inject/compare/v0.1.0...v0.2.0)
227
298
 
228
- # v0.1.0 2015-11-12
299
+ ## 0.1.0 2015-11-12
229
300
 
230
301
  Changed interface from `Dry::AutoInject.new { container(some_container) }` to
231
- `Dry::AutoInject(some_container)`.
232
302
 
233
- # v0.0.1 2015-08-20
303
+
304
+ [Compare v0.0.1...v0.1.0](https://github.com/dry-rb/dry-auto_inject/compare/v0.0.1...v0.1.0)
305
+
306
+ ## 0.0.1 2015-08-20
234
307
 
235
308
  First public release \o/
data/LICENSE CHANGED
@@ -1,20 +1,20 @@
1
- Copyright (c) 2015-2016 Piotr Solnica
1
+ The MIT License (MIT)
2
2
 
3
- Permission is hereby granted, free of charge, to any person obtaining
4
- a copy of this software and associated documentation files (the
5
- "Software"), to deal in the Software without restriction, including
6
- without limitation the rights to use, copy, modify, merge, publish,
7
- distribute, sublicense, and/or sell copies of the Software, and to
8
- permit persons to whom the Software is furnished to do so, subject to
9
- the following conditions:
3
+ Copyright (c) 2015-2021 dry-rb team
10
4
 
11
- The above copyright notice and this permission notice shall be
12
- included in all copies or substantial portions of the Software.
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
13
11
 
14
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -1,57 +1,30 @@
1
+ <!--- this file is synced from dry-rb/template-gem project -->
1
2
  [gem]: https://rubygems.org/gems/dry-auto_inject
2
- [travis]: https://travis-ci.org/dry-rb/dry-auto_inject
3
- [codeclimate]: https://codeclimate.com/github/dry-rb/dry-auto_inject
4
- [coveralls]: https://coveralls.io/r/dry-rb/dry-auto_inject
3
+ [actions]: https://github.com/dry-rb/dry-auto_inject/actions
4
+ [codacy]: https://www.codacy.com/gh/dry-rb/dry-auto_inject
5
+ [chat]: https://dry-rb.zulipchat.com
5
6
  [inchpages]: http://inch-ci.org/github/dry-rb/dry-auto_inject
6
7
 
7
- # dry-auto_inject [![Join the chat at https://gitter.im/dry-rb/chat](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/dry-rb/chat)
8
+ # dry-auto_inject [![Join the chat at https://dry-rb.zulipchat.com](https://img.shields.io/badge/dry--rb-join%20chat-%23346b7a.svg)][chat]
8
9
 
9
10
  [![Gem Version](https://badge.fury.io/rb/dry-auto_inject.svg)][gem]
10
- [![Build Status](https://travis-ci.org/dry-rb/dry-auto_inject.svg?branch=master)][travis]
11
- [![Code Climate](https://codeclimate.com/github/dry-rb/dry-auto_inject/badges/gpa.svg)][codeclimate]
12
- [![Test Coverage](https://codeclimate.com/github/dry-rb/dry-auto_inject/badges/coverage.svg)][codeclimate]
11
+ [![CI Status](https://github.com/dry-rb/dry-auto_inject/workflows/ci/badge.svg)][actions]
12
+ [![Codacy Badge](https://api.codacy.com/project/badge/Grade/d869ec8dc92e46b6a6eafa551f68c3f4)][codacy]
13
+ [![Codacy Badge](https://api.codacy.com/project/badge/Coverage/d869ec8dc92e46b6a6eafa551f68c3f4)][codacy]
13
14
  [![Inline docs](http://inch-ci.org/github/dry-rb/dry-auto_inject.svg?branch=master)][inchpages]
14
- ![No monkey-patches](https://img.shields.io/badge/monkey--patches-0-brightgreen.svg)
15
-
16
- A simple extension which allows you to automatically inject dependencies to your
17
- object constructors from a configured container.
18
-
19
- It does 3 things:
20
-
21
- - Defines a constructor which accepts dependencies
22
- - Defines attribute readers for dependencies
23
- - Injects dependencies automatically to the constructor with overridden `.new`
24
-
25
- ## Installation
26
-
27
- Add this line to your application's Gemfile:
28
-
29
- ```ruby
30
- gem 'dry-auto_inject'
31
- ```
32
-
33
- And then execute:
34
-
35
- ```sh
36
- $ bundle
37
- ```
38
-
39
- Or install it yourself as:
40
- ```sh
41
- $ gem install dry-auto_inject
42
- ```
43
15
 
44
16
  ## Links
45
17
 
46
- * [Documentation](http://dry-rb.org/gems/dry-auto_inject/)
47
-
48
- ## Development
18
+ * [User documentation](https://dry-rb.org/gems/dry-auto_inject)
19
+ * [API documentation](http://rubydoc.info/gems/dry-auto_inject)
49
20
 
50
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
21
+ ## Supported Ruby versions
51
22
 
52
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
23
+ This library officially supports the following Ruby versions:
53
24
 
54
- ## Contributing
25
+ * MRI `>= 2.7.0`
26
+ * jruby `>= 9.3` (postponed until 2.7 is supported)
55
27
 
56
- Bug reports and pull requests are welcome on GitHub at https://github.com/dry-rb/dry-auto_inject.
28
+ ## License
57
29
 
30
+ See `LICENSE` file.
@@ -1,29 +1,37 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- lib = File.expand_path('../lib', __FILE__)
3
+ # this file is synced from dry-rb/template-gem project
4
+
5
+ lib = File.expand_path("lib", __dir__)
4
6
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
- require 'dry/auto_inject/version'
7
+ require "dry/auto_inject/version"
6
8
 
7
9
  Gem::Specification.new do |spec|
8
- spec.name = 'dry-auto_inject'
10
+ spec.name = "dry-auto_inject"
11
+ spec.authors = ["Piotr Solnica"]
12
+ spec.email = ["piotr.solnica@gmail.com"]
13
+ spec.license = "MIT"
9
14
  spec.version = Dry::AutoInject::VERSION.dup
10
- spec.authors = ['Piotr Solnica']
11
- spec.email = ['piotr.solnica@gmail.com']
12
- spec.license = 'MIT'
13
15
 
14
- spec.summary = 'Container-agnostic automatic constructor injection'
15
- spec.homepage = 'https://github.com/dryrb/dry-auto_inject'
16
+ spec.summary = "Container-agnostic automatic constructor injection"
17
+ spec.description = spec.summary
18
+ spec.homepage = "https://dry-rb.org/gems/dry-auto_inject"
19
+ spec.files = Dir["CHANGELOG.md", "LICENSE", "README.md", "dry-auto_inject.gemspec", "lib/**/*"]
20
+ spec.bindir = "bin"
21
+ spec.executables = []
22
+ spec.require_paths = ["lib"]
16
23
 
17
- spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
- spec.bindir = 'exe'
19
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
- spec.require_paths = ['lib']
24
+ spec.metadata["allowed_push_host"] = "https://rubygems.org"
25
+ spec.metadata["changelog_uri"] = "https://github.com/dry-rb/dry-auto_inject/blob/master/CHANGELOG.md"
26
+ spec.metadata["source_code_uri"] = "https://github.com/dry-rb/dry-auto_inject"
27
+ spec.metadata["bug_tracker_uri"] = "https://github.com/dry-rb/dry-auto_inject/issues"
21
28
 
22
- spec.required_ruby_version = '>= 2.3.0'
29
+ spec.required_ruby_version = ">= 2.7.0"
23
30
 
24
- spec.add_runtime_dependency 'dry-container', '>= 0.3.4'
31
+ # to update dependencies edit project.yml
32
+ spec.add_runtime_dependency "dry-container", ">= 0.3.4"
25
33
 
26
- spec.add_development_dependency 'bundler'
27
- spec.add_development_dependency 'rake'
28
- spec.add_development_dependency 'rspec', '~> 3.8'
34
+ spec.add_development_dependency "bundler"
35
+ spec.add_development_dependency "rake"
36
+ spec.add_development_dependency "rspec"
29
37
  end
@@ -1,17 +1,20 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'dry/auto_inject/strategies'
4
- require 'dry/auto_inject/injector'
3
+ require "dry/auto_inject/strategies"
4
+ require "dry/auto_inject/injector"
5
5
 
6
6
  module Dry
7
7
  module AutoInject
8
- class Builder < BasicObject
8
+ class Builder
9
9
  # @api private
10
10
  attr_reader :container
11
11
 
12
12
  # @api private
13
13
  attr_reader :strategies
14
14
 
15
+ # This clashes with the hash strategy
16
+ undef hash
17
+
15
18
  def initialize(container, options = {})
16
19
  @container = container
17
20
  @strategies = options.fetch(:strategies) { Strategies }
@@ -22,8 +25,8 @@ module Dry
22
25
  default[*dependency_names]
23
26
  end
24
27
 
25
- def respond_to?(name, include_private = false)
26
- Builder.public_instance_methods.include?(name) || strategies.key?(name)
28
+ def respond_to_missing?(name, _include_private = false)
29
+ strategies.key?(name)
27
30
  end
28
31
 
29
32
  private