translatr 0.1.1 → 0.1.2

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.
@@ -66,7 +66,7 @@ module Translatr
66
66
  vars = text_string.gsub(/%\{(\w+)\}/).to_a
67
67
  return nil if vars.empty?
68
68
  return [vars[0]] if vars.size == 1
69
- vars
69
+ vars.uniq
70
70
  end
71
71
 
72
72
  def matching_variables?(target_string, source_string)
@@ -1,3 +1,3 @@
1
1
  module Translatr
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
@@ -112,6 +112,12 @@ module Translatr
112
112
  merger.merge.should == { :foo => "target", :bar => "source %{baz}" }
113
113
  end
114
114
 
115
+ it "works with entries where variables match but their numbers differ" do
116
+ merger.target = { :foo => "target %{bar}", :bar => "target %{baz} %{baz}" }
117
+ merger.source = { :foo => "source %{bar} %{bar}", :bar => "source %{baz}"}
118
+ merger.merge.should == { :foo => "source %{bar} %{bar}", :bar => "source %{baz}" }
119
+ end
120
+
115
121
  it "ignores entries with markup when target has none and key doesn't end with '_html'"
116
122
  end
117
123
 
@@ -127,6 +133,10 @@ module Translatr
127
133
  it "gives a list of variables in a string" do
128
134
  merger.variables_in("foo %{bar}, %{baz}").should == ["%{bar}", "%{baz}"]
129
135
  end
136
+
137
+ it "gives duplicate variables only once" do
138
+ merger.variables_in("foo %{bar}, %{bar}").should == ["%{bar}"]
139
+ end
130
140
  end
131
141
 
132
142
  describe "#store" do
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: translatr
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.1.1
5
+ version: 0.1.2
6
6
  platform: ruby
7
7
  authors:
8
8
  - Garret Alfert