la_maquina 0.1.3 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +4 -4
- data/lib/la_maquina/dependency_map/base.rb +2 -2
- data/lib/la_maquina/dependency_map/constant_map.rb +1 -1
- data/lib/la_maquina/dependency_map/yaml_map.rb +1 -1
- data/lib/la_maquina/piston/sunspot_piston.rb +1 -1
- data/lib/la_maquina/version.rb +1 -1
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/dummy/lib/extended_sunspot_piston.rb +1 -1
- data/test/unit/dependency_maps/constant_map_test.rb +6 -6
- data/test/unit/dependency_maps/yamp_map_test.rb +6 -6
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2b9dfe4cad02401d7cff443f5fbe56a01a25e5a4
|
4
|
+
data.tar.gz: 2db651c9df50e6ca050b0191c2e195b1dd3096a1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b4e026c6f6260f8fb9f07230d2fdc096b4e98a949e795975d698169310453f1c7ddc8fa8132e1d1f2c586ffe0afa1097adf509662de27980e43af964c4837518
|
7
|
+
data.tar.gz: 86dae1b58a104b38e08aa75c7691e2dcfc9f0094f0783da72f60c2c0303bd4b280619bea3ff12150b6fbc8cf9b49cb5d1ea4c54c1b12db62faf1d7c9c6028c60
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -142,7 +142,7 @@ class CompositeCachePison < LaMaquina::Piston::Base
|
|
142
142
|
def fire!( notified_class, id, notifier_class )
|
143
143
|
key = "#{notified_class}/#{notifier_class}:#{id}"
|
144
144
|
|
145
|
-
klass = map.
|
145
|
+
klass = map.find notified_class
|
146
146
|
object = klass.find(id)
|
147
147
|
|
148
148
|
# because notifier_class is already snaked we can just send it as an association
|
@@ -167,7 +167,7 @@ class Map < LaMaquina::DependencyMap::Base
|
|
167
167
|
# defined in Base
|
168
168
|
# initialize( yaml_path = nil)
|
169
169
|
|
170
|
-
def
|
170
|
+
def find(*args)
|
171
171
|
# your code here
|
172
172
|
end
|
173
173
|
|
@@ -180,7 +180,7 @@ LaMaquina comes with 2 default maps: `ConstantMap` and `YamlMap`.
|
|
180
180
|
`LaMaquina::DependencyMap::ConstantMap` takes a string and tries to constantize it. It's not strictly speaking a map, but it works as you would expect:
|
181
181
|
```ruby
|
182
182
|
map = LaMaquina::DependencyMap::ConstantMap.new
|
183
|
-
map.
|
183
|
+
map.find "danny_trejo" # => DannyTrejo(id: integer, ...)
|
184
184
|
```
|
185
185
|
`LaMaquina::DependencyMap::YamlMap` get initialized with a yaml path, parses the yaml and spits out a dependency at any depth, meaning:
|
186
186
|
```yml
|
@@ -192,7 +192,7 @@ danny_trejo:
|
|
192
192
|
```
|
193
193
|
```ruby
|
194
194
|
map = LaMaquina::DependencyMap::YamlMap.new "#{Rail.root}/config/map.yml"
|
195
|
-
map.
|
195
|
+
map.find "danny_trejo", "machete", 1 # => "favorite"
|
196
196
|
```
|
197
197
|
|
198
198
|
### ErrorNotifier
|
data/lib/la_maquina/version.rb
CHANGED
data/test/dummy/db/test.sqlite3
CHANGED
Binary file
|
@@ -8,23 +8,23 @@ class ConstantMapTest < ActiveSupport::TestCase
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def test_can_load_map
|
11
|
-
assert Admin, @map.
|
11
|
+
assert Admin, @map.find(:admin)
|
12
12
|
end
|
13
13
|
|
14
14
|
def test_catches_mapless_lookup
|
15
|
-
@map.
|
15
|
+
@map.find :lol
|
16
16
|
|
17
17
|
assert_equal NoMethodError, $error.class
|
18
18
|
end
|
19
19
|
|
20
20
|
def test_is_with_indifferent_access
|
21
|
-
assert Admin, @map.
|
22
|
-
assert Admin, @map.
|
21
|
+
assert Admin, @map.find("admin")
|
22
|
+
assert Admin, @map.find(:admin)
|
23
23
|
end
|
24
24
|
|
25
25
|
def test_can_go_to_any_depth
|
26
26
|
map = LaMaquina::DependencyMap::YamlMap.new( Rails.root + 'config/la_maquina/dependency_maps/deep_map.yml' )
|
27
|
-
assert_equal "trait", map.
|
28
|
-
assert_equal "b", map.
|
27
|
+
assert_equal "trait", map.find( "admin", "trait" )
|
28
|
+
assert_equal "b", map.find( "guest", "trait", 1 )
|
29
29
|
end
|
30
30
|
end
|
@@ -9,24 +9,24 @@ class YamlMapTest < ActiveSupport::TestCase
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def test_can_load_map
|
12
|
-
assert 'admin', @map.
|
12
|
+
assert 'admin', @map.find(:admin)
|
13
13
|
end
|
14
14
|
|
15
15
|
def test_catches_mapless_lookup
|
16
16
|
map = LaMaquina::DependencyMap::YamlMap.new
|
17
|
-
map.
|
17
|
+
map.find :admin
|
18
18
|
|
19
19
|
assert_equal NoMethodError, $error.class
|
20
20
|
end
|
21
21
|
|
22
22
|
def test_is_with_indifferent_access
|
23
|
-
assert :admin, @map.
|
24
|
-
assert :admin, @map.
|
23
|
+
assert :admin, @map.find("admin")
|
24
|
+
assert :admin, @map.find(:admin)
|
25
25
|
end
|
26
26
|
|
27
27
|
def test_can_go_to_any_depth
|
28
28
|
map = LaMaquina::DependencyMap::YamlMap.new( Rails.root + 'config/la_maquina/dependency_maps/deep_map.yml' )
|
29
|
-
assert_equal "trait", map.
|
30
|
-
assert_equal "b", map.
|
29
|
+
assert_equal "trait", map.find( "admin", "trait" )
|
30
|
+
assert_equal "b", map.find( "guest", "trait", 1 )
|
31
31
|
end
|
32
32
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: la_maquina
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Greg Orlov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-08-
|
11
|
+
date: 2015-08-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|