doko 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. data/VERSION +1 -1
  2. data/doko.gemspec +1 -1
  3. data/lib/doko.rb +6 -2
  4. data/spec/doko_spec.rb +5 -1
  5. metadata +2 -2
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.4
1
+ 0.1.5
data/doko.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "doko"
8
- s.version = "0.1.4"
8
+ s.version = "0.1.5"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Masaki Sawamura"]
data/lib/doko.rb CHANGED
@@ -14,11 +14,15 @@ class Doko
14
14
  if str.match( /^#{URI.regexp}$/ )
15
15
  str = open(str).read
16
16
  end
17
- @doc = Nokogiri::HTML(str)
17
+ if str.match(/<html/)
18
+ @text = (Nokogiri::HTML(str)/"body").text
19
+ else
20
+ @text = str
21
+ end
18
22
  end
19
23
 
20
24
  def parse
21
- body = (@doc/"body").text
25
+ body = @text
22
26
  body.tr!("0-9","0-9")
23
27
  body.tr!("ー","-")
24
28
  body.tr!("()","()")
data/spec/doko_spec.rb CHANGED
@@ -5,7 +5,11 @@ require 'open-uri'
5
5
 
6
6
  describe "Doko" do
7
7
 
8
- it "should return address" do
8
+ it "should retrieve address from string" do
9
+ Doko.parse("ここは\n東京都港区芝浦3-4-1\nです").first.should == "東京都港区芝浦3-4-1"
10
+ end
11
+
12
+ it "should retrieve address from html" do
9
13
  addrs = Doko.parse(open("http://r.tabelog.com/tokyo/A1304/A130401/13130066/").read)
10
14
  addrs.first.should == "東京都新宿区新宿3-38-1 ルミネエスト7F"
11
15
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: doko
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -142,7 +142,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
142
142
  version: '0'
143
143
  segments:
144
144
  - 0
145
- hash: 3311531486027720188
145
+ hash: -3009257720424564000
146
146
  required_rubygems_version: !ruby/object:Gem::Requirement
147
147
  none: false
148
148
  requirements: