text_helpers 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/text_helpers/translation.rb +7 -1
- data/lib/text_helpers/version.rb +1 -1
- data/test/lib/text_helpers/translation_test.rb +10 -1
- 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: c49f9648a3bb95e99aea71aedff8bae0454e01e0
|
4
|
+
data.tar.gz: ed92fc57ef9f89ac19d1b29f54a9245f912d721b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 21a84ee6259dfe61a832c93fdbdb7ad26fc3ffcdbd574eb33f4b63ecb5cf1bb3ad82f97a59e54000998e91c1ed51bf66b35547b3016db2fbc4055ef4ae0db67e
|
7
|
+
data.tar.gz: c5df917ab268762229f9e586e39f1d669b33affae097f2e87154b4ea50fe000ee1879f3e1f98ee0a3ad0e61043c0b679804f9211124b2c6a6beb4d8afcbec190
|
@@ -90,7 +90,13 @@ module TextHelpers
|
|
90
90
|
# Returns a hash
|
91
91
|
def html_safe_options(hash)
|
92
92
|
hash.inject({}) do |result, (key, value)|
|
93
|
-
result[key] =
|
93
|
+
result[key] = case value
|
94
|
+
when String
|
95
|
+
ERB::Util.h(value)
|
96
|
+
else
|
97
|
+
value
|
98
|
+
end
|
99
|
+
|
94
100
|
result
|
95
101
|
end
|
96
102
|
end
|
data/lib/text_helpers/version.rb
CHANGED
@@ -28,7 +28,11 @@ describe TextHelpers::Translation do
|
|
28
28
|
recursive_key: "Recursively !test.interpolated_key!",
|
29
29
|
quoted_key: "They're looking for \"#{@global_text}\"--#{@scoped_text}",
|
30
30
|
argument_key: "This is what %{user} said",
|
31
|
-
number_key: "120\""
|
31
|
+
number_key: "120\"",
|
32
|
+
pluralized_key: {
|
33
|
+
one: "A single piece of text",
|
34
|
+
other: "%{count} pieces of text"
|
35
|
+
}
|
32
36
|
}
|
33
37
|
}
|
34
38
|
end
|
@@ -123,6 +127,11 @@ describe TextHelpers::Translation do
|
|
123
127
|
it "handles i18n arguments which are html-safe" do
|
124
128
|
assert_equal "This is what <b>Han</b> Solo said", @helper.text(:argument_key, user: "<b>Han</b> Solo".html_safe)
|
125
129
|
end
|
130
|
+
|
131
|
+
it "correctly handles non-string params" do
|
132
|
+
assert_equal "A single piece of text", @helper.text(:pluralized_key, count: 1)
|
133
|
+
assert_equal "2 pieces of text", @helper.text(:pluralized_key, count: 2)
|
134
|
+
end
|
126
135
|
end
|
127
136
|
|
128
137
|
describe "when no valid scope is provided" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: text_helpers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Horner
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-10-
|
11
|
+
date: 2014-10-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|