snatch 1.0.1 → 1.0.2

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.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.1
1
+ 1.0.2
@@ -12,8 +12,8 @@ class Snatch
12
12
 
13
13
  def encode_mailtos(a)
14
14
  if a['href'] =~ /^mailto:(.*)/
15
- a['href'] = 'mailto:' + url_encode($1)
16
- a.inner_html = html_encode(a.inner_html)
15
+ a['href'] = 'mailto:' + HTML.url_encode($1)
16
+ a.inner_html = HTML.html_encode(a.inner_html)
17
17
  end
18
18
  end
19
19
 
@@ -48,11 +48,11 @@ class Snatch
48
48
  new(doc, working_directory).update
49
49
  end
50
50
 
51
- def html_encode(string)
51
+ def self.html_encode(string)
52
52
  string.gsub(/./){ |char| "&#x#{char.unpack('U')[0].to_s(16)};" }
53
53
  end
54
54
 
55
- def url_encode(string)
55
+ def self.url_encode(string)
56
56
  string.gsub(/./) { |char| '%' + char.unpack('H2' * char.size).join('%').upcase }
57
57
  end
58
58
 
@@ -62,11 +62,13 @@ class Snatch
62
62
  @doc.search('//comment()').remove
63
63
 
64
64
  HrefFixMethods.instance_methods.each do |m|
65
- @doc.css('a[href]').each { |a| send m, a }
65
+ klass = Class.new { include HrefFixMethods }.new
66
+ @doc.css('a[href]').each { |a| klass.send m, a }
66
67
  end
67
68
 
68
69
  SrcFixMethods.instance_methods.each do |m|
69
- @doc.css('[src]').each { |a| send m, a }
70
+ klass = Class.new { include SrcFixMethods }.new
71
+ @doc.css('[src]').each { |a| klass.send m, a }
70
72
  end
71
73
  end
72
74
  end
data/snatch.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{snatch}
8
- s.version = "1.0.1"
8
+ s.version = "1.0.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["James Conroy-Finn"]
@@ -48,8 +48,8 @@ describe Snatch::Clean::HTML do
48
48
 
49
49
  it 'should encode email addresses' do
50
50
  anchor = %Q{<a href="mailto:blah@exåmplé.cøm">blah@exåmplé.cøm</a>}
51
- subject.should_receive(:url_encode).and_return('url_encode')
52
- subject.should_receive(:html_encode).and_return('html_encode')
51
+ @html.class.should_receive(:url_encode).and_return('url_encode')
52
+ @html.class.should_receive(:html_encode).and_return('html_encode')
53
53
  fix_node(:encode_mailtos, anchor) do |node|
54
54
  node.should have_href('mailto:url_encode')
55
55
  node.text.should == 'html_encode'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: snatch
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Conroy-Finn