movie_gem 0.1.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
+ SHA256:
3
+ metadata.gz: 0d0069098bfdddef01f127bd04a6ffccb28edbeb412c41ebc0a36cfa12843872
4
+ data.tar.gz: 88340144496454b618319e2cb8380813dc63781728a4a2739cb99cb71d446840
5
+ SHA512:
6
+ metadata.gz: 8a0bc3fe3df93e14a758b204968db2703ff6fb49fb1eab2166a464accaad7f1b819e19a83d951a71398e2469ee31dbf1aaab958b2c7c7a85c2d7fcee4ae2ced8
7
+ data.tar.gz: f59cea908330394637fc48310045f609ebd87d6a7f6b75891de5b84015530200c31a8f998db9e6c7d106f0fc3fd111be43af08cd99bd59050d7d51472e8f3fb1
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,75 @@
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 digregoriothomas@yahoo.com
59
+ . All
60
+ complaints will be reviewed and investigated and will result in a response that
61
+ is deemed necessary and appropriate to the circumstances. The project team is
62
+ obligated to maintain confidentiality with regard to the reporter of an incident.
63
+ Further details of specific enforcement policies may be posted separately.
64
+
65
+ Project maintainers who do not follow or enforce the Code of Conduct in good
66
+ faith may face temporary or permanent repercussions as determined by other
67
+ members of the project's leadership.
68
+
69
+ ## Attribution
70
+
71
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
72
+ available at [http://contributor-covenant.org/version/1/4][version]
73
+
74
+ [homepage]: http://contributor-covenant.org
75
+ [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 movie_gem.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,30 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ movie_gem (0.1.0)
5
+ nokogiri (~> 1.10.4)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ coderay (1.1.2)
11
+ method_source (0.9.2)
12
+ mini_portile2 (2.4.0)
13
+ nokogiri (1.10.4)
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
+
20
+ PLATFORMS
21
+ ruby
22
+
23
+ DEPENDENCIES
24
+ bundler (~> 2.0)
25
+ movie_gem!
26
+ pry
27
+ rake (~> 10.0)
28
+
29
+ BUNDLED WITH
30
+ 2.0.1
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2019 Thomas DiGregorio
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,43 @@
1
+ # MovieGem
2
+
3
+ This gem basically what it does is display the top 25 sci-fi movies and synopses of all time via a numerical system. after opening the file choose a number to get you desired movie.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'movie_gem'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install movie_gem
20
+
21
+ ## Usage
22
+
23
+ In order to start the CLI run the following command:
24
+
25
+ $ sci-fi
26
+
27
+ ## Development
28
+
29
+ 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.
30
+
31
+ 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).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/movie_gem. 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.
36
+
37
+ ## License
38
+
39
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
40
+
41
+ ## Code of Conduct
42
+
43
+ Everyone interacting in the MovieGem project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/movie_gem/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ require "bundler"
3
+ require "bundler/setup"
4
+ require_relative "../lib/movie_gem"
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__)
15
+
data/bin/sci-fi ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ require_relative '../lib/movie_gem'
3
+ MovieGem::CLI.new.start
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,62 @@
1
+ require 'pry'
2
+
3
+ module MovieGem
4
+ class CLI
5
+ def start
6
+ puts "Welcome to MovieGem"
7
+ Movie.load
8
+ menu
9
+ input = nil
10
+ while @input != "exit"
11
+ @input = gets.chomp
12
+ if @input == "menu"
13
+ menu
14
+ elsif @input == "1"
15
+ movie_list
16
+ puts "display's a list of movies"
17
+ elsif @input == "2"
18
+ display_synopsis
19
+ puts "display_synopsis"
20
+ end
21
+ end
22
+ puts "Thanks for checking out our MovieGem"
23
+ end
24
+ def menu
25
+ puts "Please select from the following options"
26
+ puts "1, Display a list of movies"
27
+ puts "2, Display all synopses"
28
+ puts "To see this list at anytime type 'menu'"
29
+ end
30
+ def movie_list
31
+ @object = Movie.all
32
+ @object.each.with_index(1) do |movie, i|
33
+ puts "#{i}. #{movie.title}"
34
+ end
35
+ prompt_for_movie_choice
36
+
37
+ end
38
+
39
+ def display_synopsis
40
+ @object = Movie.all
41
+ @object.each.with_index(1) do |movie, i|
42
+ puts "#{i}. #{movie.synopsis}"
43
+ end
44
+
45
+ end
46
+ def prompt_for_movie_choice
47
+ puts "Which movie would you like more info about?"
48
+ puts "Pick a number"
49
+ @input = gets.chomp
50
+ index = @input.to_i-1
51
+ if index >= 0
52
+ puts Movie.all[@input.to_i-1].synopsis
53
+ end
54
+ menu
55
+ end
56
+ end
57
+ end
58
+
59
+
60
+
61
+
62
+
@@ -0,0 +1,22 @@
1
+ module MovieGem
2
+ class Movie
3
+ attr_accessor :title, :synopsis
4
+
5
+ def initialize(attributes = {})
6
+ @title = attributes[:title]
7
+ @synopsis = attributes[:synopsis]
8
+ end
9
+ def self.all
10
+ @@all ||= self.load
11
+ end
12
+ def self.create_from_collection(movies_array)
13
+ movies_array.collect do |movie_hash|
14
+ Movie.new(movie_hash)
15
+ end
16
+ end
17
+ def self.load
18
+ create_from_collection(MovieGem::Scraper.scrape_movies)
19
+ end
20
+
21
+ end
22
+ end
@@ -0,0 +1,25 @@
1
+ require 'nokogiri'
2
+ require 'open-uri'
3
+ require 'pry'
4
+
5
+ module MovieGem
6
+ class Scraper
7
+
8
+ def self.scrape_movies
9
+ arr = []
10
+ html = open("https://editorial.rottentomatoes.com/guide/best-sci-fi-movies-of-all-time/4/")
11
+ doc = Nokogiri::HTML(html)
12
+ movies = doc.css ("div.articleContentBody div.countdown-item")
13
+ movies.each do |node|
14
+ movie ={
15
+ title: node.css("div.article_movie_title a").text.strip,
16
+ synopsis: node.css("div.synopsis").text
17
+ }
18
+ arr.push(movie)
19
+ end
20
+ arr
21
+ end
22
+ end
23
+
24
+ end
25
+
@@ -0,0 +1,3 @@
1
+ module MovieGem
2
+ VERSION = "0.1.0"
3
+ end
data/lib/movie_gem.rb ADDED
@@ -0,0 +1,13 @@
1
+ #require 'nokogiri'
2
+ #require 'open-uri'
3
+ #require 'pry'
4
+ #require 'json'
5
+ #require 'colorize'
6
+ require_relative "./movie_gem/version"
7
+ require_relative './movie_gem/scraper'
8
+ require_relative "./movie_gem/CLI"
9
+ require_relative "./movie_gem/movie"
10
+ #module MovieGem
11
+ #class Error < StandardError; end
12
+ # Your code goes here...
13
+ #end
data/movie_gem.gemspec ADDED
@@ -0,0 +1,42 @@
1
+ lib = File.expand_path("../lib", __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require "movie_gem/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "movie_gem"
7
+ spec.version = MovieGem::VERSION
8
+ spec.authors = ["Thomas DiGregorio"]
9
+ spec.email = ["digregoriothomas@yahoo.com\n"]
10
+
11
+ spec.summary = %q{Flatiron Cli Movie}
12
+ spec.description = %q{Displays the top 25 sci-fi movies}
13
+ spec.homepage = "https://github.com/ThomasDiGregorio/movie_gem.git"
14
+ spec.license = "MIT"
15
+
16
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
17
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
18
+ if spec.respond_to?(:metadata)
19
+
20
+
21
+ spec.metadata["homepage_uri"] = spec.homepage
22
+ spec.metadata["source_code_uri"] = "https://github.com/ThomasDiGregorio/movie_gem.git"
23
+ spec.metadata["changelog_uri"] = "https://github.com/ThomasDiGregorio/movie_gem.git"
24
+ else
25
+ raise "RubyGems 2.0 or newer is required to protect against " \
26
+ "public gem pushes."
27
+ end
28
+
29
+ # Specify which files should be added to the gem when it is released.
30
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
31
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
32
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
33
+ end
34
+ #spec.bindir = "exe"
35
+ spec.executables = ["sci-fi"]
36
+ spec.require_paths = ["lib"]
37
+
38
+ spec.add_development_dependency "bundler", "~> 2.0"
39
+ spec.add_development_dependency "rake", "~> 10.0"
40
+ spec.add_development_dependency "pry"
41
+ spec.add_dependency "nokogiri", "~> 1.10.4"
42
+ end
metadata ADDED
@@ -0,0 +1,121 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: movie_gem
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Thomas DiGregorio
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-10-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: '2.0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.0'
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'
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: nokogiri
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 1.10.4
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 1.10.4
69
+ description: Displays the top 25 sci-fi movies
70
+ email:
71
+ - 'digregoriothomas@yahoo.com
72
+
73
+ '
74
+ executables:
75
+ - sci-fi
76
+ extensions: []
77
+ extra_rdoc_files: []
78
+ files:
79
+ - ".gitignore"
80
+ - CODE_OF_CONDUCT.md
81
+ - Gemfile
82
+ - Gemfile.lock
83
+ - LICENSE.txt
84
+ - README.md
85
+ - Rakefile
86
+ - bin/console
87
+ - bin/sci-fi
88
+ - bin/setup
89
+ - lib/movie_gem.rb
90
+ - lib/movie_gem/CLI.rb
91
+ - lib/movie_gem/movie.rb
92
+ - lib/movie_gem/scraper.rb
93
+ - lib/movie_gem/version.rb
94
+ - movie_gem.gemspec
95
+ homepage: https://github.com/ThomasDiGregorio/movie_gem.git
96
+ licenses:
97
+ - MIT
98
+ metadata:
99
+ homepage_uri: https://github.com/ThomasDiGregorio/movie_gem.git
100
+ source_code_uri: https://github.com/ThomasDiGregorio/movie_gem.git
101
+ changelog_uri: https://github.com/ThomasDiGregorio/movie_gem.git
102
+ post_install_message:
103
+ rdoc_options: []
104
+ require_paths:
105
+ - lib
106
+ required_ruby_version: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ required_rubygems_version: !ruby/object:Gem::Requirement
112
+ requirements:
113
+ - - ">="
114
+ - !ruby/object:Gem::Version
115
+ version: '0'
116
+ requirements: []
117
+ rubygems_version: 3.0.2
118
+ signing_key:
119
+ specification_version: 4
120
+ summary: Flatiron Cli Movie
121
+ test_files: []