localization 2.0.0 → 2.0.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: 6b54429be21e9c5cf5bb33fd0331997af284d9cd
4
- data.tar.gz: c206fda50299a375a6467e2bcfe6822c7c3ad812
3
+ metadata.gz: e7558ebec4986dc1feb1b4df6e5ff59384c57ef9
4
+ data.tar.gz: 4da1907e712acb41b1f4e48b974a70b29ba6c888
5
5
  SHA512:
6
- metadata.gz: 53b8ec32e2d25501a6f5def2c931b4e9a442e17c4a586cfaebc921ccd4d84bdd54754ae635db2ec4b9c71ba76ce92bd70baba24c6583ff964e429851659dd407
7
- data.tar.gz: b8b7ad1bd6284ed65947598b404622901448bc04e2bed39912a3cd87a63847d6c5dc82a78fa27a7473de7a4c388b48cf320c0b7769a1be5a5966fb03a1268a2b
6
+ metadata.gz: 6504db30636dd52dd4167cd4c9a3f0132cfecd08144c5318f88268a7acd0b822092d404fafb932d069c114285d83229002b4ca6c49646ca174e20518dcdb5aad
7
+ data.tar.gz: a76fada2cd8ed09304b4e885722de3a800a0e6580f4f11ac01d1733bb63b6522924786162b225abed7c1583e0859e92b98b9eced49d3fdc673780210d5778dc7
@@ -12,10 +12,14 @@ class Localization
12
12
  @@sources
13
13
  end
14
14
 
15
- def initialize(tree = nil, assignments = nil, parent = nil)
16
- @assignments = assignments || {}
17
- @parent = parent
18
- @tree = tree || default_tree
15
+ def initialize(tree = nil, assignments = nil, parent = nil, error = nil)
16
+ unless error
17
+ @assignments = assignments || {}
18
+ @parent = parent
19
+ @tree = tree || default_tree
20
+ else
21
+ @error = error
22
+ end
19
23
  end
20
24
 
21
25
  def method_missing(name, *arguments, &block)
@@ -24,12 +28,12 @@ class Localization
24
28
  Localization.new(@tree[name.to_s], arguments.first, self)
25
29
  when !@parent.nil?
26
30
  @parent.send(name, arguments.first)
27
- else "Localized text missing for #{name}"
31
+ else Localization.new(nil, nil, nil, @error || "Localized text missing for #{name}")
28
32
  end
29
33
  end
30
34
 
31
35
  def to_s
32
- Mustache.render(@tree, @assignments)
36
+ @error || Mustache.render(@tree, @assignments)
33
37
  end
34
38
 
35
39
  private
@@ -1,3 +1,3 @@
1
1
  class Localization
2
- VERSION = "2.0.0"
2
+ VERSION = "2.0.1"
3
3
  end
@@ -58,12 +58,16 @@ describe Localization do
58
58
  end
59
59
 
60
60
  it "returns content any level up if it can find it" do
61
- expect(content.header.to_s).to eq("Funworld")
61
+ expect(content.name.to_s).to eq("Funworld")
62
62
  end
63
63
 
64
64
  it "returns unfindable message if it can never find it" do
65
65
  expect(content.woop.to_s).to eq("Localized text missing for woop")
66
66
  end
67
+
68
+ it "returns unfindable message even if we call other stuff on it" do
69
+ expect(content.woop.foop.to_s).to eq("Localized text missing for woop")
70
+ end
67
71
  end
68
72
 
69
73
  # def roots
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: localization
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kurtis Rainbolt-Greene