standalone_typograf 2.0.2 → 3.0.0

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.
Files changed (42) hide show
  1. checksums.yaml +7 -0
  2. data/.rspec +2 -0
  3. data/.travis.yml +8 -0
  4. data/README.md +108 -72
  5. data/Rakefile +1 -9
  6. data/doc/fonts.md +1 -4
  7. data/doc/logo.png +0 -0
  8. data/doc/logo.psd +0 -0
  9. data/lib/standalone_typograf/dashes.rb +23 -0
  10. data/lib/standalone_typograf/ellipsis.rb +23 -0
  11. data/lib/standalone_typograf/fractions.rb +12 -28
  12. data/lib/standalone_typograf/mnemonics.rb +33 -0
  13. data/lib/standalone_typograf/nbspaces.rb +36 -0
  14. data/lib/standalone_typograf/quotes.rb +109 -77
  15. data/lib/standalone_typograf/version.rb +1 -1
  16. data/lib/standalone_typograf.rb +86 -42
  17. data/spec/processors/dashes_spec.rb +31 -0
  18. data/spec/processors/ellipsis_spec.rb +28 -0
  19. data/spec/processors/fractions_spec.rb +18 -0
  20. data/spec/processors/mnemonics_spec.rb +34 -0
  21. data/spec/processors/nbspaces_spec.rb +31 -0
  22. data/spec/processors/quotes_spec.rb +32 -0
  23. data/spec/spec_helper.rb +21 -0
  24. data/spec/standalone_typograf_spec.rb +12 -0
  25. data/spec/typograf_spec.rb +57 -0
  26. data/standalone_typograf.gemspec +6 -3
  27. metadata +76 -45
  28. data/.DS_Store +0 -0
  29. data/.rvmrc +0 -1
  30. data/lib/standalone_typograf/dasherize.rb +0 -12
  31. data/lib/standalone_typograf/dots.rb +0 -9
  32. data/lib/standalone_typograf/endash.rb +0 -9
  33. data/lib/standalone_typograf/nbspace.rb +0 -42
  34. data/lib/standalone_typograf/signs.rb +0 -26
  35. data/test/test_dash.rb +0 -24
  36. data/test/test_dots.rb +0 -24
  37. data/test/test_endash.rb +0 -12
  38. data/test/test_fractions.rb +0 -25
  39. data/test/test_nbspace.rb +0 -33
  40. data/test/test_prepare.rb +0 -34
  41. data/test/test_quotes.rb +0 -32
  42. data/test/test_signs.rb +0 -36
@@ -1,42 +0,0 @@
1
- # encoding: UTF-8
2
-
3
- module StandaloneTypograf
4
- module Nbspace
5
- PARTICLES = [
6
- 'разве',
7
- 'неужели',
8
- 'едва',
9
- 'вряд',
10
- 'вроде',
11
- 'якобы',
12
- 'мол',
13
- 'дескать',
14
- 'даже',
15
- 'ведь',
16
- 'таки',
17
- 'лишь',
18
- 'почти',
19
- 'только',
20
- 'исключительно',
21
- 'вон',
22
- 'вот',
23
- 'именно',
24
- 'точь-в-точь',
25
- 'приблизительно',
26
- 'прямо',
27
- ]
28
- # Неразрывный пробел
29
- def nbspace
30
- # Одна буква - неразрывный пробел справа
31
- @text = @text.gsub(/(\s| )([a-zа-яА-Я])(\s| )/i, '\1'+'\2'+' ')
32
-
33
- # Двухбуквенные слова - наразрывные пробел справа
34
- @text = @text.gsub(/(\s| )([a-zа-яА-Я][a-zа-яА-Я])(\s| )/i, '\1'+'\2'+' ')
35
-
36
- # У частиц неразрывный пробел слева
37
- PARTICLES.each { |p| @text = @text.gsub(/(\s| )(#{p})/i, ' '+'\2') }
38
-
39
- @text
40
- end
41
- end
42
- end
@@ -1,26 +0,0 @@
1
- # encoding: UTF-8
2
-
3
- module StandaloneTypograf
4
- module Signs
5
-
6
- SIGNS = {
7
- '[(]c[)]' => '©',
8
- '[(]tm[)]' => '™',
9
- '[(]r[)]' => '®',
10
- '[+][-]' => '±',
11
- }
12
- SIGNS_RU = {
13
- '[(]с[)]' => '©',
14
- '[(]тм[)]' => '™',
15
- '[(]р[)]' => '®',
16
- }
17
-
18
- def signs
19
- source = @signs.merge(@signs_ru).merge(SIGNS).merge(SIGNS_RU)
20
- source.each_pair do |text, sign|
21
- @text = @text.gsub(/#{text}/i, sign)
22
- end
23
- @text
24
- end
25
- end
26
- end
data/test/test_dash.rb DELETED
@@ -1,24 +0,0 @@
1
- #encoding: UTF-8
2
-
3
- require 'test/unit'
4
- require 'standalone_typograf'
5
-
6
- class DashTest < Test::Unit::TestCase
7
- def test_dasherize_left
8
- text = StandaloneTypograf::Typograf.new('Привет,- это длинное тире!')
9
- should = 'Привет,— это длинное тире!'
10
- assert_equal text.dasherize, should
11
- end
12
-
13
- def test_dasherize_hyphen
14
- text = StandaloneTypograf::Typograf.new('Яблоко - это фрукт. То-то и оно.')
15
- should = 'Яблоко — это фрукт. То-то и оно.'
16
- assert_equal text.dasherize, should
17
- end
18
-
19
- def test_no_dashes
20
- text = StandaloneTypograf::Typograf.new('Яблоко есть фрукт.')
21
- should = 'Яблоко есть фрукт.'
22
- assert_equal text.dasherize, should
23
- end
24
- end
data/test/test_dots.rb DELETED
@@ -1,24 +0,0 @@
1
- #encoding: UTF-8
2
-
3
- require 'test/unit'
4
- require 'standalone_typograf'
5
-
6
- class DotsTest < Test::Unit::TestCase
7
- def test_dots
8
- text = StandaloneTypograf::Typograf.new('Дубровский молчал...')
9
- should = 'Дубровский молчал…'
10
- assert_equal text.dots, should
11
- end
12
-
13
- def test_two_dots
14
- text = StandaloneTypograf::Typograf.new('Да что тут предлагать?..')
15
- should = 'Да что тут предлагать?..'
16
- assert_equal text.dots, should
17
- end
18
-
19
- def test_range
20
- text = StandaloneTypograf::Typograf.new('Труба длиной 5...10 м.')
21
- should = 'Труба длиной 5…10 м.'
22
- assert_equal text.dots, should
23
- end
24
- end
data/test/test_endash.rb DELETED
@@ -1,12 +0,0 @@
1
- #encoding: UTF-8
2
-
3
- require 'test/unit'
4
- require 'standalone_typograf'
5
-
6
- class EndashTest < Test::Unit::TestCase
7
- def test_endash
8
- text = StandaloneTypograf::Typograf.new('- В 2006-2012 годах я учился в каком-то университете.')
9
- should = '- В 2006–2012 годах я учился в каком-то университете.'
10
- assert_equal text.endash, should
11
- end
12
- end
@@ -1,25 +0,0 @@
1
- #encoding: UTF-8
2
-
3
- require 'test/unit'
4
- require 'standalone_typograf'
5
-
6
- class FractionsTest < Test::Unit::TestCase
7
- # Дроби
8
- def test_fractions
9
- text = StandaloneTypograf::Typograf.new('В 1/3 всей воды на планете содержится 2/10 углекислого газа. 102/303')
10
- should = 'В ⅓ всей воды на планете содержится 2/10 углекислого газа. 102/303'
11
- assert_equal text.fractions, should
12
- end
13
-
14
- def test_whitespaces
15
- text = StandaloneTypograf::Typograf.new('1/2 1/4')
16
- should = '½ ¼'
17
- assert_equal text.fractions, should
18
- end
19
-
20
- def test_single
21
- text = StandaloneTypograf::Typograf.new('1/2')
22
- should = '½'
23
- assert_equal text.fractions, should
24
- end
25
- end
data/test/test_nbspace.rb DELETED
@@ -1,33 +0,0 @@
1
- #encoding: UTF-8
2
-
3
- require 'test/unit'
4
- require 'standalone_typograf'
5
-
6
- class NbspaceTest < Test::Unit::TestCase
7
- def test_prepare_1word
8
- # Неразрывный пробел справа от 'я' и 'в'
9
- text = StandaloneTypograf::Typograf.new('Давно я ходил в лес')
10
- should = 'Давно я ходил в лес'
11
- assert_equal text.nbspace, should
12
- end
13
- def test_prepare_2words
14
- # Неразрывный пробел справа от 'за'
15
- text = StandaloneTypograf::Typograf.new('Сходи за пивом')
16
- should = 'Сходи за пивом'
17
- assert_equal text.nbspace, should
18
- end
19
-
20
- def test_particles
21
- # У частиц неразрывный пробел слева
22
- text = StandaloneTypograf::Typograf.new('Саша якобы принес водку')
23
- should = 'Саша якобы принес водку'
24
- assert_equal text.nbspace, should
25
- end
26
-
27
- def test_combine
28
- # впваып ваыпаыв пывап я&nbsp;за&nbsp;пивом пошел 2/3
29
- text = StandaloneTypograf::Typograf.new('впваып ваыпаыв пывап я за пивом пошел 2/3')
30
- should = 'впваып ваыпаыв пывап я за пивом пошел 2/3'
31
- assert_equal text.nbspace, should
32
- end
33
- end
data/test/test_prepare.rb DELETED
@@ -1,34 +0,0 @@
1
- #encoding: UTF-8
2
-
3
- require 'test/unit'
4
- require 'standalone_typograf'
5
-
6
- class PrepareTest < Test::Unit::TestCase
7
- def test_prepare
8
- source = <<-PLAIN
9
- (р) 2013 кто-то, кого нельзя называть. "Артемий лебедев(тм), - "Взял мяч - хуяч"(с)"
10
- PLAIN
11
- text = StandaloneTypograf::Typograf.new(source)
12
- should = <<-PLAIN
13
- ® 2013 кто-то, кого нельзя называть. «Артемий лебедев™, — „Взял мяч — хуяч“©»
14
- PLAIN
15
- assert_equal text.prepare, should
16
- end
17
-
18
- def test_prepare_redefinition
19
- source = <<-PLAIN
20
- (р) 2013 кто-то, кого нельзя называть. "Артемий лебедев(тм), - "Взял мяч - хуяч"(с)"
21
- PLAIN
22
- text = StandaloneTypograf::Typograf.new(source, quotes: {outer: ['&laquo;', '&raquo;']})
23
- should = <<-PLAIN
24
- ® 2013 кто-то, кого нельзя называть. &laquo;Артемий лебедев™, — „Взял мяч — хуяч“©&raquo;
25
- PLAIN
26
- assert_equal text.prepare, should
27
- end
28
-
29
- def test_except
30
- text = StandaloneTypograf::Typograf.new('1/2+1/3', except: [:fractions])
31
- should = '1/2+1/3'
32
- assert_equal text.prepare, should
33
- end
34
- end
data/test/test_quotes.rb DELETED
@@ -1,32 +0,0 @@
1
- #encoding: UTF-8
2
-
3
- require 'test/unit'
4
- require 'standalone_typograf'
5
-
6
- class QuotesTest < Test::Unit::TestCase
7
- def test_quotes_o_i
8
- text = StandaloneTypograf::Typograf.new('"Два "вида" "кавычек"" "Жесть"')
9
- should = '«Два „вида“ „кавычек“» «Жесть»'
10
- assert_equal text.quotes, should
11
- end
12
- def test_quotes_o
13
- text = StandaloneTypograf::Typograf.new('"Один", "Два", "Три"')
14
- should = '«Один», «Два», «Три»'
15
- assert_equal text.quotes, should
16
- end
17
- def test_quotes_redefinition
18
- text = StandaloneTypograf::Typograf.new('"Один", "Два", "Три"', quotes: {outer: ['**', '**;']})
19
- should = '**Один**;, **Два**;, **Три**;'
20
- assert_equal text.quotes, should
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
32
- end
data/test/test_signs.rb DELETED
@@ -1,36 +0,0 @@
1
- #encoding: UTF-8
2
-
3
- require 'test/unit'
4
- require 'standalone_typograf'
5
-
6
- class SignsTest < Test::Unit::TestCase
7
- def test_signs
8
- text = StandaloneTypograf::Typograf.new('(р)(Р)(r)(R)(тм)(ТМ)(с)(С)(C)(c)')
9
- should = '®®®®™™©©©©'
10
- assert_equal text.signs, should
11
- end
12
-
13
- def test_no_signs
14
- text = StandaloneTypograf::Typograf.new('Это чистый текст (yes)')
15
- should = 'Это чистый текст (yes)'
16
- assert_equal text.signs, should
17
- end
18
-
19
- def test_signs_option
20
- text = StandaloneTypograf::Typograf.new('(copy) 2013', signs: {'[(]copy[)]' => '©'})
21
- should = '© 2013'
22
- assert_equal text.signs, should
23
- end
24
-
25
- def test_signs_ru_option
26
- text = StandaloneTypograf::Typograf.new('(копи) 2013', signs_ru: {'[(]копи[)]' => '&COPY;'})
27
- should = '&COPY; 2013'
28
- assert_equal text.signs, should
29
- end
30
-
31
- def test_plus_minus
32
- text = StandaloneTypograf::Typograf.new('В шахматной нотации символ +- означает, что после соответствующего хода преимущество имеют белые. Малахов +1.')
33
- should = 'В шахматной нотации символ ± означает, что после соответствующего хода преимущество имеют белые. Малахов +1.'
34
- assert_equal text.signs, should
35
- end
36
- end