hotel_price 0.2.1 → 0.2.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 87c91d285ca9f23c4fd9315ae10ae7d34a07a52160ddb8c827079f281426ab81
4
- data.tar.gz: ff3b1565cba8b422318729e610bcaf592c171f57c2bb6d10278b4f03123bd7c7
3
+ metadata.gz: 7a4c5a3f6cbbe65473cb75159bffe08427d56715d6c7658c80ddd43be4d6fb2e
4
+ data.tar.gz: c430e764095d019bfe233172e26afa84aba5d8ddc097b26dd53e0f2e2e6875fc
5
5
  SHA512:
6
- metadata.gz: 705a64bade5aeff929bed833d4193f3b61b138657b13bbdbe992dc6a1d4aa42345149d0487a19d2f457e2bd31907d25b5d099f7c1ded0dee21daaba65081b7b0
7
- data.tar.gz: 41fd30af0bb60ce2a2658615de090e1f773034cec4e02a78efa4652ddd2483cbed6d4fcd6a6852210006e90cad2a13bd0c64e07b0e79e3308dc5d89b641491a5
6
+ metadata.gz: 8438a25ced4479c39e48f88f35fc3bc56bdf269fa1423706e7820d29b6a9b8a5060a854ecc58f950964753f3b403972fc8995d580840b70b33506bdeac2cd11f
7
+ data.tar.gz: b36957e05bc1b67a702714e92ce227131c63fd764934c99aedd4efbdd46517a18874488ccdbc7b890aa5f4fb08a50f507827ba86327cbbba7742c7d3776a2d07
data/.rubocop.yml CHANGED
@@ -215,4 +215,7 @@ Naming/HeredocDelimiterNaming:
215
215
  Enabled: false
216
216
 
217
217
  Naming/AccessorMethodName:
218
+ Enabled: false
219
+
220
+ Style/MutableConstant:
218
221
  Enabled: false
data/README.md CHANGED
@@ -6,26 +6,43 @@ This Gem is made for ppl who work at travel industry
6
6
  Add this line to your application's Gemfile:
7
7
 
8
8
  ```ruby
9
- gem 'hotel_price'
9
+ gem "hotel_price"
10
10
  ```
11
11
 
12
12
  And then execute:
13
13
 
14
+ ```bash
14
15
  $ bundle
16
+ ```
15
17
 
16
18
  Or install it yourself as:
17
19
 
20
+ ```bash
18
21
  $ gem install hotel_price
22
+ ```
19
23
 
20
24
  ## Usage
21
25
 
22
- Get Rakuten Travel Top Page Title
26
+ ### Rakuten Travel
27
+
28
+ #### Rakuten API
29
+ Set `rakuten_hotel_id`
23
30
 
24
- $ hotel_price
31
+ ```ruby
32
+ hotel = HotelPrice::RakutenTravel::RakutenAPI.new(
33
+ rakuten_hotel_id: "128552
34
+ )
35
+ ```
36
+
37
+ Get Hotel Info
38
+
39
+ ```ruby
40
+ puts hotel.hotel_info
41
+ ```
25
42
 
26
43
  ## Development
27
44
 
28
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
45
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `bundle exec rspec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
29
46
 
30
47
  To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
31
48
 
data/lib/hotel_price.rb CHANGED
@@ -10,39 +10,43 @@ module HotelPrice
10
10
  options = Selenium::WebDriver::Firefox::Options.new
11
11
  options.add_argument("-headless")
12
12
  driver = Selenium::WebDriver.for :firefox, options: options
13
- rakuten_travel_hotel_id = 7770
14
- driver.get("https://travel.rakuten.co.jp/HOTEL/#{rakuten_travel_hotel_id}/review.html")
13
+ rakuten_travel_hotel_id = 128552
14
+ driver.get("https://travel.rakuten.co.jp/HOTEL/#{rakuten_travel_hotel_id.to_s}/review.html")
15
15
  sleep 2
16
16
  comment_area = driver.find_elements(:class_name, "commentReputationBoth")
17
- data = comment_area.map do |f|
17
+ comment_area.map do |f|
18
18
  {
19
19
  status: "success",
20
20
  date: f.find_element(class_name: "time").text,
21
- rakuten_hotel_id: 7770,
21
+ rakuten_hotel_id: rakuten_travel_hotel_id,
22
22
  comment: f.find_element(class_name: "commentSentence").text
23
23
  }
24
24
  end
25
25
  end
26
26
 
27
- module Jalan
28
- class JalanConsole
29
- def initialize params
30
- @config = {
31
- login_id: params[:login_id],
32
- login_pw: params[:login_pw],
33
- chain: params[:chain] ||= false,
34
- jalan_hotel_id: params[:jalan_hotel_id] ||= 0,
35
- jalan_api_key: params[:jalan_api_key] ||= ENV["JALAN_API_KEY"]
27
+ require "jalan"
28
+
29
+ module RakutenTravel
30
+ def self.review rakuten_hotel_id
31
+ # firefox_capabilities = Selenium::WebDriver::Remote::Capabilities.firefox
32
+ # @driver = Selenium::WebDriver.for(:remote, url: "http://hub:4444/wd/hub", desired_capabilities: firefox_capabilities)
33
+ options = Selenium::WebDriver::Firefox::Options.new
34
+ options.add_argument("-headless")
35
+ driver = Selenium::WebDriver.for :firefox, options: options
36
+ driver.get("https://travel.rakuten.co.jp/HOTEL/#{rakuten_hotel_id.to_s}/review.html")
37
+ sleep 2
38
+ comment_area = driver.find_elements(:class_name, "commentBox")
39
+ data = comment_area.map do |f|
40
+ {
41
+ date: f.find_element(class_name: "time").text,
42
+ rakuten_hotel_id: rakuten_hotel_id,
43
+ comment: f.find_element(class_name: "commentSentence").text
36
44
  }
37
45
  end
38
-
39
- def test
40
- @config
41
- end
46
+ driver.quit
47
+ data
42
48
  end
43
- end
44
49
 
45
- module RakutenTravel
46
50
  class RakutenConsole
47
51
  def initialize params
48
52
  @config = {
@@ -1,3 +1,3 @@
1
1
  module HotelPrice
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.2"
3
3
  end
data/lib/jalan.rb ADDED
@@ -0,0 +1,11 @@
1
+ module Jalan
2
+ class JalanAPI
3
+ def initialize api_key
4
+ @api_key = api_key
5
+ end
6
+
7
+ def test
8
+ @api_key
9
+ end
10
+ end
11
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hotel_price
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fumitake Kawasaki
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-01-15 00:00:00.000000000 Z
11
+ date: 2020-01-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -71,7 +71,6 @@ email:
71
71
  - fumitake.kawasaki@el-soul.com
72
72
  executables:
73
73
  - hotel_price
74
- - rakuten_travel_review
75
74
  extensions: []
76
75
  extra_rdoc_files: []
77
76
  files:
@@ -88,12 +87,10 @@ files:
88
87
  - bin/console
89
88
  - bin/setup
90
89
  - exe/hotel_price
91
- - exe/rakuten_travel_review
92
90
  - hotel_price.gemspec
93
91
  - lib/hotel_price.rb
94
92
  - lib/hotel_price/version.rb
95
- - lib/rakuten_travel.rb
96
- - lib/rakuten_travel_review.rb
93
+ - lib/jalan.rb
97
94
  homepage: https://github.com/el-fudo/hotel_price
98
95
  licenses:
99
96
  - MIT
@@ -1,4 +0,0 @@
1
- #!/usr/bin/env ruby
2
- require 'rakuten_travel_review'
3
-
4
- puts RakutenTravelReview.rakuten_travel ARGV[0]
@@ -1,85 +0,0 @@
1
- module RakutenTravel
2
- class RakutenConsole
3
- def initialize params
4
- @config = {
5
- login_id: params[:login_id],
6
- login_pw: params[:login_pw],
7
- chain: params[:chain] ||= false,
8
- rakuten_hotel_id: params[:rakuten_hotel_id] ||= 0,
9
- rakuten_api_key: params[:rakuten_api_key] ||= ENV["RT_API_KEY"]
10
- }
11
- end
12
-
13
- def test
14
- @config
15
- end
16
-
17
- def hotel_info
18
- uri = URI.parse("https://app.rakuten.co.jp/services/api/Travel/HotelDetailSearch/20131024?hotelNo=" + @config[:rakuten_hotel_id].to_s + "&applicationId=" + @config[:rakuten_api_key].to_s + "&datumType=1&responseType=large")
19
- json = Net::HTTP.get(uri)
20
- @result = JSON.parse(json)
21
- return "ホテル情報がありませんでした。" if @result["error"] == "not_found"
22
- return @result["error_description"] if @result["error"] == "wrong_parameter"
23
- @result["hotels"][0].each do |_key, value|
24
- value[0].each do |_key, value|
25
- @data_hash = {
26
- rakuten_hotel_id: value["hotelNo"],
27
- hotel_name: value["hotelName"],
28
- room_price_min: value["hotelMinCharge"],
29
- lat: value["latitude"],
30
- lon: value["longitude"],
31
- tel: value["telephoneNo"],
32
- zip_code: value["postalCode"],
33
- prefecture: value["address1"],
34
- address1: value["address2"],
35
- fax: value["faxNo"],
36
- access: value["access"],
37
- parking_info: value["parkingInformation"],
38
- near_station: value["nearestStation"],
39
- hotel_img_url: value["hotelImageUrl"],
40
- rakuten_review_count: value["reviewCount"],
41
- rakuten_review_avg: value["reviewAverage"].to_f
42
- }
43
- end
44
- end
45
- @result["hotels"][0].each do |_key, value|
46
- value[1].each do |_key, value|
47
- @data_hash["rakuten_service_review"] = value["serviceAverage"].to_f
48
- @data_hash["rakuten_location_review"] = value["locationAverage"].to_f
49
- @data_hash["rakuten_room_review"] = value["roomAverage"].to_f
50
- @data_hash["rakuten_equipment_review"] = value["equipmentAverage"].to_f
51
- @data_hash["rakuten_bath_review"] = value["bathAverage"].to_f
52
- @data_hash["rakuten_meal_review"] = value["mealAverage"].to_f
53
- end
54
- end
55
- @result["hotels"][0].each do |_key, value|
56
- value[2].each do |_key, value|
57
- @data_hash["middle_class_code"] = value["middleClassCode"].to_s
58
- @data_hash["small_class_code"] = value["smallClassCode"].to_s
59
- @data_hash["area_name"] = value["areaName"].to_s
60
- @data_hash["hotel_class_code"] = value["hotelClassCode"].to_s
61
- @data_hash["checkin_time"] = value["checkinTime"].to_s
62
- @data_hash["checkout_time"] = value["checkoutTime"].to_s
63
- @data_hash["last_checkin_time"] = value["lastCheckinTime"].to_s
64
- end
65
- end
66
- @result["hotels"][0].each do |_key, value|
67
- value[3].each do |_key, value|
68
- @data_hash["total_room_num"] = value["hotelRoomNum"].to_s
69
- room_facilities = []
70
- value["roomFacilities"].each_with_index do |f, i|
71
- room_facilities[i] = f["item"]
72
- end
73
- @data_hash["room_facilities"] = room_facilities
74
- end
75
- end
76
- @result["hotels"][0].each do |_key, value|
77
- value[4].each do |_key, value|
78
- @data_hash["hotel_policy_note"] = value["note"].to_s
79
- @data_hash["cancel_policy"] = value["cancelPolicy"].to_s
80
- end
81
- end
82
- @data_hash
83
- end
84
- end
85
- end
@@ -1,27 +0,0 @@
1
- require "hotel_price/version"
2
- require "selenium-webdriver"
3
-
4
- module RakutenTravelReview
5
- class Error < StandardError; end
6
- def self.rakuten_travel rakuten_hotel_id
7
- # firefox_capabilities = Selenium::WebDriver::Remote::Capabilities.firefox
8
- # @driver = Selenium::WebDriver.for(:remote, url: "http://hub:4444/wd/hub", desired_capabilities: firefox_capabilities)
9
- options = Selenium::WebDriver::Firefox::Options.new
10
- options.add_argument("-headless")
11
- driver = Selenium::WebDriver.for :firefox#, options: options
12
- rakuten_travel_hotel_id = rakuten_hotel_id.to_s
13
- driver.get("https://travel.rakuten.co.jp/HOTEL/#{rakuten_travel_hotel_id.to_s}/review.html")
14
- sleep 2
15
- comment_area = driver.find_elements(:class_name, "commentBox")
16
- data = comment_area.map do |f|
17
- {
18
- status: "success",
19
- date: f.find_element(class_name: "time").text,
20
- rakuten_hotel_id: rakuten_hotel_id,
21
- comment: f.find_element(class_name: "commentSentence").text
22
- }
23
- end
24
- driver.quit
25
- data
26
- end
27
- end