super_list 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +3 -3
- data/VERSION +1 -0
- data/lib/super_list.rb +8 -5
- data/test/super_list_test.rb +7 -3
- metadata +13 -12
data/README.rdoc
CHANGED
@@ -15,13 +15,13 @@
|
|
15
15
|
User.new(:gender => 'F').original_gender => 'F'
|
16
16
|
|
17
17
|
user = User.new(:gender => 'F', :gender2 => 'M')
|
18
|
-
user.gender2 => "translation missing: en.Gender.
|
19
|
-
user.gender2(:locale => "api") => "translation missing: api.Gender.
|
18
|
+
user.gender2 => "translation missing: en.Gender.Man"
|
19
|
+
user.gender2(:locale => "api") => "translation missing: api.Gender.Man"
|
20
20
|
|
21
21
|
SuperList["Gender"].options => {:use_i18n=>false, :i18n_scope=>"Gender", :allow_blank=>true}
|
22
22
|
SuperList["Gender"].keys => ["M", "F"]
|
23
23
|
SuperList["Gender"].values(:use_i18n => true, :locale => 'zh')
|
24
|
-
=> ["translation missing: zh.Gender1.
|
24
|
+
=> ["translation missing: zh.Gender1.Man", "translation missing: zh.Gender1.Female"]
|
25
25
|
|
26
26
|
|
27
27
|
== Contributing to super_list
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
1.0.1
|
data/lib/super_list.rb
CHANGED
@@ -35,11 +35,14 @@ class SuperList
|
|
35
35
|
|
36
36
|
def get_value(key,options={})
|
37
37
|
options = @options.merge(options)
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
38
|
+
key = @values[key]
|
39
|
+
|
40
|
+
return I18n.t(key, :scope => options[:i18n_scope], :default => options[:i18n_default], :locale => options[:locale]) if options[:use_i18n]
|
41
|
+
key
|
42
|
+
end
|
43
|
+
|
44
|
+
def get_key(value,options={})
|
45
|
+
keys[values(options).index(value)] rescue nil
|
43
46
|
end
|
44
47
|
|
45
48
|
def options
|
data/test/super_list_test.rb
CHANGED
@@ -5,7 +5,11 @@ class SuperListTest < ActiveSupport::TestCase
|
|
5
5
|
assert_equal SuperList["Gender"].keys, ["M","F"]
|
6
6
|
assert_equal SuperList["Gender"].values, ["Man", "Female"]
|
7
7
|
assert_equal SuperList["Gender1"].values(:locale => 'zh'),
|
8
|
-
["translation missing: zh.Gender1.
|
8
|
+
["translation missing: zh.Gender1.Man", "translation missing: zh.Gender1.Female"]
|
9
|
+
|
10
|
+
assert_equal SuperList["Gender"].get_value("M"), "Man"
|
11
|
+
assert_equal SuperList["Gender"].get_key("Man"), "M"
|
12
|
+
assert_equal SuperList["Gender1"].get_key("translation missing: en.Gender1.Female"), "F"
|
9
13
|
end
|
10
14
|
|
11
15
|
test "only valid when included" do
|
@@ -28,8 +32,8 @@ class SuperListTest < ActiveSupport::TestCase
|
|
28
32
|
|
29
33
|
test "SuperList gender (use i18n, no default translation)" do
|
30
34
|
u = Factory(:user, :gender1 => 'F')
|
31
|
-
assert_equal u.gender1, "translation missing: en.Gender.
|
32
|
-
assert_equal u.gender1(:locale => 'new_locale'), "translation missing: new_locale.Gender.
|
35
|
+
assert_equal u.gender1, "translation missing: en.Gender.Female"
|
36
|
+
assert_equal u.gender1(:locale => 'new_locale'), "translation missing: new_locale.Gender.Female"
|
33
37
|
end
|
34
38
|
|
35
39
|
test "SuperList gender (use i18n wtih default translation)" do
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: super_list
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 21
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 1.0.
|
9
|
+
- 1
|
10
|
+
version: 1.0.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Jinzhu
|
@@ -15,11 +15,10 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-02-
|
18
|
+
date: 2011-02-28 00:00:00 +08:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
22
|
-
type: :development
|
23
22
|
version_requirements: &id001 !ruby/object:Gem::Requirement
|
24
23
|
none: false
|
25
24
|
requirements:
|
@@ -34,8 +33,8 @@ dependencies:
|
|
34
33
|
requirement: *id001
|
35
34
|
prerelease: false
|
36
35
|
name: bundler
|
37
|
-
- !ruby/object:Gem::Dependency
|
38
36
|
type: :development
|
37
|
+
- !ruby/object:Gem::Dependency
|
39
38
|
version_requirements: &id002 !ruby/object:Gem::Requirement
|
40
39
|
none: false
|
41
40
|
requirements:
|
@@ -50,8 +49,8 @@ dependencies:
|
|
50
49
|
requirement: *id002
|
51
50
|
prerelease: false
|
52
51
|
name: jeweler
|
53
|
-
- !ruby/object:Gem::Dependency
|
54
52
|
type: :development
|
53
|
+
- !ruby/object:Gem::Dependency
|
55
54
|
version_requirements: &id003 !ruby/object:Gem::Requirement
|
56
55
|
none: false
|
57
56
|
requirements:
|
@@ -64,8 +63,8 @@ dependencies:
|
|
64
63
|
requirement: *id003
|
65
64
|
prerelease: false
|
66
65
|
name: rcov
|
67
|
-
- !ruby/object:Gem::Dependency
|
68
66
|
type: :development
|
67
|
+
- !ruby/object:Gem::Dependency
|
69
68
|
version_requirements: &id004 !ruby/object:Gem::Requirement
|
70
69
|
none: false
|
71
70
|
requirements:
|
@@ -78,8 +77,8 @@ dependencies:
|
|
78
77
|
requirement: *id004
|
79
78
|
prerelease: false
|
80
79
|
name: sqlite3-ruby
|
81
|
-
- !ruby/object:Gem::Dependency
|
82
80
|
type: :development
|
81
|
+
- !ruby/object:Gem::Dependency
|
83
82
|
version_requirements: &id005 !ruby/object:Gem::Requirement
|
84
83
|
none: false
|
85
84
|
requirements:
|
@@ -94,8 +93,8 @@ dependencies:
|
|
94
93
|
requirement: *id005
|
95
94
|
prerelease: false
|
96
95
|
name: rails
|
97
|
-
- !ruby/object:Gem::Dependency
|
98
96
|
type: :development
|
97
|
+
- !ruby/object:Gem::Dependency
|
99
98
|
version_requirements: &id006 !ruby/object:Gem::Requirement
|
100
99
|
none: false
|
101
100
|
requirements:
|
@@ -110,8 +109,8 @@ dependencies:
|
|
110
109
|
requirement: *id006
|
111
110
|
prerelease: false
|
112
111
|
name: capybara
|
113
|
-
- !ruby/object:Gem::Dependency
|
114
112
|
type: :development
|
113
|
+
- !ruby/object:Gem::Dependency
|
115
114
|
version_requirements: &id007 !ruby/object:Gem::Requirement
|
116
115
|
none: false
|
117
116
|
requirements:
|
@@ -124,6 +123,7 @@ dependencies:
|
|
124
123
|
requirement: *id007
|
125
124
|
prerelease: false
|
126
125
|
name: factory_girl
|
126
|
+
type: :development
|
127
127
|
description: super list
|
128
128
|
email: wosmvp@gmail.com
|
129
129
|
executables: []
|
@@ -140,6 +140,7 @@ files:
|
|
140
140
|
- LICENSE.txt
|
141
141
|
- README.rdoc
|
142
142
|
- Rakefile
|
143
|
+
- VERSION
|
143
144
|
- lib/super_list.rb
|
144
145
|
- super_list.gemspec
|
145
146
|
- test/dummy/Rakefile
|
@@ -213,7 +214,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
213
214
|
requirements: []
|
214
215
|
|
215
216
|
rubyforge_project:
|
216
|
-
rubygems_version: 1.4.
|
217
|
+
rubygems_version: 1.4.1
|
217
218
|
signing_key:
|
218
219
|
specification_version: 3
|
219
220
|
summary: super list
|