kandianying 0.0.8 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +0 -6
- data/README.md +12 -3
- data/bin/kandianying +4 -1
- data/lib/kandianying/ambassador.rb +3 -2
- data/lib/kandianying/ambassador_scrape.rb +21 -15
- data/lib/kandianying/version.rb +2 -2
- data/lib/kandianying/vieshow.rb +6 -6
- data/lib/kandianying/vieshow_scrape.rb +20 -10
- data/spec/ambassador_spec.rb +80 -58
- data/spec/fixtures/ambassador_name_38897fa9-094f-4e63-9d6d-c52408438cb6_chinese.yml +6 -0
- data/spec/fixtures/{ambassador_name_38897fa9-094f-4e63-9d6d-c52408438cb6.yml → ambassador_name_38897fa9-094f-4e63-9d6d-c52408438cb6_english.yml} +2 -0
- data/spec/fixtures/ambassador_name_5c2d4697-7f54-4955-800c-7b3ad782582c_chinese.yml +11 -0
- data/spec/fixtures/{ambassador_name_5c2d4697-7f54-4955-800c-7b3ad782582c.yml → ambassador_name_5c2d4697-7f54-4955-800c-7b3ad782582c_english.yml} +2 -0
- data/spec/fixtures/ambassador_table_38897fa9-094f-4e63-9d6d-c52408438cb6_chinese.yml +202 -0
- data/spec/fixtures/ambassador_table_38897fa9-094f-4e63-9d6d-c52408438cb6_english.yml +202 -0
- data/spec/fixtures/ambassador_table_5c2d4697-7f54-4955-800c-7b3ad782582c_chinese.yml +371 -0
- data/spec/fixtures/ambassador_table_5c2d4697-7f54-4955-800c-7b3ad782582c_english.yml +371 -0
- data/spec/fixtures/vcr_cassettes/{ambassador_name_38897fa9-094f-4e63-9d6d-c52408438cb6.yml → ambassador_name_38897fa9-094f-4e63-9d6d-c52408438cb6_chinese.yml} +772 -222
- data/spec/fixtures/vcr_cassettes/{ambassador_table_38897fa9-094f-4e63-9d6d-c52408438cb6.yml → ambassador_name_38897fa9-094f-4e63-9d6d-c52408438cb6_english.yml} +772 -222
- data/spec/fixtures/vcr_cassettes/{ambassador_name_5c2d4697-7f54-4955-800c-7b3ad782582c.yml → ambassador_name_5c2d4697-7f54-4955-800c-7b3ad782582c_chinese.yml} +1112 -832
- data/spec/fixtures/vcr_cassettes/{ambassador_table_5c2d4697-7f54-4955-800c-7b3ad782582c.yml → ambassador_name_5c2d4697-7f54-4955-800c-7b3ad782582c_english.yml} +1112 -832
- data/spec/fixtures/vcr_cassettes/ambassador_table_38897fa9-094f-4e63-9d6d-c52408438cb6_chinese.yml +2568 -0
- data/spec/fixtures/vcr_cassettes/ambassador_table_38897fa9-094f-4e63-9d6d-c52408438cb6_english.yml +2568 -0
- data/spec/fixtures/vcr_cassettes/ambassador_table_5c2d4697-7f54-4955-800c-7b3ad782582c_chinese.yml +2889 -0
- data/spec/fixtures/vcr_cassettes/ambassador_table_5c2d4697-7f54-4955-800c-7b3ad782582c_english.yml +2889 -0
- data/spec/fixtures/vcr_cassettes/vieshow_name_05_chinese.yml +896 -0
- data/spec/fixtures/vcr_cassettes/vieshow_name_05_english.yml +521 -0
- data/spec/fixtures/vcr_cassettes/vieshow_name_12_chinese.yml +626 -0
- data/spec/fixtures/vcr_cassettes/vieshow_name_12_english.yml +370 -0
- data/spec/fixtures/vcr_cassettes/vieshow_table_05_chinese.yml +896 -0
- data/spec/fixtures/vcr_cassettes/vieshow_table_05_english.yml +521 -0
- data/spec/fixtures/vcr_cassettes/vieshow_table_12_chinese.yml +626 -0
- data/spec/fixtures/vcr_cassettes/vieshow_table_12_english.yml +370 -0
- data/spec/fixtures/vieshow_name_05_chinese.yml +26 -0
- data/spec/fixtures/vieshow_name_05_english.yml +26 -0
- data/spec/fixtures/vieshow_name_12_chinese.yml +20 -0
- data/spec/fixtures/{vieshow_name_12.yml → vieshow_name_12_english.yml} +7 -1
- data/spec/fixtures/vieshow_table_05_chinese.yml +881 -0
- data/spec/fixtures/vieshow_table_05_english.yml +881 -0
- data/spec/fixtures/vieshow_table_12_chinese.yml +629 -0
- data/spec/fixtures/vieshow_table_12_english.yml +629 -0
- data/spec/support/vcr_setup.rb +4 -0
- data/spec/vieshow_spec.rb +86 -68
- metadata +67 -35
- data/spec/fixtures/ambassador_table_38897fa9-094f-4e63-9d6d-c52408438cb6.yml +0 -131
- data/spec/fixtures/ambassador_table_5c2d4697-7f54-4955-800c-7b3ad782582c.yml +0 -304
- data/spec/fixtures/vcr_cassettes/vieshow_name_05.yml +0 -298
- data/spec/fixtures/vcr_cassettes/vieshow_name_12.yml +0 -245
- data/spec/fixtures/vcr_cassettes/vieshow_table_05.yml +0 -298
- data/spec/fixtures/vcr_cassettes/vieshow_table_12.yml +0 -245
- data/spec/fixtures/vieshow_name_05.yml +0 -17
- data/spec/fixtures/vieshow_table_05.yml +0 -458
- data/spec/fixtures/vieshow_table_12.yml +0 -356
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3c2b7b9301e9a183bf01b53e8836f917cfaa46b8
|
4
|
+
data.tar.gz: 7626e72430864d00b07770361aa7a314a18be371
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0a1d8102acecabcf895a6e48fd5448d2107accc01ff2d8e6fd3743a0ba1b64597c760beb5195c8cd25ff35bbe12e83437bf922b65b62196093f6852c6b2dcc93
|
7
|
+
data.tar.gz: 2632153993af786b284fb34ddfd87104ecec2ea7aa0f985b1fd04c95cc2c2cef18662da6428aac0d03e6fa4011add45f57f52cc790de242954ff6b1576bed89d
|
data/.travis.yml
CHANGED
@@ -3,12 +3,6 @@ rvm:
|
|
3
3
|
- ruby-head
|
4
4
|
- 2.2.3
|
5
5
|
- 2.1.0
|
6
|
-
- 1.9.3
|
7
|
-
- jruby-head
|
8
|
-
matrix:
|
9
|
-
allow_failures:
|
10
|
-
- rvm: jruby-head
|
11
|
-
- rvm: 1.9.3
|
12
6
|
notifications:
|
13
7
|
slack: soa-2015:kyVe3CqcC9MHxQdS3y4SyD07
|
14
8
|
# uncomment this line if your project needs to run something other than `rake`:
|
data/README.md
CHANGED
@@ -12,11 +12,14 @@ gem install kandianying
|
|
12
12
|
```
|
13
13
|
|
14
14
|
### General usage notes
|
15
|
-
Currently, usage requires specifying a theater_id
|
15
|
+
Currently, usage requires specifying a `theater_id` and `language`.
|
16
|
+
- For Vieshow cinemas, `theater_id` ranges from 1 to 14. For a cinema located in Hsinchu, use 5 or 12.
|
17
|
+
- For Ambassador cinemas, `theater_id codes` are unique. For the Ambassador cinema in Hsinchu, use 38897fa9-094f-4e63-9d6d-c52408438cb6
|
18
|
+
- For `language`, this has to be either 'chinese' or 'english'.
|
16
19
|
|
17
20
|
### Command line usage
|
18
21
|
```
|
19
|
-
kandianying vieshow <theater_id>
|
22
|
+
kandianying vieshow <theater_id> # Development deprecated.
|
20
23
|
# This prints out cinema name with films on display and show times.
|
21
24
|
```
|
22
25
|
|
@@ -24,19 +27,25 @@ kandianying vieshow <theater_id>
|
|
24
27
|
```
|
25
28
|
require 'kandianying'
|
26
29
|
|
27
|
-
vieshow_movie = HsinChuMovie::Vieshow.new(<theater_id>)
|
30
|
+
vieshow_movie = HsinChuMovie::Vieshow.new(<theater_id>, <language>)
|
28
31
|
vieshow_movie.movie_names # Returns array of film names
|
29
32
|
vieshow_movie.movie_table # Returns Hash containing film names, dates, times
|
30
33
|
vieshow_movie.to_json # Returns JSON array of movie_table
|
34
|
+
ambassador_movie = HsinChuMovie::Ambassador.new(<theater_id>, <language>)
|
35
|
+
ambassador_movie.movie_names # Returns array of film names
|
36
|
+
ambassador_movie.movie_table # Returns Hash containing film names, dates, times
|
37
|
+
ambassador_movie.to_json # Returns JSON array of movie_table
|
31
38
|
|
32
39
|
# <film_name> is a string that is any part of the name of film.
|
33
40
|
vieshow_movie.film_times(film_name)
|
41
|
+
ambassador_movie.film_times(film_name)
|
34
42
|
# Returns Hash containing film viewing dates and times.
|
35
43
|
|
36
44
|
# <date_time> is string of the type 'MONTH DATE TIME' such as 'November 5 22:00'.
|
37
45
|
# Abbreviations such as 'Nov 5 22:00' would suffice.
|
38
46
|
# If the date is the same as the query date, you can simply use the time '22:00'
|
39
47
|
vieshow_movie.films_after_time(date_time)
|
48
|
+
ambassador_movie.films_after_time(date_time)
|
40
49
|
# Returns hash containing films on display after given time with start times
|
41
50
|
```
|
42
51
|
|
data/bin/kandianying
CHANGED
@@ -1,4 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# This is deprecated!
|
4
|
+
|
2
5
|
require_relative '../lib/kandianying'
|
3
6
|
VIESHOW_CODES = ('1'..'14').to_a.map { |e| e.length == 1 ? "0#{e}" : e }
|
4
7
|
ID_OUT_OUT_RANGE = 'Please use a cinema code between \'1\' and \'14\' inclusive'
|
@@ -6,7 +9,7 @@ ID_OUT_OUT_RANGE = 'Please use a cinema code between \'1\' and \'14\' inclusive'
|
|
6
9
|
if ARGV[0] == 'vieshow'
|
7
10
|
ARGV[1] = "0#{ARGV[1]}" if ARGV[1].length == 1
|
8
11
|
if VIESHOW_CODES.include? ARGV[1]
|
9
|
-
cinema = HsinChuMovie::Vieshow.new(ARGV[1])
|
12
|
+
cinema = HsinChuMovie::Vieshow.new(ARGV[1], 'english')
|
10
13
|
cinema.movie_table.each do |cinema_name, movies|
|
11
14
|
puts cinema_name
|
12
15
|
movies.each do |movie, date_times|
|
@@ -13,14 +13,15 @@ module Ambassador
|
|
13
13
|
include AmbassadorScrape, Search
|
14
14
|
attr_reader :movie_table, :theater_id_table, :cinema_name
|
15
15
|
|
16
|
-
def initialize(id)
|
16
|
+
def initialize(id, language)
|
17
17
|
@movie_table = {}
|
18
18
|
@theater_id_table = fetch_theater_id_table(AMBASSADOR_THEATER_ID_URL)
|
19
19
|
theater_id_table.each do |theater_id, theater_name|
|
20
20
|
next unless theater_id.include? id
|
21
21
|
date_list = fetch_theater_date(theater_id)
|
22
22
|
@cinema_name = theater_name
|
23
|
-
@movie_table[theater_name] = fetch_movie_info(theater_id, date_list
|
23
|
+
@movie_table[theater_name] = fetch_movie_info(theater_id, date_list,
|
24
|
+
language)
|
24
25
|
end
|
25
26
|
end
|
26
27
|
|
@@ -4,31 +4,37 @@ module AmbassadorScrape
|
|
4
4
|
AMBASSADOR_THEATER_ID_XPATH = "//*[@class='list-group sidebar-nav-v1']//li//a"
|
5
5
|
AMBASSADOR_TIME_API = 'http://cinemaservice.ambassador.com.tw/ambassadorsite.webapi/api/Movies/GetScreeningDateListForTheater/?'
|
6
6
|
AMBASSADOR_FILM_API = 'http://cinemaservice.ambassador.com.tw/ambassadorsite.webapi/api/Movies/GetShowtimeListForTheater/?'
|
7
|
+
PICK_LANGUAGE = { 'chinese' => 'Name', 'english' => 'ForeignName' }
|
8
|
+
PERIOD_SHOW_TIME = 'PeriodShowtime'
|
9
|
+
SHOW_TIMES = 'Showtimes'
|
7
10
|
|
8
|
-
def fetch_movie_info(theater_id, date_list)
|
11
|
+
def fetch_movie_info(theater_id, date_list, language)
|
12
|
+
language = PICK_LANGUAGE[language]
|
9
13
|
movie_info = Hash.new { |hash, key| hash[key] = {} }
|
10
14
|
date_list.map do |date|
|
11
15
|
url = "#{AMBASSADOR_FILM_API}theaterId=#{theater_id}&showingDate=#{date}"
|
12
|
-
|
13
|
-
|
14
|
-
name = movie['ForeignName']
|
15
|
-
time = movie['PeriodShowtime'].first['Showtimes']
|
16
|
+
JSON.parse(open(url).read).map do |movie|
|
17
|
+
name, time = *name_time(movie, language)
|
16
18
|
movie_info[name][date] = time
|
17
|
-
end
|
18
|
-
end # .map(&:execute).map(&:value)
|
19
|
+
end; end # .map(&:execute).map(&:value)
|
19
20
|
movie_info # .sort.to_h
|
20
21
|
end
|
21
22
|
|
22
|
-
def
|
23
|
-
|
24
|
-
|
25
|
-
name = movie['ForeignName']
|
26
|
-
time = movie['PeriodShowtime'].first['Showtimes']
|
27
|
-
movie_info[name][date] = time
|
28
|
-
end
|
29
|
-
end
|
23
|
+
def name_time(movie, language)
|
24
|
+
movie = movie
|
25
|
+
[movie[language], movie[PERIOD_SHOW_TIME].first[SHOW_TIMES]]
|
30
26
|
end
|
31
27
|
|
28
|
+
# def concurrent_retrieve_info(url, date, movie_info)
|
29
|
+
# Concurrent::Future.new do
|
30
|
+
# JSON.parse(Nokogiri::HTML(open(url)).text).map do |movie|
|
31
|
+
# name = movie['ForeignName']
|
32
|
+
# time = movie['PeriodShowtime'].first['Showtimes']
|
33
|
+
# movie_info[name][date] = time
|
34
|
+
# end
|
35
|
+
# end
|
36
|
+
# end
|
37
|
+
|
32
38
|
def fetch_theater_date(theater_id)
|
33
39
|
url = "#{AMBASSADOR_TIME_API}theaterId=#{theater_id}"
|
34
40
|
JSON.parse(Nokogiri::HTML(open(url)).text)
|
data/lib/kandianying/version.rb
CHANGED
data/lib/kandianying/vieshow.rb
CHANGED
@@ -7,20 +7,20 @@ require_relative './search'
|
|
7
7
|
# Scraper for VieShow
|
8
8
|
module VieShow
|
9
9
|
INITIALIZE_ERROR = 'id out of range'
|
10
|
+
LANGUAGE_ERROR = 'language must be one of \'english\' or \'chinese\''
|
10
11
|
|
11
12
|
# Class for Vieshow films
|
12
13
|
class Vieshow
|
13
14
|
include VieshowScrape, Search
|
14
15
|
# initialize movie_table with ID
|
15
|
-
def initialize(vis_cinema_id)
|
16
|
+
def initialize(vis_cinema_id, langauge)
|
16
17
|
vis_cinema_id = vis_cinema_id.to_s
|
17
18
|
vis_cinema_id = "0#{vis_cinema_id}" if vis_cinema_id.length == 1
|
18
19
|
fail INITIALIZE_ERROR unless VIESHOW_CINEMA_CODES.include? vis_cinema_id
|
19
|
-
|
20
|
-
|
21
|
-
@cinema_name = doc
|
22
|
-
|
23
|
-
make_movie_table
|
20
|
+
fail LANGUAGE_ERROR unless PICK_LANGUAGE.keys.include? langauge
|
21
|
+
doc = visit_vieshow(vis_cinema_id, langauge)
|
22
|
+
@table, @cinema_name = initiatilize_table_cinema_name(doc)
|
23
|
+
make_movie_table(langauge)
|
24
24
|
@movie_table = { @cinema_name => @movie_table }
|
25
25
|
end
|
26
26
|
|
@@ -3,7 +3,7 @@ module VieshowScrape
|
|
3
3
|
VIESHOW_URL = 'http://sales.vscinemas.com.tw/ticketing/visPrintShowTimes'\
|
4
4
|
'.aspx?visCinemaID=00'
|
5
5
|
LANGUAGE_PARAM = '&visLang='
|
6
|
-
|
6
|
+
PICK_LANGUAGE = { 'english' => '1', 'chinese' => '2' }
|
7
7
|
VIESHOW_COOKIE_SETTINGS = 'AspxAutoDetectCookieSupport=1'
|
8
8
|
VIESHOW_BASE_XPATH = 'PrintShowTimes'
|
9
9
|
VIESHOW_CLASSES_XPATH = %w(Film Day Session)
|
@@ -17,30 +17,40 @@ module VieshowScrape
|
|
17
17
|
end
|
18
18
|
VIESHOW_CINEMA_NAME_XPATH = "//*[contains(@class, 'PrintCinemaName')]"
|
19
19
|
|
20
|
-
def visit_vieshow(vis_cinema_id)
|
21
|
-
|
22
|
-
|
23
|
-
url = VIESHOW_URL + vis_cinema_id
|
24
|
-
open_doc = open(url, 'Cookie' => VIESHOW_COOKIE_SETTINGS)
|
20
|
+
def visit_vieshow(vis_cinema_id, language)
|
21
|
+
url = VIESHOW_URL + vis_cinema_id + LANGUAGE_PARAM + PICK_LANGUAGE[language]
|
22
|
+
open_doc = open(url, 'Cookie' => VIESHOW_COOKIE_SETTINGS).read
|
25
23
|
Nokogiri::HTML(open_doc)
|
26
24
|
end
|
27
25
|
|
28
26
|
# make movie_table like the structure {"name"=>[[day,time],"name2".....}
|
29
|
-
def make_movie_table
|
27
|
+
def make_movie_table(langauge)
|
28
|
+
@movie_table = Hash.new { |hash, key| hash[key] = [] }
|
30
29
|
current_movie = ''
|
31
30
|
@table.each do |td|
|
32
|
-
current_movie = movie_conditions(td, current_movie)
|
31
|
+
current_movie = movie_conditions(td, current_movie, langauge)
|
33
32
|
end
|
34
33
|
@movie_table.each { |k, v| movie_table[k] = v.to_h }
|
35
34
|
end
|
36
35
|
|
36
|
+
def make_chinese_dates_english(text, langauge)
|
37
|
+
return [text] unless langauge == 'chinese'
|
38
|
+
text = text.split.map { |x| x[/\d+/] }.compact if langauge == 'chinese'
|
39
|
+
[text.join('/')]
|
40
|
+
end
|
41
|
+
|
42
|
+
def initiatilize_table_cinema_name(doc)
|
43
|
+
[doc.xpath(VIESHOW_FULL_XPATH), doc.xpath(VIESHOW_CINEMA_NAME_XPATH).text]
|
44
|
+
end
|
45
|
+
|
37
46
|
# make make_movie_table simple
|
38
|
-
def movie_conditions(td, current_movie)
|
47
|
+
def movie_conditions(td, current_movie, langauge)
|
39
48
|
case td.first[1]
|
40
49
|
when 'PrintShowTimesFilm'
|
41
50
|
current_movie = td.text
|
42
51
|
when 'PrintShowTimesDay'
|
43
|
-
|
52
|
+
date_in_array = make_chinese_dates_english(td.text, langauge)
|
53
|
+
@movie_table[current_movie] << date_in_array
|
44
54
|
when 'PrintShowTimesSession'
|
45
55
|
@movie_table[current_movie][-1] << td.text.split(', ')
|
46
56
|
end
|
data/spec/ambassador_spec.rb
CHANGED
@@ -3,74 +3,96 @@ require './spec/support/vcr_setup'
|
|
3
3
|
AMBASSADOR_TEST_SITES = %w(38897fa9-094f-4e63-9d6d-c52408438cb6
|
4
4
|
5c2d4697-7f54-4955-800c-7b3ad782582c)
|
5
5
|
# FAIL_SITES = %w(0 16)
|
6
|
-
|
6
|
+
AMB_FIXTURES = './spec/fixtures/ambassador_'
|
7
7
|
|
8
8
|
describe 'Get film information' do
|
9
9
|
AMBASSADOR_TEST_SITES.each do |site|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
10
|
+
LANGUAGE.each do |lang|
|
11
|
+
it "must return same list of movies for #{site} for #{lang}" do
|
12
|
+
VCR.use_cassette("ambassador_name_#{site}_#{lang}") do
|
13
|
+
cinema = HsinChuMovie::Ambassador.new(site, lang)
|
14
|
+
site_names = yml_load("#{AMB_FIXTURES}name_#{site}_#{lang}.yml")
|
15
|
+
site_names.must_equal cinema.movie_names
|
16
|
+
end
|
15
17
|
end
|
16
|
-
end
|
17
18
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
end
|
19
|
+
it "must return same table for #{site} for #{lang}" do
|
20
|
+
VCR.use_cassette("ambassador_table_#{site}_#{lang}") do
|
21
|
+
cinema = HsinChuMovie::Ambassador.new(site, lang)
|
22
|
+
site_table = yml_load("#{AMB_FIXTURES}table_#{site}_#{lang}.yml")
|
23
|
+
site_table.must_equal cinema.movie_table
|
24
|
+
end; end; end
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
|
-
describe 'Get
|
28
|
+
describe 'Get show times for a film' do
|
29
29
|
AMBASSADOR_TEST_SITES.each do |site|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
#
|
45
|
-
show_times.each do |show_time|
|
46
|
-
show_time.must_be :<, comparison_time
|
47
|
-
end
|
48
|
-
else
|
49
|
-
after_show_times = after_films[film][date]
|
50
|
-
after_show_times.each do |ast|
|
51
|
-
# On day show times must include after request show times
|
52
|
-
show_times.must_include ast
|
53
|
-
# After show times must be greater than comparison time
|
54
|
-
if (ast < comparison_time) &&
|
55
|
-
(MIDNIGHT.include? ast[HOUR_PART])
|
56
|
-
# Movies airing from midnight onwards are group with past day
|
57
|
-
ast[HOUR_PART] = "#{ast[HOUR_PART].to_i + ADD_24}"
|
58
|
-
end
|
59
|
-
ast.must_be :>=, comparison_time
|
60
|
-
end
|
61
|
-
show_times -= after_films[film][date]
|
62
|
-
# Any show time not returned must be less than comparison time
|
63
|
-
show_times.each do |show_time|
|
64
|
-
show_time.must_be :<, comparison_time
|
65
|
-
end
|
30
|
+
LANGUAGE.each do |lang|
|
31
|
+
it "should get viewing times for this film in #{lang}" do
|
32
|
+
VCR.use_cassette("ambassador_table_#{site}_#{lang}") do
|
33
|
+
cinema = HsinChuMovie::Ambassador.new(site, lang)
|
34
|
+
one_movie = yml_load("#{AMB_FIXTURES}name_#{site}_#{lang}.yml").sample
|
35
|
+
# Films are saved as UPPERCASE but search should pass any case
|
36
|
+
cinema.film_times(one_movie.downcase).each do |film, date_times|
|
37
|
+
film.must_include one_movie
|
38
|
+
date_times.keys.each do |date|
|
39
|
+
nums_in_date = date.split('/')
|
40
|
+
MONTH_NUM.must_include nums_in_date[1]
|
41
|
+
DATE_NUM.must_include nums_in_date.last
|
42
|
+
# words_in_date = date.split
|
43
|
+
# MONTHS.must_include words_in_date.first
|
44
|
+
# DAYS.must_include words_in_date.last
|
66
45
|
end; end; end; end; end
|
67
46
|
end
|
47
|
+
AMBASSADOR_TEST_SITES.each do |site|
|
48
|
+
LANGUAGE.each do |lang|
|
49
|
+
it 'should return empty array for random string' do
|
50
|
+
VCR.use_cassette("ambassador_table_#{site}_#{lang}") do
|
51
|
+
cinema = HsinChuMovie::Ambassador.new(site, lang)
|
52
|
+
cinema.film_times(RANDOM_STRING).must_be_empty
|
53
|
+
end; end; end
|
54
|
+
end
|
68
55
|
end
|
69
56
|
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
#
|
74
|
-
#
|
75
|
-
|
76
|
-
|
57
|
+
describe 'Get films after a given time on given day' do
|
58
|
+
AMBASSADOR_TEST_SITES.each do |site|
|
59
|
+
LANGUAGE.each do |lang|
|
60
|
+
it "should only return films after a time for #{site} for #{lang}" do
|
61
|
+
VCR.use_cassette("ambassador_table_#{site}_#{lang}") do
|
62
|
+
cinema = HsinChuMovie::Ambassador.new(site, lang)
|
63
|
+
time = DateTime.now.new_offset(TAIWAN_TIME)
|
64
|
+
time += GIVEN_DAY.sample
|
65
|
+
time_s = time.to_s
|
66
|
+
time_s[SEC_PART] = ZERO_SEC
|
67
|
+
day_films = cinema.films_on_day(time_s)
|
68
|
+
after_films = cinema.films_after_time(time_s)
|
69
|
+
# comparison_time is an hour earlier than specified time
|
70
|
+
comparison_time = (time - AN_HOUR).to_s[HOUR_MIN]
|
71
|
+
day_films.each do |film, date_times|
|
72
|
+
date_times.each do |date, show_times|
|
73
|
+
if after_films[film].nil?
|
74
|
+
# If empty, all show times must be less than comparison time
|
75
|
+
show_times.each do |show_time|
|
76
|
+
show_time.must_be :<, comparison_time
|
77
|
+
end
|
78
|
+
else
|
79
|
+
after_show_times = after_films[film][date]
|
80
|
+
after_show_times.each do |ast|
|
81
|
+
# On day show times must include after request show times
|
82
|
+
show_times.must_include ast
|
83
|
+
# After show times must be greater than comparison time
|
84
|
+
if (ast < comparison_time) &&
|
85
|
+
(MIDNIGHT.include? ast[HOUR_PART])
|
86
|
+
# Movies airing from midnight onwards are grouped w/past day
|
87
|
+
ast[HOUR_PART] = "#{ast[HOUR_PART].to_i + ADD_24}"
|
88
|
+
end
|
89
|
+
ast.must_be :>=, comparison_time
|
90
|
+
end
|
91
|
+
show_times -= after_films[film][date]
|
92
|
+
# Any show time not returned must be less than comparison time
|
93
|
+
show_times.each do |show_time|
|
94
|
+
show_time.must_be :<, comparison_time
|
95
|
+
end
|
96
|
+
end; end; end; end; end; end
|
97
|
+
end
|
98
|
+
end
|
@@ -0,0 +1,202 @@
|
|
1
|
+
---
|
2
|
+
國賓影城@新竹環球世博店:
|
3
|
+
殭屍教戰守則:
|
4
|
+
2015/11/19:
|
5
|
+
- '12:00'
|
6
|
+
- '13:50'
|
7
|
+
- '15:40'
|
8
|
+
- '17:30'
|
9
|
+
- '19:20'
|
10
|
+
- '21:10'
|
11
|
+
2015/11/20:
|
12
|
+
- '11:40'
|
13
|
+
- '13:30'
|
14
|
+
- '17:20'
|
15
|
+
- '21:30'
|
16
|
+
2015/11/21:
|
17
|
+
- '10:20'
|
18
|
+
- '12:50'
|
19
|
+
- '16:40'
|
20
|
+
- '20:30'
|
21
|
+
2015/11/22:
|
22
|
+
- '10:20'
|
23
|
+
- '12:50'
|
24
|
+
- '16:40'
|
25
|
+
- '20:30'
|
26
|
+
2015/11/23:
|
27
|
+
- '11:40'
|
28
|
+
- '14:10'
|
29
|
+
- '16:00'
|
30
|
+
- '17:50'
|
31
|
+
- '19:40'
|
32
|
+
- '21:30'
|
33
|
+
2015/11/24:
|
34
|
+
- '11:40'
|
35
|
+
- '14:10'
|
36
|
+
- '16:00'
|
37
|
+
- '17:50'
|
38
|
+
- '19:40'
|
39
|
+
- '21:30'
|
40
|
+
2015/11/25:
|
41
|
+
- '11:40'
|
42
|
+
- '14:10'
|
43
|
+
- '16:00'
|
44
|
+
- '17:50'
|
45
|
+
- '19:40'
|
46
|
+
- '21:30'
|
47
|
+
2015/11/26:
|
48
|
+
- '11:40'
|
49
|
+
- '14:10'
|
50
|
+
- '16:00'
|
51
|
+
- '17:50'
|
52
|
+
- '19:40'
|
53
|
+
- '21:30'
|
54
|
+
007惡魔四伏:
|
55
|
+
2015/11/19:
|
56
|
+
- '11:30'
|
57
|
+
- '12:30'
|
58
|
+
- '14:10'
|
59
|
+
- '15:10'
|
60
|
+
- '16:20'
|
61
|
+
- '17:50'
|
62
|
+
- '18:50'
|
63
|
+
- '20:30'
|
64
|
+
- '21:30'
|
65
|
+
2015/11/20:
|
66
|
+
- '12:20'
|
67
|
+
- '13:30'
|
68
|
+
- '15:00'
|
69
|
+
- '16:10'
|
70
|
+
- '17:40'
|
71
|
+
- '18:50'
|
72
|
+
- '20:20'
|
73
|
+
- '21:10'
|
74
|
+
2015/11/21:
|
75
|
+
- '10:20'
|
76
|
+
- '12:10'
|
77
|
+
- '14:50'
|
78
|
+
- '16:10'
|
79
|
+
- '17:30'
|
80
|
+
- '18:50'
|
81
|
+
- '20:10'
|
82
|
+
- '21:30'
|
83
|
+
2015/11/22:
|
84
|
+
- '10:40'
|
85
|
+
- '12:10'
|
86
|
+
- '13:20'
|
87
|
+
- '14:50'
|
88
|
+
- '16:00'
|
89
|
+
- '17:30'
|
90
|
+
- '18:40'
|
91
|
+
- '20:10'
|
92
|
+
- '21:20'
|
93
|
+
2015/11/23:
|
94
|
+
- '11:30'
|
95
|
+
- '12:20'
|
96
|
+
- '13:30'
|
97
|
+
- '15:00'
|
98
|
+
- '16:10'
|
99
|
+
- '17:40'
|
100
|
+
- '18:50'
|
101
|
+
- '20:20'
|
102
|
+
- '21:30'
|
103
|
+
2015/11/24:
|
104
|
+
- '11:30'
|
105
|
+
- '12:20'
|
106
|
+
- '13:30'
|
107
|
+
- '15:00'
|
108
|
+
- '16:10'
|
109
|
+
- '17:40'
|
110
|
+
- '18:50'
|
111
|
+
- '20:20'
|
112
|
+
- '21:30'
|
113
|
+
2015/11/25:
|
114
|
+
- '11:30'
|
115
|
+
- '12:20'
|
116
|
+
- '13:30'
|
117
|
+
- '15:00'
|
118
|
+
- '16:10'
|
119
|
+
- '17:40'
|
120
|
+
- '18:50'
|
121
|
+
- '20:20'
|
122
|
+
- '21:30'
|
123
|
+
2015/11/26:
|
124
|
+
- '11:30'
|
125
|
+
- '12:20'
|
126
|
+
- '13:30'
|
127
|
+
- '15:00'
|
128
|
+
- '16:10'
|
129
|
+
- '17:40'
|
130
|
+
- '18:50'
|
131
|
+
- '20:20'
|
132
|
+
- '21:30'
|
133
|
+
小王子:
|
134
|
+
2015/11/19:
|
135
|
+
- '12:20'
|
136
|
+
- '16:50'
|
137
|
+
2015/11/20:
|
138
|
+
- '11:30'
|
139
|
+
- '13:30'
|
140
|
+
- '17:30'
|
141
|
+
2015/11/21:
|
142
|
+
- '11:00'
|
143
|
+
- '13:00'
|
144
|
+
- '17:00'
|
145
|
+
2015/11/22:
|
146
|
+
- '11:00'
|
147
|
+
- '13:00'
|
148
|
+
- '17:00'
|
149
|
+
2015/11/23:
|
150
|
+
- '11:30'
|
151
|
+
- '13:30'
|
152
|
+
- '17:30'
|
153
|
+
2015/11/24:
|
154
|
+
- '11:30'
|
155
|
+
- '13:30'
|
156
|
+
- '17:30'
|
157
|
+
2015/11/25:
|
158
|
+
- '11:30'
|
159
|
+
- '13:30'
|
160
|
+
- '17:30'
|
161
|
+
2015/11/26:
|
162
|
+
- '11:30'
|
163
|
+
- '13:30'
|
164
|
+
- '17:30'
|
165
|
+
危機女王[口碑場]:
|
166
|
+
2015/11/20:
|
167
|
+
- '11:30'
|
168
|
+
- '15:20'
|
169
|
+
- '19:10'
|
170
|
+
2015/11/21:
|
171
|
+
- '10:50'
|
172
|
+
- '14:40'
|
173
|
+
- '18:30'
|
174
|
+
2015/11/22:
|
175
|
+
- '10:50'
|
176
|
+
- '14:40'
|
177
|
+
- '18:30'
|
178
|
+
STAR WARS:原力覺醒:
|
179
|
+
2015/12/17:
|
180
|
+
- '11:30'
|
181
|
+
- '14:00'
|
182
|
+
- '16:30'
|
183
|
+
- '19:00'
|
184
|
+
- '21:30'
|
185
|
+
2015/12/18:
|
186
|
+
- '11:30'
|
187
|
+
- '14:00'
|
188
|
+
- '16:30'
|
189
|
+
- '19:00'
|
190
|
+
- '21:30'
|
191
|
+
2015/12/19:
|
192
|
+
- '10:20'
|
193
|
+
- '12:50'
|
194
|
+
- '15:20'
|
195
|
+
- '17:50'
|
196
|
+
- '20:20'
|
197
|
+
2015/12/20:
|
198
|
+
- '10:20'
|
199
|
+
- '12:50'
|
200
|
+
- '15:20'
|
201
|
+
- '17:50'
|
202
|
+
- '20:20'
|