mock_search 0.4 → 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 +8 -8
- data/lib/mock_city.rb +62 -0
- data/lib/mock_search.rb +49 -0
- data/mock_search.gemspec +2 -2
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
Y2VjZDkxZDVjMzk2YzM2YzdkZThiZjgwNTQ0M2Q1YzYxZjc1NGQxYw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZDkxNzE1MGQxZTc0YmI3OWNmYTc1M2M2ZDNjZWRhMmUyMjdlMThmMQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ODEzNTYzZmM5M2FlNWZiYTVhOWYyNWFlYjg1ZWE1Y2M1Njc4YjY5MDgxOGI4
|
10
|
+
YTY0NjU2OTMxMzEwNzkwOTQ3NWE0MWUxNTMxNTVmN2ZjNzg1ZWI5MTViNGEy
|
11
|
+
YzQ5NjBmOWVkNjVlZTdkNzNiYzliMDVlOWY5NTQ5ZTc1MGUxMDM=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
OTg0NWQwYzg0OWNkMjViNTRiNmZmYWRiYzZlNjRiNWJkZmYzY2M3ZjJjYWMz
|
14
|
+
YjU3NjJlMDliYWYwM2RlNTY5YWQ1NmJlMTljYjc5NDY5MjU4ZTFkNWU2OTYx
|
15
|
+
ZTRmZWJiNmM0ZGFhOWI5ZGRjNGMwYTY0YmY1ZTk1MzEwYjMyZWE=
|
data/lib/mock_city.rb
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
class MockCity
|
3
|
+
|
4
|
+
CITIES = { 'CL' => [{:code=>"SCL",:airports=>["SCL"],:name=>"Santiago de Chile|Santiago"},{:code=>"IQQ",:airports=>["IQQ"],:name=>"Iquique"}],
|
5
|
+
'AR' => [{:code=>"BUE",:airports=>["EZE","AEP","BUE"],:name=>"Buenos Aires"},{:code=>"COR",:airports=>["COR"],:name=>"Cordoba"}],
|
6
|
+
'BR' => [{:code=>"SAO",:airports=>["SAO","GRU","CGH","VCP","CPQ"],:name=>"San Pablo|Sao Paulo"},{:code=>"RIO",:airports=>["RIO","SDU","GIG"],:name=>"Rio de Janeiro"},{:code=>"FLN",:airports=>["FLN"],:name=>"Florianopolis"}],
|
7
|
+
'MX' => [{:code=>"MEX",:airports=>["MEX","TLC"],:name=>"Ciudad de Mexico|Cidade do Mexico"},{:code=>"GDL",:airports=>["GDL"],:name=>"Guadalajara"},{:code=>"CUN",:airports=>["CUN"],:name=>"Cancun"}],
|
8
|
+
'PE' => [{:code=>"LIM",:airports=>["LIM"],:name=>"Lima"}],
|
9
|
+
'VE' => [{:code=>"CCS",:airports=>["CCS"],:name=>"Caracas"}],
|
10
|
+
'CO' => [{:code=>"BOG",:airports=>["BOG"],:name=>"Bogota"},{:code=>"MDE",:airports=>["MDE"],:name=>"Medellin"},{:code=>"CLO",:airports=>["CLO"],:name=>"Cali"}],
|
11
|
+
'CR' => [{:code=>"SJO",:airports=>["SJO"],:name=>"San Jose|Sao Jose"}],
|
12
|
+
'PA' => [{:code=>"PTY",:airports=>["PTY"],:name=>"Panama|Cidade do Panama"}],
|
13
|
+
'UY' => [{:code=>"MVD",:airports=>["MVD"],:name=>"Montevideo|Montevideu"}],
|
14
|
+
'EC' => [{:code=>"UIO",:airports=>["UIO"],:name=>"Quito"},{:code=>"GYE",:airports=>["GYE"],:name=>"Guayaquil|Guaiaquil"}],
|
15
|
+
'US' => [{:code=>"MIA",:airports=>["MIA"],:name=>"Miami"},{:code=>"NYC",:airports=>["EWR","JFK","LGA","NYC"],:name=>"Nueva York|Nova York"},{:code=>"WAS",:airports=>["WAS","DCA","BWI","IAD"],:name=>"Washington"}]}
|
16
|
+
|
17
|
+
def initialize(*args)#site,code=nil)
|
18
|
+
@site = args[0]
|
19
|
+
city = args[1] ? self.find_city(args[1]) : CITIES[@site][0]
|
20
|
+
@code = city[:code]
|
21
|
+
@airports = city[:airports]
|
22
|
+
@name = city[:name]
|
23
|
+
end
|
24
|
+
|
25
|
+
def code()
|
26
|
+
@code
|
27
|
+
end
|
28
|
+
|
29
|
+
def airports()
|
30
|
+
@airports
|
31
|
+
end
|
32
|
+
|
33
|
+
def name(site=nil)
|
34
|
+
if site
|
35
|
+
@name.split('|').length==1 ? @name.split('|').first : @name.split('|')[site=="BR" ? 1 : 0]
|
36
|
+
else
|
37
|
+
return @name
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def add_airport(airport)
|
42
|
+
@airports << airport
|
43
|
+
end
|
44
|
+
|
45
|
+
def find_city(code)
|
46
|
+
city = nil
|
47
|
+
CITIES.each_pair{|key,value| value.each{|_city| city = _city if _city[:code] == code}}
|
48
|
+
return city
|
49
|
+
end
|
50
|
+
|
51
|
+
def generate_to_city(cabotage)
|
52
|
+
arr_tmp = Array.new
|
53
|
+
CITIES.reject{|key,value| key==@site}.values.collect{|cities| cities.each{|city| arr_tmp << city}}
|
54
|
+
if CITIES[@site][1] and cabotage
|
55
|
+
to_city = MockCity.new(@site,CITIES[@site][1][:code])
|
56
|
+
else
|
57
|
+
to_city = MockCity.new(@site,arr_tmp[rand(arr_tmp.length)][:code])
|
58
|
+
end
|
59
|
+
return to_city
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
data/lib/mock_search.rb
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
require_relative 'mock_city'
|
3
|
+
|
4
|
+
class MockSearch
|
5
|
+
|
6
|
+
attr_reader :adt, :cnn, :inf, :host, :cabotage
|
7
|
+
|
8
|
+
def initialize(site,env,cabotage)
|
9
|
+
@site = site
|
10
|
+
@host = generar_host(site,env)
|
11
|
+
@cabotage = (cabotage=='true')
|
12
|
+
end
|
13
|
+
|
14
|
+
def generar_host(site,env)
|
15
|
+
host = YAML.load(File.open("features/data/host.yml"))
|
16
|
+
return host[site][env]
|
17
|
+
end
|
18
|
+
|
19
|
+
def passengers()
|
20
|
+
@adt = [1,2,3][rand(3)]
|
21
|
+
@cnn = [0,1,2][rand(@adt)]
|
22
|
+
@inf = [0,1,2][rand(@adt-@cnn)]
|
23
|
+
return "#{@adt}/#{@cnn}/#{@inf}"
|
24
|
+
end
|
25
|
+
|
26
|
+
def to_city_change(site)
|
27
|
+
unless site == @site
|
28
|
+
@to_city = MockCity.new(site)
|
29
|
+
@path = @path.gsub(/^...\/...\//,"#{@from_city.code}/#{@to_city.code}/")
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def generate_post_alert_url()
|
34
|
+
return @host + "/subscriptions-ui/subscriptions/price-alert-by-month/add"
|
35
|
+
end
|
36
|
+
|
37
|
+
def get_childrens
|
38
|
+
@cnn + @inf
|
39
|
+
end
|
40
|
+
|
41
|
+
def set_from_city(code)
|
42
|
+
@city_from_1 = MockCity.new(@site,code)
|
43
|
+
end
|
44
|
+
|
45
|
+
def set_to_city(code)
|
46
|
+
@city_to_1 = MockCity.new(@site,code)
|
47
|
+
end
|
48
|
+
|
49
|
+
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'] + 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,7 +15,7 @@
|
|
15
15
|
|
16
16
|
gem.require_paths = ["lib"] #Usualmente es solo lib -> ["lib"]
|
17
17
|
|
18
|
-
gem.version = '0.
|
18
|
+
gem.version = '0.5' #La version se debe incrementar cada vez que se desea publicar una nueva version del test.
|
19
19
|
|
20
20
|
gem.add_development_dependency('geminabox')
|
21
21
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mock_search
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
4
|
+
version: '0.5'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- lgonzalez
|
@@ -36,6 +36,8 @@ files:
|
|
36
36
|
- lib/mock_search/mock_search_multipledestinations.rb
|
37
37
|
- lib/mock_search/mock_search_oneway.rb
|
38
38
|
- lib/mock_search/mock_search_roundtrip.rb
|
39
|
+
- lib/mock_search.rb
|
40
|
+
- lib/mock_city.rb
|
39
41
|
homepage:
|
40
42
|
licenses: []
|
41
43
|
metadata: {}
|