la_maquina 0.1.2 → 0.1.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: acd2791bb4c7f4a12ecce84438589889b745a5c5
4
- data.tar.gz: 353b65cc5432f9aa0c6263978b70046c21c14d7e
3
+ metadata.gz: 882d374d14ea85b1f5fc6cecbe12fd5756fdb35d
4
+ data.tar.gz: 9f0237300142961bd25cc6ff24e4524df633d62b
5
5
  SHA512:
6
- metadata.gz: 7aafe304080235d4f6f2ca9290c078bbd61408230a70aa22c58ee57006e7305302d0bb04e9c397e19549a26c07d2c1a9d0259427999a8506ed8f6728b9e1a7f8
7
- data.tar.gz: a7f50f4b9e986b241f1e8770f96fd0453356b2d17df698faa18373305d9e4790fb3f39b605fd5b5ca0c4101ecc8681b5f01fdf78c7352d034144d6de219d8c14
6
+ metadata.gz: 8a1e57d81fcaa1b20b398ee2b798b898030afb2a1517b70bfb55b914c6b750c03262e423ff9ac545f28d0eefc4a45d6a54dfab6ea92c3f1c23fae2c1bf67cf53
7
+ data.tar.gz: 2c77272adacb71c9253069904f279e52505554a8350875c1d35364b28db60ff2216899d36942ef88bb9bc255394ef2bd9e6a47a0dbce575f7b3cedaa74a4b3a8
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- la_maquina (0.1.0)
4
+ la_maquina (0.1.2)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -196,14 +196,12 @@ map.mapping_for "danny_trejo", "machete", 1 # => "favorite"
196
196
  ```
197
197
 
198
198
  ### ErrorNotifier
199
- LaMaquina by default comes with an `ErrorNotifier::Base` that will explode in a very unhelpful manner. To override it, you need to change it in the config above and roll a new `ErrorNotifier` that responds to `notify(error, details)`. For example, if you're using Honeybadger, you can use the included `LaMaquina::ErrorNotifiers::HoneybadgerNotifier`, which looks like:
199
+ LaMaquina by default comes with an `ErrorNotifier::Base` that will explode in a very unhelpful manner. To override it, you need to change it in the config above and roll a new `ErrorNotifier` that responds to `notify(error, details)`. For example, a really handy debugging notifier you can build is a PutsNotifier, that just puts the error details, and looks like this:
200
200
  ```ruby
201
- class HoneybadgerNotifier < LaMaquina::ErrorNotifier::Base
202
- self.notify(error = nil, details = {})
203
- Honeybadger.notify( :error_class => "LaMaquinaError: #{error.class.name}",
204
- :error_message => error.message,
205
- :parameters => details
206
- )
201
+ class PutsNotifier < LaMaquina::ErrorNotifier::Base
202
+
203
+ def self.notify(error, details)
204
+ puts error.inspect, details.inspect
207
205
  end
208
206
  end
209
207
  ```
@@ -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, id)
5
+ def mapping_for(notified_class)
6
6
  notified_class.camelize.constantize
7
7
  rescue => e
8
8
  LaMaquina.error_notifier.notify( e,
@@ -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, id
7
+ target_class = map.mapping_for 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.2"
2
+ VERSION = "0.1.3"
3
3
  end
Binary file
@@ -0,0 +1,30 @@
1
+ require 'test_helper'
2
+
3
+
4
+ class ConstantMapTest < ActiveSupport::TestCase
5
+ def setup
6
+ @admin = admins(:wheel)
7
+ @map = LaMaquina::DependencyMap::ConstantMap.new
8
+ end
9
+
10
+ def test_can_load_map
11
+ assert Admin, @map.mapping_for(:admin)
12
+ end
13
+
14
+ def test_catches_mapless_lookup
15
+ @map.mapping_for :lol
16
+
17
+ assert_equal NoMethodError, $error.class
18
+ end
19
+
20
+ def test_is_with_indifferent_access
21
+ assert Admin, @map.mapping_for("admin")
22
+ assert Admin, @map.mapping_for(:admin)
23
+ end
24
+
25
+ def test_can_go_to_any_depth
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 )
29
+ end
30
+ end
@@ -20,7 +20,7 @@ class YamlMapTest < ActiveSupport::TestCase
20
20
  end
21
21
 
22
22
  def test_is_with_indifferent_access
23
- assert 'admin', @map.mapping_for(:admin)
23
+ assert :admin, @map.mapping_for("admin")
24
24
  assert :admin, @map.mapping_for(:admin)
25
25
  end
26
26
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: la_maquina
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Greg Orlov
@@ -145,6 +145,7 @@ files:
145
145
  - test/dummy/test/fixtures/standalones.yml
146
146
  - test/dummy/test/fixtures/traits.yml
147
147
  - test/test_helper.rb
148
+ - test/unit/dependency_maps/constant_map_test.rb
148
149
  - test/unit/dependency_maps/yamp_map_test.rb
149
150
  - test/unit/engine_test.rb
150
151
  - test/unit/error_notifier_test.rb
@@ -239,6 +240,7 @@ test_files:
239
240
  - test/dummy/test/fixtures/standalones.yml
240
241
  - test/dummy/test/fixtures/traits.yml
241
242
  - test/test_helper.rb
243
+ - test/unit/dependency_maps/constant_map_test.rb
242
244
  - test/unit/dependency_maps/yamp_map_test.rb
243
245
  - test/unit/engine_test.rb
244
246
  - test/unit/error_notifier_test.rb