text_helpers 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -13
- data/lib/text_helpers/translation.rb +2 -5
- data/lib/text_helpers/version.rb +1 -1
- data/test/lib/text_helpers/translation_test.rb +3 -8
- data/text_helpers.gemspec +1 -1
- metadata +13 -13
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
Y2I1MzBlOWY2YTY3ZTUyNWQyODFkY2U0MGM5ZmQzOGYzZjY3NWNlMw==
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 96b1413c9d4a7e4a7c09d61fcf73d31024088238
|
4
|
+
data.tar.gz: f8d107fdadfb1d61b71fd41b3338b0981f325e2f
|
7
5
|
SHA512:
|
8
|
-
metadata.gz:
|
9
|
-
|
10
|
-
MmI5ZmQ4YTczOWYyNWQ5MWM1YzRhMGEyMTYyNzNkYWEzNWE4NGY0YjIwYTk5
|
11
|
-
ZTU0ZTI1MDQ3MmU3NTI5MTE0NDRhZjk4MzMzM2Y1NzFhZmQwYjc=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
NDU2Y2IzNDVjYjFhZTc3ZGFlNmU2ZTdlMzViOTJlMTQxNjNiYzEwNzg5YmJh
|
14
|
-
MDZmMDY5MWJjYjgxOGRjZWZhMmU4NWM4YTg3ZDVmY2RjZTRlYjBlZGFlNzA3
|
15
|
-
MzMxMGRkZGZlYTk3ZGIzOTJlMTJhZTk0MGVhYmIwNDQwODJkNTc=
|
6
|
+
metadata.gz: b61a1f7ab9fdc3b2a0c7c40190c37609fd5d57058df512ea19376d462b90424f08da965975a53d3cc863665ed36c8ba1a275e754bfc24713bee61e2ac960ae96
|
7
|
+
data.tar.gz: b800a3e4ae9fe750c3645de28546b38d51c10ced240b65d5b6ba311dfe719d117613c08d7f2d3637dc3a7faf55f209c0a74b96a7863f1bd3abca4c26b745c8c2
|
@@ -24,10 +24,7 @@ module TextHelpers
|
|
24
24
|
}.merge(options))
|
25
25
|
|
26
26
|
# Interpolate any keypaths (e.g., `!some.lookup.path/key!`) found in the text.
|
27
|
-
final_text = text.strip.gsub(/!([\w._\/]+)!/)
|
28
|
-
I18n.t($1)
|
29
|
-
end
|
30
|
-
final_text = final_text.sub(/\s(\S+)\Z/, ' \1') unless options[:orphans]
|
27
|
+
final_text = text.strip.gsub(/!([\w._\/]+)!/) { |match| I18n.t($1) }
|
31
28
|
final_text.html_safe
|
32
29
|
end
|
33
30
|
|
@@ -43,7 +40,7 @@ module TextHelpers
|
|
43
40
|
#
|
44
41
|
# Returns a String containing the localized text rendered via Markdown
|
45
42
|
def html(key, options = {})
|
46
|
-
rendered = GitHub::Markdown.render(text(key, options
|
43
|
+
rendered = GitHub::Markdown.render(text(key, options))
|
47
44
|
|
48
45
|
rendered = options[:orphans] ? rendered : rendered.gsub(ORPHAN_MATCHER, ' \1')
|
49
46
|
rendered = rendered.gsub(/<\/?p>/, '') if options[:inline]
|
data/lib/text_helpers/version.rb
CHANGED
@@ -16,7 +16,6 @@ describe TextHelpers::Translation do
|
|
16
16
|
MULTI
|
17
17
|
|
18
18
|
@nb_scoped_text = "Scoped lookup"
|
19
|
-
@nb_global_text = "Global lookup"
|
20
19
|
|
21
20
|
I18n.backend.store_translations :en, {
|
22
21
|
test_key: @global_text,
|
@@ -38,11 +37,7 @@ describe TextHelpers::Translation do
|
|
38
37
|
end
|
39
38
|
|
40
39
|
it "looks up the text for the key in a scope derived from the call stack" do
|
41
|
-
assert_equal "*#{@
|
42
|
-
end
|
43
|
-
|
44
|
-
it "allows orphaned text with :orphans" do
|
45
|
-
assert_equal "*#{@scoped_text}*", @helper.text(:test_key, orphans: true)
|
40
|
+
assert_equal "*#{@scoped_text}*", @helper.text(:test_key)
|
46
41
|
end
|
47
42
|
|
48
43
|
it "converts the text to HTML via Markdown" do
|
@@ -86,7 +81,7 @@ describe TextHelpers::Translation do
|
|
86
81
|
end
|
87
82
|
|
88
83
|
it "interpolates values wrapped in !!" do
|
89
|
-
assert_equal "Global? (#{@
|
84
|
+
assert_equal "Global? (#{@global_text})", @helper.text(:interpolated_key)
|
90
85
|
end
|
91
86
|
end
|
92
87
|
|
@@ -98,7 +93,7 @@ describe TextHelpers::Translation do
|
|
98
93
|
end
|
99
94
|
|
100
95
|
it "defaults to a globally-defined value for the key" do
|
101
|
-
assert_equal @
|
96
|
+
assert_equal @global_text, @helper.text(:test_key)
|
102
97
|
end
|
103
98
|
end
|
104
99
|
end
|
data/text_helpers.gemspec
CHANGED
metadata
CHANGED
@@ -1,55 +1,55 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: text_helpers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.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: 2013-12-
|
11
|
+
date: 2013-12-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - '>='
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - '>='
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: i18n
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - '>='
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 0.6.8
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - '>='
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: 0.6.8
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: github-markdown
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - '>='
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - '>='
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
description: Easily fetch text and static content from your locales
|
@@ -83,17 +83,17 @@ require_paths:
|
|
83
83
|
- lib
|
84
84
|
required_ruby_version: !ruby/object:Gem::Requirement
|
85
85
|
requirements:
|
86
|
-
- -
|
86
|
+
- - '>='
|
87
87
|
- !ruby/object:Gem::Version
|
88
88
|
version: '0'
|
89
89
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
90
90
|
requirements:
|
91
|
-
- -
|
91
|
+
- - '>='
|
92
92
|
- !ruby/object:Gem::Version
|
93
93
|
version: '0'
|
94
94
|
requirements: []
|
95
95
|
rubyforge_project:
|
96
|
-
rubygems_version: 2.
|
96
|
+
rubygems_version: 2.0.6
|
97
97
|
signing_key:
|
98
98
|
specification_version: 4
|
99
99
|
summary: TextHelpers is a gem which supplies some basic utilities for text localization
|