taipeiHotel 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/Gemfile +4 -0
- data/README.md +34 -0
- data/Rakefile +1 -0
- data/lib/taipeiHotel.rb +53 -0
- data/lib/taipeiHotel/version.rb +3 -0
- data/taipeiHotel.gemspec +24 -0
- metadata +71 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
taipeiHotel
|
2
|
+
===========
|
3
|
+
|
4
|
+
The ruby gem adapter Hotel location api of Taipei City Government.
|
5
|
+
|
6
|
+
##Installtiona##
|
7
|
+
|
8
|
+
> gem install taipeiHotel
|
9
|
+
|
10
|
+
##Useage##
|
11
|
+
|
12
|
+
> *TaipeiHotel.list* #get all Hotel index and name
|
13
|
+
|
14
|
+
> *TaipeiHotel.detail(_hotelID)* #get hotel detail
|
15
|
+
|
16
|
+
> *TaipeiHotel.import2DB(_Your model)* #write all taipei hotel data in your model
|
17
|
+
>
|
18
|
+
>>Your model must have follow column.
|
19
|
+
|
20
|
+
>> t.string "travelId"
|
21
|
+
|
22
|
+
>> t.string "travelName"
|
23
|
+
|
24
|
+
>> t.text "description"
|
25
|
+
|
26
|
+
>> t.string "address"
|
27
|
+
|
28
|
+
>> t.string "lat"
|
29
|
+
|
30
|
+
>> t.string "lng"
|
31
|
+
|
32
|
+
>> t.string "imgURL"
|
33
|
+
|
34
|
+
>> t.string "pb_organization"
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/lib/taipeiHotel.rb
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
#$LOAD_PATH << "."
|
2
|
+
require "taipeiHotel/version"
|
3
|
+
require 'json'
|
4
|
+
require 'net/http'
|
5
|
+
require 'pathname'
|
6
|
+
module TaipeiHotel
|
7
|
+
# @endpoint="http://www.api.cloud.taipei.gov.tw/CSCP_API/etm/trv"
|
8
|
+
@endpoint="http://www.api.cloud.taipei.gov.tw/CSCP_API/etm/trv/subCategories/H03/topics"
|
9
|
+
def self.connect
|
10
|
+
resp = Net::HTTP.get_response(URI.parse("#{@endpoint}"))
|
11
|
+
data = resp.body
|
12
|
+
result = JSON.parse(data)
|
13
|
+
end
|
14
|
+
def list
|
15
|
+
res=self.connect()
|
16
|
+
end
|
17
|
+
def detail(_num)
|
18
|
+
@endpoint="http://www.api.cloud.taipei.gov.tw/CSCP_API/etm/trv/rows/#{_num}"
|
19
|
+
res=self.connect()
|
20
|
+
end
|
21
|
+
def import2DB(_dbobj)
|
22
|
+
hotelids=list()
|
23
|
+
hotelids.each do |x|
|
24
|
+
_id=x["travelId"]
|
25
|
+
@endpoint="http://www.api.cloud.taipei.gov.tw/CSCP_API/etm/trv/rows/#{_id}"
|
26
|
+
res=self.connect()
|
27
|
+
a=_dbobj.new
|
28
|
+
a.travelId=res[0]["travelId"]
|
29
|
+
a.travelName=res[0]["travelName"]
|
30
|
+
a.description=res[0]["description"]
|
31
|
+
a.address=res[0]["address"]
|
32
|
+
a.lat=res[0]["lat"]
|
33
|
+
a.lng=res[0]["lng"]
|
34
|
+
a.imgURL=res[0]["imgURL"]
|
35
|
+
a.pb_organization=res[0]["pb_organization"]
|
36
|
+
a.save
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
module_function :list
|
41
|
+
module_function :detail
|
42
|
+
module_function :import2DB
|
43
|
+
end
|
44
|
+
#_dbobj must have follow column
|
45
|
+
# t.string "travelId"
|
46
|
+
# t.string "travelName"
|
47
|
+
# t.text "description"
|
48
|
+
# t.string "address"
|
49
|
+
# t.string "lat"
|
50
|
+
# t.string "lng"
|
51
|
+
# t.string "imgURL"
|
52
|
+
# t.string "pb_organization"
|
53
|
+
|
data/taipeiHotel.gemspec
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "taipeiHotel/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "taipeiHotel"
|
7
|
+
s.version = TaipeiHotel::VERSION
|
8
|
+
s.authors = ["joehwang"]
|
9
|
+
s.email = ["joehwang.com@gmail.com"]
|
10
|
+
s.homepage = ""
|
11
|
+
s.summary = %q{ The ruby gem adapter Hotel location api of Taipei City Government. }
|
12
|
+
s.description = %q{ The ruby gem adapter Hotel location api of Taipei City Government. }
|
13
|
+
s.homepage ="http://github.com/joehwang/taipeiHotel"
|
14
|
+
s.rubyforge_project = "taipeiHotel"
|
15
|
+
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
+
s.require_paths = ["lib"]
|
20
|
+
|
21
|
+
# specify any dependencies here; for example:
|
22
|
+
# s.add_development_dependency "rspec"
|
23
|
+
# s.add_runtime_dependency "rest-client"
|
24
|
+
end
|
metadata
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: taipeiHotel
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 0
|
8
|
+
- 2
|
9
|
+
version: 0.0.2
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- joehwang
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2012-05-10 00:00:00 +08:00
|
18
|
+
default_executable:
|
19
|
+
dependencies: []
|
20
|
+
|
21
|
+
description: " The ruby gem adapter Hotel location api of Taipei City Government. "
|
22
|
+
email:
|
23
|
+
- joehwang.com@gmail.com
|
24
|
+
executables: []
|
25
|
+
|
26
|
+
extensions: []
|
27
|
+
|
28
|
+
extra_rdoc_files: []
|
29
|
+
|
30
|
+
files:
|
31
|
+
- .gitignore
|
32
|
+
- Gemfile
|
33
|
+
- README.md
|
34
|
+
- Rakefile
|
35
|
+
- lib/taipeiHotel.rb
|
36
|
+
- lib/taipeiHotel/version.rb
|
37
|
+
- taipeiHotel.gemspec
|
38
|
+
has_rdoc: true
|
39
|
+
homepage: http://github.com/joehwang/taipeiHotel
|
40
|
+
licenses: []
|
41
|
+
|
42
|
+
post_install_message:
|
43
|
+
rdoc_options: []
|
44
|
+
|
45
|
+
require_paths:
|
46
|
+
- lib
|
47
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
48
|
+
none: false
|
49
|
+
requirements:
|
50
|
+
- - ">="
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
segments:
|
53
|
+
- 0
|
54
|
+
version: "0"
|
55
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
56
|
+
none: false
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
segments:
|
61
|
+
- 0
|
62
|
+
version: "0"
|
63
|
+
requirements: []
|
64
|
+
|
65
|
+
rubyforge_project: taipeiHotel
|
66
|
+
rubygems_version: 1.3.7
|
67
|
+
signing_key:
|
68
|
+
specification_version: 3
|
69
|
+
summary: The ruby gem adapter Hotel location api of Taipei City Government.
|
70
|
+
test_files: []
|
71
|
+
|