crm_formatter 2.5 → 2.6
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 +4 -4
- data/README.md +88 -74
- data/Rakefile +17 -15
- data/lib/crm_formatter/tools.rb +58 -7
- data/lib/crm_formatter/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b66f8317ec1e74e46058adc3ed9709f48655ab77edf30f3f84d7551aeda075fd
|
|
4
|
+
data.tar.gz: e5aba562f330b7c9354f56a8864ec09386e05612d15835aadbdc543116144488
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a15c2adff359992692e7ca2567bb4f7df2eba16154b8390650a3261ea832dcbb75858d88dee9cf5db47ede3af40f250bc9eee25c04cafe7175225189ba25f130
|
|
7
|
+
data.tar.gz: 013ed660aa7e50db5e93be55f28b006af45912b225d49d7d8ab0d8e1feea3b66fa2034c51e1b0428c1e79b3d96ad3ad32fdbc028aeeefef268cfafaef2b2112c
|
data/README.md
CHANGED
|
@@ -37,6 +37,7 @@ format_urls(array_of_urls)
|
|
|
37
37
|
```
|
|
38
38
|
|
|
39
39
|
1. Format Array of Proper Strings:
|
|
40
|
+
|
|
40
41
|
Use `format_propers` to format strings with proper nouns, such as (but not limited to):
|
|
41
42
|
|
|
42
43
|
Business Account Names (123 bmw-world => 123 BMW-World),
|
|
@@ -49,14 +50,16 @@ Article Titles (the 15 most useful ruby methods => The 15 Most Useful Ruby Metho
|
|
|
49
50
|
|
|
50
51
|
```
|
|
51
52
|
array_of_propers = [
|
|
52
|
-
'
|
|
53
|
-
'Car-world Kia',
|
|
53
|
+
'the gmc and bmw-world of AUSTIN tx',
|
|
54
|
+
'123 Car-world Kia OF CHICAGO IL',
|
|
55
|
+
'Main Street Ford in DALLAS tX',
|
|
56
|
+
'broad st fiat of houston',
|
|
57
|
+
'hot-deal auto insurance',
|
|
54
58
|
'BUDGET - AUTOMOTORES ZONA & FRANCA, INC',
|
|
55
59
|
'DOWNTOWN CAR REPAIR, INC',
|
|
56
60
|
'Young Gmc Trucks',
|
|
57
61
|
'TEXAS TRAVEL, CO',
|
|
58
62
|
'youmans Chevrolet',
|
|
59
|
-
'Hot-Deal auto Insurance',
|
|
60
63
|
'quick auto approval, inc',
|
|
61
64
|
'yazell chevy',
|
|
62
65
|
'quick cAr LUBE',
|
|
@@ -71,77 +74,88 @@ formatted_proper_hashes = CrmFormatter.format_propers(array_of_propers)
|
|
|
71
74
|
Formatted Proper Strings:
|
|
72
75
|
|
|
73
76
|
```
|
|
74
|
-
formatted_proper_hashes =
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
:
|
|
78
|
-
:
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
77
|
+
formatted_proper_hashes =
|
|
78
|
+
[
|
|
79
|
+
{
|
|
80
|
+
proper_status: 'formatted',
|
|
81
|
+
proper: 'the gmc and bmw-world of AUSTIN tx',
|
|
82
|
+
proper_f: 'The GMC and BMW-World of Austin TX'
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
proper_status: 'formatted',
|
|
86
|
+
proper: '123 Car-world Kia OF CHICAGO IL',
|
|
87
|
+
proper_f: '123 Car-World Kia of Chicago IL'
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
proper_status: 'formatted',
|
|
91
|
+
proper: 'Main Street Ford in DALLAS tX',
|
|
92
|
+
proper_f: 'Main Street Ford in Dallas TX'
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
proper_status: 'formatted',
|
|
96
|
+
proper: 'broad st fiat of houston',
|
|
97
|
+
proper_f: 'Broad St Fiat of Houston'
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
proper_status: 'formatted',
|
|
101
|
+
proper: 'hot-deal auto insurance',
|
|
102
|
+
proper_f: 'Hot-Deal Auto Insurance'
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
proper_status: 'formatted',
|
|
106
|
+
proper: 'BUDGET - AUTOMOTORES ZONA & FRANCA, INC',
|
|
107
|
+
proper_f: 'Budget - Automotores Zona & Franca, Inc'
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
proper_status: 'formatted',
|
|
111
|
+
proper: 'DOWNTOWN CAR REPAIR, INC',
|
|
112
|
+
proper_f: 'Downtown Car Repair, Inc'
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
proper_status: 'formatted',
|
|
116
|
+
proper: 'Young Gmc Trucks',
|
|
117
|
+
proper_f: 'Young GMC Trucks'
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
proper_status: 'formatted',
|
|
121
|
+
proper: 'TEXAS TRAVEL, CO',
|
|
122
|
+
proper_f: 'Texas Travel, Co'
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
proper_status: 'formatted',
|
|
126
|
+
proper: 'youmans Chevrolet',
|
|
127
|
+
proper_f: 'Youmans Chevrolet'
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
proper_status: 'formatted',
|
|
131
|
+
proper: 'quick auto approval, inc',
|
|
132
|
+
proper_f: 'Quick Auto Approval, Inc'
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
proper_status: 'formatted',
|
|
136
|
+
proper: 'yazell chevy',
|
|
137
|
+
proper_f: 'Yazell Chevy'
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
proper_status: 'formatted',
|
|
141
|
+
proper: 'quick cAr LUBE',
|
|
142
|
+
proper_f: 'Quick Car Lube'
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
proper_status: 'formatted',
|
|
146
|
+
proper: 'yAtEs AuTo maLL',
|
|
147
|
+
proper_f: 'Yates Auto Mall'
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
proper_status: 'formatted',
|
|
151
|
+
proper: 'YADKIN VALLEY COLLISION CO',
|
|
152
|
+
proper_f: 'Yadkin Valley Collision Co'
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
proper_status: 'formatted',
|
|
156
|
+
proper: 'XIT FORD INC',
|
|
157
|
+
proper_f: 'Xit Ford Inc'
|
|
158
|
+
}
|
|
145
159
|
]
|
|
146
160
|
```
|
|
147
161
|
|
data/Rakefile
CHANGED
|
@@ -27,21 +27,23 @@ end
|
|
|
27
27
|
#############################################
|
|
28
28
|
def format_propers
|
|
29
29
|
array_of_propers = [
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
30
|
+
'the gmc and bmw-world of AUSTIN tx',
|
|
31
|
+
'123 Car-world Kia OF CHICAGO IL',
|
|
32
|
+
'Main Street Ford in DALLAS tX',
|
|
33
|
+
'broad st fiat of houston',
|
|
34
|
+
'hot-deal auto insurance',
|
|
35
|
+
'BUDGET - AUTOMOTORES ZONA & FRANCA, INC',
|
|
36
|
+
'DOWNTOWN CAR REPAIR, INC',
|
|
37
|
+
'Young Gmc Trucks',
|
|
38
|
+
'TEXAS TRAVEL, CO',
|
|
39
|
+
'youmans Chevrolet',
|
|
40
|
+
'quick auto approval, inc',
|
|
41
|
+
'yazell chevy',
|
|
42
|
+
'quick cAr LUBE',
|
|
43
|
+
'yAtEs AuTo maLL',
|
|
44
|
+
'YADKIN VALLEY COLLISION CO',
|
|
45
|
+
'XIT FORD INC'
|
|
46
|
+
]
|
|
45
47
|
|
|
46
48
|
formatted_propers = CrmFormatter.format_propers(array_of_propers)
|
|
47
49
|
formatted_propers
|
data/lib/crm_formatter/tools.rb
CHANGED
|
@@ -5,14 +5,24 @@ module CrmFormatter
|
|
|
5
5
|
|
|
6
6
|
def letter_case_check(str)
|
|
7
7
|
return unless str.present?
|
|
8
|
-
|
|
9
|
-
str = str.upcase.split(' ')&.each { |el| el.capitalize! if el.gsub(/[^ A-Za-z]/, '')&.strip }&.join(' ')
|
|
8
|
+
str = force_capitalize(str)
|
|
10
9
|
str = capitalize_dashes(str)
|
|
11
|
-
str =
|
|
10
|
+
str = force_upcase(str)
|
|
11
|
+
str = force_downcase(str)
|
|
12
|
+
str = force_first_cap(str)
|
|
12
13
|
str
|
|
13
14
|
end
|
|
14
15
|
|
|
16
|
+
def force_capitalize(str)
|
|
17
|
+
return unless str.present?
|
|
18
|
+
str_parts = str.downcase.split(' ')&.each do |el|
|
|
19
|
+
el.capitalize! if el.gsub(/[^ A-Za-z]/, '')&.strip
|
|
20
|
+
end
|
|
21
|
+
str = str_parts&.join(' ')
|
|
22
|
+
end
|
|
23
|
+
|
|
15
24
|
def capitalize_dashes(str)
|
|
25
|
+
return unless str.present?
|
|
16
26
|
if str&.include?('-')
|
|
17
27
|
els = str.split(' ')
|
|
18
28
|
dash_els = els.select { |el| el != '-' && el.include?('-') }
|
|
@@ -25,12 +35,53 @@ module CrmFormatter
|
|
|
25
35
|
str
|
|
26
36
|
end
|
|
27
37
|
|
|
28
|
-
def
|
|
38
|
+
def force_upcase(str)
|
|
39
|
+
return unless str.present?
|
|
40
|
+
str = add_space(str)
|
|
41
|
+
|
|
42
|
+
grab_ups.map do |up|
|
|
43
|
+
str = str.gsub(" #{up.capitalize} ", " #{up} ")
|
|
44
|
+
str = str.gsub(" #{up.capitalize}-", " #{up}-")
|
|
45
|
+
str = str.gsub("-#{up.capitalize} ", "-#{up} ")
|
|
46
|
+
end
|
|
47
|
+
str = strip_squeeze(str)
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def force_downcase(str)
|
|
29
51
|
return unless str.present?
|
|
30
|
-
|
|
31
|
-
|
|
52
|
+
str = add_space(str)
|
|
53
|
+
|
|
54
|
+
grab_downs.map do |down|
|
|
55
|
+
str = str.gsub(" #{down.capitalize} ", " #{down} ")
|
|
32
56
|
end
|
|
33
|
-
str
|
|
57
|
+
str = strip_squeeze(str)
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def force_first_cap(str)
|
|
61
|
+
str = "#{str[0].upcase}#{str[1..-1]}"
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def add_space(str)
|
|
65
|
+
return unless str.present?
|
|
66
|
+
str = " #{str} "
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def strip_squeeze(str)
|
|
70
|
+
str = str.squeeze(" ")
|
|
71
|
+
str = str.strip
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def grab_downs
|
|
75
|
+
downs = %w[and as both but either for from in just neither nor of only or out so the to whether with yet]
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
def grab_ups
|
|
79
|
+
ups = %w[I]
|
|
80
|
+
brands = %w[BMW CDJR CJDR GMC CJD I]
|
|
81
|
+
professional = %w[BA BS MA JD DC PA MD VP SVP EVP CMO CFO CEO]
|
|
82
|
+
states = %w[AK AL AR AZ CA CT DC DE FL GA HI IA ID IL KS KY LA MA MD MI MN MO NC ND NE NH NJ NM NV NY OH OK PA RI SC SD TN TX UT VA VT WA WI WV WY]
|
|
83
|
+
directions = %w[NE NW SE SW]
|
|
84
|
+
ups = [brands, professional, states, directions].flatten.uniq
|
|
34
85
|
end
|
|
35
86
|
|
|
36
87
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: crm_formatter
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: '2.
|
|
4
|
+
version: '2.6'
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Adam Booth
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2018-06-
|
|
11
|
+
date: 2018-06-29 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: pry
|