pretty_strings 0.3.0 → 0.4.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 69f404ce3a7e5b50beaffbb42b695c5f110dd9a8
4
- data.tar.gz: 7d06f91be8f0c05f6708ef9b49e90834e4628e23
3
+ metadata.gz: 5ff8178afecac1b22dae2a3f3aa53af39f3521a5
4
+ data.tar.gz: 5c907cc787b34369cefe91d1af62157d8dfcf02b
5
5
  SHA512:
6
- metadata.gz: 5b22be2ebfac04032d66f97c3c262584492ff5fb97be573db5fb3a58b2694750f513f07887ab4e957fbb2861d78dbc8ce1dd1ce85b00b1fef10e41a8e5ad6a82
7
- data.tar.gz: 65c535c17ddcb8c4641120899a4a4174bf184dae6c6c9daf5d0d6f01348548410940f6082ebaaa9584d6605c3c27131bc4664be7f67bcf1e060b6acbc724fd45
6
+ metadata.gz: b83673da5b1c6f9f3ff3207cf547fb513dfbbf6a61bd95ce489fcae2d330901d72f29b45b13f342af5768e9c307bc91bb949480a6e680f7f0575db12f9c6536d
7
+ data.tar.gz: bbb30c81a6ca195531cf103b1ab85f0760808adc7760c5e2fa96551535cbd5f31e5487fa0afbcd3076235b485a9935455521f88cf8d574128b87a310e7644b1b
data/README.md CHANGED
@@ -8,17 +8,16 @@ Some strings have been abused by being run through many a CAT tool (one too many
8
8
 
9
9
  Add this line to your application's Gemfile:
10
10
 
11
- ```ruby
12
- gem 'pretty_strings'
11
+ **Ruby**
12
+ ```
13
+ gem install pretty_strings
13
14
  ```
14
15
 
15
- And then execute:
16
-
17
- $ bundle
18
-
19
- Or install it yourself as:
20
-
21
- $ gem install pretty_strings
16
+ **Ruby on Rails**
17
+ Add this line to your application’s Gemfile:
18
+ ```ruby
19
+ gem 'pretty_strings'
20
+ ```
22
21
 
23
22
  ## Usage
24
23
 
@@ -1,3 +1,3 @@
1
1
  module PrettyStrings
2
- VERSION = "0.3.0"
2
+ VERSION = "0.4.0"
3
3
  end
@@ -13,9 +13,9 @@ Gem::Specification.new do |spec|
13
13
  spec.description = %q{Clean up strings (html entities, html/xml code, unnecessary whitespace, etc.) to prep them to be better searched or analyzed.}
14
14
  spec.homepage = "https://github.com/diasks2/pretty_strings"
15
15
 
16
- spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
- spec.bindir = "exe"
18
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
21
  spec.add_runtime_dependency "rails-html-sanitizer"
@@ -0,0 +1,142 @@
1
+ require 'spec_helper'
2
+
3
+ describe PrettyStrings do
4
+ it 'has a version number' do
5
+ expect(PrettyStrings::VERSION).not_to be nil
6
+ end
7
+
8
+ it "prettifies example #001" do
9
+ text = "Hello World. My name is Jonas."
10
+ expect(PrettyStrings::Cleaner.new(text).pretty).to eq("Hello World. My name is Jonas.")
11
+ end
12
+
13
+ it "prettifies example #002" do
14
+ text = "<ut>{\cs6\f1\cf6\lang1024 </ut>&lt;cf size=&quot;8&quot; complexscriptssize=&quot;8&quot;&gt;<ut>}</ut>Determination of time point of wound closure <ut>{\cs6\f1\cf6\lang1024 </ut>&lt;/cf&gt;&lt;cf size=&quot;8&quot; complexscriptssize=&quot;8&quot; superscript=&quot;on&quot;&gt;<ut>}</ut>K<ut>{\cs6\f1\cf6\lang1024 </ut>&lt;/cf&gt;<ut>}</ut>"
15
+ expect(PrettyStrings::Cleaner.new(text).pretty).to eq("Determination of time point of wound closure K")
16
+ end
17
+
18
+ it "prettifies example #003" do
19
+ text = "<ut>{\cs6\f1\cf6\lang1024 </ut>&lt;/cf&gt;&lt;cf font=&quot;Arial&quot; size=&quot;11&quot; complexscriptsfont=&quot;Arial&quot; complexscriptssize=&quot;11&quot;&gt;<ut>}</ut>DermaPro<ut>{\cs6\f1\cf6\lang1024 </ut>&lt;/cf&gt;&lt;cf font=&quot;Arial&quot; size=&quot;11&quot; complexscriptsfont=&quot;Arial&quot; complexscriptssize=&quot;11&quot; superscript=&quot;on&quot;&gt;<ut>}</ut>®<ut>{\cs6\f1\cf6\lang1024 </ut>&lt;/cf&gt;&lt;cf font=&quot;Arial&quot; size=&quot;11&quot; complexscriptsfont=&quot;Arial&quot; complexscriptssize=&quot;11&quot;&gt;<ut>}</ut> versus isotonic sodium chloride solution in patients with diabetic foot ulcers<ut>{\cs6\f1\cf6\lang1024 </ut>&lt;/cf&gt;<ut>}</ut>"
20
+ expect(PrettyStrings::Cleaner.new(text).pretty).to eq("DermaPro® versus isotonic sodium chloride solution in patients with diabetic foot ulcers")
21
+ end
22
+
23
+ it "prettifies example #004" do
24
+ text = "HS will not refund any applied registration fees or backorder fees for a backordered domain that has been allocated into a Customer's ownership and account."
25
+ expect(PrettyStrings::Cleaner.new(text).pretty).to eq("HS will not refund any applied registration fees or backorder fees for a backordered domain that has been allocated into a Customer's ownership and account.")
26
+ end
27
+
28
+ it "prettifies example #005" do
29
+ text = "40 Hz nominal for a standard kit (48&quot;/12&quot;); &amp;gt;200 Hz for sensor alone"
30
+ expect(PrettyStrings::Cleaner.new(text).pretty).to eq('40 Hz nominal for a standard kit (48"/12"); >200 Hz for sensor alone')
31
+ end
32
+
33
+ it "prettifies example #006" do
34
+ text = "The Edwards SAPIEN transcatheter heart valve is indicated for use in patients with symptomatic aortic stenosis (aortic valve area &amp;amp;lt;0.8 cm2) requiring aortic valve replacement who have high risk for operative mortality, or are “non-operable”, as determined by either or both of the following risk assessments:"
35
+ expect(PrettyStrings::Cleaner.new(text).pretty).to eq("The Edwards SAPIEN transcatheter heart valve is indicated for use in patients with symptomatic aortic stenosis (aortic valve area <0.8 cm2) requiring aortic valve replacement who have high risk for operative mortality, or are “non-operable”, as determined by either or both of the following risk assessments:")
36
+ end
37
+
38
+ it "prettifies example #007" do
39
+ text = "{&#92;f23 3.2.1} {&#92;f23 SCUF (Slow Continuous Ultra-filtration):}"
40
+ expect(PrettyStrings::Cleaner.new(text).pretty).to eq("3.2.1 SCUF (Slow Continuous Ultra-filtration):")
41
+ end
42
+
43
+ it "prettifies example #008" do
44
+ text = nil
45
+ expect(PrettyStrings::Cleaner.new(text).pretty).to eq("")
46
+ end
47
+
48
+ it "prettifies example #009" do
49
+ text = "&amp;amp;lt;CharStyle:&amp;amp;gt;&amp;amp;lt;CharStyle:credit&amp;amp;gt;Reuter et al&amp;amp;lt;cSize:6.000000&amp;amp;gt;&amp;amp;lt;cBaselineShift:4.000000&amp;amp;gt;5&amp;amp;lt;cBaselineShift:&amp;amp;gt;&amp;amp;lt;cSize:&amp;amp;gt;"
50
+ expect(PrettyStrings::Cleaner.new(text).pretty).to eq("Reuter et al5")
51
+ end
52
+
53
+ it "prettifies example #010" do
54
+ text = "Lifesciences S.A. · Ch. du Glapin 6 · 1162 Saint-Prex · Switzerland · 41.21.823.4300&amp;amp;lt;SoftReturn&amp;amp;gt;Edwards"
55
+ expect(PrettyStrings::Cleaner.new(text).pretty).to eq("Lifesciences S.A. · Ch. du Glapin 6 · 1162 Saint-Prex · Switzerland · 41.21.823.4300Edwards")
56
+ end
57
+
58
+ it "prettifies example #011" do
59
+ text = "&amp;amp;lt;CharStyle:legal&amp;amp;gt;5."
60
+ expect(PrettyStrings::Cleaner.new(text).pretty).to eq("5.")
61
+ end
62
+
63
+ it "prettifies example #012" do
64
+ text = "{0}No other express or implied warranty exists, including any warranty of merchantability or fitness for a particular purpose.{1}"
65
+ expect(PrettyStrings::Cleaner.new(text).pretty).to eq("No other express or implied warranty exists, including any warranty of merchantability or fitness for a particular purpose.")
66
+ end
67
+
68
+ it "prettifies example #013" do
69
+ text = "&amp;amp;lt;CharStyle:legal&amp;amp;gt;"
70
+ expect(PrettyStrings::Cleaner.new(text).pretty).to eq("")
71
+ end
72
+
73
+ it "prettifies example #014" do
74
+ text = "&amp;amp;lt;CharStyle:bullets&amp;amp;gt;&amp;amp;lt;cColor:PANTONE 561 C&amp;amp;gt;• &amp;amp;lt;cColor:&amp;amp;gt;Validated against the clinical gold-standard Swan-Ganz pulmonary artery catheter&amp;amp;lt;cSize:6.000000&amp;amp;gt;&amp;amp;lt;cBaselineShift:4.000000&amp;amp;gt;&amp;amp;lt;cLeading:14.000000&amp;amp;gt;1&amp;amp;lt;cLeading:&amp;amp;gt;&amp;amp;lt;cBaselineShift:&amp;amp;gt;&amp;amp;lt;cSize:&amp;amp;gt;"
75
+ expect(PrettyStrings::Cleaner.new(text).pretty).to eq( "• Validated against the clinical gold-standard Swan-Ganz pulmonary artery catheter1")
76
+ end
77
+
78
+ it "prettifies example #015" do
79
+ text = "Hello\n\n\n\n\rWorld"
80
+ expect(PrettyStrings::Cleaner.new(text).pretty).to eq("Hello World")
81
+ end
82
+
83
+ it "prettifies example #016" do
84
+ text = "{&#92;f23 3.2.1}"
85
+ expect(PrettyStrings::Cleaner.new(text).pretty).to eq("3.2.1")
86
+ end
87
+
88
+ it "prettifies example #017" do
89
+ text = "&amp;lt;CharStyle:body copy&amp;gt;The Fl&amp;lt;cTracking:-75&amp;gt;o&amp;lt;cTracking:&amp;gt;Trac system is easy to set up and use, providing real-time &amp;lt;SoftReturn&amp;gt;hemodynamic insight from pre-op to the operating room and to the ICU."
90
+ expect(PrettyStrings::Cleaner.new(text).pretty).to eq("The FloTrac system is easy to set up and use, providing real-time hemodynamic insight from pre-op to the operating room and to the ICU.")
91
+ end
92
+
93
+ it "prettifies example #018" do
94
+ text = "Tabulka 1 ukazuje počet pozorovaných časných komplikací (< 30 dnů u nežádoucích účinků týkajících se chlopně), linearizované počty pozdních komplikací (> 30 dnů po operaci) a počty komplikací 1, 5 a 8 let po operaci."
95
+ expect(PrettyStrings::Cleaner.new(text).pretty).to eq("Tabulka 1 ukazuje počet pozorovaných časných komplikací (< 30 dnů u nežádoucích účinků týkajících se chlopně), linearizované počty pozdních komplikací (> 30 dnů po operaci) a počty komplikací 1, 5 a 8 let po operaci.")
96
+ end
97
+
98
+ it "prettifies example #019" do
99
+ text = "&amp;lt;z6cW&amp;gt;33 - 47 mL/beat/m&amp;lt;V&amp;gt;2"
100
+ expect(PrettyStrings::Cleaner.new(text).pretty).to eq("33 - 47 mL/beat/m2")
101
+ end
102
+
103
+ it "prettifies example #020" do
104
+ text = "Hello\t\tworld."
105
+ expect(PrettyStrings::Cleaner.new(text).pretty).to eq("Hello world.")
106
+ end
107
+
108
+ it "prettifies example #021" do
109
+ text = "&amp;lt;CharStyle:body copy&amp;gt;The Supe&amp;lt;cTracking:-75&amp;gt;r&amp;lt;cTracking:&amp;gt;Track system is easy to set up and use, providing real-time &amp;lt;SoftReturn&amp;gt;insight and stats."
110
+ expect(PrettyStrings::Cleaner.new(text).pretty).to eq("The SuperTrack system is easy to set up and use, providing real-time insight and stats.")
111
+ end
112
+
113
+ it "prettifies example #022" do
114
+ text = "The following tools are included: Déjà Vu X2 (Atril), memoQ (Kilgray), SDL Trados Studio 2009 (SDL) and Wordfast Pro (Wordfast)."
115
+ expect(PrettyStrings::Cleaner.new(text).pretty).to eq("The following tools are included: Déjà Vu X2 (Atril), memoQ (Kilgray), SDL Trados Studio 2009 (SDL) and Wordfast Pro (Wordfast).")
116
+ end
117
+
118
+ it "prettifies example #023" do
119
+ text = "こんにちは、今日は土曜日。"
120
+ expect(PrettyStrings::Cleaner.new(text).pretty).to eq("こんにちは、今日は土曜日。")
121
+ end
122
+
123
+ it "prettifies example #024" do
124
+ text = "**{date}** **{number}** **{email}** **{url}** test"
125
+ expect(PrettyStrings::Cleaner.new(text).pretty).to eq("**{date}** **{number}** **{email}** **{url}** test")
126
+ end
127
+
128
+ it "prettifies example #025" do
129
+ text = "How satisfied were you with the way in which the car was handed over to you?<it pos='begin'>&lt;6&gt;</it>"
130
+ expect(PrettyStrings::Cleaner.new(text).pretty).to eq("How satisfied were you with the way in which the car was handed over to you?")
131
+ end
132
+
133
+ it "prettifies example #026" do
134
+ text = "hello..........................................................................................................................................................................................................................................................................................................................................................."
135
+ expect(PrettyStrings::Cleaner.new(text).pretty).to eq("hello")
136
+ end
137
+
138
+ it "prettifies example #027" do
139
+ text = "hello...what is your name."
140
+ expect(PrettyStrings::Cleaner.new(text).pretty).to eq("hello...what is your name.")
141
+ end
142
+ end
@@ -0,0 +1,2 @@
1
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
+ require 'pretty_strings'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pretty_strings
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
  - Kevin S. Dias
8
8
  autorequire:
9
- bindir: exe
9
+ bindir: bin
10
10
  cert_chain: []
11
- date: 2016-01-20 00:00:00.000000000 Z
11
+ date: 2016-01-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails-html-sanitizer
@@ -81,11 +81,11 @@ files:
81
81
  - LICENSE.txt
82
82
  - README.md
83
83
  - Rakefile
84
- - bin/console
85
- - bin/setup
86
84
  - lib/pretty_strings.rb
87
85
  - lib/pretty_strings/version.rb
88
86
  - pretty_strings.gemspec
87
+ - spec/pretty_strings_spec.rb
88
+ - spec/spec_helper.rb
89
89
  homepage: https://github.com/diasks2/pretty_strings
90
90
  licenses: []
91
91
  metadata: {}
@@ -110,4 +110,6 @@ signing_key:
110
110
  specification_version: 4
111
111
  summary: Take strings that have been abused in the wild and clean them up (for translation
112
112
  tools)
113
- test_files: []
113
+ test_files:
114
+ - spec/pretty_strings_spec.rb
115
+ - spec/spec_helper.rb
data/bin/console DELETED
@@ -1,14 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require "bundler/setup"
4
- require "pretty_strings"
5
-
6
- # You can add fixtures and/or initialization code here to make experimenting
7
- # with your gem easier. You can also use a different console, if you like.
8
-
9
- # (If you use this, don't forget to add pry to your Gemfile!)
10
- # require "pry"
11
- # Pry.start
12
-
13
- require "irb"
14
- IRB.start
data/bin/setup DELETED
@@ -1,7 +0,0 @@
1
- #!/bin/bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
-
5
- bundle install
6
-
7
- # Do any other automated setup that you need to do here