dry-auto_inject 0.4.2 → 0.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6f9eb1effcee4d7bd3a8741b9d66b736ec2a1254
4
- data.tar.gz: f8401c55f988c919a09033e510fd58566bd76484
3
+ metadata.gz: b5d25d77aea481c1dfd5c35eb30eaca7d921b1a7
4
+ data.tar.gz: a9512d492a6805f94b33784683f13a64ec6fe69d
5
5
  SHA512:
6
- metadata.gz: 6c6eea940b2c7c57137a737e3d66abd763ec2ff4e51725e7386bf15020efabe6c2485e412f0088fe54dccc16114914d0bada89d3a5a1c55e11da73f211b155e5
7
- data.tar.gz: aac93975a6bbcd756108a72310d7f8995430bae11a97c867a3073e1503e95012cd177187d4aff0b4a9a4db6c988a3b21eb4f26074261eda5a0fdc450e56dacdb
6
+ metadata.gz: a270fe530357ac14278071e5d76dca6a2dd4e07865817d0e9f2e3524af8138a250d403261615737f8a084803bcacd38ec7b8a765a5af9f2034b515ca71e093ac
7
+ data.tar.gz: 4dcfbdeb49aeccb0109b414d4e0d18e7733bbb2ff5b70b4be9ec4582c4e6aacad9c5755d368a14ad04c02de79fe87895450358f4cca55dcc2012d5e07581feda
@@ -1,24 +1,21 @@
1
1
  language: ruby
2
- sudo: false
2
+ dist: trusty
3
+ sudo: required
3
4
  cache: bundler
4
- bundler_args: --without console
5
+ bundler_args: --without tools
5
6
  script:
6
- - bundle exec rake spec
7
+ - bundle exec rake
8
+ after_success:
9
+ - '[ -d coverage ] && bundle exec codeclimate-test-reporter'
7
10
  rvm:
8
- - 2.1
9
- - 2.2
10
- - 2.3.1
11
- - rbx
12
- - ruby-head
13
- - jruby-head
11
+ - 2.1.10
12
+ - 2.2.7
13
+ - 2.3.4
14
+ - 2.4.1
15
+ - jruby-9.1.10.0
14
16
  env:
15
17
  global:
16
18
  - JRUBY_OPTS='--dev -J-Xmx1024M'
17
- matrix:
18
- allow_failures:
19
- - rvm: rbx
20
- - rvm: ruby-head
21
- - rvm: jruby-head
22
19
  addons:
23
20
  code_climate:
24
21
  repo_token: 029b5aa100b82b6710e285597b7eabe760357b5dd1f626514371356055378d8c
@@ -1,3 +1,9 @@
1
+ # 0.4.3 / to-be-released
2
+
3
+ ### Added
4
+
5
+ - Push sequential arguments along with keywords in the kwargs strategy (hbda + vladra in [#32](https://github.com/dry-rb/dry-auto_inject/pull/32))
6
+
1
7
  # 0.4.2 / 2016-10-10
2
8
 
3
9
  ### Fixed
data/Gemfile CHANGED
@@ -4,6 +4,7 @@ source 'https://rubygems.org'
4
4
  gemspec
5
5
 
6
6
  group :test do
7
+ gem "simplecov"
7
8
  gem "codeclimate-test-reporter", require: nil
8
9
  end
9
10
 
data/README.md CHANGED
@@ -14,7 +14,7 @@
14
14
  [![API Documentation Coverage](http://inch-ci.org/github/dry-rb/dry-auto_inject.svg)][inch]
15
15
  ![No monkey-patches](https://img.shields.io/badge/monkey--patches-0-brightgreen.svg)
16
16
 
17
- A simple extensions which allows you to automatically inject dependencies to your
17
+ A simple extension which allows you to automatically inject dependencies to your
18
18
  object constructors from a configured container.
19
19
 
20
20
  It does 3 things:
@@ -42,36 +42,9 @@ Or install it yourself as:
42
42
  $ gem install dry-auto_inject
43
43
  ```
44
44
 
45
- ## Usage
45
+ ## Links
46
46
 
47
- You can use `AutoInject` with any container that responds to `[]`. In this example
48
- we're going to use `dry-container`:
49
-
50
- ```ruby
51
- # set up your container
52
- my_container = Dry::Container.new
53
-
54
- my_container.register(:data_store, -> { DataStore.new })
55
- my_container.register(:user_repository, -> { container[:data_store][:users] })
56
- my_container.register(:persist_user, -> { PersistUser.new })
57
-
58
- # set up your auto-injection function
59
- AutoInject = Dry::AutoInject(my_container)
60
-
61
- # then simply include it in your class providing which dependencies should be
62
- # injected automatically from the configured container
63
- class PersistUser
64
- include AutoInject[:user_repository]
65
-
66
- def call(user)
67
- user_repository << user
68
- end
69
- end
70
-
71
- persist_user = my_container[:persist_user]
72
-
73
- persist_user.call(name: 'Jane')
74
- ```
47
+ * [Documentation](http://dry-rb.org/gems/dry-auto_inject/)
75
48
 
76
49
  ## Development
77
50
 
@@ -9,12 +9,12 @@ module Dry
9
9
 
10
10
  def define_new
11
11
  class_mod.class_exec(container, dependency_map) do |container, dependency_map|
12
- define_method :new do |**args|
12
+ define_method :new do |*args, **kwargs|
13
13
  deps = dependency_map.to_h.each_with_object({}) { |(name, identifier), obj|
14
- obj[name] = args[name] || container[identifier]
15
- }.merge(args)
14
+ obj[name] = kwargs[name] || container[identifier]
15
+ }.merge(kwargs)
16
16
 
17
- super(**deps)
17
+ super(*args, **deps)
18
18
  end
19
19
  end
20
20
  end
@@ -45,21 +45,21 @@ module Dry
45
45
 
46
46
  def define_initialize_with_splat(super_method)
47
47
  super_kwarg_names = super_method.parameters.select { |type, _| [:key, :keyreq].include?(type) }.map(&:last)
48
- super_params = super_kwarg_names.map { |name| "#{name}: args[:#{name}]" }.join(', ')
48
+ super_kw_params = super_kwarg_names.map { |name| "#{name}: kwargs[:#{name}]" }.join(', ')
49
49
 
50
50
  # Pass through any non-dependency args if the super method accepts `**args`
51
51
  if super_method.parameters.any? { |type, _| type == :keyrest }
52
- if super_params.empty?
53
- super_params = '**args'
52
+ if super_kw_params.empty?
53
+ super_kw_params = '**kwargs'
54
54
  else
55
- super_params += ', **args'
55
+ super_kw_params += ', **kwargs'
56
56
  end
57
57
  end
58
58
 
59
59
  instance_mod.class_eval <<-RUBY, __FILE__, __LINE__ + 1
60
- def initialize(**args)
61
- super(#{super_params})
62
- #{dependency_map.names.map { |name| "@#{name} = args[:#{name}]" }.join("\n")}
60
+ def initialize(*args, **kwargs)
61
+ super(*args, #{super_kw_params})
62
+ #{dependency_map.names.map { |name| "@#{name} = kwargs[:#{name}]" }.join("\n")}
63
63
  end
64
64
  RUBY
65
65
  self
@@ -1,5 +1,5 @@
1
1
  module Dry
2
2
  module AutoInject
3
- VERSION = '0.4.2'.freeze
3
+ VERSION = '0.4.3'.freeze
4
4
  end
5
5
  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.2
4
+ version: 0.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Piotr Solnica
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-10-09 00:00:00.000000000 Z
11
+ date: 2017-05-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dry-container
@@ -118,7 +118,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
118
118
  version: '0'
119
119
  requirements: []
120
120
  rubyforge_project:
121
- rubygems_version: 2.5.1
121
+ rubygems_version: 2.6.11
122
122
  signing_key:
123
123
  specification_version: 4
124
124
  summary: Container-agnostic automatic constructor injection