nameable_record 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -22,6 +22,10 @@ module NameableRecord
22
22
  self == another_name
23
23
  end
24
24
 
25
+ def <=>( another_name )
26
+ self.to_s( :full_with_middle ) <=> another_name.to_s( :full_with_middle )
27
+ end
28
+
25
29
  # Creates a name based on pattern provided. Defaults to last, first.
26
30
  #
27
31
  # Symbols:
@@ -56,8 +60,8 @@ module NameableRecord
56
60
  /%s/ => :suffix
57
61
  }.freeze
58
62
 
59
- PREFIX_BASE = %w(Mr Mrs Miss Dr General) # The order of this matters because of PREFIXES_CORRECTIONS
60
- SUFFIX_BASE = %w(Jr III V IV Esq) # The order of this matters because of SUFFIXES_CORRECTIONS
63
+ PREFIX_BASE = %w(Mr Mrs Miss Dr General Pastor Bishop Agent Rep) # The order of this matters because of PREFIXES_CORRECTIONS
64
+ SUFFIX_BASE = %w(Jr III V IV Esq MD DDS) # The order of this matters because of SUFFIXES_CORRECTIONS
61
65
 
62
66
  PREFIXES = PREFIX_BASE.map { |p| [p, "#{p}.", p.upcase, "#{p.upcase}.", p.downcase, "#{p.downcase}."] }.flatten.sort
63
67
  SUFFIXES = SUFFIX_BASE.map { |p| [p, "#{p}.", p.upcase, "#{p.upcase}.", p.downcase, "#{p.downcase}."] }.flatten.sort
@@ -1,4 +1,4 @@
1
1
  module NameableRecord
2
- VERSION = "1.0.0"
2
+ VERSION = "1.1.0"
3
3
  end
4
4
 
@@ -12,6 +12,10 @@ describe NameableRecord::Name do
12
12
  described_class.new *name_parts
13
13
  end
14
14
 
15
+ let :another_name_for_sorting do
16
+ described_class.new *%w(Smith Jason Mr. Jacob III)
17
+ end
18
+
15
19
  it 'should be frozen after initialization' do
16
20
  subject.should be_frozen
17
21
  end
@@ -21,6 +25,14 @@ describe NameableRecord::Name do
21
25
  subject.==( another_name ).should be_true
22
26
  end
23
27
 
28
+ context '#<=>' do
29
+
30
+ it 'should correctly sort' do
31
+ [name, another_name_for_sorting].sort.should == [another_name_for_sorting, name]
32
+ end
33
+
34
+ end
35
+
24
36
  context 'PREDEFINED_PATTERNS' do
25
37
 
26
38
  subject { described_class::PREDEFINED_PATTERNS }
@@ -55,7 +67,7 @@ describe NameableRecord::Name do
55
67
 
56
68
  subject { described_class::PREFIX_BASE.sort }
57
69
 
58
- it { should == %w(Mr Mrs Miss Dr General).sort }
70
+ it { should == %w(Mr Mrs Miss Dr General Agent Bishop Pastor Rep).sort }
59
71
 
60
72
  end
61
73
 
@@ -63,7 +75,7 @@ describe NameableRecord::Name do
63
75
 
64
76
  subject { described_class::SUFFIX_BASE.sort }
65
77
 
66
- it { should == %w(Jr III IV V Esq).sort }
78
+ it { should == %w(Jr III IV V Esq DDS MD).sort }
67
79
 
68
80
  end
69
81
 
@@ -71,7 +83,7 @@ describe NameableRecord::Name do
71
83
 
72
84
  subject { described_class::PREFIXES }
73
85
 
74
- it { should == ["DR", "DR.", "Dr", "Dr.", "GENERAL", "GENERAL.", "General", "General.", "MISS", "MISS.", "MR", "MR.", "MRS", "MRS.", "Miss", "Miss.", "Mr", "Mr.", "Mrs", "Mrs.", "dr", "dr.", "general", "general.", "miss", "miss.", "mr", "mr.", "mrs", "mrs."] }
86
+ it { should == ["AGENT", "AGENT.", "Agent", "Agent.", "BISHOP", "BISHOP.", "Bishop", "Bishop.", "DR", "DR.", "Dr", "Dr.", "GENERAL", "GENERAL.", "General", "General.", "MISS", "MISS.", "MR", "MR.", "MRS", "MRS.", "Miss", "Miss.", "Mr", "Mr.", "Mrs", "Mrs.", "PASTOR", "PASTOR.", "Pastor", "Pastor.", "REP", "REP.", "Rep", "Rep.", "agent", "agent.", "bishop", "bishop.", "dr", "dr.", "general", "general.", "miss", "miss.", "mr", "mr.", "mrs", "mrs.", "pastor", "pastor.", "rep", "rep."] }
75
87
 
76
88
  end
77
89
 
@@ -79,7 +91,7 @@ describe NameableRecord::Name do
79
91
 
80
92
  subject { described_class::SUFFIXES }
81
93
 
82
- it { should == ["ESQ", "ESQ.", "Esq", "Esq.", "III", "III", "III.", "III.", "IV", "IV", "IV.", "IV.", "JR", "JR.", "Jr", "Jr.", "V", "V", "V.", "V.", "esq", "esq.", "iii", "iii.", "iv", "iv.", "jr", "jr.", "v", "v."] }
94
+ it { should == ["DDS", "DDS", "DDS.", "DDS.", "ESQ", "ESQ.", "Esq", "Esq.", "III", "III", "III.", "III.", "IV", "IV", "IV.", "IV.", "JR", "JR.", "Jr", "Jr.", "MD", "MD", "MD.", "MD.", "V", "V", "V.", "V.", "dds", "dds.", "esq", "esq.", "iii", "iii.", "iv", "iv.", "jr", "jr.", "md", "md.", "v", "v."] }
83
95
 
84
96
  end
85
97
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nameable_record
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 19
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
+ - 1
8
9
  - 0
9
- - 0
10
- version: 1.0.0
10
+ version: 1.1.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jason Harrelson
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-11-08 00:00:00 -06:00
18
+ date: 2011-11-25 00:00:00 -06:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency