picturehouse_uk 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/.rdoc_options +16 -0
- data/.yardopts +4 -0
- data/lib/picturehouse_uk/cinema.rb +23 -37
- data/lib/picturehouse_uk/film.rb +22 -27
- data/lib/picturehouse_uk/internal/film_with_screenings_parser.rb +14 -1
- data/lib/picturehouse_uk/screening.rb +11 -14
- data/lib/picturehouse_uk/version.rb +4 -1
- data/lib/picturehouse_uk.rb +0 -1
- metadata +8 -21
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
Y2E3N2EwZjlhZGJhZWJiOGU5YTY2NjRhZThiYWM5ZmEyODA3MzdiOQ==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
N2RlNzU4ZDA3MjIwMThiNjZlZjM2ZmJiN2Q3YmE0NGY0NDYzNzBmZg==
|
7
|
+
SHA512:
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
NzVlMWI3ZGZkN2RlZmQxODAzNTU4NTZmYzZiYjZjODAyNjIwZTQyYzc0YzEw
|
10
|
+
ZTBjMzcyNjllNTQ4NjY5YzMxODQ0NmNjZDc2M2UzNjk4MjQ2NTE4NTZkZGY3
|
11
|
+
YzRmZWQxYTk2ZWY5OTZiNzNjZmJmYTMyMDg4NWMzODI5NmVhMWU=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
MWI2MTFkMmI1YzQyN2MzZmZhZGFhZTVkOTQzODM4Y2I1ZDNjMTlhMmY4MzMx
|
14
|
+
MjY2Mjg4OWMxMzI4ZjBjODU5YjZlZDNkZTNmZGU5NmVkMmFhMjg1M2M3Nzhi
|
15
|
+
ZWEyY2U1NzAwZTFlNGU2MjcwNGViMTgxNzdlNGJjYjllZTk1NjE=
|
data/.rdoc_options
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
--- !ruby/object:RDoc::Options
|
2
|
+
encoding: UTF-8
|
3
|
+
static_path: []
|
4
|
+
rdoc_include:
|
5
|
+
- .
|
6
|
+
charset: UTF-8
|
7
|
+
exclude:
|
8
|
+
hyperlink_all: false
|
9
|
+
line_numbers: false
|
10
|
+
main_page:
|
11
|
+
markup: tomdoc
|
12
|
+
show_hash: false
|
13
|
+
tab_width: 8
|
14
|
+
title:
|
15
|
+
visibility: :protected
|
16
|
+
webcvs:
|
data/.yardopts
ADDED
@@ -1,24 +1,23 @@
|
|
1
1
|
module PicturehouseUk
|
2
2
|
|
3
|
-
#
|
3
|
+
# The object representing a cinema on the Picturehouse UK website
|
4
4
|
class Cinema
|
5
5
|
|
6
|
-
#
|
6
|
+
# @return [String] the brand of the cinema
|
7
7
|
attr_reader :brand
|
8
|
-
#
|
8
|
+
# @return [String] the id of the cinema on the Picturehouse website
|
9
9
|
attr_reader :id
|
10
|
-
#
|
10
|
+
# @return [String] the name of the cinema
|
11
11
|
attr_reader :name
|
12
|
-
#
|
12
|
+
# @return [String] the slug of the cinema
|
13
13
|
attr_reader :slug
|
14
|
-
#
|
14
|
+
# @return [String] the url of the cinema on the Picturehouse website
|
15
15
|
attr_reader :url
|
16
16
|
|
17
|
-
#
|
18
|
-
#
|
19
|
-
#
|
20
|
-
#
|
21
|
-
# url - String of cinema url on the picturehouse website
|
17
|
+
# @param [String] id cinema id from the site
|
18
|
+
# @param [String] name cinema name
|
19
|
+
# @param [String] url url on Picturehouse website
|
20
|
+
# @return [PicturehouseUk::Cinema]
|
22
21
|
def initialize(id, name, url)
|
23
22
|
@brand = 'Picturehouse'
|
24
23
|
@id = id
|
@@ -27,43 +26,33 @@ module PicturehouseUk
|
|
27
26
|
@url = (url[0] == '/') ? "http://www.picturehouses.co.uk#{url}" : url
|
28
27
|
end
|
29
28
|
|
30
|
-
#
|
31
|
-
#
|
32
|
-
#
|
33
|
-
#
|
29
|
+
# Return basic cinema information for all cinemas
|
30
|
+
# @return [Array<PicturehouseUk::Cinema>]
|
31
|
+
# @example
|
34
32
|
# PicturehouseUk::Cinema.all
|
35
33
|
# # => [<PicturehouseUK::Cinema brand="Picturehouse" name="Duke's At Komedia" slug="dukes-at-komedia" id="Dukes_At_Komedia" url="...">, #=> <PicturehouseUK::Cinema brand="Picturehouse" name="Duke o York's" slug="duke-of-yorks" id="Duke_Of_Yorks" url="...">, ...]
|
36
|
-
#
|
37
|
-
# Returns an array of hashes of cinema information.
|
38
34
|
def self.all
|
39
35
|
cinema_links.map do |link|
|
40
36
|
new_from_link link
|
41
37
|
end
|
42
38
|
end
|
43
39
|
|
44
|
-
#
|
45
|
-
#
|
46
|
-
#
|
47
|
-
#
|
48
|
-
# Examples
|
49
|
-
#
|
40
|
+
# Find a single cinema
|
41
|
+
# @param [String] id the cinema id as used on the picturehouses.co.uk website
|
42
|
+
# @return [PicturehouseUk::Cinema, nil]
|
43
|
+
# @example
|
50
44
|
# PicturehouseUk::Cinema.find('Dukes_At_Komedia')
|
51
45
|
# # => <PicturehouseUK::Cinema brand="Picturehouse" name="Duke's At Komedia" slug="dukes-at-komedia" id="Dukes_At_Komedia" url="...">
|
52
|
-
#
|
53
|
-
# Returns an PicturehouseUk::Cinema or nil if none was found
|
54
46
|
def self.find(id)
|
55
47
|
all.select { |cinema| cinema.id == id }[0]
|
56
48
|
end
|
57
49
|
|
58
|
-
#
|
59
|
-
#
|
60
|
-
#
|
61
|
-
#
|
50
|
+
# Films with showings scheduled at this cinema
|
51
|
+
# @return [Array<PicturehouseUk::Film>]
|
52
|
+
# @example
|
62
53
|
# cinema = PicturehouseUk::Cinema.find('Dukes_At_Komedia')
|
63
54
|
# cinema.films
|
64
55
|
# # => [<PicturehouseUk::Film name="Iron Man 3">, <PicturehouseUk::Film name="Star Trek Into Darkness">]
|
65
|
-
#
|
66
|
-
# Returns an array of PicturehouseUk::Film objects
|
67
56
|
def films
|
68
57
|
film_nodes.map do |node|
|
69
58
|
parser = PicturehouseUk::Internal::FilmWithScreeningsParser.new node.to_s
|
@@ -71,15 +60,12 @@ module PicturehouseUk
|
|
71
60
|
end.uniq
|
72
61
|
end
|
73
62
|
|
74
|
-
#
|
75
|
-
#
|
76
|
-
#
|
77
|
-
#
|
63
|
+
# All planned screenings
|
64
|
+
# @return [Array<PicturehouseUk::Screening>]
|
65
|
+
# @example
|
78
66
|
# cinema = PicturehouseUk::Cinema.find('Dukes_At_Komedia')
|
79
67
|
# cinema.screenings
|
80
68
|
# # => [<PicturehouseUk::Screening film_name="Iron Man 3" cinema_name="Duke's At Komedia" when="..." varient="...">, <PicturehouseUk::Screening ...>]
|
81
|
-
#
|
82
|
-
# Returns an array of Odeon::Screening objects
|
83
69
|
def screenings
|
84
70
|
film_nodes.map do |node|
|
85
71
|
parser = PicturehouseUk::Internal::FilmWithScreeningsParser.new node.to_s
|
data/lib/picturehouse_uk/film.rb
CHANGED
@@ -1,52 +1,47 @@
|
|
1
1
|
module PicturehouseUk
|
2
2
|
|
3
|
-
#
|
3
|
+
# A film on the Picturehouse UK website
|
4
4
|
class Film
|
5
5
|
include Comparable
|
6
6
|
|
7
|
-
#
|
7
|
+
# @return [String] the name of the film
|
8
8
|
attr_reader :name
|
9
|
-
#
|
9
|
+
# @return [String] the normalized slug derived from the film name
|
10
10
|
attr_reader :slug
|
11
11
|
|
12
|
-
#
|
12
|
+
# @param [String] name the film name
|
13
|
+
# @return [PicturehouseUk::Film]
|
14
|
+
def initialize(name)
|
15
|
+
@name = name
|
16
|
+
@slug = name.downcase.gsub(/[^0-9a-z ]/,'').gsub(/\s+/, '-')
|
17
|
+
end
|
18
|
+
|
19
|
+
# Allows sort on objects
|
20
|
+
# @param [PicturehouseUk::Film] other another film object
|
21
|
+
# @return [Integer] -1, 0 or 1
|
13
22
|
def <=> other
|
14
23
|
self.slug <=> other.slug
|
15
24
|
end
|
16
25
|
|
17
|
-
#
|
18
|
-
#
|
19
|
-
# True if both objects are the same exact object, or if
|
20
|
-
# type and share an equal slug
|
21
|
-
#
|
22
|
-
# Guided by http://woss.name/2011/01/20/equality-comparison-and-ordering-in-ruby/
|
23
|
-
#
|
24
|
-
# object - object to be compared
|
25
|
-
#
|
26
|
-
# Returns Boolean
|
26
|
+
# Check an object is the same as another object.
|
27
|
+
# @param [PicturehouseUk::Film] other another film
|
28
|
+
# @return [Boolean] True if both objects are the same exact object, or if
|
29
|
+
# they are of the same type and share an equal slug
|
30
|
+
# @note Guided by http://woss.name/2011/01/20/equality-comparison-and-ordering-in-ruby/
|
27
31
|
def eql? other
|
28
32
|
self.class == other.class && self == other
|
29
33
|
end
|
30
34
|
|
31
|
-
#
|
32
|
-
#
|
35
|
+
# Generates hash of slug in order to allow two records of the same type and
|
36
|
+
# id to work with something like:
|
33
37
|
#
|
34
38
|
# [ Film.new('ABC'), Film.new('DEF') ] & [ Film.new('DEF'), Film.new('GHI') ]
|
35
39
|
# #=> [ Film.new('DEF') ]
|
36
40
|
#
|
37
|
-
#
|
38
|
-
#
|
39
|
-
# Returns an Integer hash of the slug
|
41
|
+
# @return [Integer] hash of slug
|
42
|
+
# @note Guided by http://woss.name/2011/01/20/equality-comparison-and-ordering-in-ruby/
|
40
43
|
def hash
|
41
44
|
self.slug.hash
|
42
45
|
end
|
43
|
-
|
44
|
-
# Public: Initialize a screening
|
45
|
-
#
|
46
|
-
# name - String of the film name
|
47
|
-
def initialize(name)
|
48
|
-
@name = name
|
49
|
-
@slug = name.downcase.gsub(/[^0-9a-z ]/,'').gsub(/\s+/, '-')
|
50
|
-
end
|
51
46
|
end
|
52
47
|
end
|
@@ -1,12 +1,19 @@
|
|
1
1
|
module PicturehouseUk
|
2
|
+
|
3
|
+
# Internal utility classes: Do not use
|
4
|
+
# @api private
|
2
5
|
module Internal
|
3
|
-
|
6
|
+
|
7
|
+
# Parses a chunk of HTML to derive movie showing data
|
4
8
|
class FilmWithScreeningsParser
|
5
9
|
|
10
|
+
# @param [String] film_html a chunk of html
|
6
11
|
def initialize(film_html)
|
7
12
|
@nokogiri_html = Nokogiri::HTML(film_html)
|
8
13
|
end
|
9
14
|
|
15
|
+
# The film name
|
16
|
+
# @return [String]
|
10
17
|
def film_name
|
11
18
|
name = @nokogiri_html.css('.movielink').children.first.to_s
|
12
19
|
|
@@ -28,6 +35,12 @@ module PicturehouseUk
|
|
28
35
|
name = name.gsub /\s+\z/, '' # remove trailing spaces
|
29
36
|
end
|
30
37
|
|
38
|
+
# Showings
|
39
|
+
# @return [Hash]
|
40
|
+
# @example
|
41
|
+
# {
|
42
|
+
# "2D" => [Time.utc, Time.utc]
|
43
|
+
# }
|
31
44
|
def showings
|
32
45
|
@nokogiri_html.css('a[epoch]').inject({}) do |result, link|
|
33
46
|
key = case link['class']
|
@@ -1,31 +1,28 @@
|
|
1
1
|
module PicturehouseUk
|
2
2
|
|
3
|
-
#
|
3
|
+
# A single screening of a film on the Picturehouse UK website
|
4
4
|
class Screening
|
5
5
|
|
6
|
-
#
|
6
|
+
# @return [String] the cinema name
|
7
7
|
attr_reader :cinema_name
|
8
|
-
#
|
8
|
+
# @return [String] the film name
|
9
9
|
attr_reader :film_name
|
10
|
-
#
|
10
|
+
# @return [Time] the UTC time of the screening
|
11
11
|
attr_reader :when
|
12
|
-
#
|
12
|
+
# @return [String] the type of screening (2D, 3D, IMAX...)
|
13
13
|
attr_reader :varient
|
14
14
|
|
15
|
-
#
|
16
|
-
#
|
17
|
-
#
|
18
|
-
#
|
19
|
-
# time - DateTime representing the time of the screening, UTC preferred
|
20
|
-
# varient - String representing the type of showing (e.g. 3d/baby/live)
|
15
|
+
# @param [String] film_name the film name
|
16
|
+
# @param [String] cinema_name the cinema name
|
17
|
+
# @param [Time] time datetime of the screening (UTC preferred)
|
18
|
+
# @param [String] varient the type of showing (e.g. 3d/baby/live)
|
21
19
|
def initialize(film_name, cinema_name, time, varient=nil)
|
22
20
|
@cinema_name, @film_name, @varient = cinema_name, film_name, varient
|
23
21
|
@when = time.utc? ? time : TZInfo::Timezone.get('Europe/London').local_to_utc(time)
|
24
22
|
end
|
25
23
|
|
26
|
-
#
|
27
|
-
#
|
28
|
-
# Returns a Date
|
24
|
+
# The date of the screening
|
25
|
+
# @return [Date]
|
29
26
|
def date
|
30
27
|
@when.to_date
|
31
28
|
end
|
data/lib/picturehouse_uk.rb
CHANGED
metadata
CHANGED
@@ -1,20 +1,18 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: picturehouse_uk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
5
|
-
prerelease:
|
4
|
+
version: 1.0.1
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Andy Croll
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2013-
|
11
|
+
date: 2013-11-08 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: bundler
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
17
|
- - ~>
|
20
18
|
- !ruby/object:Gem::Version
|
@@ -22,7 +20,6 @@ dependencies:
|
|
22
20
|
type: :development
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
24
|
- - ~>
|
28
25
|
- !ruby/object:Gem::Version
|
@@ -30,7 +27,6 @@ dependencies:
|
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: rake
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
31
|
- - ! '>='
|
36
32
|
- !ruby/object:Gem::Version
|
@@ -38,7 +34,6 @@ dependencies:
|
|
38
34
|
type: :development
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
38
|
- - ! '>='
|
44
39
|
- !ruby/object:Gem::Version
|
@@ -46,7 +41,6 @@ dependencies:
|
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
42
|
name: webmock
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
44
|
requirements:
|
51
45
|
- - ! '>='
|
52
46
|
- !ruby/object:Gem::Version
|
@@ -54,7 +48,6 @@ dependencies:
|
|
54
48
|
type: :development
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
51
|
requirements:
|
59
52
|
- - ! '>='
|
60
53
|
- !ruby/object:Gem::Version
|
@@ -62,7 +55,6 @@ dependencies:
|
|
62
55
|
- !ruby/object:Gem::Dependency
|
63
56
|
name: httparty
|
64
57
|
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
58
|
requirements:
|
67
59
|
- - ! '>='
|
68
60
|
- !ruby/object:Gem::Version
|
@@ -70,7 +62,6 @@ dependencies:
|
|
70
62
|
type: :runtime
|
71
63
|
prerelease: false
|
72
64
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
65
|
requirements:
|
75
66
|
- - ! '>='
|
76
67
|
- !ruby/object:Gem::Version
|
@@ -78,7 +69,6 @@ dependencies:
|
|
78
69
|
- !ruby/object:Gem::Dependency
|
79
70
|
name: nokogiri
|
80
71
|
requirement: !ruby/object:Gem::Requirement
|
81
|
-
none: false
|
82
72
|
requirements:
|
83
73
|
- - ! '>='
|
84
74
|
- !ruby/object:Gem::Version
|
@@ -86,7 +76,6 @@ dependencies:
|
|
86
76
|
type: :runtime
|
87
77
|
prerelease: false
|
88
78
|
version_requirements: !ruby/object:Gem::Requirement
|
89
|
-
none: false
|
90
79
|
requirements:
|
91
80
|
- - ! '>='
|
92
81
|
- !ruby/object:Gem::Version
|
@@ -94,7 +83,6 @@ dependencies:
|
|
94
83
|
- !ruby/object:Gem::Dependency
|
95
84
|
name: tzinfo
|
96
85
|
requirement: !ruby/object:Gem::Requirement
|
97
|
-
none: false
|
98
86
|
requirements:
|
99
87
|
- - ! '>='
|
100
88
|
- !ruby/object:Gem::Version
|
@@ -102,7 +90,6 @@ dependencies:
|
|
102
90
|
type: :runtime
|
103
91
|
prerelease: false
|
104
92
|
version_requirements: !ruby/object:Gem::Requirement
|
105
|
-
none: false
|
106
93
|
requirements:
|
107
94
|
- - ! '>='
|
108
95
|
- !ruby/object:Gem::Version
|
@@ -110,7 +97,6 @@ dependencies:
|
|
110
97
|
- !ruby/object:Gem::Dependency
|
111
98
|
name: tzinfo-data
|
112
99
|
requirement: !ruby/object:Gem::Requirement
|
113
|
-
none: false
|
114
100
|
requirements:
|
115
101
|
- - ! '>='
|
116
102
|
- !ruby/object:Gem::Version
|
@@ -118,7 +104,6 @@ dependencies:
|
|
118
104
|
type: :runtime
|
119
105
|
prerelease: false
|
120
106
|
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
none: false
|
122
107
|
requirements:
|
123
108
|
- - ! '>='
|
124
109
|
- !ruby/object:Gem::Version
|
@@ -131,7 +116,9 @@ extensions: []
|
|
131
116
|
extra_rdoc_files: []
|
132
117
|
files:
|
133
118
|
- .gitignore
|
119
|
+
- .rdoc_options
|
134
120
|
- .travis.yml
|
121
|
+
- .yardopts
|
135
122
|
- Gemfile
|
136
123
|
- LICENSE.txt
|
137
124
|
- README.md
|
@@ -167,27 +154,26 @@ files:
|
|
167
154
|
homepage: ''
|
168
155
|
licenses:
|
169
156
|
- MIT
|
157
|
+
metadata: {}
|
170
158
|
post_install_message:
|
171
159
|
rdoc_options: []
|
172
160
|
require_paths:
|
173
161
|
- lib
|
174
162
|
required_ruby_version: !ruby/object:Gem::Requirement
|
175
|
-
none: false
|
176
163
|
requirements:
|
177
164
|
- - ! '>='
|
178
165
|
- !ruby/object:Gem::Version
|
179
166
|
version: '0'
|
180
167
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
181
|
-
none: false
|
182
168
|
requirements:
|
183
169
|
- - ! '>='
|
184
170
|
- !ruby/object:Gem::Version
|
185
171
|
version: '0'
|
186
172
|
requirements: []
|
187
173
|
rubyforge_project:
|
188
|
-
rubygems_version: 1.
|
174
|
+
rubygems_version: 2.1.10
|
189
175
|
signing_key:
|
190
|
-
specification_version:
|
176
|
+
specification_version: 4
|
191
177
|
summary: It's a scraper, but a nice one
|
192
178
|
test_files:
|
193
179
|
- test/fixtures/dukes-at-komedia-cinema.html
|
@@ -211,3 +197,4 @@ test_files:
|
|
211
197
|
- test/lib/picturehouse_uk/screening_test.rb
|
212
198
|
- test/lib/picturehouse_uk/version_test.rb
|
213
199
|
- test/test_helper.rb
|
200
|
+
has_rdoc:
|