html_page_title 0.1.0 → 0.1.1

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/README.rdoc CHANGED
@@ -25,6 +25,9 @@ that will always return some kind of string
25
25
 
26
26
  You can also have a look at the unit test to find out about the behaviour!
27
27
 
28
+ == TODO:
29
+ * Remove arbitrary html from the h1 content
30
+
28
31
  == Note on Patches/Pull Requests
29
32
 
30
33
  * Fork the project.
data/Rakefile CHANGED
@@ -12,6 +12,7 @@ begin
12
12
  gem.authors = ["Christoph Olszowka"]
13
13
  gem.add_dependency "redirect_follower", ">= 0.1.1"
14
14
  gem.add_dependency "hpricot", ">= 0.8.2"
15
+ gem.add_dependency 'htmlentities', '>= 4.0.0'
15
16
  gem.add_development_dependency "shoulda", ">= 2.11.1"
16
17
  # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
17
18
  end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.1.1
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{html_page_title}
8
- s.version = "0.1.0"
8
+ s.version = "0.1.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Christoph Olszowka"]
@@ -45,15 +45,18 @@ Gem::Specification.new do |s|
45
45
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
46
46
  s.add_runtime_dependency(%q<redirect_follower>, [">= 0.1.1"])
47
47
  s.add_runtime_dependency(%q<hpricot>, [">= 0.8.2"])
48
+ s.add_runtime_dependency(%q<htmlentities>, [">= 4.0.0"])
48
49
  s.add_development_dependency(%q<shoulda>, [">= 2.11.1"])
49
50
  else
50
51
  s.add_dependency(%q<redirect_follower>, [">= 0.1.1"])
51
52
  s.add_dependency(%q<hpricot>, [">= 0.8.2"])
53
+ s.add_dependency(%q<htmlentities>, [">= 4.0.0"])
52
54
  s.add_dependency(%q<shoulda>, [">= 2.11.1"])
53
55
  end
54
56
  else
55
57
  s.add_dependency(%q<redirect_follower>, [">= 0.1.1"])
56
58
  s.add_dependency(%q<hpricot>, [">= 0.8.2"])
59
+ s.add_dependency(%q<htmlentities>, [">= 4.0.0"])
57
60
  s.add_dependency(%q<shoulda>, [">= 2.11.1"])
58
61
  end
59
62
  end
@@ -1,5 +1,7 @@
1
1
  require 'redirect_follower'
2
2
  require 'hpricot'
3
+ require 'htmlentities'
4
+
3
5
  def HtmlPageTitle(url)
4
6
  HtmlPageTitle.new(url)
5
7
  rescue SocketError => err
@@ -42,7 +44,7 @@ class HtmlPageTitle
42
44
  def title
43
45
  return @title if @title
44
46
  if title_tag = document.at('head title')
45
- @title = title_tag.inner_html.strip.chomp
47
+ @title = HTMLEntities.new.decode(title_tag.inner_html.strip.chomp)
46
48
  end
47
49
  end
48
50
 
@@ -50,7 +52,7 @@ class HtmlPageTitle
50
52
  def heading
51
53
  return @heading if @heading
52
54
  if heading_tag = document.at('body h1')
53
- @heading = heading_tag.inner_html.strip.chomp
55
+ @heading = HTMLEntities.new.decode(heading_tag.inner_html.strip.chomp)
54
56
  end
55
57
  end
56
58
 
@@ -60,4 +60,9 @@ class TestHtmlPageTitle < Test::Unit::TestCase
60
60
  instance = HtmlPageTitle('http://gembundler.com/v1.0/index.html')
61
61
  assert_equal instance.title, instance.label
62
62
  end
63
+
64
+ def test_title_with_entities
65
+ instance = HtmlPageTitle('http://metautonomo.us/2010/04/15/introducing-metawhere/')
66
+ assert_equal 'metautonomo.us » Blog Archive » Introducing MetaWhere', instance.title
67
+ end
63
68
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: html_page_title
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 0
10
- version: 0.1.0
9
+ - 1
10
+ version: 0.1.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Christoph Olszowka
@@ -51,9 +51,25 @@ dependencies:
51
51
  type: :runtime
52
52
  version_requirements: *id002
53
53
  - !ruby/object:Gem::Dependency
54
- name: shoulda
54
+ name: htmlentities
55
55
  prerelease: false
56
56
  requirement: &id003 !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ hash: 63
62
+ segments:
63
+ - 4
64
+ - 0
65
+ - 0
66
+ version: 4.0.0
67
+ type: :runtime
68
+ version_requirements: *id003
69
+ - !ruby/object:Gem::Dependency
70
+ name: shoulda
71
+ prerelease: false
72
+ requirement: &id004 !ruby/object:Gem::Requirement
57
73
  none: false
58
74
  requirements:
59
75
  - - ">="
@@ -65,7 +81,7 @@ dependencies:
65
81
  - 1
66
82
  version: 2.11.1
67
83
  type: :development
68
- version_requirements: *id003
84
+ version_requirements: *id004
69
85
  description: Retrieve the page title for a given url using redirect_follower and hpricot ruby gems
70
86
  email: "'christoph at olszowka.de'"
71
87
  executables: []