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 +4 -4
- data/CHANGELOG.md +66 -27
- data/LICENSE +1 -1
- data/README.md +15 -43
- data/dry-auto_inject.gemspec +29 -17
- data/lib/dry-auto_inject.rb +1 -1
- data/lib/dry/auto_inject.rb +1 -1
- data/lib/dry/auto_inject/dependency_map.rb +2 -0
- data/lib/dry/auto_inject/method_parameters.rb +6 -2
- data/lib/dry/auto_inject/strategies/args.rb +3 -3
- data/lib/dry/auto_inject/strategies/constructor.rb +2 -2
- data/lib/dry/auto_inject/strategies/kwargs.rb +11 -10
- data/lib/dry/auto_inject/version.rb +1 -1
- metadata +16 -34
- data/.codeclimate.yml +0 -12
- data/.github/ISSUE_TEMPLATE/----please-don-t-ask-for-support-via-issues.md +0 -10
- data/.github/ISSUE_TEMPLATE/---bug-report.md +0 -30
- data/.github/ISSUE_TEMPLATE/---feature-request.md +0 -18
- data/.github/workflows/ci.yml +0 -76
- data/.github/workflows/docsite.yml +0 -34
- data/.github/workflows/sync_configs.yml +0 -34
- data/.gitignore +0 -10
- data/.rspec +0 -4
- data/.rubocop.yml +0 -95
- data/.rubocop_todo.yml +0 -6
- data/CODE_OF_CONDUCT.md +0 -13
- data/CONTRIBUTING.md +0 -29
- data/Gemfile +0 -17
- data/Rakefile +0 -14
- data/bin/console +0 -11
- data/bin/setup +0 -7
- data/docsite/source/basic-usage.html.md +0 -104
- data/docsite/source/how-does-it-work.html.md +0 -45
- data/docsite/source/index.html.md +0 -53
- data/docsite/source/injection-strategies.html.md +0 -94
- data/rakelib/rubocop.rake +0 -20
@@ -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
|
@@ -14,19 +14,20 @@ module Dry
|
|
14
14
|
class_mod.class_exec(container, dependency_map) do |container, dependency_map|
|
15
15
|
map = dependency_map.to_h
|
16
16
|
|
17
|
-
define_method :new do |*args, **kwargs|
|
17
|
+
define_method :new do |*args, **kwargs, &block|
|
18
18
|
map.each do |name, identifier|
|
19
19
|
kwargs[name] = container[identifier] unless kwargs.key?(name)
|
20
20
|
end
|
21
21
|
|
22
|
-
super(*args, **kwargs)
|
22
|
+
super(*args, **kwargs, &block)
|
23
23
|
end
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
27
|
def define_initialize(klass)
|
28
28
|
super_parameters = MethodParameters.of(klass, :initialize).each do |ps|
|
29
|
-
# Look upwards past `def foo(*)`
|
29
|
+
# Look upwards past `def foo(*)` and `def foo(...)` methods
|
30
|
+
# until we get an explicit list of parameters
|
30
31
|
break ps unless ps.pass_through?
|
31
32
|
end
|
32
33
|
|
@@ -44,15 +45,15 @@ module Dry
|
|
44
45
|
slice_kwargs = method(:slice_kwargs)
|
45
46
|
|
46
47
|
instance_mod.class_exec do
|
47
|
-
define_method :initialize do |**kwargs|
|
48
|
+
define_method :initialize do |**kwargs, &block|
|
48
49
|
assign_dependencies.(kwargs, self)
|
49
50
|
|
50
51
|
super_kwargs = slice_kwargs.(kwargs, super_parameters)
|
51
52
|
|
52
53
|
if super_kwargs.any?
|
53
|
-
super(**super_kwargs)
|
54
|
+
super(**super_kwargs, &block)
|
54
55
|
else
|
55
|
-
super()
|
56
|
+
super(&block)
|
56
57
|
end
|
57
58
|
end
|
58
59
|
end
|
@@ -63,18 +64,18 @@ module Dry
|
|
63
64
|
slice_kwargs = method(:slice_kwargs)
|
64
65
|
|
65
66
|
instance_mod.class_exec do
|
66
|
-
define_method :initialize do |*args, **kwargs|
|
67
|
+
define_method :initialize do |*args, **kwargs, &block|
|
67
68
|
assign_dependencies.(kwargs, self)
|
68
69
|
|
69
70
|
if super_parameters.splat?
|
70
|
-
super(*args, **kwargs)
|
71
|
+
super(*args, **kwargs, &block)
|
71
72
|
else
|
72
73
|
super_kwargs = slice_kwargs.(kwargs, super_parameters)
|
73
74
|
|
74
75
|
if super_kwargs.any?
|
75
|
-
super(*args, **super_kwargs)
|
76
|
+
super(*args, **super_kwargs, &block)
|
76
77
|
else
|
77
|
-
super(*args)
|
78
|
+
super(*args, &block)
|
78
79
|
end
|
79
80
|
end
|
80
81
|
end
|
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
|
@@ -56,47 +56,26 @@ dependencies:
|
|
56
56
|
name: rspec
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - "
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
61
|
+
version: '0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - "
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
69
|
-
description:
|
68
|
+
version: '0'
|
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
|
-
- ".github/ISSUE_TEMPLATE/----please-don-t-ask-for-support-via-issues.md"
|
78
|
-
- ".github/ISSUE_TEMPLATE/---bug-report.md"
|
79
|
-
- ".github/ISSUE_TEMPLATE/---feature-request.md"
|
80
|
-
- ".github/workflows/ci.yml"
|
81
|
-
- ".github/workflows/docsite.yml"
|
82
|
-
- ".github/workflows/sync_configs.yml"
|
83
|
-
- ".gitignore"
|
84
|
-
- ".rspec"
|
85
|
-
- ".rubocop.yml"
|
86
|
-
- ".rubocop_todo.yml"
|
87
76
|
- CHANGELOG.md
|
88
|
-
- CODE_OF_CONDUCT.md
|
89
|
-
- CONTRIBUTING.md
|
90
|
-
- Gemfile
|
91
77
|
- LICENSE
|
92
78
|
- README.md
|
93
|
-
- Rakefile
|
94
|
-
- bin/console
|
95
|
-
- bin/setup
|
96
|
-
- docsite/source/basic-usage.html.md
|
97
|
-
- docsite/source/how-does-it-work.html.md
|
98
|
-
- docsite/source/index.html.md
|
99
|
-
- docsite/source/injection-strategies.html.md
|
100
79
|
- dry-auto_inject.gemspec
|
101
80
|
- lib/dry-auto_inject.rb
|
102
81
|
- lib/dry/auto_inject.rb
|
@@ -110,11 +89,14 @@ files:
|
|
110
89
|
- lib/dry/auto_inject/strategies/hash.rb
|
111
90
|
- lib/dry/auto_inject/strategies/kwargs.rb
|
112
91
|
- lib/dry/auto_inject/version.rb
|
113
|
-
-
|
114
|
-
homepage: https://github.com/dry-rb/dry-auto_inject
|
92
|
+
homepage: https://dry-rb.org/gems/dry-auto_inject
|
115
93
|
licenses:
|
116
94
|
- MIT
|
117
|
-
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
|
118
100
|
post_install_message:
|
119
101
|
rdoc_options: []
|
120
102
|
require_paths:
|
@@ -123,14 +105,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
123
105
|
requirements:
|
124
106
|
- - ">="
|
125
107
|
- !ruby/object:Gem::Version
|
126
|
-
version: 2.
|
108
|
+
version: 2.6.0
|
127
109
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
128
110
|
requirements:
|
129
111
|
- - ">="
|
130
112
|
- !ruby/object:Gem::Version
|
131
113
|
version: '0'
|
132
114
|
requirements: []
|
133
|
-
rubygems_version: 3.1.
|
115
|
+
rubygems_version: 3.1.6
|
134
116
|
signing_key:
|
135
117
|
specification_version: 4
|
136
118
|
summary: Container-agnostic automatic constructor injection
|
data/.codeclimate.yml
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
---
|
2
|
-
name: "\U0001F41B Bug report"
|
3
|
-
about: See CONTRIBUTING.md for more information
|
4
|
-
title: ''
|
5
|
-
labels: bug
|
6
|
-
assignees: ''
|
7
|
-
|
8
|
-
---
|
9
|
-
|
10
|
-
**Before you submit this: WE ONLY ACCEPT BUG REPORTS AND FEATURE REQUESTS**
|
11
|
-
|
12
|
-
For more information see `CONTRIBUTING.md`.
|
13
|
-
|
14
|
-
**Describe the bug**
|
15
|
-
|
16
|
-
A clear and concise description of what the bug is.
|
17
|
-
|
18
|
-
**To Reproduce**
|
19
|
-
|
20
|
-
Provide detailed steps to reproduce, an executable script would be best.
|
21
|
-
|
22
|
-
**Expected behavior**
|
23
|
-
|
24
|
-
A clear and concise description of what you expected to happen.
|
25
|
-
|
26
|
-
**Your environment**
|
27
|
-
|
28
|
-
- Affects my production application: **YES/NO**
|
29
|
-
- Ruby version: ...
|
30
|
-
- OS: ...
|
@@ -1,18 +0,0 @@
|
|
1
|
-
---
|
2
|
-
name: "\U0001F6E0 Feature request"
|
3
|
-
about: See CONTRIBUTING.md for more information
|
4
|
-
title: ''
|
5
|
-
labels: feature
|
6
|
-
assignees: ''
|
7
|
-
|
8
|
-
---
|
9
|
-
|
10
|
-
Summary of what the feature is supposed to do.
|
11
|
-
|
12
|
-
## Examples
|
13
|
-
|
14
|
-
Code examples showing how the feature could be used.
|
15
|
-
|
16
|
-
## Resources
|
17
|
-
|
18
|
-
Additional information, like a link to the discussion forum thread where the feature was discussed etc.
|
data/.github/workflows/ci.yml
DELETED
@@ -1,76 +0,0 @@
|
|
1
|
-
# this file is managed by dry-rb/devtools project
|
2
|
-
|
3
|
-
name: ci
|
4
|
-
|
5
|
-
on:
|
6
|
-
push:
|
7
|
-
paths:
|
8
|
-
- .github/workflows/ci.yml
|
9
|
-
- lib/**
|
10
|
-
- spec/**
|
11
|
-
- Gemfile
|
12
|
-
- "*.gemspec"
|
13
|
-
|
14
|
-
jobs:
|
15
|
-
tests-mri:
|
16
|
-
runs-on: ubuntu-latest
|
17
|
-
strategy:
|
18
|
-
fail-fast: false
|
19
|
-
matrix:
|
20
|
-
ruby: ["2.6.x", "2.5.x", "2.4.x"]
|
21
|
-
include:
|
22
|
-
- ruby: "2.6.x"
|
23
|
-
coverage: "true"
|
24
|
-
steps:
|
25
|
-
- uses: actions/checkout@v1
|
26
|
-
- name: Set up Ruby
|
27
|
-
uses: actions/setup-ruby@v1
|
28
|
-
with:
|
29
|
-
ruby-version: ${{matrix.ruby}}
|
30
|
-
- name: Download test reporter
|
31
|
-
if: "matrix.coverage == 'true'"
|
32
|
-
run: |
|
33
|
-
mkdir -p tmp/
|
34
|
-
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./tmp/cc-test-reporter
|
35
|
-
chmod +x ./tmp/cc-test-reporter
|
36
|
-
./tmp/cc-test-reporter before-build
|
37
|
-
- name: Bundle install
|
38
|
-
run: |
|
39
|
-
gem install bundler
|
40
|
-
bundle install --jobs 4 --retry 3 --without tools docs benchmarks
|
41
|
-
- name: Run all tests
|
42
|
-
env:
|
43
|
-
COVERAGE: ${{matrix.coverage}}
|
44
|
-
run: bundle exec rake
|
45
|
-
- name: Send coverage results
|
46
|
-
if: "matrix.coverage == 'true'"
|
47
|
-
env:
|
48
|
-
CC_TEST_REPORTER_ID: ${{secrets.CC_TEST_REPORTER_ID}}
|
49
|
-
GIT_COMMIT_SHA: ${{github.sha}}
|
50
|
-
GIT_BRANCH: ${{github.ref}}
|
51
|
-
GIT_COMMITTED_AT: ${{github.event.head_commit.timestamp}}
|
52
|
-
run: |
|
53
|
-
GIT_BRANCH=`ruby -e "puts ENV['GITHUB_REF'].split('/', 3).last"` \
|
54
|
-
GIT_COMMITTED_AT=`ruby -r time -e "puts Time.iso8601(ENV['GIT_COMMITTED_AT']).to_i"` \
|
55
|
-
./tmp/cc-test-reporter after-build
|
56
|
-
|
57
|
-
tests-others:
|
58
|
-
runs-on: ubuntu-latest
|
59
|
-
strategy:
|
60
|
-
fail-fast: false
|
61
|
-
matrix:
|
62
|
-
image: ["jruby:9.2.9", "ruby:2.7"]
|
63
|
-
container:
|
64
|
-
image: ${{matrix.image}}
|
65
|
-
steps:
|
66
|
-
- uses: actions/checkout@v1
|
67
|
-
- name: Install git
|
68
|
-
run: |
|
69
|
-
apt-get update
|
70
|
-
apt-get install -y --no-install-recommends git
|
71
|
-
- name: Bundle install
|
72
|
-
run: |
|
73
|
-
gem install bundler
|
74
|
-
bundle install --jobs 4 --retry 3 --without tools docs benchmarks
|
75
|
-
- name: Run all tests
|
76
|
-
run: bundle exec rake
|
@@ -1,34 +0,0 @@
|
|
1
|
-
# this file is managed by dry-rb/devtools project
|
2
|
-
|
3
|
-
name: docsite
|
4
|
-
|
5
|
-
on:
|
6
|
-
push:
|
7
|
-
paths:
|
8
|
-
- docsite/**
|
9
|
-
- .github/workflows/docsite.yml
|
10
|
-
branches:
|
11
|
-
- master
|
12
|
-
- release-**
|
13
|
-
tags:
|
14
|
-
|
15
|
-
jobs:
|
16
|
-
update-docs:
|
17
|
-
runs-on: ubuntu-latest
|
18
|
-
steps:
|
19
|
-
- uses: actions/checkout@v1
|
20
|
-
- name: Set up Ruby
|
21
|
-
uses: actions/setup-ruby@v1
|
22
|
-
with:
|
23
|
-
ruby-version: "2.6.x"
|
24
|
-
- name: Install dependencies
|
25
|
-
run: |
|
26
|
-
gem install bundler
|
27
|
-
bundle install --jobs 4 --retry 3 --without benchmarks sql
|
28
|
-
- name: Symlink ossy
|
29
|
-
run: mkdir -p bin && ln -sf "$(bundle show ossy)/bin/ossy" bin/ossy
|
30
|
-
- name: Trigger dry-rb.org deploy
|
31
|
-
env:
|
32
|
-
GITHUB_LOGIN: dry-bot
|
33
|
-
GITHUB_TOKEN: ${{ secrets.GH_PAT }}
|
34
|
-
run: bin/ossy github workflow dry-rb/dry-rb.org ci
|
@@ -1,34 +0,0 @@
|
|
1
|
-
# this file is managed by dry-rb/devtools project
|
2
|
-
|
3
|
-
name: sync_configs
|
4
|
-
|
5
|
-
on:
|
6
|
-
repository_dispatch:
|
7
|
-
|
8
|
-
jobs:
|
9
|
-
sync-configs:
|
10
|
-
runs-on: ubuntu-latest
|
11
|
-
if: github.event.action == 'sync_configs'
|
12
|
-
steps:
|
13
|
-
- uses: actions/checkout@v1
|
14
|
-
- name: Update configuration files from devtools
|
15
|
-
env:
|
16
|
-
GITHUB_LOGIN: dry-bot
|
17
|
-
GITHUB_TOKEN: ${{ secrets.GH_PAT }}
|
18
|
-
run: |
|
19
|
-
git clone https://github.com/dry-rb/devtools.git tmp/devtools
|
20
|
-
|
21
|
-
if [ -f ".github/workflows/custom_ci.yml" ]; then
|
22
|
-
rsync -av --exclude '.github/workflows/ci.yml' tmp/devtools/shared/ . ;
|
23
|
-
else
|
24
|
-
rsync -av tmp/devtools/shared/ . ;
|
25
|
-
fi
|
26
|
-
|
27
|
-
git config --local user.email "dry-bot@dry-rb.org"
|
28
|
-
git config --local user.name "dry-bot"
|
29
|
-
git add -A
|
30
|
-
git commit -m "[devtools] config sync" || echo "nothing changed"
|
31
|
-
- name: Push changes
|
32
|
-
uses: ad-m/github-push-action@master
|
33
|
-
with:
|
34
|
-
github_token: ${{ secrets.GH_PAT }}
|
data/.gitignore
DELETED
data/.rspec
DELETED
data/.rubocop.yml
DELETED
@@ -1,95 +0,0 @@
|
|
1
|
-
# this file is managed by dry-rb/devtools project
|
2
|
-
|
3
|
-
AllCops:
|
4
|
-
TargetRubyVersion: 2.4
|
5
|
-
|
6
|
-
Style/EachWithObject:
|
7
|
-
Enabled: false
|
8
|
-
|
9
|
-
Style/StringLiterals:
|
10
|
-
Enabled: true
|
11
|
-
EnforcedStyle: single_quotes
|
12
|
-
|
13
|
-
Style/Alias:
|
14
|
-
Enabled: false
|
15
|
-
|
16
|
-
Style/LambdaCall:
|
17
|
-
Enabled: false
|
18
|
-
|
19
|
-
Style/StabbyLambdaParentheses:
|
20
|
-
Enabled: false
|
21
|
-
|
22
|
-
Style/FormatString:
|
23
|
-
Enabled: false
|
24
|
-
|
25
|
-
Style/Documentation:
|
26
|
-
Enabled: false
|
27
|
-
|
28
|
-
Layout/SpaceInLambdaLiteral:
|
29
|
-
Enabled: false
|
30
|
-
|
31
|
-
Layout/MultilineMethodCallIndentation:
|
32
|
-
Enabled: true
|
33
|
-
EnforcedStyle: indented
|
34
|
-
|
35
|
-
Metrics/LineLength:
|
36
|
-
Max: 100
|
37
|
-
|
38
|
-
Metrics/MethodLength:
|
39
|
-
Max: 22
|
40
|
-
|
41
|
-
Metrics/ClassLength:
|
42
|
-
Max: 150
|
43
|
-
|
44
|
-
Metrics/AbcSize:
|
45
|
-
Max: 20
|
46
|
-
|
47
|
-
Metrics/BlockLength:
|
48
|
-
Enabled: false
|
49
|
-
|
50
|
-
Metrics/CyclomaticComplexity:
|
51
|
-
Enabled: true
|
52
|
-
Max: 10
|
53
|
-
|
54
|
-
Lint/BooleanSymbol:
|
55
|
-
Enabled: false
|
56
|
-
|
57
|
-
Style/AccessModifierDeclarations:
|
58
|
-
Enabled: false
|
59
|
-
|
60
|
-
Style/BlockDelimiters:
|
61
|
-
Enabled: false
|
62
|
-
|
63
|
-
Layout/IndentFirstArrayElement:
|
64
|
-
EnforcedStyle: consistent
|
65
|
-
|
66
|
-
Style/ClassAndModuleChildren:
|
67
|
-
Exclude:
|
68
|
-
- "spec/**/*_spec.rb"
|
69
|
-
|
70
|
-
Lint/HandleExceptions:
|
71
|
-
Exclude:
|
72
|
-
- "spec/spec_helper.rb"
|
73
|
-
|
74
|
-
Naming/FileName:
|
75
|
-
Exclude:
|
76
|
-
- "lib/dry-*.rb"
|
77
|
-
|
78
|
-
Style/SymbolArray:
|
79
|
-
Exclude:
|
80
|
-
- "spec/**/*_spec.rb"
|
81
|
-
|
82
|
-
Style/ConditionalAssignment:
|
83
|
-
Enabled: false
|
84
|
-
|
85
|
-
Naming/MethodName:
|
86
|
-
Enabled: false
|
87
|
-
|
88
|
-
Style/AsciiComments:
|
89
|
-
Enabled: false
|
90
|
-
|
91
|
-
Style/DateTime:
|
92
|
-
Enabled: false
|
93
|
-
|
94
|
-
Style/IfUnlessModifier:
|
95
|
-
Enabled: false
|