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.
- checksums.yaml +4 -4
- data/lib/listserv.rb +23 -10
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 037d8eff57ddd65cdb61072b6f11ffdda37d1982
|
4
|
+
data.tar.gz: 23d88a1d2437885690d58d5299f9419bc6231e2c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d49bd19582de3bbe0c284a8a6e9ddd9eb089deffb543ef4c1a91eb7328b349d7ea3c8b6ca8b046fa87e269b09e233459bab3b10e8f6ed7dcc4bb267d37f5a989
|
7
|
+
data.tar.gz: f972fafa9ed8f1f78da320a91984b194a79652180475e5dafb30d6d5f8e40fd702b48de027bf8c81264161fef00924de795ef5edbc374513941338fab6dd0b74
|
data/lib/listserv.rb
CHANGED
@@ -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
|
-
|
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
|
-
|
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
|
-
|
106
|
-
#
|
107
|
-
|
108
|
-
|
109
|
-
|
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
|
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:
|
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.
|
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.
|