super_list 1.1.0 → 1.2.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/README.rdoc CHANGED
@@ -20,10 +20,17 @@
20
20
  user.gender2.to_s => "translation missing: en.Gender.Man"
21
21
  user.gender2(:locale => "api").to_s => "translation missing: api.Gender.Man"
22
22
 
23
+ SuperList["Gender"].get_value("M").to_s, "Man"
24
+ SuperList["Gender"].get_key("Man"), "M"
25
+ SuperList["Gender1"].get_key("translation missing: en.Gender1.Female"), "F"
23
26
  SuperList["Gender"].options => {:use_i18n=>false, :i18n_scope=>"Gender", :allow_blank=>true}
24
27
  SuperList["Gender"].keys => ["M", "F"]
25
28
  SuperList["Gender"].values(:use_i18n => true, :locale => 'zh')
26
29
  => ["translation missing: zh.Gender1.Man", "translation missing: zh.Gender1.Female"]
30
+ assert_equal ["M","F"], SuperList["Gender"].map {|k,v| k }
31
+ assert_equal ["Man", "Female"], SuperList["Gender"].map {|k,v| v }
32
+
33
+ == Please refer {test file}[https://github.com/jinzhu/super_list/blob/master/test/super_list_test.rb] for more examples.
27
34
 
28
35
 
29
36
  == Contributing to super_list
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.1.0
1
+ 1.2.0
data/lib/super_list.rb CHANGED
@@ -48,6 +48,10 @@ class SuperList
48
48
  keys.map {|x| get_value(x, options).to_s(type) }
49
49
  end
50
50
 
51
+ def map(type=:default, options={}, &blk)
52
+ keys.zip(values(type,options)).map &blk
53
+ end
54
+
51
55
  def get_value(key,options={})
52
56
  options = @options.merge(options)
53
57
  value = @values[key]
@@ -10,6 +10,8 @@ class SuperListTest < ActiveSupport::TestCase
10
10
  assert_equal SuperList["Gender"].get_value("M").to_s, "Man"
11
11
  assert_equal SuperList["Gender"].get_key("Man"), "M"
12
12
  assert_equal SuperList["Gender1"].get_key("translation missing: en.Gender1.Female"), "F"
13
+ assert_equal ["M","F"], SuperList["Gender"].map {|k,v| k }
14
+ assert_equal ["Man", "Female"], SuperList["Gender"].map {|k,v| v }
13
15
  end
14
16
 
15
17
  test "only valid when included" 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: 19
4
+ hash: 31
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
- - 1
8
+ - 2
9
9
  - 0
10
- version: 1.1.0
10
+ version: 1.2.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jinzhu
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-03-04 00:00:00 +08:00
18
+ date: 2011-03-08 00:00:00 +08:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency