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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 882d374d14ea85b1f5fc6cecbe12fd5756fdb35d
4
- data.tar.gz: 9f0237300142961bd25cc6ff24e4524df633d62b
3
+ metadata.gz: 2b9dfe4cad02401d7cff443f5fbe56a01a25e5a4
4
+ data.tar.gz: 2db651c9df50e6ca050b0191c2e195b1dd3096a1
5
5
  SHA512:
6
- metadata.gz: 8a1e57d81fcaa1b20b398ee2b798b898030afb2a1517b70bfb55b914c6b750c03262e423ff9ac545f28d0eefc4a45d6a54dfab6ea92c3f1c23fae2c1bf67cf53
7
- data.tar.gz: 2c77272adacb71c9253069904f279e52505554a8350875c1d35364b28db60ff2216899d36942ef88bb9bc255394ef2bd9e6a47a0dbce575f7b3cedaa74a4b3a8
6
+ metadata.gz: b4e026c6f6260f8fb9f07230d2fdc096b4e98a949e795975d698169310453f1c7ddc8fa8132e1d1f2c586ffe0afa1097adf509662de27980e43af964c4837518
7
+ data.tar.gz: 86dae1b58a104b38e08aa75c7691e2dcfc9f0094f0783da72f60c2c0303bd4b280619bea3ff12150b6fbc8cf9b49cb5d1ea4c54c1b12db62faf1d7c9c6028c60
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- la_maquina (0.1.2)
4
+ la_maquina (0.1.3)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
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.mapping_for notified_class
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 mapping_for(*args)
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.mapping_for "danny_trejo" # => DannyTrejo(id: integer, ...)
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.mapping_for "danny_trejo", "machete", 1 # => "favorite"
195
+ map.find "danny_trejo", "machete", 1 # => "favorite"
196
196
  ```
197
197
 
198
198
  ### ErrorNotifier
@@ -7,8 +7,8 @@ module LaMaquina
7
7
  end
8
8
  end
9
9
 
10
- def mapping_for(*args)
11
- raise "A dependency map has to implement 'mapping_for'"
10
+ def find(*args)
11
+ raise "A dependency map has to implement 'find'"
12
12
  end
13
13
 
14
14
  protected
@@ -2,7 +2,7 @@ module LaMaquina
2
2
  module DependencyMap
3
3
  class ConstantMap < LaMaquina::DependencyMap::Base
4
4
 
5
- def mapping_for(notified_class)
5
+ def find(notified_class)
6
6
  notified_class.camelize.constantize
7
7
  rescue => e
8
8
  LaMaquina.error_notifier.notify( e,
@@ -1,7 +1,7 @@
1
1
  module LaMaquina
2
2
  module DependencyMap
3
3
  class YamlMap < LaMaquina::DependencyMap::Base
4
- def mapping_for(*args)
4
+ def find(*args)
5
5
  submap = map
6
6
  args.each do |key|
7
7
  submap = submap[key]
@@ -4,7 +4,7 @@ module LaMaquina
4
4
 
5
5
  class << self
6
6
  def fire!( notified_class, id, notifier_class = "" )
7
- target_class = map.mapping_for notified_class
7
+ target_class = map.find notified_class
8
8
  target = target_class.find(id)
9
9
  target.solr_index!
10
10
  rescue => e
@@ -1,3 +1,3 @@
1
1
  module LaMaquina
2
- VERSION = "0.1.3"
2
+ VERSION = "0.2.0"
3
3
  end
Binary file
@@ -1,7 +1,7 @@
1
1
  class ExtendedSunspotPiston < LaMaquina::Piston::SunspotPiston
2
2
  class << self
3
3
  def fire!( notified_class, id, notifier_class = "" )
4
- if yaml_map.mapping_for notified_class
4
+ if yaml_map.find notified_class
5
5
  super
6
6
  $last_reindexed = notified_class
7
7
  end
@@ -8,23 +8,23 @@ class ConstantMapTest < ActiveSupport::TestCase
8
8
  end
9
9
 
10
10
  def test_can_load_map
11
- assert Admin, @map.mapping_for(:admin)
11
+ assert Admin, @map.find(:admin)
12
12
  end
13
13
 
14
14
  def test_catches_mapless_lookup
15
- @map.mapping_for :lol
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.mapping_for("admin")
22
- assert Admin, @map.mapping_for(:admin)
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.mapping_for( "admin", "trait" )
28
- assert_equal "b", map.mapping_for( "guest", "trait", 1 )
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.mapping_for(:admin)
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.mapping_for :admin
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.mapping_for("admin")
24
- assert :admin, @map.mapping_for(:admin)
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.mapping_for( "admin", "trait" )
30
- assert_equal "b", map.mapping_for( "guest", "trait", 1 )
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.1.3
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-05 00:00:00.000000000 Z
11
+ date: 2015-08-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler