traducto 1.0.4 → 1.0.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
  SHA1:
3
- metadata.gz: dc68ea3c2de967b1f946c41eac30cc5f2a560fd2
4
- data.tar.gz: 640369a35edb3f9a4243d3cdf818b455988e87d7
3
+ metadata.gz: eac718f024196cc622b16f3d6787ae8ad84ffaa0
4
+ data.tar.gz: 2e44ae2b70124640e05d80ad8ab8433afe46d0ba
5
5
  SHA512:
6
- metadata.gz: e67a80e679bcbf5404ba2d18ab8df528f3bdd6c687477b02275481004fccde245e72cf80e921ecbbb2f6a520caf386ba2aff83cc57ea71bd843afca2d7393300
7
- data.tar.gz: 8bd8b31f4e77d2903ede0db155fed1c5e41fefa2dc5fccabc3ad2092b79cc13855b9b7aff215d2c87fc2b98a2ade43fbbed8b3a3f32f756a77522158a1d20c5a
6
+ metadata.gz: d05a66de93abe039aba736f0d91857e7133428998d32137ba9245dd29081fea7d8df3b34bc0b7ee118d53f135c90a5ed1291dd6b04ae071c65ccf3936d50ed01
7
+ data.tar.gz: 1a348c672cdc2f81c424c419cbadfd9c39dd3358996b1206fecf2849a2b2f3243ae3141f55afbe6675d420189d19f4aa90406959b532d5a10b26cf226a320ac7
data/lib/traducto/base.rb CHANGED
@@ -43,6 +43,7 @@ module Traducto
43
43
  def format
44
44
  case @options[:format]
45
45
  when :text then format_text
46
+ when :list then format_list
46
47
  else format_base
47
48
  end
48
49
  end
@@ -51,6 +52,13 @@ module Traducto
51
52
  @text = @text.join("\n") if @text.is_a? Array
52
53
  end
53
54
 
55
+ def format_list
56
+ @text = [@text] if not @text.is_a? Array
57
+
58
+ @text = @text.map { |x| content_tag(:li, x.html_safe) }.join.html_safe
59
+ @text = content_tag(:ul, @text)
60
+ end
61
+
54
62
  def format_text
55
63
  @text = [@text] if not @text.is_a? Array
56
64
 
@@ -71,5 +71,17 @@ describe Traducto::Base do
71
71
  end
72
72
  end
73
73
 
74
+ context "with the key task_list having the value ['item1', 'item2', 'item3']" do
75
+ before { I18n.stub('translate').with('task_list', anything()).and_return(['item1', 'item2', 'item3']) }
76
+
77
+ context "when translating the key 'task_list' with a list format" do
78
+ before { @base = Traducto::Base.new(ActionView::Base.new) }
79
+
80
+ subject { @base.translate('task_list', format: :list) }
81
+
82
+ it { should eql '<ul><li>item1</li><li>item2</li><li>item3</li></ul>' }
83
+ end
84
+ end
85
+
74
86
  end
75
87
  end
@@ -11,5 +11,13 @@ describe Traducto::Helpers do
11
11
 
12
12
  it { should eql '<p>Hello!</p>' }
13
13
  end
14
+
15
+ context "with the key list being an array" do
16
+ before { I18n.stub('translate').with('list', anything()).and_return(['item1', 'item2', 'item3']) }
17
+
18
+ subject { action_view.t('list') }
19
+
20
+ it { should eql "item1\nitem2\nitem3" }
21
+ end
14
22
  end
15
23
  end
data/traducto.gemspec CHANGED
@@ -3,7 +3,7 @@ Gem::Specification.new do |gem|
3
3
  gem.description = "Rails helpers collection to simplify the localization code."
4
4
  gem.summary = "Rails helpers collection to simplify the localization code."
5
5
  gem.homepage = "https://github.com/alchimikweb/traducto"
6
- gem.version = "1.0.4"
6
+ gem.version = "1.0.5"
7
7
  gem.licenses = ["MIT"]
8
8
 
9
9
  gem.authors = ["Sebastien Rosa"]
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: traducto
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sebastien Rosa
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-21 00:00:00.000000000 Z
11
+ date: 2014-08-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails