dry-auto_inject 1.0.0 → 1.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: d360da0539f06319e2e74cd1d24dc8b5cf946a0390f0257e41e4d8f6dbf91540
4
- data.tar.gz: 5d095923d9dfd059a58b91af09c7afe7047ed69b7c8f3dee3f6055073da7d0ed
3
+ metadata.gz: 0fe35e3cc69af3c8553b31c5687b46e86a26a51371390ee7f23e31eff74292c1
4
+ data.tar.gz: 61eaf8236d91026dd0b510ce5e5ca8f5cb68e5b9bd54781d5fcbb981cbd0d663
5
5
  SHA512:
6
- metadata.gz: eeacadf98f186011fd02faa49b353a290158cbb815b1b4bf6b9f41154fa0041dc08c4c4cf6e903ef8ca2b8c99467aecc02c2b3f3fcb3cdb4b9683ad90d72808f
7
- data.tar.gz: d3370290dc82a3dcf1ff95489c0ab91f6813847e55158f1729a664a4644c3fb81643e9e89527f5c9265f090733f6f5ae044b1d3662b020c4b51363cc1caac762
6
+ metadata.gz: 6e63f1dd733ffd29956d7a0d5d8e38137066ab6f84a625c68bb1d1953931863cac3bf775450ecc3b70e727b8cd5f896ef7569fc3414c711e85b6fb25a5936e11
7
+ data.tar.gz: 32539bb893f836435848a10a0a12646a7dadf8d0ceaf7c3269d7b2c1d5302f96f82032a192622134a6db487ae3bb5d981077dd515a64050bfb801ca4592bb1c9
data/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
1
1
  <!--- DO NOT EDIT THIS FILE - IT'S AUTOMATICALLY GENERATED VIA DEVTOOLS --->
2
2
 
3
+ ## 1.1.0 2025-01-07
4
+
5
+
6
+ ### Fixed
7
+
8
+ - Update minimal ruby version to 3.1 (@flash-gordon)
9
+
10
+
11
+ [Compare v1.0.1...v1.1.0](https://github.com/dry-rb/dry-auto_inject/compare/v1.0.1...v1.1.0)
12
+
13
+ ## 1.0.1 2023-02-13
14
+
15
+
16
+ ### Fixed
17
+
18
+ - Update passthrough parameters list to support ruby 3.2.1 (@hieuk09 in [#88](https://github.com/dry-rb/dry-auto_inject/pull/88))
19
+
20
+
21
+ [Compare v1.0.0...v1.0.1](https://github.com/dry-rb/dry-auto_inject/compare/v1.0.0...v1.0.1)
22
+
3
23
  ## 1.0.0 2022-11-18
4
24
 
5
25
 
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2015-2022 dry-rb team
3
+ Copyright (c) 2015-2023 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,29 +1,22 @@
1
1
  <!--- this file is synced from dry-rb/template-gem project -->
2
+
2
3
  [gem]: https://rubygems.org/gems/dry-auto_inject
3
4
  [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
6
- [inchpages]: http://inch-ci.org/github/dry-rb/dry-auto_inject
7
-
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
5
 
10
- [![Gem Version](https://badge.fury.io/rb/dry-auto_inject.svg)][gem]
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
- [![Inline docs](http://inch-ci.org/github/dry-rb/dry-auto_inject.svg?branch=main)][inchpages]
6
+ # dry-auto_inject [![Gem Version](https://badge.fury.io/rb/dry-auto_inject.svg)][gem] [![CI Status](https://github.com/dry-rb/dry-auto_inject/workflows/CI/badge.svg)][actions]
15
7
 
16
8
  ## Links
17
9
 
18
10
  * [User documentation](https://dry-rb.org/gems/dry-auto_inject)
19
11
  * [API documentation](http://rubydoc.info/gems/dry-auto_inject)
12
+ * [Forum](https://discourse.dry-rb.org)
20
13
 
21
14
  ## Supported Ruby versions
22
15
 
23
16
  This library officially supports the following Ruby versions:
24
17
 
25
- * MRI `>= 2.7.0`
26
- * jruby `>= 9.3` (postponed until 2.7 is supported)
18
+ * MRI `>= 3.1`
19
+ * jruby `>= 9.4` (not tested on CI)
27
20
 
28
21
  ## License
29
22
 
@@ -16,23 +16,21 @@ Gem::Specification.new do |spec|
16
16
  spec.summary = "Container-agnostic automatic constructor injection"
17
17
  spec.description = spec.summary
18
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/**/*"]
19
+ spec.files = Dir["CHANGELOG.md", "LICENSE", "README.md", "dry-auto_inject.gemspec",
20
+ "lib/**/*"]
20
21
  spec.bindir = "bin"
21
22
  spec.executables = []
22
23
  spec.require_paths = ["lib"]
23
24
 
24
- spec.metadata["allowed_push_host"] = "https://rubygems.org"
25
- spec.metadata["changelog_uri"] = "https://github.com/dry-rb/dry-auto_inject/blob/main/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"
25
+ spec.metadata["allowed_push_host"] = "https://rubygems.org"
26
+ spec.metadata["changelog_uri"] = "https://github.com/dry-rb/dry-auto_inject/blob/main/CHANGELOG.md"
27
+ spec.metadata["source_code_uri"] = "https://github.com/dry-rb/dry-auto_inject"
28
+ spec.metadata["bug_tracker_uri"] = "https://github.com/dry-rb/dry-auto_inject/issues"
29
+ spec.metadata["rubygems_mfa_required"] = "true"
28
30
 
29
- spec.required_ruby_version = ">= 2.7.0"
31
+ spec.required_ruby_version = ">= 3.1"
30
32
 
31
33
  # to update dependencies edit project.yml
32
- spec.add_runtime_dependency "dry-core", "~> 1.0", "< 2"
33
- spec.add_runtime_dependency "zeitwerk", "~> 2.6"
34
-
35
- spec.add_development_dependency "bundler"
36
- spec.add_development_dependency "rake"
37
- spec.add_development_dependency "rspec"
34
+ spec.add_dependency "dry-core", "~> 1.1"
35
+ spec.add_dependency "zeitwerk", "~> 2.6"
38
36
  end
@@ -18,17 +18,13 @@ module Dry
18
18
  end
19
19
 
20
20
  # @api public
21
- def [](*dependency_names)
22
- default[*dependency_names]
23
- end
21
+ def [](*dependency_names) = default[*dependency_names]
24
22
 
25
- def respond_to_missing?(name, _include_private = false)
26
- strategies.key?(name)
27
- end
23
+ def respond_to_missing?(name, _ = false) = strategies.key?(name)
28
24
 
29
25
  private
30
26
 
31
- def method_missing(name, *args, &block)
27
+ def method_missing(name, ...)
32
28
  if strategies.key?(name)
33
29
  Injector.new(container, strategies[name], builder: self)
34
30
  else
@@ -2,17 +2,17 @@
2
2
 
3
3
  module Dry
4
4
  module AutoInject
5
- DuplicateDependencyError = Class.new(StandardError)
6
- DependencyNameInvalid = Class.new(StandardError)
5
+ DuplicateDependencyError = ::Class.new(::StandardError)
6
+ DependencyNameInvalid = ::Class.new(::StandardError)
7
7
 
8
- VALID_NAME = /([a-z_][a-zA-Z_0-9]*)$/.freeze
8
+ VALID_NAME = /([a-z_][a-zA-Z_0-9]*)$/
9
9
 
10
10
  class DependencyMap
11
11
  def initialize(*dependencies)
12
12
  @map = {}
13
13
 
14
14
  dependencies = dependencies.dup
15
- aliases = dependencies.last.is_a?(Hash) ? dependencies.pop : {}
15
+ aliases = dependencies.last.is_a?(::Hash) ? dependencies.pop : {}
16
16
 
17
17
  dependencies.each do |identifier|
18
18
  name = name_for(identifier)
@@ -24,17 +24,13 @@ module Dry
24
24
  end
25
25
  end
26
26
 
27
- def inspect
28
- @map.inspect
29
- end
27
+ def inspect = @map.inspect
30
28
 
31
29
  def names
32
30
  @names ||= @map.keys
33
31
  end
34
32
 
35
- def to_h
36
- @map.dup
37
- end
33
+ def to_h = @map.dup
38
34
  alias_method :to_hash, :to_h
39
35
 
40
36
  private
@@ -4,7 +4,7 @@ require "dry/auto_inject/strategies"
4
4
 
5
5
  module Dry
6
6
  module AutoInject
7
- class Injector < BasicObject
7
+ class Injector < ::BasicObject
8
8
  # @api private
9
9
  attr_reader :container
10
10
 
@@ -23,19 +23,13 @@ module Dry
23
23
  @builder = builder
24
24
  end
25
25
 
26
- def [](*dependency_names)
27
- strategy.new(container, *dependency_names)
28
- end
26
+ def [](*dependency_names) = strategy.new(container, *dependency_names)
29
27
 
30
- def respond_to_missing?(name, _include_private = false)
31
- builder.respond_to?(name)
32
- end
28
+ def respond_to_missing?(name, _ = false) = builder.respond_to?(name)
33
29
 
34
30
  private
35
31
 
36
- def method_missing(name, *_args)
37
- builder.__send__(name)
38
- end
32
+ def method_missing(name, ...) = builder.__send__(name)
39
33
  end
40
34
  end
41
35
  end
@@ -6,10 +6,15 @@ module Dry
6
6
  module AutoInject
7
7
  # @api private
8
8
  class MethodParameters
9
- PASS_THROUGH = [[%i[rest]], [%i[rest], %i[keyrest]]].freeze
9
+ PASS_THROUGH = [
10
+ [%i[rest]],
11
+ [%i[rest], %i[keyrest]],
12
+ [%i[rest *]],
13
+ [%i[rest *], %i[keyrest **]]
14
+ ].freeze
10
15
 
11
16
  def self.of(obj, name)
12
- Enumerator.new do |y|
17
+ ::Enumerator.new do |y|
13
18
  begin
14
19
  method = obj.instance_method(name)
15
20
  rescue ::NameError # rubocop: disable Lint/SuppressedException
@@ -39,32 +44,24 @@ module Dry
39
44
  def sequential_arguments?
40
45
  return @sequential_arguments if defined? @sequential_arguments
41
46
 
42
- @sequential_arguments = parameters.any? { |type, _|
47
+ @sequential_arguments = parameters.any? do |type, _|
43
48
  type == :req || type == :opt
44
- }
49
+ end
45
50
  end
46
51
 
47
52
  def keyword_names
48
- @keyword_names ||= parameters.each_with_object(Set.new) { |(type, name), names|
53
+ @keyword_names ||= parameters.each_with_object(::Set.new) do |(type, name), names|
49
54
  names << name if type == :key || type == :keyreq
50
- }
55
+ end
51
56
  end
52
57
 
53
- def keyword?(name)
54
- keyword_names.include?(name)
55
- end
58
+ def keyword?(name) = keyword_names.include?(name)
56
59
 
57
- def empty?
58
- parameters.empty?
59
- end
60
+ def empty? = parameters.empty?
60
61
 
61
- def length
62
- parameters.length
63
- end
62
+ def length = parameters.length
64
63
 
65
- def pass_through?
66
- PASS_THROUGH.include?(parameters)
67
- end
64
+ def pass_through? = PASS_THROUGH.include?(parameters)
68
65
 
69
66
  EMPTY = new([])
70
67
  end
@@ -9,12 +9,14 @@ module Dry
9
9
 
10
10
  def define_new
11
11
  class_mod.class_exec(container, dependency_map) do |container, dependency_map|
12
+ deps_with_indices = dependency_map.to_h.values.map.with_index
13
+
12
14
  define_method :new do |*args|
13
- deps = dependency_map.to_h.values.map.with_index { |identifier, i|
15
+ deps = deps_with_indices.map do |identifier, i|
14
16
  args[i] || container[identifier]
15
- }
17
+ end
16
18
 
17
- super(*deps, *args[deps.size..])
19
+ super(*deps, *args.drop(deps.size))
18
20
  end
19
21
  end
20
22
  end
@@ -46,11 +48,12 @@ module Dry
46
48
  end
47
49
 
48
50
  def define_initialize_with_splat(super_parameters)
49
- super_pass = if super_parameters.splat?
50
- "*args"
51
- else
52
- "*args.take(#{super_parameters.length})"
53
- end
51
+ super_pass =
52
+ if super_parameters.splat?
53
+ "*args"
54
+ else
55
+ "*args.take(#{super_parameters.length})"
56
+ end
54
57
 
55
58
  assignments = dependency_map.names.map.with_index do |name, idx|
56
59
  "@#{name} = args[#{idx}]"
@@ -9,12 +9,14 @@ module Dry
9
9
 
10
10
  def define_new
11
11
  class_mod.class_exec(container, dependency_map) do |container, dependency_map|
12
+ deps_map = dependency_map.to_h
13
+
12
14
  define_method :new do |options = {}|
13
- deps = dependency_map.to_h.each_with_object({}) { |(name, identifier), obj|
14
- obj[name] = options[name] || container[identifier]
15
- }.merge(options)
15
+ deps = deps_map.transform_values do |identifier|
16
+ options[identifier] || container[identifier]
17
+ end
16
18
 
17
- super(deps)
19
+ super({**deps, **options})
18
20
  end
19
21
  end
20
22
  end
@@ -24,7 +26,7 @@ module Dry
24
26
  super_pass = super_params.empty? ? "" : "options"
25
27
  assignments = dependency_map.names.map do |name|
26
28
  <<~RUBY
27
- unless !options.key?(:#{name}) && instance_variable_defined?(:'@#{name}')
29
+ if options.key?(:#{name}) || !instance_variable_defined?(:'@#{name}')
28
30
  @#{name} = options[:#{name}]
29
31
  end
30
32
  RUBY
@@ -33,7 +35,7 @@ module Dry
33
35
 
34
36
  instance_mod.class_eval <<-RUBY, __FILE__, __LINE__ + 1
35
37
  def initialize(options) # def initialize(options)
36
- # unless !options.key?(:dep) && instance_variable_defined?(:@dep)
38
+ # if options.key?(:dep) || !instance_variable_defined?(:@dep)
37
39
  #{body} # @dep = options[:dep]
38
40
  # end
39
41
  super(#{super_pass}) # super(options)
@@ -11,9 +11,9 @@ module Dry
11
11
  register :default, strategy
12
12
  end
13
13
 
14
- register :args, proc { Args }
14
+ register :args, proc { Strategies::Args }
15
15
  register :hash, proc { Strategies::Hash }
16
- register_default :kwargs, proc { Kwargs }
16
+ register_default :kwargs, proc { Strategies::Kwargs }
17
17
  end
18
18
  end
19
19
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Dry
4
4
  module AutoInject
5
- VERSION = "1.0.0"
5
+ VERSION = "1.1.0"
6
6
  end
7
7
  end
@@ -6,10 +6,10 @@ require "dry/core"
6
6
  module Dry
7
7
  module AutoInject
8
8
  def self.loader
9
- @loader ||= Zeitwerk::Loader.new.tap do |loader|
10
- root = File.expand_path("..", __dir__)
9
+ @loader ||= ::Zeitwerk::Loader.new.tap do |loader|
10
+ root = ::File.expand_path("..", __dir__)
11
11
  loader.tag = "dry-auto_inject"
12
- loader.inflector = Zeitwerk::GemInflector.new("#{root}/dry-auto_inject.rb")
12
+ loader.inflector = ::Zeitwerk::GemInflector.new("#{root}/dry-auto_inject.rb")
13
13
  loader.push_dir(root)
14
14
  loader.ignore(
15
15
  "#{root}/dry-auto_inject.rb",
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: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Piotr Solnica
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-11-18 00:00:00.000000000 Z
11
+ date: 2025-01-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dry-core
@@ -16,20 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.0'
20
- - - "<"
21
- - !ruby/object:Gem::Version
22
- version: '2'
19
+ version: '1.1'
23
20
  type: :runtime
24
21
  prerelease: false
25
22
  version_requirements: !ruby/object:Gem::Requirement
26
23
  requirements:
27
24
  - - "~>"
28
25
  - !ruby/object:Gem::Version
29
- version: '1.0'
30
- - - "<"
31
- - !ruby/object:Gem::Version
32
- version: '2'
26
+ version: '1.1'
33
27
  - !ruby/object:Gem::Dependency
34
28
  name: zeitwerk
35
29
  requirement: !ruby/object:Gem::Requirement
@@ -44,48 +38,6 @@ dependencies:
44
38
  - - "~>"
45
39
  - !ruby/object:Gem::Version
46
40
  version: '2.6'
47
- - !ruby/object:Gem::Dependency
48
- name: bundler
49
- requirement: !ruby/object:Gem::Requirement
50
- requirements:
51
- - - ">="
52
- - !ruby/object:Gem::Version
53
- version: '0'
54
- type: :development
55
- prerelease: false
56
- version_requirements: !ruby/object:Gem::Requirement
57
- requirements:
58
- - - ">="
59
- - !ruby/object:Gem::Version
60
- version: '0'
61
- - !ruby/object:Gem::Dependency
62
- name: rake
63
- requirement: !ruby/object:Gem::Requirement
64
- requirements:
65
- - - ">="
66
- - !ruby/object:Gem::Version
67
- version: '0'
68
- type: :development
69
- prerelease: false
70
- version_requirements: !ruby/object:Gem::Requirement
71
- requirements:
72
- - - ">="
73
- - !ruby/object:Gem::Version
74
- version: '0'
75
- - !ruby/object:Gem::Dependency
76
- name: rspec
77
- requirement: !ruby/object:Gem::Requirement
78
- requirements:
79
- - - ">="
80
- - !ruby/object:Gem::Version
81
- version: '0'
82
- type: :development
83
- prerelease: false
84
- version_requirements: !ruby/object:Gem::Requirement
85
- requirements:
86
- - - ">="
87
- - !ruby/object:Gem::Version
88
- version: '0'
89
41
  description: Container-agnostic automatic constructor injection
90
42
  email:
91
43
  - piotr.solnica@gmail.com
@@ -117,7 +69,8 @@ metadata:
117
69
  changelog_uri: https://github.com/dry-rb/dry-auto_inject/blob/main/CHANGELOG.md
118
70
  source_code_uri: https://github.com/dry-rb/dry-auto_inject
119
71
  bug_tracker_uri: https://github.com/dry-rb/dry-auto_inject/issues
120
- post_install_message:
72
+ rubygems_mfa_required: 'true'
73
+ post_install_message:
121
74
  rdoc_options: []
122
75
  require_paths:
123
76
  - lib
@@ -125,15 +78,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
125
78
  requirements:
126
79
  - - ">="
127
80
  - !ruby/object:Gem::Version
128
- version: 2.7.0
81
+ version: '3.1'
129
82
  required_rubygems_version: !ruby/object:Gem::Requirement
130
83
  requirements:
131
84
  - - ">="
132
85
  - !ruby/object:Gem::Version
133
86
  version: '0'
134
87
  requirements: []
135
- rubygems_version: 3.1.6
136
- signing_key:
88
+ rubygems_version: 3.3.27
89
+ signing_key:
137
90
  specification_version: 4
138
91
  summary: Container-agnostic automatic constructor injection
139
92
  test_files: []