doko 0.1.9 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.9
1
+ 0.2.0
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.9"
8
+ s.version = "0.2.0"
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
@@ -1,5 +1,4 @@
1
1
  # -*- coding: utf-8 -*-
2
- # -*- code:utf-8 -*-
3
2
 
4
3
  require 'nokogiri'
5
4
  require 'open-uri'
@@ -25,7 +24,7 @@ class Doko
25
24
  out = []
26
25
  doc = Nokogiri::HTML(open(url).read)
27
26
  doc.search("a").each do |a|
28
- if a[:href].match(/access/) && !a[:href].match(/http/)
27
+ if a[:href] && a[:href].match(/access/) && !a[:href].match(/http/)
29
28
  out << uri + a[:href]
30
29
  end
31
30
  end
@@ -52,6 +51,7 @@ class Doko
52
51
  body.tr!("、",",")
53
52
  body.tr!(" "," ")
54
53
  body.tr!(".",".")
54
+ body.tr!(":",":")
55
55
  blackchars = ",()\n"
56
56
 
57
57
  addrs = body.scan(/\b([^\s,()]{2,3}(都|道|府|県)[^\s,()]{1,8}(市|区|町|村)[^#{blackchars}]+)/).map{ |m|
@@ -76,10 +76,11 @@ class Doko
76
76
  line.gsub!(/\s+$/,"")
77
77
  line.gsub!(/\s?電話:.+$/,"")
78
78
  line.gsub!("[MAP]","")
79
- line.gsub!(/(TEL|FAX):\d{2,4}-\d{2,4}-\d{2,4}/,"")
79
+ line.gsub!(/(TEL|FAX):\d{2,4}-\d{2,4}-\d{2,4}.+/,"")
80
80
  line.gsub!(/(\dー)*\d/) do |t|
81
81
  t.tr("ー","-")
82
82
  end
83
+ line.sub!(/\s$/,"")
83
84
  line
84
85
  end
85
86
  end
data/sample/Gemfile.lock CHANGED
@@ -1,12 +1,8 @@
1
- PATH
2
- remote: ..
3
- specs:
4
- doko (0.1.8)
5
- nokogiri
6
-
7
1
  GEM
8
2
  remote: http://rubygems.org/
9
3
  specs:
4
+ doko (0.1.9)
5
+ nokogiri
10
6
  nokogiri (1.5.3)
11
7
  rack (1.3.6)
12
8
  rack-protection (1.2.0)
@@ -21,5 +17,5 @@ PLATFORMS
21
17
  ruby
22
18
 
23
19
  DEPENDENCIES
24
- doko!
20
+ doko
25
21
  sinatra
data/spec/doko_spec.rb CHANGED
@@ -6,7 +6,6 @@ require 'open-uri'
6
6
  describe "Doko" do
7
7
 
8
8
  describe "parse" do
9
-
10
9
  it "should retrieve address from string" do
11
10
  Doko.parse("ここは\n東京都港区芝浦3-4-1\nです").first.should == "東京都港区芝浦3-4-1"
12
11
  end
@@ -61,11 +60,19 @@ describe "Doko" do
61
60
  it do
62
61
  Doko.parse("http://www.stadium2002.com/stadium/index.php").first.should == "さいたま市緑区中野田500"
63
62
  end
63
+
64
+ it do
65
+ Doko.parse("http://www.canalcafe.jp/").first.should == "東京都新宿区神楽坂1-9"
66
+ end
64
67
  end
65
68
 
66
69
  describe "deep" do
67
70
  it do
68
71
  Doko.deep("http://www.risonare-atami.com/").first.should == "静岡県熱海市水口町2-13-1"
69
72
  end
73
+
74
+ it do
75
+ Doko.deep("http://www.yokohama-akarenga.jp/index.html").should be_empty
76
+ end
70
77
  end
71
78
  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.9
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -146,7 +146,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
146
146
  version: '0'
147
147
  segments:
148
148
  - 0
149
- hash: 2942783918463996752
149
+ hash: -4468521619932611074
150
150
  required_rubygems_version: !ruby/object:Gem::Requirement
151
151
  none: false
152
152
  requirements: