mock_search 0.3.2 → 0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +13 -5
- data/lib/mock_search/mock_search_multipledestinations.rb +35 -43
- data/lib/mock_search/mock_search_oneway.rb +26 -59
- data/lib/mock_search/mock_search_roundtrip.rb +50 -68
- data/mock_search.gemspec +2 -4
- metadata +8 -24
- data/lib/mock_city.rb +0 -58
- data/lib/mock_search.rb +0 -130
checksums.yaml
CHANGED
@@ -1,7 +1,15 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
Mzg5ZGJjMjkwYWNhNWEwMjk1ZDZkNmEzNTRlYmQ5NzQ4Y2Y4MzAwMQ==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
ZjVlNzQzODM3NGMzMWVjY2I5YmI2ZmNlM2M1YmJhNDliZjhlZjFjZQ==
|
5
7
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
MDc4NjQwOTZkODYwMzJmOGYwOTUyZTZlNGRhNjg0M2NhY2RiMjBjYjJhOGZl
|
10
|
+
NTU2ZDZmMjU3YmYwMjlmNWEwMWI4ODVmNjJiNDRjNzcwZTYzOGIxMTBiNTI0
|
11
|
+
ZGMzZDM1N2QwNzkyOTQxNzgzMTI5M2M0ZDg1ZjUwMmVmNzhiNTI=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
ODgxNjY2Y2ZmNTg3YTYzNjE0NmIzZjRkOTdkNGQwMWI0OTVkMmViNjE0ZTA4
|
14
|
+
OTFkMjNhOWQ5MzMzNjY5NTBhYWY5Y2YxYTk0MWUxYTJkNDI0YzFhNWEyNjVm
|
15
|
+
M2Q2MWEyYTIxOTRiZTFhYmYwNDM0N2JiZTlmMDdhMmM3NjY5MjA=
|
@@ -2,69 +2,61 @@ class MockSearchMultipledestinations < MockSearch
|
|
2
2
|
|
3
3
|
attr_reader :city_from_1, :city_from_2, :city_from_3, :city_to_1, :city_to_2, :city_to_3, :date_from_1, :date_from_2, :date_from_3, :description, :path
|
4
4
|
|
5
|
-
def initialize(site,env,cabotage
|
5
|
+
def initialize(site,env,cabotage)
|
6
6
|
super(site,env,cabotage)
|
7
|
-
@city_from_1 = MockCity.new(@site)
|
8
|
-
@city_to_1 =
|
7
|
+
@city_from_1 = MockCity.new(@site,"CCS")
|
8
|
+
@city_to_1 = MockCity.new(@site,"BUE")
|
9
9
|
@city_from_2 = @city_to_1
|
10
|
-
@city_to_2 =
|
10
|
+
@city_to_2 = MockCity.new(@site,"RIO")
|
11
11
|
@city_from_3 = @city_to_2
|
12
12
|
@city_to_3 = @city_from_1
|
13
|
-
@date_from_1 = Date.today+
|
14
|
-
@date_from_2 = Date.today+
|
15
|
-
@date_from_3 = Date.today+
|
13
|
+
@date_from_1 = Date.today+60
|
14
|
+
@date_from_2 = Date.today+68
|
15
|
+
@date_from_3 = Date.today+75
|
16
16
|
@description = "multipledestinations"
|
17
17
|
@path = "#{@city_from_1.code},#{@city_from_2.code},#{@city_from_3.code}/#{@city_to_1.code},#{@city_to_2.code},#{@city_to_3.code}/#{@date_from_1},#{@date_from_2},#{@date_from_3}/#{passengers}"
|
18
18
|
end
|
19
19
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
20
|
+
def generate_search_url()
|
21
|
+
return @host + "/shop/flights/results/multipledestinations/" + @path
|
22
|
+
end
|
23
|
+
|
24
|
+
def advanced_bussinnes
|
25
|
+
return ""
|
26
|
+
end
|
25
27
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
28
|
+
def generate_query_string_search_url()
|
29
|
+
return @host + "/shop/flights/search/multipledestinations/" + @path + "?param1=1"
|
30
|
+
end
|
31
|
+
|
32
|
+
def generate_airports_disambiguation_search_url(city)
|
33
|
+
@path = "#{@city_from_1.code},#{city},#{@city_from_3.code}/#{city},#{@city_to_2.code},#{@city_to_3.code}/#{@date_from_1},#{@date_from_2},#{@date_from_3}/#{passengers}"
|
34
|
+
return @host + "/shop/flights/disambiguation/airports/multipledestinations/" + @path
|
30
35
|
end
|
31
36
|
|
32
|
-
|
33
|
-
def generate_url_disambiguation_city()
|
37
|
+
def generate_city_disambiguation_search_url()
|
34
38
|
return @host + "/shop/flights/search/multipledestinations/" + @path.gsub(/(\D{3}),(\D{3}),(\D{3})\/(\D{3}),(\D{3}),(\D{3})\//,"___,___,___/___,___,___/") + "?toDescriptions=test1,test2,test3&fromDescriptions=test4,test5,test6"
|
35
39
|
end
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
return @host + "/shop/flights/test/data/search/begin/multipledestinations/" + @path
|
40
|
+
|
41
|
+
def generate_anticipated_search_url()
|
42
|
+
return @host + "/shop/flights/test/data/search/begin/multipledestinations/" + @path
|
40
43
|
end
|
41
44
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
end
|
46
|
-
|
47
|
-
def get_ticket_date()
|
48
|
-
super()
|
49
|
-
@result_hash['itinerary_hash'] = @itinerary['id']
|
50
|
-
end
|
45
|
+
def generate_search_url_for_cabotage()
|
46
|
+
return @host + "/shop/flights/results/multipledestinations/" + @path
|
47
|
+
end
|
51
48
|
|
52
|
-
|
53
|
-
|
54
|
-
|
49
|
+
def generate_search_url_for_country(site_country)
|
50
|
+
to_city_change(site_country)
|
51
|
+
return @host + "/shop/flights/results/multipledestinations/" + @path
|
52
|
+
end
|
55
53
|
|
56
54
|
def get_indec_airlines(env)
|
57
55
|
return []
|
58
56
|
end
|
59
57
|
|
60
58
|
def to_city_description()
|
61
|
-
|
59
|
+
return "#{@city_to_1},#{@city_to_2},#{@city_to_3}"
|
62
60
|
end
|
63
|
-
|
64
|
-
|
65
|
-
@date_from_1 = date_from
|
66
|
-
@path = "#{@city_from_1.code},#{@city_from_2.code},#{@city_from_3.code}/#{@city_to_1.code},#{@city_to_2.code},#{@city_to_3.code}/#{@date_from_1},#{@date_from_2},#{@date_from_3}/#{passengers}"
|
67
|
-
end
|
68
|
-
|
69
|
-
|
70
|
-
end
|
61
|
+
|
62
|
+
end
|
@@ -2,71 +2,47 @@ class MockSearchOneway < MockSearch
|
|
2
2
|
|
3
3
|
attr_reader :city_from_1, :city_to_1, :date_from_1, :description, :path
|
4
4
|
|
5
|
-
def initialize(site,env,cabotage
|
5
|
+
def initialize(site,env,cabotage)
|
6
6
|
super(site,env,cabotage)
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
else
|
11
|
-
@city_from_1 = MockCity.new(@site)
|
12
|
-
@city_to_1 = @city_from_1.generate_to_city(@cabotage)
|
13
|
-
end
|
14
|
-
@date_from_1 = Date.today + 120 + rand(15)
|
7
|
+
@city_from_1 = MockCity.new(@site)
|
8
|
+
@city_to_1 = @city_from_1.generate_to_city(@cabotage)
|
9
|
+
@date_from_1 = Date.today + 60 + rand(15)
|
15
10
|
@description = "oneway"
|
16
11
|
@path = "#{@city_from_1.code}/#{@city_to_1.code}/#{@date_from_1}/#{passengers}"
|
17
12
|
end
|
18
13
|
|
19
|
-
|
20
|
-
|
21
|
-
to_city_change(site_country) if site_country
|
22
|
-
return @host + "/shop/flights/results/oneway/" + @path + params
|
14
|
+
def generate_search_url()
|
15
|
+
return @host + "/shop/flights/results/oneway/" + @path
|
23
16
|
end
|
24
17
|
|
25
|
-
|
26
|
-
|
18
|
+
def advanced_bussinnes
|
19
|
+
return "/NA/C/NA/NA"
|
20
|
+
end
|
21
|
+
|
22
|
+
def generate_query_string_search_url()
|
23
|
+
return @host + "/shop/flights/search/oneway/" + @path + "?param1=1"
|
24
|
+
end
|
25
|
+
|
26
|
+
def generate_airports_disambiguation_search_url(city)
|
27
27
|
@path = "#{@city_from_1.code}/#{city}/#{@date_from_1}/#{passengers}"
|
28
|
-
return @host + "/shop/flights/
|
28
|
+
return @host + "/shop/flights/disambiguation/airports/oneway/" + @path
|
29
29
|
end
|
30
|
-
|
31
|
-
|
32
|
-
def generate_url_disambiguation_city()
|
30
|
+
|
31
|
+
def generate_city_disambiguation_search_url()
|
33
32
|
return @host + "/shop/flights/search/oneway/" + @path.gsub(/(\D{3})\/(\D{3})\//,"___/___/") + "?toDescriptions=test1&fromDescriptions=test2"
|
34
33
|
end
|
35
34
|
|
36
|
-
|
37
|
-
def generate_url_anticipated_search()
|
35
|
+
def generate_anticipated_search_url()
|
38
36
|
return @host + "/shop/flights/test/data/search/begin/oneway/" + @path
|
39
37
|
end
|
40
|
-
|
41
|
-
#genero la url del servicio de resultados
|
42
|
-
def generate_url_results_search_service(type="TOTALFARE")
|
43
|
-
return @host + "/shop/flights/data/search/oneway/" + @path + "/#{type}/ASCENDING/NA/NA/NA/NA?hashForData=#{digest_md5()}"
|
44
|
-
end
|
45
38
|
|
46
|
-
|
47
|
-
|
48
|
-
return "#{@host}/shop/flights/data/refine/#{@description.upcase}/#{@city_from_1.code}/#{@city_to_1.code}/#{@cabotage ? 'DOMESTIC' : 'INTERNATIONAL'}/NA/#{hash}/1/PRECLUSTER/FARE/ASCENDING/#{page}/NA/NA/BRL/BRL/NA/NA/NA/NA/NA/NA/NA/NA/NA/NA/NA/NA/NA"
|
49
|
-
end
|
50
|
-
|
51
|
-
#genero la url de resultados de landing a partir de una ciudad de salida y una ciudad de destino
|
52
|
-
def generate_url_landing_search(dep,ret)
|
53
|
-
landing = (@site == "BR" ? "/passagens-aereas" : "/vuelos")
|
54
|
-
return @host + landing + "/#{dep}/#{ret}"
|
39
|
+
def generate_search_url_for_cabotage()
|
40
|
+
return @host + "/shop/flights/results/oneway/" + @path
|
55
41
|
end
|
56
42
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
return @host + landing
|
61
|
-
end
|
62
|
-
|
63
|
-
def get_ticket_date()
|
64
|
-
super()
|
65
|
-
@result_hash['itinerary_hash'] = @itinerary['itinerariesBox']['matchingInfoMap']['_0_-1']['itineraryId']
|
66
|
-
end
|
67
|
-
|
68
|
-
def get_advanced_bussinnes()
|
69
|
-
return "/NA/C/NA/NA"
|
43
|
+
def generate_search_url_for_country(site_country)
|
44
|
+
to_city_change(site_country)
|
45
|
+
return @host + "/shop/flights/results/oneway/" + @path
|
70
46
|
end
|
71
47
|
|
72
48
|
def get_indec_airlines(env)
|
@@ -75,6 +51,7 @@ class MockSearchOneway < MockSearch
|
|
75
51
|
"beta"=>"http://backoffice.despegar.com/",
|
76
52
|
"produccion"=>"http://backoffice.despegar.com/"
|
77
53
|
}
|
54
|
+
puts "#{servers[env.downcase]}indec/airlines/byroute/#{@site}/#{@city_from_1.code}/#{@city_to_1.code}"
|
78
55
|
respond = HTTParty.get("#{servers[env.downcase]}indec/airlines/byroute/#{@site}/#{@city_from_1.code}/#{@city_to_1.code}")
|
79
56
|
return respond
|
80
57
|
end
|
@@ -83,14 +60,4 @@ class MockSearchOneway < MockSearch
|
|
83
60
|
return @city_to_1.name.no_accents
|
84
61
|
end
|
85
62
|
|
86
|
-
|
87
|
-
@date_from_1 = date_from
|
88
|
-
@path = "#{@city_from_1.code}/#{@city_to_1.code}/#{@date_from_1}/#{passengers}"
|
89
|
-
end
|
90
|
-
|
91
|
-
def set_new_date(date_from,date_to)
|
92
|
-
@date_from_1 = date_from
|
93
|
-
@path = "#{@city_from_1.code}/#{@city_to_1.code}/#{@date_from_1}/#{passengers}"
|
94
|
-
end
|
95
|
-
|
96
|
-
end
|
63
|
+
end
|
@@ -2,73 +2,59 @@ class MockSearchRoundtrip < MockSearch
|
|
2
2
|
|
3
3
|
attr_reader :city_from_1, :city_to_1, :date_from_1, :date_to_1, :description, :path
|
4
4
|
|
5
|
-
def initialize(site,env,cabotage
|
5
|
+
def initialize(site,env,cabotage)
|
6
6
|
super(site,env,cabotage)
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
else
|
11
|
-
@city_from_1 = MockCity.new(@site)
|
12
|
-
@city_to_1 = @city_from_1.generate_to_city(@cabotage)
|
13
|
-
end
|
14
|
-
@date_from_1 = Date.today + 120 + rand(15)
|
7
|
+
@city_from_1 = MockCity.new(@site)
|
8
|
+
@city_to_1 = @city_from_1.generate_to_city(@cabotage)
|
9
|
+
@date_from_1 = Date.today + 60 + rand(15)
|
15
10
|
@date_to_1 = @date_from_1 + rand(15)
|
16
11
|
@description = "roundtrip"
|
17
12
|
@path = "#{@city_from_1.code}/#{@city_to_1.code}/#{@date_from_1}/#{@date_to_1}/#{passengers}"
|
18
13
|
end
|
19
14
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
15
|
+
def generate_search_url()
|
16
|
+
return @host + "/shop/flights/results/roundtrip/" + @path
|
17
|
+
end
|
18
|
+
|
19
|
+
def advanced_bussinnes
|
20
|
+
return "/NA/NA/C/NA/NA"
|
21
|
+
end
|
22
|
+
|
23
|
+
def generate_query_string_search_url()
|
24
|
+
return @host + "/shop/flights/search/roundtrip/" + @path + "?param1=1"
|
24
25
|
end
|
25
26
|
|
26
|
-
|
27
|
-
def generate_url_disambiguation_airports(city)
|
27
|
+
def generate_airports_disambiguation_search_url(city)
|
28
28
|
@path = "#{@city_from_1.code}/#{city}/#{@date_from_1}/#{@date_to_1}/#{passengers}"
|
29
|
-
return @host + "/shop/flights/
|
30
|
-
|
29
|
+
return @host + "/shop/flights/disambiguation/airports/roundtrip/" + @path
|
30
|
+
end
|
31
|
+
|
32
|
+
def generate_city_disambiguation_search_url()
|
33
|
+
return @host + "/shop/flights/search/roundtrip/" + @path.gsub(/(\D{3})\/(\D{3})\//,"___/___/") + "?toDescriptions=test1&fromDescriptions=test2"
|
34
|
+
end
|
31
35
|
|
32
|
-
|
33
|
-
|
34
|
-
|
36
|
+
def generate_anticipated_search_url()
|
37
|
+
return @host + "/shop/flights/test/data/search/begin/roundtrip/" + @path
|
38
|
+
end
|
39
|
+
|
40
|
+
def generate_search_url_for_cabotage()
|
41
|
+
return @host + "/shop/flights/results/roundtrip/" + @path
|
35
42
|
end
|
36
43
|
|
37
|
-
|
38
|
-
|
39
|
-
|
44
|
+
def generate_search_url_for_country(site_country)
|
45
|
+
to_city_change(site_country)
|
46
|
+
return @host + "/shop/flights/results/roundtrip/" + @path
|
40
47
|
end
|
41
48
|
|
42
|
-
|
43
|
-
def generate_url_landing_search(dep,ret)
|
49
|
+
def generate_results_landing(dep,ret)
|
44
50
|
landing = (@site == "BR" ? "/passagens-aereas" : "/vuelos")
|
45
51
|
return @host + landing + "/#{dep}/#{ret}"
|
46
52
|
end
|
47
53
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
end
|
53
|
-
|
54
|
-
#genero la url del servicio de resultados
|
55
|
-
def generate_url_results_search_service(type="TOTALFARE")
|
56
|
-
return @host + "/shop/flights/data/search/roundtrip/" + @path + "/#{type}/ASCENDING/NA/NA/NA/NA/NA?hashForData=#{digest_md5()}"
|
57
|
-
end
|
58
|
-
|
59
|
-
#genero la url del paginado
|
60
|
-
def generate_url_results_search_paginate_service(page,hash)
|
61
|
-
return "#{@host}/shop/flights/data/refine/#{@description.upcase}/#{@city_from_1.code}/#{@city_to_1.code}/#{@cabotage ? 'DOMESTIC' : 'INTERNATIONAL'}/NA/#{hash}/1/PRECLUSTER/FARE/ASCENDING/#{page}/NA/NA/BRL/BRL/NA/NA/NA/NA/NA/NA/NA/NA/NA/NA/NA/NA/NA"
|
62
|
-
end
|
63
|
-
|
64
|
-
def get_ticket_date()
|
65
|
-
super()
|
66
|
-
@result_hash['itinerary_hash'] = @itinerary['itinerariesBox']['matchingInfoMap']['_0_0']['itineraryId']
|
67
|
-
end
|
68
|
-
|
69
|
-
def get_advanced_bussinnes()
|
70
|
-
return "/NA/NA/C/NA/NA"
|
71
|
-
end
|
54
|
+
def generate_home_landing()
|
55
|
+
landing = (@site == "BR" ? "/passagens-aereas" : "/vuelos")
|
56
|
+
return @host + landing
|
57
|
+
end
|
72
58
|
|
73
59
|
def get_indec_airlines(env)
|
74
60
|
servers = {
|
@@ -76,29 +62,25 @@ class MockSearchRoundtrip < MockSearch
|
|
76
62
|
"beta"=>"http://backoffice.despegar.com/",
|
77
63
|
"produccion"=>"http://backoffice.despegar.com/"
|
78
64
|
}
|
65
|
+
puts "#{servers[env.downcase]}indec/airlines/byroute/#{@site}/#{@city_from_1.code}/#{@city_to_1.code}"
|
79
66
|
respond = HTTParty.get("#{servers[env.downcase]}indec/airlines/byroute/#{@site}/#{@city_from_1.code}/#{@city_to_1.code}")
|
80
67
|
return respond
|
81
|
-
|
68
|
+
end
|
82
69
|
|
83
|
-
|
84
|
-
|
85
|
-
|
70
|
+
def to_city_description()
|
71
|
+
return @city_to_1.name.no_accents
|
72
|
+
end
|
86
73
|
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
def set_new_date(date_from,date_to)
|
94
|
-
@date_from_1 = date_from
|
95
|
-
@date_to_1 = date_to
|
96
|
-
@path = "#{@city_from_1.code}/#{@city_to_1.code}/#{@date_from_1}/#{@date_to_1}/#{passengers}"
|
97
|
-
end
|
74
|
+
def add_day_to_search()
|
75
|
+
@date_from_1 = @date_from_1 + 1
|
76
|
+
@date_to_1 = @date_to_1 + 1
|
77
|
+
@path = "#{@city_from_1.code}/#{@city_to_1.code}/#{@date_from_1}/#{@date_to_1}/#{passengers}"
|
78
|
+
end
|
98
79
|
|
99
|
-
|
100
|
-
|
101
|
-
|
80
|
+
def set_new_date(date_from,date_to)
|
81
|
+
@date_from_1 = date_from
|
82
|
+
@date_to_1 = date_to
|
83
|
+
@path = "#{@city_from_1.code}/#{@city_to_1.code}/#{@date_from_1}/#{@date_to_1}/#{passengers}"
|
102
84
|
end
|
103
85
|
|
104
|
-
end
|
86
|
+
end
|
data/mock_search.gemspec
CHANGED
@@ -7,7 +7,7 @@
|
|
7
7
|
gem.description = %q{generador de url de busqueda}
|
8
8
|
gem.summary = %q{generador de paginas}
|
9
9
|
|
10
|
-
gem.files = Dir["mock_search.gemspec"] + Dir["Gemfile"] + Dir['lib/*/*.rb']
|
10
|
+
gem.files = Dir["mock_search.gemspec"] + Dir["Gemfile"] + Dir['lib/*/*.rb']
|
11
11
|
#Se pueden descartar archivos que solo son necesarios en desarrollo.
|
12
12
|
#Usualmente esta lista se obtiene de forma programática levantando todos los archivos que esten dentro de lib.
|
13
13
|
|
@@ -15,9 +15,7 @@
|
|
15
15
|
|
16
16
|
gem.require_paths = ["lib"] #Usualmente es solo lib -> ["lib"]
|
17
17
|
|
18
|
-
gem.version = '0.
|
19
|
-
|
20
|
-
gem.add_dependency('httparty')
|
18
|
+
gem.version = '0.4' #La version se debe incrementar cada vez que se desea publicar una nueva version del test.
|
21
19
|
|
22
20
|
gem.add_development_dependency('geminabox')
|
23
21
|
|
metadata
CHANGED
@@ -1,41 +1,27 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mock_search
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: '0.4'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- lgonzalez
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2013-10-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: httparty
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - ">="
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '0'
|
20
|
-
type: :runtime
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - ">="
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '0'
|
27
13
|
- !ruby/object:Gem::Dependency
|
28
14
|
name: geminabox
|
29
15
|
requirement: !ruby/object:Gem::Requirement
|
30
16
|
requirements:
|
31
|
-
- -
|
17
|
+
- - ! '>='
|
32
18
|
- !ruby/object:Gem::Version
|
33
19
|
version: '0'
|
34
20
|
type: :development
|
35
21
|
prerelease: false
|
36
22
|
version_requirements: !ruby/object:Gem::Requirement
|
37
23
|
requirements:
|
38
|
-
- -
|
24
|
+
- - ! '>='
|
39
25
|
- !ruby/object:Gem::Version
|
40
26
|
version: '0'
|
41
27
|
description: generador de url de busqueda
|
@@ -45,13 +31,11 @@ executables: []
|
|
45
31
|
extensions: []
|
46
32
|
extra_rdoc_files: []
|
47
33
|
files:
|
34
|
+
- mock_search.gemspec
|
48
35
|
- Gemfile
|
49
|
-
- lib/mock_city.rb
|
50
|
-
- lib/mock_search.rb
|
51
36
|
- lib/mock_search/mock_search_multipledestinations.rb
|
52
37
|
- lib/mock_search/mock_search_oneway.rb
|
53
38
|
- lib/mock_search/mock_search_roundtrip.rb
|
54
|
-
- mock_search.gemspec
|
55
39
|
homepage:
|
56
40
|
licenses: []
|
57
41
|
metadata: {}
|
@@ -61,17 +45,17 @@ require_paths:
|
|
61
45
|
- lib
|
62
46
|
required_ruby_version: !ruby/object:Gem::Requirement
|
63
47
|
requirements:
|
64
|
-
- -
|
48
|
+
- - ! '>='
|
65
49
|
- !ruby/object:Gem::Version
|
66
50
|
version: '0'
|
67
51
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
68
52
|
requirements:
|
69
|
-
- -
|
53
|
+
- - ! '>='
|
70
54
|
- !ruby/object:Gem::Version
|
71
55
|
version: '0'
|
72
56
|
requirements: []
|
73
57
|
rubyforge_project:
|
74
|
-
rubygems_version: 2.
|
58
|
+
rubygems_version: 2.1.5
|
75
59
|
signing_key:
|
76
60
|
specification_version: 4
|
77
61
|
summary: generador de paginas
|
data/lib/mock_city.rb
DELETED
@@ -1,58 +0,0 @@
|
|
1
|
-
# -*- encoding : utf-8 -*-
|
2
|
-
require 'yaml'
|
3
|
-
class MockCity
|
4
|
-
|
5
|
-
CITIES = YAML.load(File.open("features/data/sites.yml"))
|
6
|
-
|
7
|
-
def initialize(*args)#site,code=nil)
|
8
|
-
@site = args[0]
|
9
|
-
city = args[1] ? self.find_city(args[1]) : CITIES[@site][0]
|
10
|
-
@code = city["code"]
|
11
|
-
@airports = city["airports"]
|
12
|
-
@name = city["name"]
|
13
|
-
end
|
14
|
-
|
15
|
-
def code()
|
16
|
-
@code
|
17
|
-
end
|
18
|
-
|
19
|
-
def airports()
|
20
|
-
@airports
|
21
|
-
end
|
22
|
-
|
23
|
-
def name(site=nil)
|
24
|
-
if site
|
25
|
-
@name.split('|').length==1 ? @name.split('|').first : @name.split('|')[site=="BR" ? 1 : 0]
|
26
|
-
else
|
27
|
-
return @name
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
def add_airport(airport)
|
32
|
-
@airports << airport
|
33
|
-
end
|
34
|
-
|
35
|
-
def find_city(code)
|
36
|
-
city = nil
|
37
|
-
CITIES.each_pair{|key,value| value.each{|_city| city = _city if _city["code"] == code}}
|
38
|
-
return city
|
39
|
-
end
|
40
|
-
|
41
|
-
def generate_to_city(cabotage,black_list=[])
|
42
|
-
arr_tmp = Array.new
|
43
|
-
CITIES.reject{|key,value| key==@site}.values.collect{|cities| cities.each{|city| arr_tmp << city unless black_list.include?(city["code"])}}
|
44
|
-
if CITIES[@site][1] and cabotage
|
45
|
-
to_city = MockCity.new(@site,CITIES[@site][1]["code"])
|
46
|
-
else
|
47
|
-
to_city = MockCity.new(@site,arr_tmp[rand(arr_tmp.length)]["code"])
|
48
|
-
end
|
49
|
-
return to_city
|
50
|
-
end
|
51
|
-
|
52
|
-
def generate_city(black_list=[])
|
53
|
-
arr_tmp = Array.new
|
54
|
-
CITIES.reject{|key,value| key==@site}.values.collect{|cities| cities.each{|city| arr_tmp << city unless black_list.include?(city["code"])}}
|
55
|
-
return MockCity.new(@site,arr_tmp[rand(arr_tmp.length)]["code"])
|
56
|
-
end
|
57
|
-
|
58
|
-
end
|
data/lib/mock_search.rb
DELETED
@@ -1,130 +0,0 @@
|
|
1
|
-
# -*- encoding : utf-8 -*-
|
2
|
-
require 'digest/md5'
|
3
|
-
require 'httparty'
|
4
|
-
|
5
|
-
require_relative 'mock_city'
|
6
|
-
|
7
|
-
class MockSearch
|
8
|
-
|
9
|
-
attr_reader :adt, :cnn, :inf, :host, :cabotage, :itinerary, :json
|
10
|
-
|
11
|
-
def initialize(site,env,cabotage,params={})
|
12
|
-
@site = site
|
13
|
-
@host = generar_host(site,env)
|
14
|
-
@cabotage = (cabotage=='true')
|
15
|
-
@json = nil
|
16
|
-
end
|
17
|
-
|
18
|
-
#genero el host de la url a la cual nos vamos a conectar, se genera a partir del pais y ambiente enviados como parametros.
|
19
|
-
def generar_host(site,env)
|
20
|
-
host = YAML.load(File.open("features/data/host.yml"))
|
21
|
-
return host[site][env]
|
22
|
-
end
|
23
|
-
|
24
|
-
def passengers()
|
25
|
-
@adt = [1,2,3][rand(3)]
|
26
|
-
@cnn = [0,1,2][rand(@adt)]
|
27
|
-
@inf = [0,1,2][rand(@adt-@cnn)]
|
28
|
-
return "#{@adt}/#{@cnn}/#{@inf}"
|
29
|
-
end
|
30
|
-
|
31
|
-
def to_city_change(site)
|
32
|
-
unless site == @site
|
33
|
-
@city_to_1 = MockCity.new(site)
|
34
|
-
@path = @path.gsub(/^...\/...\//,"#{@city_from_1.code}/#{@city_to_1.code}/")
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
def generate_post_alert_url()
|
39
|
-
return @host + "/subscriptions-ui/subscriptions/price-alert-by-month/add"
|
40
|
-
end
|
41
|
-
|
42
|
-
#genero la url de resultados de landing para filtrar por aerolinea
|
43
|
-
def generate_url_landing_airline(code,dest)
|
44
|
-
path = case @site
|
45
|
-
when "BR" then "/passagens-aereas/companhiasaerea"
|
46
|
-
else "/vuelos/aerolinea"
|
47
|
-
end
|
48
|
-
return @host + path + "/#{dest}/#{code}/vuelos"
|
49
|
-
end
|
50
|
-
|
51
|
-
#genero la url de resultados de landing para filtrar por aeropuerto destino
|
52
|
-
def generate_url_landing_arrival_airport(dest)
|
53
|
-
path = case @site
|
54
|
-
when "BR" then "/passagens-aereas/aeroporto"
|
55
|
-
else "/vuelos/aeropuerto"
|
56
|
-
end
|
57
|
-
return @host + path + "/#{dest}/vuelos"
|
58
|
-
end
|
59
|
-
|
60
|
-
#genero la url de resultados de landing para filtrar por aeropuerto origen
|
61
|
-
def generate_url_landing_origin_airport(origin,dest)
|
62
|
-
path = case @site
|
63
|
-
when "BR" then "/passagens-aereas/aeroporto"
|
64
|
-
else "/vuelos/aeropuerto"
|
65
|
-
end
|
66
|
-
return @host + path + "/#{origin}/#{dest}/vuelos"
|
67
|
-
end
|
68
|
-
|
69
|
-
#genero una url para ingresar a desambiguacion de aeropuertos
|
70
|
-
def generate_url_landing_disambiguation_airports(city)
|
71
|
-
@path = "#{@city_from_1.code}/#{city}/"
|
72
|
-
landing = (@site == "BR" ? "/passagens-aereas/" : "/vuelos/")
|
73
|
-
return @host + landing + @path
|
74
|
-
end
|
75
|
-
|
76
|
-
def get_childrens
|
77
|
-
@cnn + @inf
|
78
|
-
end
|
79
|
-
|
80
|
-
def set_from_city(code)
|
81
|
-
@city_from_1 = MockCity.new(@site,code)
|
82
|
-
end
|
83
|
-
|
84
|
-
def set_to_city(code)
|
85
|
-
@city_to_1 = MockCity.new(@site,code)
|
86
|
-
end
|
87
|
-
|
88
|
-
def set_header_json(header={})
|
89
|
-
@header ||= {}
|
90
|
-
@header.merge!(header)
|
91
|
-
end
|
92
|
-
|
93
|
-
def get_results_search_service(type="TOTALFARE")
|
94
|
-
set_header_json({"referer"=>self.generate_url_results_search})
|
95
|
-
unless @json
|
96
|
-
@json = HTTParty.get(self.generate_url_results_search_service(type),:headers => @header)
|
97
|
-
end
|
98
|
-
return @json
|
99
|
-
end
|
100
|
-
|
101
|
-
def get_ticket_date()
|
102
|
-
@result_hash = {}
|
103
|
-
|
104
|
-
json = self.get_results_search_service
|
105
|
-
@itinerary = json['result']['data']['items'][0]
|
106
|
-
ticket = json['result']['data']['metadata']['ticket']
|
107
|
-
|
108
|
-
@result_hash['search_hash'] = ticket['id']
|
109
|
-
@result_hash['search_version'] = ticket['version']
|
110
|
-
end
|
111
|
-
|
112
|
-
def generate_url_checkout()
|
113
|
-
self.get_ticket_date()
|
114
|
-
return @host.gsub('http','https') + "/book/flights/checkout/#{@result_hash['search_hash']}/#{@result_hash['search_version']}/#{@result_hash['itinerary_hash']}/"
|
115
|
-
end
|
116
|
-
|
117
|
-
def digest_md5()
|
118
|
-
return Digest::MD5.hexdigest(self.generate_url_results_search+"despegar")
|
119
|
-
end
|
120
|
-
|
121
|
-
def paginate(page)
|
122
|
-
json = self.get_results_search_service
|
123
|
-
return HTTParty.get(self.generate_url_results_search_paginate_service(page,json['result']['data']['metadata']['ticket']['id']))
|
124
|
-
end
|
125
|
-
|
126
|
-
end
|
127
|
-
|
128
|
-
require_relative 'mock_search/mock_search_oneway'
|
129
|
-
require_relative 'mock_search/mock_search_multipledestinations'
|
130
|
-
require_relative 'mock_search/mock_search_roundtrip'
|