movie_helper 0.1.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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: dfce5bb70b13d455cc3aacf68cdbd09790194c0c706a19e89005bea4c9da1e5c
4
+ data.tar.gz: 2ca69f3673ba16946e6ac60c6132dde123dc63439034d8b4d885cf4b391bad5f
5
+ SHA512:
6
+ metadata.gz: b6e695ad564f3f8c17e2cb6ae7b2456069259a5eb79ba9da39b988f6514dd44b83539ca1067de673712eecf797eaa3aec585b95f40d4a82975003a7144f53181
7
+ data.tar.gz: 7532951c1d9c0677d3150dfe17c8c911610cdf9e67fbb4c86b9479d54a94eaf0b307e92fdc810b69910479028812eaf51248ba5aae8d766da86ab0defc8c2b90
data/.DS_Store ADDED
Binary file
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.3.3
7
+ before_install: gem install bundler -v 1.16.4
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at dlyons8@binghamton.edu. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ #git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in movie_helper.gemspec
6
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,45 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ movie_helper (0.1.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ coderay (1.1.2)
10
+ diff-lcs (1.3)
11
+ method_source (0.9.2)
12
+ mini_portile2 (2.4.0)
13
+ nokogiri (1.10.3)
14
+ mini_portile2 (~> 2.4.0)
15
+ pry (0.12.2)
16
+ coderay (~> 1.1.0)
17
+ method_source (~> 0.9.0)
18
+ rake (10.5.0)
19
+ rspec (3.8.0)
20
+ rspec-core (~> 3.8.0)
21
+ rspec-expectations (~> 3.8.0)
22
+ rspec-mocks (~> 3.8.0)
23
+ rspec-core (3.8.0)
24
+ rspec-support (~> 3.8.0)
25
+ rspec-expectations (3.8.4)
26
+ diff-lcs (>= 1.2.0, < 2.0)
27
+ rspec-support (~> 3.8.0)
28
+ rspec-mocks (3.8.0)
29
+ diff-lcs (>= 1.2.0, < 2.0)
30
+ rspec-support (~> 3.8.0)
31
+ rspec-support (3.8.2)
32
+
33
+ PLATFORMS
34
+ ruby
35
+
36
+ DEPENDENCIES
37
+ bundler (~> 1.16)
38
+ movie_helper!
39
+ nokogiri
40
+ pry
41
+ rake (~> 10.0)
42
+ rspec (~> 3.0)
43
+
44
+ BUNDLED WITH
45
+ 1.17.3
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2019 Donnovan Lyons
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,42 @@
1
+ # Movie Helper
2
+
3
+ Welcome to the Movie Helper gem!
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'movie_helper'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install movie_helper
20
+
21
+ ## Usage
22
+
23
+ To run this gem, cd into the file and run `ruby bin/movie-helper`, and it will automatically scrape the data for use in the Command Line Interface.
24
+
25
+ ## Development
26
+
27
+ 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.
28
+
29
+ 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).
30
+
31
+ ## Contributing
32
+
33
+ Bug reports and pull requests are welcome on GitHub at https://github.com/dlyons8/movie_helper. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
34
+
35
+ ## License
36
+
37
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
38
+
39
+ ## Code of Conduct
40
+
41
+ Everyone interacting in the MovieHelper project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/dlyons8/movie_helper/blob/master/CODE_OF_CONDUCT.md).
42
+ # movie_helper
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "movie_helper"
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(__FILE__)
data/bin/movie-helper ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "movie_helper"
5
+
6
+ MovieHelper::CLI.new.call
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,12 @@
1
+ require 'open-uri'
2
+ require 'nokogiri'
3
+ require 'pry'
4
+
5
+ require_relative "./movie_helper/version"
6
+ require_relative "./movie_helper/cli"
7
+ require_relative "./movie_helper/movie"
8
+ require_relative "./movie_helper/scraper"
9
+
10
+ module MovieHelper
11
+ # Your code goes here...
12
+ end
@@ -0,0 +1,153 @@
1
+ class MovieHelper::CLI
2
+
3
+ def call
4
+ greeting
5
+ list_options
6
+ satisfaction_check
7
+ goodbye
8
+ end
9
+
10
+ def greeting
11
+ puts "Welcome to Movie Helper!"
12
+ puts
13
+ end
14
+
15
+ def list_options
16
+ puts "Let us help you find a movie!"
17
+ puts ""
18
+ puts "Please select an option below:"
19
+ puts "1. Random"
20
+ puts "2. Best Films"
21
+ puts "3. Latest Suggestions"
22
+ puts "4. Exit"
23
+ selector
24
+ end
25
+
26
+ def selector
27
+ input = gets.chomp
28
+ case input
29
+ when "1"
30
+ random
31
+ when "2"
32
+ best_films
33
+ when "3"
34
+ latest_suggestions
35
+ when "4" || "exit" || "quit"
36
+ else
37
+ puts "Invalid request."
38
+ puts ""
39
+ list_options
40
+ end
41
+ end
42
+
43
+ def random
44
+ puts "One moment while we randomly select your movie..."
45
+ movie_hash = MovieHelper::Scraper.random
46
+ movie = MovieHelper::Movie.new(movie_hash)
47
+ puts ""
48
+ puts "Your random movie is:"
49
+ puts ""
50
+ puts movie.title
51
+ puts ""
52
+ more_info(movie)
53
+ end
54
+
55
+ def best_films
56
+
57
+ if MovieHelper::Movie.best_films.empty?
58
+ puts "Loading..."
59
+ best_films = MovieHelper::Scraper.best_films
60
+ MovieHelper::Movie.create_from_list(best_films)
61
+ puts ""
62
+ end
63
+ puts "Here is a list of our best films:"
64
+ movies = MovieHelper::Movie.best_films
65
+ movies.each.with_index do |movie, i|
66
+ puts "#{i+1}. #{movie.title}"
67
+ end
68
+ information(movies)
69
+ end
70
+
71
+
72
+ def information(movies)
73
+ puts ""
74
+ puts "For more information on one of these movies, please type 1 - #{movies.count}."
75
+ puts "To return to the main menu, please type 'list'"
76
+
77
+ input = gets.chomp
78
+ if input.to_i.between?(1, movies.count)
79
+ input = input.to_i - 1
80
+ more_info(movies[input])
81
+ elsif input == "list"
82
+ list_options
83
+ else
84
+ information(movies)
85
+ end
86
+ end
87
+
88
+ def latest_suggestions
89
+ if MovieHelper::Movie.latest.empty?
90
+ puts "Loading..."
91
+ latest_films = MovieHelper::Scraper.latest
92
+ MovieHelper::Movie.create_from_list(latest_films)
93
+ puts ""
94
+ end
95
+ puts "Here are some of our latest suggestions:"
96
+ movies = MovieHelper::Movie.latest
97
+ movies.each.with_index do |movie, i|
98
+ puts "#{i+1}. #{movie.title}"
99
+ end
100
+ information(movies)
101
+ end
102
+
103
+ def more_info(movie)
104
+ puts "Would you like more information about this movie?"
105
+ puts "Type Y to get more information, or list to go back to the main menu."
106
+ input = gets.chomp
107
+ if input.upcase == "Y"
108
+ display(movie)
109
+ elsif input.downcase == "list"
110
+ list_options
111
+ else
112
+ more_info(movie)
113
+ end
114
+ end
115
+
116
+ def display(movie)
117
+ puts "Title: #{movie.title} (#{movie.year})"
118
+ puts "Watch with #{movie.watch_with}"
119
+ puts "Watch when #{movie.watch_when}"
120
+ puts "Genre: #{movie.genre}"
121
+ puts "Selected review: #{movie.review}"
122
+ puts "Movie stars: #{movie.stars}"
123
+ puts "Movie rating: #{movie.rating}"
124
+ puts "Language: #{movie.language}"
125
+ end
126
+
127
+ def satisfaction_check
128
+ input = nil
129
+ until input == "yes" ||input == "y"
130
+ puts "Are you satisfied with your movie choice?"
131
+ input = gets.chomp.downcase
132
+ if input == "no" || input == "n"
133
+ input = try_again
134
+ end
135
+ end
136
+ end
137
+
138
+ def try_again
139
+ puts "Would you like to try again?"
140
+ input = gets.chomp.downcase
141
+ if input == "yes" || input == "y"
142
+ list_options
143
+ elsif input == "no" || input == "n"
144
+ "yes"
145
+ else
146
+ try_again
147
+ end
148
+ end
149
+
150
+ def goodbye
151
+ puts "Thank you for your using Movie Helper!"
152
+ end
153
+ end
@@ -0,0 +1,30 @@
1
+ class MovieHelper::Movie
2
+ attr_accessor :title, :year, :watch_with, :watch_when, :genre, :review, :stars, :rating, :language, :url, :is_latest, :is_best
3
+
4
+ @@all = []
5
+
6
+ def initialize(movie_hash)
7
+ movie_hash.each {|key, value| self.send(("#{key}="), value)}
8
+ @@all << self
9
+ end
10
+
11
+ def self.create_from_list(movies)
12
+ movies.each do |movie|
13
+ film = MovieHelper::Movie.new(movie)
14
+ end
15
+ end
16
+
17
+ def self.all
18
+ @@all
19
+ end
20
+
21
+ def self.best_films
22
+ @@all.select {|movie| movie.is_best == true}
23
+ end
24
+
25
+ def self.latest
26
+ @@all.select {|movie| movie.is_latest == true}
27
+ end
28
+
29
+
30
+ end