upcoming_movies_in_the_park 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/.travis.yml +5 -0
- data/CODE_OF_CONDUCT.md +13 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +31 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/bin/upcoming_movies_in_the_park +5 -0
- data/config/environment.rb +11 -0
- data/lib/upcoming_movies_in_the_park/cli.rb +218 -0
- data/lib/upcoming_movies_in_the_park/gate.rb +49 -0
- data/lib/upcoming_movies_in_the_park/park.rb +43 -0
- data/lib/upcoming_movies_in_the_park/scraper.rb +47 -0
- data/lib/upcoming_movies_in_the_park/showing.rb +51 -0
- data/lib/upcoming_movies_in_the_park/version.rb +3 -0
- data/lib/upcoming_movies_in_the_park.rb +5 -0
- data/spec.md +16 -0
- data/upcoming_movies_in_the_park.gemspec +33 -0
- metadata +124 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 93c83166aa8e018f7863e74e1bcad7be69b36922
|
4
|
+
data.tar.gz: 7c92fdf3133741096edc768e1b35a6c66e2d1076
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 25fa900a3345c7878c27932ebded9b0f7ab23a604476da4c8679f10c466f8b078eef43d2483be33efac7015decfcc28313380b17ee345a54cbc59422b4fca48c
|
7
|
+
data.tar.gz: dafacdee3df11ebf591dd3dab1f04add925931d0d25c69e4fff6e8531b95e583e7f7e0f7598bf94f8ab7cfc814c6a765096b6a2f8726b836e9636ebca372b42c
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
|
3
|
+
As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
|
4
|
+
|
5
|
+
We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
|
6
|
+
|
7
|
+
Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
|
8
|
+
|
9
|
+
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
|
10
|
+
|
11
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
|
12
|
+
|
13
|
+
This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2018 sgibson47
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# UpcomingMoviesInThePark
|
2
|
+
|
3
|
+
This Ruby Gem provides a CLI to view upcoming movies playing in Chicago's parks.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
$ gem install upcoming_movies_in_the_park
|
8
|
+
|
9
|
+
## Usage
|
10
|
+
|
11
|
+
Type the below and follow the on screen prompts.
|
12
|
+
|
13
|
+
$ upcoming_movies_in_the_park
|
14
|
+
|
15
|
+
## Development
|
16
|
+
|
17
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
18
|
+
|
19
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
20
|
+
|
21
|
+
## Contributing
|
22
|
+
|
23
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/sgibson47/upcoming_movies_in_the_park.
|
24
|
+
|
25
|
+
This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
|
26
|
+
|
27
|
+
|
28
|
+
## License
|
29
|
+
|
30
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
31
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "upcoming_movies_in_the_park"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'nokogiri'
|
2
|
+
require 'open-uri'
|
3
|
+
require 'pry'
|
4
|
+
require 'colorize'
|
5
|
+
|
6
|
+
require_relative '../lib/upcoming_movies_in_the_park/version'
|
7
|
+
require_relative '../lib/upcoming_movies_in_the_park/cli'
|
8
|
+
require_relative '../lib/upcoming_movies_in_the_park/showing'
|
9
|
+
require_relative '../lib/upcoming_movies_in_the_park/park'
|
10
|
+
require_relative '../lib/upcoming_movies_in_the_park/gate'
|
11
|
+
require_relative '../lib/upcoming_movies_in_the_park/scraper'
|
@@ -0,0 +1,218 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
class UpcomingMoviesInThePark::CLI
|
4
|
+
|
5
|
+
def call
|
6
|
+
UpcomingMoviesInThePark::Scraper.new.make_showings
|
7
|
+
menu
|
8
|
+
menu_path
|
9
|
+
end
|
10
|
+
|
11
|
+
def menu
|
12
|
+
puts "\n"
|
13
|
+
puts "Upcoming Movies in Chicago Parks".colorize(:blue)
|
14
|
+
puts "\n"
|
15
|
+
puts "How would you like to explore movies in the park?".colorize(:blue)
|
16
|
+
print "Enter".colorize(:blue)
|
17
|
+
print " by name "
|
18
|
+
puts "to see a list of upcoming movies by their names.".colorize(:blue)
|
19
|
+
print "Enter".colorize(:blue)
|
20
|
+
print " by date "
|
21
|
+
puts "to see a list of upcoming dates on which movies are playing in a park.".colorize(:blue)
|
22
|
+
print "Enter".colorize(:blue)
|
23
|
+
print " by park "
|
24
|
+
puts "to see a list of parks in which upcoming movies are playing.".colorize(:blue)
|
25
|
+
print "Or enter".colorize(:blue)
|
26
|
+
print " exit "
|
27
|
+
puts "to quit.".colorize(:blue)
|
28
|
+
end
|
29
|
+
|
30
|
+
def menu_path
|
31
|
+
input = nil
|
32
|
+
while input != "exit"
|
33
|
+
input = gets.strip
|
34
|
+
if input == "by name"
|
35
|
+
by_name_path
|
36
|
+
elsif input == "by date"
|
37
|
+
by_date_path
|
38
|
+
elsif input == "by park"
|
39
|
+
by_park_path
|
40
|
+
elsif input === "exit"
|
41
|
+
break
|
42
|
+
else
|
43
|
+
puts "\n"
|
44
|
+
puts "Hrm, I don't understand what you want.".colorize(:blue)
|
45
|
+
print "Please enter".colorize(:blue)
|
46
|
+
print " by name"
|
47
|
+
print ", ".colorize(:blue)
|
48
|
+
print "by date"
|
49
|
+
print ", ".colorize(:blue)
|
50
|
+
print "by park"
|
51
|
+
print ", or ".colorize(:blue)
|
52
|
+
print "exit"
|
53
|
+
puts ".".colorize(:blue)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def by_name_path
|
59
|
+
puts "\n"
|
60
|
+
UpcomingMoviesInThePark::Showing.list_by_name
|
61
|
+
puts "\n"
|
62
|
+
by_name_instructions
|
63
|
+
|
64
|
+
input = nil
|
65
|
+
while input != "back"
|
66
|
+
input = gets.strip
|
67
|
+
if input.to_i > 0 && input.to_i <= UpcomingMoviesInThePark::Showing.all.length
|
68
|
+
showing = UpcomingMoviesInThePark::Showing.all[input.to_i - 1]
|
69
|
+
puts "\n"
|
70
|
+
showing.display_details
|
71
|
+
puts "\n"
|
72
|
+
by_name_instructions
|
73
|
+
elsif input == "back"
|
74
|
+
menu
|
75
|
+
break
|
76
|
+
else
|
77
|
+
puts "Hrm, I don't understand what you want.".colorize(:green)
|
78
|
+
by_name_instructions
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
def by_name_instructions
|
84
|
+
print "Enter ".colorize(:green)
|
85
|
+
print "a number"
|
86
|
+
puts " from the list movie names to get the showing details for that movie".colorize(:green)
|
87
|
+
print "or enter ".colorize(:green)
|
88
|
+
print "back"
|
89
|
+
puts " to go back to the main menu.".colorize(:green)
|
90
|
+
end
|
91
|
+
|
92
|
+
def by_date_path
|
93
|
+
puts "\n"
|
94
|
+
UpcomingMoviesInThePark::Gate.list_by_date
|
95
|
+
puts "\n"
|
96
|
+
by_date_instructions_1
|
97
|
+
input = nil
|
98
|
+
while input != "back"
|
99
|
+
input = gets.strip
|
100
|
+
if input.to_i > 0 && input.to_i <= UpcomingMoviesInThePark::Gate.all.length
|
101
|
+
date = UpcomingMoviesInThePark::Gate.all[input.to_i - 1]
|
102
|
+
puts "\n"
|
103
|
+
date.list_showings
|
104
|
+
puts "\n"
|
105
|
+
by_date_instructions_2
|
106
|
+
input = nil
|
107
|
+
while input != "return"
|
108
|
+
input = gets.strip
|
109
|
+
if input.to_i > 0 && input.to_i <= date.showings.length
|
110
|
+
showing = date.showings[input.to_i - 1]
|
111
|
+
puts "\n"
|
112
|
+
showing.display_details
|
113
|
+
puts "\n"
|
114
|
+
by_date_instructions_2
|
115
|
+
elsif input == "return"
|
116
|
+
puts "\n"
|
117
|
+
UpcomingMoviesInThePark::Gate.list_by_date
|
118
|
+
puts "\n"
|
119
|
+
by_date_instructions_1
|
120
|
+
break
|
121
|
+
else
|
122
|
+
puts "Hrm, I don't understand what you want.".colorize(:cyan)
|
123
|
+
by_date_instructions_2
|
124
|
+
end
|
125
|
+
end
|
126
|
+
elsif input == "back"
|
127
|
+
menu
|
128
|
+
break
|
129
|
+
else
|
130
|
+
puts "Hrm, I don't understand what you want.".colorize(:green)
|
131
|
+
by_date_instructions_1
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
def by_date_instructions_1
|
137
|
+
print "Enter ".colorize(:green)
|
138
|
+
print "a number "
|
139
|
+
puts "to get a list of movies playing on that date".colorize(:green)
|
140
|
+
print "or enter ".colorize(:green)
|
141
|
+
print "back"
|
142
|
+
puts " to go back to the main menu.".colorize(:green)
|
143
|
+
end
|
144
|
+
|
145
|
+
def by_date_instructions_2
|
146
|
+
print "Enter ".colorize(:cyan)
|
147
|
+
print "another number"
|
148
|
+
puts " to get the showing details for that movie".colorize(:cyan)
|
149
|
+
print "or enter ".colorize(:cyan)
|
150
|
+
print "return"
|
151
|
+
puts " to go return to the list of upcoming dates".colorize(:cyan)
|
152
|
+
puts "on which movies are playing in a park.".colorize(:cyan)
|
153
|
+
end
|
154
|
+
|
155
|
+
def by_park_path
|
156
|
+
puts "\n"
|
157
|
+
UpcomingMoviesInThePark::Park.list_by_name
|
158
|
+
puts "\n"
|
159
|
+
by_park_instructions_1
|
160
|
+
input = nil
|
161
|
+
while input != "back"
|
162
|
+
input = gets.strip
|
163
|
+
if input.to_i > 0 && input.to_i <= UpcomingMoviesInThePark::Park.all.length
|
164
|
+
park = UpcomingMoviesInThePark::Park.all[input.to_i - 1]
|
165
|
+
puts "\n"
|
166
|
+
park.list_showings
|
167
|
+
puts "\n"
|
168
|
+
by_park_instructions_2
|
169
|
+
input = nil
|
170
|
+
while input != "return"
|
171
|
+
input = gets.strip
|
172
|
+
if input.to_i > 0 && input.to_i <= park.showings.length
|
173
|
+
showing = park.showings[input.to_i - 1]
|
174
|
+
puts "\n"
|
175
|
+
showing.display_details
|
176
|
+
puts "\n"
|
177
|
+
by_park_instructions_2
|
178
|
+
elsif input == "return"
|
179
|
+
puts "\n"
|
180
|
+
UpcomingMoviesInThePark::Park.list_by_name
|
181
|
+
puts "\n"
|
182
|
+
by_park_instructions_1
|
183
|
+
break
|
184
|
+
else
|
185
|
+
puts "Hrm, I don't understand what you want.".colorize(:cyan)
|
186
|
+
by_park_instructions_2
|
187
|
+
end
|
188
|
+
end
|
189
|
+
elsif input == "back"
|
190
|
+
menu
|
191
|
+
break
|
192
|
+
else
|
193
|
+
puts "Hrm, I don't understand what you want.".colorize(:green)
|
194
|
+
by_park_instructions_1
|
195
|
+
end
|
196
|
+
end
|
197
|
+
end
|
198
|
+
|
199
|
+
def by_park_instructions_1
|
200
|
+
print "Enter ".colorize(:green)
|
201
|
+
print "a number"
|
202
|
+
puts " to get a list of movies playing in that park".colorize(:green)
|
203
|
+
print "or enter ".colorize(:green)
|
204
|
+
print "back"
|
205
|
+
puts " to go back to the main menu.".colorize(:green)
|
206
|
+
end
|
207
|
+
|
208
|
+
def by_park_instructions_2
|
209
|
+
print "Enter ".colorize(:cyan)
|
210
|
+
print "another number"
|
211
|
+
puts " to get the showing details for that movie".colorize(:cyan)
|
212
|
+
print "or enter ".colorize(:cyan)
|
213
|
+
print "return"
|
214
|
+
print " to return to the list of parks".colorize(:cyan)
|
215
|
+
puts "in which upcoming movies are playing.".colorize(:cyan)
|
216
|
+
end
|
217
|
+
|
218
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
class UpcomingMoviesInThePark::Gate
|
2
|
+
attr_accessor :name, :day, :month, :year, :showings
|
3
|
+
|
4
|
+
@@all = []
|
5
|
+
# date info pulled from web, this'll be the name, then parse it to get desired info
|
6
|
+
#"\n Date & Time:\n Mon, Jun 11, 2018 from 8:30 PM - 10:22 PM\n "
|
7
|
+
|
8
|
+
def save
|
9
|
+
@@all << self
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.all
|
13
|
+
@@all
|
14
|
+
end
|
15
|
+
|
16
|
+
def initialize(name)
|
17
|
+
@showings =[]
|
18
|
+
@name = name
|
19
|
+
self.save
|
20
|
+
data = name.split(/, | /)
|
21
|
+
@month = data[31]
|
22
|
+
@day = data[32]
|
23
|
+
@year = data[33]
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.find_or_create_by_name(name)
|
27
|
+
data = name.split(/, | /)
|
28
|
+
if @@all.any? {|gate| data[31] == gate.month && data[32] == gate.day && data[33] = gate.year}
|
29
|
+
@@all.find {|gate| data[31] == gate.month && data[32] == gate.day && data[33] = gate.year}
|
30
|
+
else
|
31
|
+
gate_1 = self.new(name)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def add_showing(showing)
|
36
|
+
@showings << showing
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.list_by_date
|
40
|
+
self.all.each_with_index {|gate, i|
|
41
|
+
puts "#{i +1}. #{gate.month} #{gate.day}, #{gate.year}".colorize(:green)}
|
42
|
+
end
|
43
|
+
|
44
|
+
def list_showings
|
45
|
+
@showings.each_with_index {|showing, i|
|
46
|
+
puts "#{i +1}. #{showing.name}".colorize(:cyan)}
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
class UpcomingMoviesInThePark::Park
|
2
|
+
attr_accessor :name, :showings
|
3
|
+
|
4
|
+
@@all = []
|
5
|
+
|
6
|
+
def save
|
7
|
+
@@all << self
|
8
|
+
end
|
9
|
+
|
10
|
+
def initialize(name)
|
11
|
+
@name = name
|
12
|
+
@showings =[]
|
13
|
+
self.save
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.all
|
17
|
+
@@all
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.find_or_create_by_name(name)
|
21
|
+
if @@all.any? {|park| park.name == name}
|
22
|
+
@@all.find {|park|
|
23
|
+
park.name == name}
|
24
|
+
else
|
25
|
+
park_1 = self.new(name)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def add_showing(showing)
|
30
|
+
@showings << showing
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.list_by_name
|
34
|
+
self.all.each_with_index {|park, i|
|
35
|
+
puts "#{i +1}. #{park.name}".colorize(:green)}
|
36
|
+
end
|
37
|
+
|
38
|
+
def list_showings
|
39
|
+
@showings.each_with_index {|showing, i|
|
40
|
+
puts "#{i +1}. #{showing.name}".colorize(:cyan)}
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
class UpcomingMoviesInThePark::Scraper
|
2
|
+
attr_accessor :showings, :urls
|
3
|
+
|
4
|
+
def initialize
|
5
|
+
@showings =[]
|
6
|
+
end
|
7
|
+
|
8
|
+
def get_page(url)
|
9
|
+
Nokogiri::HTML(open(url))
|
10
|
+
end
|
11
|
+
|
12
|
+
def get_showing_urls
|
13
|
+
day = Date.today
|
14
|
+
doc = get_page("https://www.chicagoparkdistrict.com/events/night-out-in-the-parks?field_event_category=404&field_event_start_date=#{day.year}-#{day.month}-#{day.day}&field_event_end_date=&field_event_movie_title=&field_event_movie_rating=All")
|
15
|
+
|
16
|
+
doc2 = doc.css("div.view-content")
|
17
|
+
|
18
|
+
@urls = doc2.children.css("div.views-field h2 a").map{ |x| x.attribute('href').value}
|
19
|
+
end
|
20
|
+
|
21
|
+
def get_showing_details
|
22
|
+
self.urls.each do |url|
|
23
|
+
doc = get_page("https://www.chicagoparkdistrict.com/#{url}")
|
24
|
+
showing_hash ={}
|
25
|
+
|
26
|
+
showing_hash[:date] = doc.css("p").first.text
|
27
|
+
showing_hash[:park] = doc.css("div.field--name-node-title a").text
|
28
|
+
|
29
|
+
if doc.css("b").text == ""
|
30
|
+
showing_hash[:name] = doc.css("section#description strong").text
|
31
|
+
else
|
32
|
+
showing_hash[:name] = doc.css("b").text
|
33
|
+
end
|
34
|
+
|
35
|
+
@showings << showing_hash
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def make_showings
|
40
|
+
get_showing_urls
|
41
|
+
get_showing_details
|
42
|
+
@showings.each do |hash|
|
43
|
+
UpcomingMoviesInThePark::Showing.create_from_hash(hash)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require_relative './park'
|
2
|
+
require_relative './gate'
|
3
|
+
|
4
|
+
class UpcomingMoviesInThePark::Showing
|
5
|
+
attr_accessor :name, :url
|
6
|
+
attr_reader :date, :park
|
7
|
+
|
8
|
+
@@all =[]
|
9
|
+
|
10
|
+
def self.all
|
11
|
+
@@all
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.list_by_name
|
15
|
+
self.all.each_with_index {|showing, i|
|
16
|
+
puts "#{i +1}. #{showing.name}".colorize(:green)}
|
17
|
+
end
|
18
|
+
|
19
|
+
def display_details
|
20
|
+
puts "#{@name} is playing from #{self.time}".colorize(:red)
|
21
|
+
puts "on #{@date.month} #{@date.day}, #{@date.year} in #{@park.name}.".colorize(:red)
|
22
|
+
end
|
23
|
+
|
24
|
+
def save
|
25
|
+
@@all << self
|
26
|
+
end
|
27
|
+
|
28
|
+
def time
|
29
|
+
data = self.date.name.split(/, | |\n/)
|
30
|
+
time = "#{data[37]} #{data[38]} to #{data[40]} #{data[41]}"
|
31
|
+
end
|
32
|
+
|
33
|
+
def date=(str)
|
34
|
+
@date = UpcomingMoviesInThePark::Gate.find_or_create_by_name(str)
|
35
|
+
@date.add_showing(self)
|
36
|
+
end
|
37
|
+
|
38
|
+
def park=(str)
|
39
|
+
@park = UpcomingMoviesInThePark::Park.find_or_create_by_name(str)
|
40
|
+
@park.add_showing(self)
|
41
|
+
end
|
42
|
+
|
43
|
+
def self.create_from_hash(hash)
|
44
|
+
thing = UpcomingMoviesInThePark::Showing.new
|
45
|
+
hash.each do |k,v|
|
46
|
+
thing.send("#{k}=", v)
|
47
|
+
end
|
48
|
+
@@all<<thing
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
data/spec.md
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# Specifications for the CLI Assessment
|
2
|
+
|
3
|
+
Specs:
|
4
|
+
- [x] Have a CLI for interfacing with the application
|
5
|
+
UpcomingMoviesInThePark::CLI provides a CLI to let a user interface with the application
|
6
|
+
|
7
|
+
- [x] Pull data from an external source
|
8
|
+
UpcomingMoviesInThePark::Scraper pulls data from the web
|
9
|
+
|
10
|
+
- [x] Implement both list and detail views
|
11
|
+
UpcomingMoviesInThePark::Showing.list_by_name
|
12
|
+
UpcomingMoviesInThePark::Gate.list_by_date
|
13
|
+
UpcomingMoviesInThePark::Park.list_by_name
|
14
|
+
list data for the user to review
|
15
|
+
|
16
|
+
The UpcomingMoviesInThePark::Showing class's display_details method provides a detail view
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'upcoming_movies_in_the_park/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "upcoming_movies_in_the_park"
|
8
|
+
spec.version = UpcomingMoviesInThePark::VERSION
|
9
|
+
spec.authors = ["sgibson47"]
|
10
|
+
spec.email = ["sgibson47@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Upcoming Movies In The Park}
|
13
|
+
spec.description = %q{Provides details on upcoming movies in Chicagos parks.}
|
14
|
+
spec.homepage = "https://github.com/sgibson47/upcoming_movies_in_the_park"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
18
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
19
|
+
if spec.respond_to?(:metadata)
|
20
|
+
spec.metadata['allowed_push_host'] = "https://rubygems.org"
|
21
|
+
else
|
22
|
+
raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
|
23
|
+
end
|
24
|
+
|
25
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
26
|
+
spec.executables = "upcoming_movies_in_the_park"
|
27
|
+
spec.require_paths = ["lib", "lib/upcoming_movies_in_the_park"]
|
28
|
+
|
29
|
+
spec.add_development_dependency "bundler", "~> 1.12"
|
30
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
31
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
32
|
+
spec.add_development_dependency "nokogiri", "~> 1.8.1"
|
33
|
+
end
|
metadata
ADDED
@@ -0,0 +1,124 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: upcoming_movies_in_the_park
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- sgibson47
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-06-08 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.12'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.12'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: nokogiri
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 1.8.1
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 1.8.1
|
69
|
+
description: Provides details on upcoming movies in Chicagos parks.
|
70
|
+
email:
|
71
|
+
- sgibson47@gmail.com
|
72
|
+
executables:
|
73
|
+
- upcoming_movies_in_the_park
|
74
|
+
extensions: []
|
75
|
+
extra_rdoc_files: []
|
76
|
+
files:
|
77
|
+
- ".gitignore"
|
78
|
+
- ".rspec"
|
79
|
+
- ".travis.yml"
|
80
|
+
- CODE_OF_CONDUCT.md
|
81
|
+
- Gemfile
|
82
|
+
- LICENSE.txt
|
83
|
+
- README.md
|
84
|
+
- Rakefile
|
85
|
+
- bin/console
|
86
|
+
- bin/setup
|
87
|
+
- bin/upcoming_movies_in_the_park
|
88
|
+
- config/environment.rb
|
89
|
+
- lib/upcoming_movies_in_the_park.rb
|
90
|
+
- lib/upcoming_movies_in_the_park/cli.rb
|
91
|
+
- lib/upcoming_movies_in_the_park/gate.rb
|
92
|
+
- lib/upcoming_movies_in_the_park/park.rb
|
93
|
+
- lib/upcoming_movies_in_the_park/scraper.rb
|
94
|
+
- lib/upcoming_movies_in_the_park/showing.rb
|
95
|
+
- lib/upcoming_movies_in_the_park/version.rb
|
96
|
+
- spec.md
|
97
|
+
- upcoming_movies_in_the_park.gemspec
|
98
|
+
homepage: https://github.com/sgibson47/upcoming_movies_in_the_park
|
99
|
+
licenses:
|
100
|
+
- MIT
|
101
|
+
metadata:
|
102
|
+
allowed_push_host: https://rubygems.org
|
103
|
+
post_install_message:
|
104
|
+
rdoc_options: []
|
105
|
+
require_paths:
|
106
|
+
- lib
|
107
|
+
- lib/upcoming_movies_in_the_park
|
108
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
109
|
+
requirements:
|
110
|
+
- - ">="
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
version: '0'
|
113
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
requirements: []
|
119
|
+
rubyforge_project:
|
120
|
+
rubygems_version: 2.4.5.1
|
121
|
+
signing_key:
|
122
|
+
specification_version: 4
|
123
|
+
summary: Upcoming Movies In The Park
|
124
|
+
test_files: []
|