fandango 1.0.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +0 -1
- data/.irbrc +2 -3
- data/.ruby-version +1 -0
- data/.travis.yml +2 -2
- data/Gemfile +2 -0
- data/Gemfile.lock +37 -0
- data/README.md +45 -22
- data/Rakefile +2 -2
- data/fandango.gemspec +3 -3
- data/lib/fandango.rb +13 -35
- data/lib/fandango/api.rb +14 -0
- data/lib/fandango/api/movies_near.rb +36 -0
- data/lib/fandango/api/theater_showtimes.rb +47 -0
- data/lib/fandango/movie.rb +34 -18
- data/lib/fandango/showtime.rb +18 -0
- data/lib/fandango/theater.rb +44 -35
- data/lib/fandango/version.rb +1 -1
- data/spec/api/movies_near.spec.rb +30 -0
- data/spec/api/theater_showtimes.spec.rb +36 -0
- data/spec/movie.spec.rb +17 -18
- data/spec/showtime.spec.rb +21 -0
- data/spec/spec_helper.rb +5 -10
- data/spec/support/fixture_helpers.rb +14 -0
- data/spec/support/fixtures/movies_near_me_73142.rss +185 -1
- data/spec/support/fixtures/{movies_near_me_73142.yaml → movies_near_me_73142.yml} +70 -70
- data/spec/support/fixtures/showtimes_amcquailspringsmall24_aaktw_2016_08_01.html +7264 -0
- data/spec/support/fixtures/theater_showtimes_amcquailspringsmall24.yml +203 -0
- data/spec/support/fixtures/theater_showtimes_amcquailspringsmall24_tomorrow.yml +190 -0
- data/spec/support/minitest.rb +9 -0
- data/spec/support/vcr.rb +6 -0
- data/spec/support/vcr_cassettes/theater_showtimes_amcquailspringsmall24.yml +10974 -0
- data/spec/support/vcr_cassettes/theater_showtimes_amcquailspringsmall24_tomorrow.yml +10759 -0
- data/spec/theater.spec.rb +58 -12
- metadata +79 -48
- data/.rvmrc +0 -1
- data/lib/fandango/parser.rb +0 -39
- data/spec/fandango.spec.rb +0 -41
- data/spec/parser.spec.rb +0 -12
- data/spec/support/fixtures/item.html +0 -1
- data/spec/support/helpers.rb +0 -25
data/spec/theater.spec.rb
CHANGED
@@ -1,16 +1,62 @@
|
|
1
|
-
|
1
|
+
require_relative 'spec_helper'
|
2
|
+
require 'support/fixture_helpers'
|
2
3
|
|
3
|
-
|
4
|
+
module Fandango
|
5
|
+
describe Theater do
|
4
6
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
address: '2501 West Memorial Oklahoma City, OK 73134',
|
12
|
-
postal_code: '73134',
|
13
|
-
})
|
14
|
-
end
|
7
|
+
include FixtureHelpers
|
8
|
+
|
9
|
+
specify '.parse parses RSS item into Theater' do
|
10
|
+
xml = fixture_file_content('movies_near_me_73142.rss')
|
11
|
+
item_node = Nokogiri.XML(xml).at_css('item')
|
12
|
+
theater = Theater.parse(item_node)
|
15
13
|
|
14
|
+
theater.must_equal(
|
15
|
+
name: 'AMC Quail Springs Mall 24',
|
16
|
+
id: 'aaktw',
|
17
|
+
address: '2501 West Memorial Oklahoma City, OK 73134',
|
18
|
+
postal_code: '73134',
|
19
|
+
showtimes_link: 'http://www.fandango.com/amcquailspringsmall24_aaktw/theaterpage?wssaffid=11836&wssac=123',
|
20
|
+
movies: [
|
21
|
+
{:title=>"Abraham Lincoln: Vampire Hunter", :id=>"141897"},
|
22
|
+
{:title=>"The Amazing Spider-Man 3D", :id=>"141122"},
|
23
|
+
{:title=>"The Amazing Spider-Man", :id=>"126975"},
|
24
|
+
{:title=>"The Amazing Spider-Man: An IMAX 3D Experience", :id=>"153829"},
|
25
|
+
{:title=>"Battleship", :id=>"130096"},
|
26
|
+
{:title=>"The Best Exotic Marigold Hotel", :id=>"147777"},
|
27
|
+
{:title=>"Brave", :id=>"136016"},
|
28
|
+
{:title=>"Bully", :id=>"145958"},
|
29
|
+
{:title=>"Chernobyl Diaries", :id=>"152960"},
|
30
|
+
{:title=>"Chimpanzee", :id=>"116882"},
|
31
|
+
{:title=>"Dark Shadows", :id=>"147176"},
|
32
|
+
{:title=>"The Dictator", :id=>"145763"},
|
33
|
+
{:title=>"Happiest Baby and Happiest Toddler Live With Dr. Karp", :id=>"154921"},
|
34
|
+
{:title=>"The Hunger Games", :id=>"136944"},
|
35
|
+
{:title=>"The Lucky One", :id=>"145457"},
|
36
|
+
{:title=>"Madagascar 3: Europe's Most Wanted 3D", :id=>"151457"},
|
37
|
+
{:title=>"Marvel's The Avengers", :id=>"30154"},
|
38
|
+
{:title=>"Marvel's The Avengers 3D", :id=>"151545"},
|
39
|
+
{:title=>"Men in Black III", :id=>"135737"},
|
40
|
+
{:title=>"Men in Black III 3D", :id=>"147264"},
|
41
|
+
{:title=>"Men in Black III: An IMAX 3D Experience", :id=>"148659"},
|
42
|
+
{:title=>"National Theater Live: Frankenstein (Original Casting)", :id=>"137637"},
|
43
|
+
{:title=>"National Theater Live: Frankenstein (Reverse Casting)", :id=>"142883"},
|
44
|
+
{:title=>"The Pirates! Band of Misfits", :id=>"146664"},
|
45
|
+
{:title=>"Prometheus 3D", :id=>"152981"},
|
46
|
+
{:title=>"Prometheus: An IMAX 3D Experience", :id=>"153676"},
|
47
|
+
{:title=>"Ratatouille", :id=>"98260"},
|
48
|
+
{:title=>"Snow White and the Huntsman", :id=>"141533"},
|
49
|
+
{:title=>"Ted", :id=>"136691"},
|
50
|
+
{:title=>"The Tempest Starring Christopher Plummer", :id=>"155187"},
|
51
|
+
{:title=>"That's My Boy", :id=>"149081"},
|
52
|
+
{:title=>"Think Like a Man", :id=>"147732"},
|
53
|
+
{:title=>"Toy Story 3", :id=>"124782"},
|
54
|
+
{:title=>"Up", :id=>"114055"},
|
55
|
+
{:title=>"WALL-E", :id=>"102903"},
|
56
|
+
{:title=>"What to Expect When You're Expecting", :id=>"120322"},
|
57
|
+
],
|
58
|
+
)
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
16
62
|
end
|
metadata
CHANGED
@@ -1,71 +1,85 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fandango
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
5
|
-
prerelease:
|
4
|
+
version: 2.0.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Jared Ning
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2017-01-05 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: nokogiri
|
16
|
-
requirement:
|
17
|
-
none: false
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
18
16
|
requirements:
|
19
|
-
- - ~>
|
17
|
+
- - "~>"
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: '1.0'
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
|
-
version_requirements:
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.0'
|
25
27
|
- !ruby/object:Gem::Dependency
|
26
28
|
name: awesome_print
|
27
|
-
requirement:
|
28
|
-
none: false
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
29
30
|
requirements:
|
30
|
-
- -
|
31
|
+
- - ">="
|
31
32
|
- !ruby/object:Gem::Version
|
32
33
|
version: '0'
|
33
34
|
type: :development
|
34
35
|
prerelease: false
|
35
|
-
version_requirements:
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
36
41
|
- !ruby/object:Gem::Dependency
|
37
|
-
name:
|
38
|
-
requirement:
|
39
|
-
none: false
|
42
|
+
name: webmock
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
40
44
|
requirements:
|
41
|
-
- -
|
45
|
+
- - ">="
|
42
46
|
- !ruby/object:Gem::Version
|
43
|
-
version:
|
47
|
+
version: '0'
|
44
48
|
type: :development
|
45
49
|
prerelease: false
|
46
|
-
version_requirements:
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
47
55
|
- !ruby/object:Gem::Dependency
|
48
56
|
name: minitest
|
49
|
-
requirement:
|
50
|
-
none: false
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
51
58
|
requirements:
|
52
|
-
- -
|
59
|
+
- - ">="
|
53
60
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
61
|
+
version: '0'
|
55
62
|
type: :development
|
56
63
|
prerelease: false
|
57
|
-
version_requirements:
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
58
69
|
- !ruby/object:Gem::Dependency
|
59
70
|
name: vcr
|
60
|
-
requirement:
|
61
|
-
none: false
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
62
72
|
requirements:
|
63
|
-
- -
|
73
|
+
- - ">="
|
64
74
|
- !ruby/object:Gem::Version
|
65
|
-
version:
|
75
|
+
version: '0'
|
66
76
|
type: :development
|
67
77
|
prerelease: false
|
68
|
-
version_requirements:
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
69
83
|
description: Find theaters and movies on sale near a given postal code
|
70
84
|
email:
|
71
85
|
- jared@redningja.com
|
@@ -73,63 +87,80 @@ executables: []
|
|
73
87
|
extensions: []
|
74
88
|
extra_rdoc_files: []
|
75
89
|
files:
|
76
|
-
- .gitignore
|
77
|
-
- .irbrc
|
78
|
-
- .
|
79
|
-
- .travis.yml
|
90
|
+
- ".gitignore"
|
91
|
+
- ".irbrc"
|
92
|
+
- ".ruby-version"
|
93
|
+
- ".travis.yml"
|
80
94
|
- Gemfile
|
95
|
+
- Gemfile.lock
|
81
96
|
- README.md
|
82
97
|
- Rakefile
|
83
98
|
- fandango.gemspec
|
84
99
|
- lib/fandango.rb
|
100
|
+
- lib/fandango/api.rb
|
101
|
+
- lib/fandango/api/movies_near.rb
|
102
|
+
- lib/fandango/api/theater_showtimes.rb
|
85
103
|
- lib/fandango/movie.rb
|
86
|
-
- lib/fandango/
|
104
|
+
- lib/fandango/showtime.rb
|
87
105
|
- lib/fandango/theater.rb
|
88
106
|
- lib/fandango/version.rb
|
89
|
-
- spec/
|
107
|
+
- spec/api/movies_near.spec.rb
|
108
|
+
- spec/api/theater_showtimes.spec.rb
|
90
109
|
- spec/movie.spec.rb
|
91
|
-
- spec/
|
110
|
+
- spec/showtime.spec.rb
|
92
111
|
- spec/spec_helper.rb
|
93
|
-
- spec/support/
|
112
|
+
- spec/support/fixture_helpers.rb
|
94
113
|
- spec/support/fixtures/movies_near_me_73142.rss
|
95
|
-
- spec/support/fixtures/movies_near_me_73142.
|
96
|
-
- spec/support/
|
114
|
+
- spec/support/fixtures/movies_near_me_73142.yml
|
115
|
+
- spec/support/fixtures/showtimes_amcquailspringsmall24_aaktw_2016_08_01.html
|
116
|
+
- spec/support/fixtures/theater_showtimes_amcquailspringsmall24.yml
|
117
|
+
- spec/support/fixtures/theater_showtimes_amcquailspringsmall24_tomorrow.yml
|
118
|
+
- spec/support/minitest.rb
|
119
|
+
- spec/support/vcr.rb
|
97
120
|
- spec/support/vcr_cassettes/movies_near_me_123BADZIP.yml
|
98
121
|
- spec/support/vcr_cassettes/movies_near_me_73142.yml
|
122
|
+
- spec/support/vcr_cassettes/theater_showtimes_amcquailspringsmall24.yml
|
123
|
+
- spec/support/vcr_cassettes/theater_showtimes_amcquailspringsmall24_tomorrow.yml
|
99
124
|
- spec/theater.spec.rb
|
100
125
|
homepage: https://github.com/ordinaryzelig/fandango
|
101
126
|
licenses: []
|
127
|
+
metadata: {}
|
102
128
|
post_install_message:
|
103
129
|
rdoc_options: []
|
104
130
|
require_paths:
|
105
131
|
- lib
|
106
132
|
required_ruby_version: !ruby/object:Gem::Requirement
|
107
|
-
none: false
|
108
133
|
requirements:
|
109
|
-
- -
|
134
|
+
- - ">="
|
110
135
|
- !ruby/object:Gem::Version
|
111
136
|
version: '0'
|
112
137
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
113
|
-
none: false
|
114
138
|
requirements:
|
115
|
-
- -
|
139
|
+
- - ">="
|
116
140
|
- !ruby/object:Gem::Version
|
117
141
|
version: '0'
|
118
142
|
requirements: []
|
119
143
|
rubyforge_project: fandango
|
120
|
-
rubygems_version:
|
144
|
+
rubygems_version: 2.5.1
|
121
145
|
signing_key:
|
122
|
-
specification_version:
|
146
|
+
specification_version: 4
|
123
147
|
summary: Fandango API
|
124
148
|
test_files:
|
125
|
-
- spec/
|
149
|
+
- spec/api/movies_near.spec.rb
|
150
|
+
- spec/api/theater_showtimes.spec.rb
|
126
151
|
- spec/movie.spec.rb
|
127
|
-
- spec/
|
152
|
+
- spec/showtime.spec.rb
|
128
153
|
- spec/spec_helper.rb
|
129
|
-
- spec/support/
|
154
|
+
- spec/support/fixture_helpers.rb
|
130
155
|
- spec/support/fixtures/movies_near_me_73142.rss
|
131
|
-
- spec/support/fixtures/movies_near_me_73142.
|
132
|
-
- spec/support/
|
156
|
+
- spec/support/fixtures/movies_near_me_73142.yml
|
157
|
+
- spec/support/fixtures/showtimes_amcquailspringsmall24_aaktw_2016_08_01.html
|
158
|
+
- spec/support/fixtures/theater_showtimes_amcquailspringsmall24.yml
|
159
|
+
- spec/support/fixtures/theater_showtimes_amcquailspringsmall24_tomorrow.yml
|
160
|
+
- spec/support/minitest.rb
|
161
|
+
- spec/support/vcr.rb
|
133
162
|
- spec/support/vcr_cassettes/movies_near_me_123BADZIP.yml
|
134
163
|
- spec/support/vcr_cassettes/movies_near_me_73142.yml
|
164
|
+
- spec/support/vcr_cassettes/theater_showtimes_amcquailspringsmall24.yml
|
165
|
+
- spec/support/vcr_cassettes/theater_showtimes_amcquailspringsmall24_tomorrow.yml
|
135
166
|
- spec/theater.spec.rb
|
data/.rvmrc
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
rvm use ruby-1.9.2-p290@fandango
|
data/lib/fandango/parser.rb
DELETED
@@ -1,39 +0,0 @@
|
|
1
|
-
require 'fandango/movie'
|
2
|
-
require 'fandango/theater'
|
3
|
-
|
4
|
-
module Fandango
|
5
|
-
class Parser
|
6
|
-
|
7
|
-
class << self
|
8
|
-
|
9
|
-
def parse(source)
|
10
|
-
parser = new(source)
|
11
|
-
parser.parse
|
12
|
-
end
|
13
|
-
|
14
|
-
# Description content is wrapped in CDATA.
|
15
|
-
# Parse it and return a parsed Nokogiri node.
|
16
|
-
def parse_description(item_node)
|
17
|
-
cdata = item_node.at_css('description')
|
18
|
-
Nokogiri::HTML(cdata.content)
|
19
|
-
end
|
20
|
-
|
21
|
-
end
|
22
|
-
|
23
|
-
def initialize(source)
|
24
|
-
@source = source
|
25
|
-
end
|
26
|
-
|
27
|
-
def parse
|
28
|
-
@doc = Nokogiri.XML(@source)
|
29
|
-
@doc.css('item').map do |item_node|
|
30
|
-
hash = {}
|
31
|
-
description_node = self.class.parse_description(item_node)
|
32
|
-
hash[:theater] = Theater.parse(item_node, description_node)
|
33
|
-
hash[:movies] = Movie.parse(description_node)
|
34
|
-
hash
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
end
|
39
|
-
end
|
data/spec/fandango.spec.rb
DELETED
@@ -1,41 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Fandango do
|
4
|
-
|
5
|
-
describe '.movies_near' do
|
6
|
-
|
7
|
-
it 'returns hash of theaters and movies playing at each' do
|
8
|
-
VCR.use_cassette 'movies_near_me_73142' do
|
9
|
-
array = Fandango.movies_near(73142)
|
10
|
-
fixture_yaml = fixture_file_content('movies_near_me_73142.yaml')
|
11
|
-
array.to_yaml.must_equal fixture_yaml
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
it 'raises error if postal code blank' do
|
16
|
-
proc { Fandango.movies_near('') }.must_raise(ArgumentError)
|
17
|
-
end
|
18
|
-
|
19
|
-
it 'raises error if status code is not 200' do
|
20
|
-
response = MiniTest::Mock.new
|
21
|
-
response.expect(:status, ['500', 'not ok'])
|
22
|
-
Fandango.stub(:request, response) do
|
23
|
-
proc { Fandango.movies_near('does not matter') }.must_raise(Fandango::BadResponse)
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
end
|
28
|
-
|
29
|
-
specify '.request makes http request and returns response' do
|
30
|
-
VCR.use_cassette 'movies_near_me_73142' do
|
31
|
-
source = Fandango.request(73142).read
|
32
|
-
fixture_source = fixture_file_content('movies_near_me_73142.rss').chomp
|
33
|
-
source.must_equal fixture_source
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
specify '.clean_postal_code removes spaces from postal code' do
|
38
|
-
Fandango.send(:clean_postal_code, 'ABC 123').must_equal 'ABC123'
|
39
|
-
end
|
40
|
-
|
41
|
-
end
|
data/spec/parser.spec.rb
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Fandango::Parser do
|
4
|
-
|
5
|
-
specify '.parse returns hash of results' do
|
6
|
-
source = fixture_file_content('movies_near_me_73142.rss')
|
7
|
-
array = Fandango::Parser.parse(source)
|
8
|
-
fixture_yaml = fixture_file_content('movies_near_me_73142.yaml')
|
9
|
-
array.to_yaml.must_equal fixture_yaml
|
10
|
-
end
|
11
|
-
|
12
|
-
end
|
@@ -1 +0,0 @@
|
|
1
|
-
<item><title><![CDATA[AMC Quail Springs Mall 24]]></title><link><![CDATA[http://www.fandango.com/amcquailspringsmall24_aaktw/theaterpage?wssaffid=11836&wssac=123]]></link><description><![CDATA[<p>2501 West Memorial Oklahoma City, OK 73134</p><p><ul><li><a href="http://www.fandango.com/abraham+lincoln3a+vampire+hunter_141897/movietimes?location=73134&wssaffid=11836&wssac=123">Abraham Lincoln: Vampire Hunter</a></li><li><a href="http://www.fandango.com/the+amazing+spiderman+3d_141122/movietimes?location=73134&wssaffid=11836&wssac=123">The Amazing Spider-Man 3D</a></li><li><a href="http://www.fandango.com/the+amazing+spiderman_126975/movietimes?location=73134&wssaffid=11836&wssac=123">The Amazing Spider-Man</a></li></ul></p><p><a href="http://www.fandango.com/movietimes?wssaffid=11836&wssac=123">Search other theaters</a></p>]]></description><author>affiliates@fandango.com</author><category>Movies Near Me</category><pubDate>Mon, 28 May 2012 14:16:27 GMT</pubDate><source url="http://www.fandango.com/rss/moviesnearme_73142.rss?wssaffid=11836&wssac=123">Fandango.com Movies Near Me</source></item>
|
data/spec/support/helpers.rb
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
require 'pathname'
|
2
|
-
|
3
|
-
module SpecHelpers
|
4
|
-
|
5
|
-
def fixture_file(file_name)
|
6
|
-
fixtures_path = Pathname.new('./spec/support/fixtures/')
|
7
|
-
File.open(fixtures_path + file_name)
|
8
|
-
end
|
9
|
-
|
10
|
-
def fixture_file_content(file_name)
|
11
|
-
fixture_file(file_name).read
|
12
|
-
end
|
13
|
-
|
14
|
-
def item_node_from_fixture_file(file_name)
|
15
|
-
item_html = fixture_file_content('item.html')
|
16
|
-
Nokogiri.XML(item_html).at_css('item')
|
17
|
-
end
|
18
|
-
|
19
|
-
def description_node_from_fixture_file(file_name)
|
20
|
-
Fandango::Parser.parse_description(item_node_from_fixture_file(file_name))
|
21
|
-
end
|
22
|
-
|
23
|
-
end
|
24
|
-
|
25
|
-
MiniTest::Unit::TestCase.send :include, SpecHelpers if defined?(MiniTest)
|