rutils 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +11 -2
- data/TODO +4 -0
- data/bin/rutilize +4 -3
- data/lib/datetime/datetime.rb +6 -6
- data/lib/gilenson/gilenson.rb +1 -1
- data/lib/integration/integration.rb +1 -1
- data/lib/integration/rails_date_helper_override.rb +12 -1
- data/lib/rutils.rb +1 -1
- data/lib/transliteration/bidi.rb +71 -0
- data/lib/transliteration/simple.rb +52 -0
- data/lib/transliteration/transliteration.rb +2 -123
- data/test/t_datetime.rb +5 -4
- metadata +55 -52
data/CHANGELOG
CHANGED
@@ -1,4 +1,14 @@
|
|
1
|
+
Версия 0.1.4 - 08.05.2006
|
2
|
+
* Транслитераторы вынесены в отдельные файлы (julik)
|
3
|
+
* Починен баг с передачей часа в нужном падеже в distance_of_time (anonyomous)
|
4
|
+
* Добавлены корректные методы публикации доков, сменены параметры их генерации (julik)
|
5
|
+
* cp -r заменен на cp_r чтобы rutilize работал в Windows (anonymous)
|
6
|
+
* Имена месяцев со строчной буквы (sgt - http://rubyforge.org/users/sgt)
|
7
|
+
* Поддерживаем оба класса Locale (из ruby-locale и gettext - они немного отличаются по семантике) (julik)
|
8
|
+
|
9
|
+
|
1
10
|
Версия 0.1.4 - 02.12.2005
|
11
|
+
* Поправлен импорт Rails-плагина (julik)
|
2
12
|
* Поправлен паттерн сбора тестируемых файлов (julik)
|
3
13
|
* Gilenson - на Oniguruma сбоит skip_code, но это надо побарывать нормальным токенизатором, пока откладывается (julik)
|
4
14
|
* Gilenson - в тестах произведена замена <cOdE> на <code> и <TT> на <tt> (mash)
|
@@ -10,8 +20,7 @@
|
|
10
20
|
Версия 0.1.3 - 14.11.2005
|
11
21
|
* Gilenson - замена троеточий на ellipsis (julik)
|
12
22
|
* Gilenson - теперь пробел, идущий перед одной или двумя буквами на конце слова
|
13
|
-
меняется на glyph[:nbsp].
|
14
|
-
text.gsub!(/(\s+)([a-zа-яА-Я]{1,2}[\)\]\!\?,\.;]{0,3}\s$)/ui, self.glyph[:nbsp]+'\2') (mash)
|
23
|
+
меняется на glyph[:nbsp]. (mash)
|
15
24
|
* Gilenson - починен баг из-за которого не типографилась закрывающая кавычка после вопросительного
|
16
25
|
и восклицательного знака (julik)
|
17
26
|
* По умолчанию используется новый Gilenson (Gilenson::Formatter). Старый доступен как Gilenson::Obsolete и через
|
data/TODO
CHANGED
data/bin/rutilize
CHANGED
@@ -11,12 +11,13 @@
|
|
11
11
|
#
|
12
12
|
# == Author
|
13
13
|
# Julik <me@julik.nl>
|
14
|
-
|
15
14
|
|
16
15
|
$KCODE = 'u'
|
17
16
|
require File.dirname(__FILE__) + '/../lib/rutils'
|
18
17
|
require 'optparse'
|
19
|
-
require 'rdoc/usage'
|
18
|
+
require 'rdoc/usage'
|
19
|
+
require 'fileutils'
|
20
|
+
include FileUtils::Verbose
|
20
21
|
|
21
22
|
opts = OptionParser.new
|
22
23
|
opts.on(" -h", "--help") { RDoc::usage }
|
@@ -33,5 +34,5 @@ for item in ARGV
|
|
33
34
|
raise "#{item} - not a directory" unless File.directory?(item)
|
34
35
|
raise "This directory doesn't seem to be a Rails application" unless File.exist?(item + '/vendor')
|
35
36
|
Dir::mkdir(item+'/vendor/plugins') unless File.exist?(item + '/vendor/plugins')
|
36
|
-
|
37
|
+
cp_r(RuTils::INSTALLATION_DIRECTORY, item + "/vendor/plugins")
|
37
38
|
end
|
data/lib/datetime/datetime.rb
CHANGED
@@ -25,7 +25,7 @@ module RuTils
|
|
25
25
|
when 46..90 then 'около часа'
|
26
26
|
# исключение, сдвигаем на один влево чтобы соответствовать падежу
|
27
27
|
when 90..1440 then "около " + (distance_in_minutes.to_f / 60.0).round.to_s +
|
28
|
-
" " + (distance_in_minutes.to_f / 60.0).round.items("часа",
|
28
|
+
" " + (distance_in_minutes.to_f / 60.0).round.items("часа", 'часов', 'часов')
|
29
29
|
when 1441..2880 then '1 день'
|
30
30
|
else (distance_in_minutes / 1440).round.to_s +
|
31
31
|
" " + (distance_in_minutes / 1440).round.items("день", "дня", "дней")
|
@@ -46,11 +46,11 @@ module RuTils
|
|
46
46
|
end
|
47
47
|
|
48
48
|
class Date
|
49
|
-
RU_MONTHNAMES = [nil] + %w{
|
50
|
-
RU_DAYNAMES = %w(
|
51
|
-
RU_ABBR_MONTHNAMES = [nil] + %w{
|
52
|
-
RU_ABBR_DAYNAMES = %w(
|
53
|
-
RU_INFLECTED_MONTHNAMES = [nil] + %w{
|
49
|
+
RU_MONTHNAMES = [nil] + %w{ январь февраль март апрель май июнь июль август сентябрь октябрь ноябрь декабрь }
|
50
|
+
RU_DAYNAMES = %w(воскресенье понедельник вторник среда четверг пятница суббота)
|
51
|
+
RU_ABBR_MONTHNAMES = [nil] + %w{ янв фев мар апр май июн июл авг сен окт ноя дек }
|
52
|
+
RU_ABBR_DAYNAMES = %w(вск пн вт ср чт пт сб)
|
53
|
+
RU_INFLECTED_MONTHNAMES = [nil] + %w{ января февраля марта апреля мая июня июля августа сентября октября ноября декабря }
|
54
54
|
# RU_DAYNAMES_E -- оставить?
|
55
55
|
RU_DAYNAMES_E = [nil] + %w{первое второе третье четвёртое пятое шестое седьмое восьмое девятое десятое одиннадцатое двенадцатое тринадцатое четырнадцатое пятнадцатое шестнадцатое семнадцатое восемнадцатое девятнадцатое двадцатое двадцать тридцатое тридцатьпервое}
|
56
56
|
end
|
data/lib/gilenson/gilenson.rb
CHANGED
@@ -479,7 +479,7 @@ class RuTils::Gilenson::Formatter
|
|
479
479
|
end
|
480
480
|
|
481
481
|
def process_dashglue(text)
|
482
|
-
text.gsub!( /([a-zа-яА-Я0-9]+(\-[a-zа-яА-Я0-9]+)+)/ui, '
|
482
|
+
text.gsub!( /([a-zа-яА-Я0-9]+(\-[a-zа-яА-Я0-9]+)+)/ui, glyph[:nob_open]+'\1'+glyph[:nob_close])
|
483
483
|
end
|
484
484
|
|
485
485
|
def process_escape_html(text)
|
@@ -7,7 +7,7 @@ module RuTils
|
|
7
7
|
# Модуль Locale можно получить как часть Multilingual Rails.
|
8
8
|
def self.overrides_enabled?
|
9
9
|
if defined?(Locale) and Locale.respond_to?(:current)
|
10
|
-
return true if Locale.current.split('_').first == 'ru'
|
10
|
+
return true if Locale.current.to_s.split('_').first == 'ru'
|
11
11
|
end
|
12
12
|
@@overrides ? true : false
|
13
13
|
end
|
@@ -11,7 +11,7 @@ if defined?(Object::ActionView)
|
|
11
11
|
RuTils::overrides_enabled? ? RuTils::DateTime::distance_of_time_in_words(*args) : stock_distance_of_time_in_words
|
12
12
|
end
|
13
13
|
|
14
|
-
# Заменяет ActionView::Helpers::DateHelper::select_month меню выбора
|
14
|
+
# Заменяет ActionView::Helpers::DateHelper::select_month меню выбора русских месяцев.
|
15
15
|
#
|
16
16
|
# select_month(Date.today) # Использует ключи "Январь", "Март"
|
17
17
|
# select_month(Date.today, :use_month_numbers => true) # Использует ключи "1", "3"
|
@@ -40,5 +40,16 @@ if defined?(Object::ActionView)
|
|
40
40
|
|
41
41
|
select_html(options[:field_name] || 'month', month_options, options[:prefix], options[:include_blank], options[:discard_type], options[:disabled])
|
42
42
|
end
|
43
|
+
|
44
|
+
# Заменяет ActionView::Helpers::DateHelper::select_date меню выбора русской даты.
|
45
|
+
def select_date(date = Date.today, options = {})
|
46
|
+
select_day(date, options) + select_month(date, options) + select_year(date, options)
|
47
|
+
end
|
48
|
+
|
49
|
+
# Заменяет ActionView::Helpers::DateHelper::select_datetime меню выбора русской даты.
|
50
|
+
def select_datetime(datetime = Time.now, options = {})
|
51
|
+
select_day(datetime, options) + select_month(datetime, options) + select_year(datetime, options) +
|
52
|
+
select_hour(datetime, options) + select_minute(datetime, options)
|
53
|
+
end
|
43
54
|
end
|
44
55
|
end #endif
|
data/lib/rutils.rb
CHANGED
@@ -0,0 +1,71 @@
|
|
1
|
+
# Реализует транслитерацию "в обе стороны", дающую возможность автоматически использовать URL как ключ записи
|
2
|
+
module RuTils::Transliteration::BiDi
|
3
|
+
TABLE_TO = {
|
4
|
+
"А"=>"A","Б"=>"B","В"=>"V","Г"=>"G","Д"=>"D",
|
5
|
+
"Е"=>"E","Ё"=>"JO","Ж"=>"ZH","З"=>"Z","И"=>"I",
|
6
|
+
"Й"=>"JJ","К"=>"K","Л"=>"L","М"=>"M","Н"=>"N",
|
7
|
+
"О"=>"O","П"=>"P","Р"=>"R","С"=>"S","Т"=>"T",
|
8
|
+
"У"=>"U","Ф"=>"F","Х"=>"KH","Ц"=>"C","Ч"=>"CH",
|
9
|
+
"Ш"=>"SH","Щ"=>"SHH","Ъ"=>"_~","Ы"=>"Y","Ь"=>"_'",
|
10
|
+
"Э"=>"EH","Ю"=>"JU","Я"=>"JA","а"=>"a","б"=>"b",
|
11
|
+
"в"=>"v","г"=>"g","д"=>"d","е"=>"e","ё"=>"jo",
|
12
|
+
"ж"=>"zh","з"=>"z","и"=>"i","й"=>"jj","к"=>"k",
|
13
|
+
"л"=>"l","м"=>"m","н"=>"n","о"=>"o","п"=>"p",
|
14
|
+
"р"=>"r","с"=>"s","т"=>"t","у"=>"u","ф"=>"f",
|
15
|
+
"х"=>"kh","ц"=>"c","ч"=>"ch","ш"=>"sh","щ"=>"shh",
|
16
|
+
"ъ"=>"~","ы"=>"y","ь"=>"'","э"=>"eh","ю"=>"ju",
|
17
|
+
"я"=>"ja",
|
18
|
+
# " "=>"__","_"=>"__"
|
19
|
+
# так сразу не получится, будут проблемы с "Ь"=>"_'"
|
20
|
+
}.sort do |one, two|
|
21
|
+
two[1].jsize <=> one[1].jsize
|
22
|
+
end
|
23
|
+
|
24
|
+
TABLE_FROM = TABLE_TO.unshift([" ","__"]).clone
|
25
|
+
TABLE_TO.unshift(["_","__"])
|
26
|
+
|
27
|
+
def self.translify(str, allow_slashes = true)
|
28
|
+
slash = allow_slashes ? '/' : '';
|
29
|
+
|
30
|
+
s = str.clone.gsub(/[^\- _0-9a-zA-ZА-ёЁ#{slash}]/, '')
|
31
|
+
lang_fr = s.scan(/[А-ёЁ ]+/)
|
32
|
+
lang_fr.each do |fr|
|
33
|
+
TABLE_TO.each do | translation |
|
34
|
+
fr.gsub!(/#{translation[0]}/, translation[1])
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
lang_sr = s.scan(/[0-9A-Za-z\_\-\.\/\']+/)
|
39
|
+
|
40
|
+
string = ""
|
41
|
+
if s =~ /\A[А-ёЁ ]/
|
42
|
+
lang_fr, lang_sr = lang_sr, lang_fr
|
43
|
+
string = "+"
|
44
|
+
end
|
45
|
+
|
46
|
+
0.upto([lang_fr.length, lang_sr.length].min-1) do |x|
|
47
|
+
string += lang_sr[x] + "+" + lang_fr[x] + "+";
|
48
|
+
end
|
49
|
+
|
50
|
+
if (lang_fr.length < lang_sr.length)
|
51
|
+
string += lang_sr[lang_sr.length-1]
|
52
|
+
else
|
53
|
+
string[0, string.length-1]
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def self.detranslify(str, allow_slashes = true)
|
58
|
+
slash = allow_slashes ? '/' : '';
|
59
|
+
|
60
|
+
str.split('/').inject(out = "") do |out, pg|
|
61
|
+
strings = pg.split('+')
|
62
|
+
1.step(strings.length-1, 2) do |x|
|
63
|
+
TABLE_FROM.each do | translation |
|
64
|
+
strings[x].gsub!(/#{translation[1]}/, translation[0])
|
65
|
+
end
|
66
|
+
end
|
67
|
+
out << slash << strings.to_s
|
68
|
+
end
|
69
|
+
out[slash.length, out.length-slash.length]
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# Реализует простейшую транслитерацию
|
2
|
+
# "вот мы и здесь".translify => "vot my i zdes"
|
3
|
+
# "vot my i zdes".detranslify => "вот мы и здесь"
|
4
|
+
module RuTils::Transliteration::Simple
|
5
|
+
TABLE = {
|
6
|
+
"Ґ"=>"G","Ё"=>"YO","Є"=>"E","Ї"=>"YI","І"=>"I",
|
7
|
+
"і"=>"i","ґ"=>"g","ё"=>"yo","№"=>"#","є"=>"e",
|
8
|
+
"ї"=>"yi","А"=>"A","Б"=>"B","В"=>"V","Г"=>"G",
|
9
|
+
"Д"=>"D","Е"=>"E","Ж"=>"ZH","З"=>"Z","И"=>"I",
|
10
|
+
"Й"=>"Y","К"=>"K","Л"=>"L","М"=>"M","Н"=>"N",
|
11
|
+
"О"=>"O","П"=>"P","Р"=>"R","С"=>"S","Т"=>"T",
|
12
|
+
"У"=>"U","Ф"=>"F","Х"=>"H","Ц"=>"TS","Ч"=>"CH",
|
13
|
+
"Ш"=>"SH","Щ"=>"SCH","Ъ"=>"'","Ы"=>"YI","Ь"=>"",
|
14
|
+
"Э"=>"E","Ю"=>"YU","Я"=>"YA","а"=>"a","б"=>"b",
|
15
|
+
"в"=>"v","г"=>"g","д"=>"d","е"=>"e","ж"=>"zh",
|
16
|
+
"з"=>"z","и"=>"i","й"=>"y","к"=>"k","л"=>"l",
|
17
|
+
"м"=>"m","н"=>"n","о"=>"o","п"=>"p","р"=>"r",
|
18
|
+
"с"=>"s","т"=>"t","у"=>"u","ф"=>"f","х"=>"h",
|
19
|
+
"ц"=>"ts","ч"=>"ch","ш"=>"sh","щ"=>"sch","ъ"=>"'",
|
20
|
+
"ы"=>"yi","ь"=>"","э"=>"e","ю"=>"yu","я"=>"ya"
|
21
|
+
}.sort do | one, two|
|
22
|
+
two[1].size <=> one[1].size
|
23
|
+
end
|
24
|
+
|
25
|
+
# Заменяет кириллицу в строке на латиницу
|
26
|
+
def self.translify(str)
|
27
|
+
s = str.clone
|
28
|
+
TABLE.each do | translation |
|
29
|
+
s = s.gsub(/#{translation[0]}/, translation[1])
|
30
|
+
end
|
31
|
+
s
|
32
|
+
end
|
33
|
+
|
34
|
+
# Заменяет латиницу на кириллицу
|
35
|
+
def self.detranslify(str)
|
36
|
+
s = str.clone
|
37
|
+
TABLE.each do | translation |
|
38
|
+
s.gsub!(/#{translation[1]}/, translation[0])
|
39
|
+
end
|
40
|
+
s
|
41
|
+
end
|
42
|
+
|
43
|
+
# Транслитерирует строку, делая ее пригодной для применения как имя директории или URL
|
44
|
+
def self.dirify(string)
|
45
|
+
st = self.translify(string)
|
46
|
+
st.gsub!(/(\s\&\s)|(\s\&\;\s)/, ' and ') # convert & to "and"
|
47
|
+
st.gsub!(/\W/, ' ') #replace non-chars
|
48
|
+
st.gsub!(/(_)$/, '') #trailing underscores
|
49
|
+
st.gsub!(/^(_)/, '') #leading unders
|
50
|
+
st.strip.translify.gsub(/(\s)/,'-').downcase.squeeze
|
51
|
+
end
|
52
|
+
end
|
@@ -3,131 +3,10 @@ module RuTils
|
|
3
3
|
end
|
4
4
|
end
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
# "vot my i zdes".detranslify => "вот мы и здесь"
|
9
|
-
module RuTils::Transliteration::Simple
|
10
|
-
TABLE = {
|
11
|
-
"Ґ"=>"G","Ё"=>"YO","Є"=>"E","Ї"=>"YI","І"=>"I",
|
12
|
-
"і"=>"i","ґ"=>"g","ё"=>"yo","№"=>"#","є"=>"e",
|
13
|
-
"ї"=>"yi","А"=>"A","Б"=>"B","В"=>"V","Г"=>"G",
|
14
|
-
"Д"=>"D","Е"=>"E","Ж"=>"ZH","З"=>"Z","И"=>"I",
|
15
|
-
"Й"=>"Y","К"=>"K","Л"=>"L","М"=>"M","Н"=>"N",
|
16
|
-
"О"=>"O","П"=>"P","Р"=>"R","С"=>"S","Т"=>"T",
|
17
|
-
"У"=>"U","Ф"=>"F","Х"=>"H","Ц"=>"TS","Ч"=>"CH",
|
18
|
-
"Ш"=>"SH","Щ"=>"SCH","Ъ"=>"'","Ы"=>"YI","Ь"=>"",
|
19
|
-
"Э"=>"E","Ю"=>"YU","Я"=>"YA","а"=>"a","б"=>"b",
|
20
|
-
"в"=>"v","г"=>"g","д"=>"d","е"=>"e","ж"=>"zh",
|
21
|
-
"з"=>"z","и"=>"i","й"=>"y","к"=>"k","л"=>"l",
|
22
|
-
"м"=>"m","н"=>"n","о"=>"o","п"=>"p","р"=>"r",
|
23
|
-
"с"=>"s","т"=>"t","у"=>"u","ф"=>"f","х"=>"h",
|
24
|
-
"ц"=>"ts","ч"=>"ch","ш"=>"sh","щ"=>"sch","ъ"=>"'",
|
25
|
-
"ы"=>"yi","ь"=>"","э"=>"e","ю"=>"yu","я"=>"ya"
|
26
|
-
}.sort do | one, two|
|
27
|
-
two[1].size <=> one[1].size
|
28
|
-
end
|
29
|
-
|
30
|
-
# Заменяет кириллицу в строке на латиницу
|
31
|
-
def self.translify(str)
|
32
|
-
s = str.clone
|
33
|
-
TABLE.each do | translation |
|
34
|
-
s = s.gsub(/#{translation[0]}/, translation[1])
|
35
|
-
end
|
36
|
-
s
|
37
|
-
end
|
6
|
+
require File.join(File.dirname(__FILE__), 'simple')
|
7
|
+
require File.join(File.dirname(__FILE__), 'bidi')
|
38
8
|
|
39
|
-
# Заменяет латиницу на кириллицу
|
40
|
-
def self.detranslify(str)
|
41
|
-
s = str.clone
|
42
|
-
TABLE.each do | translation |
|
43
|
-
s.gsub!(/#{translation[1]}/, translation[0])
|
44
|
-
end
|
45
|
-
s
|
46
|
-
end
|
47
|
-
|
48
|
-
# Транслитерирует строку, делая ее пригодной для применения как имя директории или URL
|
49
|
-
def self.dirify(string)
|
50
|
-
st = self.translify(string)
|
51
|
-
st.gsub!(/(\s\&\s)|(\s\&\;\s)/, ' and ') # convert & to "and"
|
52
|
-
st.gsub!(/\W/, ' ') #replace non-chars
|
53
|
-
st.gsub!(/(_)$/, '') #trailing underscores
|
54
|
-
st.gsub!(/^(_)/, '') #leading unders
|
55
|
-
st.strip.translify.gsub(/(\s)/,'-').downcase.squeeze
|
56
|
-
end
|
57
|
-
end
|
58
9
|
|
59
|
-
# Реализует транслитерацию "в обе стороны", дающую возможность автоматически использовать URL как ключ записи
|
60
|
-
module RuTils::Transliteration::BiDi #:nodoc:
|
61
|
-
TABLE_TO = {
|
62
|
-
"А"=>"A","Б"=>"B","В"=>"V","Г"=>"G","Д"=>"D",
|
63
|
-
"Е"=>"E","Ё"=>"JO","Ж"=>"ZH","З"=>"Z","И"=>"I",
|
64
|
-
"Й"=>"JJ","К"=>"K","Л"=>"L","М"=>"M","Н"=>"N",
|
65
|
-
"О"=>"O","П"=>"P","Р"=>"R","С"=>"S","Т"=>"T",
|
66
|
-
"У"=>"U","Ф"=>"F","Х"=>"KH","Ц"=>"C","Ч"=>"CH",
|
67
|
-
"Ш"=>"SH","Щ"=>"SHH","Ъ"=>"_~","Ы"=>"Y","Ь"=>"_'",
|
68
|
-
"Э"=>"EH","Ю"=>"JU","Я"=>"JA","а"=>"a","б"=>"b",
|
69
|
-
"в"=>"v","г"=>"g","д"=>"d","е"=>"e","ё"=>"jo",
|
70
|
-
"ж"=>"zh","з"=>"z","и"=>"i","й"=>"jj","к"=>"k",
|
71
|
-
"л"=>"l","м"=>"m","н"=>"n","о"=>"o","п"=>"p",
|
72
|
-
"р"=>"r","с"=>"s","т"=>"t","у"=>"u","ф"=>"f",
|
73
|
-
"х"=>"kh","ц"=>"c","ч"=>"ch","ш"=>"sh","щ"=>"shh",
|
74
|
-
"ъ"=>"~","ы"=>"y","ь"=>"'","э"=>"eh","ю"=>"ju",
|
75
|
-
"я"=>"ja",
|
76
|
-
# " "=>"__","_"=>"__"
|
77
|
-
# так сразу не получится, будут проблемы с "Ь"=>"_'"
|
78
|
-
}.sort do |one, two|
|
79
|
-
two[1].jsize <=> one[1].jsize
|
80
|
-
end
|
81
|
-
|
82
|
-
TABLE_FROM = TABLE_TO.unshift([" ","__"]).clone
|
83
|
-
TABLE_TO.unshift(["_","__"])
|
84
|
-
|
85
|
-
def self.translify(str, allow_slashes = true)
|
86
|
-
slash = allow_slashes ? '/' : '';
|
87
|
-
|
88
|
-
s = str.clone.gsub(/[^\- _0-9a-zA-ZА-ёЁ#{slash}]/, '')
|
89
|
-
lang_fr = s.scan(/[А-ёЁ ]+/)
|
90
|
-
lang_fr.each do |fr|
|
91
|
-
TABLE_TO.each do | translation |
|
92
|
-
fr.gsub!(/#{translation[0]}/, translation[1])
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
lang_sr = s.scan(/[0-9A-Za-z\_\-\.\/\']+/)
|
97
|
-
|
98
|
-
string = ""
|
99
|
-
if s =~ /\A[А-ёЁ ]/
|
100
|
-
lang_fr, lang_sr = lang_sr, lang_fr
|
101
|
-
string = "+"
|
102
|
-
end
|
103
|
-
|
104
|
-
0.upto([lang_fr.length, lang_sr.length].min-1) do |x|
|
105
|
-
string += lang_sr[x] + "+" + lang_fr[x] + "+";
|
106
|
-
end
|
107
|
-
|
108
|
-
if (lang_fr.length < lang_sr.length)
|
109
|
-
string += lang_sr[lang_sr.length-1]
|
110
|
-
else
|
111
|
-
string[0, string.length-1]
|
112
|
-
end
|
113
|
-
end
|
114
|
-
|
115
|
-
def self.detranslify(str, allow_slashes = true)
|
116
|
-
slash = allow_slashes ? '/' : '';
|
117
|
-
|
118
|
-
str.split('/').inject(out = "") do |out, pg|
|
119
|
-
strings = pg.split('+')
|
120
|
-
1.step(strings.length-1, 2) do |x|
|
121
|
-
TABLE_FROM.each do | translation |
|
122
|
-
strings[x].gsub!(/#{translation[1]}/, translation[0])
|
123
|
-
end
|
124
|
-
end
|
125
|
-
out << slash << strings.to_s
|
126
|
-
end
|
127
|
-
out[slash.length, out.length-slash.length]
|
128
|
-
end
|
129
|
-
end
|
130
|
-
|
131
10
|
# Реализует транслитерацию любого объекта, реализующего String или to_s
|
132
11
|
module RuTils::Transliteration::StringFormatting
|
133
12
|
|
data/test/t_datetime.rb
CHANGED
@@ -8,6 +8,7 @@ class DistanceOfTimeTest < Test::Unit::TestCase
|
|
8
8
|
assert_equal "2 минуты", RuTils::DateTime::distance_of_time_in_words(0, 140)
|
9
9
|
assert_equal "около 2 часов", RuTils::DateTime::distance_of_time_in_words(0, 60*114)
|
10
10
|
assert_equal "около 3 часов", RuTils::DateTime::distance_of_time_in_words(0, 60*120+60*60)
|
11
|
+
assert_equal "около 5 часов", RuTils::DateTime.distance_of_time_in_words(60*60*5)
|
11
12
|
end
|
12
13
|
end
|
13
14
|
|
@@ -16,13 +17,13 @@ class StrftimeRuTest < Test::Unit::TestCase
|
|
16
17
|
@@old_overrides = RuTils::overrides_enabled?
|
17
18
|
|
18
19
|
RuTils::overrides = true
|
19
|
-
assert_equal "
|
20
|
+
assert_equal "сб, суббота, дек, декабрь", Time.local(2005,"dec",31).strftime("%a, %A, %b, %B")
|
20
21
|
assert_equal "%a, %A, %b, %B", Time.local(2005,"dec",31).strftime("%%a, %%A, %%b, %%B")
|
21
|
-
assert_equal "
|
22
|
-
assert_equal "Сегодня: 31
|
22
|
+
assert_equal "%сб, %суббота, %дек, %декабрь", Time.local(2005,"dec",31).strftime("%%%a, %%%A, %%%b, %%%B")
|
23
|
+
assert_equal "Сегодня: 31 декабрь, суббота, 2005 год", Time.local(2005,"dec",31).strftime("Сегодня: %d %B, %A, %Y год")
|
23
24
|
|
24
25
|
date = Date.new(2005, 11, 9)
|
25
|
-
assert_equal "
|
26
|
+
assert_equal "ноя ноябрь ср среда", "#{Date::RU_ABBR_MONTHNAMES[date.mon]} #{Date::RU_MONTHNAMES[date.mon]} #{Date::RU_ABBR_DAYNAMES[date.wday]} #{Date::RU_DAYNAMES[date.wday]}"
|
26
27
|
|
27
28
|
RuTils::overrides = false
|
28
29
|
assert_equal "Sat, Saturday, Dec, December", Time.local(2005,"dec",31).strftime("%a, %A, %b, %B")
|
metadata
CHANGED
@@ -3,78 +3,81 @@ rubygems_version: 0.8.11
|
|
3
3
|
specification_version: 1
|
4
4
|
name: rutils
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.1.
|
7
|
-
date:
|
6
|
+
version: 0.1.5
|
7
|
+
date: 2006-05-09 00:00:00 +02:00
|
8
8
|
summary: Simple processing of russian strings
|
9
9
|
require_paths:
|
10
|
-
|
10
|
+
- lib
|
11
11
|
email: me@julik.nl
|
12
12
|
homepage: http://rubyforge.org/projects/rutils
|
13
13
|
rubyforge_project: rutils
|
14
|
-
description:
|
15
|
-
and HTML beautification"
|
14
|
+
description: Allows simple processing of russian strings - transliteration, numerals as text and HTML beautification
|
16
15
|
autorequire: rutils
|
17
16
|
default_executable:
|
18
17
|
bindir: bin
|
19
18
|
has_rdoc: true
|
20
19
|
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
21
20
|
requirements:
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
version: 0.0.0
|
21
|
+
- - ">"
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 0.0.0
|
26
24
|
version:
|
27
25
|
platform: ruby
|
28
26
|
signing_key:
|
29
27
|
cert_chain:
|
30
28
|
authors:
|
31
|
-
|
29
|
+
- Julian "Julik" Tarkhanov
|
32
30
|
files:
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
31
|
+
- bin/gilensize
|
32
|
+
- bin/rutilize
|
33
|
+
- test/run_tests.rb
|
34
|
+
- test/t_datetime.rb
|
35
|
+
- test/t_gilenson.rb
|
36
|
+
- test/t_integration.rb
|
37
|
+
- test/t_pluralize.rb
|
38
|
+
- test/t_rutils_base.rb
|
39
|
+
- test/t_transliteration.rb
|
40
|
+
- test/t_typografica.rb
|
41
|
+
- lib/countries
|
42
|
+
- lib/datetime
|
43
|
+
- lib/gilenson
|
44
|
+
- lib/integration
|
45
|
+
- lib/pluralizer
|
46
|
+
- lib/rutils.rb
|
47
|
+
- lib/transliteration
|
48
|
+
- lib/countries/countries.rb
|
49
|
+
- lib/datetime/datetime.rb
|
50
|
+
- lib/gilenson/gilenson.rb
|
51
|
+
- lib/gilenson/gilenson_port.rb
|
52
|
+
- lib/integration/blue_cloth_override.rb
|
53
|
+
- lib/integration/integration.rb
|
54
|
+
- lib/integration/rails_date_helper_override.rb
|
55
|
+
- lib/integration/red_cloth_override.rb
|
56
|
+
- lib/pluralizer/pluralizer.rb
|
57
|
+
- lib/transliteration/bidi.rb
|
58
|
+
- lib/transliteration/simple.rb
|
59
|
+
- lib/transliteration/transliteration.rb
|
60
|
+
- README
|
61
|
+
- TODO
|
62
|
+
- CHANGELOG
|
63
63
|
test_files:
|
64
|
-
|
64
|
+
- test/run_tests.rb
|
65
65
|
rdoc_options:
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
66
|
+
- --main=README
|
67
|
+
- --line-numbers
|
68
|
+
- --webcvs=http://rubyforge.org/cgi-bin/viewcvs.cgi/rutils/%s?cvsroot=rutils
|
69
|
+
- --charset=utf-8
|
70
|
+
- --promiscuous
|
71
71
|
extra_rdoc_files:
|
72
|
-
|
73
|
-
|
74
|
-
|
72
|
+
- README
|
73
|
+
- TODO
|
74
|
+
- CHANGELOG
|
75
75
|
executables:
|
76
|
-
|
77
|
-
|
76
|
+
- gilensize
|
77
|
+
- rutilize
|
78
78
|
extensions: []
|
79
|
+
|
79
80
|
requirements: []
|
80
|
-
|
81
|
+
|
82
|
+
dependencies: []
|
83
|
+
|