traco 0.2.4 → 0.2.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -3,11 +3,6 @@ module Traco
3
3
  def translates(*columns)
4
4
  set_up_once
5
5
  store_as_translatable_columns columns.map(&:to_sym)
6
-
7
- columns.each do |column|
8
- define_localized_reader column
9
- define_localized_writer column
10
- end
11
6
  end
12
7
 
13
8
  private
@@ -25,6 +20,11 @@ module Traco
25
20
 
26
21
  def store_as_translatable_columns(columns)
27
22
  self.translatable_columns |= columns
23
+
24
+ columns.each do |column|
25
+ define_localized_reader column
26
+ define_localized_writer column
27
+ end
28
28
  end
29
29
 
30
30
  def define_localized_reader(column)
@@ -1,3 +1,3 @@
1
1
  module Traco
2
- VERSION = "0.2.4"
2
+ VERSION = "0.2.5"
3
3
  end
@@ -2,7 +2,6 @@ require "spec_helper"
2
2
  require "traco"
3
3
 
4
4
  describe ActiveRecord::Base, ".translates" do
5
-
6
5
  it "should be available" do
7
6
  Post.should respond_to :translates
8
7
  end
@@ -27,11 +26,9 @@ describe ActiveRecord::Base, ".translates" do
27
26
  Post.new.should respond_to :title
28
27
  Post.new.should_not respond_to :body
29
28
  end
30
-
31
29
  end
32
30
 
33
31
  describe Post, ".translatable_columns" do
34
-
35
32
  before do
36
33
  Post.translates :title
37
34
  end
@@ -39,11 +36,9 @@ describe Post, ".translatable_columns" do
39
36
  it "should list the translatable columns" do
40
37
  Post.translatable_columns.should == [ :title ]
41
38
  end
42
-
43
39
  end
44
40
 
45
41
  describe Post, ".locales_for_column" do
46
-
47
42
  before do
48
43
  Post.translates :title
49
44
  end
@@ -54,12 +49,12 @@ describe Post, ".locales_for_column" do
54
49
  :fi, :en, :sv
55
50
  ]
56
51
  end
57
-
58
52
  end
59
53
 
60
54
  describe Post, "#title" do
61
-
62
- let(:post) { Post.new(:title_sv => "Hej", :title_en => "Halloa", :title_fi => "Moi moi") }
55
+ let(:post) {
56
+ Post.new(:title_sv => "Hej", :title_en => "Halloa", :title_fi => "Moi moi")
57
+ }
63
58
 
64
59
  before do
65
60
  Post.translates :title
@@ -93,11 +88,9 @@ describe Post, "#title" do
93
88
  post.title_fi = nil
94
89
  post.title.should be_nil
95
90
  end
96
-
97
91
  end
98
92
 
99
93
  describe Post, "#title=" do
100
-
101
94
  before do
102
95
  Post.translates :title
103
96
  I18n.locale = :sv
@@ -117,11 +110,9 @@ describe Post, "#title=" do
117
110
  post.title = "Privet"
118
111
  }.should raise_error(NoMethodError, /title_ru/)
119
112
  end
120
-
121
113
  end
122
114
 
123
115
  describe Post, ".human_attribute_name" do
124
-
125
116
  before do
126
117
  Post.translates :title
127
118
  I18n.locale = :sv
@@ -156,5 +147,4 @@ describe Post, ".human_attribute_name" do
156
147
  it "should pass through defaults" do
157
148
  Post.human_attribute_name(:body_sv, :default => "Boday").should == "Boday"
158
149
  end
159
-
160
150
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: traco
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.2.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-11-18 00:00:00.000000000 Z
12
+ date: 2012-11-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord
16
- requirement: &70337754840160 !ruby/object:Gem::Requirement
16
+ requirement: &70270314834900 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '3.0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70337754840160
24
+ version_requirements: *70270314834900
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: sqlite3
27
- requirement: &70337754839700 !ruby/object:Gem::Requirement
27
+ requirement: &70270314834440 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *70337754839700
35
+ version_requirements: *70270314834440
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rake
38
- requirement: &70337754839240 !ruby/object:Gem::Requirement
38
+ requirement: &70270314833940 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70337754839240
46
+ version_requirements: *70270314833940
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rspec
49
- requirement: &70337754838800 !ruby/object:Gem::Requirement
49
+ requirement: &70270314833520 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *70337754838800
57
+ version_requirements: *70270314833520
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: guard
60
- requirement: &70337754838320 !ruby/object:Gem::Requirement
60
+ requirement: &70270314833080 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '0'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *70337754838320
68
+ version_requirements: *70270314833080
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: guard-rspec
71
- requirement: &70337754837840 !ruby/object:Gem::Requirement
71
+ requirement: &70270314832640 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,7 +76,7 @@ dependencies:
76
76
  version: '0'
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *70337754837840
79
+ version_requirements: *70270314832640
80
80
  description:
81
81
  email:
82
82
  - henrik@barsoom.se