messages_dictionary 0.1.3.1 → 0.1.3.2

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: d7e86a9334f8e0fe44e69e7bd166095578f22896
4
- data.tar.gz: 6178d615c1359bbfcfa8c5ea5241db44ea21e455
3
+ metadata.gz: 8e04ddafa4acde576e068661a7f9d0cc51f9f8e7
4
+ data.tar.gz: 3d64b738f76be0c00ac15abc347efc44dbbddafb
5
5
  SHA512:
6
- metadata.gz: 7d4e456a6bdb98e40d3189615a4771822a1d4dd0d8658569675326e3963a893f490db7307dab350789c22d6ac8055505c3cd96048c064cc3ca1916611ee65a1c
7
- data.tar.gz: 4b42e399da84fb80e79954d2386a85bc566f5f7d0ff10d1b9944e3c605ddddb287bc0b37b72ec9c8a97dec5eb57deecd8d73c98ce36d5791187dbccbd22ce241
6
+ metadata.gz: 6a34f5fa258dc7c36233c70c0a4f7cde497028db75ad55514620378d8f64bb5f71042e5398786982c008d77de480d5ddb2bee79c5886bf1769ad726eaa78d1c2
7
+ data.tar.gz: 284b26087daf4ae5215a0ddf9430a2c052c1d8b611a309576f0de33ade6be8ef4407df4f57cacd487ceab5da7e156d6b1d1621988662145d452d9e8b2b7a47e1
data/.travis.yml CHANGED
@@ -4,6 +4,6 @@ rvm:
4
4
  - 2.0.0
5
5
  - 2.1.5
6
6
  - 2.2.5
7
- - rbx
7
+ - ruby-head
8
8
 
9
9
  install: bundle install --retry=3
data/README.md CHANGED
@@ -237,6 +237,8 @@ my_object = MyClass.new
237
237
  my_object.greet # Will return "WELCOME", nothing will be put on the screen
238
238
  ```
239
239
 
240
+ Transformation provided per method takes higher precedence than the one provided per class.
241
+
240
242
  **Please note** that by default MessagesDictionary **does not output anything** when you provide transformation
241
243
  block. This is done to allow more control, because sometimes you may want to fetch a message, but not output
242
244
  it anywhere (for example, when raising a custom error - see use case [here](https://github.com/bodrovis/Guesser/blob/master/lib/guesser.rb#L25)).
@@ -26,7 +26,7 @@ module MessagesDictionary
26
26
  values.each do |k, v|
27
27
  msg.gsub!(Regexp.new('\{\{' + k.to_s + '\}\}'), v.to_s)
28
28
  end
29
- transform = klass::DICTIONARY_CONF[:transform] || block
29
+ transform = block || klass::DICTIONARY_CONF[:transform]
30
30
  transform ?
31
31
  transform.call(msg) :
32
32
  klass::DICTIONARY_CONF[:output].send(klass::DICTIONARY_CONF[:method].to_sym, msg)
@@ -1,3 +1,3 @@
1
1
  module MessagesDictionary
2
- VERSION = '0.1.3.1'
2
+ VERSION = '0.1.3.2'
3
3
  end
@@ -132,5 +132,15 @@ RSpec.describe MessagesDictionary do
132
132
  object = @subject.new
133
133
  expect( object.send(:pretty_output, :test) ).to eq('STRING')
134
134
  end
135
+
136
+ it "per-method takes higher priority than per-class" do
137
+ @subject.class_eval do
138
+ has_messages_dictionary messages: {test: 'string'},
139
+ transform: ->(msg) {msg.reverse!}
140
+ end
141
+
142
+ object = @subject.new
143
+ expect( object.send(:pretty_output, :test) {|msg| msg.upcase!} ).to eq('STRING')
144
+ end
135
145
  end
136
146
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: messages_dictionary
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3.1
4
+ version: 0.1.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ilya Bodrov
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-09-27 00:00:00.000000000 Z
12
+ date: 2016-09-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: hashie