titlezilla 0.1.2 → 0.1.3

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: b86a9199b181239e752411d423764f57bb60f431
4
- data.tar.gz: 743bf1cedb88954e8a747d4506dae2a9a2d89874
3
+ metadata.gz: 0eecbd86111fab30e1ca161d993a104d1834572c
4
+ data.tar.gz: baa72c194765f3d389eb7a6c6f78644c1c175cfd
5
5
  SHA512:
6
- metadata.gz: 55b3f176b14501205bf99041b208868206aa4ed4f2ac82309655f85da770609fddced5b90b69c4db4bc9ba2cb5bfb31d69165ed81df6f02c79f2ec7b5436f926
7
- data.tar.gz: 8533306134666c3f7a96602d3f44c4985d527543389f471f3e0c9770c85333144a6d56a4204f564f009429b7440298657292e2bd34ec14e3104cd409732d3541
6
+ metadata.gz: 89695306ef894bbc08471cf924b309c6ca98100c19c83f94a4275b0bcbf8f00abee049cc69cfb495d0ce2c83981ac2218b2fd648578649b057e2267f7f500757
7
+ data.tar.gz: 962b3735897a7f99a0bb330d90c2656d0a751bf81b8d85b2176f791cb254c4f76725d7945e4ecd257e30e7764d0ce6129c1026680b748d56637f4b96e81ea54e
@@ -19,7 +19,7 @@ module Titlezilla
19
19
  end
20
20
 
21
21
  def application_title
22
- @application_title ||= lookup('application')
22
+ @application_title ||= reverse_lookup('application')
23
23
  end
24
24
 
25
25
  def meta_title
@@ -34,12 +34,25 @@ module Titlezilla
34
34
  if parts.size > 1
35
35
  [parts[(0...-1)], parts[-1]]
36
36
  else
37
- [nil, parts[0].to_s.freeze]
37
+ [[], parts[0].to_s.freeze]
38
38
  end
39
39
  end
40
40
 
41
41
  def lookup(*key)
42
- t_key = [:titles, namespace, key].flatten.compact.join('.')
42
+ lookup_with_namespace(key, namespace)
43
+ end
44
+
45
+ def reverse_lookup(*key)
46
+ title_namespace = namespace.dup
47
+ begin
48
+ title = lookup_with_namespace(key, title_namespace)
49
+ return title if title
50
+ title_namespace.pop
51
+ end while title_namespace.size >= 0
52
+ end
53
+
54
+ def lookup_with_namespace(keys, namespace)
55
+ t_key = [:titles, namespace, keys].flatten.compact.join('.')
43
56
  i18n_set?(t_key) ? I18n.t(t_key, context) : nil
44
57
  end
45
58
 
@@ -1,3 +1,3 @@
1
1
  module Titlezilla
2
- VERSION = '0.1.2'.freeze
2
+ VERSION = '0.1.3'.freeze
3
3
  end
@@ -70,6 +70,12 @@ module Titlezilla
70
70
  t = Translator.new('admin/main', :index)
71
71
  t.application_title.must_equal 'App'
72
72
  end
73
+
74
+ it 'should lookup application title when no namespaced app title provided' do
75
+ load_translations({ application: 'App' })
76
+ t = Translator.new('admin/main', :index)
77
+ t.application_title.must_equal 'App'
78
+ end
73
79
  end
74
80
 
75
81
  describe '#meta_title' do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: titlezilla
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Evgeny Likholetov