improve_typography 0.1.15 → 0.1.16
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/improve_typography.gemspec +2 -2
- data/lib/config/locales/da.yml +2 -0
- data/lib/improve_typography/base.rb +15 -3
- data/lib/improve_typography/processor.rb +17 -2
- data/lib/improve_typography/processors/apostrophe.rb +2 -1
- data/lib/improve_typography/processors/double_quotes.rb +2 -1
- data/lib/improve_typography/processors/ellipsis.rb +2 -2
- data/lib/improve_typography/processors/em_dash.rb +2 -1
- data/lib/improve_typography/processors/en_dash.rb +2 -1
- data/lib/improve_typography/processors/multiply_sign.rb +2 -2
- data/lib/improve_typography/processors/single_quotes.rb +2 -1
- data/lib/improve_typography/version.rb +1 -1
- metadata +10 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d6d3cfe8e809e1e21fcc9eb90c85e6eab6704d96160dab03e3708a88981ac0e9
|
4
|
+
data.tar.gz: 2e94d39063ec4ecadbdb034015adca8f70c3c6aae9167756696a38305b80a620
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f4104301d85835ceabe273e522c690dfdd24d19ee644fc98d2864fa2261c241ac0a705e622c7d741fedff1aa633270d4e8fd05b4dafc18a46272c6091939f771
|
7
|
+
data.tar.gz: 559c315c4eef1bd0ea29634d84aa02c9d9560119c5cd5cf135ba6147fd5cdced0038dbf71cf724aab645005f7df6f48a1765d14161255be0f83a00b5ec3255c4
|
data/CHANGELOG.md
CHANGED
data/improve_typography.gemspec
CHANGED
@@ -24,9 +24,9 @@ Gem::Specification.new do |spec|
|
|
24
24
|
spec.add_dependency 'i18n'
|
25
25
|
spec.add_dependency 'nokogiri'
|
26
26
|
|
27
|
-
spec.add_development_dependency 'bundler'
|
27
|
+
spec.add_development_dependency 'bundler'
|
28
28
|
spec.add_development_dependency 'guard'
|
29
29
|
spec.add_development_dependency 'guard-minitest'
|
30
30
|
spec.add_development_dependency 'minitest', '~> 5.0'
|
31
|
-
spec.add_development_dependency 'rake', '~>
|
31
|
+
spec.add_development_dependency 'rake', '~> 13.0'
|
32
32
|
end
|
@@ -2,8 +2,20 @@ require 'nokogiri'
|
|
2
2
|
|
3
3
|
module ImproveTypography
|
4
4
|
class Base < Struct.new(:str, :options)
|
5
|
-
|
6
|
-
|
5
|
+
class << self
|
6
|
+
def all_processor_classes
|
7
|
+
@@all_processor_classes ||= []
|
8
|
+
end
|
9
|
+
|
10
|
+
def add_processor_class(klass)
|
11
|
+
unless all_processor_classes.include?(klass)
|
12
|
+
all_processor_classes << klass
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def call(*args)
|
17
|
+
new(*args).call
|
18
|
+
end
|
7
19
|
end
|
8
20
|
|
9
21
|
def initialize(str, options = {})
|
@@ -41,7 +53,7 @@ module ImproveTypography
|
|
41
53
|
end
|
42
54
|
|
43
55
|
def all_processor_classes
|
44
|
-
|
56
|
+
self.class.all_processor_classes
|
45
57
|
end
|
46
58
|
|
47
59
|
def processor_for_locale(klass)
|
@@ -1,7 +1,14 @@
|
|
1
1
|
module ImproveTypography
|
2
2
|
class Processor < Struct.new(:str, :options)
|
3
|
-
|
4
|
-
|
3
|
+
class << self
|
4
|
+
def call(*args)
|
5
|
+
new(*args).call
|
6
|
+
end
|
7
|
+
|
8
|
+
def inherited(klass)
|
9
|
+
ImproveTypography::Base.add_processor_class(klass)
|
10
|
+
super
|
11
|
+
end
|
5
12
|
end
|
6
13
|
|
7
14
|
def initialize(str, options = {})
|
@@ -14,6 +21,14 @@ module ImproveTypography
|
|
14
21
|
|
15
22
|
private
|
16
23
|
|
24
|
+
def translation(key)
|
25
|
+
I18n.t(key, scope: %i(improve_typography), locale: locale)
|
26
|
+
end
|
27
|
+
|
28
|
+
def sign_exists?(sign)
|
29
|
+
!sign.nil? && !sign.match?(/translation missing/)
|
30
|
+
end
|
31
|
+
|
17
32
|
def configuration
|
18
33
|
@configuration ||= Configuration.new
|
19
34
|
end
|
@@ -4,6 +4,7 @@ module ImproveTypography
|
|
4
4
|
REGEXP = /(\w+)'(\w*)/i
|
5
5
|
|
6
6
|
def call
|
7
|
+
return str unless sign_exists?(apostrophe_sign)
|
7
8
|
return str unless str.match?(/'/)
|
8
9
|
replace_apostrophe
|
9
10
|
end
|
@@ -15,7 +16,7 @@ module ImproveTypography
|
|
15
16
|
end
|
16
17
|
|
17
18
|
def apostrophe_sign
|
18
|
-
options.fetch(:apostrophe_sign,
|
19
|
+
options.fetch(:apostrophe_sign, translation(:apostrophe_sign))
|
19
20
|
end
|
20
21
|
end
|
21
22
|
end
|
@@ -2,6 +2,7 @@ module ImproveTypography
|
|
2
2
|
module Processors
|
3
3
|
class DoubleQuotes < Processor
|
4
4
|
def call
|
5
|
+
return str unless sign_exists?(double_quotes)
|
5
6
|
return str unless str.match?(/[\"#{double_quotes[0]}#{double_quotes[1]}]/)
|
6
7
|
replace_double_quotes
|
7
8
|
end
|
@@ -17,7 +18,7 @@ module ImproveTypography
|
|
17
18
|
end
|
18
19
|
|
19
20
|
def double_quotes
|
20
|
-
options.fetch(:double_quotes,
|
21
|
+
options.fetch(:double_quotes, translation(:double_quotes))
|
21
22
|
end
|
22
23
|
end
|
23
24
|
end
|
@@ -4,7 +4,7 @@ module ImproveTypography
|
|
4
4
|
REGEXP = /(\.\s*?){3,}/i
|
5
5
|
|
6
6
|
def call
|
7
|
-
return str unless ellipsis_sign
|
7
|
+
return str unless sign_exists?(ellipsis_sign)
|
8
8
|
return str unless str.match?(REGEXP)
|
9
9
|
|
10
10
|
str.gsub(REGEXP, ellipsis_sign)
|
@@ -13,7 +13,7 @@ module ImproveTypography
|
|
13
13
|
private
|
14
14
|
|
15
15
|
def ellipsis_sign
|
16
|
-
options.fetch(:ellipsis_sign,
|
16
|
+
options.fetch(:ellipsis_sign, translation(:ellipsis_sign))
|
17
17
|
end
|
18
18
|
end
|
19
19
|
end
|
@@ -4,6 +4,7 @@ module ImproveTypography
|
|
4
4
|
REGEXP = /(\w+?)\s+-{1,3}\s+(\w+?)/i
|
5
5
|
|
6
6
|
def call
|
7
|
+
return str unless sign_exists?(em_dash_sign)
|
7
8
|
return str unless str.match?(/-{1,3}/)
|
8
9
|
str.gsub(REGEXP, '\1'+em_dash_sign+'\2')
|
9
10
|
end
|
@@ -11,7 +12,7 @@ module ImproveTypography
|
|
11
12
|
private
|
12
13
|
|
13
14
|
def em_dash_sign
|
14
|
-
options.fetch(:em_dash_sign,
|
15
|
+
options.fetch(:em_dash_sign, translation(:em_dash_sign))
|
15
16
|
end
|
16
17
|
end
|
17
18
|
end
|
@@ -4,6 +4,7 @@ module ImproveTypography
|
|
4
4
|
REGEXP = /(\w+?)\s+-{1,2}\s+(\w+?)/i
|
5
5
|
|
6
6
|
def call
|
7
|
+
return str unless sign_exists?(en_dash_sign)
|
7
8
|
return str unless str.match?(/-{1,3}/)
|
8
9
|
str.gsub(REGEXP, '\1'+en_dash_sign+'\2')
|
9
10
|
end
|
@@ -11,7 +12,7 @@ module ImproveTypography
|
|
11
12
|
private
|
12
13
|
|
13
14
|
def en_dash_sign
|
14
|
-
options.fetch(:en_dash_sign,
|
15
|
+
options.fetch(:en_dash_sign, translation(:en_dash_sign))
|
15
16
|
end
|
16
17
|
end
|
17
18
|
end
|
@@ -4,7 +4,7 @@ module ImproveTypography
|
|
4
4
|
REGEXP = /(\d+|[½⅓¼⅔⅛⅜⅝⅞])(\s*)x(\s*)(\d+|[½⅓¼⅔⅛⅜⅝⅞])/i
|
5
5
|
|
6
6
|
def call
|
7
|
-
return str unless multiply_sign
|
7
|
+
return str unless sign_exists?(multiply_sign)
|
8
8
|
return str unless str.match?(REGEXP)
|
9
9
|
|
10
10
|
str.gsub(REGEXP, '\1'+multiply_sign+'\4')
|
@@ -13,7 +13,7 @@ module ImproveTypography
|
|
13
13
|
private
|
14
14
|
|
15
15
|
def multiply_sign
|
16
|
-
options.fetch(:multiply_sign,
|
16
|
+
options.fetch(:multiply_sign, translation(:multiply_sign))
|
17
17
|
end
|
18
18
|
end
|
19
19
|
end
|
@@ -2,6 +2,7 @@ module ImproveTypography
|
|
2
2
|
module Processors
|
3
3
|
class SingleQuotes < Processor
|
4
4
|
def call
|
5
|
+
return str unless sign_exists?(single_quotes)
|
5
6
|
return str unless str.match?(/[\'#{single_quotes[0]}#{single_quotes[1]}]/)
|
6
7
|
replace_single_quotes
|
7
8
|
end
|
@@ -17,7 +18,7 @@ module ImproveTypography
|
|
17
18
|
end
|
18
19
|
|
19
20
|
def single_quotes
|
20
|
-
options.fetch(:single_quotes,
|
21
|
+
options.fetch(:single_quotes, translation(:single_quotes))
|
21
22
|
end
|
22
23
|
end
|
23
24
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: improve_typography
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.16
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tomas Celizna
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-05-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: i18n
|
@@ -42,16 +42,16 @@ dependencies:
|
|
42
42
|
name: bundler
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: guard
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -100,14 +100,14 @@ dependencies:
|
|
100
100
|
requirements:
|
101
101
|
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: '
|
103
|
+
version: '13.0'
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: '
|
110
|
+
version: '13.0'
|
111
111
|
description:
|
112
112
|
email:
|
113
113
|
- tomas.celizna@gmail.com
|
@@ -127,6 +127,7 @@ files:
|
|
127
127
|
- bin/setup
|
128
128
|
- improve_typography.gemspec
|
129
129
|
- lib/config/locales/cs.yml
|
130
|
+
- lib/config/locales/da.yml
|
130
131
|
- lib/config/locales/en.yml
|
131
132
|
- lib/improve_typography.rb
|
132
133
|
- lib/improve_typography/base.rb
|
@@ -163,7 +164,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
163
164
|
- !ruby/object:Gem::Version
|
164
165
|
version: '0'
|
165
166
|
requirements: []
|
166
|
-
rubygems_version: 3.
|
167
|
+
rubygems_version: 3.1.4
|
167
168
|
signing_key:
|
168
169
|
specification_version: 4
|
169
170
|
summary: Improves typography (quotes, hyphens, etc.) of a given string. Works well
|