truty 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 06eaf24a439e783faee1611fc66b4342506adb45
4
- data.tar.gz: d77ee705f0291cb4b49dd03e139cd8e1ecc3cea9
3
+ metadata.gz: 2f2719650e009095a973fd6e3ad22a1e23c6e3d0
4
+ data.tar.gz: 72ef5bb43c3a47fc088f42e6b288e3e13a93453f
5
5
  SHA512:
6
- metadata.gz: ed88d0bacf40000e0d0259251319472c8a3da5b243ca113ab4aacb71a890d731a47baac05b2bc29b9e25e64fe56429dd3cc94d7c608688d817dcaf69fa8a2a37
7
- data.tar.gz: d376ee6b2b30c1cce8aef57aa0a898bcc58a2354bbc2592b1c12002aadafa468b9f948fba8bbd9ccac54464c0ddcdf10a5992852f95728b25cfae88a4143e66f
6
+ metadata.gz: e2d1bad2e772f9fd2a7d5cae334b180b08f8fdf393420a8951dd0a4e3008d45925a1b06a18b743511ac5d64cde682e08dd52cc68cee70ad007b759b40b38352e
7
+ data.tar.gz: 98ae6086f246caef3d6f8cf4ff3f1dbfed0275d9d8be63662a97ed95bd291d5869b19e25263aacd431211bfd42b85b92130af4f2e00753193f98ec1d84f9cc52
data/README.md CHANGED
@@ -28,7 +28,7 @@ The most simple way to install Truty is using Ruby gems.
28
28
  gem install truty
29
29
  ```
30
30
 
31
- ## Usage
31
+ ## Usage
32
32
 
33
33
  The gem contains an executable. For now it has only one parameter, language. Other arguments are files which will be converted and outputted. If no file is supplied, then the standard input is converted.
34
34
 
@@ -67,7 +67,7 @@ Full documentation can be found here:
67
67
 
68
68
  http://www.rubydoc.info/gems/truty
69
69
 
70
- ## Authors
70
+ ## Authors
71
71
 
72
72
  - [Matěj Kašpar Jirásek](https://github.com/mkj-is) (http://mkj.is)
73
73
 
data/lib/truty.rb CHANGED
@@ -17,4 +17,3 @@ module Truty
17
17
  extend Conversion
18
18
 
19
19
  end
20
-
data/lib/truty/czech.rb CHANGED
@@ -12,6 +12,7 @@ module Truty
12
12
  def czech(input)
13
13
  input = soft_hyphens(input, "cs")
14
14
  input = general(input)
15
+ input = czech_dates(input)
15
16
  input = czech_double_quotes(input)
16
17
  input = czech_single_quotes(input)
17
18
  input = czech_long_numbers(input)
@@ -32,7 +33,7 @@ module Truty
32
33
  # @param input [String] The paragraph which will be converted.
33
34
  # @return [String] Paragraph with spaces inside of long numbers.
34
35
  def czech_long_numbers(input)
35
- input.gsub(/\d+/) { |n| n.reverse.scan(/(.{1,3})/).join(' ').reverse }
36
+ input.gsub(/\d{5,}/) { |n| n.reverse.scan(/(.{1,3})/).join(' ').reverse }
36
37
  end
37
38
 
38
39
  # Adds non-breaking spaces in and after Czech abbreviations.
@@ -49,7 +50,7 @@ module Truty
49
50
  # @param input [String] The paragraph which will be converted.
50
51
  # @return [String] Paragraph with correct single quotes.
51
52
  def czech_single_quotes(input)
52
- quotes(input, "'", "‚", "‘")
53
+ quotes(input, "'`", "‚", "‘")
53
54
  end
54
55
 
55
56
  # Converts double quotes to the typograhic ones.
@@ -57,7 +58,15 @@ module Truty
57
58
  # @param input [String] The paragraph which will be converted.
58
59
  # @return [String] Paragraph with correct double quotes.
59
60
  def czech_double_quotes(input)
60
- quotes(input, "\"", "„", "“")
61
+ quotes(input, '"“”„', "„", "“")
62
+ end
63
+
64
+ # Adds non-breaking space after number with period.
65
+ #
66
+ # @param input [String] The paragraph which will be converted.
67
+ # @return [String] Paragraph with non-breaking spaces after numbers.
68
+ def czech_dates(input)
69
+ input.gsub(/((\d+\. )+)/) { $1.gsub(/ /, " ") }
61
70
  end
62
71
 
63
72
  end
data/lib/truty/french.rb CHANGED
@@ -29,7 +29,7 @@ module Truty
29
29
  # @param input [String] The paragraph which will be converted.
30
30
  # @return [String] Paragraph with correct double quotes.
31
31
  def french_double_quotes(input)
32
- quotes(input, "\"", "« ", " »")
32
+ quotes(input, '"“”„«»', "« ", " »")
33
33
  end
34
34
 
35
35
  end
data/lib/truty/general.rb CHANGED
@@ -32,7 +32,6 @@ module Truty
32
32
  input = multiplication_sign(input)
33
33
  input = space_between_numbers(input)
34
34
  input = units(input)
35
- input = trailing_spaces(input)
36
35
  input = widows(input)
37
36
  end
38
37
 
@@ -88,8 +87,8 @@ module Truty
88
87
  # @param start_quotes [String] The character used for starting quotes.
89
88
  # @param end_quotes [String] The character used for ending quotes.
90
89
  # @return [String] Paragraph with correct double quotes.
91
- def quotes(input, type = '"', start_quotes = "“", end_quotes = "”")
92
- regexp = Regexp.new(type + '[^' + type + ']*' + type)
90
+ def quotes(input, type = '"“”„', start_quotes = "“", end_quotes = "”")
91
+ regexp = Regexp.new('[' + type + '][^' + type + ']*[' + type + ']')
93
92
  input.gsub(regexp) { |s| start_quotes + s[1..-2].gsub(/(^[\s ]+|[\s ]+$)/, "") + end_quotes }
94
93
  end
95
94
 
@@ -133,7 +132,7 @@ module Truty
133
132
  output = output.gsub(/\((TM|tm|Tm)\)/, "™")
134
133
  output = output.gsub(/\+-/, "±")
135
134
  output = output.gsub(/-\+/, "∓")
136
- output = output.gsub(/No.?\s*(\d+)/i, '№\1')
135
+ output = output.gsub(/N[oO]\.?\s*(\d+)/, '№\1')
137
136
  output = output.gsub(/°C/, '℃')
138
137
  output = output.gsub(/°F/, '℉')
139
138
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: truty
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matěj Kašpar Jirásek
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-06 00:00:00.000000000 Z
11
+ date: 2015-01-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: text-hyphen