messages_dictionary 0.1.3.1 → 0.1.3.2
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 +4 -4
- data/.travis.yml +1 -1
- data/README.md +2 -0
- data/lib/messages_dictionary/injector.rb +1 -1
- data/lib/messages_dictionary/version.rb +1 -1
- data/spec/injector_spec.rb +10 -0
- 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: 8e04ddafa4acde576e068661a7f9d0cc51f9f8e7
|
4
|
+
data.tar.gz: 3d64b738f76be0c00ac15abc347efc44dbbddafb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6a34f5fa258dc7c36233c70c0a4f7cde497028db75ad55514620378d8f64bb5f71042e5398786982c008d77de480d5ddb2bee79c5886bf1769ad726eaa78d1c2
|
7
|
+
data.tar.gz: 284b26087daf4ae5215a0ddf9430a2c052c1d8b611a309576f0de33ade6be8ef4407df4f57cacd487ceab5da7e156d6b1d1621988662145d452d9e8b2b7a47e1
|
data/.travis.yml
CHANGED
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]
|
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)
|
data/spec/injector_spec.rb
CHANGED
@@ -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.
|
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-
|
12
|
+
date: 2016-09-30 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: hashie
|