crm_formatter 1.0.3.pre.rc.1 → 1.0.4.pre.rc.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/crm_formatter.gemspec +2 -4
- data/lib/crm_formatter/phone.rb +2 -2
- data/lib/crm_formatter/version.rb +1 -1
- data/lib/crm_formatter/web.rb +19 -19
- metadata +9 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 424ebc11d4c279d201981d650185cedefe8246bc990921337e82c438eead6bee
|
4
|
+
data.tar.gz: ca7827e6c645e83310e67dc513954beb2b623de692860c6dce33d4fbf8b23e86
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 59f9d1fbf15cfc95ead528671370adaeb4e2f45e9dff18fa3cf48b9689b55caa068a9321e02e6aa189884af43cdd32be31124899a07b27969018eb0864f59c00
|
7
|
+
data.tar.gz: 1bee91fe0cd638eb2f2263b3fce308d7f4d71e4bd0ab2de861585a27b14f3095491cfb66f6bbb5143c873b323a383e36465b7e867cf7c3e1740b836e7e2d70d0
|
data/crm_formatter.gemspec
CHANGED
@@ -9,8 +9,8 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.authors = ["Adam Booth"]
|
10
10
|
spec.email = ["4rlm@protonmail.ch"]
|
11
11
|
|
12
|
-
spec.summary = %q{
|
13
|
-
spec.description = %q{
|
12
|
+
spec.summary = %q{Reformat and Normalize CRM Contact Data, Addresses, Phones, Emails and URLs}
|
13
|
+
spec.description = %q{Reformat and Normalize CRM Contact Data, Addresses, Phones, Emails and URLs. Originally developed for proprietary use in an enterprise software suite. Recently decided to make them open source in a gem. It's a work in progress as there are additional features being added in near future. Also creating additonal gems with similar CRM office efficiency objectives. Please contact me if you have any questions or comments.}
|
14
14
|
spec.homepage = "https://github.com/4rlm/crm_formatter"
|
15
15
|
spec.license = "MIT"
|
16
16
|
|
@@ -22,6 +22,4 @@ Gem::Specification.new do |spec|
|
|
22
22
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
23
23
|
spec.require_paths = ["lib"]
|
24
24
|
|
25
|
-
spec.add_development_dependency "pry", "~> 0.10.4"
|
26
|
-
|
27
25
|
end
|
data/lib/crm_formatter/phone.rb
CHANGED
@@ -5,13 +5,13 @@ module CRMFormatter
|
|
5
5
|
|
6
6
|
# Call: Formatter.new.validate_phone(phone)
|
7
7
|
def validate_phone(phone)
|
8
|
-
phone_hsh = { phone: phone, valid_phone: nil,
|
8
|
+
phone_hsh = { phone: phone, valid_phone: nil, phone_edit: false }
|
9
9
|
if phone.present?
|
10
10
|
phone = phone&.gsub(/\s/, ' ')&.strip
|
11
11
|
reg = Regexp.new("[(]?[0-9]{3}[ ]?[)-.]?[ ]?[0-9]{3}[ ]?[-. ][ ]?[0-9]{4}")
|
12
12
|
return phone_hsh if phone.first == "0" || phone.include?("(0") || !reg.match(phone)
|
13
13
|
phone_hsh[:valid_phone] = format_phone(phone)
|
14
|
-
phone_hsh[:
|
14
|
+
phone_hsh[:phone_edit] = phone_hsh[:phone] != phone_hsh[:valid_phone]
|
15
15
|
end
|
16
16
|
phone_hsh
|
17
17
|
end
|
data/lib/crm_formatter/web.rb
CHANGED
@@ -2,16 +2,16 @@ module CRMFormatter
|
|
2
2
|
class Web
|
3
3
|
|
4
4
|
def initialize(args={})
|
5
|
-
@
|
6
|
-
@
|
7
|
-
@
|
8
|
-
@
|
5
|
+
@url_flags = args.fetch(:url_flags, [])
|
6
|
+
@link_flags = args.fetch(:link_flags, [])
|
7
|
+
@href_flags = args.fetch(:href_flags, [])
|
8
|
+
@extension_flags = args.fetch(:ext_flags, [])
|
9
9
|
@length_min = args.fetch(:length_min, 2)
|
10
10
|
@length_max = args.fetch(:length_max, 100)
|
11
11
|
end
|
12
12
|
|
13
13
|
def format_url(url)
|
14
|
-
url_hsh = {
|
14
|
+
url_hsh = {url_path: url, formatted_url: nil, url_edit: false }
|
15
15
|
if url.present?
|
16
16
|
begin
|
17
17
|
url = url&.split('|')&.first
|
@@ -34,8 +34,8 @@ module CRMFormatter
|
|
34
34
|
if uri.present?
|
35
35
|
host_parts = uri.host&.split(".")
|
36
36
|
|
37
|
-
if @
|
38
|
-
bad_host_sts = host_parts&.map { |part| TRUE if @
|
37
|
+
if @ext_flags.any?
|
38
|
+
bad_host_sts = host_parts&.map { |part| TRUE if @ext_flags.any? {|ext| part == ext } }&.compact&.first
|
39
39
|
return url_hsh if bad_host_sts
|
40
40
|
end
|
41
41
|
|
@@ -44,9 +44,9 @@ module CRMFormatter
|
|
44
44
|
url = "#{scheme}://#{host}" if host.present? && scheme.present?
|
45
45
|
url = "http://#{url}" if url[0..3] != "http"
|
46
46
|
url = url.gsub("//", "//www.") if !url.include?("www.")
|
47
|
-
return url_hsh if @
|
48
|
-
url_hsh[:
|
49
|
-
url_hsh[:
|
47
|
+
return url_hsh if @url_flags.any? { |bad_text| url&.include?(bad_text) }
|
48
|
+
url_hsh[:formatted_url] = convert_to_scheme_host(url) if url.present?
|
49
|
+
url_hsh[:url_edit] = url_hsh[:formatted_url] != url_hsh[:url_path]
|
50
50
|
end
|
51
51
|
rescue
|
52
52
|
return url_hsh
|
@@ -77,11 +77,11 @@ module CRMFormatter
|
|
77
77
|
end
|
78
78
|
|
79
79
|
|
80
|
-
def extract_link(
|
81
|
-
url_hsh = format_url(
|
82
|
-
url = url_hsh[:
|
83
|
-
link =
|
84
|
-
link_hsh = {
|
80
|
+
def extract_link(url_path)
|
81
|
+
url_hsh = format_url(url_path)
|
82
|
+
url = url_hsh[:formatted_url]
|
83
|
+
link = url_path
|
84
|
+
link_hsh = {url_path: url_path, url: url, link: nil }
|
85
85
|
if url.present? && link.present? && link.length > @length_min
|
86
86
|
url = strip_down_url(url)
|
87
87
|
link = strip_down_url(link)
|
@@ -111,8 +111,8 @@ module CRMFormatter
|
|
111
111
|
link_hsh = {link: link, valid_link: nil, flags: nil }
|
112
112
|
if link.present?
|
113
113
|
invalid_chars = ['(', ')', '[', ']', '{', '}', '*', '@', '^', '$', '%', '+', '!', '<', '>', '~', ',', "'"]
|
114
|
-
@
|
115
|
-
flags = @
|
114
|
+
@link_flags += invalid_chars
|
115
|
+
flags = @link_flags.select { |red| link&.include?(red) }
|
116
116
|
flags << "below #{@length_min}" if link.length < @length_min
|
117
117
|
flags << "over #{@length_max}" if link.length > @length_max
|
118
118
|
flags = flags.flatten.compact
|
@@ -128,7 +128,7 @@ module CRMFormatter
|
|
128
128
|
href_hsh = {href: href, valid_href: nil, flags: nil }
|
129
129
|
if href.present?
|
130
130
|
symbs = ['{', '}', '*', '@', '^', '$', '%', '+', '!', '<', '>', '~']
|
131
|
-
@
|
131
|
+
@href_flags += symbs
|
132
132
|
href = href.split('|').join(' ')
|
133
133
|
href = href.split('/').join(' ')
|
134
134
|
href&.gsub!("(", ' ')
|
@@ -145,7 +145,7 @@ module CRMFormatter
|
|
145
145
|
href = href&.downcase
|
146
146
|
href = href&.strip
|
147
147
|
|
148
|
-
flags << @
|
148
|
+
flags << @href_flags.select { |red| href&.include?(red) }
|
149
149
|
flags = flags.flatten.compact.uniq
|
150
150
|
href_hsh[:valid_href] = href unless flags.any?
|
151
151
|
href_hsh[:flags] = flags.join(', ')
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: crm_formatter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.4.pre.rc.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Booth
|
@@ -9,22 +9,13 @@ autorequire:
|
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
11
|
date: 2018-05-13 00:00:00.000000000 Z
|
12
|
-
dependencies:
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
version: 0.10.4
|
20
|
-
type: :development
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - "~>"
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: 0.10.4
|
27
|
-
description: Formats addresses, phones, emails, urls
|
12
|
+
dependencies: []
|
13
|
+
description: Reformat and Normalize CRM Contact Data, Addresses, Phones, Emails and
|
14
|
+
URLs. Originally developed for proprietary use in an enterprise software suite. Recently
|
15
|
+
decided to make them open source in a gem. It's a work in progress as there are
|
16
|
+
additional features being added in near future. Also creating additonal gems with
|
17
|
+
similar CRM office efficiency objectives. Please contact me if you have any questions
|
18
|
+
or comments.
|
28
19
|
email:
|
29
20
|
- 4rlm@protonmail.ch
|
30
21
|
executables: []
|
@@ -64,5 +55,5 @@ rubyforge_project:
|
|
64
55
|
rubygems_version: 2.7.6
|
65
56
|
signing_key:
|
66
57
|
specification_version: 4
|
67
|
-
summary:
|
58
|
+
summary: Reformat and Normalize CRM Contact Data, Addresses, Phones, Emails and URLs
|
68
59
|
test_files: []
|