dustin-anderson-cli-app 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
+ SHA1:
3
+ metadata.gz: 5a521a474e6ba3059f5f1845a4c70f5896a9396c
4
+ data.tar.gz: ed62e77443d4a5b0ee243bd005b97aa4488fcf37
5
+ SHA512:
6
+ metadata.gz: 44a460b4a548a9fd87e40e71cf736320fc8462c2b42555f54f98ab0461fa177224f9bfad5609efd69428899f3d8f162d017fe25bf653bdbbaaf02d73be217092
7
+ data.tar.gz: 1c4fcad81a2042fa53c16b3123afc9cbab0907ae24d0b01a8df407347f379502a6b34890f64de7cc9ab974790c4c030998230c95611507853a7162960e1c9932
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
@@ -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 'dandersonsoftware@outlook.com'. 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,4 @@
1
+ source 'http://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in dustin-anderson-cli-app.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 'Dustin Anderson'
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,37 @@
1
+ # DustinAndersonCLIApp
2
+
3
+ This is a CLI application that takese date from Rotten Tomatoes top 100 movie list and gives the user details on each movie.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'dustin-anderson-cli-app'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install dustin-anderson-cli-app
20
+
21
+ ## Development
22
+
23
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
24
+
25
+ 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).
26
+
27
+ ## Usage
28
+ To run the program enter ./bin/console from the correct directory
29
+
30
+ ## Contributing
31
+
32
+ Bug reports and pull requests are welcome on GitHub at https://github.com/'dandersonsoftware-67227'/dustin-anderson-cli-app. 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.
33
+
34
+
35
+ ## License
36
+
37
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require './config/environment'
5
+ require 'pry'
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ DustinAndersonCLIApp::Controller.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,3 @@
1
+ require './lib/dustin_anderson_cli_app'
2
+ require './lib/movie_scraper'
3
+ require './lib/CLI_class'
@@ -0,0 +1,31 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require_relative './lib/app/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'dustin-anderson-cli-app'
8
+ spec.version = DustinAndersonCLIApp::VERSION
9
+ spec.authors = 'Dustin Anderson'
10
+ spec.email = 'dandersonsoftware@out0look.com'
11
+
12
+ spec.summary = 'Provides information about Rotten Tomatoes top 100 movies.'
13
+ spec.homepage = 'https://github.com/TheDreamingTree145/dustin-anderson-cli-app'
14
+ spec.license = 'MIT'
15
+
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
+
20
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
21
+ f.match(%r{^(test|spec|features)/})
22
+ end
23
+ spec.bindir = "exe"
24
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
25
+ spec.require_paths = ["lib"]
26
+
27
+ spec.add_development_dependency "bundler", "~> 1.14"
28
+ spec.add_development_dependency "rake", "~> 10.0"
29
+ spec.add_development_dependency 'pry', '~> 0.10.3'
30
+ spec.add_development_dependency 'nokogiri', '~> 1.6', '>= 1.6.8'
31
+ end
data/lib/CLI_class.rb ADDED
@@ -0,0 +1,53 @@
1
+ require_relative './movie_scraper'
2
+ require_relative './dustin_anderson_cli_app'
3
+
4
+ module DustinAndersonCLIApp
5
+ class Controller
6
+ attr_accessor :movie_scraper, :movie
7
+
8
+ OPTIONS = "Here are your options for lists: \n" "To see the top 10 enter: 'top 10'\n" "To see the top 25 enter: 'top 25'\n" "To see the top 50 enter: 'top 50'\n" "To see the full list enter: 'list'\n" "To see a random movie summary from the list enter 'random'\n" "To leave the program enter 'exit'\n\n"
9
+
10
+ SUMMARY_REMINDER = "\nIf you would like to see a movie summary, enter 'movie summary' and then the rank of the movie you would like the summary of.\n\n"
11
+
12
+ WELCOME = "Welcome to Rotten Tomatoes top 100 movies! This will list the rank, title, rating, and the number of reviews on Rotten Tomatoes. Once you choose how many movies to see at once, just input the rank of the movie to see the movie summary. At any time you can type 'exit' to quit the program, or options for a list of options. Each list will put the film rank, title, Rotten Tomato ranking, and the number of reviews.\n\n"
13
+
14
+ def call
15
+
16
+ puts WELCOME
17
+ puts OPTIONS
18
+ input = ""
19
+ scrape = MovieScraper.new
20
+ scrape.new_with_attributes
21
+ while input.downcase != 'exit'
22
+ input = gets.chomp
23
+ if input.downcase == 'top 10'
24
+ DustinAndersonCLIApp::Movie.top_ten
25
+ puts SUMMARY_REMINDER
26
+ puts OPTIONS
27
+ elsif input.downcase == 'top 25'
28
+ DustinAndersonCLIApp::Movie.top_twentyfive
29
+ puts SUMMARY_REMINDER
30
+ puts OPTIONS
31
+ elsif input.downcase == 'top 50'
32
+ DustinAndersonCLIApp::Movie.top_fifty
33
+ puts SUMMARY_REMINDER
34
+ puts OPTIONS
35
+ elsif input.downcase == 'list'
36
+ DustinAndersonCLIApp::Movie.list_all
37
+ puts SUMMARY_REMINDER
38
+ puts OPTIONS
39
+ elsif input.downcase == 'options'
40
+ puts OPTIONS
41
+ elsif input.downcase == 'movie summary'
42
+ DustinAndersonCLIApp::Movie.movie_summary #
43
+ elsif input.downcase == 'random'
44
+ DustinAndersonCLIApp::Movie.random_movie_summary
45
+ puts "\n#{OPTIONS}"
46
+ else puts OPTIONS
47
+ end
48
+ end
49
+ end
50
+
51
+
52
+ end
53
+ end
@@ -0,0 +1,4 @@
1
+ module DustinAndersonCLIApp
2
+ VERSION = "0.1.0"
3
+ end
4
+
@@ -0,0 +1,93 @@
1
+ require "./lib/app/version"
2
+
3
+ module DustinAndersonCLIApp
4
+ class Movie
5
+ attr_accessor :rank, :title, :rating, :reviews, :summary, :parental, :genre, :theatre_date, :studio, :movie_scraper
6
+ @@all = []
7
+ OPTIONS = "Here are your options for lists: \n" "To see the top 10 enter: 'top 10'\n" "To see the top 25 enter: 'top 25'\n" "To see the top 50 enter: 'top 50'\n" "To see the full list enter: 'list'\n" "To see a random movie summary from the list enter 'random'\n" "To leave the program enter 'exit'\n\n"
8
+
9
+ def initialize(rank = nil, title = nil, rating = nil, reviews = nil, summary = nil, parental = nil, genre = nil, theatre_date = nil, studio = nil)
10
+ @rank = rank
11
+ @title = title
12
+ @rating = rating
13
+ @reviews = reviews
14
+ @summary = summary
15
+ @parental = parental
16
+ @genre = genre
17
+ @theatre_date = theatre_date
18
+ @studio = studio
19
+ @@all << self
20
+ end
21
+
22
+ def self.all
23
+ @@all
24
+ end
25
+
26
+ def self.top_ten
27
+ DustinAndersonCLIApp::Movie.all[0..9].each do |film|
28
+ puts "#{film.rank}. #{film.title} #{film.rating} #{film.reviews}"
29
+ end
30
+ end
31
+
32
+ def self.top_twentyfive
33
+ DustinAndersonCLIApp::Movie.all[0..24].each do |film|
34
+ puts "#{film.rank}. #{film.title} #{film.rating} #{film.reviews}"
35
+ end
36
+ end
37
+
38
+ def self.top_fifty
39
+ DustinAndersonCLIApp::Movie.all[0..49].each do |film|
40
+ puts "#{film.rank}. #{film.title} #{film.rating} #{film.reviews}"
41
+ end
42
+ end
43
+
44
+ def self.list_all
45
+ DustinAndersonCLIApp::Movie.all[0..99].each do |film|
46
+ puts "#{film.rank}. #{film.title} #{film.rating} #{film.reviews}"
47
+ end
48
+ end
49
+
50
+ def self.movie_summary
51
+ another_summary = 'yes'
52
+ while another_summary != 'options'
53
+ if another_summary == 'exit'
54
+ break
55
+ end
56
+ puts "Please enter the rank of the move you would like the summary of: "
57
+ summary_input = gets.chomp
58
+ if summary_input == 'exit'
59
+ break
60
+ end
61
+ if summary_input.to_i >= 1 && summary_input.to_i <= 100
62
+ self.all.each do |film|
63
+ if film.rank == summary_input
64
+ puts "#{film.title}:"
65
+ puts film.summary
66
+ puts "\nIf you would like a few more details about the movie enter 'more'.If you wnat another movie summary enter 'yes'. Else type 'options' for list of options."
67
+ another_summary = gets.downcase.chomp
68
+ if another_summary == 'more'
69
+ puts "#{film.title}: "
70
+ puts " Parental Rating: #{film.parental}\n Film Genre: #{film.genre}\n In Theatres: #{film.theatre_date}\n Studio: #{film.studio}\n"
71
+ puts "\n.If you want another movie summary enter 'yes'. Else type 'options' for list of options."
72
+ another_summary = gets.downcase.chomp
73
+ if another_summary == 'options'
74
+ break
75
+ end
76
+ end
77
+ end
78
+ end
79
+ end
80
+ end
81
+ puts "\n#{OPTIONS}"
82
+ end
83
+
84
+ def self.random_movie_summary
85
+ random_movie_summary = self.all.sample
86
+ puts "#{random_movie_summary.title} #{random_movie_summary.rank}: "
87
+ puts "#{random_movie_summary.summary}\n"
88
+ end
89
+
90
+
91
+
92
+ end
93
+ end
@@ -0,0 +1,34 @@
1
+
2
+ require 'pry'
3
+ require 'nokogiri'
4
+ require 'open-uri'
5
+ require_relative './dustin_anderson_cli_app'
6
+
7
+ class MovieScraper
8
+ attr_accessor :movie
9
+ BASE_RT_URL = 'https://www.rottentomatoes.com/'
10
+
11
+ def get_main_page
12
+ doc = Nokogiri::HTML(open('https://www.rottentomatoes.com/top/bestofrt/'))
13
+ end
14
+
15
+ def new_with_attributes
16
+ self.get_main_page.css(".table tr").drop(1).each do |row|
17
+ movie = DustinAndersonCLIApp::Movie.new
18
+ movie.rank = row.css(".bold").text.delete!(".")
19
+ movie.rating = row.css(".tMeterScore").text.gsub!(/\u00A0/, "")
20
+ movie.title = row.css(".unstyled").text
21
+ movie.title.strip!
22
+ movie.reviews = row.css(".right").text
23
+ link = row.css("a").attribute("href").value.sub("/", "")
24
+ details_doc = BASE_RT_URL + link
25
+ open_details_doc = Nokogiri::HTML(open(details_doc))
26
+ movie.summary = open_details_doc.css(".movie_synopsis").text.strip!
27
+ movie.parental = open_details_doc.css(".meta-value").first.text
28
+ movie.genre = open_details_doc.css(".meta-value a").first.text.strip!
29
+ movie.theatre_date = open_details_doc.css(".meta-value time").first.text
30
+ movie.studio = open_details_doc.css("div.meta-value").last.text.strip
31
+ end
32
+ DustinAndersonCLIApp::Movie.all
33
+ end
34
+ end
metadata ADDED
@@ -0,0 +1,119 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: dustin-anderson-cli-app
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Dustin Anderson
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-06-25 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.14'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.14'
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: pry
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 0.10.3
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 0.10.3
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.6'
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ version: 1.6.8
65
+ type: :development
66
+ prerelease: false
67
+ version_requirements: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - "~>"
70
+ - !ruby/object:Gem::Version
71
+ version: '1.6'
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: 1.6.8
75
+ description:
76
+ email: dandersonsoftware@out0look.com
77
+ executables: []
78
+ extensions: []
79
+ extra_rdoc_files: []
80
+ files:
81
+ - ".gitignore"
82
+ - CODE_OF_CONDUCT.md
83
+ - Gemfile
84
+ - LICENSE.txt
85
+ - README.md
86
+ - Rakefile
87
+ - bin/console
88
+ - bin/setup
89
+ - config/environment.rb
90
+ - dustin-anderson-cli-app.gemspec
91
+ - lib/CLI_class.rb
92
+ - lib/app/version.rb
93
+ - lib/dustin_anderson_cli_app.rb
94
+ - lib/movie_scraper.rb
95
+ homepage: https://github.com/TheDreamingTree145/dustin-anderson-cli-app
96
+ licenses:
97
+ - MIT
98
+ metadata: {}
99
+ post_install_message:
100
+ rdoc_options: []
101
+ require_paths:
102
+ - lib
103
+ required_ruby_version: !ruby/object:Gem::Requirement
104
+ requirements:
105
+ - - ">="
106
+ - !ruby/object:Gem::Version
107
+ version: '0'
108
+ required_rubygems_version: !ruby/object:Gem::Requirement
109
+ requirements:
110
+ - - ">="
111
+ - !ruby/object:Gem::Version
112
+ version: '0'
113
+ requirements: []
114
+ rubyforge_project:
115
+ rubygems_version: 2.6.11
116
+ signing_key:
117
+ specification_version: 4
118
+ summary: Provides information about Rotten Tomatoes top 100 movies.
119
+ test_files: []