qunar 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e4ba1d679946abe2f3016259dc8e0b4e7ee0379c
4
- data.tar.gz: c55780c6f8d0986e17d8886dcf4b650076117b8e
3
+ metadata.gz: 22b65dfbe0550eac019ee245cf7b7eeb13694f43
4
+ data.tar.gz: b4117d0056b9ff1bf526e61ff8e1470b18ca9877
5
5
  SHA512:
6
- metadata.gz: e938a846a8799b42590edfca4e09b777dbe04094210b3830128b3727d735d492f7a3721783e2f75e97a61115754b4ab852fda934df45df5c8411ed243956ba65
7
- data.tar.gz: 5df5d5d986d06d5249bd76891cc5ff253bf1949563b275bc031865f88ed2d51a7c305ee70eb97036919c97db459476de5b34f3530ade39ffe2d8e2f7c77b403f
6
+ metadata.gz: 3155729d55afe3b7dd6c2f062f017d90a4b83367b6955b1899a0028825d320c92961e8971027bdabf35ac0c042ada8f2360f4d7beeb7b0d86f6ebc7f8f56e3f7
7
+ data.tar.gz: 94fbf6f6917856f030e42b2ab3e60737b8ecf65af1fcb4b03f72c2e42dd387e5c2e3835379037277ef3e8ff2468cf7ffeffc43a3fe13d192685b3e63982ebd09
data/lib/qunar/rank.rb CHANGED
@@ -57,12 +57,14 @@ module Qunar
57
57
  end
58
58
  otas['insurance'] = insurance
59
59
 
60
- coupon = row.search("span[@class='fan']/em[@class='pr'] |span[@class='fan laps']/em[@class='pr']").first
60
+ coupon = row.search("span[@class='fan']/em[@class='pr']").first
61
+
61
62
  if coupon == nil
62
63
  coupon = '0'
63
64
  else
64
65
  coupon = coupon.text.sub(/¥/,'').strip
65
66
  end
67
+
66
68
  otas['coupon'] = coupon
67
69
 
68
70
  prepay = row.search("span[@title='需要预先支付房款']").first
data/lib/qunar/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Qunar
2
- VERSION = "0.0.2"
3
- end
2
+ VERSION = "0.0.3"
3
+ end
data/spec/rank_spec.rb CHANGED
@@ -2,7 +2,9 @@ require 'qunar/rank'
2
2
 
3
3
  describe Qunar::Rank do
4
4
  sample = Qunar::Rank.new('beijing_city_2933')
5
-
5
+
6
+ sz_sample = Qunar::Rank.new('shenzhen_6993')
7
+
6
8
  it "has 7 rooms" do
7
9
  # when directly check the hash object the Chinese charactervalue is saved as format like "\u6807\u51C6\u53CC\u5E8A\u623F", it is not been parsed here, so it is not equal to chinese charactor, it's just a sequnce of coding,it needs to be parse,then it could show as Chinese character.
8
10
  # room = {"room_type" => "\u6807\u51C6\u53CC\u5E8A\u623F", "ota" => "\u827A\u9F99\u65C5\u884C\u7F51", "bookable" => "\u9884\u8BA2", "insurance" => true, "coupon" => "0", "prepay" => false, "price" => "918", "neat_price" => "918"}
@@ -17,8 +19,8 @@ describe Qunar::Rank do
17
19
  expect(sample.rooms[1]['room_type']).to eq '标准大床房'
18
20
  end
19
21
 
20
- it "has 22 otas for the first room type '标准双床房'" do
21
- expect(sample.rooms.first['otas'].size).to eq 22
22
+ it "has 20 otas for the first room type '标准双床房'" do
23
+ expect(sample.rooms.first['otas'].size).to eq 20
22
24
  end
23
25
 
24
26
  it "has 20 otas for the second room type '标准大床房'" do
@@ -36,12 +38,10 @@ describe Qunar::Rank do
36
38
  end
37
39
 
38
40
  it "first ota of first roomtype is bookable" do
39
- #puts subject.rooms.first['otas'].first['bookable']
40
41
  expect(sample.rooms.first['otas'].first['bookable']).to eq '预订'
41
42
  end
42
43
 
43
44
  it "last ota of first roomtype is bookable" do
44
- #puts subject.rooms[-1]['otas'].first['bookable']
45
45
  expect(sample.rooms.first['otas'][-1]['bookable']).to eq '订完'
46
46
  end
47
47
 
@@ -49,9 +49,8 @@ describe Qunar::Rank do
49
49
  expect(sample.rooms.first['otas'].first['insurance']).to eq true
50
50
  end
51
51
 
52
- it "third ota of first roomtype need insurance" do
53
- #puts subject.rooms.first['otas'][2]['insurance']
54
- expect(sample.rooms.first['otas'][2]['insurance']).to eq false
52
+ it "second ota of first roomtype not need insurance" do
53
+ expect(sample.rooms.first['otas'][1]['insurance']).to eq false
55
54
  end
56
55
 
57
56
  it "first ota of first roomtype coupon is 0" do
@@ -59,20 +58,25 @@ describe Qunar::Rank do
59
58
  end
60
59
 
61
60
 
61
+ it "first ota of first roomtype in shenzhen coupon is 40" do
62
+ expect(sz_sample.rooms.first['otas'].first['coupon']).to eq '40'
63
+ end
64
+
65
+
62
66
  it "first ota of first roomtype need prepay" do
63
- expect(sample.rooms.first['otas'].first['prepay']).to eq false
67
+ expect(sample.rooms.first['otas'][2]['prepay']).to eq true
64
68
  end
65
69
 
66
70
  it "second ota of first roomtype need prepay" do
67
- expect(sample.rooms.first['otas'][1]['prepay']).to eq true
71
+ expect(sample.rooms.first['otas'][1]['prepay']).to eq false
68
72
  end
69
73
 
70
74
  it "first ota of first roomtype price" do
71
75
  expect(sample.rooms.first['otas'].first['price']).to eq '918'
72
76
  end
73
77
 
74
- it "sixth ota of first roomtype price" do
75
- expect(sample.rooms.first['otas'][5]['price']).to eq '638'
78
+ it "fifth ota of first roomtype price" do
79
+ expect(sample.rooms.first['otas'][4]['price']).to eq '638'
76
80
  end
77
81
 
78
82
  it "first ota of first roomtype neat_price" do
@@ -81,7 +85,7 @@ describe Qunar::Rank do
81
85
 
82
86
  it "sixth ota of first roomtype neat_price" do
83
87
  #puts subject.rooms.first['otas'][5]['neat_price']
84
- expect(sample.rooms.first['otas'][5]['neat_price']).to eq '734'
88
+ expect(sample.rooms.first['otas'][4]['neat_price']).to eq '734'
85
89
  end
86
90
 
87
91
  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.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - JusticeChow