enumerate_it 1.1.0 → 1.1.1
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/Gemfile.lock +1 -1
- data/README.rdoc +1 -0
- data/lib/enumerate_it/base.rb +2 -1
- data/lib/enumerate_it/version.rb +1 -1
- data/spec/enumerate_it/base_spec.rb +9 -3
- data/spec/support/test_classes.rb +2 -1
- metadata +5 -5
data/Gemfile.lock
CHANGED
data/README.rdoc
CHANGED
@@ -133,6 +133,7 @@ The `sort_by` methods accept one of the following values:
|
|
133
133
|
* `:translation`: The default behavior, will sort the returned values based on translations.
|
134
134
|
* `:value`: Will sort the returned values based on values.
|
135
135
|
* `:name`: Will sort the returned values based on the name of each enumeration option.
|
136
|
+
* `:none`: Will return values in order that was passed to associate_values call.
|
136
137
|
|
137
138
|
== Using enumerations
|
138
139
|
|
data/lib/enumerate_it/base.rb
CHANGED
@@ -81,7 +81,8 @@ module EnumerateIt
|
|
81
81
|
{
|
82
82
|
:value => lambda { |k, v| v[0] },
|
83
83
|
:name => lambda { |k, v| k },
|
84
|
-
:translation => lambda { |k, v| translate(v[1]) }
|
84
|
+
:translation => lambda { |k, v| translate(v[1]) },
|
85
|
+
:none => lambda { |k, v| nil }
|
85
86
|
}[sort_mode || :translation]
|
86
87
|
end
|
87
88
|
|
data/lib/enumerate_it/version.rb
CHANGED
@@ -132,19 +132,25 @@ describe EnumerateIt::Base do
|
|
132
132
|
context "by value" do
|
133
133
|
let(:sort_mode) { :value }
|
134
134
|
|
135
|
-
it { should == [["xyz", "1"], ["fgh", "2"], ["abc", "3"]] }
|
135
|
+
it { should == [["jkl", "0"], ["xyz", "1"], ["fgh", "2"], ["abc", "3"]] }
|
136
136
|
end
|
137
137
|
|
138
138
|
context "by name" do
|
139
139
|
let(:sort_mode) { :name }
|
140
140
|
|
141
|
-
it { should == [["fgh", "2"], ["xyz", "1"], ["abc", "3"]] }
|
141
|
+
it { should == [["fgh", "2"], ["xyz", "1"], ["abc", "3"], ["jkl", "0"]] }
|
142
142
|
end
|
143
143
|
|
144
144
|
context "by translation" do
|
145
145
|
let(:sort_mode) { :translation }
|
146
146
|
|
147
|
-
it { should == [["abc", "3"] ,["fgh", "2"], ["xyz", "1"]] }
|
147
|
+
it { should == [["abc", "3"] ,["fgh", "2"], ["jkl", "0"], ["xyz", "1"]] }
|
148
|
+
end
|
149
|
+
|
150
|
+
context "by nothing" do
|
151
|
+
let(:sort_mode) { :none }
|
152
|
+
|
153
|
+
it { should == [["xyz", "1"], ["fgh", "2"], ["abc", "3"], ["jkl", "0"] ] }
|
148
154
|
end
|
149
155
|
end
|
150
156
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: enumerate_it
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-07-
|
12
|
+
date: 2013-07-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
@@ -158,7 +158,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
158
158
|
version: '0'
|
159
159
|
segments:
|
160
160
|
- 0
|
161
|
-
hash:
|
161
|
+
hash: -817288258794681256
|
162
162
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
163
163
|
none: false
|
164
164
|
requirements:
|
@@ -167,10 +167,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
167
167
|
version: '0'
|
168
168
|
segments:
|
169
169
|
- 0
|
170
|
-
hash:
|
170
|
+
hash: -817288258794681256
|
171
171
|
requirements: []
|
172
172
|
rubyforge_project:
|
173
|
-
rubygems_version: 1.8.
|
173
|
+
rubygems_version: 1.8.25
|
174
174
|
signing_key:
|
175
175
|
specification_version: 3
|
176
176
|
summary: Ruby Enumerations
|