now_showing 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 250895a2f19c202e8d5283fcb1be122aaf1b3ffd
4
+ data.tar.gz: 8b09d868c6e5b6b914cd92446c8adc4f6d61a711
5
+ SHA512:
6
+ metadata.gz: ce345b3c447db3679970ce49f5f1705127cf573eae6c4cb855b358302fc84e586c979c2b9ecb4be770b1cf09503cb8439bbceabee021a955ab6fd968945c7ea7
7
+ data.tar.gz: 882aa11f0d71dbc80682d58c9243765d97f93532ed19fa9a562e00156d7b3560476f336ad978ce2d4d681d772759ed0f7573ea04600cb942203673d75ada2d32
data/.gitignore ADDED
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+
11
+ # rspec failure tracking
12
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.2.3
5
+ before_install: gem install bundler -v 1.14.5
@@ -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 vineshpersaud@gmail.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 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in now_showing.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 codeesh
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,36 @@
1
+ # NowShowing
2
+
3
+
4
+ Welcome to now showing gem! This Gem is a CLI that shows the current top ten movies and movies opening this week.You can also view a summary and metascore of these movies .All the information about the movies are scraped from IMDB.com
5
+
6
+
7
+ ## Installation
8
+
9
+ Install by entering:
10
+
11
+ ```ruby
12
+ gem 'now_showing'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ now_showing
18
+
19
+ ## Usage
20
+
21
+
22
+
23
+ ## Development
24
+
25
+ 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.
26
+
27
+ 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).
28
+
29
+ ## Contributing
30
+
31
+ Bug reports and pull requests are welcome on GitHub at https://github.com/codeesh/now_showing. 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.
32
+
33
+
34
+ ## License
35
+
36
+ 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,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 "now_showing"
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/now-showing ADDED
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "./lib/now_showing"
5
+
6
+ NowShowing::CLI.new.call
7
+
8
+ #NowShowing::Show.scrape_now_showing
9
+ #NowShowing::Opening.scrape
10
+
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,9 @@
1
+ require 'open-uri'
2
+ require 'nokogiri'
3
+ require 'pry'
4
+
5
+
6
+ require_relative "../lib/now_showing/version"
7
+ require_relative "../lib/now_showing/showing"
8
+ require_relative "../lib/now_showing/opening"
9
+ require_relative "../lib/now_showing/cli"
@@ -0,0 +1,126 @@
1
+ class NowShowing::CLI
2
+ def call
3
+ welcome
4
+ menu
5
+ end
6
+
7
+ def welcome
8
+ puts "Welcome to Now Showing"
9
+ puts "What would you like to found out about?"
10
+ puts ""
11
+ puts "1. Top ten movies in theathers now"
12
+ puts "2. Movings opening this week"
13
+ puts ""
14
+ end
15
+
16
+ def menu
17
+ input = nil
18
+ print "Please enter the number for the option you would like to see or exit to quit gem."
19
+ input = gets.strip.downcase
20
+
21
+ if input == "1"
22
+ top
23
+ elsif input == "2"
24
+ opening
25
+ elsif input == "exit"
26
+ goodbye
27
+ else
28
+ print "Please enter a valid option of 1/2 or exit. "
29
+ menu
30
+ end
31
+ end
32
+
33
+ def top
34
+ #Scrapes imdb.com for top ten movies and create array of instances of movies.
35
+ NowShowing::Show.scrape_now_showing
36
+ #puts list of top ten movies
37
+ puts "The current top ten movies are:"
38
+ puts " Title | Gross | Weekend "
39
+ puts ''
40
+
41
+ NowShowing::Show.all.each_with_index do |movie ,index|
42
+ puts "#{index+1}. #{movie.name.strip.ljust(40)}| #{movie.gross.ljust(15)}| #{movie.weekend.ljust(15)}"
43
+ # format text using .ljust
44
+ end
45
+ #puts option to show extended info about movie by inputing movie number
46
+ input = nil
47
+ puts ""
48
+ print "Would you like more info about a movie if so enter the movie number else type exit/return. "
49
+
50
+ while input != "exit"
51
+ input = gets.strip.downcase
52
+ if input.to_i.between?(1, 10)
53
+ movie = NowShowing::Show.all[input.to_i-1]
54
+ #scrapes addtional movie info if not already scraped
55
+ NowShowing::Show.more_info(movie) if movie.about == nil || movie.metascore == nil
56
+ puts " -------------------------------------------------------------------------------- "
57
+ puts "#{movie.name}"
58
+ puts ""
59
+ puts "Metascore: #{movie.metascore}"
60
+ puts ""
61
+ puts "#{movie.about} "
62
+ puts " -------------------------------------------------------------------------------- "
63
+ puts ""
64
+ print "Please select another movie you would like more info on or you can return at exit. "
65
+ elsif input == "return"
66
+ # exits this loop and clears array to reset it
67
+ input = "exit"
68
+ NowShowing::Show.reset
69
+ self.call
70
+ elsif input == "exit"
71
+ goodbye
72
+ else
73
+ print "Please enter valid a option. "
74
+ end
75
+ end
76
+
77
+ end
78
+
79
+ def opening
80
+ NowShowing::Opening.scrape
81
+ #puts list of top ten movies
82
+ puts "Movies opening this week are:"
83
+ puts " Title "
84
+ puts ''
85
+ NowShowing::Opening.all.each_with_index do |movie,index|
86
+ puts "#{index+1}. #{movie.name.ljust(35)}"
87
+ end
88
+ puts ""
89
+ print "Please select a movie by number you would like more info on or you can return at exit. "
90
+ input = nil
91
+ while input != "exit"
92
+ input = gets.strip.downcase
93
+ #if (1..NowShowing::Opening.all.length).to_a.include?(input.to_i)
94
+ if input.to_i.between?(1, NowShowing::Opening.all.count)
95
+ movie = NowShowing::Opening.all[input.to_i-1]
96
+ puts " -------------------------------------------------------------------------------- "
97
+ puts "#{movie.name}"
98
+ puts ""
99
+ puts "Metascore: #{movie.metascore}"
100
+ puts ""
101
+ puts "#{movie.about} "
102
+ puts ""
103
+ puts " -------------------------------------------------------------------------------- "
104
+ puts ""
105
+ print "Please select another movie you would like more info on or you can return at exit. "
106
+ elsif input == "return"
107
+ # exits this loop and clears array to reset it
108
+ input = "exit"
109
+ NowShowing::Opening.reset
110
+ self.call
111
+ elsif input == "exit"
112
+ goodbye
113
+ else
114
+ print "Please enter valid a option."
115
+ end
116
+ end
117
+
118
+ end
119
+
120
+ def goodbye
121
+ puts ""
122
+ puts "Thank you for using Now Showing gem. Bye!"
123
+ end
124
+
125
+
126
+ end
@@ -0,0 +1,40 @@
1
+ class NowShowing::Opening
2
+
3
+ attr_accessor :name,:about,:metascore
4
+
5
+ @@all=[]
6
+
7
+ def initialize(name,about,metascore)
8
+ @name=name
9
+ @about=about
10
+ @metascore=metascore
11
+ @@all << self
12
+ end
13
+
14
+ def self.scrape
15
+ doc = Nokogiri::HTML(open("http://www.imdb.com/movies-in-theaters/"))
16
+ doc.css(".list_item").each do |movie|
17
+ name = movie.css(".overview-top").css('h4').text.split(" ")[0..-2].join(" ")
18
+ about = movie.css('.outline').text.strip
19
+ metascore = movie.css('.metascore').text.strip
20
+ metascore = "Metacritic score not yet available" if metascore == ""
21
+ self.new(name,about,metascore)
22
+
23
+ end
24
+ #remove last ten form list which are the weeks top ten
25
+
26
+ @@all = @@all[0..-11]
27
+ end
28
+
29
+
30
+ def self.all
31
+ @@all
32
+ end
33
+
34
+ def self.reset
35
+ self.all.clear
36
+ end
37
+
38
+
39
+
40
+ end
@@ -0,0 +1,47 @@
1
+ class NowShowing::Show
2
+
3
+ attr_accessor :name, :weekend,:gross,:link,:about,:metascore
4
+
5
+ @@all=[]
6
+
7
+ def initialize(name,weekend,gross,link,about=nil,metascore=nil)
8
+ @name=name
9
+ @weekend=weekend
10
+ @gross=gross
11
+ @link=link
12
+ @about=about
13
+ @metascore=metascore
14
+ @@all << self
15
+ end
16
+
17
+ def self.scrape_now_showing
18
+ doc = Nokogiri::HTML(open("http://www.imdb.com/chart/boxoffice?ref_=nv_ch_cht_1 "))
19
+ doc.css("#boxoffice").css('tr').each do |movie|
20
+ #checks if the table row contains movie info
21
+ if movie.css('.ratingColumn')[0] && movie.css('.titleColumn') && movie.css('.ratingColumn')[1]
22
+ name = movie.css('.titleColumn').text.gsub("\n",' ').squeeze(' ')
23
+ weekend = movie.css('.ratingColumn')[0].text.gsub("\n",' ').squeeze(' ')
24
+ gross = movie.css('.ratingColumn')[1].text.gsub("\n",' ').squeeze(' ')
25
+ link="http://www.imdb.com#{movie.css(".posterColumn").css('td')[0].css('a')[0]['href']}"
26
+ self.new(name,weekend,gross,link)
27
+ end
28
+ end
29
+ end
30
+
31
+
32
+ def self.all
33
+ @@all
34
+ end
35
+
36
+ def self.reset
37
+ self.all.clear
38
+ end
39
+
40
+ #scrapes movie page for addtional movie info
41
+ def self.more_info(movie)
42
+ doc = Nokogiri::HTML(open(movie.link))
43
+ movie.about = doc.css('.summary_text').text.gsub("\n",' ').squeeze(' ')
44
+ movie.metascore = doc.css('.metacriticScore').text.gsub("\n",' ').squeeze(' ')
45
+ end
46
+
47
+ end
@@ -0,0 +1,3 @@
1
+ module NowShowing
2
+ VERSION = "0.2.0"
3
+ end
@@ -0,0 +1,4 @@
1
+ module NowShowing
2
+ end
3
+
4
+ require_relative '../config/environment'
@@ -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 'now_showing/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "now_showing"
8
+ spec.version = NowShowing::VERSION
9
+ spec.authors = ["vineshp"]
10
+ spec.email = ["vinesh.persaud@gmail.com"]
11
+
12
+ spec.summary = %q{ Shows current top ten movies and movies opening this week.}
13
+ spec.description = %q{ }
14
+ spec.homepage = "http://codeesh.github.io/"
15
+ spec.license = "MIT"
16
+ spec.files = ["./lib/now_showing.rb","./lib/now_showing/cli.rb","./lib/now_showing/opening.rb","./lib/now_showing/showing.rb", "config/environment.rb"]
17
+ spec.executables << 'now-showing'
18
+
19
+
20
+
21
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
22
+ f.match(%r{^(test|spec|features)/})
23
+ end
24
+
25
+ spec.require_paths = ["lib"]
26
+
27
+
28
+ spec.add_development_dependency "bundler", "~> 1.10"
29
+ spec.add_development_dependency "rake", "~> 10.0"
30
+ spec.add_development_dependency 'rspec'
31
+ spec.add_development_dependency 'pry'
32
+ spec.add_dependency 'nokogiri'
33
+ end
data/spec.md ADDED
@@ -0,0 +1,7 @@
1
+ # Specifications for the CLI Assessment
2
+
3
+ Specs:
4
+ - [x] Have a CLI for interfacing with the application
5
+ - [x] Pull data from an external source
6
+ - [x] Implement both list and detail views
7
+
metadata ADDED
@@ -0,0 +1,134 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: now_showing
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.0
5
+ platform: ruby
6
+ authors:
7
+ - vineshp
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-10-24 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.10'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.10'
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
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: " "
84
+ email:
85
+ - vinesh.persaud@gmail.com
86
+ executables:
87
+ - now-showing
88
+ extensions: []
89
+ extra_rdoc_files: []
90
+ files:
91
+ - ".gitignore"
92
+ - ".rspec"
93
+ - ".travis.yml"
94
+ - CODE_OF_CONDUCT.md
95
+ - Gemfile
96
+ - LICENSE.txt
97
+ - README.md
98
+ - Rakefile
99
+ - bin/console
100
+ - bin/now-showing
101
+ - bin/setup
102
+ - config/environment.rb
103
+ - lib/now_showing.rb
104
+ - lib/now_showing/cli.rb
105
+ - lib/now_showing/opening.rb
106
+ - lib/now_showing/showing.rb
107
+ - lib/now_showing/version.rb
108
+ - now_showing.gemspec
109
+ - spec.md
110
+ homepage: http://codeesh.github.io/
111
+ licenses:
112
+ - MIT
113
+ metadata: {}
114
+ post_install_message:
115
+ rdoc_options: []
116
+ require_paths:
117
+ - lib
118
+ required_ruby_version: !ruby/object:Gem::Requirement
119
+ requirements:
120
+ - - ">="
121
+ - !ruby/object:Gem::Version
122
+ version: '0'
123
+ required_rubygems_version: !ruby/object:Gem::Requirement
124
+ requirements:
125
+ - - ">="
126
+ - !ruby/object:Gem::Version
127
+ version: '0'
128
+ requirements: []
129
+ rubyforge_project:
130
+ rubygems_version: 2.6.10
131
+ signing_key:
132
+ specification_version: 4
133
+ summary: Shows current top ten movies and movies opening this week.
134
+ test_files: []