listserv 0.0.2 → 0.1.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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/listserv.rb +23 -10
  3. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e92b32d9c5eb1a531a6775fe93bb87aaebbf1492
4
- data.tar.gz: 923ba68e2de70d24375c2f692f574b93de1aea48
3
+ metadata.gz: 037d8eff57ddd65cdb61072b6f11ffdda37d1982
4
+ data.tar.gz: 23d88a1d2437885690d58d5299f9419bc6231e2c
5
5
  SHA512:
6
- metadata.gz: 825ed3e42c84abd88cd454999af9e633445c004b9098b45ea0cc862f4cb2af7e6ba5499b2df4df4a307032046fd71f0b1e2ffdd22977da64b971037a875c3e9d
7
- data.tar.gz: 64ea14a9e67c0a5c3cfa2460b784c9289e1b55bad49a48ef4f26f1ff8575d8c4e4271552f9540213f0ca5fb6a208b55c8cee8e493d83e58bb4a81cb354b9fd7e
6
+ metadata.gz: d49bd19582de3bbe0c284a8a6e9ddd9eb089deffb543ef4c1a91eb7328b349d7ea3c8b6ca8b046fa87e269b09e233459bab3b10e8f6ed7dcc4bb267d37f5a989
7
+ data.tar.gz: f972fafa9ed8f1f78da320a91984b194a79652180475e5dafb30d6d5f8e40fd702b48de027bf8c81264161fef00924de795ef5edbc374513941338fab6dd0b74
@@ -23,7 +23,11 @@ class Listserv
23
23
 
24
24
  # The first 'line' contains the plain title of the Listserv.
25
25
  @title = IO.read(file, length, offset += length, mode:'rb')
26
- @title = @title.strip[2..-1]
26
+ begin
27
+ @title = @title.strip[2..-1]
28
+ rescue
29
+ @title = "{Could Not Parse Title}"
30
+ end
27
31
 
28
32
  # Read the first section of the file. Settings come in the form of "* Key= Value"
29
33
  while line = IO.read(file, length, offset += length, mode: 'rb')
@@ -46,7 +50,12 @@ class Listserv
46
50
  @members = Array.new
47
51
  while line = IO.read(file, length, offset += length, mode: 'rb')
48
52
  member_matches = line.scan(/(.{1,80})[\S]{12}\/\/\/\/ /)
49
- if member_matches.flatten!.count > 0
53
+ begin
54
+ member_match_count = member_matches.flatten!.count
55
+ rescue
56
+ member_match_count = 0
57
+ end
58
+ if member_match_count > 0
50
59
  member_matches.each do |m|
51
60
  @members.push m.strip
52
61
  end
@@ -98,16 +107,20 @@ class Listserv
98
107
  private
99
108
 
100
109
  def get_emails(matches)
101
- matches.flatten! #Flattens the match array in case the original contained any arrays (it probably didn't)
102
- matches.map! {|m| m.split(',')} #Split any elements of the match array if they are comma-delimited
103
- matches.flatten! #Flatten the split comma-delimited elements back down so this is a 1-D array again
104
110
  output = [] #The output variable
105
- matches.each do |match|
106
- #Find any email addresses in a match
107
- emails = match.downcase.scan(/[a-z'0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,5}/)
108
- emails.each do |email|
109
- output.push email #Put those email addresses into the output variable
111
+ begin
112
+ matches.flatten! #Flattens the match array in case the original contained any arrays (it probably didn't)
113
+ matches.map! {|m| m.split(',')} #Split any elements of the match array if they are comma-delimited
114
+ matches.flatten! #Flatten the split comma-delimited elements back down so this is a 1-D array again
115
+ matches.each do |match|
116
+ #Find any email addresses in a match
117
+ emails = match.downcase.scan(/[a-z'0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,5}/)
118
+ emails.each do |email|
119
+ output.push email #Put those email addresses into the output variable
120
+ end
110
121
  end
122
+ rescue
123
+ #You were probably passed an empty block of matches
111
124
  end
112
125
  return output #Return a flat array of email addresses.
113
126
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: listserv
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Benjamin J. Thompson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-16 00:00:00.000000000 Z
11
+ date: 2018-12-04 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Use this gem to interpret raw files from Listserv, and access the settings
14
14
  and memberships of those listservs.
@@ -38,7 +38,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
38
38
  version: '0'
39
39
  requirements: []
40
40
  rubyforge_project:
41
- rubygems_version: 2.4.5.1
41
+ rubygems_version: 2.6.14
42
42
  signing_key:
43
43
  specification_version: 4
44
44
  summary: A gem for parsing Listserv's .list files.