dry-auto_inject 0.4.6 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +202 -87
- data/LICENSE +17 -17
- data/README.md +16 -43
- data/dry-auto_inject.gemspec +29 -18
- data/lib/dry-auto_inject.rb +1 -1
- data/lib/dry/auto_inject.rb +1 -9
- data/lib/dry/auto_inject/dependency_map.rb +4 -2
- data/lib/dry/auto_inject/method_parameters.rb +96 -0
- data/lib/dry/auto_inject/strategies/args.rb +13 -20
- data/lib/dry/auto_inject/strategies/constructor.rb +2 -2
- data/lib/dry/auto_inject/strategies/hash.rb +5 -4
- data/lib/dry/auto_inject/strategies/kwargs.rb +59 -36
- data/lib/dry/auto_inject/version.rb +1 -1
- metadata +13 -21
- data/.codeclimate.yml +0 -6
- data/.gitignore +0 -10
- data/.rspec +0 -2
- data/.rubocop.yml +0 -19
- data/.rubocop_todo.yml +0 -6
- data/.travis.yml +0 -23
- data/CONTRIBUTING.md +0 -29
- data/Gemfile +0 -16
- data/Rakefile +0 -14
- data/bin/console +0 -11
- data/bin/setup +0 -7
- data/rakelib/rubocop.rake +0 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3a0ca61974e0289e42b6058415642ce1fdcdd0c7c47cf5466e85222468147b26
|
4
|
+
data.tar.gz: 2a794922b2761a9e6bee7d0be47e0c5861954d7cc47ebb42143c452054e58ea8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 97034d375899475a0bc2116af339470960cea4bbf9ee7cf996295c7648802f62b8b77a91ae143bcdb8be48bc20216221c2cd65966d972ce8cc025ada343971ce
|
7
|
+
data.tar.gz: c112580b36f24515162b2088e48015238e36b68151b6f4b841ea6c4edae5061f5e05a580b408e320ced4f393701ae08034b23caf0b6ef037b9ea973d2ed95ee9
|
data/CHANGELOG.md
CHANGED
@@ -1,4 +1,103 @@
|
|
1
|
-
|
1
|
+
<!--- DO NOT EDIT THIS FILE - IT'S AUTOMATICALLY GENERATED VIA DEVTOOLS --->
|
2
|
+
|
3
|
+
## 0.8.0 2021-06-06
|
4
|
+
|
5
|
+
|
6
|
+
### Added
|
7
|
+
|
8
|
+
- Support For `...` passthrough-args (@ytaben)
|
9
|
+
|
10
|
+
### Fixed
|
11
|
+
|
12
|
+
- Constructors with kwargs strategy properly forward blocks to super (via #68) (@mintyfresh)
|
13
|
+
|
14
|
+
### Changed
|
15
|
+
|
16
|
+
- [BREAKING] Support for 2.4 and 2.5 was dropped
|
17
|
+
|
18
|
+
[Compare v0.7.0...v0.8.0](https://github.com/dry-rb/dry-auto_inject/compare/v0.7.0...v0.8.0)
|
19
|
+
|
20
|
+
## 0.7.0 2019-12-28
|
21
|
+
|
22
|
+
|
23
|
+
### Fixed
|
24
|
+
|
25
|
+
- Keyword warnings issued by Ruby 2.7 in certain contexts (flash-gordon)
|
26
|
+
|
27
|
+
### Changed
|
28
|
+
|
29
|
+
- [BREAKING] Support for 2.3 was dropped
|
30
|
+
|
31
|
+
[Compare v0.6.1...v0.7.0](https://github.com/dry-rb/dry-auto_inject/compare/v0.6.1...v0.7.0)
|
32
|
+
|
33
|
+
## 0.6.1 2019-04-16
|
34
|
+
|
35
|
+
|
36
|
+
### Fixed
|
37
|
+
|
38
|
+
- Allow explicit injection of falsey values (timriley in [#58](https://github.com/dry-rb/dry-auto_inject/pull/58))
|
39
|
+
|
40
|
+
|
41
|
+
[Compare v0.6.0...v0.6.1](https://github.com/dry-rb/dry-auto_inject/compare/v0.6.0...v0.6.1)
|
42
|
+
|
43
|
+
## 0.6.0 2018-11-29
|
44
|
+
|
45
|
+
|
46
|
+
### Added
|
47
|
+
|
48
|
+
- Enhanced support for integrating with existing constructors. The kwargs strategy will now pass dependencies up to the next constructor if it accepts an arbitrary number of arguments with `*args`. Note that this change may break existing code though we think it's unlikely to happen. If something doesn't work for you please report and we'll try to sort it out (flash-gordon + timriley in [#48](https://github.com/dry-rb/dry-auto_inject/pull/48))
|
49
|
+
|
50
|
+
### Fixed
|
51
|
+
|
52
|
+
- 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))
|
53
|
+
|
54
|
+
### Changed
|
55
|
+
|
56
|
+
- [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
|
57
|
+
|
58
|
+
[Compare v0.5.0...v0.6.0](https://github.com/dry-rb/dry-auto_inject/compare/v0.5.0...v0.6.0)
|
59
|
+
|
60
|
+
## 0.5.0 2018-11-09
|
61
|
+
|
62
|
+
|
63
|
+
### Changed
|
64
|
+
|
65
|
+
- 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))
|
66
|
+
|
67
|
+
```ruby
|
68
|
+
module SomeFramework
|
69
|
+
class Action
|
70
|
+
def self.new(configuration:, **args)
|
71
|
+
# Do some trickery so `#initialize` on subclasses don't need to worry
|
72
|
+
# about handling a configuration kwarg and passing it to super
|
73
|
+
allocate.tap do |obj|
|
74
|
+
obj.instance_variable_set :@configuration, configuration
|
75
|
+
obj.send :initialize, **args
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
module MyApp
|
82
|
+
class Action < SomeFramework::Action
|
83
|
+
# Inject the configuration object, which is passed to
|
84
|
+
# SomeFramework::Action.new but not all the way through to any subsequent
|
85
|
+
# `#initialize` calls
|
86
|
+
include Import[configuration: "web.action.configuration"]
|
87
|
+
end
|
88
|
+
|
89
|
+
class SomeAction < Action
|
90
|
+
# Subclasses of MyApp::Action don't need to concern themselves with
|
91
|
+
# `configuration` dependency
|
92
|
+
include Import["some_repo"]
|
93
|
+
end
|
94
|
+
end
|
95
|
+
```
|
96
|
+
|
97
|
+
[Compare v0.4.6...v0.5.0](https://github.com/dry-rb/dry-auto_inject/compare/v0.4.6...v0.5.0)
|
98
|
+
|
99
|
+
## 0.4.6 2018-03-27
|
100
|
+
|
2
101
|
|
3
102
|
### Changed
|
4
103
|
|
@@ -6,37 +105,48 @@
|
|
6
105
|
|
7
106
|
[Compare v0.4.5...v0.4.6](https://github.com/dry-rb/dry-auto_inject/compare/v0.4.5...v0.4.6)
|
8
107
|
|
9
|
-
|
108
|
+
## 0.4.5 2018-01-02
|
109
|
+
|
10
110
|
|
11
111
|
### Added
|
12
112
|
|
13
113
|
- Improved handling of kwargs being passed to #initialize’s super method (timriley)
|
14
114
|
|
115
|
+
|
15
116
|
[Compare v0.4.4...v0.4.5](https://github.com/dry-rb/dry-auto_inject/compare/v0.4.4...v0.4.5)
|
16
117
|
|
17
|
-
|
118
|
+
## 0.4.4 2017-09-14
|
119
|
+
|
18
120
|
|
19
121
|
### Added
|
20
122
|
|
21
123
|
- 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))
|
22
124
|
|
23
|
-
|
125
|
+
|
126
|
+
[Compare v0.4.3...v0.4.4](https://github.com/dry-rb/dry-auto_inject/compare/v0.4.3...v0.4.4)
|
127
|
+
|
128
|
+
## 0.4.3 2017-05-27
|
129
|
+
|
24
130
|
|
25
131
|
### Added
|
26
132
|
|
27
133
|
- Push sequential arguments along with keywords in the kwargs strategy (hbda + vladra in [#32](https://github.com/dry-rb/dry-auto_inject/pull/32))
|
28
134
|
|
135
|
+
|
29
136
|
[Compare v0.4.2...v0.4.3](https://github.com/dry-rb/dry-auto_inject/compare/v0.4.2...v0.4.3)
|
30
137
|
|
31
|
-
|
138
|
+
## 0.4.2 2016-10-10
|
139
|
+
|
32
140
|
|
33
141
|
### Fixed
|
34
142
|
|
35
143
|
- 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))
|
36
144
|
|
145
|
+
|
37
146
|
[Compare v0.4.1...v0.4.2](https://github.com/dry-rb/dry-auto_inject/compare/v0.4.1...v0.4.2)
|
38
147
|
|
39
|
-
|
148
|
+
## 0.4.1 2016-08-14
|
149
|
+
|
40
150
|
|
41
151
|
### Changed
|
42
152
|
|
@@ -44,138 +154,143 @@
|
|
44
154
|
|
45
155
|
[Compare v0.4.0...v0.4.1](https://github.com/dry-rb/dry-auto_inject/compare/v0.4.0...v0.4.1)
|
46
156
|
|
47
|
-
|
157
|
+
## 0.4.0 2016-07-26
|
158
|
+
|
48
159
|
|
49
160
|
### Added
|
50
161
|
|
51
162
|
- 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))
|
52
163
|
|
53
|
-
|
54
|
-
|
55
|
-
|
164
|
+
```ruby
|
165
|
+
# Define the application's injector with a non-default
|
166
|
+
MyInject = Dry::AutoInject(MyContainer).hash
|
56
167
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
168
|
+
# Opt for a different strategy in a particular class
|
169
|
+
class MyClass
|
170
|
+
include MyInject.args["foo"]
|
171
|
+
end
|
61
172
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
173
|
+
# You can chain as long as you want (silly example to demonstrate the flexibility)
|
174
|
+
class OtherClass
|
175
|
+
include MyInject.args.hash.kwargs.args["foo"]
|
176
|
+
end
|
177
|
+
```
|
178
|
+
|
179
|
+
### Fixed
|
180
|
+
|
181
|
+
- 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))
|
67
182
|
|
68
183
|
### Changed
|
69
184
|
|
70
185
|
- 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))
|
71
186
|
|
72
|
-
|
187
|
+
[Compare v0.3.0,...v0.4.0](https://github.com/dry-rb/dry-auto_inject/compare/v0.3.0,...v0.4.0)
|
73
188
|
|
74
|
-
|
75
|
-
|
76
|
-
[Compare v0.3.0...v0.4.0](https://github.com/dry-rb/dry-auto_inject/compare/v0.3.0...v0.4.0)
|
189
|
+
## 0.3.0, 2016-06-02
|
77
190
|
|
78
|
-
# 0.3.0, 2016-06-02
|
79
191
|
|
80
192
|
### Added
|
81
193
|
|
82
|
-
|
194
|
+
- Support for new `kwargs` and `hash` injection strategies
|
83
195
|
|
84
|
-
|
196
|
+
These strategies can be accessed via methods on the main builder object:
|
85
197
|
|
86
|
-
|
87
|
-
|
198
|
+
```ruby
|
199
|
+
MyInject = Dry::AutoInject(my_container)
|
88
200
|
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
201
|
+
class MyClass
|
202
|
+
include MyInject.hash["my_dep"]
|
203
|
+
end
|
204
|
+
```
|
205
|
+
- Support for user-provided injection strategies
|
94
206
|
|
95
|
-
|
207
|
+
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:
|
96
208
|
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
209
|
+
```ruby
|
210
|
+
class CustomStrategy < Module
|
211
|
+
# Your strategy code goes here :)
|
212
|
+
end
|
101
213
|
|
102
|
-
|
103
|
-
|
214
|
+
# Registering your own strategy (globally)
|
215
|
+
Dry::AutoInject::Strategies.register :custom, CustomStrategy
|
104
216
|
|
105
|
-
|
217
|
+
MyInject = Dry::AutoInject(my_container)
|
106
218
|
|
107
|
-
|
108
|
-
|
109
|
-
|
219
|
+
class MyClass
|
220
|
+
include MyInject.custom["my_dep"]
|
221
|
+
end
|
110
222
|
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
223
|
+
# Providing your own container (keeping the existing strategies in place)
|
224
|
+
class MyStrategies < Dry::AutoInject::Strategies
|
225
|
+
register :custom, CustomStrategy
|
226
|
+
end
|
115
227
|
|
116
|
-
|
228
|
+
MyInject = Dry::AutoInject(my_container, strategies: MyStrategies)
|
117
229
|
|
118
|
-
|
119
|
-
|
120
|
-
|
230
|
+
class MyClass
|
231
|
+
include MyInject.custom["my_dep"]
|
232
|
+
end
|
121
233
|
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
234
|
+
# Proiding a completely separated container
|
235
|
+
class MyStrategies
|
236
|
+
extend Dry::Container::Mixin
|
237
|
+
register :custom, CustomStrategy
|
238
|
+
end
|
127
239
|
|
128
|
-
|
129
|
-
|
130
|
-
class MyClass
|
131
|
-
include MyInject.custom["my_dep"]
|
132
|
-
end
|
133
|
-
```
|
134
|
-
* User-specified aliases for dependencies
|
240
|
+
MyInject = Dry::AutoInject(my_container, strategies: MyStrategies)
|
135
241
|
|
136
|
-
|
242
|
+
class MyClass
|
243
|
+
include MyInject.custom["my_dep"]
|
244
|
+
end
|
245
|
+
```
|
246
|
+
- User-specified aliases for dependencies
|
137
247
|
|
138
|
-
|
139
|
-
MyInject = Dry::AutoInject(my_container)
|
248
|
+
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:
|
140
249
|
|
141
|
-
|
142
|
-
|
250
|
+
```ruby
|
251
|
+
MyInject = Dry::AutoInject(my_container)
|
143
252
|
|
144
|
-
|
145
|
-
|
253
|
+
class MyClass
|
254
|
+
include MyInject[my_dep: "some_other.dep"]
|
146
255
|
|
147
|
-
#
|
148
|
-
|
149
|
-
```
|
256
|
+
# Refer to the dependency as `my_dep` inside the class
|
257
|
+
end
|
150
258
|
|
151
|
-
|
259
|
+
# Pass your own replacements using the `my_dep` initializer key
|
260
|
+
my_obj = MyClass.new(my_dep: something_else)
|
261
|
+
```
|
152
262
|
|
153
|
-
|
154
|
-
include MyInject["some_dep", another_dep: "some_other.dep"]
|
155
|
-
```
|
263
|
+
A mix of both regular and aliased dependencies can also be injected:
|
156
264
|
|
157
|
-
|
265
|
+
```ruby
|
266
|
+
include MyInject["some_dep", another_dep: "some_other.dep"]
|
267
|
+
```
|
268
|
+
- 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.
|
158
269
|
|
159
270
|
### Changed
|
160
271
|
|
161
|
-
|
162
|
-
|
272
|
+
- `kwargs` is the new default injection strategy
|
273
|
+
- Rubinius support is not available for the `kwargs` strategy (see [#18](https://github.com/dry-rb/dry-auto_inject/issues/18))
|
274
|
+
|
275
|
+
[Compare v0.2.0...v0.3.0,](https://github.com/dry-rb/dry-auto_inject/compare/v0.2.0...v0.3.0,)
|
163
276
|
|
164
|
-
|
277
|
+
## 0.2.0 2016-02-09
|
165
278
|
|
166
|
-
# v0.2.0 2016-02-09
|
167
279
|
|
168
280
|
### Added
|
169
281
|
|
170
|
-
|
282
|
+
- Support for hashes as constructor arguments via `Import.hash` interface (solnic)
|
283
|
+
|
171
284
|
|
172
285
|
[Compare v0.1.0...v0.2.0](https://github.com/dry-rb/dry-auto_inject/compare/v0.1.0...v0.2.0)
|
173
286
|
|
174
|
-
|
287
|
+
## 0.1.0 2015-11-12
|
175
288
|
|
176
289
|
Changed interface from `Dry::AutoInject.new { container(some_container) }` to
|
177
|
-
`Dry::AutoInject(some_container)`.
|
178
290
|
|
179
|
-
|
291
|
+
|
292
|
+
[Compare v0.0.1...v0.1.0](https://github.com/dry-rb/dry-auto_inject/compare/v0.0.1...v0.1.0)
|
293
|
+
|
294
|
+
## 0.0.1 2015-08-20
|
180
295
|
|
181
296
|
First public release \o/
|
data/LICENSE
CHANGED
@@ -1,20 +1,20 @@
|
|
1
|
-
|
1
|
+
The MIT License (MIT)
|
2
2
|
|
3
|
-
|
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
|
-
|
12
|
-
|
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
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
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
|
-
[
|
3
|
-
[
|
4
|
-
[
|
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://
|
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
|
-
[![
|
11
|
-
[![
|
12
|
-
[![
|
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
|
-
* [
|
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
|
-
|
21
|
+
## Supported Ruby versions
|
51
22
|
|
52
|
-
|
23
|
+
This library officially supports the following Ruby versions:
|
53
24
|
|
54
|
-
|
25
|
+
* MRI `>= 2.6.0`
|
26
|
+
* jruby `>= 9.2`
|
55
27
|
|
56
|
-
|
28
|
+
## License
|
57
29
|
|
30
|
+
See `LICENSE` file.
|
data/dry-auto_inject.gemspec
CHANGED
@@ -1,30 +1,41 @@
|
|
1
|
-
# coding: utf-8
|
2
1
|
# frozen_string_literal: true
|
3
2
|
|
4
|
-
|
3
|
+
# this file is synced from dry-rb/template-gem project
|
4
|
+
|
5
|
+
lib = File.expand_path("lib", __dir__)
|
5
6
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
6
|
-
require
|
7
|
+
require "dry/auto_inject/version"
|
7
8
|
|
8
9
|
Gem::Specification.new do |spec|
|
9
|
-
spec.name =
|
10
|
+
spec.name = "dry-auto_inject"
|
11
|
+
spec.authors = ["Piotr Solnica"]
|
12
|
+
spec.email = ["piotr.solnica@gmail.com"]
|
13
|
+
spec.license = "MIT"
|
10
14
|
spec.version = Dry::AutoInject::VERSION.dup
|
11
|
-
spec.authors = ['Piotr Solnica']
|
12
|
-
spec.email = ['piotr.solnica@gmail.com']
|
13
|
-
spec.license = 'MIT'
|
14
15
|
|
15
|
-
spec.summary =
|
16
|
-
spec.
|
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"]
|
17
23
|
|
18
|
-
spec.
|
19
|
-
spec.
|
20
|
-
spec.
|
21
|
-
spec.
|
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"
|
22
28
|
|
23
|
-
|
29
|
+
if defined? JRUBY_VERSION
|
30
|
+
spec.required_ruby_version = ">= 2.5.0"
|
31
|
+
else
|
32
|
+
spec.required_ruby_version = ">= 2.6.0"
|
33
|
+
end
|
24
34
|
|
25
|
-
|
35
|
+
# to update dependencies edit project.yml
|
36
|
+
spec.add_runtime_dependency "dry-container", ">= 0.3.4"
|
26
37
|
|
27
|
-
spec.add_development_dependency
|
28
|
-
spec.add_development_dependency
|
29
|
-
spec.add_development_dependency
|
38
|
+
spec.add_development_dependency "bundler"
|
39
|
+
spec.add_development_dependency "rake"
|
40
|
+
spec.add_development_dependency "rspec"
|
30
41
|
end
|
data/lib/dry-auto_inject.rb
CHANGED
data/lib/dry/auto_inject.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "dry/auto_inject/builder"
|
4
4
|
|
5
5
|
module Dry
|
6
6
|
# Configure an auto-injection module
|
@@ -43,12 +43,4 @@ module Dry
|
|
43
43
|
def self.AutoInject(container, options = {})
|
44
44
|
AutoInject::Builder.new(container, options)
|
45
45
|
end
|
46
|
-
|
47
|
-
module AutoInject
|
48
|
-
# @api private
|
49
|
-
def self.super_method(klass, method)
|
50
|
-
method = klass.instance_method(method)
|
51
|
-
method unless method.owner.equal?(klass)
|
52
|
-
end
|
53
|
-
end
|
54
46
|
end
|
@@ -29,11 +29,11 @@ module Dry
|
|
29
29
|
end
|
30
30
|
|
31
31
|
def names
|
32
|
-
@map.keys
|
32
|
+
@names ||= @map.keys
|
33
33
|
end
|
34
34
|
|
35
35
|
def to_h
|
36
|
-
@map.dup
|
36
|
+
@map.dup
|
37
37
|
end
|
38
38
|
alias_method :to_hash, :to_h
|
39
39
|
|
@@ -42,12 +42,14 @@ module Dry
|
|
42
42
|
def name_for(identifier)
|
43
43
|
matched = VALID_NAME.match(identifier.to_s)
|
44
44
|
raise DependencyNameInvalid, "name +#{identifier}+ is not a valid Ruby identifier" unless matched
|
45
|
+
|
45
46
|
matched[0]
|
46
47
|
end
|
47
48
|
|
48
49
|
def add_dependency(name, identifier)
|
49
50
|
name = name.to_sym
|
50
51
|
raise DuplicateDependencyError, "name +#{name}+ is already used" if @map.key?(name)
|
52
|
+
|
51
53
|
@map[name] = identifier
|
52
54
|
end
|
53
55
|
end
|
@@ -0,0 +1,96 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'set'
|
4
|
+
|
5
|
+
module Dry
|
6
|
+
module AutoInject
|
7
|
+
# @api private
|
8
|
+
class MethodParameters
|
9
|
+
PASS_THROUGH = [[%i[rest]], [%i[rest *], %i[block &]]]
|
10
|
+
|
11
|
+
if RUBY_VERSION >= '2.4.4.' && !defined? JRUBY_VERSION
|
12
|
+
def self.of(obj, name)
|
13
|
+
Enumerator.new do |y|
|
14
|
+
begin
|
15
|
+
method = obj.instance_method(name)
|
16
|
+
rescue NameError
|
17
|
+
end
|
18
|
+
|
19
|
+
loop do
|
20
|
+
break if method.nil?
|
21
|
+
|
22
|
+
y << MethodParameters.new(method.parameters)
|
23
|
+
method = method.super_method
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
else
|
28
|
+
# see https://bugs.ruby-lang.org/issues/13973
|
29
|
+
def self.of(obj, name)
|
30
|
+
Enumerator.new do |y|
|
31
|
+
ancestors = obj.ancestors
|
32
|
+
|
33
|
+
loop do
|
34
|
+
klass = ancestors.shift
|
35
|
+
break if klass.nil?
|
36
|
+
|
37
|
+
begin
|
38
|
+
method = klass.instance_method(name)
|
39
|
+
|
40
|
+
next unless method.owner.equal?(klass)
|
41
|
+
rescue NameError
|
42
|
+
next
|
43
|
+
end
|
44
|
+
|
45
|
+
y << MethodParameters.new(method.parameters)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
attr_reader :parameters
|
52
|
+
|
53
|
+
def initialize(parameters)
|
54
|
+
@parameters = parameters
|
55
|
+
end
|
56
|
+
|
57
|
+
def splat?
|
58
|
+
return @splat if defined? @splat
|
59
|
+
|
60
|
+
@splat = parameters.any? { |type, _| type == :rest }
|
61
|
+
end
|
62
|
+
|
63
|
+
def sequential_arguments?
|
64
|
+
return @sequential_arguments if defined? @sequential_arguments
|
65
|
+
|
66
|
+
@sequential_arguments = parameters.any? { |type, _|
|
67
|
+
type == :req || type == :opt
|
68
|
+
}
|
69
|
+
end
|
70
|
+
|
71
|
+
def keyword_names
|
72
|
+
@keyword_names ||= parameters.each_with_object(Set.new) { |(type, name), names|
|
73
|
+
names << name if type == :key || type == :keyreq
|
74
|
+
}
|
75
|
+
end
|
76
|
+
|
77
|
+
def keyword?(name)
|
78
|
+
keyword_names.include?(name)
|
79
|
+
end
|
80
|
+
|
81
|
+
def empty?
|
82
|
+
parameters.empty?
|
83
|
+
end
|
84
|
+
|
85
|
+
def length
|
86
|
+
parameters.length
|
87
|
+
end
|
88
|
+
|
89
|
+
def pass_through?
|
90
|
+
PASS_THROUGH.include?(parameters)
|
91
|
+
end
|
92
|
+
|
93
|
+
EMPTY = new([])
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'dry/auto_inject/strategies/constructor'
|
4
|
+
require 'dry/auto_inject/method_parameters'
|
4
5
|
|
5
6
|
module Dry
|
6
7
|
module AutoInject
|
@@ -22,12 +23,15 @@ module Dry
|
|
22
23
|
end
|
23
24
|
|
24
25
|
def define_initialize(klass)
|
25
|
-
|
26
|
+
super_parameters = MethodParameters.of(klass, :initialize).each do |ps|
|
27
|
+
# Look upwards past `def foo(*)` methods until we get an explicit list of parameters
|
28
|
+
break ps unless ps.pass_through?
|
29
|
+
end
|
26
30
|
|
27
|
-
if
|
31
|
+
if super_parameters.empty?
|
28
32
|
define_initialize_with_params
|
29
33
|
else
|
30
|
-
define_initialize_with_splat(
|
34
|
+
define_initialize_with_splat(super_parameters)
|
31
35
|
end
|
32
36
|
end
|
33
37
|
|
@@ -42,31 +46,20 @@ module Dry
|
|
42
46
|
RUBY
|
43
47
|
end
|
44
48
|
|
45
|
-
def define_initialize_with_splat(
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
49
|
+
def define_initialize_with_splat(super_parameters)
|
50
|
+
super_pass = if super_parameters.splat?
|
51
|
+
'*args'
|
52
|
+
else
|
53
|
+
"*args.take(#{super_parameters.length})"
|
50
54
|
end
|
51
55
|
|
52
56
|
instance_mod.class_eval <<-RUBY, __FILE__, __LINE__ + 1
|
53
57
|
def initialize(*args)
|
54
58
|
#{dependency_map.names.map.with_index { |name, i| "@#{name} = args[#{i}]" }.join("\n")}
|
55
|
-
super(#{
|
59
|
+
super(#{super_pass})
|
56
60
|
end
|
57
61
|
RUBY
|
58
62
|
end
|
59
|
-
|
60
|
-
def find_super(klass, method_name)
|
61
|
-
super_method = Dry::AutoInject.super_method(klass, method_name)
|
62
|
-
|
63
|
-
# Look upwards past `def foo(*)` methods until we get an explicit list of parameters
|
64
|
-
while super_method && super_method.parameters == [[:rest]]
|
65
|
-
super_method = Dry::AutoInject.super_method(super_method.owner, :initialize)
|
66
|
-
end
|
67
|
-
|
68
|
-
super_method
|
69
|
-
end
|
70
63
|
end
|
71
64
|
|
72
65
|
register :args, Args
|
@@ -44,11 +44,11 @@ module Dry
|
|
44
44
|
end
|
45
45
|
|
46
46
|
def define_new
|
47
|
-
raise NotImplementedError,
|
47
|
+
raise NotImplementedError, 'must be implemented by a subclass'
|
48
48
|
end
|
49
49
|
|
50
50
|
def define_initialize(klass)
|
51
|
-
raise NotImplementedError,
|
51
|
+
raise NotImplementedError, 'must be implemented by a subclass'
|
52
52
|
end
|
53
53
|
end
|
54
54
|
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'dry/auto_inject/strategies/constructor'
|
4
|
+
require 'dry/auto_inject/method_parameters'
|
4
5
|
|
5
6
|
module Dry
|
6
7
|
module AutoInject
|
@@ -22,13 +23,13 @@ module Dry
|
|
22
23
|
end
|
23
24
|
|
24
25
|
def define_initialize(klass)
|
25
|
-
|
26
|
-
|
26
|
+
super_params = MethodParameters.of(klass, :initialize).first
|
27
|
+
super_pass = super_params.empty? ? '' : 'options'
|
27
28
|
|
28
29
|
instance_mod.class_eval <<-RUBY, __FILE__, __LINE__ + 1
|
29
30
|
def initialize(options)
|
30
|
-
#{dependency_map.names.map { |name| "@#{name} = options[:#{name}]" }.join("\n")}
|
31
|
-
super(#{
|
31
|
+
#{dependency_map.names.map { |name| "@#{name} = options[:#{name}] unless !options.key?(#{name}) && instance_variable_defined?(:'@#{name}')" }.join("\n")}
|
32
|
+
super(#{super_pass})
|
32
33
|
end
|
33
34
|
RUBY
|
34
35
|
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'dry/auto_inject/strategies/constructor'
|
4
|
+
require 'dry/auto_inject/method_parameters'
|
4
5
|
|
5
6
|
module Dry
|
6
7
|
module AutoInject
|
@@ -11,69 +12,91 @@ module Dry
|
|
11
12
|
|
12
13
|
def define_new
|
13
14
|
class_mod.class_exec(container, dependency_map) do |container, dependency_map|
|
14
|
-
map = dependency_map.to_h
|
15
|
+
map = dependency_map.to_h
|
15
16
|
|
16
|
-
define_method :new do |*args, **kwargs|
|
17
|
+
define_method :new do |*args, **kwargs, &block|
|
17
18
|
map.each do |name, identifier|
|
18
|
-
kwargs[name]
|
19
|
+
kwargs[name] = container[identifier] unless kwargs.key?(name)
|
19
20
|
end
|
20
21
|
|
21
|
-
super(*args, **kwargs)
|
22
|
+
super(*args, **kwargs, &block)
|
22
23
|
end
|
23
24
|
end
|
24
25
|
end
|
25
26
|
|
26
27
|
def define_initialize(klass)
|
27
|
-
|
28
|
+
super_parameters = MethodParameters.of(klass, :initialize).each do |ps|
|
29
|
+
# Look upwards past `def foo(*)` and `def foo(...)` methods
|
30
|
+
# until we get an explicit list of parameters
|
31
|
+
break ps unless ps.pass_through?
|
32
|
+
end
|
28
33
|
|
29
|
-
if
|
30
|
-
|
34
|
+
if super_parameters.splat? || super_parameters.sequential_arguments?
|
35
|
+
define_initialize_with_splat(super_parameters)
|
31
36
|
else
|
32
|
-
|
37
|
+
define_initialize_with_keywords(super_parameters)
|
33
38
|
end
|
34
39
|
|
35
40
|
self
|
36
41
|
end
|
37
42
|
|
38
|
-
def define_initialize_with_keywords
|
39
|
-
|
40
|
-
|
41
|
-
instance_mod.class_eval <<-RUBY, __FILE__, __LINE__ + 1
|
42
|
-
def initialize(#{initialize_params})
|
43
|
-
#{dependency_map.names.map { |name| "@#{name} = #{name}" }.join("\n")}
|
44
|
-
super()
|
45
|
-
end
|
46
|
-
RUBY
|
43
|
+
def define_initialize_with_keywords(super_parameters)
|
44
|
+
assign_dependencies = method(:assign_dependencies)
|
45
|
+
slice_kwargs = method(:slice_kwargs)
|
47
46
|
|
48
|
-
|
49
|
-
|
47
|
+
instance_mod.class_exec do
|
48
|
+
define_method :initialize do |**kwargs, &block|
|
49
|
+
assign_dependencies.(kwargs, self)
|
50
50
|
|
51
|
-
|
52
|
-
super_kwarg_names = super_method.parameters.each_with_object([]) { |(type, name), names|
|
53
|
-
names << name if [:key, :keyreq].include?(type)
|
54
|
-
}
|
51
|
+
super_kwargs = slice_kwargs.(kwargs, super_parameters)
|
55
52
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
53
|
+
if super_kwargs.any?
|
54
|
+
super(**super_kwargs, &block)
|
55
|
+
else
|
56
|
+
super(&block)
|
60
57
|
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
61
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
end
|
66
|
-
}
|
62
|
+
def define_initialize_with_splat(super_parameters)
|
63
|
+
assign_dependencies = method(:assign_dependencies)
|
64
|
+
slice_kwargs = method(:slice_kwargs)
|
67
65
|
|
68
|
-
|
69
|
-
|
66
|
+
instance_mod.class_exec do
|
67
|
+
define_method :initialize do |*args, **kwargs, &block|
|
68
|
+
assign_dependencies.(kwargs, self)
|
69
|
+
|
70
|
+
if super_parameters.splat?
|
71
|
+
super(*args, **kwargs, &block)
|
70
72
|
else
|
71
|
-
|
73
|
+
super_kwargs = slice_kwargs.(kwargs, super_parameters)
|
74
|
+
|
75
|
+
if super_kwargs.any?
|
76
|
+
super(*args, **super_kwargs, &block)
|
77
|
+
else
|
78
|
+
super(*args, &block)
|
79
|
+
end
|
72
80
|
end
|
73
81
|
end
|
74
82
|
end
|
83
|
+
end
|
75
84
|
|
76
|
-
|
85
|
+
def assign_dependencies(kwargs, destination)
|
86
|
+
dependency_map.names.each do |name|
|
87
|
+
# Assign instance variables, but only if the ivar is not
|
88
|
+
# previously defined (this improves compatibility with objects
|
89
|
+
# initialized in unconventional ways)
|
90
|
+
if kwargs.key?(name) || !destination.instance_variable_defined?(:"@#{name}")
|
91
|
+
destination.instance_variable_set :"@#{name}", kwargs[name]
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
def slice_kwargs(kwargs, super_parameters)
|
97
|
+
kwargs.select do |key|
|
98
|
+
!dependency_map.names.include?(key) || super_parameters.keyword?(key)
|
99
|
+
end
|
77
100
|
end
|
78
101
|
end
|
79
102
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dry-auto_inject
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Piotr Solnica
|
8
8
|
autorequire:
|
9
|
-
bindir:
|
9
|
+
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-06-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dry-container
|
@@ -66,44 +66,37 @@ dependencies:
|
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
|
-
description:
|
69
|
+
description: Container-agnostic automatic constructor injection
|
70
70
|
email:
|
71
71
|
- piotr.solnica@gmail.com
|
72
72
|
executables: []
|
73
73
|
extensions: []
|
74
74
|
extra_rdoc_files: []
|
75
75
|
files:
|
76
|
-
- ".codeclimate.yml"
|
77
|
-
- ".gitignore"
|
78
|
-
- ".rspec"
|
79
|
-
- ".rubocop.yml"
|
80
|
-
- ".rubocop_todo.yml"
|
81
|
-
- ".travis.yml"
|
82
76
|
- CHANGELOG.md
|
83
|
-
- CONTRIBUTING.md
|
84
|
-
- Gemfile
|
85
77
|
- LICENSE
|
86
78
|
- README.md
|
87
|
-
- Rakefile
|
88
|
-
- bin/console
|
89
|
-
- bin/setup
|
90
79
|
- dry-auto_inject.gemspec
|
91
80
|
- lib/dry-auto_inject.rb
|
92
81
|
- lib/dry/auto_inject.rb
|
93
82
|
- lib/dry/auto_inject/builder.rb
|
94
83
|
- lib/dry/auto_inject/dependency_map.rb
|
95
84
|
- lib/dry/auto_inject/injector.rb
|
85
|
+
- lib/dry/auto_inject/method_parameters.rb
|
96
86
|
- lib/dry/auto_inject/strategies.rb
|
97
87
|
- lib/dry/auto_inject/strategies/args.rb
|
98
88
|
- lib/dry/auto_inject/strategies/constructor.rb
|
99
89
|
- lib/dry/auto_inject/strategies/hash.rb
|
100
90
|
- lib/dry/auto_inject/strategies/kwargs.rb
|
101
91
|
- lib/dry/auto_inject/version.rb
|
102
|
-
-
|
103
|
-
homepage: https://github.com/dryrb/dry-auto_inject
|
92
|
+
homepage: https://dry-rb.org/gems/dry-auto_inject
|
104
93
|
licenses:
|
105
94
|
- MIT
|
106
|
-
metadata:
|
95
|
+
metadata:
|
96
|
+
allowed_push_host: https://rubygems.org
|
97
|
+
changelog_uri: https://github.com/dry-rb/dry-auto_inject/blob/master/CHANGELOG.md
|
98
|
+
source_code_uri: https://github.com/dry-rb/dry-auto_inject
|
99
|
+
bug_tracker_uri: https://github.com/dry-rb/dry-auto_inject/issues
|
107
100
|
post_install_message:
|
108
101
|
rdoc_options: []
|
109
102
|
require_paths:
|
@@ -112,15 +105,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
112
105
|
requirements:
|
113
106
|
- - ">="
|
114
107
|
- !ruby/object:Gem::Version
|
115
|
-
version: 2.
|
108
|
+
version: 2.6.0
|
116
109
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
117
110
|
requirements:
|
118
111
|
- - ">="
|
119
112
|
- !ruby/object:Gem::Version
|
120
113
|
version: '0'
|
121
114
|
requirements: []
|
122
|
-
|
123
|
-
rubygems_version: 2.7.5
|
115
|
+
rubygems_version: 3.1.6
|
124
116
|
signing_key:
|
125
117
|
specification_version: 4
|
126
118
|
summary: Container-agnostic automatic constructor injection
|
data/.codeclimate.yml
DELETED
data/.gitignore
DELETED
data/.rspec
DELETED
data/.rubocop.yml
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
# Generated by `rubocop --auto-gen-config`
|
2
|
-
inherit_from: .rubocop_todo.yml
|
3
|
-
|
4
|
-
Metrics/LineLength:
|
5
|
-
Max: 110
|
6
|
-
|
7
|
-
Lint/HandleExceptions:
|
8
|
-
Exclude:
|
9
|
-
- rakelib/*.rake
|
10
|
-
|
11
|
-
Style/LambdaCall:
|
12
|
-
EnforcedStyle: braces
|
13
|
-
|
14
|
-
Style/Documentation:
|
15
|
-
Enabled: false
|
16
|
-
|
17
|
-
Style/FileName:
|
18
|
-
Exclude:
|
19
|
-
- lib/dry-pipeline.rb
|
data/.rubocop_todo.yml
DELETED
@@ -1,6 +0,0 @@
|
|
1
|
-
# This configuration was generated by `rubocop --auto-gen-config`
|
2
|
-
# on 2015-08-19 22:11:28 +0100 using RuboCop version 0.32.0.
|
3
|
-
# The point is for the user to remove these configuration records
|
4
|
-
# one by one as the offenses are removed from the code base.
|
5
|
-
# Note that changes in the inspected code, or installation of new
|
6
|
-
# versions of RuboCop, may require this file to be generated again.
|
data/.travis.yml
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
language: ruby
|
2
|
-
cache: bundler
|
3
|
-
bundler_args: --without tools
|
4
|
-
script:
|
5
|
-
- bundle exec rake
|
6
|
-
after_success:
|
7
|
-
- '[ -d coverage ] && bundle exec codeclimate-test-reporter'
|
8
|
-
rvm:
|
9
|
-
- 2.5.0
|
10
|
-
- 2.4.3
|
11
|
-
- 2.3.6
|
12
|
-
- jruby-9.1.10.0
|
13
|
-
env:
|
14
|
-
global:
|
15
|
-
- COVERAGE=true
|
16
|
-
notifications:
|
17
|
-
email: false
|
18
|
-
webhooks:
|
19
|
-
urls:
|
20
|
-
- https://webhooks.gitter.im/e/19098b4253a72c9796db
|
21
|
-
on_success: change # options: [always|never|change] default: always
|
22
|
-
on_failure: always # options: [always|never|change] default: always
|
23
|
-
on_start: false # default: false
|
data/CONTRIBUTING.md
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
# Issue Guidelines
|
2
|
-
|
3
|
-
## Reporting bugs
|
4
|
-
|
5
|
-
If you found a bug, report an issue and describe what's the expected behavior versus what actually happens. If the bug causes a crash, attach a full backtrace. If possible, a reproduction script showing the problem is highly appreciated.
|
6
|
-
|
7
|
-
## Reporting feature requests
|
8
|
-
|
9
|
-
Report a feature request **only after discussing it first on [discuss.dry-rb.org](https://discuss.dry-rb.org)** where it was accepted. Please provide a concise description of the feature, don't link to a discussion thread, and instead summarize what was discussed.
|
10
|
-
|
11
|
-
## Reporting questions, support requests, ideas, concerns etc.
|
12
|
-
|
13
|
-
**PLEASE DON'T** - use [discuss.dry-rb.org](http://discuss.dry-rb.org) instead.
|
14
|
-
|
15
|
-
# Pull Request Guidelines
|
16
|
-
|
17
|
-
A Pull Request will only be accepted if it addresses a specific issue that was reported previously, or fixes typos, mistakes in documentation etc.
|
18
|
-
|
19
|
-
Other requirements:
|
20
|
-
|
21
|
-
1) Do not open a pull request if you can't provide tests along with it. If you have problems writing tests, ask for help in the related issue.
|
22
|
-
2) Follow the style conventions of the surrounding code. In most cases, this is standard ruby style.
|
23
|
-
3) Add API documentation if it's a new feature
|
24
|
-
4) Update API documentation if it changes an existing feature
|
25
|
-
5) Bonus points for sending a PR to [github.com/dry-rb/dry-rb.org](github.com/dry-rb/dry-rb.org) which updates user documentation and guides
|
26
|
-
|
27
|
-
# Asking for help
|
28
|
-
|
29
|
-
If these guidelines aren't helpful, and you're stuck, please post a message on [discuss.dry-rb.org](https://discuss.dry-rb.org).
|
data/Gemfile
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
source 'https://rubygems.org'
|
4
|
-
|
5
|
-
# Specify your gem's dependencies in dry-auto_inject.gemspec
|
6
|
-
gemspec
|
7
|
-
|
8
|
-
group :test do
|
9
|
-
gem "simplecov"
|
10
|
-
gem "codeclimate-test-reporter", require: nil
|
11
|
-
end
|
12
|
-
|
13
|
-
group :tools do
|
14
|
-
gem 'byebug', platforms: :mri
|
15
|
-
gem 'pry'
|
16
|
-
end
|
data/Rakefile
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
#!/usr/bin/env rake
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
require 'bundler/gem_tasks'
|
5
|
-
|
6
|
-
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), 'lib'))
|
7
|
-
|
8
|
-
require 'rspec/core'
|
9
|
-
require 'rspec/core/rake_task'
|
10
|
-
|
11
|
-
task default: :spec
|
12
|
-
|
13
|
-
desc 'Run all specs in spec directory'
|
14
|
-
RSpec::Core::RakeTask.new(:spec)
|
data/bin/console
DELETED
@@ -1,11 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
require 'bundler/setup'
|
5
|
-
require 'dry-auto_inject'
|
6
|
-
|
7
|
-
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
-
# with your gem easier. You can also use a different console, if you like.
|
9
|
-
|
10
|
-
require 'pry'
|
11
|
-
Pry.start
|
data/bin/setup
DELETED
data/rakelib/rubocop.rake
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
begin
|
4
|
-
require 'rubocop/rake_task'
|
5
|
-
|
6
|
-
Rake::Task[:default].enhance [:rubocop]
|
7
|
-
|
8
|
-
RuboCop::RakeTask.new do |task|
|
9
|
-
task.options << '--display-cop-names'
|
10
|
-
end
|
11
|
-
|
12
|
-
namespace :rubocop do
|
13
|
-
desc 'Generate a configuration file acting as a TODO list.'
|
14
|
-
task :auto_gen_config do
|
15
|
-
exec 'bundle exec rubocop --auto-gen-config'
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
rescue LoadError
|
20
|
-
end
|