rutils 0.1.8 → 0.1.9

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/CHANGELOG CHANGED
@@ -1,3 +1,6 @@
1
+ Версия 0.1.9 - 17.02.2007
2
+ * Gilenson integration - не съедаем пробелы между тегами при прогоне текста через Textile
3
+
1
4
  Версия 0.1.8 - 05.02.2007
2
5
  * Gilenson - расстановка инициалов не должна цеплять аббревиатуры (julik)
3
6
 
@@ -59,8 +59,27 @@ end
59
59
  class Time
60
60
  alias_method :strftime_norutils, :strftime
61
61
 
62
- def strftime(date)
63
- RuTils::DateTime::ru_strftime(date, self) if RuTils::overrides_enabled?
64
- strftime_norutils(date)
62
+ def strftime(fmt)
63
+ RuTils::DateTime::ru_strftime(fmt, self) if RuTils::overrides_enabled?
64
+ strftime_norutils(fmt)
65
65
  end
66
+ end
67
+
68
+ class Date
69
+
70
+ # Inside rails we have date formatting
71
+ if self.instance_methods.include?('strftime')
72
+ alias_method :strftime_norutils, :strftime
73
+ def strftime(fmt=nil)
74
+ RuTils::DateTime::ru_strftime(fmt, self) if RuTils::overrides_enabled?
75
+ strftime_norutils(fmt)
76
+ end
77
+
78
+ else
79
+ def strftime(fmt=nil)
80
+ RuTils::DateTime::ru_strftime(fmt, self) if RuTils::overrides_enabled?
81
+ self.to_time.strftime(fmt)
82
+ end
83
+ end
84
+
66
85
  end
@@ -12,7 +12,16 @@ if defined?(Object::RedCloth) and (!RedCloth.instance_methods.include?(:stock_pg
12
12
  # Вместо того чтобы влезать в чужие таблицы мы просто заменим Textile Glyphs на Gilenson - и все будут рады.
13
13
  alias_method :stock_pgl, :pgl
14
14
  def pgl(text) #:nodoc:
15
- RuTils::overrides_enabled? ? text.replace(RuTils::Gilenson::Formatter.new(text).to_html) : stock_pgl(text)
15
+ if RuTils::overrides_enabled?
16
+ # Suspend the spaces in the start and end of the block because Gilenson chews them off, and RedCloth feeds them to us in packs
17
+ # that appear between tag starts/stops. We mess up the formatting but preserve the spacing.
18
+ spaces = Array.new(2,'')
19
+ text.gsub!(/\A([\s]+)/) { spaces[0] = $1; '' }
20
+ text.gsub!(/(\s+)\Z/) { spaces[1] = $1; '' }
21
+ text.replace(spaces[0].to_s + RuTils::Gilenson::Formatter.new(text).to_html + spaces[1].to_s)
22
+ else
23
+ stock_pgl(text)
24
+ end
16
25
  end
17
26
  end
18
27
  end
data/lib/rutils.rb CHANGED
@@ -6,7 +6,7 @@ module RuTils
6
6
  INSTALLATION_DIRECTORY = File.expand_path(File.dirname(__FILE__) + '/../') #:nodoc:
7
7
  MAJOR = 0
8
8
  MINOR = 1
9
- TINY = 8
9
+ TINY = 9
10
10
 
11
11
  # Версия RuTils
12
12
  VERSION = [MAJOR, MINOR ,TINY].join('.') #:nodoc:
data/test/t_datetime.rb CHANGED
@@ -23,8 +23,9 @@ class StrftimeRuTest < Test::Unit::TestCase
23
23
  assert_equal "Сегодня: 31 декабря, суббота, 2005 года", Time.local(2005,"dec",31).strftime("Сегодня: %d %B, %A, %Y года")
24
24
  assert_equal "Сегодня: ноябрь, 30 число, дождик в четверг, а год у нас - 2006", Time.local(2006,11,30).strftime("Сегодня: %B, %d число, дождик в %A, а год у нас - %Y")
25
25
 
26
- date = Date.new(2005, 11, 9)
27
- 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
+ date = Date.new(2005, 12, 31)
27
+ assert_equal "дек декабрь сб суббота", "#{Date::RU_ABBR_MONTHNAMES[date.mon]} #{Date::RU_MONTHNAMES[date.mon]} #{Date::RU_ABBR_DAYNAMES[date.wday]} #{Date::RU_DAYNAMES[date.wday]}"
28
+ assert_equal "сб, суббота, дек, декабрь", date.strftime("%a, %A, %b, %B")
28
29
 
29
30
  RuTils::overrides = false
30
31
  assert_equal "Sat, Saturday, Dec, December", Time.local(2005,"dec",31).strftime("%a, %A, %b, %B")
data/test/t_gilenson.rb CHANGED
@@ -61,7 +61,7 @@ class GilensonOwnTest < Test::Unit::TestCase
61
61
  assert_equal 'при&#160;установке командой строки в&#160;?page=help <nobr>бла-бла-бла-бла</nobr>', 'при установке командой строки в ?page=help бла-бла-бла-бла'.gilensize
62
62
  assert_equal 'как&#160;интересно будет переноситься со&#160;строки на&#160;строку <nobr>что-то</nobr> разделённое дефисом, ведь дефис тот&#160;тоже ведь из&#160;наших. <nobr>Какие-то</nobr> браузеры думают, что&#160;следует переносить и&#160;его&#8230;', 'как интересно будет переноситься со строки на строку что-то разделённое дефисом, ведь дефис тот тоже ведь из наших. Какие-то браузеры думают, что следует переносить и его...'.gilensize
63
63
  end
64
-
64
+
65
65
  def test_quotes
66
66
  assert_equal 'english &#8220;quotes&#8221; should be&#160;quite like this', 'english "quotes" should be quite like this'.gilensize
67
67
  assert_equal 'русские же&#160;&#171;оформляются&#187; подобным образом', 'русские же "оформляются" подобным образом'.gilensize
@@ -47,10 +47,22 @@ class TextileIntegrationTest < Test::Unit::TestCase
47
47
  assert_equal "<p>И&#160;вот &#171;они пошли туда&#187;, и&#160;шли шли&#160;шли</p>",
48
48
  RedCloth.new('И вот "они пошли туда", и шли шли шли').to_html
49
49
 
50
+ RuTils::overrides = false
51
+ assert !RuTils::overrides_enabled?
52
+ assert_equal '<p><strong>strong text</strong> and <em>emphasized text</em></p>',
53
+ RedCloth.new("*strong text* and _emphasized text_").to_html, "Spaces should be preserved \
54
+ without RuTils"
55
+
56
+ RuTils::overrides = true
57
+ assert RuTils.overrides_enabled?
58
+ assert_equal '<p><strong>strong text</strong> and <em>emphasized text</em></p>',
59
+ RedCloth.new("*strong text* and _emphasized text_").to_html, "Spaces should be preserved"
60
+
50
61
  RuTils::overrides = false
51
62
  assert !RuTils.overrides_enabled?
52
63
  assert_equal "<p>И вот &#8220;они пошли туда&#8221;, и шли шли шли</p>",
53
64
  RedCloth.new('И вот "они пошли туда", и шли шли шли').to_html
65
+
54
66
  end
55
67
  end
56
68
 
@@ -73,7 +85,7 @@ class MarkdownIntegrationTest < Test::Unit::TestCase
73
85
  end
74
86
 
75
87
  TEST_DATE = Date.parse("1983-10-15") # coincidentially...
76
-
88
+ TEST_TIME = Time.local(1983, 10, 15, 12, 15) # also coincidentially...
77
89
  # Перегрузка helper'ов Rails
78
90
  class RailsHelpersOverrideTest < Test::Unit::TestCase
79
91
  def test_distance_of_time_in_words
@@ -106,6 +118,7 @@ class RailsHelpersOverrideTest < Test::Unit::TestCase
106
118
  assert_match /декабря/, stub.get_date_select, "Имя месяца должно быть указано в родительном падеже"
107
119
  assert_match /декабря/, stub.get_date_select_without_day,
108
120
  "Хелпер select_date не позволяет опускать фрагменты, имя месяца должно быть указано в родительном падеже"
121
+
109
122
  end
110
123
  end
111
124
 
metadata CHANGED
@@ -3,8 +3,8 @@ 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.8
7
- date: 2007-02-05 00:00:00 +01:00
6
+ version: 0.1.9
7
+ date: 2007-02-17 00:00:00 +01:00
8
8
  summary: Simple processing of russian strings
9
9
  require_paths:
10
10
  - lib