reelagram-mail 0.0.4 → 0.0.5

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
  SHA1:
3
- metadata.gz: 08eb5c9c91316ad4f51bc73ae30529becc999712
4
- data.tar.gz: 6494edc93363360c9c0dcc43194eb808b69d8033
3
+ metadata.gz: cc3c7f71f3351bacf6db9d32715e2ef5fb7734a5
4
+ data.tar.gz: 07a203b5394d26605fb15b354adfff7336fe2b20
5
5
  SHA512:
6
- metadata.gz: 57c50a3f424325adc1aeb7ddf4319f957508805e6a0713d3712966a93022d74e99027faa8fa3d1dec7dabc8f968499af1cccf2cf58c49703cc7dc2c750a5694d
7
- data.tar.gz: ef27f6bde615cd71c8302dd61114d39c75dc4730a95b3ce24cef2fd0e223379d17f455b9eb0e88a96b945fa573f63fa60894f587c7040ca80824e340f1a11dc6
6
+ metadata.gz: e5319d23291936eb7d1dc10d543fc81fa4fc9b2af2c061f5eb6f402711ee4e89b01d3390613a09b0ce5895b48976827b6ff3b750c6a123b932963e2dcc38ce98
7
+ data.tar.gz: ce93cda5b00755413b2c80c99611561bfa382858b4a7e93bf34ec4a1cd1e52a8c446a131dad128e67c7c1e8f7a6a054e7444539ee9b08a88b29837bce8eaebb8
data/Gemfile.lock CHANGED
@@ -1,7 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- reelagram-mail (0.0.3)
4
+ reelagram-mail (0.0.5)
5
+ nokogiri (= 1.6.2.1)
5
6
  ruby-gmail (= 0.3.1)
6
7
 
7
8
  GEM
@@ -12,6 +13,9 @@ GEM
12
13
  mime-types (>= 1.16, < 3)
13
14
  mime (0.4.2)
14
15
  mime-types (2.3)
16
+ mini_portile (0.6.0)
17
+ nokogiri (1.6.2.1)
18
+ mini_portile (= 0.6.0)
15
19
  rake (0.9.6)
16
20
  ruby-gmail (0.3.1)
17
21
  mail (>= 2.2.1)
@@ -1,50 +1,68 @@
1
+ require "nokogiri"
2
+
1
3
  module Reelagram
2
4
  module Mail
3
5
  module Parsers
4
6
  class ShippingParser
5
- attr_reader :string
7
+ attr_reader :doc
6
8
 
7
9
  def run(string)
8
- @string = string
10
+ @doc = Nokogiri::HTML(string)
9
11
  self
10
12
  end
11
13
 
12
- def order_number
13
- string.scan(/(?<=Purchase Order Number: ).*/).first
14
- end
15
-
16
14
  def carrier
17
- shipping_info[0...-1].join(" ")
15
+ if shipping_info_row
16
+ @row.children[1].text
17
+ else
18
+ "Unavailable"
19
+ end
18
20
  end
19
21
 
20
22
  def tracking_number
21
- shipping_info[-1]
23
+ if shipping_info_row
24
+ @row.children[3].css("a").text
25
+ else
26
+ "Unavailable"
27
+ end
22
28
  end
23
29
 
24
30
  def tracking_link
25
- tracking_block = string.gsub(/\n/, "").scan(/(?<=Shipped By Tracking Number).*(?=\=>)/)
26
- if tracking_block.any?
27
- link = tracking_block.first.
28
- split("<").
29
- last
30
- "#{link}="
31
+ if shipping_info_row
32
+ @row.children[3].css("a").attr("href").value
31
33
  end
32
34
  end
33
35
 
36
+ def order_number
37
+ table = doc.css("table")[2]
38
+ if table
39
+ table.css("tr")
40
+ .children.css("td")
41
+ .children
42
+ .text
43
+ .gsub(/\\n+/, " ")
44
+ .scan(/\w*/)
45
+ .reject(&:empty?)
46
+ .last
47
+ end
48
+ end
49
+
50
+ def reset!
51
+ @shipping_info_table, @row = nil, nil
52
+ end
53
+
34
54
  private
35
55
 
36
- def shipping_info
37
- shipping_info_block = string.gsub(/\n/, " ").
38
- scan(/(?<=Shipped By Tracking Number).*(?=\<http)/)
56
+ def shipping_info_table
57
+ @shipping_info_table ||= doc.css("table")[-2]
58
+ end
39
59
 
40
- if shipping_info_block.any?
41
- shipping_info_block.first.
42
- strip.
43
- split(" ")
44
- else
45
- ["Unavailable", "Unavailable"]
60
+ def shipping_info_row
61
+ if shipping_info_table
62
+ @row ||= @shipping_info_table.css("tr")[-1]
46
63
  end
47
64
  end
65
+
48
66
  end
49
67
  end
50
68
  end
@@ -18,7 +18,9 @@ module Reelagram
18
18
  private
19
19
 
20
20
  def process_email(email)
21
- build_email_hash(parser.run(email))
21
+ email_data = build_email_hash(parser.run(email))
22
+ parser.reset!
23
+ email_data
22
24
  end
23
25
 
24
26
  def build_email_hash(email)
@@ -1,3 +1,3 @@
1
1
  module Reelagram
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
@@ -19,6 +19,7 @@ Gem::Specification.new do |spec|
19
19
  spec.require_paths = ["lib"]
20
20
 
21
21
  spec.add_runtime_dependency "ruby-gmail", "0.3.1"
22
+ spec.add_runtime_dependency "nokogiri", "1.6.2.1"
22
23
 
23
24
  spec.add_development_dependency "bundler", "~> 1.3"
24
25
  spec.add_development_dependency "rake", "~> 0"
@@ -1,310 +1 @@
1
- --001a11c0ed789583e404fe2af1ad
2
- Content-Type: text/plain; charset=UTF-8
3
-
4
- [image: Image3D] <http://www.image3d.com/store/index.php/> Hello, Sait
5
- Mesutcan Ilhaner
6
-
7
-
8
- We are happy to say that your order is complete and has left our facility!
9
- You can check the status of your shipment by clicking the tracking number
10
- below.
11
- Please know that tracking numbers can take up to 24 hours to be updated.
12
-
13
- Be sure to sign up for our E-Newsltter <http://bit.ly/I3Demails> to get the
14
- latest deals and info, you even get a coupon just for subscribing! Then,
15
- follow the fun on Facebook <https://www.facebook.com/USA.Image3D>, Twitter
16
- <https://twitter.com/Image3Dusa>, YouTube
17
- <http://www.youtube.com/image3dusa>, and Pinterest
18
- <http://pinterest.com/image3d/>.
19
-
20
-
21
- If you have any questions, email us at Celebrate@image3d.com or give us a
22
- ring at 503-632-2470.
23
-
24
- Your Order #27780000265 (placed on July 5, 2014 9:49:00 PM PDT) Billing
25
- Information: Payment Method: Sait Mesutcan Ilhaner
26
- 2400 W. Empire Ave Ste 300
27
- Burbank, CA, 91504
28
-
29
- T: 510-289-9049
30
- Purchase Order
31
-
32
- Purchase Order Number: 7780000265
33
- Shipping Information: Shipping Method: Sait Mesutcan Ilhaner
34
- 2400 W. Empire Ave Ste 300
35
- Burbank, CA, 91504
36
-
37
- T: 510-289-9049 Shipped By Tracking Number United States Postal
38
- Service 92748999982943513015002409
39
- <http://wwwapps.ups.com/WebTracking/track?HTMLVersion=5.0&loc=en_US&Requester=UPSHome&WBPM_lid=homepage%2Fct1.html_pnl_trk&trackNums=92748999982943513015002409&track.x=Track%20target=>
40
-
41
- Please allow 24 hours for your tracking number to update
42
- Item Sku Qty Subtotal *Reel & Viewer Set* *Reel ID* *Viewer Color* Black
43
- VIEWER-4510 1 $29.95 Subtotal $29.95 Shipping & Handling $7.50 *Grand
44
- Total* *$37.45*
45
-
46
- Thank you!*Image3D*
47
-
48
- --001a11c0ed789583e404fe2af1ad
49
- Content-Type: text/html; charset=UTF-8
50
- Content-Transfer-Encoding: quoted-printable
51
-
52
- <div dir=3D"ltr"><div class=3D"gmail_quote"><br>
53
- <div style=3D"background:#f6f6f6;font-family:Verdana,Arial,Helvetica,sans-s=
54
- erif;font-size:12px;margin:0;padding:0">
55
- <div style=3D"background:#f6f6f6;font-family:Verdana,Arial,Helvetica,sans-s=
56
- erif;font-size:12px;margin:0;padding:0">
57
- <table cellspacing=3D"0" cellpadding=3D"0" border=3D"0" width=3D"100%">
58
- <tbody><tr>
59
- <td align=3D"center" valign=3D"top" style=3D"padding:20px 0 20px 0">
60
- <table bgcolor=3D"#FFFFFF" cellspacing=3D"0" cellpadding=3D"10" bor=
61
- der=3D"0" width=3D"650" style=3D"border:1px solid #e0e0e0">
62
- =20
63
- <tbody><tr>
64
- <td valign=3D"top"><a href=3D"http://www.image3d.com/store/=
65
- index.php/" target=3D"_blank"><img src=3D"https://www.image3d.com/store/med=
66
- ia/email/logo/default/logosmall1.jpg" alt=3D"Image3D" style=3D"margin-botto=
67
- m:10px" border=3D"0"></a></td>
68
-
69
- </tr>
70
- =20
71
- <tr>
72
- <td valign=3D"top">
73
- <h1 style=3D"font-size:22px;font-weight:normal;line-hei=
74
- ght:22px;margin:0 0 11px 0">Hello, Sait Mesutcan Ilhaner</h1>
75
- <p style=3D"font-size:12px;line-height:16px;margin:0">
76
- <br>
77
- We are happy to say that your order is complete and has left our facility!=
78
- =20
79
- <br>You can check the status of your shipment by clicking the tracking numb=
80
- er below.=20
81
- <br>Please know that tracking numbers can take up to 24 hours to be updated=
82
- .=20
83
- =20
84
- <br><br> </p><p style=3D"font-size:12px;line-height:16px;mar=
85
- gin:0">Be sure to sign up for our <a href=3D"http://bit.ly/I3Demails" targe=
86
- t=3D"_blank">E-Newsltter</a> to get the latest deals and info, you even get=
87
- a coupon just for subscribing! Then, follow the fun on <a href=3D"https://=
88
- www.facebook.com/USA.Image3D" title=3D"Image3D on Facebook" target=3D"_blan=
89
- k">Facebook</a>, <a href=3D"https://twitter.com/Image3Dusa" title=3D"Image3=
90
- D on Twitter" target=3D"_blank">Twitter</a>, <a href=3D"http://www.youtube.=
91
- com/image3dusa" title=3D"Image3D on YouTube" target=3D"_blank">YouTube</a>,=
92
- and <a href=3D"http://pinterest.com/image3d/" title=3D"Image3D on Pinteres=
93
- t" target=3D"_blank">Pinterest</a>. </p>
94
-
95
-
96
- <br><br> If you have any questions, email us at <a href=3D"mailto:Celebra=
97
- te@image3d.com" style=3D"color:#1e7ec8" target=3D"_blank">Celebrate@image3d=
98
- .com</a> or give us a ring at <span><a href=3D"tel:503-632-2470" value=3D"+=
99
- 15036322470" target=3D"_blank">503-632-2470</a></span>.
100
- <p></p>
101
- </td></tr>
102
- <tr>
103
- <td>
104
- <h2 style=3D"font-size:18px;font-weight:normal;margin:0=
105
- ">Your Order #27780000265 <small>(placed on July 5, 2014 9:49:00 PM PDT)</s=
106
- mall></h2>
107
- </td>
108
- </tr>
109
- <tr>
110
- <td>
111
- <table cellspacing=3D"0" cellpadding=3D"0" border=3D"0"=
112
- width=3D"650">
113
- <thead>
114
- <tr>
115
- <th align=3D"left" width=3D"325" bgcolor=3D"#EA=
116
- EAEA" style=3D"font-size:13px;padding:5px 9px 6px 9px;line-height:1em">Bill=
117
- ing Information:</th>
118
- <th width=3D"10"></th>
119
- <th align=3D"left" width=3D"325" bgcolor=3D"#EA=
120
- EAEA" style=3D"font-size:13px;padding:5px 9px 6px 9px;line-height:1em">Paym=
121
- ent Method:</th>
122
- </tr>
123
- </thead>
124
- <tbody>
125
- <tr>
126
- <td valign=3D"top" style=3D"font-size:12px;padd=
127
- ing:7px 9px 9px 9px;border-left:1px solid #eaeaea;border-bottom:1px solid #=
128
- eaeaea;border-right:1px solid #eaeaea">
129
- Sait Mesutcan Ilhaner<br>
130
-
131
- 2400 W. Empire Ave Ste 300<br>
132
-
133
-
134
-
135
- Burbank, CA, 91504<br>
136
- <br>
137
- T: <a href=3D"tel:510-289-9049" value=3D"+15102899049" target=3D"_blank">51=
138
- 0-289-9049</a>
139
-
140
-
141
- </td>
142
- <td>=C2=A0</td>
143
- <td valign=3D"top" style=3D"font-size:12px;padd=
144
- ing:7px 9px 9px 9px;border-left:1px solid #eaeaea;border-bottom:1px solid #=
145
- eaeaea;border-right:1px solid #eaeaea">
146
- <br>Purchase Order <br><br>Purchase Order Nu=
147
- mber: 7780000265
148
-
149
-
150
-
151
-
152
-
153
- </td>
154
- </tr>
155
- </tbody>
156
- </table>
157
- <br>
158
- =20
159
- <table cellspacing=3D"0" cellpadding=3D"0" border=3D"0"=
160
- width=3D"650">
161
- <thead>
162
- <tr>
163
- <th align=3D"left" width=3D"325" bgcolor=3D"#EA=
164
- EAEA" style=3D"font-size:13px;padding:5px 9px 6px 9px;line-height:1em">Ship=
165
- ping Information:</th>
166
- <th width=3D"10"></th>
167
- <th align=3D"left" width=3D"325" bgcolor=3D"#EA=
168
- EAEA" style=3D"font-size:13px;padding:5px 9px 6px 9px;line-height:1em">Ship=
169
- ping Method:</th>
170
- </tr>
171
- </thead>
172
- <tbody>
173
- <tr>
174
- <td valign=3D"top" width=3D"50%" style=3D"font-=
175
- size:12px;padding:7px 9px 9px 9px;border-left:1px solid #eaeaea;border-bott=
176
- om:1px solid #eaeaea;border-right:1px solid #eaeaea">
177
- Sait Mesutcan Ilhaner<br>
178
-
179
- 2400 W. Empire Ave Ste 300<br>
180
-
181
-
182
-
183
- Burbank, CA, 91504<br>
184
- <br>
185
- T: <a href=3D"tel:510-289-9049" value=3D"+15102899049" target=3D"_blank">51=
186
- 0-289-9049</a>
187
-
188
-
189
- =C2=A0
190
- </td>
191
- <td>=C2=A0</td>
192
- <td valign=3D"top" width=3D"50%" style=3D"font-=
193
- size:12px;padding:7px 9px 9px 9px;border-left:1px solid #eaeaea;border-bott=
194
- om:1px solid #eaeaea;border-right:1px solid #eaeaea">
195
- <table cellspacing=3D"0" cellpadding=
196
- =3D"0" border=3D"0" width=3D"300" style=3D"border:1px solid #eaeaea">
197
- <thead>
198
- <tr>
199
- <th align=3D"left" bgcolor=3D"#EAEAEA" style=3D"font-size:13px;=
200
- padding:3px 9px">Shipped By</th>
201
- <th align=3D"center" bgcolor=3D"#EAEAEA" style=3D"font-size:13p=
202
- x;padding:3px 9px">Tracking Number</th>
203
- </tr>
204
- </thead>
205
- <tbody>
206
- <tr bgcolor=3D"#F6F6F6">
207
- <td align=3D"left" valign=3D"top" style=3D"padding:3px 9px">Uni=
208
- ted States Postal Service</td>
209
- <td align=3D"center" valign=3D"top" style=3D"padding:3px 9px"><=
210
- a href=3D"http://wwwapps.ups.com/WebTracking/track?HTMLVersion=3D5.0&amp;lo=
211
- c=3Den_US&amp;Requester=3DUPSHome&amp;WBPM_lid=3Dhomepage%2Fct1.html_pnl_tr=
212
- k&amp;trackNums=3D92748999982943513015002409&amp;track.x=3DTrack%20target=
213
- =3D" target=3D"_blank">92748999982943513015002409</a><br>
214
- <br>Please allow 24 hours for your tracking number to update</td>
215
- </tr>
216
- </tbody>
217
- </table>
218
-
219
-
220
- </td>
221
- </tr>
222
- </tbody>
223
- </table>
224
- <br>
225
- =20
226
- <table cellspacing=3D"0" cellpadding=3D"0" border=3D"0"=
227
- width=3D"650" style=3D"border:1px solid #eaeaea">
228
- <thead>
229
- <tr>
230
- <th align=3D"left" bgcolor=3D"#EAEAEA" style=3D"font-size:13px;=
231
- padding:3px 9px">Item</th>
232
- <th align=3D"left" bgcolor=3D"#EAEAEA" style=3D"font-size:13px;=
233
- padding:3px 9px">Sku</th>
234
- <th align=3D"center" bgcolor=3D"#EAEAEA" style=3D"font-size:13p=
235
- x;padding:3px 9px">Qty</th>
236
- <th align=3D"right" bgcolor=3D"#EAEAEA" style=3D"font-size:13px=
237
- ;padding:3px 9px">Subtotal</th>
238
- </tr>
239
- </thead>
240
-
241
- <tbody bgcolor=3D"#F6F6F6">
242
- <tr>
243
- <td align=3D"left" valign=3D"top" style=3D"font-size:11px;padding:3px 9=
244
- px;border-bottom:1px dotted #cccccc">
245
- <strong style=3D"font-size:11px">Reel &amp; Viewer Set</strong>
246
- <dl style=3D"margin:0;padding:0">
247
- <dt><strong><em>Reel ID</em></strong></dt>
248
- <dd style=3D"margin:0;padding:0 0 0 9px">
249
- </dd>
250
- <dt><strong><em>Viewer Color</em></strong></dt>
251
- <dd style=3D"margin:0;padding:0 0 0 9px">
252
- Black </dd>
253
- </dl>
254
- </td>
255
- <td align=3D"left" valign=3D"top" style=3D"font-size:11px;padding:3px 9=
256
- px;border-bottom:1px dotted #cccccc">VIEWER-4510</td>
257
- <td align=3D"center" valign=3D"top" style=3D"font-size:11px;padding:3px=
258
- 9px;border-bottom:1px dotted #cccccc">1</td>
259
- <td align=3D"right" valign=3D"top" style=3D"font-size:11px;padding:3px =
260
- 9px;border-bottom:1px dotted #cccccc">
261
- <span>$29.95</span> =
262
- =20
263
-
264
- =20
265
-
266
- </td>
267
- </tr>
268
- </tbody>
269
- =20
270
- <tbody>
271
- <tr>
272
- <td colspan=3D"3" align=3D"right" style=3D"padding:3px 9px">
273
- Subtotal </td>
274
- <td align=3D"right" style=3D"padding:3px 9px">
275
- <span>$29.95</span> </td>
276
- </tr>
277
- <tr>
278
- <td colspan=3D"3" align=3D"right" style=3D"padding:3px 9px">
279
- Shipping &amp; Handling </td>
280
- <td align=3D"right" style=3D"padding:3px 9px">
281
- <span>$7.50</span> </td>
282
- </tr>
283
- <tr>
284
- <td colspan=3D"3" align=3D"right" style=3D"padding:3px 9px">
285
- <strong>Grand Total</strong>
286
- </td>
287
- <td align=3D"right" style=3D"padding:3px 9px">
288
- <strong><span>$37.45</span></strong>
289
- </td>
290
- </tr>
291
- </tbody>
292
- </table>
293
-
294
- <p style=3D"font-size:12px;margin:0 0 10px 0"></p>
295
- </td>
296
- </tr>
297
- <tr>
298
- <td bgcolor=3D"#EAEAEA" align=3D"center" style=3D"backgroun=
299
- d:#eaeaea;text-align:center"><center><p style=3D"font-size:12px;margin:0">T=
300
- hank you!<strong>Image3D</strong></p></center></td>
301
- </tr>
302
- </tbody></table>
303
- </td>
304
- </tr>
305
- </tbody></table>
306
- </div>
307
- </div>
308
- </div><br></div>
309
-
310
- --001a11c0ed789583e404fe2af1ad--
1
+ <style type=\"text/css\">\nbody,td { color:#2f2f2f; font:11px/1.35em Verdana, Arial, Helvetica, sans-serif; }\n</style>\n<body style=\"background:#F6F6F6; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; margin:0; padding:0;\">\n<div style=\"background:#F6F6F6; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; margin:0; padding:0;\">\n<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\" width=\"100%\">\n<tr>\n <td align=\"center\" valign=\"top\" style=\"padding:20px 0 20px 0\">\n <table bgcolor=\"#FFFFFF\" cellspacing=\"0\" cellpadding=\"10\" border=\"0\" width=\"650\" style=\"border:1px solid #E0E0E0;\">\n <!-- [ header starts here] -->\n <tr>\n <td valign=\"top\"><a href=\"http://www.image3d.com/store/index.php/\"><img src=\"https://www.image3d.com/store/media/email/logo/default/logosmall1.jpg\" alt=\"Image3D\" style=\"margin-bottom:10px;\" border=\"0\"/></a></td>\n </tr>\n <!-- [ middle starts here] -->\n <tr>\n <td valign=\"top\">\n <h1 style=\"font-size:22px; font-weight:normal; line-height:22px; margin:0 0 11px 0;\"\">Hello, jordanah </h1>\n <p style=\"font-size:12px; line-height:16px; margin:0;\">\n<br />\nWe are happy to say that your order is complete and has left our facility! \n<br />You can check the status of your shipment by clicking the tracking number below. \n<br />Please know that tracking numbers can take up to 24 hours to be updated. \n \n <br /><br /> <p style=\"font-size:12px; line-height:16px; margin:0;\">Be sure to sign up for our <a href=\"http://bit.ly/I3Demails\">E-Newsltter</a> to get the latest deals and info, you even get a coupon just for subscribing! Then, follow the fun on <a href=\"https://www.facebook.com/USA.Image3D\" title=\"Image3D on Facebook\">Facebook</a>, <a href=\"https://twitter.com/Image3Dusa\" title=\"Image3D on Twitter\">Twitter</a>, <a href=\"http://www.youtube.com/image3dusa\" title=\"Image3D on YouTube\">YouTube</a>, and <a href=\"http://pinterest.com/image3d/\" title=\"Image3D on Pinterest\">Pinterest</a>. </p>\n\n<br /><br /> If you have any questions, email us at <a href=\"mailto:Celebrate@image3d.com\" style=\"color:#1E7EC8;\">Celebrate@image3d.com</a> or give us a ring at <span class=\"nobr\">503-632-2470</span>.\n </p>\n </tr>\n <tr>\n <td>\n <h2 style=\"font-size:18px; font-weight:normal; margin:0;\">Your Order #27780000298 <small>(placed on July 13, 2014 7:54:00 AM PDT)</small></h2>\n </td>\n </tr>\n <tr>\n <td>\n <table cellspacing=\"0\" cellpadding=\"0\" border=\"0\" width=\"650\">\n <thead>\n <tr>\n <th align=\"left\" width=\"325\" bgcolor=\"#EAEAEA\" style=\"font-size:13px; padding:5px 9px 6px 9px; line-height:1em;\">Billing Information:</th>\n <th width=\"10\"></th>\n <th align=\"left\" width=\"325\" bgcolor=\"#EAEAEA\" style=\"font-size:13px; padding:5px 9px 6px 9px; line-height:1em;\">Payment Method:</th>\n </tr>\n </thead>\n <tbody>\n <tr>\n <td valign=\"top\" style=\"font-size:12px; padding:7px 9px 9px 9px; border-left:1px solid #EAEAEA; border-bottom:1px solid #EAEAEA; border-right:1px solid #EAEAEA;\">\n jordanah <br/>\n\n19926 NE 129th st<br />\n\n\n\nwoodinville, wa, 98077<br/>\n<br/>\nT: 4254177626\n\n\n </td>\n <td>&nbsp;</td>\n <td valign=\"top\" style=\"font-size:12px; padding:7px 9px 9px 9px; border-left:1px solid #EAEAEA; border-bottom:1px solid #EAEAEA; border-right:1px solid #EAEAEA;\">\n <br />Purchase Order <br /><br />Purchase Order Number: 7780000298\n\n\n\n\n\n </td>\n </tr>\n </tbody>\n </table>\n <br/>\n \n <table cellspacing=\"0\" cellpadding=\"0\" border=\"0\" width=\"650\">\n <thead>\n <tr>\n <th align=\"left\" width=\"325\" bgcolor=\"#EAEAEA\" style=\"font-size:13px; padding:5px 9px 6px 9px; line-height:1em;\">Shipping Information:</th>\n <th width=\"10\"></th>\n <th align=\"left\" width=\"325\" bgcolor=\"#EAEAEA\" style=\"font-size:13px; padding:5px 9px 6px 9px; line-height:1em;\">Shipping Method:</th>\n </tr>\n </thead>\n <tbody>\n <tr>\n <td valign=\"top\" width=\"50%\" style=\"font-size:12px; padding:7px 9px 9px 9px; border-left:1px solid #EAEAEA; border-bottom:1px solid #EAEAEA; border-right:1px solid #EAEAEA;\">\n jordanah <br/>\n\n19926 NE 129th st<br />\n\n\n\nwoodinville, wa, 98077<br/>\n<br/>\nT: 4254177626\n\n\n &nbsp;\n </td>\n <td>&nbsp;</td>\n <td valign=\"top\" width=\"50%\" style=\"font-size:12px; padding:7px 9px 9px 9px; border-left:1px solid #EAEAEA; border-bottom:1px solid #EAEAEA; border-right:1px solid #EAEAEA;\">\n <table cellspacing=\"0\" cellpadding=\"0\" border=\"0\" width=\"300\" style=\"border:1px solid #EAEAEA;\">\n <thead>\n <tr>\n <th align=\"left\" bgcolor=\"#EAEAEA\" style=\"font-size:13px; padding:3px 9px\">Shipped By</th>\n <th align=\"center\" bgcolor=\"#EAEAEA\" style=\"font-size:13px; padding:3px 9px\">Tracking Number</th>\n </tr>\n </thead>\n <tbody>\n <tr bgcolor=\"#F6F6F6\">\n <td align=\"left\" valign=\"top\" style=\"padding:3px 9px\">United States Postal Service</td>\n <td align=\"center\" valign=\"top\" style=\"padding:3px 9px\"><a href='http://wwwapps.ups.com/WebTracking/track?HTMLVersion=5.0&loc=en_US&Requester=UPSHome&WBPM_lid=homepage%2Fct1.html_pnl_trk&trackNums=92789999982943513015003089&track.x=Track target='_blank'>92789999982943513015003089</a><br /><br />Please allow 24 hours for your tracking number to update</td>\n </tr>\n </tbody>\n</table>\n\n\n </td>\n </tr>\n </tbody>\n </table>\n <br/>\n \n <table cellspacing=\"0\" cellpadding=\"0\" border=\"0\" width=\"650\" style=\"border:1px solid #EAEAEA;\">\n <thead>\n <tr>\n <th align=\"left\" bgcolor=\"#EAEAEA\" style=\"font-size:13px; padding:3px 9px\">Item</th>\n <th align=\"left\" bgcolor=\"#EAEAEA\" style=\"font-size:13px; padding:3px 9px\">Sku</th>\n <th align=\"center\" bgcolor=\"#EAEAEA\" style=\"font-size:13px; padding:3px 9px\">Qty</th>\n <th align=\"right\" bgcolor=\"#EAEAEA\" style=\"font-size:13px; padding:3px 9px\">Subtotal</th>\n </tr>\n </thead>\n\n <tbody bgcolor=\"#F6F6F6\">\n <tr>\n <td align=\"left\" valign=\"top\" style=\"font-size:11px; padding:3px 9px; border-bottom:1px dotted #CCCCCC;\">\n <strong style=\"font-size:11px;\">Reels Only</strong>\n <dl style=\"margin:0; padding:0;\">\n <dt><strong><em>Reel ID</em></strong></dt>\n <dd style=\"margin:0; padding:0 0 0 9px;\">\n \t </dd>\n </dl>\n </td>\n <td align=\"left\" valign=\"top\" style=\"font-size:11px; padding:3px 9px; border-bottom:1px dotted #CCCCCC;\">REEL-4530</td>\n <td align=\"center\" valign=\"top\" style=\"font-size:11px; padding:3px 9px; border-bottom:1px dotted #CCCCCC;\">1</td>\n <td align=\"right\" valign=\"top\" style=\"font-size:11px; padding:3px 9px; border-bottom:1px dotted #CCCCCC;\">\n <span class=\"price\">$19.95</span> \n\n \n\n </td>\n</tr>\n </tbody>\n \n <tbody>\n <tr class=\"subtotal\">\n <td colspan=\"3\" align=\"right\" style=\"padding:3px 9px\">\n Subtotal </td>\n <td align=\"right\" style=\"padding:3px 9px\">\n <span class=\"price\">$19.95</span> </td>\n </tr>\n <tr class=\"shipping\">\n <td colspan=\"3\" align=\"right\" style=\"padding:3px 9px\">\n Shipping &amp; Handling </td>\n <td align=\"right\" style=\"padding:3px 9px\">\n <span class=\"price\">$7.00</span> </td>\n </tr>\n <tr class=\"grand_total\">\n <td colspan=\"3\" align=\"right\" style=\"padding:3px 9px\">\n <strong>Grand Total</strong>\n </td>\n <td align=\"right\" style=\"padding:3px 9px\">\n <strong><span class=\"price\">$26.95</span></strong>\n </td>\n </tr>\n </tbody>\n</table>\n\n <p style=\"font-size:12px; margin:0 0 10px 0\"></p>\n </td>\n </tr>\n <tr>\n <td bgcolor=\"#EAEAEA\" align=\"center\" style=\"background:#EAEAEA; text-align:center;\"><center><p style=\"font-size:12px; margin:0;\">Thank you!<strong>Image3D</strong></p></center></td>\n </tr>\n </table>\n </td>\n</tr>\n</table>\n</div>\n</body>\n
@@ -9,7 +9,7 @@ class ShippingParserTest < MiniTest::Unit::TestCase
9
9
 
10
10
  def test_order_number_returns_the_order_number
11
11
  parsed_string = parser.run(data)
12
- assert_equal("7780000265", parsed_string.order_number)
12
+ assert_equal("7780000298", parsed_string.order_number)
13
13
  end
14
14
 
15
15
  def test_carrier_returns_the_carrier
@@ -19,12 +19,12 @@ class ShippingParserTest < MiniTest::Unit::TestCase
19
19
 
20
20
  def test_tracking_number_returns_the_tracking_number
21
21
  parsed_string = parser.run(data)
22
- assert_equal("92748999982943513015002409", parsed_string.tracking_number)
22
+ assert_equal("92789999982943513015003089", parsed_string.tracking_number)
23
23
  end
24
24
 
25
25
  def test_tracking_link_returns_the_tracking_link
26
26
  parsed_string = parser.run(data)
27
- assert_equal("http://wwwapps.ups.com/WebTracking/track?HTMLVersion=5.0&loc=en_US&Requester=UPSHome&WBPM_lid=homepage%2Fct1.html_pnl_trk&trackNums=92748999982943513015002409&track.x=Track%20target=", parsed_string.tracking_link)
27
+ assert_equal("http://wwwapps.ups.com/WebTracking/track?HTMLVersion=5.0&loc=en_US&Requester=UPSHome&WBPM_lid=homepage%2Fct1.html_pnl_trk&trackNums=92789999982943513015003089&track.x=Track target=", parsed_string.tracking_link)
28
28
  end
29
29
 
30
30
  def test_when_there_is_no_shipping_information_link_is_unavailable
@@ -42,6 +42,14 @@ class ShippingParserTest < MiniTest::Unit::TestCase
42
42
  assert_equal("Unavailable", parsed_string.tracking_number)
43
43
  end
44
44
 
45
+ def test_reset_sets_variables_to_nil
46
+ parser.reset!
47
+ assert_nil(parser.instance_variable_get("@shipping_info_table"))
48
+ assert_nil(parser.instance_variable_get("@row"))
49
+ end
50
+
51
+ private
52
+
45
53
  def parser
46
54
  @parser ||= Reelagram::Mail::Parsers::ShippingParser.new
47
55
  end
@@ -14,10 +14,10 @@ class ShippingUpdateProcessorTest < MiniTest::Unit::TestCase
14
14
 
15
15
  def test_run_returns_the_parsed_data_from_the_email
16
16
  parsed_data = {
17
- order_id: "7780000265",
17
+ order_id: "7780000298",
18
18
  carrier: "United States Postal Service",
19
- tracking_number: "92748999982943513015002409",
20
- tracking_link: "http://wwwapps.ups.com/WebTracking/track?HTMLVersion=5.0&loc=en_US&Requester=UPSHome&WBPM_lid=homepage%2Fct1.html_pnl_trk&trackNums=92748999982943513015002409&track.x=Track%20target="
19
+ tracking_number: "92789999982943513015003089",
20
+ tracking_link: "http://wwwapps.ups.com/WebTracking/track?HTMLVersion=5.0&loc=en_US&Requester=UPSHome&WBPM_lid=homepage%2Fct1.html_pnl_trk&trackNums=92789999982943513015003089&track.x=Track target="
21
21
  }
22
22
  assert_equal([parsed_data], processor.run)
23
23
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: reelagram-mail
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jon Wheeler
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-17 00:00:00.000000000 Z
11
+ date: 2014-07-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ruby-gmail
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
26
  version: 0.3.1
27
+ - !ruby/object:Gem::Dependency
28
+ name: nokogiri
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '='
32
+ - !ruby/object:Gem::Version
33
+ version: 1.6.2.1
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '='
39
+ - !ruby/object:Gem::Version
40
+ version: 1.6.2.1
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: bundler
29
43
  requirement: !ruby/object:Gem::Requirement