cartero 0.2.1 → 0.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 92ca09c4a1e5053535f5064e4602913b21731073
4
- data.tar.gz: 0ec2d283c43dc83c0a74f9fad6d762b311889751
3
+ metadata.gz: d436bc1de588567d4ccd9b05d7ba747145b5ef82
4
+ data.tar.gz: 78aece78c0db42d1c810a082f13e76a1c78ebbb3
5
5
  SHA512:
6
- metadata.gz: 56998191408109eb13935d9420abbcca54011ee0fa0a4bf0564d5e2cc7bd116567c95b9c3d0b80de17438955cf3b45eb2d7b0c8459500de1e926b6f1bf4f235f
7
- data.tar.gz: 91f99024e158f9f191df09104c9d2992d11686e45782e4538950a5e5716bc33d6049e98d257161b1f9f8a6ac43e91045f36cb6cfd14b0d2a904f67f21ff6e8ae
6
+ metadata.gz: f648388fc293c158f6f4242a2f54febd1493ef71eb3e841b3746df7063a9a80004f275bae3c5ac975bb22b92397f0294c378c8e8e2d2817a0ae5f4714b57cecd
7
+ data.tar.gz: 9d35b4cadb838536011bb2abe8d4601e12b609ef25ec65bc2e52fdcf03a0bf60e0a5d3cfa6720b952abeba9ab931aed3969537040eced240fe71e1ae028ebe84
@@ -16,13 +16,19 @@ module Cartero
16
16
  end
17
17
 
18
18
  def premailer options
19
- options[:html] = @original_html
20
- response = Net::HTTP.post_form( @@premailer_uri, options)
19
+ premailer_options = options.reject{|key, value| key == :base_url}
20
+ premailer_options[:html] = @original_html
21
+ response = Net::HTTP.post_form( @@premailer_uri, premailer_options)
21
22
  documents = JSON.parse(response.body)['documents']
22
23
  premailer_html_url = documents['html']
23
24
  premailer_text_url = documents['txt']
24
25
 
25
26
  processed_html = open(premailer_html_url).read.gsub('&', '&')
27
+
28
+ if options[:base_url]
29
+ processed_html.gsub!(/src="(?!http)/, "src=\"#{options[:base_url]}/")
30
+ end
31
+
26
32
  processed_text = open(premailer_text_url).read.gsub('&', '&').gsub('&', '&')
27
33
 
28
34
  @processed[:html] = processed_html
@@ -1,3 +1,3 @@
1
1
  module Cartero
2
- VERSION = "0.2.1"
2
+ VERSION = "0.3.0"
3
3
  end
@@ -101,7 +101,7 @@
101
101
  <tr>
102
102
  <td width="613" height="331" valign="_top">
103
103
  <a href="http://www.mintvelvet.co.uk/SALE/dept/fcp-category/list?resetFilters=true" target="_blank=">
104
- <img src="http://www.elabs12.com/content/2012000705/50-140407_sale.jpg" alt="The mid season sale is now on" />
104
+ <img src="50-140407_sale.jpg" alt="The mid season sale is now on" />
105
105
  </a>
106
106
  </td>
107
107
  </tr>
@@ -4,7 +4,8 @@ describe Cartero::Document do
4
4
  before :all do
5
5
  @path = File.expand_path 'test/fixtures/31_140311.html'
6
6
  @doc = Cartero::Document.new @path, {
7
- link_query_string: 'utm_campaign=test&something-else=another-thing'
7
+ link_query_string: 'utm_campaign=test&something-else=another-thing',
8
+ base_url: 'http://google.com'
8
9
  }
9
10
  end
10
11
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cartero
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Dawkins
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-23 00:00:00.000000000 Z
11
+ date: 2014-05-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler