orthotypo 1.0.2 → 1.0.3

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
  SHA256:
3
- metadata.gz: f2f6a258873f18c7dc354138d1c32a75eb53c185ff8df8352222d5ea67eff0cf
4
- data.tar.gz: be6d6756ec6f2925304776c150448c0e34469a32b95e92cbf3e54b64a9f581ac
3
+ metadata.gz: 818fb1bd3d3eb901d75f4e02210bf77fd7602b1d032003a3dac4f8a74d82f947
4
+ data.tar.gz: eef332835ee689969703219a8ddb6807c2f7d4d6d0e066ec71e9b1d68010e3ed
5
5
  SHA512:
6
- metadata.gz: 1138ac9e055c6b87db9117b6640bb32457dd20a35306e87da7665a5496485aa89a82e18f9bde2329c77533a64815cdfbfbd44bb6fa2d17c2f5b0f576f80adee0
7
- data.tar.gz: fd5f3571d645b7facf19afa56d7c6700724dbe6d8f5372ce3bc8a68bfa14d346408cf7a64fe8c8b34fc3db5e5037f4173ed268651c8fdcde133e3a89a39e3542
6
+ metadata.gz: 6055df7db77d195116bd55015ceecc22c7799991a13cfbd0f7fc01868afe16bf6c1578763a972c4ceee032fb72736388353463468cfd8a1596c8c54b659f854c
7
+ data.tar.gz: 6643636a85073aecf213a8c533882fe960d275acead499b91cf92fa7ce987de006d9951b520e6077e234b951c44ff825002f1af692edcfafd1291d072942dcc7
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- orthotypo (1.0.2)
4
+ orthotypo (1.0.3)
5
5
  htmlentities
6
6
  nokogiri
7
7
 
@@ -2,10 +2,12 @@ module Orthotypo
2
2
  class Analyzer
3
3
 
4
4
  def self.url?(string)
5
- (string =~ /\A#{URI::DEFAULT_PARSER.regexp[:ABS_URI]}\z/) &&
6
- (string =~ /\A(http|https):\/\/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(:[0-9]{1,5})?(\/.*)?\z/ix) ? true : false
5
+ uri = URI.parse(string)
6
+ uri.class != URI::Generic
7
+ rescue URI::InvalidURIError
8
+ false
7
9
  end
8
-
10
+
9
11
  def self.email?(string)
10
12
  string =~ /\A#{URI::MailTo::EMAIL_REGEXP}\z/ ? true : false
11
13
  end
@@ -13,6 +15,6 @@ module Orthotypo
13
15
  def self.precious?(string)
14
16
  email?(string) || url?(string)
15
17
  end
16
-
18
+
17
19
  end
18
20
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Orthotypo
4
- VERSION = "1.0.2"
4
+ VERSION = "1.0.3"
5
5
  end
@@ -3,6 +3,8 @@ require 'spec_helper'
3
3
  describe Orthotypo::Analyzer do
4
4
  it 'find urls' do
5
5
  expect(Orthotypo::Analyzer.url?("https://unsplash.com/@lusvardi?utm_source=osuny")).to be true
6
+ expect(Orthotypo::Analyzer.url?("https://hal.science/hal-02455856")).to be true
7
+ expect(Orthotypo::Analyzer.url?("mailto:test@example.com")).to be true
6
8
  expect(Orthotypo::Analyzer.url?("mot:")).to be false
7
9
  end
8
10
  end
@@ -5,7 +5,7 @@ describe Orthotypo::Composer::Fr do
5
5
  it 'adds spaces before double punctuation marks' do
6
6
  expect("mot: suite".ortho).to(eq("mot : suite"))
7
7
  expect("é: suite".ortho).to(eq("é : suite"))
8
- # Pas automatisable, parce que 11:20
8
+ # Pas automatisable, parce qu'on peut écrire une heure 11:20
9
9
  # expect("1: suite".ortho).to(eq("1 : suite"))
10
10
  expect("mot; suite".ortho).to(eq("mot ; suite"))
11
11
  expect("mot!".ortho).to(eq("mot !"))
@@ -27,11 +27,12 @@ describe Orthotypo::Composer::Fr do
27
27
 
28
28
  it 'fixes space after simple punctuation' do
29
29
  expect("mot,suite".ortho).to(eq("mot, suite"))
30
+ expect("84.Paris".ortho).to(eq("84.Paris"))
30
31
  expect("etudiant.gouv.fr".ortho).to(eq("etudiant.gouv.fr"))
31
32
  expect("4,5".ortho).to(eq("4,5"))
32
33
  expect("4.5".ortho).to(eq("4.5"))
33
- # Le test suivant, on ne fait rien, on ne peut pas résoudre, car s'apparente au cas précédent.
34
- expect("Il est né en 1984.5 maisons en paille".ortho).to(eq("Il est né en 1984.5 maisons en paille"))
34
+ # Le test suivant, on ne fait rien, on ne peut pas résoudre, car s'apparente au cas précédent (1984.5)
35
+ # expect("Il est né en 1984.5 maisons en paille".ortho).to(eq("Il est né en 1984. 5 maisons en paille"))
35
36
  end
36
37
 
37
38
  it 'fixes quotation marks' do
@@ -68,6 +69,10 @@ describe Orthotypo::Composer::Fr do
68
69
  expect("A parallel between wildlife and urban ensembles.\r\rShot during summer 2014 on our trip from north to south of Portugal.".ortho).to(eq("A parallel between wildlife and urban ensembles.<br><br>Shot during summer 2014 on our trip from north to south of Portugal."))
69
70
  end
70
71
 
72
+ it 'preserves URLs' do
73
+ expect("https://hal.science/hal-02455856".ortho).to(eq("https://hal.science/hal-02455856"))
74
+ end
75
+
71
76
  # https://www.scribbr.fr/elements-linguistiques/les-espaces/
72
77
  it 'tests de Justine Debret' do
73
78
  # FIXME
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: orthotypo
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Arnaud Levy
@@ -140,7 +140,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
140
140
  - !ruby/object:Gem::Version
141
141
  version: '0'
142
142
  requirements: []
143
- rubygems_version: 3.4.10
143
+ rubygems_version: 3.5.5
144
144
  signing_key:
145
145
  specification_version: 4
146
146
  summary: Pour un texte correctement typographié