├── VERSION ├── rails └── init.rb ├── .document ├── test ├── helper.rb └── test_possessive.rb ├── .gitignore ├── lib └── possessive.rb ├── README.rdoc ├── LICENSE ├── possessive.gemspec └── Rakefile /VERSION: -------------------------------------------------------------------------------- 1 | 1.0.0 2 | -------------------------------------------------------------------------------- /rails/init.rb: -------------------------------------------------------------------------------- 1 | require "possessive" -------------------------------------------------------------------------------- /.document: -------------------------------------------------------------------------------- 1 | README.rdoc 2 | lib/**/*.rb 3 | bin/* 4 | features/**/*.feature 5 | LICENSE 6 | -------------------------------------------------------------------------------- /test/helper.rb: -------------------------------------------------------------------------------- 1 | require 'rubygems' 2 | gem 'test-unit' 3 | require 'test/unit' 4 | 5 | require 'possessive' 6 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## MAC OS 2 | .DS_Store 3 | 4 | ## TEXTMATE 5 | *.tmproj 6 | tmtags 7 | 8 | ## EMACS 9 | *~ 10 | \#* 11 | .\#* 12 | 13 | ## VIM 14 | *.swp 15 | 16 | ## PROJECT::GENERAL 17 | coverage 18 | rdoc 19 | pkg 20 | 21 | ## PROJECT::SPECIFIC 22 | -------------------------------------------------------------------------------- /lib/possessive.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | String.class_eval do 4 | def possessive 5 | return self if self.empty? 6 | self + ('s' == self[-1,1] ? Possessive::APOSTROPHE_CHAR : Possessive::APOSTROPHE_CHAR+"s") 7 | end 8 | end 9 | 10 | module Possessive 11 | APOSTROPHE_CHAR = '’' 12 | end 13 | -------------------------------------------------------------------------------- /test/test_possessive.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require 'helper' 4 | 5 | class TestPossessive < Test::Unit::TestCase 6 | test "Possessive with a normal string" do 7 | assert_equal "Brian’s", "Brian".possessive 8 | end 9 | 10 | test "Possessive with a string ending with s" do 11 | assert_equal "Steelers’", "Steelers".possessive 12 | end 13 | 14 | test "Possessive with an empty string" do 15 | assert_equal "", "".possessive 16 | end 17 | end 18 | -------------------------------------------------------------------------------- /README.rdoc: -------------------------------------------------------------------------------- 1 | = possessive 2 | 3 | Rails plugin that lets you get a possessive form of a string for use on sites 4 | 5 | Code from http://stackoverflow.com/questions/1115283/making-a-rails-inflection-for-possessive-strings 6 | 7 | == Example 8 | 9 | "Brian".possessive # => Brian's 10 | 11 | "Sooners".possessive # => Sooners' 12 | 13 | == Install 14 | Add this to your Gemfile 15 | 16 | gem "possessive" 17 | 18 | 19 | == Note on Patches/Pull Requests 20 | 21 | * Fork the project. 22 | * Make your feature addition or bug fix. 23 | * Add tests for it. This is important so I don't break it in a 24 | future version unintentionally. 25 | * Commit, do not mess with rakefile, version, or history. 26 | (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull) 27 | * Send me a pull request. Bonus points for topic branches. 28 | 29 | == Copyright 30 | 31 | Copyright (c) 2010 Brian Clubb. See LICENSE for details. 32 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2009 Brian Clubb 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /possessive.gemspec: -------------------------------------------------------------------------------- 1 | # Generated by jeweler 2 | # DO NOT EDIT THIS FILE DIRECTLY 3 | # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command 4 | # -*- encoding: utf-8 -*- 5 | 6 | Gem::Specification.new do |s| 7 | s.name = %q{possessive} 8 | s.version = "1.0.0" 9 | 10 | s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= 11 | s.authors = ["Brian Clubb", "Jamie Flournoy", "Nick Howard"] 12 | s.date = %q{2010-10-14} 13 | s.description = %q{Rails plugin that lets you get a possessive form of a string for use on sites} 14 | s.email = %q{bclubb@gmail.com} 15 | s.extra_rdoc_files = [ 16 | "LICENSE", 17 | "README.rdoc" 18 | ] 19 | s.files = [ 20 | ".document", 21 | ".gitignore", 22 | "LICENSE", 23 | "README.rdoc", 24 | "Rakefile", 25 | "VERSION", 26 | "lib/possessive.rb", 27 | "rails/init.rb", 28 | "test/helper.rb", 29 | "test/test_possessive.rb" 30 | ] 31 | s.homepage = %q{http://github.com/bclubb/possessive} 32 | s.rdoc_options = ["--charset=UTF-8"] 33 | s.require_paths = ["lib"] 34 | s.rubygems_version = %q{1.3.7} 35 | s.summary = %q{Rails plugin that lets you get a possessive form of a string for use on sites} 36 | s.test_files = [ 37 | "test/helper.rb", 38 | "test/test_possessive.rb" 39 | ] 40 | 41 | if s.respond_to? :specification_version then 42 | current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION 43 | s.specification_version = 3 44 | 45 | if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then 46 | else 47 | end 48 | else 49 | end 50 | end 51 | 52 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | require 'rubygems' 2 | require 'rake' 3 | 4 | begin 5 | require 'jeweler' 6 | Jeweler::Tasks.new do |gem| 7 | gem.name = "possessive" 8 | gem.summary = "Rails plugin that lets you get a possessive form of a string for use on sites" 9 | gem.description = "Rails plugin that lets you get a possessive form of a string for use on sites" 10 | gem.email = "bclubb@gmail.com" 11 | gem.homepage = "http://github.com/bclubb/possessive" 12 | gem.authors = ["Brian Clubb", "Jamie Flournoy", "Nick Howard"] 13 | # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings 14 | end 15 | Jeweler::GemcutterTasks.new 16 | rescue LoadError 17 | puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler" 18 | end 19 | 20 | require 'rake/testtask' 21 | Rake::TestTask.new(:test) do |test| 22 | test.libs << 'lib' << 'test' 23 | test.pattern = 'test/**/test_*.rb' 24 | test.verbose = true 25 | end 26 | 27 | begin 28 | require 'rcov/rcovtask' 29 | Rcov::RcovTask.new do |test| 30 | test.libs << 'test' 31 | test.pattern = 'test/**/test_*.rb' 32 | test.verbose = true 33 | end 34 | rescue LoadError 35 | task :rcov do 36 | abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov" 37 | end 38 | end 39 | 40 | task :test => :check_dependencies 41 | 42 | task :default => :test 43 | 44 | require 'rdoc/task' 45 | Rake::RDocTask.new do |rdoc| 46 | version = File.exist?('VERSION') ? File.read('VERSION') : "" 47 | 48 | rdoc.rdoc_dir = 'rdoc' 49 | rdoc.title = "possessive #{version}" 50 | rdoc.rdoc_files.include('README*') 51 | rdoc.rdoc_files.include('lib/**/*.rb') 52 | end 53 | --------------------------------------------------------------------------------