possessify 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "http://rubygems.org"
2
+
3
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 David Busse
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.
data/README.rdoc ADDED
@@ -0,0 +1,17 @@
1
+ = Possessify
2
+
3
+ Possessify extends the Ruby String class adding functionality to make strings possessive and non-possessive. It also provides a possessive? checker method.
4
+
5
+ == Examples
6
+
7
+ "Dave".possessive #=> "Dave's"
8
+ "Xerxes".possessive #=> "Xerxes'"
9
+
10
+ "Dave's".non_possessive #=> "Dave"
11
+ "Xerxes'".non_possessive #=> "Xerxes"
12
+
13
+ "Dave's".possessive? #=> true
14
+ "Dave".possessive? #=> false
15
+
16
+
17
+ Copyright (c) 2011 David Busse, released under the MIT license
data/Rakefile ADDED
@@ -0,0 +1,26 @@
1
+ require 'rake'
2
+ require 'rake/testtask'
3
+ require 'rake/rdoctask'
4
+ require 'bundler'
5
+
6
+ Bundler::GemHelper.install_tasks
7
+
8
+ desc 'Default: run unit tests.'
9
+ task :default => :test
10
+
11
+ desc 'Test the possessify plugin.'
12
+ Rake::TestTask.new(:test) do |t|
13
+ t.libs << 'lib'
14
+ t.libs << 'test'
15
+ t.pattern = 'test/**/*_test.rb'
16
+ t.verbose = true
17
+ end
18
+
19
+ desc 'Generate documentation for the possessify plugin.'
20
+ Rake::RDocTask.new(:rdoc) do |rdoc|
21
+ rdoc.rdoc_dir = 'rdoc'
22
+ rdoc.title = 'Possessify'
23
+ rdoc.options << '--line-numbers' << '--inline-source'
24
+ rdoc.rdoc_files.include('README')
25
+ rdoc.rdoc_files.include('lib/**/*.rb')
26
+ end
data/init.rb ADDED
@@ -0,0 +1 @@
1
+ require 'possessify'
data/lib/possessify.rb ADDED
@@ -0,0 +1 @@
1
+ require 'possessify/possessify'
@@ -0,0 +1,26 @@
1
+ module Possessify
2
+
3
+ String.class_eval do
4
+ def possessive
5
+ str = self
6
+ unless str.possessive? || str.blank?
7
+ str = str + (str[-1,1] && str[-1,1].downcase == "s" ? "'" : "'s")
8
+ end
9
+ str
10
+ end
11
+
12
+ def non_possessive
13
+ if self.possessive?
14
+ unless self.chomp!("'s")
15
+ self.chomp!("'")
16
+ end
17
+ end
18
+ self
19
+ end
20
+
21
+ def possessive?
22
+ self[-2,2] && (self[-2,2].downcase == "'s" || self[-2,2].downcase == "s'")
23
+ end
24
+ end
25
+
26
+ end
@@ -0,0 +1,3 @@
1
+ module Possessify
2
+ VERSION = "1.0.1"
3
+ end
@@ -0,0 +1,20 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "possessify/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "possessify"
7
+ s.version = Possessify::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["David Busse"]
10
+ s.email = ["dpb@essub.com"]
11
+ s.homepage = "http://github.com/dpbus/possessify"
12
+ s.summary = %q{Possessify extends the Ruby String class adding functionality to make strings possessive and non-possessive.}
13
+ s.description = %q{Possessify extends the Ruby String class adding functionality to make strings possessive and non-possessive. Methods include possessive, non_possessive, and possessive?}
14
+
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ s.require_paths = ["lib"]
20
+ end
@@ -0,0 +1,36 @@
1
+ require 'test_helper'
2
+
3
+ class PossessifyTest < ActiveSupport::TestCase
4
+ test "string not ending in s possessive" do
5
+ assert_equal "Dave's", "Dave".possessive
6
+ end
7
+
8
+ test "string ending in s possessive" do
9
+ assert_equal "James'", "James".possessive
10
+ assert_equal "JameS'", "JameS".possessive
11
+ end
12
+
13
+ test "string already possessive" do
14
+ assert_equal "Dave's", "Dave's".possessive
15
+ assert_equal "James'", "James'".possessive
16
+ end
17
+
18
+ test "short string" do
19
+ assert_equal "D's", "D".possessive
20
+ assert_equal "S'", "S".possessive
21
+ end
22
+
23
+ test "blanks string" do
24
+ assert_equal "", "".possessive
25
+ end
26
+
27
+ test "possesive string non_possesive" do
28
+ assert_equal "Dave", "Dave's".non_possessive
29
+ end
30
+
31
+ test "plural possesive string non_possesive" do
32
+ assert_equal "James", "James'".non_possessive
33
+ assert_equal "JameS", "JameS'".non_possessive
34
+ end
35
+
36
+ end
@@ -0,0 +1,5 @@
1
+ require 'rubygems'
2
+ require 'test/unit'
3
+ require 'active_support'
4
+
5
+ require File.dirname(__FILE__) + '/../init'
metadata ADDED
@@ -0,0 +1,80 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: possessify
3
+ version: !ruby/object:Gem::Version
4
+ hash: 21
5
+ prerelease:
6
+ segments:
7
+ - 1
8
+ - 0
9
+ - 1
10
+ version: 1.0.1
11
+ platform: ruby
12
+ authors:
13
+ - David Busse
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-01-31 00:00:00 -06:00
19
+ default_executable:
20
+ dependencies: []
21
+
22
+ description: Possessify extends the Ruby String class adding functionality to make strings possessive and non-possessive. Methods include possessive, non_possessive, and possessive?
23
+ email:
24
+ - dpb@essub.com
25
+ executables: []
26
+
27
+ extensions: []
28
+
29
+ extra_rdoc_files: []
30
+
31
+ files:
32
+ - .gitignore
33
+ - Gemfile
34
+ - LICENSE
35
+ - README.rdoc
36
+ - Rakefile
37
+ - init.rb
38
+ - lib/possessify.rb
39
+ - lib/possessify/possessify.rb
40
+ - lib/possessify/version.rb
41
+ - possessify.gemspec
42
+ - test/possessify_test.rb
43
+ - test/test_helper.rb
44
+ has_rdoc: true
45
+ homepage: http://github.com/dpbus/possessify
46
+ licenses: []
47
+
48
+ post_install_message:
49
+ rdoc_options: []
50
+
51
+ require_paths:
52
+ - lib
53
+ required_ruby_version: !ruby/object:Gem::Requirement
54
+ none: false
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ hash: 3
59
+ segments:
60
+ - 0
61
+ version: "0"
62
+ required_rubygems_version: !ruby/object:Gem::Requirement
63
+ none: false
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ hash: 3
68
+ segments:
69
+ - 0
70
+ version: "0"
71
+ requirements: []
72
+
73
+ rubyforge_project:
74
+ rubygems_version: 1.4.2
75
+ signing_key:
76
+ specification_version: 3
77
+ summary: Possessify extends the Ruby String class adding functionality to make strings possessive and non-possessive.
78
+ test_files:
79
+ - test/possessify_test.rb
80
+ - test/test_helper.rb