selection_options_for 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -35,7 +35,7 @@ module SelectionOptionsFor
35
35
  end
36
36
  case label.size
37
37
  when 2
38
- letter, display_text = label[1].first, label[1]
38
+ raise "Invalid number of items. 2 part definition is no longer supported. Add the middle value for storage in the DB."
39
39
  when 3
40
40
  letter, display_text = label[1], label[2]
41
41
  else
@@ -1,3 +1,3 @@
1
1
  module SelectionOptionsFor
2
- VERSION = "0.0.6" unless defined? SelectionOptionsFor::VERSION
2
+ VERSION = "0.0.7" unless defined? SelectionOptionsFor::VERSION
3
3
  end
Binary file
Binary file
@@ -1,4 +1,4 @@
1
- ## ruby -Itest test/selection_options_for_ex_test.rb
1
+ ## ruby -Itest -Ilib test/selection_options_for_ex_test.rb
2
2
  require 'test_helper'
3
3
 
4
4
  #
@@ -6,26 +6,26 @@ require 'test_helper'
6
6
  #
7
7
 
8
8
  class ModelUnderTest < SuperModel::Base
9
- extend ModelAdditions
9
+ extend SelectionOptionsFor::ModelAdditions
10
10
 
11
11
  begin
12
12
  selection_options_for :price_option,
13
- [:basic, 'Basic' ],
14
- [:cash, 'Cash Account '],
15
- [:cc, 'R','Credit Card Account'],
13
+ [:basic, 'B', 'Basic' ],
14
+ [:cash, 'C', 'Cash Account '],
15
+ [:cc, 'R','Credit Card Account'],
16
16
  123
17
17
 
18
18
  rescue RuntimeError => ex
19
19
  @@exception_num = ex
20
20
  end
21
21
 
22
- def self.exception_num
23
- @@exception_num
24
- end
22
+ def self.exception_num
23
+ @@exception_num
24
+ end
25
25
 
26
26
  begin
27
27
  selection_options_for :status_option,
28
- [:basic, 'Basic' ],
28
+ [:basic, 'B', 'Basic' ],
29
29
  'Cash Account',
30
30
  [:cc, 'R','Credit Card Account']
31
31
 
@@ -33,10 +33,22 @@ class ModelUnderTest < SuperModel::Base
33
33
  @@exception_string = ex
34
34
  end
35
35
 
36
- def self.exception_string
37
- @@exception_string
38
- end
36
+ def self.exception_string
37
+ @@exception_string
38
+ end
39
39
 
40
+ begin
41
+ selection_options_for :gender_option,
42
+ [:male, 'B', 'Male' ],
43
+ [:female, 'Female'],
44
+ [:unknown, 'U', 'unknown' ]
45
+ rescue RuntimeError => ex
46
+ @@exception_deprecated = ex
47
+ end
48
+
49
+ def self.exception_deprecated
50
+ @@exception_deprecated
51
+ end
40
52
 
41
53
  end
42
54
 
@@ -57,5 +69,11 @@ class TranslateOptionsForExTest < Test::Unit::TestCase
57
69
  ModelUnderTest.exception_string.message
58
70
  end
59
71
 
72
+ def test_deprecated_format
73
+ assert_equal RuntimeError, ModelUnderTest.exception_deprecated.class
74
+ assert_equal "Invalid number of items. 2 part definition is no longer supported. Add the middle value for storage in the DB.",
75
+ ModelUnderTest.exception_deprecated.message
76
+ end
77
+
60
78
 
61
79
  end
@@ -1,4 +1,4 @@
1
- ## ruby -Itest test/selection_options_for_test.rb
1
+ ## ruby -Itest -Ilib test/selection_options_for_test.rb
2
2
  require 'test_helper'
3
3
 
4
4
  #
@@ -10,23 +10,23 @@ require 'test_helper'
10
10
  #
11
11
 
12
12
  class SiblingOfModelUnderTest < SuperModel::Base
13
- extend ModelAdditions
13
+ extend SelectionOptionsFor::ModelAdditions
14
14
  end
15
15
 
16
16
  class ModelUnderTest < SuperModel::Base
17
- extend ModelAdditions
17
+ extend SelectionOptionsFor::ModelAdditions
18
18
 
19
19
  selection_options_for :status_option,
20
- [:partial, 'Partial Registration'],
21
- [:active, 'Active'],
20
+ [:partial, 'P', 'Partial Registration'],
21
+ [:active, 'A', 'Active'],
22
22
  [:changing_email, 'E', 'Active, Changing Email'],
23
- [:inactive, 'Inactive'],
23
+ [:inactive, 'I', 'Inactive'],
24
24
  [:forgot_pw, 'F', 'Active, Forgot Password' ]
25
25
 
26
26
  selection_options_for :payment_method_option,
27
- [:basic, 'Basic'],
28
- [:cash, 'Cash Account'],
29
- [:cc, 'R','Credit Card Account']
27
+ [:basic, 'B', 'Basic'],
28
+ [:cash, 'C', 'Cash Account'],
29
+ [:cc, 'R', 'Credit Card Account']
30
30
 
31
31
  selection_options_for :sorted_option,
32
32
  [:none, 'H', 'Honorary Member'],
@@ -39,8 +39,8 @@ class ModelUnderTest < SuperModel::Base
39
39
 
40
40
  class SubClassOfModel < ModelUnderTest
41
41
  selection_options_for :payment_method_option,
42
- [:advanced, 'Advanced'],
43
- [:ecash, 'ECash Account']
42
+ [:advanced, 'A', 'Advanced'],
43
+ [:ecash, 'E', 'ECash Account']
44
44
  end
45
45
 
46
46
  class SelectionOptionsForTest < Test::Unit::TestCase
@@ -49,7 +49,7 @@ class SelectionOptionsForTest < Test::Unit::TestCase
49
49
  end
50
50
 
51
51
  def test_should_provide_symbols
52
- expected = {"Basic"=>:basic, "Cash Account"=>:cash, "R"=>:cc}
52
+ expected = {"B"=>:basic, "C"=>:cash, "R"=>:cc}
53
53
  assert_equal expected, ModelUnderTest.payment_method_option_symbols
54
54
  end
55
55
 
@@ -94,40 +94,35 @@ class SelectionOptionsForTest < Test::Unit::TestCase
94
94
  flunk "wrong exception thrown"
95
95
  end
96
96
 
97
- def test_each_subclass_has_own_symbols
98
-
99
- assert_equal [["Advanced", "Advanced"], ["ECash Account", "ECash Account"]].sort ,
97
+ def test_each_subclass_has_own_symbols
98
+ assert_equal [["Advanced", "A"], ["ECash Account", "E"]] ,
100
99
  SubClassOfModel.payment_method_options.sort
101
100
  end
102
101
 
103
102
  def test_payment_method_option_array
104
-
105
- assert_equal [["Basic", "Basic"],
106
- ["Cash Account", "Cash Account"],
107
- ["Credit Card Account", "R"]].sort ,
108
- @model.payment_method_options.sort
103
+ assert_equal [["Basic", "B"], ["Cash Account", "C"], ["Credit Card Account", "R"]],
104
+ @model.payment_method_options.sort
109
105
  end
110
106
 
111
107
  def test_default_status
112
108
  target = @model.new
113
109
  target.status_option_forgot_pw!
114
110
  assert_equal 'Active, Forgot Password', target.status_option_label
115
- target.status_option = 'Active'
111
+ target.status_option = 'A'
116
112
  assert_equal 'Active', target.status_option_label
117
113
  end
118
114
 
119
- def test_status_option_array
120
-
121
- assert_equal [["Active", "Active"],
115
+ def test_status_option_array
116
+ assert_equal [["Active", 'A'],
122
117
  ["Active, Changing Email", "E"],
123
118
  ["Active, Forgot Password", "F"],
124
- ["Inactive", "Inactive"],
125
- ["Partial Registration", "Partial Registration"]].sort ,
119
+ ["Inactive", "I"],
120
+ ["Partial Registration", 'P']].sort ,
126
121
  @model.status_options.sort
127
122
  end
128
123
 
129
124
  def test_default_payment_method_option_hash
130
- expected = {"Cash Account"=>"Cash Account", "R"=>"Credit Card Account", "Basic"=>"Basic"}
125
+ expected = {"B"=>"Basic", "C"=>"Cash Account", "R"=>"Credit Card Account"}
131
126
  assert_equal expected, @model.payment_method_option_hash
132
127
  end
133
128
 
metadata CHANGED
@@ -1,60 +1,62 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: selection_options_for
3
- version: !ruby/object:Gem::Version
4
- hash: 19
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.7
5
5
  prerelease:
6
- segments:
7
- - 0
8
- - 0
9
- - 6
10
- version: 0.0.6
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Mark Windholtz
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2012-03-22 00:00:00 Z
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
12
+ date: 2012-10-30 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
21
15
  name: supermodel
22
- prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
24
17
  none: false
25
- requirements:
26
- - - ">="
27
- - !ruby/object:Gem::Version
28
- hash: 3
29
- segments:
30
- - 0
31
- version: "0"
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
32
22
  type: :development
33
- version_requirements: *id001
34
- - !ruby/object:Gem::Dependency
35
- name: activerecord
36
23
  prerelease: false
37
- requirement: &id002 !ruby/object:Gem::Requirement
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: activerecord
32
+ requirement: !ruby/object:Gem::Requirement
38
33
  none: false
39
- requirements:
40
- - - ">="
41
- - !ruby/object:Gem::Version
42
- hash: 3
43
- segments:
44
- - 0
45
- version: "0"
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
46
38
  type: :runtime
47
- version_requirements: *id002
48
- description: "\n This code allows you to keep the display labels in the model \n when the DB holds only a 1 character flag.\n and when the code requires symbolic references to the value to use in algorithms\n \n element 0 of the array passed in is always the logical symbol\n If a 2-element Array is passed in, [key, label] and the first letter of label is the DB value\n If a 3-element Array is passed in, [key, DB value, label] \n Any other type passed in throws an error\n \n Limitations: Don't use this if you will run reports directly against the DB \n In that case, the reports will not have access to the display labels \n "
49
- email:
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ description: ! "\n This code allows you to keep the display labels in the model
47
+ \n when the DB holds only a 1 character flag.\n and when the code requires symbolic
48
+ references to the value to use in algorithms\n \n element 0 of the array passed
49
+ in is always the logical symbol\n If a 2-element Array is passed in, [key, label]
50
+ and the first letter of label is the DB value\n If a 3-element Array is passed
51
+ in, [key, DB value, label] \n Any other type passed in throws an error\n \n
52
+ \ Limitations: Don't use this if you will run reports directly against the DB \n
53
+ \ In that case, the reports will not have access to the display labels \n "
54
+ email:
50
55
  - mark@agiledna.com
51
56
  executables: []
52
-
53
57
  extensions: []
54
-
55
58
  extra_rdoc_files: []
56
-
57
- files:
59
+ files:
58
60
  - .DS_Store
59
61
  - CHANGELOG.md
60
62
  - Gemfile
@@ -66,45 +68,37 @@ files:
66
68
  - lib/selection_options_for/railtie.rb
67
69
  - lib/selection_options_for/version.rb
68
70
  - pkg/selection_options_for-0.0.5.gem
71
+ - pkg/selection_options_for-0.0.6.gem
72
+ - pkg/selection_options_for-0.0.7.gem
69
73
  - selection_options_for.gemspec
70
74
  - test/selection_options_for_ex_test.rb
71
75
  - test/selection_options_for_test.rb
72
76
  - test/test_helper.rb
73
77
  homepage: https://github.com/mwindholtz/selection_options_for
74
78
  licenses: []
75
-
76
79
  post_install_message:
77
80
  rdoc_options: []
78
-
79
- require_paths:
81
+ require_paths:
80
82
  - lib
81
- required_ruby_version: !ruby/object:Gem::Requirement
83
+ required_ruby_version: !ruby/object:Gem::Requirement
82
84
  none: false
83
- requirements:
84
- - - ">="
85
- - !ruby/object:Gem::Version
86
- hash: 3
87
- segments:
88
- - 0
89
- version: "0"
90
- required_rubygems_version: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ! '>='
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ required_rubygems_version: !ruby/object:Gem::Requirement
91
90
  none: false
92
- requirements:
93
- - - ">="
94
- - !ruby/object:Gem::Version
95
- hash: 3
96
- segments:
97
- - 0
98
- version: "0"
91
+ requirements:
92
+ - - ! '>='
93
+ - !ruby/object:Gem::Version
94
+ version: '0'
99
95
  requirements: []
100
-
101
96
  rubyforge_project:
102
- rubygems_version: 1.8.17
97
+ rubygems_version: 1.8.24
103
98
  signing_key:
104
99
  specification_version: 3
105
100
  summary: Display labels and symbolic references
106
- test_files:
101
+ test_files:
107
102
  - test/selection_options_for_ex_test.rb
108
103
  - test/selection_options_for_test.rb
109
104
  - test/test_helper.rb
110
- has_rdoc: