email_signature_parser 0.1.1 → 0.1.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: 276004e620bb311863f8af53b6247b3d65160242e78e1eedde1cb4dba302cc1b
4
- data.tar.gz: b92b2222b0b64f97c67f19ecd6a4026cf93e622c7a685d8ba61090b0ecc0391f
3
+ metadata.gz: 1bfc690817d76870045cb565082894471ff91b530c1ca0d29b0f8932a485f3a0
4
+ data.tar.gz: e8a0d00b64d50b77c8ea8a43c449e4ae03e6dc7e94d78e6c22bf6ff26c87ab9e
5
5
  SHA512:
6
- metadata.gz: 6bab1405757b03908ffd6a973f45c24689c0b6eebf5b9f832c0d2bda35dfa7dde9bf6c46e7e4dbf50b8060baf00d91e15a031499d4ac1a429883ab567e9fdf4a
7
- data.tar.gz: 840e2be844581a467912f5af19b99035f87dd0932dd652f89d0215ee71af342c81193e22eef505a4d6d18e4b00f9f0acffeee4bd5f44f2c40185974b7a325b8a
6
+ metadata.gz: 0ff3f082a7d0366b6953db51ab0139fe5482ca2216c773f255547f4c51634946c3419e112c70a70cbfcfaba51e5f492312013aca4527050d063005deef73d95f
7
+ data.tar.gz: 1069582d064cff2b58898f5bdb01a86d6478e0f38a20c2cb63437382871624502c5062c3cf84ea9444b8771dbbfb2ba8dd217b51cc90c8636825301cb1baeff9
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # EmailSignatureParser
2
2
 
3
- A Ruby gem for parsing email signatures. The gem tries to find the signature based on the name, if available, or email address and try to extract as much information as it can from the
3
+ A Ruby gem for parsing email signatures. The gem tries to find the signature based on the name, if available, or email address and try to extract as much information as it can
4
4
 
5
5
  ## Prerequisites
6
6
 
@@ -92,8 +92,8 @@ It will return a hash with whatever could be extracted from the signature
92
92
  ]
93
93
  },
94
94
  "job_title": {
95
- "title": "",
96
- "acronym": "CEO"
95
+ "titles": ["Sales Marketing VP"],
96
+ "acronyms": ["CEO"]
97
97
  },
98
98
  "text": "Text of the signature",
99
99
  "company_name": "TestCompany Ltd"
@@ -96,10 +96,10 @@ module EmailSignatureParser
96
96
  @parsed_text << "\n-------------------------------------------------------------------------------------------------------------------------------------------------\n"
97
97
  end
98
98
 
99
- if (@current_element == :ol && name == :start)
99
+ if (@current_element == :ol && name == :start && !@lists.last.nil?)
100
100
  @lists.last[:ordered_list_level] = value.to_i
101
101
  end
102
- if (@current_element == :ol && name == :type)
102
+ if (@current_element == :ol && name == :type && !@lists.last.nil?)
103
103
  @lists.last[:ordered_list_type] = value
104
104
  end
105
105
  end
@@ -62,17 +62,16 @@ module EmailSignatureParser
62
62
  COMMON_COMPANY_ENDINGS = [
63
63
  # English suffixes
64
64
  'inc', 'incorporated', 'corp', 'corporation', 'company', 'co', 'ltd', 'limited',
65
- 'llc', 'lp', 'limited partnership', 'plc', 'public limited company',
65
+ 'llc', 'lp', 'partnership', 'plc', 'public',
66
66
  'enterprises', 'group', 'holdings', 'international', 'intl', 'worldwide',
67
67
  'global', 'associates', 'partners', 'consulting', 'services', 'solutions',
68
68
  'systems', 'technologies', 'tech', 'industries', 'manufacturing', 'mfg',
69
69
 
70
70
  # Spanish suffixes
71
- 'sa', 'sociedad anónima', 'sl', 'sociedad limitada', 'srl', 'sociedad de responsabilidad limitada',
72
- 'sc', 'sociedad colectiva', 'scp', 'sociedad civil particular', 'scpp', 'sociedad civil público privada',
73
- 'sad', 'sociedad anónima deportiva', 'sal', 'sociedad anónima laboral', 'sll', 'sociedad limitada laboral',
74
- 'sau', 'sociedad anónima unipersonal', 'slu', 'sociedad limitada unipersonal',
75
- 'sociedad', 'compañía', 'cia', 'empresa', 'corporación', 'grupo', 'holding',
71
+ 'sa', 'sociedad', 'anónima', 'sl', 'srl', 'responsabilidad', 'limitada',
72
+ 'sc', 'scp', 'colectiva', 'civil', 'particular', 'scpp', 'público', 'privada',
73
+ 'sad', 'deportiva', 'sal', 'laboral', 'sll',
74
+ 'sau', 'unipersonal', 'slu', 'compañía', 'cia', 'empresa', 'corporación', 'grupo', 'holding',
76
75
  'internacional', 'mundial', 'global', 'asociados', 'socios', 'consultoría',
77
76
  'servicios', 'soluciones', 'sistemas', 'tecnologías', 'industrias', 'industrial',
78
77
  'ltda', 'limitada',
@@ -625,20 +624,11 @@ module EmailSignatureParser
625
624
  end
626
625
  end
627
626
 
628
- job_title = {}
627
+ job_title = {
628
+ titles: parsed_titles,
629
+ acronyms: acronyms_found
630
+ }
629
631
 
630
- if acronyms_found.size == 1
631
- job_title[:acronym] = acronyms_found.first
632
- elsif acronyms_found.size > 1
633
- job_title[:acronyms] = acronyms_found
634
- end
635
-
636
- if parsed_titles.size == 1
637
- job_title[:title] = parsed_titles.first
638
- elsif parsed_titles.size > 1
639
- job_title[:titles] = parsed_titles
640
- end
641
-
642
632
  return [company_name.uniq.join(" "), job_title]
643
633
  end
644
634
 
@@ -853,7 +843,11 @@ module EmailSignatureParser
853
843
  unless !email_html_body.nil? && !email_html_body.empty?
854
844
  raise InvalidEmailError, "No email body provided"
855
845
  end
856
-
846
+
847
+ if from.downcase.include?("reply") || from.downcase.include?("mailer-daemon")
848
+ raise InvalidFromError, "No valid From address"
849
+ end
850
+
857
851
 
858
852
  name, email_address = extract_name_and_email(from)
859
853
  parsed_text = parse_email_html(email_html_body)
@@ -872,6 +866,10 @@ module EmailSignatureParser
872
866
  raise InvalidFromError, "No from provided"
873
867
  end
874
868
 
869
+ if from.downcase.include?("reply") || from.downcase.include?("mailer-daemon")
870
+ raise InvalidFromError, "No valid From address"
871
+ end
872
+
875
873
  if meeting_email?(email_body)
876
874
  raise InvalidEmailError, "Email appears to be a meeting invite"
877
875
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: email_signature_parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Guillermo Molini
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-10-15 00:00:00.000000000 Z
11
+ date: 2025-10-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ruby_postal