boxoffice-cli-gem 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: e700e5893eea2cbcdea81076eda669462f6fcf9e152f5d5799764ed4ea9f55c4
4
+ data.tar.gz: 0033959391cfd78e0bdaaca559f07fc185a249ec7e91b8c09247f2ad3fa20f76
5
+ SHA512:
6
+ metadata.gz: bb0e1ffaea61dbe7fdf479e7b8720d6930f6dd453c891e79bff51f92f69c86edf20ec659b5276277393b537d0c4230b177d2c5a569f9278e1b433f9a1288bb4e
7
+ data.tar.gz: adb13af26633d1dfb4d1f752cace716e54305d677c98ef13a5f009016adbd7911fb0f65d5e81594fb8196e2d5a271ebb257128b8c7d9aaf1c89fdc4f04e04d32
data/.gitignore ADDED
@@ -0,0 +1,8 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
@@ -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
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in boxoffice-cli-gem.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,45 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ boxoffice-cli-gem (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.0)
12
+ mini_portile2 (2.3.0)
13
+ nokogiri (1.8.1)
14
+ mini_portile2 (~> 2.3.0)
15
+ pry (0.11.3)
16
+ coderay (~> 1.1.0)
17
+ method_source (~> 0.9.0)
18
+ rake (10.4.2)
19
+ rspec (3.7.0)
20
+ rspec-core (~> 3.7.0)
21
+ rspec-expectations (~> 3.7.0)
22
+ rspec-mocks (~> 3.7.0)
23
+ rspec-core (3.7.0)
24
+ rspec-support (~> 3.7.0)
25
+ rspec-expectations (3.7.0)
26
+ diff-lcs (>= 1.2.0, < 2.0)
27
+ rspec-support (~> 3.7.0)
28
+ rspec-mocks (3.7.0)
29
+ diff-lcs (>= 1.2.0, < 2.0)
30
+ rspec-support (~> 3.7.0)
31
+ rspec-support (3.7.0)
32
+
33
+ PLATFORMS
34
+ ruby
35
+
36
+ DEPENDENCIES
37
+ boxoffice-cli-gem!
38
+ bundler (~> 1.16)
39
+ nokogiri
40
+ pry
41
+ rake (~> 10.0)
42
+ rspec
43
+
44
+ BUNDLED WITH
45
+ 1.16.0
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 rubyweiner
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,25 @@
1
+ # BoxOffice-Cli-Gem
2
+
3
+ The BoxOffice-Cli-Gem uses a CLI to display the current top 3 box office movies and their Rotten Tomatoes score according to the Rotten Tomatoes website. The User is prompted to select one of the three for more information on the movie including audience score and a 'Critic Consensus' description.
4
+
5
+ ## Installation
6
+
7
+ $ gem install boxoffice-cli-gem
8
+
9
+ ## Usage
10
+
11
+ Run 'bestmovies' after installing 'boxoffice-cli-gem'
12
+
13
+ ## Development
14
+
15
+ 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.
16
+
17
+ 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).
18
+
19
+ ## Contributing
20
+
21
+ Bug reports and pull requests are welcome on GitHub at https://github.com/'rubyweiner796-42993'/boxoffice-cli-gem. 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.
22
+
23
+ ## License
24
+
25
+ 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,10 @@
1
+ #require "bundler/gem_tasks"
2
+ #task :default => :spec
3
+
4
+
5
+ require "bundler/gem_tasks"
6
+ require "rspec/core/rake_task"
7
+
8
+ RSpec::Core::RakeTask.new(:spec)
9
+
10
+ task :default => :spec
data/bin/bestmovies ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require_relative '../lib/boxoffice'
4
+
5
+ BoxOffice::CLI.new.call
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "boxoffice"
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/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,39 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "boxoffice/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "boxoffice-cli-gem"
8
+ spec.version = BoxOffice::VERSION
9
+ spec.authors = ["'Ruby Weiner'"]
10
+ spec.email = ["'rubyweiner796@me.com'"]
11
+
12
+ spec.summary = "List of top 3 box office movies"
13
+ spec.description = "List of today's top 3 box office movies includes Rotton Tomato score, audience score, and a short description of the movie."
14
+ spec.homepage = "https://github.com/rubyweiner/box-office-cli-gem"
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"] = "TODO: Set to 'http://mygemserver.com'"
21
+ #else
22
+ # raise "RubyGems 2.0 or newer is required to protect against " \
23
+ # "public gem pushes."
24
+ #end
25
+
26
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
27
+ f.match(%r{^(test|spec|features)/})
28
+ end
29
+ spec.bindir = "bin"
30
+ spec.executables = 'bestmovies'
31
+ spec.require_paths = ["lib"]
32
+
33
+ spec.add_development_dependency "bundler", "~> 1.16"
34
+ spec.add_development_dependency "rake", "~> 10.0"
35
+ spec.add_development_dependency "rspec"
36
+ spec.add_development_dependency "pry"
37
+
38
+ spec.add_development_dependency "nokogiri" "~> 0"
39
+ end
@@ -0,0 +1,37 @@
1
+ class BoxOffice::CLI
2
+
3
+ def call
4
+ list_movies
5
+ options
6
+ goodbye
7
+ end
8
+
9
+ def list_movies
10
+ puts "Today's Top 3 Box Office Movies:"
11
+ @top_three = BoxOffice::Movies.today
12
+ @top_three.each.with_index(1) do |movie, i|
13
+ puts "#{i}. '#{movie.name}' - Rotton Tomatoes: #{movie.rt_score}"
14
+ end
15
+ end
16
+
17
+ def options
18
+ input = nil
19
+ while input != "exit"
20
+ puts "Type in the number of the movie you'd like more information on. Type 'list' to see today's top 3 box office movies again. Type 'exit' to quit at any time."
21
+ input = gets.strip
22
+ if input.to_i > 0 && input.to_i < 4
23
+ movie = @top_three[input.to_i - 1]
24
+ puts "'#{movie.name}'"
25
+ puts "Rotton Tomatoes: #{movie.rt_score}"
26
+ puts "Audience Score: #{movie.a_score}"
27
+ puts "#{movie.cc}"
28
+ elsif input == "list"
29
+ list_movies
30
+ end
31
+ end
32
+ end
33
+
34
+ def goodbye
35
+ puts "Thank you for using the boxoffice-cli-gem!"
36
+ end
37
+ end
@@ -0,0 +1,43 @@
1
+ class BoxOffice::Movies
2
+ attr_accessor :name, :rt_score, :url, :top_three, :cc, :a_score
3
+
4
+
5
+ def self.today
6
+ self.mov_info
7
+ self.more_info
8
+ end
9
+
10
+
11
+ def self.mov_info
12
+ doc1 = Nokogiri::HTML(open("https://www.rottentomatoes.com/"))
13
+
14
+ movie_1 = self.new
15
+ movie_1.name = doc1.css("#homepage-top-box-office .movie_list .middle_col")[0].text.strip
16
+ movie_1.rt_score = doc1.css("#homepage-top-box-office .movie_list .left_col")[0].text.strip
17
+ movie_1.url = doc1.css("#homepage-top-box-office .movie_list .middle_col a")[0].attr("href")
18
+
19
+ movie_2 = self.new
20
+ movie_2.name = doc1.css("#homepage-top-box-office .movie_list .middle_col")[1].text.strip
21
+ movie_2.rt_score = doc1.css("#homepage-top-box-office .movie_list .left_col")[1].text.strip
22
+ movie_2.url = doc1.css("#homepage-top-box-office .movie_list .middle_col a")[1].attr("href")
23
+
24
+ movie_3 = self.new
25
+ movie_3.name = doc1.css("#homepage-top-box-office .movie_list .middle_col")[2].text.strip
26
+ movie_3.rt_score = doc1.css("#homepage-top-box-office .movie_list .left_col")[2].text.strip
27
+ movie_3.url = doc1.css("#homepage-top-box-office .movie_list .middle_col a")[2].attr("href")
28
+
29
+ [movie_1, movie_2, movie_3]
30
+ end
31
+
32
+
33
+ def self.more_info
34
+ top_three = self.mov_info
35
+ top_three.each.with_index do |movie, i|
36
+ doc2 = Nokogiri::HTML(open("https://www.rottentomatoes.com#{top_three[i.to_i].url}"))
37
+ top_three[i.to_i].cc = doc2.css("#scorePanel .col-full-xs").text.strip
38
+ top_three[i.to_i].a_score = doc2.css("#scorePanel .audience-score .media-body .meter-value").text.strip
39
+ end
40
+ end
41
+
42
+
43
+ end
@@ -0,0 +1,3 @@
1
+ module BoxOffice
2
+ VERSION = "0.1.0"
3
+ end
data/lib/boxoffice.rb ADDED
@@ -0,0 +1,7 @@
1
+ require 'open-uri'
2
+ require 'pry'
3
+ require 'nokogiri'
4
+
5
+ require_relative "./boxoffice/version"
6
+ require_relative './boxoffice/cli'
7
+ require_relative './boxoffice/movies'
metadata ADDED
@@ -0,0 +1,131 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: boxoffice-cli-gem
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - "'Ruby Weiner'"
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-12-21 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.16'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.16'
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: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: pry
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: nokogiri~> 0
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: List of today's top 3 box office movies includes Rotton Tomato score,
84
+ audience score, and a short description of the movie.
85
+ email:
86
+ - "'rubyweiner796@me.com'"
87
+ executables:
88
+ - bestmovies
89
+ extensions: []
90
+ extra_rdoc_files: []
91
+ files:
92
+ - ".gitignore"
93
+ - CODE_OF_CONDUCT.md
94
+ - Gemfile
95
+ - Gemfile.lock
96
+ - LICENSE.txt
97
+ - README.md
98
+ - Rakefile
99
+ - bin/bestmovies
100
+ - bin/console
101
+ - bin/setup
102
+ - boxoffice-cli-gem.gemspec
103
+ - lib/boxoffice.rb
104
+ - lib/boxoffice/cli.rb
105
+ - lib/boxoffice/movies.rb
106
+ - lib/boxoffice/version.rb
107
+ homepage: https://github.com/rubyweiner/box-office-cli-gem
108
+ licenses:
109
+ - MIT
110
+ metadata: {}
111
+ post_install_message:
112
+ rdoc_options: []
113
+ require_paths:
114
+ - lib
115
+ required_ruby_version: !ruby/object:Gem::Requirement
116
+ requirements:
117
+ - - ">="
118
+ - !ruby/object:Gem::Version
119
+ version: '0'
120
+ required_rubygems_version: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ requirements: []
126
+ rubyforge_project:
127
+ rubygems_version: 2.7.2
128
+ signing_key:
129
+ specification_version: 4
130
+ summary: List of top 3 box office movies
131
+ test_files: []