dry-auto_inject 0.4.5 → 0.4.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.codeclimate.yml +6 -0
- data/.travis.yml +4 -10
- data/CHANGELOG.md +8 -0
- data/Gemfile +2 -0
- data/README.md +9 -10
- data/Rakefile +2 -0
- data/bin/console +1 -0
- data/dry-auto_inject.gemspec +2 -0
- data/lib/dry-auto_inject.rb +2 -0
- data/lib/dry/auto_inject.rb +2 -0
- data/lib/dry/auto_inject/builder.rb +2 -0
- data/lib/dry/auto_inject/dependency_map.rb +3 -1
- data/lib/dry/auto_inject/injector.rb +2 -0
- data/lib/dry/auto_inject/strategies.rb +2 -0
- data/lib/dry/auto_inject/strategies/args.rb +4 -2
- data/lib/dry/auto_inject/strategies/constructor.rb +2 -0
- data/lib/dry/auto_inject/strategies/hash.rb +3 -1
- data/lib/dry/auto_inject/strategies/kwargs.rb +7 -5
- data/lib/dry/auto_inject/version.rb +3 -1
- data/rakelib/rubocop.rake +2 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 7390d5a0b2fd3f12fc33f412a506e355bcb315e6dc90199740b5e3af34d6918b
|
4
|
+
data.tar.gz: e3864b6de7ba096650403e7cec2adb3baa8cc036c933ba9e89f4c27f443fcac4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2f58d872c1a323b9a9a08d2e4615bb3c8d3adb2153ddab83ee14b18b401c5e78018ce9b67accbbd2005759c8456656619e78fd1145535246b99da46b9c101075
|
7
|
+
data.tar.gz: 91b4b889a5c4cdfc7e7876bed582205f7ffaea8fc970f9d7b098f95b9727d326632b474e820698752b8b9a67b8a2374e15cc076ad04e1570c9fe751bfab1a388
|
data/.codeclimate.yml
ADDED
data/.travis.yml
CHANGED
@@ -1,6 +1,4 @@
|
|
1
1
|
language: ruby
|
2
|
-
dist: trusty
|
3
|
-
sudo: required
|
4
2
|
cache: bundler
|
5
3
|
bundler_args: --without tools
|
6
4
|
script:
|
@@ -8,17 +6,13 @@ script:
|
|
8
6
|
after_success:
|
9
7
|
- '[ -d coverage ] && bundle exec codeclimate-test-reporter'
|
10
8
|
rvm:
|
11
|
-
- 2.
|
12
|
-
- 2.
|
13
|
-
- 2.3.
|
14
|
-
- 2.4.1
|
9
|
+
- 2.5.0
|
10
|
+
- 2.4.3
|
11
|
+
- 2.3.6
|
15
12
|
- jruby-9.1.10.0
|
16
13
|
env:
|
17
14
|
global:
|
18
|
-
-
|
19
|
-
addons:
|
20
|
-
code_climate:
|
21
|
-
repo_token: 029b5aa100b82b6710e285597b7eabe760357b5dd1f626514371356055378d8c
|
15
|
+
- COVERAGE=true
|
22
16
|
notifications:
|
23
17
|
email: false
|
24
18
|
webhooks:
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
# 0.4.6 / 2018-03-27
|
2
|
+
|
3
|
+
### Changed
|
4
|
+
|
5
|
+
- In injector-generated `#initialize` methods, set dependency instance variables before calling `super` (timriley)
|
6
|
+
|
7
|
+
[Compare v0.4.5...v0.4.6](https://github.com/dry-rb/dry-auto_inject/compare/v0.4.5...v0.4.6)
|
8
|
+
|
1
9
|
# 0.4.5 / 2018-01-02
|
2
10
|
|
3
11
|
### Added
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,17 +1,16 @@
|
|
1
|
-
[gitter]: https://gitter.im/dry-rb/chat
|
2
1
|
[gem]: https://rubygems.org/gems/dry-auto_inject
|
3
2
|
[travis]: https://travis-ci.org/dry-rb/dry-auto_inject
|
4
|
-
[
|
5
|
-
[
|
6
|
-
[
|
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
|
7
6
|
|
8
|
-
# dry-auto_inject [![Join the
|
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)
|
9
8
|
|
10
|
-
[![Gem Version](https://
|
11
|
-
[![Build Status](https://
|
12
|
-
[![
|
13
|
-
[![
|
14
|
-
[![
|
9
|
+
[![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]
|
13
|
+
[![Inline docs](http://inch-ci.org/github/dry-rb/dry-auto_inject.svg?branch=master)][inchpages]
|
15
14
|
![No monkey-patches](https://img.shields.io/badge/monkey--patches-0-brightgreen.svg)
|
16
15
|
|
17
16
|
A simple extension which allows you to automatically inject dependencies to your
|
data/Rakefile
CHANGED
data/bin/console
CHANGED
data/dry-auto_inject.gemspec
CHANGED
data/lib/dry-auto_inject.rb
CHANGED
data/lib/dry/auto_inject.rb
CHANGED
@@ -1,9 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Dry
|
2
4
|
module AutoInject
|
3
5
|
DuplicateDependencyError = Class.new(StandardError)
|
4
6
|
DependencyNameInvalid = Class.new(StandardError)
|
5
7
|
|
6
|
-
VALID_NAME = /([a-z_][a-zA-Z_0-9]*)
|
8
|
+
VALID_NAME = /([a-z_][a-zA-Z_0-9]*)$/
|
7
9
|
|
8
10
|
class DependencyMap
|
9
11
|
def initialize(*dependencies)
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'dry/auto_inject/strategies/constructor'
|
2
4
|
|
3
5
|
module Dry
|
@@ -34,8 +36,8 @@ module Dry
|
|
34
36
|
|
35
37
|
instance_mod.class_eval <<-RUBY, __FILE__, __LINE__ + 1
|
36
38
|
def initialize(#{initialize_args})
|
37
|
-
super()
|
38
39
|
#{dependency_map.names.map { |name| "@#{name} = #{name}" }.join("\n")}
|
40
|
+
super()
|
39
41
|
end
|
40
42
|
RUBY
|
41
43
|
end
|
@@ -49,8 +51,8 @@ module Dry
|
|
49
51
|
|
50
52
|
instance_mod.class_eval <<-RUBY, __FILE__, __LINE__ + 1
|
51
53
|
def initialize(*args)
|
52
|
-
super(#{super_params})
|
53
54
|
#{dependency_map.names.map.with_index { |name, i| "@#{name} = args[#{i}]" }.join("\n")}
|
55
|
+
super(#{super_params})
|
54
56
|
end
|
55
57
|
RUBY
|
56
58
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'dry/auto_inject/strategies/constructor'
|
2
4
|
|
3
5
|
module Dry
|
@@ -25,8 +27,8 @@ module Dry
|
|
25
27
|
|
26
28
|
instance_mod.class_eval <<-RUBY, __FILE__, __LINE__ + 1
|
27
29
|
def initialize(options)
|
28
|
-
super(#{super_params})
|
29
30
|
#{dependency_map.names.map { |name| "@#{name} = options[:#{name}]" }.join("\n")}
|
31
|
+
super(#{super_params})
|
30
32
|
end
|
31
33
|
RUBY
|
32
34
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'dry/auto_inject/strategies/constructor'
|
2
4
|
|
3
5
|
module Dry
|
@@ -38,8 +40,8 @@ module Dry
|
|
38
40
|
|
39
41
|
instance_mod.class_eval <<-RUBY, __FILE__, __LINE__ + 1
|
40
42
|
def initialize(#{initialize_params})
|
41
|
-
super()
|
42
43
|
#{dependency_map.names.map { |name| "@#{name} = #{name}" }.join("\n")}
|
44
|
+
super()
|
43
45
|
end
|
44
46
|
RUBY
|
45
47
|
|
@@ -53,6 +55,10 @@ module Dry
|
|
53
55
|
|
54
56
|
instance_mod.class_exec(dependency_map) do |dependency_map|
|
55
57
|
define_method :initialize do |*args, **kwargs|
|
58
|
+
dependency_map.names.each do |name|
|
59
|
+
instance_variable_set :"@#{name}", kwargs[name]
|
60
|
+
end
|
61
|
+
|
56
62
|
super_kwargs = kwargs.each_with_object({}) { |(key, _), hsh|
|
57
63
|
if !dependency_map.names.include?(key) || super_kwarg_names.include?(key)
|
58
64
|
hsh[key] = kwargs[key]
|
@@ -64,10 +70,6 @@ module Dry
|
|
64
70
|
else
|
65
71
|
super(*args)
|
66
72
|
end
|
67
|
-
|
68
|
-
dependency_map.names.each do |name|
|
69
|
-
instance_variable_set :"@#{name}", kwargs[name]
|
70
|
-
end
|
71
73
|
end
|
72
74
|
end
|
73
75
|
|
data/rakelib/rubocop.rake
CHANGED
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.
|
4
|
+
version: 0.4.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Piotr Solnica
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-03-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dry-container
|
@@ -73,6 +73,7 @@ executables: []
|
|
73
73
|
extensions: []
|
74
74
|
extra_rdoc_files: []
|
75
75
|
files:
|
76
|
+
- ".codeclimate.yml"
|
76
77
|
- ".gitignore"
|
77
78
|
- ".rspec"
|
78
79
|
- ".rubocop.yml"
|
@@ -119,7 +120,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
119
120
|
version: '0'
|
120
121
|
requirements: []
|
121
122
|
rubyforge_project:
|
122
|
-
rubygems_version: 2.
|
123
|
+
rubygems_version: 2.7.5
|
123
124
|
signing_key:
|
124
125
|
specification_version: 4
|
125
126
|
summary: Container-agnostic automatic constructor injection
|