From 06d175b5255489c69ad5424e74db9d2193d30057 Mon Sep 17 00:00:00 2001 From: Shane Becker Date: Tue, 28 Jun 2011 20:36:24 -0700 Subject: [PATCH] removed borrowed rails methods so that this can be public domain --- lib/microformats2.rb | 23 +---------------------- 1 file changed, 1 insertion(+), 22 deletions(-) diff --git a/lib/microformats2.rb b/lib/microformats2.rb index c948708..c1eedb5 100644 --- a/lib/microformats2.rb +++ b/lib/microformats2.rb @@ -17,7 +17,7 @@ module Microformats2 doc.css("*[class*=h-]").each do |microformat| microformat.attribute("class").to_s.split.each do |mf_class| if mf_class =~ /^h-/ - constant_name = classify(mf_class.gsub("-","_")) + constant_name = mf_class.gsub("-","_").gsub(/^([a-z])/){$1.upcase}.gsub(/_(.)/) { $1.upcase } if Object.const_defined?(constant_name) klass = Object.const_get(constant_name) @@ -108,25 +108,4 @@ module Microformats2 end end end - - # Thank you Rails Developers for your unitentional contribution to this project - # File activesupport/lib/active_support/inflector/inflections.rb, line 206 - def self.classify(str) - # strip out any leading schema name - camelize(singularize(str.to_s.sub(/.*\./, ''))) - end - - # File activesupport/lib/active_support/inflector/inflections.rb, line 148 - def self.singularize(word) - result = word.to_s.dup - end - - # File activesupport/lib/active_support/inflector/methods.rb, line 28 - def self.camelize(lower_case_and_underscored_word, first_letter_in_uppercase = true) - if first_letter_in_uppercase - lower_case_and_underscored_word.to_s.gsub(/\/(.?)/) { "::#{$1.upcase}" }.gsub(/(?:^|_)(.)/) { $1.upcase } - else - lower_case_and_underscored_word.to_s[0].chr.downcase + camelize(lower_case_and_underscored_word)[1..-1] - end - end end