aboutsummaryrefslogtreecommitdiff
path: root/_plugins/titlecase.rb
diff options
context:
space:
mode:
authorBrandon Mathis <brandon@imathis.com>2011-06-11 15:58:53 -0400
committerBrandon Mathis <brandon@imathis.com>2011-06-11 15:58:53 -0400
commit913fa105c4a6793e6522ca45b85d8f06c803c6b9 (patch)
tree8047baaf313f6a0966b03c8a26a8988cdfa3c172 /_plugins/titlecase.rb
parent814be44c151088dfb90d6a01281c9206151b0a88 (diff)
downloadmy_new_personal_website-913fa105c4a6793e6522ca45b85d8f06c803c6b9.tar.xz
my_new_personal_website-913fa105c4a6793e6522ca45b85d8f06c803c6b9.zip
1. Moved _plugins into themes/classic/_plugins
I think it's probably better to ship plugins with themes to make it easier to update them. 2. Improved 'install' rake task and made nicer output
Diffstat (limited to '_plugins/titlecase.rb')
-rw-r--r--_plugins/titlecase.rb36
1 files changed, 0 insertions, 36 deletions
diff --git a/_plugins/titlecase.rb b/_plugins/titlecase.rb
deleted file mode 100644
index 103bf702..00000000
--- a/_plugins/titlecase.rb
+++ /dev/null
@@ -1,36 +0,0 @@
-class String
- def titlecase
- small_words = %w(a an and as at but by en for if in of on or the to v v. via vs vs.)
-
- x = split(" ").map do |word|
- # note: word could contain non-word characters!
- # downcase all small_words, capitalize the rest
- small_words.include?(word.gsub(/\W/, "").downcase) ? word.downcase! : word.smart_capitalize!
- word
- end
- # capitalize first and last words
- x.first.to_s.smart_capitalize!
- x.last.to_s.smart_capitalize!
- # small words after colons are capitalized
- x.join(" ").gsub(/:\s?(\W*#{small_words.join("|")}\W*)\s/) { ": #{$1.smart_capitalize} " }
- end
-
- def titlecase!
- replace(titlecase)
- end
-
- def smart_capitalize
- # ignore any leading crazy characters and capitalize the first real character
- if self =~ /^['"\(\[']*([a-z])/
- i = index($1)
- x = self[i,self.length]
- # word with capitals and periods mid-word are left alone
- self[i,1] = self[i,1].upcase unless x =~ /[A-Z]/ or x =~ /\.\w+/
- end
- self
- end
-
- def smart_capitalize!
- replace(smart_capitalize)
- end
-end