mindi 0.5 → 0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +17 -17
- data/examples/game.rb +4 -3
- data/lib/mindi.rb +3 -3
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f834757708bc208a40345d926add820c21fb236e
|
4
|
+
data.tar.gz: 160b48516bbb978b2022b46fbaf1795632da3868
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ba8928b900e7c540e5cd628b4db9bcc537f9516e16ebc3b8daf0903056eff8451beebaee12a0caf1a21b4052489bb9a6b685efe3081c1ef3b1878b9e894d8ed8
|
7
|
+
data.tar.gz: d737d66ef628caa1630801e00f1adfb5c3d2e06bd780db353759d60429d24320475b9d96f1c24cdc1137ce3df0b0cd1e7e7496939eaac52684cd95aa56e3087d
|
data/README.md
CHANGED
@@ -112,40 +112,40 @@ Notes
|
|
112
112
|
- The Injectable module can be used without MinDI containers as a kind of
|
113
113
|
delegation:
|
114
114
|
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
115
|
+
require 'mindi'
|
116
|
+
x = [1,2,3]
|
117
|
+
y = {}
|
118
|
+
x.extend MinDI::Injectable
|
119
|
+
x.inject_into y
|
120
|
+
p y.reverse # ==> [3, 2, 1]
|
121
121
|
|
122
122
|
- MinDI can be used as a Rake-like task scheduler:
|
123
123
|
|
124
|
-
|
124
|
+
require 'mindi'
|
125
125
|
|
126
|
-
|
127
|
-
|
126
|
+
class Tasks
|
127
|
+
include MinDI::BasicContainer
|
128
128
|
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
129
|
+
a { print "a" }
|
130
|
+
b { a; print "b" }
|
131
|
+
c { a; print "c" }
|
132
|
+
d { b; c; print "d" }
|
133
|
+
end
|
134
134
|
|
135
|
-
|
135
|
+
Tasks.new.d # ==> abcd
|
136
136
|
|
137
137
|
Bugs
|
138
138
|
----
|
139
139
|
|
140
140
|
- Private and protected services must be declared explicitly:
|
141
141
|
|
142
|
-
|
142
|
+
private :some_service
|
143
143
|
|
144
144
|
rather than by putting them in the private section of the class def.
|
145
145
|
|
146
146
|
- Because of how ruby defines Proc#arity, a service defined like
|
147
147
|
|
148
|
-
|
148
|
+
sname { do_something }
|
149
149
|
|
150
150
|
with no argument list will be treated as a multikey_multiton rather than
|
151
151
|
as a singleton. The behavior will be the same, though.
|
data/examples/game.rb
CHANGED
@@ -39,13 +39,14 @@ class GameContainer
|
|
39
39
|
|
40
40
|
# A multiton.
|
41
41
|
# The |name| means there can be many things--one for each name.
|
42
|
-
# internally, there is a hash
|
43
|
-
# each name
|
42
|
+
# internally, there is a hash stored in @thing that maps
|
43
|
+
# each name to a Thing.
|
44
44
|
thing { |name| Thing.new name }
|
45
45
|
|
46
46
|
# The shovel (unique with that name).
|
47
47
|
shovel { thing "Shovel" }
|
48
48
|
|
49
|
+
# Another multiton -- mapping from name to Room instance.
|
49
50
|
room { |name| Room.new name, [] }
|
50
51
|
|
51
52
|
start_room { room "garden" }
|
@@ -65,7 +66,7 @@ puts
|
|
65
66
|
|
66
67
|
# Create a new thing:
|
67
68
|
ball = game.thing("ball")
|
68
|
-
ball.location = game.room
|
69
|
+
ball.location = game.room("basement")
|
69
70
|
p ball
|
70
71
|
puts
|
71
72
|
|
data/lib/mindi.rb
CHANGED
@@ -6,7 +6,7 @@ module MinDI # :nodoc:
|
|
6
6
|
# container].
|
7
7
|
#
|
8
8
|
# Use MinDI by <b><tt>include</tt></b>ing the MinDI::InjectableContainer
|
9
|
-
# module in your container class.
|
9
|
+
# module in your container class. This does two things: it
|
10
10
|
# <b><tt>extend</tt></b>s your container class with the Container module,
|
11
11
|
# which provides class methods for expressing service definitions in a
|
12
12
|
# natural, rubylike way. It also injects the container into all services which
|
@@ -31,7 +31,7 @@ module MinDI # :nodoc:
|
|
31
31
|
# Note that services can be defined dynamically by reopening the class scope
|
32
32
|
# or simply by calling the service with a block. See examples/dynamic.rb.
|
33
33
|
|
34
|
-
VERSION = '0.
|
34
|
+
VERSION = '0.6'
|
35
35
|
|
36
36
|
module Container
|
37
37
|
|
@@ -138,7 +138,7 @@ module MinDI # :nodoc:
|
|
138
138
|
#
|
139
139
|
# threaded(:service_name) { |thr| ... }
|
140
140
|
|
141
|
-
def threaded(name, &impl) # :yields:
|
141
|
+
def threaded(name, &impl) # :yields: thread
|
142
142
|
impl_name = Container.impl_method_name(name)
|
143
143
|
define_implementation(impl_name, impl)
|
144
144
|
arity = impl.arity
|
metadata
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mindi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
4
|
+
version: '0.6'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joel VanderWerf
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-01-
|
11
|
+
date: 2014-01-29 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
|
-
description: MinDI is minimalist in that it attempts to map concepts of
|
14
|
-
ruby constructs, rather than into a layer of specialized constructs.
|
13
|
+
description: MinDI is minimalist in that it attempts to map concepts of dependency
|
14
|
+
injection into basic ruby constructs, rather than into a layer of specialized constructs.
|
15
15
|
email: vjoel@users.sourceforge.net
|
16
16
|
executables: []
|
17
17
|
extensions: []
|