truty 0.1.0 → 0.1.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e33c09b42c8ceb567b09cf0a0577bb01b20dba5c
4
- data.tar.gz: 08f1808d7826aeef5738b05af2081799d0606cd5
3
+ metadata.gz: 1f40bb7fec5fbcc791d421f3815710ffea30736b
4
+ data.tar.gz: a64fddfb5f0fec224737008005e4f3657b09c22a
5
5
  SHA512:
6
- metadata.gz: cb6bd314915bfa2ca1d9d467b39fdc647f0528820d255c73808a1389eddd5687ae3d72deb423bd2c1b2ecc06451d8e483b2067f53fa4db1ec7be3eaf559657d9
7
- data.tar.gz: f10562c3e8a6215d74cfdf0308a02cfd2b281b724c4eb11116daacf7a0f84a80a7244df7c861b82f58ebadc854267a4791e4f03ed86f23dcbe3e6f4048fad8c3
6
+ metadata.gz: 14476727de9625d8872b21ab3134d441b662da6a4c9010d7756ac17ade34d500125b840a9273fda4c2971067c1f6990e115d8af1222760c36a7e43f73a2ea5c8
7
+ data.tar.gz: bd59bad1b93812342cb70fba9435b2164cf10acbdaff7b6387c89a1a71606e4d67255770472d001e20bbdecc21e2767628867664dbf7f0847a07e5bef7c0c44a
data/README.md CHANGED
@@ -1,4 +1,11 @@
1
1
 
2
2
  # Truty
3
3
 
4
+ [![Gem Version](https://badge.fury.io/rb/truty.svg)](http://badge.fury.io/rb/truty)
5
+ [![Test Coverage](https://codeclimate.com/github/mkj-is/Truty/badges/coverage.svg)](https://codeclimate.com/github/mkj-is/Truty)
6
+ [![Code Climate](https://codeclimate.com/github/mkj-is/Truty/badges/gpa.svg)](https://codeclimate.com/github/mkj-is/Truty)
7
+ [![Build Status](https://travis-ci.org/mkj-is/Truty.svg?branch=master)](https://travis-ci.org/mkj-is/Truty)
8
+ [![Dependency Status](https://gemnasium.com/mkj-is/Truty.svg)](https://gemnasium.com/mkj-is/Truty)
9
+ [![security](https://hakiri.io/github/mkj-is/Truty/master.svg)](https://hakiri.io/github/mkj-is/Truty/master)
10
+
4
11
  This is a ruby gem in development which is a simple string converter, which aims to fix all the typography imperfections of the plain text.
data/lib/truty/czech.rb CHANGED
@@ -26,8 +26,8 @@ module Truty
26
26
  output = add_soft_hyphens(output, "cs")
27
27
  output = emdash_spaces(output)
28
28
  output = endash_spaces(output)
29
- output = fix_double_quotes(output, "„", "“")
30
- output = fix_single_quotes(output, "‚", "‘")
29
+ output = fix_quotes(output, "\"", "„", "“")
30
+ output = fix_quotes(output, "'", "‚", "‘")
31
31
  output = fix_multiplication_sign(output)
32
32
  output = fix_space_between_numbers(output)
33
33
  output = fix_units(output)
data/lib/truty/general.rb CHANGED
@@ -28,8 +28,8 @@ module Truty
28
28
  output = add_soft_hyphens(output, lang)
29
29
  output = emdash_spaces(output)
30
30
  output = endash_spaces(output)
31
- output = fix_double_quotes(output, "„", "“")
32
- output = fix_single_quotes(output, "‚", "‘")
31
+ output = fix_double_quotes(output)
32
+ output = fix_single_quotes(output)
33
33
  output = fix_multiplication_sign(output)
34
34
  output = fix_space_between_numbers(output)
35
35
  output = fix_units(output)
@@ -82,24 +82,32 @@ module Truty
82
82
  result.join(" ")
83
83
  end
84
84
 
85
- # Converts simple double quotes to the typograhic ones.
85
+ # Converts quotes to the typograhic ones.
86
86
  #
87
87
  # @param input [String] The paragraph which will be converted.
88
+ # @param type [String] Character which will be substited for correct quotes.
88
89
  # @param start_quotes [String] The character used for starting quotes.
89
90
  # @param end_quotes [String] The character used for ending quotes.
90
91
  # @return [String] Paragraph with correct double quotes.
91
- def fix_double_quotes(input, start_quotes = "“", end_quotes = "”")
92
- input.gsub(/"[^"]*"/) { |s| start_quotes + s[1..-2].strip + end_quotes }
92
+ def fix_quotes(input, type = '"', start_quotes = "“", end_quotes = "”")
93
+ regexp = Regexp.new(type + '[^' + type + ']*' + type)
94
+ input.gsub(regexp) { |s| start_quotes + s[1..-2].strip + end_quotes }
93
95
  end
94
96
 
95
- # Converts simple single quotes to the typograhic ones.
97
+ # Converts single quotes to the typograhic ones.
96
98
  #
97
99
  # @param input [String] The paragraph which will be converted.
98
- # @param start_quotes [String] The character used for starting quotes.
99
- # @param end_quotes [String] The character used for ending quotes.
100
100
  # @return [String] Paragraph with correct single quotes.
101
- def fix_single_quotes(input, start_quotes = "‘", end_quotes = "’")
102
- input.gsub(/'[^']*'/) { |s| start_quotes + s[1..-2].strip + end_quotes }
101
+ def fix_single_quotes(input)
102
+ fix_quotes(input, "'", "‘", "’")
103
+ end
104
+
105
+ # Converts double quotes to the typograhic ones.
106
+ #
107
+ # @param input [String] The paragraph which will be converted.
108
+ # @return [String] Paragraph with correct double quotes.
109
+ def fix_double_quotes(input)
110
+ fix_quotes(input, '"', "“", "”")
103
111
  end
104
112
 
105
113
  # Adds multiplication sign between numbers instead of X.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: truty
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matěj Kašpar Jirásek
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.4'
27
+ - !ruby/object:Gem::Dependency
28
+ name: test-unit
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '3.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '3.0'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: simplecov
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -54,8 +68,7 @@ dependencies:
54
68
  version: '0.8'
55
69
  description: A string converter which aims to correct the typography.
56
70
  email: matej.jirasek@me.com
57
- executables:
58
- - truty
71
+ executables: []
59
72
  extensions: []
60
73
  extra_rdoc_files: []
61
74
  files:
@@ -77,7 +90,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
77
90
  requirements:
78
91
  - - ">="
79
92
  - !ruby/object:Gem::Version
80
- version: '0'
93
+ version: 2.0.0
81
94
  required_rubygems_version: !ruby/object:Gem::Requirement
82
95
  requirements:
83
96
  - - ">="
@@ -85,7 +98,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
85
98
  version: '0'
86
99
  requirements: []
87
100
  rubyforge_project:
88
- rubygems_version: 2.4.3
101
+ rubygems_version: 2.4.5
89
102
  signing_key:
90
103
  specification_version: 4
91
104
  summary: True typography converter