dry-auto_inject 0.7.0 → 0.8.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: 0703f168c7bd86b0b847ff3805d192745b22595a9b0b70bd1880e74d4a189251
4
- data.tar.gz: f4fe146fe1721a14cf22a90cb7a5d58f17f55ba97a5e74304368a04c69a26f47
3
+ metadata.gz: 3a0ca61974e0289e42b6058415642ce1fdcdd0c7c47cf5466e85222468147b26
4
+ data.tar.gz: 2a794922b2761a9e6bee7d0be47e0c5861954d7cc47ebb42143c452054e58ea8
5
5
  SHA512:
6
- metadata.gz: ad18bccd197227333852c9cb65116cfff76a3fce5a5dfaef22ad73cdcfbda699f8305602d330af59b2dd3a8fe02c40cf403ac10e23f973db9b1787b2928e824e
7
- data.tar.gz: a699bbd6b33883d036fee625782790ea9a43e6687c730a7f62185c47570df021f661e33ea492ab9c72d79584717074b5ebd2bb7c012b27753c127c928ae19983
6
+ metadata.gz: 97034d375899475a0bc2116af339470960cea4bbf9ee7cf996295c7648802f62b8b77a91ae143bcdb8be48bc20216221c2cd65966d972ce8cc025ada343971ce
7
+ data.tar.gz: c112580b36f24515162b2088e48015238e36b68151b6f4b841ea6c4edae5061f5e05a580b408e320ced4f393701ae08034b23caf0b6ef037b9ea973d2ed95ee9
data/CHANGELOG.md CHANGED
@@ -1,4 +1,24 @@
1
- # 0.7.0 / 2019-12-28
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
+
2
22
 
3
23
  ### Fixed
4
24
 
@@ -10,19 +30,18 @@
10
30
 
11
31
  [Compare v0.6.1...v0.7.0](https://github.com/dry-rb/dry-auto_inject/compare/v0.6.1...v0.7.0)
12
32
 
13
- # 0.6.1 / 2019-04-16
33
+ ## 0.6.1 2019-04-16
34
+
14
35
 
15
36
  ### Fixed
16
37
 
17
38
  - Allow explicit injection of falsey values (timriley in [#58](https://github.com/dry-rb/dry-auto_inject/pull/58))
18
39
 
19
- [Compare v0.6.0...v0.6.1](https://github.com/dry-rb/dry-auto_inject/compare/v0.6.0...v0.6.1)
20
40
 
21
- # 0.6.0 / 2018-11-29
41
+ [Compare v0.6.0...v0.6.1](https://github.com/dry-rb/dry-auto_inject/compare/v0.6.0...v0.6.1)
22
42
 
23
- ### Changed
43
+ ## 0.6.0 2018-11-29
24
44
 
25
- - [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
26
45
 
27
46
  ### Added
28
47
 
@@ -32,9 +51,14 @@
32
51
 
33
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))
34
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
+
35
58
  [Compare v0.5.0...v0.6.0](https://github.com/dry-rb/dry-auto_inject/compare/v0.5.0...v0.6.0)
36
59
 
37
- # 0.5.0 / 2018-11-09
60
+ ## 0.5.0 2018-11-09
61
+
38
62
 
39
63
  ### Changed
40
64
 
@@ -72,7 +96,8 @@
72
96
 
73
97
  [Compare v0.4.6...v0.5.0](https://github.com/dry-rb/dry-auto_inject/compare/v0.4.6...v0.5.0)
74
98
 
75
- # 0.4.6 / 2018-03-27
99
+ ## 0.4.6 2018-03-27
100
+
76
101
 
77
102
  ### Changed
78
103
 
@@ -80,37 +105,48 @@
80
105
 
81
106
  [Compare v0.4.5...v0.4.6](https://github.com/dry-rb/dry-auto_inject/compare/v0.4.5...v0.4.6)
82
107
 
83
- # 0.4.5 / 2018-01-02
108
+ ## 0.4.5 2018-01-02
109
+
84
110
 
85
111
  ### Added
86
112
 
87
113
  - Improved handling of kwargs being passed to #initialize’s super method (timriley)
88
114
 
115
+
89
116
  [Compare v0.4.4...v0.4.5](https://github.com/dry-rb/dry-auto_inject/compare/v0.4.4...v0.4.5)
90
117
 
91
- # 0.4.4 / 2017-09-14
118
+ ## 0.4.4 2017-09-14
119
+
92
120
 
93
121
  ### Added
94
122
 
95
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))
96
124
 
97
- # 0.4.3 / 2017-05-27
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
+
98
130
 
99
131
  ### Added
100
132
 
101
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))
102
134
 
135
+
103
136
  [Compare v0.4.2...v0.4.3](https://github.com/dry-rb/dry-auto_inject/compare/v0.4.2...v0.4.3)
104
137
 
105
- # 0.4.2 / 2016-10-10
138
+ ## 0.4.2 2016-10-10
139
+
106
140
 
107
141
  ### Fixed
108
142
 
109
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))
110
144
 
145
+
111
146
  [Compare v0.4.1...v0.4.2](https://github.com/dry-rb/dry-auto_inject/compare/v0.4.1...v0.4.2)
112
147
 
113
- # 0.4.1 / 2016-08-14
148
+ ## 0.4.1 2016-08-14
149
+
114
150
 
115
151
  ### Changed
116
152
 
@@ -118,7 +154,8 @@
118
154
 
119
155
  [Compare v0.4.0...v0.4.1](https://github.com/dry-rb/dry-auto_inject/compare/v0.4.0...v0.4.1)
120
156
 
121
- # 0.4.0 / 2016-07-26
157
+ ## 0.4.0 2016-07-26
158
+
122
159
 
123
160
  ### Added
124
161
 
@@ -139,17 +176,18 @@
139
176
  end
140
177
  ```
141
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))
182
+
142
183
  ### Changed
143
184
 
144
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))
145
186
 
146
- ### Fixed
147
-
148
- - 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))
187
+ [Compare v0.3.0,...v0.4.0](https://github.com/dry-rb/dry-auto_inject/compare/v0.3.0,...v0.4.0)
149
188
 
150
- [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
151
190
 
152
- # 0.3.0, 2016-06-02
153
191
 
154
192
  ### Added
155
193
 
@@ -164,7 +202,6 @@
164
202
  include MyInject.hash["my_dep"]
165
203
  end
166
204
  ```
167
-
168
205
  - Support for user-provided injection strategies
169
206
 
170
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:
@@ -206,7 +243,6 @@
206
243
  include MyInject.custom["my_dep"]
207
244
  end
208
245
  ```
209
-
210
246
  - User-specified aliases for dependencies
211
247
 
212
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:
@@ -229,7 +265,6 @@
229
265
  ```ruby
230
266
  include MyInject["some_dep", another_dep: "some_other.dep"]
231
267
  ```
232
-
233
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.
234
269
 
235
270
  ### Changed
@@ -237,21 +272,25 @@
237
272
  - `kwargs` is the new default injection strategy
238
273
  - Rubinius support is not available for the `kwargs` strategy (see [#18](https://github.com/dry-rb/dry-auto_inject/issues/18))
239
274
 
240
- [Compare v0.2.0...v0.3.0](https://github.com/dry-rb/dry-auto_inject/compare/v0.2.0...v0.3.0)
275
+ [Compare v0.2.0...v0.3.0,](https://github.com/dry-rb/dry-auto_inject/compare/v0.2.0...v0.3.0,)
276
+
277
+ ## 0.2.0 2016-02-09
241
278
 
242
- # v0.2.0 2016-02-09
243
279
 
244
280
  ### Added
245
281
 
246
282
  - Support for hashes as constructor arguments via `Import.hash` interface (solnic)
247
283
 
284
+
248
285
  [Compare v0.1.0...v0.2.0](https://github.com/dry-rb/dry-auto_inject/compare/v0.1.0...v0.2.0)
249
286
 
250
- # v0.1.0 2015-11-12
287
+ ## 0.1.0 2015-11-12
251
288
 
252
289
  Changed interface from `Dry::AutoInject.new { container(some_container) }` to
253
- `Dry::AutoInject(some_container)`.
254
290
 
255
- # v0.0.1 2015-08-20
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
256
295
 
257
296
  First public release \o/
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2015-2019 dry-rb team
3
+ Copyright (c) 2015-2021 dry-rb team
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy of
6
6
  this software and associated documentation files (the "Software"), to deal in
data/README.md CHANGED
@@ -1,58 +1,30 @@
1
+ <!--- this file is synced from dry-rb/template-gem project -->
1
2
  [gem]: https://rubygems.org/gems/dry-auto_inject
2
- [ci]: https://github.com/dry-rb/dry-auto_inject/actions?query=workflow%3Aci
3
- [codeclimate]: https://codeclimate.com/github/dry-rb/dry-auto_inject
4
- [coveralls]: https://coveralls.io/r/dry-rb/dry-auto_inject
5
- [inchpages]: http://inch-ci.org/github/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
6
5
  [chat]: https://dry-rb.zulipchat.com
6
+ [inchpages]: http://inch-ci.org/github/dry-rb/dry-auto_inject
7
7
 
8
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]
9
9
 
10
10
  [![Gem Version](https://badge.fury.io/rb/dry-auto_inject.svg)][gem]
11
- [![Build Status](https://github.com/dry-rb/dry-auto_inject/workflows/ci/badge.svg)][ci]
12
- [![Code Climate](https://codeclimate.com/github/dry-rb/dry-auto_inject/badges/gpa.svg)][codeclimate]
13
- [![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]
14
14
  [![Inline docs](http://inch-ci.org/github/dry-rb/dry-auto_inject.svg?branch=master)][inchpages]
15
- ![No monkey-patches](https://img.shields.io/badge/monkey--patches-0-brightgreen.svg)
16
-
17
- A simple extension which allows you to automatically inject dependencies to your
18
- object constructors from a configured container.
19
-
20
- It does 3 things:
21
-
22
- - Defines a constructor which accepts dependencies
23
- - Defines attribute readers for dependencies
24
- - Injects dependencies automatically to the constructor with overridden `.new`
25
-
26
- ## Installation
27
-
28
- Add this line to your application's Gemfile:
29
-
30
- ```ruby
31
- gem 'dry-auto_inject'
32
- ```
33
-
34
- And then execute:
35
-
36
- ```sh
37
- $ bundle
38
- ```
39
-
40
- Or install it yourself as:
41
-
42
- ```sh
43
- $ gem install dry-auto_inject
44
- ```
45
15
 
46
16
  ## Links
47
17
 
48
- - [Documentation](http://dry-rb.org/gems/dry-auto_inject/)
18
+ * [User documentation](https://dry-rb.org/gems/dry-auto_inject)
19
+ * [API documentation](http://rubydoc.info/gems/dry-auto_inject)
49
20
 
50
- ## Development
21
+ ## Supported Ruby versions
51
22
 
52
- 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.
23
+ This library officially supports the following Ruby versions:
53
24
 
54
- 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).
25
+ * MRI `>= 2.6.0`
26
+ * jruby `>= 9.2`
55
27
 
56
- ## Contributing
28
+ ## License
57
29
 
58
- Bug reports and pull requests are welcome on GitHub at https://github.com/dry-rb/dry-auto_inject.
30
+ See `LICENSE` file.
@@ -1,29 +1,41 @@
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/dry-rb/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.4.0'
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
23
34
 
24
- spec.add_runtime_dependency 'dry-container', '>= 0.3.4'
35
+ # to update dependencies edit project.yml
36
+ spec.add_runtime_dependency "dry-container", ">= 0.3.4"
25
37
 
26
- spec.add_development_dependency 'bundler'
27
- spec.add_development_dependency 'rake'
28
- spec.add_development_dependency 'rspec', '~> 3.8'
38
+ spec.add_development_dependency "bundler"
39
+ spec.add_development_dependency "rake"
40
+ spec.add_development_dependency "rspec"
29
41
  end
@@ -1,3 +1,3 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'dry/auto_inject'
3
+ require "dry/auto_inject"
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'dry/auto_inject/builder'
3
+ require "dry/auto_inject/builder"
4
4
 
5
5
  module Dry
6
6
  # Configure an auto-injection module
@@ -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
@@ -1,10 +1,12 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'set'
2
4
 
3
5
  module Dry
4
6
  module AutoInject
5
7
  # @api private
6
8
  class MethodParameters
7
- PASS_THROUGH = [[:rest]]
9
+ PASS_THROUGH = [[%i[rest]], [%i[rest *], %i[block &]]]
8
10
 
9
11
  if RUBY_VERSION >= '2.4.4.' && !defined? JRUBY_VERSION
10
12
  def self.of(obj, name)
@@ -54,11 +56,13 @@ module Dry
54
56
 
55
57
  def splat?
56
58
  return @splat if defined? @splat
59
+
57
60
  @splat = parameters.any? { |type, _| type == :rest }
58
61
  end
59
62
 
60
63
  def sequential_arguments?
61
64
  return @sequential_arguments if defined? @sequential_arguments
65
+
62
66
  @sequential_arguments = parameters.any? { |type, _|
63
67
  type == :req || type == :opt
64
68
  }
@@ -83,7 +87,7 @@ module Dry
83
87
  end
84
88
 
85
89
  def pass_through?
86
- parameters.eql?(PASS_THROUGH)
90
+ PASS_THROUGH.include?(parameters)
87
91
  end
88
92
 
89
93
  EMPTY = new([])
@@ -48,9 +48,9 @@ module Dry
48
48
 
49
49
  def define_initialize_with_splat(super_parameters)
50
50
  super_pass = if super_parameters.splat?
51
- '*args'
52
- else
53
- "*args.take(#{super_parameters.length})"
51
+ '*args'
52
+ else
53
+ "*args.take(#{super_parameters.length})"
54
54
  end
55
55
 
56
56
  instance_mod.class_eval <<-RUBY, __FILE__, __LINE__ + 1