i18nliner 0.1.2 → 0.2.0

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
  SHA256:
3
- metadata.gz: cfc705d5ce5735092cebbf57dd2d4241e0f9c29565163a7a300659b7b8fb39a1
4
- data.tar.gz: e477d3007a6ecfa1914bc2acf0798f84ca00d0f75a18450e793fc47743b3a45a
3
+ metadata.gz: 7db05f72a6f74269e7600897f2910d08749e1e8d8a334cbd8678e5ed7fe3640b
4
+ data.tar.gz: 3ee6d0d8ed3bb20ed38f7d639d9b2a151c1a3ff1c3c09dc7379a8246fcbc6599
5
5
  SHA512:
6
- metadata.gz: c9b27ba1617c266b3b627848ba465beb66674e55733274c5a850069845bea80c60acdddaea07cad3ed5de8c36ff432f159ffae7595cef4d94ba181f6f742a351
7
- data.tar.gz: 736d2e7a69ededb1cc61d2cc6e6538c4ce1d187e58ea54a6c7dde845b6c22ac03d86b2677fdcd58d30e01c6dcdd39a79e00f1d83d608d510bbf571c66bb309d6
6
+ metadata.gz: 59db484754a91d810436e65063f705026bbbfdf042a141ca053d0555616a97e83a89cd59cb9654f7d9243ee28a0f81169d1e82f7697b5f55333ea4f55ec71abd
7
+ data.tar.gz: 397e276a16b5fc43603de1abdeb1594ccb3a13ed2709809299f1a68d1b536983a66d37ed5d41684cfeb6eb1e3bda381c8e4e121fb6dbacc0e1903973a3ffc6ce
@@ -53,15 +53,24 @@ module I18nliner
53
53
  private
54
54
 
55
55
  def apply_wrappers(string, wrappers)
56
+ # In rails 6.1+ views, sometimes an Object is used for the default, and that object needs to remain
57
+ # an object or it won't be recognized if it comes back as a string
58
+ return string if string.instance_of?(Object)
59
+
56
60
  string = string.html_safe? ? string.dup : ERB::Util.h(string)
57
61
  unless wrappers.is_a?(Hash)
58
62
  wrappers = Array(wrappers)
59
63
  wrappers = Hash[wrappers.each_with_index.map{ |w, i| ['*' * (1 + i), w]}]
60
64
  end
65
+ # If you are actually using nonprintable characters in your source string, you should feel ashamed
66
+ string.gsub!("\\\\", 26.chr)
67
+ string.gsub!("\\*", 27.chr)
61
68
  wrappers.sort_by{ |k, v| -k.length }.each do |k, v|
62
69
  pattern = pattern_for(k)
63
70
  string.gsub!(pattern, v)
64
71
  end
72
+ string.gsub!(27.chr, '*')
73
+ string.gsub!(26.chr, "\\")
65
74
  string.html_safe
66
75
  end
67
76
 
@@ -23,7 +23,7 @@ module I18nliner
23
23
  File.read(file)
24
24
  end
25
25
 
26
- if defined?(::Rails) && ::Rails.version > '4'
26
+ if defined?(::Rails)
27
27
  CONTROLLER_PATH = %r{\A(.*/)?app/controllers/(.*)_controller\.rb\z}
28
28
  def scope_for(path)
29
29
  scope = path.dup
@@ -77,6 +77,11 @@ describe I18nliner::Extensions::Core do
77
77
  expect(i18n.translate("*bacon* > narwhals", :wrappers => ['<b>\1</b>'])).
78
78
  to eq "<b>bacon</b> &gt; narwhals"
79
79
  end
80
+
81
+ it "should allow escaping asterisks and backslashes" do
82
+ result = i18n.translate("Hello \\\\*b\\*b*.", :wrapper => '<b>\1</b>')
83
+ expect(result).to eq 'Hello \<b>b*b</b>.'
84
+ end
80
85
  end
81
86
  end
82
87
 
@@ -9,7 +9,7 @@ describe I18nliner::Processors::RubyProcessor do
9
9
  end
10
10
 
11
11
  describe "#scope_for" do
12
- if defined?(::Rails) && ::Rails.version > '4'
12
+ if defined?(::Rails)
13
13
  context "with a controller" do
14
14
  subject { @processor.scope_for("app/controllers/foos/bars_controller.rb") }
15
15
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: i18nliner
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jon Jensen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-02-25 00:00:00.000000000 Z
11
+ date: 2022-08-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '3.0'
19
+ version: '6.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
- version: '3.0'
26
+ version: '6.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: ruby_parser
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -218,14 +218,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
218
218
  requirements:
219
219
  - - ">="
220
220
  - !ruby/object:Gem::Version
221
- version: 1.9.3
221
+ version: '2.7'
222
222
  required_rubygems_version: !ruby/object:Gem::Requirement
223
223
  requirements:
224
224
  - - ">="
225
225
  - !ruby/object:Gem::Version
226
226
  version: 1.3.5
227
227
  requirements: []
228
- rubygems_version: 3.0.3
228
+ rubygems_version: 3.1.6
229
229
  signing_key:
230
230
  specification_version: 4
231
231
  summary: I18n made simple