app/models/wiki_words.rb in Pimki-1.7.092 vs app/models/wiki_words.rb in Pimki-1.8.092
- old
+ new
@@ -1,29 +1,29 @@
-
-# Contains all the methods for finding and replacing wiki words
-module WikiWords
- # In order of appearance: Latin, greek, cyrillian, armenian
- I18N_HIGHER_CASE_LETTERS =
- "ÀÃ?ÂÃÄÅĀĄĂÆÇĆČĈĊĎÄ?ÃˆÃ‰ÃŠÃ‹Ä’Ä˜ÄšÄ”Ä–ÄœÄžÄ Ä¢Ä¤Ä¦ÃŒÃ?ÃŽÃ?ĪĨĬĮİIJĴĶÅ?ĽĹĻĿÑŃŇŅŊÒÓÔÕÖØŌÅ?ŎŒŔŘŖŚŠŞŜȘŤŢŦȚÙÚÛÜŪŮŰŬŨŲŴÃ?ŶŸŹŽŻ" +
- "ΑΒΓΔΕΖΗΘΙΚΛΜÎ?ΞΟΠΡΣΤΥΦΧΨΩ" +
- "ΆΈΉΊΌΎÎ?Ñ Ñ¢Ñ¤Ñ¦Ñ¨ÑªÑ¬Ñ®Ñ°Ñ²Ñ´Ñ¶Ñ¸ÑºÑ¼Ñ¾Ò€ÒŠÒŒÒŽÒ?Ò’Ò”Ò–Ò˜ÒšÒœÒžÒ Ò¢Ò¤Ò¦Ò¨ÒªÒ¬Ò®Ò°Ò²Ò´Ò¶Ò¸ÒºÒ¼Ò¾Ó?ÓƒÓ…Ó‡Ó‰Ó‹Ó?Ó?Ó’Ó”Ó–Ó˜ÓšÓœÓžÓ Ó¢Ó¤Ó¦Ó¨ÓªÓ¬Ó®Ó°Ó²Ó´Ó¸Ð–" +
- "Ô±Ô²Ô³Ô´ÔµÔ¶Ô·Ô¸Ô¹ÔºÔ»Ô¼Ô½Ô¾Ô¿Õ€Õ?Õ‚ÕƒÕ„Õ…Õ†Õ‡ÕˆÕ‰ÕŠÕ‹ÕŒÕ?Õ?Õ?Õ‘Õ’Õ“Õ”Õ•Õ–"
-
- I18N_LOWER_CASE_LETTERS =
- "à áâãäåÄ?ąăæçćÄ?ĉċÄ?đèéêëēęěĕėƒÄ?ğġģĥħìÃîïīĩÄįıijĵķĸłľĺļŀñńňņʼnŋòóôõöøÅ?Å‘Å?œŕřŗśšşÅ?șťţŧțùúûüūůűÅũųŵýÿŷžżźÞþßſÃ?ð" +
- "άÎήίΰαβγδεζηθικλμνξοπÏ?ςστυφχψωϊϋόÏ?ÏŽÎ?" +
- "абвгдежзийклмнопрÑ?туфхцчшщъыьÑ?ÑŽÑ?Ñ?ёђѓєѕіїјљћќÑ?ўџѡѣѥѧѩѫÑѯѱѳѵѷѹѻѽѿÒ?Ò‹Ò?Ò?Ò‘Ò“Ò•Ò—Ò™Ò›Ò?ÒŸÒ¡Ò£Ò¥Ò§Ò©Ò«ÒүұҳҵҷҹһҽҿӀӂӄӆӈӊӌӎӑӓӕӗәӛÓ?ÓŸÓ¡Ó£Ó¥Ó§Ó©Ó«ÓÓ¯Ó±Ó³ÓµÓ¹" +
- "Õ¡Õ¢Õ£Õ¤Õ¥Õ¦Õ§Õ¨Õ©ÕªÕ«Õ¬ÕÕ®Õ¯Õ°Õ±Õ²Õ³Õ´ÕµÕ¶Õ·Õ¸Õ¹ÕºÕ»Õ¼Õ½Õ¾Õ¿Ö€Ö?Ö‚ÖƒÖ„Ö…Ö†Ö‡"
-
- DIGITS = "0123456789"
-
- WIKI_WORD_PATTERN = '[A-Z' + I18N_HIGHER_CASE_LETTERS + ']+[a-z' + I18N_LOWER_CASE_LETTERS + ']+[a-z' + I18N_LOWER_CASE_LETTERS + DIGITS + ']*[A-Z' + I18N_HIGHER_CASE_LETTERS + DIGITS + ']\w+'
- CAMEL_CASED_WORD_BORDER = /([a-z#{I18N_LOWER_CASE_LETTERS}#{DIGITS}]|[A-Z#{I18N_HIGHER_CASE_LETTERS}]{2,})(?=[A-Z#{I18N_HIGHER_CASE_LETTERS}]\B)/u
-
- def self.separate(wiki_word, ignore_separation = false)
- if ignore_separation or wiki_word.match(/^[A-Z#{I18N_HIGHER_CASE_LETTERS}]+$/) or wiki_word.match(/\s/)
- wiki_word
- else
- wiki_word.gsub(CAMEL_CASED_WORD_BORDER, '\1 \2').gsub(/(.)(\d+)/u) { $1 == '_' ? "#$1#$2" : "#$1 #$2" }
- end
- end
+
+# Contains all the methods for finding and replacing wiki words
+module WikiWords
+ # In order of appearance: Latin, greek, cyrillian, armenian
+ I18N_HIGHER_CASE_LETTERS =
+ "ÀÃ?ÂÃÄÅĀĄĂÆÇĆČĈĊĎÄ?ÃˆÃ‰ÃŠÃ‹Ä’Ä˜ÄšÄ”Ä–ÄœÄžÄ Ä¢Ä¤Ä¦ÃŒÃ?ÃŽÃ?ĪĨĬĮİIJĴĶÅ?ĽĹĻĿÑŃŇŅŊÒÓÔÕÖØŌÅ?ŎŒŔŘŖŚŠŞŜȘŤŢŦȚÙÚÛÜŪŮŰŬŨŲŴÃ?ŶŸŹŽŻ" +
+ "ΑΒΓΔΕΖΗΘΙΚΛΜÎ?ΞΟΠΡΣΤΥΦΧΨΩ" +
+ "ΆΈΉΊΌΎÎ?Ñ Ñ¢Ñ¤Ñ¦Ñ¨ÑªÑ¬Ñ®Ñ°Ñ²Ñ´Ñ¶Ñ¸ÑºÑ¼Ñ¾Ò€ÒŠÒŒÒŽÒ?Ò’Ò”Ò–Ò˜ÒšÒœÒžÒ Ò¢Ò¤Ò¦Ò¨ÒªÒ¬Ò®Ò°Ò²Ò´Ò¶Ò¸ÒºÒ¼Ò¾Ó?ÓƒÓ…Ó‡Ó‰Ó‹Ó?Ó?Ó’Ó”Ó–Ó˜ÓšÓœÓžÓ Ó¢Ó¤Ó¦Ó¨ÓªÓ¬Ó®Ó°Ó²Ó´Ó¸Ð–" +
+ "Ô±Ô²Ô³Ô´ÔµÔ¶Ô·Ô¸Ô¹ÔºÔ»Ô¼Ô½Ô¾Ô¿Õ€Õ?Õ‚ÕƒÕ„Õ…Õ†Õ‡ÕˆÕ‰ÕŠÕ‹ÕŒÕ?Õ?Õ?Õ‘Õ’Õ“Õ”Õ•Õ–"
+
+ I18N_LOWER_CASE_LETTERS =
+ "à áâãäåÄ?ąăæçćÄ?ĉċÄ?đèéêëēęěĕėƒÄ?ğġģĥħìÃîïīĩÄįıijĵķĸłľĺļŀñńňņʼnŋòóôõöøÅ?Å‘Å?œŕřŗśšşÅ?șťţŧțùúûüūůűÅũųŵýÿŷžżźÞþßſÃ?ð" +
+ "άÎήίΰαβγδεζηθικλμνξοπÏ?ςστυφχψωϊϋόÏ?ÏŽÎ?" +
+ "абвгдежзийклмнопрÑ?туфхцчшщъыьÑ?ÑŽÑ?Ñ?ёђѓєѕіїјљћќÑ?ўџѡѣѥѧѩѫÑѯѱѳѵѷѹѻѽѿÒ?Ò‹Ò?Ò?Ò‘Ò“Ò•Ò—Ò™Ò›Ò?ÒŸÒ¡Ò£Ò¥Ò§Ò©Ò«ÒүұҳҵҷҹһҽҿӀӂӄӆӈӊӌӎӑӓӕӗәӛÓ?ÓŸÓ¡Ó£Ó¥Ó§Ó©Ó«ÓÓ¯Ó±Ó³ÓµÓ¹" +
+ "Õ¡Õ¢Õ£Õ¤Õ¥Õ¦Õ§Õ¨Õ©ÕªÕ«Õ¬ÕÕ®Õ¯Õ°Õ±Õ²Õ³Õ´ÕµÕ¶Õ·Õ¸Õ¹ÕºÕ»Õ¼Õ½Õ¾Õ¿Ö€Ö?Ö‚ÖƒÖ„Ö…Ö†Ö‡"
+
+ DIGITS = "0123456789"
+
+ WIKI_WORD_PATTERN = '[A-Z' + I18N_HIGHER_CASE_LETTERS + ']+[a-z' + I18N_LOWER_CASE_LETTERS + ']+[a-z' + I18N_LOWER_CASE_LETTERS + DIGITS + ']*[A-Z' + I18N_HIGHER_CASE_LETTERS + DIGITS + ']\w+'
+ CAMEL_CASED_WORD_BORDER = /([a-z#{I18N_LOWER_CASE_LETTERS}#{DIGITS}]|[A-Z#{I18N_HIGHER_CASE_LETTERS}]{2,})(?=[A-Z#{I18N_HIGHER_CASE_LETTERS}]\B)/u
+
+ def self.separate(wiki_word, ignore_separation = false)
+ if ignore_separation or wiki_word.match(/^[A-Z#{I18N_HIGHER_CASE_LETTERS}]+$/) or wiki_word.match(/\s/)
+ wiki_word
+ else
+ wiki_word.gsub(CAMEL_CASED_WORD_BORDER, '\1 \2').gsub(/([a-z#{I18N_LOWER_CASE_LETTERS}A-Z#{I18N_HIGHER_CASE_LETTERS}])(\d+)/u) { $1 == '_' ? "#$1#$2" : "#$1 #$2" }
+ end
+ end
end
\ No newline at end of file