GithubHelp home page GithubHelp logo

briancolfer / name_of_person Goto Github PK

View Code? Open in Web Editor NEW

This project forked from basecamp/name_of_person

0.0 1.0 0.0 25 KB

Presenting names of people in full, familiar, abbreviated, and initialized forms (but without titulation etc)

License: MIT License

Ruby 100.00%

name_of_person's Introduction

Name of Person

Presenting names for English-language applications where a basic model of first and last name(s) combined is sufficient. This approach is not meant to cover all possible naming cases, deal with other languages, or even titulations. Just the basics.

Examples

# Relies on Person having a schema with first_name and last_name columns.
class Person < ApplicationRecord
  has_person_name
end

# Saves a new record using { first_name: "David", last_name: "Heinemeier Hansson" }
person = Person.create! name: "David Heinemeier Hansson"

person.name.full        # => "David Heinemeier Hansson"
person.name.first       # => "David"
person.name.last        # => "Heinemeier Hansson"
person.name.initials    # => "DHH"
person.name.familiar    # => "David H."
person.name.abbreviated # => "D. Heinemeier Hansson"
person.name.sorted      # => "Heinemeier Hansson, David"
person.name.mentionable # => "davidh"
person.name.possessive  # => "David Heinemeier Hansson's"
person.name.possessive(:first)  # => "David's"
person.name.possessive(:last)  # => "Hansson's"
person.name.possessive(:initials)  # => "DHH's"
person.name.possessive(:sorted)  # => "Heinemeier Hansson, David's"
person.name.possessive(:abbreviated)  # => "D. Heinemeier Hansson's"


# Use directly
name = NameOfPerson::PersonName.full("David Heinemeier Hansson")
name.first # => "David"

Installation

# Gemfile
gem 'name_of_person'

If you are using this outside of Rails, make sure ActiveRecord and/or ActiveModel are manually required.

require 'active_record'
# and/or
require 'active_model'

No further development is going to happen

This gem is essentially frozen, as the developers have decided to only deal with full names going forward in their applications. Feel free to fork this work, brand it under a new name, and continue development.

License

Name of Person is released under the MIT License.

name_of_person's People

Contributors

benaubin avatar dependabot[bot] avatar dhh avatar erjanmx avatar pbougie avatar tonidezman avatar weilandia avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.