qunar 0.0.4 → 0.0.5

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
  SHA1:
3
- metadata.gz: e8cdffb70710b1fbff0aa1c15ee32d65d4864994
4
- data.tar.gz: 78cbb58939792e8e3ff33bda55a9f2c1dd4f85b7
3
+ metadata.gz: 51295e4766f4a1a4e6943e7022d573cad5e47132
4
+ data.tar.gz: 8ed3eb0cab6dac6ab8294f44fcabbf6cc1b24153
5
5
  SHA512:
6
- metadata.gz: c6a440427c2e623c18546607f6beff0c6cf6c8910494b6170f9575fc6778b820d17d024efe1e11fc3c90f1b257e04bd723924a2bc4e51f03b262424ae6f6e7b2
7
- data.tar.gz: fd5ff8d88c9ebbcbbe0d26efa82ff9557f6048338ec486adbc1f0e876df038d995bdb4c4f6d7584580189ea999c347056e8ded820c1783f929f9468b70b018b2
6
+ metadata.gz: e455e2f1626397293367b227e9dacd9b7d8f765034a58c3734c5a332457c393048afae3c949351f3103e3c51d2fffa6c95685f3930ab5718d1bab095392a579a
7
+ data.tar.gz: 8d0db7e92b9e5b576b59695501d9ced033ac6e81f8e0f09f61f3fbb1306d048506ce3339713e6f98b8417baaa57e787cef4aaa4db77846f7d4b2408a53d5a85f
data/lib/qunar/rank.rb CHANGED
@@ -27,12 +27,8 @@ module Qunar
27
27
  #@page = Capybara.current_session.driver.browser.page_source #use when choose capybara driver selenium
28
28
  @page = Capybara.current_session.driver.browser.body #use when choose capybara driver webkit
29
29
  @hotel = Nokogiri::HTML @page
30
- File.open("test1.html","w") do |file|
31
- file.puts @page
32
- end
33
30
  end
34
31
 
35
-
36
32
  def rooms
37
33
  rooms = []
38
34
  # room
@@ -50,6 +46,11 @@ module Qunar
50
46
  otas['ota'] = ota
51
47
 
52
48
  bookable = row.search("a[@class='btn-book']/span").first.text.strip
49
+ if bookable == '预订'
50
+ bookable = true
51
+ else
52
+ bookable = false
53
+ end
53
54
  otas['bookable'] = bookable
54
55
 
55
56
  insurance = row.search("p[@class='dbt-ct']").first
@@ -63,13 +64,16 @@ module Qunar
63
64
  coupon = row.search("span[@class='fan']/em[@class='pr']").first
64
65
 
65
66
  if coupon == nil
66
- coupon = '0'
67
+ coupon = 0
67
68
  else
68
- coupon = coupon.text.sub(/¥/,'').strip
69
+ coupon = coupon.text.sub(/¥/,'').strip.to_i
69
70
  end
70
71
 
71
72
  otas['coupon'] = coupon
72
73
 
74
+ reserve_detail = row.search("div[@class='clrfix order-detail']").first.text.strip
75
+ otas['reserve_detail'] = reserve_detail
76
+
73
77
  prepay = row.search("span[@title='需要预先支付房款']").first
74
78
  if prepay == nil
75
79
  prepay = false
data/lib/qunar/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Qunar
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
data/spec/rank_spec.rb CHANGED
@@ -19,6 +19,8 @@ describe Qunar::Rank do
19
19
  expect(sample.rooms[1]['room_type']).to eq '标准大床房'
20
20
  end
21
21
 
22
+
23
+
22
24
  it "has 20 otas for the first room type '标准双床房'" do
23
25
  expect(sample.rooms.first['otas'].size).to eq 20
24
26
  end
@@ -27,24 +29,27 @@ describe Qunar::Rank do
27
29
  expect(sample.rooms[1]['otas'].size).to eq 20
28
30
  end
29
31
 
32
+
30
33
  it "first ota of first roomtype names '艺龙旅行网'" do
31
34
  #puts subject.rooms.first['otas'].first['ota']
32
35
  expect(sample.rooms.first['otas'].first['ota']).to eq '艺龙旅行网'
33
36
  end
34
37
 
38
+
35
39
  it "first ota of second roomtype names Expedia" do
36
40
  #puts subject.rooms.first['otas'].first['ota']
37
41
  expect(sample.rooms[1]['otas'].first['ota']).to eq 'Booking.com'
38
42
  end
39
43
 
40
44
  it "first ota of first roomtype is bookable" do
41
- expect(sample.rooms.first['otas'].first['bookable']).to eq '预订'
45
+ expect(sample.rooms.first['otas'].first['bookable']).to eq true
42
46
  end
43
47
 
44
- it "last ota of first roomtype is bookable" do
45
- expect(sample.rooms.first['otas'][-1]['bookable']).to eq '订完'
48
+ it "last ota of first roomtype is not bookable" do
49
+ expect(sample.rooms.first['otas'][-1]['bookable']).to eq false
46
50
  end
47
51
 
52
+
48
53
  it "first ota of first roomtype need insurance" do
49
54
  expect(sample.rooms.first['otas'].first['insurance']).to eq true
50
55
  end
@@ -54,12 +59,15 @@ describe Qunar::Rank do
54
59
  end
55
60
 
56
61
  it "first ota of first roomtype coupon is 0" do
57
- expect(sample.rooms.first['otas'].first['coupon']).to eq '0'
62
+ expect(sample.rooms.first['otas'].first['coupon']).to eq 0
58
63
  end
59
64
 
60
-
61
65
  it "first ota of first roomtype in shenzhen coupon is 40" do
62
- expect(sz_sample.rooms.first['otas'].first['coupon']).to eq '40'
66
+ expect(sz_sample.rooms.first['otas'].first['coupon']).to eq 40
67
+ end
68
+
69
+ it "first ota of first roomtype reserve_detail is '标准双床房 - 仅提供住宿 - 免费取消'" do
70
+ expect(sample.rooms.first['otas'].first['reserve_detail']).to eq '标准双床房 - 仅提供住宿 - 免费取消'
63
71
  end
64
72
 
65
73
 
@@ -67,25 +75,25 @@ describe Qunar::Rank do
67
75
  expect(sample.rooms.first['otas'][2]['prepay']).to eq true
68
76
  end
69
77
 
70
- it "second ota of first roomtype need prepay" do
78
+ it "second ota of first roomtype not need prepay" do
71
79
  expect(sample.rooms.first['otas'][1]['prepay']).to eq false
72
80
  end
73
81
 
74
82
  it "first ota of first roomtype price" do
75
- expect(sample.rooms.first['otas'].first['price']).to eq '918'
83
+ expect(sample.rooms.first['otas'].first['price']).to eq 918
76
84
  end
77
85
 
78
86
  it "fifth ota of first roomtype price" do
79
- expect(sample.rooms.first['otas'][4]['price']).to eq '638'
87
+ expect(sample.rooms.first['otas'][4]['price']).to eq 638
80
88
  end
81
89
 
82
90
  it "first ota of first roomtype neat_price" do
83
- expect(sample.rooms.first['otas'].first['neat_price']).to eq '918'
91
+ expect(sample.rooms.first['otas'].first['neat_price']).to eq 918
84
92
  end
85
93
 
86
94
  it "sixth ota of first roomtype neat_price" do
87
95
  #puts subject.rooms.first['otas'][5]['neat_price']
88
- expect(sample.rooms.first['otas'][4]['neat_price']).to eq '734'
96
+ expect(sample.rooms.first['otas'][4]['neat_price']).to eq 734
89
97
  end
90
-
98
+
91
99
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: qunar
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - JusticeChow