name_abbr 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/lib/name_abbr.rb +23 -0
- metadata +44 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
ZGQ3MjI1ODgyOTVkMzI0Y2NiZTQyYmMxNmQxMjE0OWYwY2U3Nzc2Mg==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
YmI5YzcxYzYyMmJlY2ZjZmJmNDY0ZTExNjc5YzQ5YzI1MzljMDhkOQ==
|
7
|
+
SHA512:
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
MzgzZGI0NGQ5NDJmNDk2NDJmZTAzZGVlMzYwNGY2YWY1NTkxZGRmODNjOWY0
|
10
|
+
ODRkMjM3ZGQyMjk5OWJhN2VkN2U3ZGVjOTNiNGZiZTliOTAyMjAwZDMzYTFk
|
11
|
+
MjAwMmEwYTk2ODU0Njg1Yzk4YjE3ZDM2Y2UxMTlkZTczZTQwMjA=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
M2YzNjY2YjBiYmRkYjc5ZTM3MDc2ZGQzM2EyZmRlMWUwMGRmOTQ4ZTQ3MjQ5
|
14
|
+
YTM3YzcxYmVjOTU3ZWVlNjIwNmE5OWM0NmJhODFhMjAxMzhhZWY3YzEyY2Fm
|
15
|
+
YmU5ZGI2MzdmOGQ5ZWI3OTJlNjBkMWM4NzU2ZmZkZjYwMGZiZjM=
|
data/lib/name_abbr.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
class NameAbbr
|
2
|
+
def self.abbr_name(first_name, last_name)
|
3
|
+
if present?(last_name) && first_name.is_a?(String) && last_name.is_a?(String)
|
4
|
+
[first_name, last_name[0]].join(' ') + "."
|
5
|
+
else
|
6
|
+
first_name
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.abbr_full_name(fullname)
|
11
|
+
if present?(fullname) && fullname.is_a?(String) && present?(fullname.match(/ /))
|
12
|
+
parts = fullname.split(' ')
|
13
|
+
[parts[0], parts[1][0]].join(' ') + "."
|
14
|
+
else
|
15
|
+
fullname
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
def self.present?(str)
|
21
|
+
!str.nil? && str.length > 0
|
22
|
+
end
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: name_abbr
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Miles Matthias
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-04-29 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Abbreviate full names like John D.
|
14
|
+
email: miles.matthias@gmail.com
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- lib/name_abbr.rb
|
20
|
+
homepage: https://github.com/milesmatthias/name_abbr
|
21
|
+
licenses:
|
22
|
+
- MIT
|
23
|
+
metadata: {}
|
24
|
+
post_install_message:
|
25
|
+
rdoc_options: []
|
26
|
+
require_paths:
|
27
|
+
- lib
|
28
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
requirements: []
|
39
|
+
rubyforge_project:
|
40
|
+
rubygems_version: 2.1.8
|
41
|
+
signing_key:
|
42
|
+
specification_version: 4
|
43
|
+
summary: Full Name Abbreviator
|
44
|
+
test_files: []
|