traco 0.4.2 → 1.0.0
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.
- data/lib/traco/version.rb +1 -1
- data/spec/traco_spec.rb +23 -23
- metadata +15 -15
data/lib/traco/version.rb
CHANGED
data/spec/traco_spec.rb
CHANGED
@@ -2,17 +2,17 @@ require "spec_helper"
|
|
2
2
|
require "traco"
|
3
3
|
|
4
4
|
describe ActiveRecord::Base, ".translates" do
|
5
|
-
it "
|
5
|
+
it "is available" do
|
6
6
|
Post.should respond_to :translates
|
7
7
|
end
|
8
8
|
|
9
|
-
it "
|
9
|
+
it "adds functionality" do
|
10
10
|
Post.new.should_not respond_to :title
|
11
11
|
Post.translates :title
|
12
12
|
Post.new.should respond_to :title
|
13
13
|
end
|
14
14
|
|
15
|
-
it "
|
15
|
+
it "can be run more than once" do
|
16
16
|
Post.new.should_not respond_to :title, :body
|
17
17
|
Post.translates :title
|
18
18
|
Post.translates :body
|
@@ -33,7 +33,7 @@ describe Post, ".translatable_attributes" do
|
|
33
33
|
Post.translates :title
|
34
34
|
end
|
35
35
|
|
36
|
-
it "
|
36
|
+
it "lists the translatable attributes" do
|
37
37
|
Post.translatable_attributes.should == [ :title ]
|
38
38
|
end
|
39
39
|
end
|
@@ -43,7 +43,7 @@ describe Post, ".locales_for_attribute" do
|
|
43
43
|
Post.translates :title
|
44
44
|
end
|
45
45
|
|
46
|
-
it "
|
46
|
+
it "lists the locales, default first and then alphabetically" do
|
47
47
|
I18n.default_locale = :fi
|
48
48
|
Post.locales_for_attribute(:title).should == [
|
49
49
|
:fi, :en, :sv
|
@@ -56,7 +56,7 @@ describe Post, ".locale_columns" do
|
|
56
56
|
Post.translates :title
|
57
57
|
end
|
58
58
|
|
59
|
-
it "
|
59
|
+
it "lists the columns-with-locale for that attribute, default locale first and then alphabetically" do
|
60
60
|
I18n.default_locale = :fi
|
61
61
|
Post.locale_columns(:title).should == [
|
62
62
|
:title_fi, :title_en, :title_sv
|
@@ -75,34 +75,34 @@ describe Post, "#title" do
|
|
75
75
|
I18n.default_locale = :en
|
76
76
|
end
|
77
77
|
|
78
|
-
it "
|
78
|
+
it "gives the title in the current locale" do
|
79
79
|
post.title.should == "Hej"
|
80
80
|
end
|
81
81
|
|
82
|
-
it "
|
82
|
+
it "falls back to the default locale if locale has no column" do
|
83
83
|
I18n.locale = :ru
|
84
84
|
post.title.should == "Halloa"
|
85
85
|
end
|
86
86
|
|
87
|
-
it "
|
87
|
+
it "falls back to the default locale if blank" do
|
88
88
|
post.title_sv = " "
|
89
89
|
post.title.should == "Halloa"
|
90
90
|
end
|
91
91
|
|
92
|
-
it "
|
92
|
+
it "does not fall back to any other locale if default locale is blank" do
|
93
93
|
post.title_sv = " "
|
94
94
|
post.title_en = ""
|
95
95
|
post.title.should be_nil
|
96
96
|
end
|
97
97
|
|
98
|
-
it "
|
98
|
+
it "returns nil if all are blank" do
|
99
99
|
post.title_sv = " "
|
100
100
|
post.title_en = ""
|
101
101
|
post.title_fi = nil
|
102
102
|
post.title.should be_nil
|
103
103
|
end
|
104
104
|
|
105
|
-
it "
|
105
|
+
it "is overridable" do
|
106
106
|
class Post
|
107
107
|
def title
|
108
108
|
super.reverse
|
@@ -131,12 +131,12 @@ describe Post, "#title" do
|
|
131
131
|
I18n.default_locale = :en
|
132
132
|
end
|
133
133
|
|
134
|
-
it "
|
134
|
+
it "does not fall back to the default locale if locale has no column" do
|
135
135
|
I18n.locale = :ru
|
136
136
|
post.title.should be_nil
|
137
137
|
end
|
138
138
|
|
139
|
-
it "
|
139
|
+
it "does not fall back to the default locale if blank" do
|
140
140
|
I18n.locale = :sv
|
141
141
|
post.title_sv = " "
|
142
142
|
post.title.should be_nil
|
@@ -152,13 +152,13 @@ describe Post, "#title=" do
|
|
152
152
|
|
153
153
|
let(:post) { Post.new }
|
154
154
|
|
155
|
-
it "
|
155
|
+
it "assigns in the current locale" do
|
156
156
|
post.title = "Hej"
|
157
157
|
post.title.should == "Hej"
|
158
158
|
post.title_sv.should == "Hej"
|
159
159
|
end
|
160
160
|
|
161
|
-
it "
|
161
|
+
it "raises if locale has no column" do
|
162
162
|
I18n.locale = :ru
|
163
163
|
lambda {
|
164
164
|
post.title = "Privet"
|
@@ -172,33 +172,33 @@ describe Post, ".human_attribute_name" do
|
|
172
172
|
I18n.locale = :sv
|
173
173
|
end
|
174
174
|
|
175
|
-
it "
|
175
|
+
it "appends a known language name" do
|
176
176
|
Post.human_attribute_name(:title_en).should == "Titel (engelska)"
|
177
177
|
end
|
178
178
|
|
179
|
-
it "
|
179
|
+
it "uses abbreviation when language name is not known" do
|
180
180
|
Post.human_attribute_name(:title_fi).should == "Titel (FI)"
|
181
181
|
end
|
182
182
|
|
183
|
-
it "
|
183
|
+
it "yields to defined translations" do
|
184
184
|
Post.human_attribute_name(:title_sv).should == "Svensk titel"
|
185
185
|
end
|
186
186
|
|
187
|
-
it "
|
187
|
+
it "passes through the default behavior" do
|
188
188
|
Post.human_attribute_name(:title).should == "Titel"
|
189
189
|
end
|
190
190
|
|
191
|
-
it "
|
191
|
+
it "passes through untranslated columns" do
|
192
192
|
Post.human_attribute_name(:body_sv).should == "Body sv"
|
193
193
|
end
|
194
194
|
|
195
195
|
# ActiveModel::Errors#full_messages passes in an ugly default.
|
196
196
|
|
197
|
-
it "
|
197
|
+
it "does not yield to passed-in defaults" do
|
198
198
|
Post.human_attribute_name(:title_en, :default => "Title en").should == "Titel (engelska)"
|
199
199
|
end
|
200
200
|
|
201
|
-
it "
|
201
|
+
it "passes through defaults" do
|
202
202
|
Post.human_attribute_name(:body_sv, :default => "Boday").should == "Boday"
|
203
203
|
end
|
204
204
|
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.
|
4
|
+
version: 1.0.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2012-12-02 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activerecord
|
16
|
-
requirement: &
|
16
|
+
requirement: &70309902617740 !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: *
|
24
|
+
version_requirements: *70309902617740
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: sqlite3
|
27
|
-
requirement: &
|
27
|
+
requirement: &70309902616360 !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: *
|
35
|
+
version_requirements: *70309902616360
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rake
|
38
|
-
requirement: &
|
38
|
+
requirement: &70309902594640 !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: *
|
46
|
+
version_requirements: *70309902594640
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rspec
|
49
|
-
requirement: &
|
49
|
+
requirement: &70309902593020 !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: *
|
57
|
+
version_requirements: *70309902593020
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: guard
|
60
|
-
requirement: &
|
60
|
+
requirement: &70309902592000 !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: *
|
68
|
+
version_requirements: *70309902592000
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: guard-rspec
|
71
|
-
requirement: &
|
71
|
+
requirement: &70309902590820 !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: *
|
79
|
+
version_requirements: *70309902590820
|
80
80
|
description:
|
81
81
|
email:
|
82
82
|
- henrik@barsoom.se
|
@@ -115,7 +115,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
115
115
|
version: '0'
|
116
116
|
segments:
|
117
117
|
- 0
|
118
|
-
hash: -
|
118
|
+
hash: -4061996226247470670
|
119
119
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
120
120
|
none: false
|
121
121
|
requirements:
|
@@ -124,7 +124,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
124
124
|
version: '0'
|
125
125
|
segments:
|
126
126
|
- 0
|
127
|
-
hash: -
|
127
|
+
hash: -4061996226247470670
|
128
128
|
requirements: []
|
129
129
|
rubyforge_project:
|
130
130
|
rubygems_version: 1.8.5
|