picturehouse_uk 3.0.14 → 5.0.0

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.
Files changed (63) hide show
  1. checksums.yaml +5 -5
  2. data/.github/workflows/ci.yml +26 -0
  3. data/.github/workflows/release.yml +26 -0
  4. data/.gitignore +1 -0
  5. data/.ruby-version +1 -0
  6. data/CHANGELOG.md +44 -0
  7. data/LICENSE +617 -0
  8. data/README.md +5 -4
  9. data/Rakefile +12 -0
  10. data/lib/picturehouse_uk/cinema.rb +152 -127
  11. data/lib/picturehouse_uk/internal/api.rb +42 -0
  12. data/lib/picturehouse_uk/internal/parser/address.rb +36 -9
  13. data/lib/picturehouse_uk/internal/parser/screenings.rb +89 -95
  14. data/lib/picturehouse_uk/internal/title_sanitizer.rb +61 -65
  15. data/lib/picturehouse_uk/internal/website.rb +10 -12
  16. data/lib/picturehouse_uk/performance.rb +60 -0
  17. data/lib/picturehouse_uk/version.rb +2 -2
  18. data/lib/picturehouse_uk.rb +3 -4
  19. data/picturehouse_uk.gemspec +5 -7
  20. data/rake/fixture_creator.rb +62 -0
  21. data/test/fixtures/cinemas.html +4262 -0
  22. data/test/fixtures/duke-of-york-s-picturehouse/cinema.html +6187 -0
  23. data/test/fixtures/duke-of-york-s-picturehouse/get_movies.json +120552 -0
  24. data/test/fixtures/duke-of-york-s-picturehouse/information.html +3725 -0
  25. data/test/fixtures/duke-s-at-komedia/cinema.html +6138 -0
  26. data/test/fixtures/duke-s-at-komedia/get_movies.json +112 -0
  27. data/test/fixtures/duke-s-at-komedia/information.html +3690 -0
  28. data/test/fixtures/home.html +6236 -565
  29. data/test/fixtures/phoenix-picturehouse/cinema.html +6089 -0
  30. data/test/fixtures/phoenix-picturehouse/get_movies.json +120552 -0
  31. data/test/fixtures/phoenix-picturehouse/information.html +3630 -0
  32. data/test/lib/picturehouse_uk/cinema_test.rb +113 -142
  33. data/test/lib/picturehouse_uk/internal/api_test.rb +92 -0
  34. data/test/lib/picturehouse_uk/internal/parser/{address_parser_test.rb → address_test.rb} +11 -11
  35. data/test/lib/picturehouse_uk/internal/parser/screenings_test.rb +100 -48
  36. data/test/lib/picturehouse_uk/internal/title_sanitizer_test.rb +48 -48
  37. data/test/lib/picturehouse_uk/internal/website_test.rb +15 -31
  38. data/test/lib/picturehouse_uk/performance_test.rb +197 -0
  39. data/test/lib/picturehouse_uk/version_test.rb +1 -1
  40. data/test/live/integration_test.rb +15 -32
  41. data/test/support/fake_api.rb +16 -0
  42. data/test/support/fake_website.rb +24 -0
  43. data/test/test_helper.rb +13 -2
  44. metadata +52 -67
  45. data/.rdoc_options +0 -16
  46. data/.travis.yml +0 -5
  47. data/lib/picturehouse_uk/film.rb +0 -59
  48. data/lib/picturehouse_uk/screening.rb +0 -70
  49. data/test/fixture_updater.rb +0 -73
  50. data/test/fixtures/cinema/Duke_Of_Yorks.html +0 -2984
  51. data/test/fixtures/cinema/Dukes_At_Komedia.html +0 -5518
  52. data/test/fixtures/cinema/National_Media_Museum.html +0 -10266
  53. data/test/fixtures/cinema/Phoenix_Picturehouse.html +0 -5202
  54. data/test/fixtures/info/Duke_Of_Yorks.html +0 -549
  55. data/test/fixtures/info/Dukes_At_Komedia.html +0 -537
  56. data/test/fixtures/info/Phoenix_Picturehouse.html +0 -553
  57. data/test/fixtures/whats_on/Duke_Of_Yorks.html +0 -2737
  58. data/test/fixtures/whats_on/Dukes_At_Komedia.html +0 -5132
  59. data/test/fixtures/whats_on/National_Media_Museum.html +0 -9690
  60. data/test/fixtures/whats_on/Phoenix_Picturehouse.html +0 -4916
  61. data/test/lib/picturehouse_uk/film_test.rb +0 -141
  62. data/test/lib/picturehouse_uk/screening_test.rb +0 -181
  63. /data/{LICENSE.txt → COMM-LICENSE} +0 -0
@@ -1,141 +0,0 @@
1
- require_relative '../../test_helper'
2
-
3
- describe PicturehouseUk::Film do
4
- let(:described_class) { PicturehouseUk::Film }
5
-
6
- describe '.new(name)' do
7
- it 'stores name' do
8
- film = described_class.new('Iron Man 3')
9
- film.name.must_equal 'Iron Man 3'
10
- end
11
- end
12
-
13
- describe '.at(cinema_id)' do
14
- let(:website) { Minitest::Mock.new }
15
-
16
- subject { described_class.at('Duke_Of_Yorks') }
17
-
18
- before do
19
- website.expect(:whats_on, whats_on_html('Duke_Of_Yorks'), ['Duke_Of_Yorks'])
20
- end
21
-
22
- it 'returns an array of films' do
23
- PicturehouseUk::Internal::Website.stub :new, website do
24
- subject.must_be_instance_of(Array)
25
- subject.each do |film|
26
- film.must_be_instance_of(PicturehouseUk::Film)
27
- end
28
- end
29
- end
30
-
31
- it 'returns a decent number of films' do
32
- PicturehouseUk::Internal::Website.stub :new, website do
33
- subject.count.must_be :>, 5
34
- end
35
- end
36
-
37
- it 'returns uniquely named films' do
38
- PicturehouseUk::Internal::Website.stub :new, website do
39
- subject.each_with_index do |item, index|
40
- subject.each_with_index do |jtem, i|
41
- next if index == i
42
- item.name.wont_equal jtem.name
43
- item.wont_equal jtem
44
- end
45
- end
46
- end
47
- end
48
- end
49
-
50
- describe 'Comparable' do
51
- it 'includes comparable methods' do
52
- film = described_class.new 'AAAA'
53
- film.methods.must_include :<
54
- film.methods.must_include :>
55
- film.methods.must_include :==
56
- film.methods.must_include :<=>
57
- film.methods.must_include :<=
58
- film.methods.must_include :>=
59
- end
60
-
61
- describe 'uniqueness' do
62
- it 'defines #hash' do
63
- film = described_class.new 'AAAA'
64
- film.methods.must_include :hash
65
- end
66
-
67
- describe '#hash' do
68
- it 'returns a hash of the slug' do
69
- film = described_class.new 'AAAA'
70
- film.hash == film.slug.hash
71
- end
72
- end
73
-
74
- it 'defines #eql?(other)' do
75
- film = described_class.new 'AAAA'
76
- film.methods.must_include :eql?
77
- end
78
-
79
- describe 'two identically named films' do
80
- let(:film) { described_class.new 'AAAA' }
81
- let(:otherfilm) { described_class.new 'AAAA' }
82
-
83
- it 'retuns only one' do
84
- result = [film, otherfilm].uniq
85
- result.count.must_equal 1
86
- result.must_equal [ described_class.new('AAAA') ]
87
- end
88
- end
89
- end
90
-
91
- describe '<=> (other)' do
92
- subject { film <=> otherfilm }
93
-
94
- describe 'film less than other' do
95
- let(:film) { described_class.new 'AAAA' }
96
- let(:otherfilm) { described_class.new 'BBBB' }
97
-
98
- it 'retuns -1' do
99
- subject.must_equal -1
100
- end
101
- end
102
-
103
- describe 'film greater than other' do
104
- let(:film) { described_class.new 'CCCC' }
105
- let(:otherfilm) { described_class.new 'BBBB' }
106
-
107
- it 'retuns 1' do
108
- subject.must_equal 1
109
- end
110
- end
111
-
112
- describe 'film same as other (exact name)' do
113
- let(:film) { described_class.new 'AAAA' }
114
- let(:otherfilm) { described_class.new 'AAAA' }
115
-
116
- it 'retuns 0' do
117
- subject.must_equal 0
118
- end
119
- end
120
-
121
- describe 'film same as other (inexact name)' do
122
- let(:film) { described_class.new 'blue jasmine' }
123
- let(:otherfilm) { described_class.new 'Blue Jasmine' }
124
-
125
- it 'retuns 0' do
126
- subject.must_equal 0
127
- end
128
- end
129
- end
130
- end
131
-
132
- private
133
-
134
- def whats_on_html(filename)
135
- read_file("../../../fixtures/whats_on/#{filename}.html")
136
- end
137
-
138
- def read_file(filepath)
139
- File.read(File.expand_path(filepath, __FILE__))
140
- end
141
- end
@@ -1,181 +0,0 @@
1
- require_relative '../../test_helper'
2
-
3
- describe PicturehouseUk::Screening do
4
- let(:website) { MockWebsite.new }
5
-
6
- before { WebMock.disable_net_connect! }
7
-
8
- describe '.at(cinema_id)' do
9
- subject { PicturehouseUk::Screening.at('Duke_Of_Yorks') }
10
-
11
- it 'returns an array of screenings' do
12
- PicturehouseUk::Internal::Website.stub :new, website do
13
- subject.must_be_instance_of(Array)
14
- subject.each do |screening|
15
- screening.must_be_instance_of(PicturehouseUk::Screening)
16
- end
17
- end
18
- end
19
-
20
- it 'returns correct number of screenings' do
21
- PicturehouseUk::Internal::Website.stub :new, website do
22
- subject.count.must_equal 58
23
- end
24
- end
25
-
26
- it 'has valid screenings' do
27
- PicturehouseUk::Internal::Website.stub :new, website do
28
- subject.map(&:showing_at).each do |time|
29
- time.wont_equal Time.utc(1970, 1, 1, 0, 0)
30
- end
31
- end
32
- end
33
- end
34
-
35
- describe '.new' do
36
- subject { PicturehouseUk::Screening.new(options) }
37
-
38
- describe 'simple' do
39
- let(:options) do
40
- {
41
- film_name: 'Iron Man 3',
42
- cinema_id: 3,
43
- cinema_name: 'Cineworld Brighton',
44
- time: Time.utc(2013, 9, 12, 11, 0)
45
- }
46
- end
47
-
48
- it 'sets cinema name and film name' do
49
- subject.film_name.must_equal 'Iron Man 3'
50
- subject.cinema_name.must_equal 'Cineworld Brighton'
51
- end
52
-
53
- it 'booking url, dimension & varient are set to defaults' do
54
- subject.booking_url.must_equal nil
55
- subject.dimension.must_equal '2d'
56
- subject.variant.must_equal []
57
- end
58
- end
59
- end
60
-
61
- describe '#dimension' do
62
- let(:options) do
63
- {
64
- film_name: 'Iron Man 3',
65
- dimension: '3d',
66
- cinema_id: 3,
67
- cinema_name: 'Cineworld Brighton',
68
- time: Time.utc(2013, 9, 12, 11, 0)
69
- }
70
- end
71
-
72
- subject { PicturehouseUk::Screening.new(options).dimension }
73
-
74
- it 'returns 2d or 3d' do
75
- subject.must_be_instance_of(String)
76
- subject.must_equal '3d'
77
- end
78
- end
79
-
80
- describe '#showing_at' do
81
- subject { PicturehouseUk::Screening.new(options).showing_at }
82
-
83
- describe 'with utc time' do
84
- let(:options) do
85
- {
86
- film_name: 'Iron Man 3',
87
- cinema_id: 3,
88
- cinema_name: 'Cineworld Brighton',
89
- time: Time.utc(2013, 9, 12, 11, 0)
90
- }
91
- end
92
-
93
- it 'returns UTC time' do
94
- subject.must_be_instance_of Time
95
- subject.must_equal Time.utc(2013, 9, 12, 11, 0)
96
- end
97
- end
98
-
99
- describe 'with non-utc time' do
100
- let(:options) do
101
- {
102
- film_name: 'Iron Man 3',
103
- cinema_id: 3,
104
- cinema_name: 'Cineworld Brighton',
105
- time: Time.parse('2013-09-12 11:00')
106
- }
107
- end
108
-
109
- it 'returns UTC time' do
110
- subject.must_be_instance_of Time
111
- subject.must_equal Time.utc(2013, 9, 12, 10, 0)
112
- end
113
- end
114
- end
115
-
116
- describe '#showing_on' do
117
- let(:options) do
118
- {
119
- film_name: 'Iron Man 3',
120
- cinema_id: 3,
121
- cinema_name: 'Cineworld Brighton',
122
- time: Time.utc(2013, 9, 12, 11, 0)
123
- }
124
- end
125
-
126
- subject { PicturehouseUk::Screening.new(options).showing_on }
127
-
128
- it 'returns date of showing' do
129
- subject.must_be_instance_of(Date)
130
- subject.must_equal Date.new(2013, 9, 12)
131
- end
132
- end
133
-
134
- describe '#variant' do
135
- subject { PicturehouseUk::Screening.new(options).variant }
136
-
137
- let(:options) do
138
- {
139
- film_name: 'Iron Man 3',
140
- cinema_id: 3,
141
- cinema_name: 'Cineworld Brighton',
142
- time: Time.utc(2013, 9, 12, 11, 0),
143
- variant: ['Kids']
144
- }
145
- end
146
-
147
- it 'is an alphabetically ordered array of lower-cased strings' do
148
- subject.must_be_instance_of Array
149
- subject.each do |tag|
150
- tag.must_be_instance_of String
151
- end
152
- subject.must_equal %w(kids)
153
- end
154
- end
155
-
156
- private
157
-
158
- class MockWebsite
159
- def home
160
- read_file('../../../fixtures/home.html')
161
- end
162
-
163
- def cinema(filename)
164
- read_file("../../../fixtures/cinema/#{filename}.html")
165
- end
166
-
167
- def contact_us(filename)
168
- read_file("../../../fixtures/contact_us/#{filename}.html")
169
- end
170
-
171
- def whats_on(filename)
172
- read_file("../../../fixtures/whats_on/#{filename}.html")
173
- end
174
-
175
- private
176
-
177
- def read_file(filepath)
178
- File.read(File.expand_path(filepath, __FILE__))
179
- end
180
- end
181
- end
File without changes