standalone_typograf 1.0.0 → 1.0.1

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.
@@ -40,6 +40,7 @@ module StandaloneTypograf
40
40
  #
41
41
  def build_quotes_tree(arr_text)
42
42
  quotes_tree = []
43
+ total = arr_text.size
43
44
  arr_text.each_with_index do |char, index|
44
45
  _next_, _prev_ = index + 1, index - 1
45
46
  # Если кавычка - первый символ в строке или за кавычкой примыкает буква,
@@ -47,6 +48,10 @@ module StandaloneTypograf
47
48
  if char == SOURCE[:double]
48
49
  if index == 0 || (arr_text[_next_] != ' ' and arr_text[_prev_] == ' ')
49
50
  quotes_tree << [index, :open]
51
+ # Ситуация с двойными кавычками идущими сразу за одинарными, например:
52
+ # "Привет, "Медвед"".
53
+ elsif arr_text[_prev_] == SOURCE[:double] and (arr_text[_next_] != ' ' and index + 1 != total)
54
+ quotes_tree << [index, :open]
50
55
  else
51
56
  quotes_tree << [index, :close]
52
57
  end
@@ -1,5 +1,5 @@
1
1
  #encoding: UTF-8
2
2
 
3
3
  module StandaloneTypograf
4
- VERSION = '1.0.0'
4
+ VERSION = '1.0.1'
5
5
  end
data/test/test_quotes.rb CHANGED
@@ -19,4 +19,14 @@ class QuotesTest < Test::Unit::TestCase
19
19
  should = '**Один**;, **Два**;, **Три**;'
20
20
  assert_equal text.quotes, should
21
21
  end
22
+ def test_double_quotes_nearby
23
+ text = StandaloneTypograf::Typograf.new('""Гномы", - вскрикнул Бильбо", - сказал Толкиен')
24
+ should = '«„Гномы“, - вскрикнул Бильбо», - сказал Толкиен'
25
+ assert_equal text.quotes, should
26
+ end
27
+ def test_double_quotes_nearby_last
28
+ text = StandaloneTypograf::Typograf.new('"Привет тебе, "Путник""')
29
+ should = '«Привет тебе, „Путник“»'
30
+ assert_equal text.quotes, should
31
+ end
22
32
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: standalone_typograf
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-03-30 00:00:00.000000000 Z
12
+ date: 2013-04-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -81,7 +81,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
81
81
  version: '0'
82
82
  segments:
83
83
  - 0
84
- hash: -4316510769190788404
84
+ hash: -484725645805835366
85
85
  required_rubygems_version: !ruby/object:Gem::Requirement
86
86
  none: false
87
87
  requirements:
@@ -90,7 +90,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
90
90
  version: '0'
91
91
  segments:
92
92
  - 0
93
- hash: -4316510769190788404
93
+ hash: -484725645805835366
94
94
  requirements: []
95
95
  rubyforge_project:
96
96
  rubygems_version: 1.8.25