name_abbr 1.0.1 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +8 -8
  2. data/lib/name_abbr.rb +9 -4
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZGQ3MjI1ODgyOTVkMzI0Y2NiZTQyYmMxNmQxMjE0OWYwY2U3Nzc2Mg==
4
+ MGJmYjQ4MWRjZGJjNDFkMWM0MDJjMmVkMTE0MWZmMDIzNTk2OWYyZA==
5
5
  data.tar.gz: !binary |-
6
- YmI5YzcxYzYyMmJlY2ZjZmJmNDY0ZTExNjc5YzQ5YzI1MzljMDhkOQ==
6
+ MTRkYjhmOWE5OTk0Y2I3MGU4MTE2OTYyYWVlNjc0MmJiMzMxNjdhOA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MzgzZGI0NGQ5NDJmNDk2NDJmZTAzZGVlMzYwNGY2YWY1NTkxZGRmODNjOWY0
10
- ODRkMjM3ZGQyMjk5OWJhN2VkN2U3ZGVjOTNiNGZiZTliOTAyMjAwZDMzYTFk
11
- MjAwMmEwYTk2ODU0Njg1Yzk4YjE3ZDM2Y2UxMTlkZTczZTQwMjA=
9
+ NTgwMmI0ZDU5MzRiMmVhMzQ0NjYzMzliMWM4YTc3MjdiM2UzNTI4NDQyOTE2
10
+ NDM5NmY5MzExZmVjZjczZDQ3YjRhM2U1NDYwZmIwYzM2OTczZWUzNWJiNmMw
11
+ YzdjMjE5ODhhY2JlYjMyY2ZlMmE5ZGM3MmQ5M2Y3ZjRkOGRkOTY=
12
12
  data.tar.gz: !binary |-
13
- M2YzNjY2YjBiYmRkYjc5ZTM3MDc2ZGQzM2EyZmRlMWUwMGRmOTQ4ZTQ3MjQ5
14
- YTM3YzcxYmVjOTU3ZWVlNjIwNmE5OWM0NmJhODFhMjAxMzhhZWY3YzEyY2Fm
15
- YmU5ZGI2MzdmOGQ5ZWI3OTJlNjBkMWM4NzU2ZmZkZjYwMGZiZjM=
13
+ YTY2NTY0NTM3YTBhMDhjYTkwZTRmMGY2YzA2NGMyYmY3NWQ4ZGYxMjY5Mjdk
14
+ NWI1MWVlOWYzYzNmNmQwN2VkZmZjMjYxZjYyNzg4MzEzYWU0YTQ5ZTdlNTRh
15
+ ODZmNzcwMGVlMzZjNTA1MjAxMDVlMjQwYTE0ZTdjZWYxOGZjN2I=
@@ -1,6 +1,9 @@
1
1
  class NameAbbr
2
2
  def self.abbr_name(first_name, last_name)
3
- if present?(last_name) && first_name.is_a?(String) && last_name.is_a?(String)
3
+ first_name = normalize(first_name)
4
+ last_name = normalize(last_name)
5
+
6
+ unless last_name.nil?
4
7
  [first_name, last_name[0]].join(' ') + "."
5
8
  else
6
9
  first_name
@@ -8,7 +11,9 @@ class NameAbbr
8
11
  end
9
12
 
10
13
  def self.abbr_full_name(fullname)
11
- if present?(fullname) && fullname.is_a?(String) && present?(fullname.match(/ /))
14
+ fullname = normalize(fullname)
15
+
16
+ unless fullname.match(/ /).nil?
12
17
  parts = fullname.split(' ')
13
18
  [parts[0], parts[1][0]].join(' ') + "."
14
19
  else
@@ -17,7 +22,7 @@ class NameAbbr
17
22
  end
18
23
 
19
24
  private
20
- def self.present?(str)
21
- !str.nil? && str.length > 0
25
+ def self.normalize(input)
26
+ input.to_s.strip
22
27
  end
23
28
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: name_abbr
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miles Matthias