Permalink
Browse files

initial version

  • Loading branch information...
1 parent 455afcd commit 64d7c612d39c2d5c5acfd5aa4da9fb8bae76fdf8 @bclubb bclubb committed Oct 14, 2010
Showing with 28 additions and 8 deletions.
  1. +13 −1 README.rdoc
  2. +3 −4 Rakefile
  3. +5 −0 lib/possessive.rb
  4. +1 −0 rails/init.rb
  5. +0 −1 test/helper.rb
  6. +6 −2 test/test_possessive.rb
View
@@ -1,6 +1,18 @@
= possessive
-Description goes here.
+Rails plugin that lets you get a possessive form of a string for use on sites
+
+Code from http://stackoverflow.com/questions/1115283/making-a-rails-inflection-for-possessive-strings
+
+== Example
+
+"Brian".possessive # => Brian's
+"Sooners".possessive # => Sooners'
+
+== Install
+Rails 3
+gem "possessive"
+
== Note on Patches/Pull Requests
View
@@ -5,12 +5,11 @@ begin
require 'jeweler'
Jeweler::Tasks.new do |gem|
gem.name = "possessive"
- gem.summary = %Q{TODO: one-line summary of your gem}
- gem.description = %Q{TODO: longer description of your gem}
+ gem.summary = "Rails plugin that lets you get a possessive form of a string for use on sites"
+ gem.description = "Rails plugin that lets you get a possessive form of a string for use on sites"
gem.email = "bclubb@gmail.com"
gem.homepage = "http://github.com/bclubb/possessive"
- gem.authors = ["Brian Clubb"]
- gem.add_development_dependency "thoughtbot-shoulda", ">= 0"
+ gem.authors = ["Brian Clubb", "Jamie Flournoy", "Nick Howard"]
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
end
Jeweler::GemcutterTasks.new
View
@@ -0,0 +1,5 @@
+String.class_eval do
+ def possessive
+ self + ('s' == self[-1,1] ? "'" : "'s")
+ end
+end
View
@@ -0,0 +1 @@
+require "possessive"
View
@@ -1,6 +1,5 @@
require 'rubygems'
require 'test/unit'
-require 'shoulda'
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
$LOAD_PATH.unshift(File.dirname(__FILE__))
View
@@ -1,7 +1,11 @@
require 'helper'
class TestPossessive < Test::Unit::TestCase
- should "probably rename this file and start testing for real" do
- flunk "hey buddy, you should probably rename this file and start testing for real"
+ test "Possessive with a normal string" do
+ assert_equal "Brian's", "Brian".possessive
+ end
+
+ test "Possessive with a string ending with s" do
+ assert_equal "Steelers'", "Steelers".possessive
end
end

0 comments on commit 64d7c61

Please sign in to comment.