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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e0042dc19e9deddd4e91c467ee37e19dd35f0b2f
4
- data.tar.gz: 1e39637937fe563fe9b6e81ce05a08fd7f4626f8
3
+ metadata.gz: c49f9648a3bb95e99aea71aedff8bae0454e01e0
4
+ data.tar.gz: ed92fc57ef9f89ac19d1b29f54a9245f912d721b
5
5
  SHA512:
6
- metadata.gz: 8f1e1554ca7e1f236cc374ea9858c4105fa8cbeba0553a81b3284733a04865c5ca5b65d477d1224d7c9936d1851e5a1e6ab04ad5800e1ec24ea80d994fc3453d
7
- data.tar.gz: 32a613528353df4ee8379fd2bd62b74573e3e1a014d1f3a8dfbcb8a9f34f8bb3871ea041254448c51f1d2799421b6748b121c1414d872712cfcc49b3bb08d636
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] = ERB::Util.h(value)
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
@@ -1,3 +1,3 @@
1
1
  module TextHelpers
2
- VERSION = "0.4.0"
2
+ VERSION = "0.4.1"
3
3
  end
@@ -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.0
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-04 00:00:00.000000000 Z
11
+ date: 2014-10-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport