i18nliner 0.2.3 → 0.2.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bbb90fe50e15cd800c8fe6266435e6ad65da7f403939cbf619c866b843b6792e
4
- data.tar.gz: cf1778863ed5faf6346c491162c90acd52c0e51e4efda4a114bbd13e99f04ed7
3
+ metadata.gz: c65c8bd881edfdc231120af22f283b85770bfa2befdf3495d273848101393062
4
+ data.tar.gz: ce466b775c3e449efc57ba5d6083f59c8c5a0a63243a0301be8515dedca6c9f0
5
5
  SHA512:
6
- metadata.gz: 74400054da78cccfd58e5a54eb452bf46b79464ea2d398536acb62ff37cbba84b044c757cbf45c0950ab22f493dd3d0ac018613a6bcc66e2d40bcca34b36e507
7
- data.tar.gz: 05fddfa85858798700910737ba60e57e0e8da23605792fa6e822ce6ef524f5a98e41fb22face1ad9aed57f4ef9da7d1f0db797898273ffdf4ac71ac33de03dd5
6
+ metadata.gz: b4e7c18f79f693a815ea3f6b6b84f46be8b56d8e739cdf7c064e0d2632cef23138cfb1e75c344077c44ace0f9c63d4b79cce32f19c8df9a79a28f7a07a71e92d
7
+ data.tar.gz: 8455844299eeca26b8d017e17ccfca90172d597f942b5331069e2b07e409167e425c16ceb8d59511066b5035c96bdee587f1c2fa0abe6793987fc4d40a4cc3be
@@ -84,6 +84,9 @@ module I18nliner
84
84
  end
85
85
 
86
86
  def evaluate_expression(exp)
87
+ # value omissions in hashes will be nil and can just be considered UnsupportedExpression
88
+ # since they are equivalent to a method call
89
+ return UnsupportedExpression if exp.nil?
87
90
  return raw(exp) if exp.sexp_type == :lit
88
91
  return string_from(exp) if stringish?(exp)
89
92
  return hash_from(exp) if exp.sexp_type == :hash
@@ -2,8 +2,6 @@ require 'i18nliner/errors'
2
2
  require 'i18nliner/call_helpers'
3
3
  require 'i18nliner/extractors/sexp_helper'
4
4
  require 'nokogiri'
5
- require 'ruby_parser'
6
- require 'ruby2ruby'
7
5
 
8
6
  module I18nliner
9
7
  module PreProcessors
@@ -37,8 +35,14 @@ module I18nliner
37
35
  DEFINITIONS = [
38
36
  {:method => :link_to, :pattern => /link_to/, :arg => 0}
39
37
  ]
40
- RUBY2RUBY = Ruby2Ruby.new
41
- PARSER = RubyParser.new
38
+
39
+ def self.parser
40
+ @parser ||= (require 'ruby_parser'; RubyParser.new)
41
+ end
42
+
43
+ def self.ruby2ruby
44
+ @ruby2ruby ||= (require 'ruby2ruby'; Ruby2Ruby.new)
45
+ end
42
46
 
43
47
  def self.match_for(string)
44
48
  DEFINITIONS.each do |info|
@@ -60,7 +64,7 @@ module I18nliner
60
64
  def wrappable?
61
65
  return @wrappable if !@wrappable.nil?
62
66
  begin
63
- sexps = PARSER.parse(@source)
67
+ sexps = self.class.parser.parse(@source)
64
68
  @wrappable = sexps.sexp_type == :call &&
65
69
  sexps[1].nil? &&
66
70
  sexps[2] == @method &&
@@ -75,10 +79,10 @@ module I18nliner
75
79
  if stringish?(sexp)
76
80
  @content = string_from(sexp)
77
81
  else
78
- @placeholder = RUBY2RUBY.process(sexp)
82
+ @placeholder = self.class.ruby2ruby.process(sexp)
79
83
  end
80
84
  sexps[@arg + SEXP_ARG_OFFSET] = Sexp.new(:str, "\\1")
81
- @wrapper = RUBY2RUBY.process(sexps)
85
+ @wrapper = self.class.ruby2ruby.process(sexps)
82
86
  end
83
87
  end
84
88
 
@@ -49,6 +49,10 @@ describe I18nliner::Extractors::RubyExtractor do
49
49
  {'foo' => "Foo"})
50
50
  end
51
51
 
52
+ it "should handle omitted values in hashes" do
53
+ expect { extract("t('foo %{count}', count:)") }.not_to raise_error
54
+ end
55
+
52
56
  it "should bail on invalid t calls" do
53
57
  assert_error "t foo", I18nliner::InvalidSignatureError
54
58
  assert_error "t :foo, foo", I18nliner::InvalidSignatureError
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: i18nliner
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jon Jensen
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2023-03-01 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: activesupport
@@ -224,7 +223,6 @@ files:
224
223
  homepage: http://github.com/jenseng/i18nliner
225
224
  licenses: []
226
225
  metadata: {}
227
- post_install_message:
228
226
  rdoc_options: []
229
227
  require_paths:
230
228
  - lib
@@ -239,8 +237,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
239
237
  - !ruby/object:Gem::Version
240
238
  version: 1.3.5
241
239
  requirements: []
242
- rubygems_version: 3.1.6
243
- signing_key:
240
+ rubygems_version: 3.6.9
244
241
  specification_version: 4
245
242
  summary: I18n made simple
246
243
  test_files: []