name_of_person 1.1.0 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6e75bed8c641e0f6361203d37e575fd793e9a13ecb8cc1a2447b6c8b81e01a2c
4
- data.tar.gz: 245209ff20495805ecd4cba96d532a77dfe41abf303d4aa5e3bb5362e5fb1998
3
+ metadata.gz: 361510fe7cb6b267e3a9d5e2b58e62b17a1a1330fb8ec833c5f6b9b744ad3811
4
+ data.tar.gz: a520d4f0283d4333607491548e03aa7509921008210385ba67c594bb6b47ad58
5
5
  SHA512:
6
- metadata.gz: 444b437c826b0a5daeb4409b3ea4c9e71303c1c1ad00ac7e690581f20b84c6a02de625062b12f8356fd5f433fa8cd40b980fa848bb0afe59f18f95a41fb1e89b
7
- data.tar.gz: a7de5f58c5f30780d6883f5f8a6a32b0eaee3ab514406446d85f6205449fbbf69703922e318c04def9cbe075229b553cf37834b3809218534b7eb000f058d9e1
6
+ metadata.gz: 4a828efd10ce8133325a60ca4bdbc643b3736f84c9acc1e8738d612223ffaef082e425b9478c1cb152197db7a0128754cfbc493783832859bcb1f544a4c0f6ce
7
+ data.tar.gz: c98b44e5420cadd80d7a2d997a1493e99ebed9b81f73bc2d6b2302ff9e47dca6d072b9a59804417f1acd1a5b44da243fd8c176f8f4d35ad27a5c7aa0669cc2f5
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- name_of_person (1.1.0)
4
+ name_of_person (1.1.1)
5
5
  activesupport (>= 5.2.0)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -28,10 +28,25 @@ name = NameOfPerson::PersonName.full("David Heinemeier Hansson")
28
28
  name.first # => "David"
29
29
  ```
30
30
 
31
+ ## Installation
32
+
33
+ ```ruby
34
+ # Gemfile
35
+ gem 'name_of_person'
36
+ ```
37
+
38
+ If you are using this outside of Rails, make sure `ActiveRecord` and/or `ActiveModel` are manually required.
39
+
40
+ ```ruby
41
+ require 'active_record'
42
+ # and/or
43
+ require 'active_model'
44
+ ```
45
+
31
46
  ## Maintenance Expectations
32
47
 
33
48
  This library is an extraction from Basecamp that's been sufficient in almost unaltered form for over 10 years. While contributions are always welcome, do not expect a lot of feature evolution beyond the basics. Feel free to fork this library if you'd like to add large upgrades like titulations or different accommodations for other languages.
34
49
 
35
50
  ## License
36
51
 
37
- Name of Person is released under the [MIT License](https://opensource.org/licenses/MIT).
52
+ Name of Person is released under the [MIT License](https://opensource.org/licenses/MIT).
@@ -1,5 +1,6 @@
1
1
  module NameOfPerson
2
2
  end
3
3
 
4
+ require 'name_of_person/has_person_name'
4
5
  require 'name_of_person/loaders/active_model_has_person_name'
5
6
  require 'name_of_person/loaders/active_record_has_person_name'
@@ -1,9 +1,3 @@
1
- begin
2
- require 'active_model'
3
- require 'name_of_person/has_person_name'
4
-
5
- require 'active_model/model'
1
+ if defined?(ActiveModel)
6
2
  ActiveModel::Model.send :include, NameOfPerson::HasPersonName
7
- rescue LoadError
8
- # Active Model won't be auto-configured with has_person_name
9
3
  end
@@ -1,8 +1,3 @@
1
- begin
2
- require 'active_record'
3
- require 'name_of_person/has_person_name'
4
-
1
+ if defined?(ActiveRecord)
5
2
  ActiveRecord::Base.send :include, NameOfPerson::HasPersonName
6
- rescue LoadError
7
- # Active Record won't be auto-configured with has_person_name
8
3
  end
@@ -42,7 +42,7 @@ module NameOfPerson
42
42
 
43
43
  # Returns just the initials.
44
44
  def initials
45
- @initials ||= scan(/(\S)\S+/).join
45
+ @initials ||= remove(/(\(|\[).*(\)|\])/).scan(/([[:word:]])[[:word:]]+/i).join
46
46
  end
47
47
 
48
48
  # Returns a mentionable version of the familiar name
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'name_of_person'
3
- s.version = '1.1.0'
3
+ s.version = '1.1.1'
4
4
  s.authors = 'David Heinemeier Hansson'
5
5
  s.email = 'david@basecamp.com'
6
6
  s.summary = 'Presenting names of people in full, familiar, abbreviated, and initialized forms (but without titulation etc)'
@@ -1,7 +1,8 @@
1
1
  require 'active_support'
2
2
  require 'active_support/testing/autorun'
3
3
 
4
- require 'name_of_person/loaders/active_model_has_person_name'
4
+ require 'active_model'
5
+ require 'name_of_person'
5
6
 
6
7
  class ModelPerson
7
8
  include ActiveModel::Model
@@ -71,6 +71,21 @@ class PersonNameTest < ActiveSupport::TestCase
71
71
  assert_equal 'D', name.initials
72
72
  end
73
73
 
74
+ test "initials skip anything inside parenthesis" do
75
+ name = PersonName.full('Conor Muirhead (Basecamp)')
76
+ assert_equal 'CM', name.initials
77
+ end
78
+
79
+ test "initials skip anything inside brackets" do
80
+ name = PersonName.full('Conor Muirhead [Basecamp]')
81
+ assert_equal 'CM', name.initials
82
+ end
83
+
84
+ test "initials skip non-word characters" do
85
+ name = PersonName.full('Conor Muirhead !')
86
+ assert_equal 'CM', name.initials
87
+ end
88
+
74
89
  test "from full name" do
75
90
  name = PersonName.full('Will St. Clair')
76
91
  assert_equal 'Will', name.first
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: name_of_person
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Heinemeier Hansson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-01-08 00:00:00.000000000 Z
11
+ date: 2019-04-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -92,8 +92,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
92
92
  - !ruby/object:Gem::Version
93
93
  version: '0'
94
94
  requirements: []
95
- rubyforge_project:
96
- rubygems_version: 2.7.6
95
+ rubygems_version: 3.0.3
97
96
  signing_key:
98
97
  specification_version: 4
99
98
  summary: Presenting names of people in full, familiar, abbreviated, and initialized