invokr 0.1.0 → 0.9.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
  SHA1:
3
- metadata.gz: d465d0fe3a99374d9964c837dd835e2686ea18e4
4
- data.tar.gz: 6f524e10b9b8dcd60755ac40ea7264835370cf5d
3
+ metadata.gz: 611146c6c46e842eda6f5593347532f605d7f713
4
+ data.tar.gz: c63700bd730b0fd929add0dbd98e99d970755c2b
5
5
  SHA512:
6
- metadata.gz: aeb433d0fcc41411665277604feab0b684f82a0f3cbdfd86cab9a9822d93aa2af2b27b5f5856fc95f8f6578d2291860d74a295e54c7338bd4852a1f7061b5534
7
- data.tar.gz: 68128087cca50df10d2186934160052d6a809c93f1f8d078c6025cb57a2825ac7b52ef824dab49e4475b7235647715796cf0f446787eac1b45f147f38cc2827b
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
 
@@ -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-reporters"
23
+ spec.add_development_dependency "minitest-red_green"
24
24
  spec.add_development_dependency "rake"
25
25
  end
@@ -111,8 +111,9 @@ module Invokr
111
111
  end
112
112
 
113
113
  def optional_arg_error! identifier
114
+ name = method.respond_to?(:name) ? method.name : 'anonymous'
114
115
  raise OptionalPositionalArgumentError.new(
115
- method.name,
116
+ name,
116
117
  @opt_arg_name,
117
118
  identifier,
118
119
  )
@@ -1,3 +1,3 @@
1
1
  module Invokr
2
- VERSION = "0.1.0"
2
+ VERSION = "0.9.0"
3
3
  end
@@ -3,9 +3,7 @@ require 'invokr'
3
3
 
4
4
  require 'minitest'
5
5
  require 'minitest/autorun'
6
- require 'minitest/reporters'
7
-
8
- Minitest::Reporters.use! Minitest::Reporters::DefaultReporter.new
6
+ require 'minitest/red_green'
9
7
 
10
8
  module TestMethodBank
11
9
  extend self
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.1.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-07-24 00:00:00.000000000 Z
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-reporters
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/dependency_injection_example_test.rb
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/dependency_injection_example_test.rb
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