invokr 0.1.0 → 0.9.0
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 +4 -4
- data/README.md +14 -1
- data/invokr.gemspec +1 -1
- data/lib/invokr/builder.rb +2 -1
- data/lib/invokr/version.rb +1 -1
- data/test/{dependency_injection_example_test.rb → dependency_injection_test.rb} +0 -0
- data/test/test_helper.rb +1 -3
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 611146c6c46e842eda6f5593347532f605d7f713
|
4
|
+
data.tar.gz: c63700bd730b0fd929add0dbd98e99d970755c2b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 34e1e23ed27ed26d8b4cd13c6aa47978f10d9e5e76b2fbd2dd416fc0bcdef7532610b85d8cc89c59d45df75cfee19d61b6fe796fa5f62acb62825288c158aaf7
|
7
|
+
data.tar.gz: 7b42582d41d76aedfa309bfbc6c52b8e7cbd3380b59a756a9f313d178aa05864d85cf71aee08047735c7fb39aebc532d2184432cd045eaf4dd1bcd023d951471
|
data/README.md
CHANGED
@@ -70,7 +70,20 @@ Before ruby 2.x introduced keyword arguments, it was common to end your method s
|
|
70
70
|
|
71
71
|
## Dependency injection
|
72
72
|
|
73
|
-
One of the use cases for Invokr is building abstract factories. In this case, you want to inspect the method signature of `Object#initialize`, but actually pass `.new` to the class to have it allocate memory and invoke the initializer for you. Check out `test/dependency_injection_example_test.rb` for how it is used. You can use a hash to serve as the registry of objects, or build your own custom resolver.
|
73
|
+
One of the use cases for Invokr is building abstract factories. In this case, you want to inspect the method signature of `Object#initialize`, but actually pass `.new` to the class to have it allocate memory and invoke the initializer for you. Check out `test/dependency_injection_example_test.rb` for how it is used. You can use a hash to serve as the registry of objects, or build your own custom resolver. Here's an example supplying a Hash as the registry:
|
74
|
+
|
75
|
+
```ruby
|
76
|
+
class MyKlass
|
77
|
+
attr :foo, :bar
|
78
|
+
def initiailze foo, bar
|
79
|
+
@foo, @bar = foo, bar
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
Invokr.inject MyKlass, using: { foo: 'FOO', bar: 'BAR', baz: 'BAZ' }
|
84
|
+
```
|
85
|
+
|
86
|
+
Even though `MyKlass` doesn't depend on `baz`, because everything it *did* need was present in the `using` Hash, Invokr was able to instantiate an instance of `MyKlass`
|
74
87
|
|
75
88
|
## Contributing
|
76
89
|
|
data/invokr.gemspec
CHANGED
@@ -20,6 +20,6 @@ Gem::Specification.new do |spec|
|
|
20
20
|
|
21
21
|
spec.add_development_dependency "bundler", "~> 1.6"
|
22
22
|
spec.add_development_dependency "minitest"
|
23
|
-
spec.add_development_dependency "minitest-
|
23
|
+
spec.add_development_dependency "minitest-red_green"
|
24
24
|
spec.add_development_dependency "rake"
|
25
25
|
end
|
data/lib/invokr/builder.rb
CHANGED
data/lib/invokr/version.rb
CHANGED
File without changes
|
data/test/test_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: invokr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ntl
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-09-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -39,7 +39,7 @@ dependencies:
|
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name: minitest-
|
42
|
+
name: minitest-red_green
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - ">="
|
@@ -89,7 +89,7 @@ files:
|
|
89
89
|
- lib/invokr/method.rb
|
90
90
|
- lib/invokr/version.rb
|
91
91
|
- test/block_args_test.rb
|
92
|
-
- test/
|
92
|
+
- test/dependency_injection_test.rb
|
93
93
|
- test/invokr_test.rb
|
94
94
|
- test/keyword_args_test.rb
|
95
95
|
- test/optional_args_test.rb
|
@@ -123,7 +123,7 @@ specification_version: 4
|
|
123
123
|
summary: Invoke methods with a consistent Hash interface.
|
124
124
|
test_files:
|
125
125
|
- test/block_args_test.rb
|
126
|
-
- test/
|
126
|
+
- test/dependency_injection_test.rb
|
127
127
|
- test/invokr_test.rb
|
128
128
|
- test/keyword_args_test.rb
|
129
129
|
- test/optional_args_test.rb
|