marvel_movies 0.1.3

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: 16c7a8d4ca6bfee46bb5b0d15cf1b243d8a152c4
4
+ data.tar.gz: bd2b50c5d0cb55f909bbf1e95be46458b817bc14
5
+ SHA512:
6
+ metadata.gz: 0ae065dae74bd8da86f006e83976449cb35d86f79ad8dffb7b403851c54721d0066000f8b33481d4d18ad252b925d2eca008a7697bdb7e364a5f24b9eac5f670
7
+ data.tar.gz: 920889a5842fbb6a16c6ad1d06083e27a571fa523c02e746d646921b74639985606eca4731776f9446c8b9146df69d65b4425466de615541462cdba2d6a9626f
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/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.3
4
+ before_install: gem install bundler -v 1.11.2
@@ -0,0 +1,49 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, and in the interest of
4
+ fostering an open and welcoming community, we pledge to respect all people who
5
+ contribute through reporting issues, posting feature requests, updating
6
+ documentation, submitting pull requests or patches, and other activities.
7
+
8
+ We are committed to making participation in this project a harassment-free
9
+ experience for everyone, regardless of level of experience, gender, gender
10
+ identity and expression, sexual orientation, disability, personal appearance,
11
+ body size, race, ethnicity, age, religion, or nationality.
12
+
13
+ Examples of unacceptable behavior by participants include:
14
+
15
+ * The use of sexualized language or imagery
16
+ * Personal attacks
17
+ * Trolling or insulting/derogatory comments
18
+ * Public or private harassment
19
+ * Publishing other's private information, such as physical or electronic
20
+ addresses, without explicit permission
21
+ * Other unethical or unprofessional conduct
22
+
23
+ Project maintainers have the right and responsibility to remove, edit, or
24
+ reject comments, commits, code, wiki edits, issues, and other contributions
25
+ that are not aligned to this Code of Conduct, or to ban temporarily or
26
+ permanently any contributor for other behaviors that they deem inappropriate,
27
+ threatening, offensive, or harmful.
28
+
29
+ By adopting this Code of Conduct, project maintainers commit themselves to
30
+ fairly and consistently applying these principles to every aspect of managing
31
+ this project. Project maintainers who do not follow or enforce the Code of
32
+ Conduct may be permanently removed from the project team.
33
+
34
+ This code of conduct applies both within project spaces and in public spaces
35
+ when an individual is representing the project or its community.
36
+
37
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
38
+ reported by contacting a project maintainer at mcclains2003@gmail.com. All
39
+ complaints will be reviewed and investigated and will result in a response that
40
+ is deemed necessary and appropriate to the circumstances. Maintainers are
41
+ obligated to maintain confidentiality with regard to the reporter of an
42
+ incident.
43
+
44
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
45
+ version 1.3.0, available at
46
+ [http://contributor-covenant.org/version/1/3/0/][version]
47
+
48
+ [homepage]: http://contributor-covenant.org
49
+ [version]: http://contributor-covenant.org/version/1/3/0/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in marvel_movies.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 mcclains2003
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/NOTES.md ADDED
@@ -0,0 +1,26 @@
1
+ How to Build a Marvel Universe Movie CLI Gem
2
+
3
+ 1. Plan your gem, imagine your interface
4
+ 2. Start with the project structure - google
5
+ 3. Start with the entry point - the file run
6
+ 4. force that to build the CLI interface
7
+ 5. stub out the interface
8
+ 6. start making things real
9
+ 7. discover objects.
10
+ 8. program
11
+
12
+ A command line interface for upcoming, and available now Marvel Universe Movies
13
+
14
+ user types marvel-movies
15
+
16
+ Show a list of options: (FIRST MENU)
17
+ 1. Show a list of All Movies
18
+ 2. Show only Upcoming Movies
19
+ 3. Show movies Available Now on DVD
20
+ 4. Exit
21
+
22
+ When movies are displayed this menu will be displaced
23
+
24
+ 1. Which movie do you want to see a description about
25
+ 2. Back
26
+ 3. Exit
data/README.md ADDED
@@ -0,0 +1,41 @@
1
+ # MarvelMovies
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/marvel_movies`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'marvel_movies'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install marvel_movies
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ 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.
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]/marvel_movies. 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
+
38
+ ## License
39
+
40
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
41
+
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 "marvel_movies"
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
data/bin/marvel-movies ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require 'marvel_movies'
5
+
6
+ MarvelMovies::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
data/exe/marvel_movies ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'marvel_movies'
4
+
5
+ MarvelMovies::CLI.new.call
@@ -0,0 +1,75 @@
1
+ class MarvelMovies::CLI
2
+
3
+ def call
4
+ list_choices
5
+ menu
6
+ end
7
+
8
+ def list_choices
9
+ puts "Hello Marvel Fans"
10
+ puts <<-DOC.gsub /^\s*/, ''
11
+ 1. Show All Marvel Movies
12
+ 2. Show Upcoming Marvel Movies
13
+ 3. Show Marvel Movies Available Now on DVD
14
+ DOC
15
+ end
16
+
17
+ def menu
18
+ input = nil
19
+ puts "Please enter the option you would like to see or type exit: "
20
+ while input != "exit"
21
+ input = gets.strip.downcase
22
+
23
+ case input
24
+ when "1"
25
+ puts ""
26
+ MarvelMovies::Movie.list_all
27
+ movie_description_menu(MarvelMovies::Movie.all)
28
+ when "2"
29
+ puts ""
30
+ MarvelMovies::Movie.list_upcoming
31
+ movie_description_menu(MarvelMovies::Movie.upcoming)
32
+ when "3"
33
+ puts ""
34
+ MarvelMovies::Movie.list_dvd
35
+ movie_description_menu(MarvelMovies::Movie.dvd)
36
+ when "exit"
37
+ goodbye
38
+ else
39
+ puts ""
40
+ puts "Not familiar with that option, please type another option or exit: "
41
+ end
42
+ end
43
+ end
44
+
45
+ def goodbye
46
+ puts ""
47
+ puts "Goodbye and check back later for more Marvel Universe"
48
+ exit
49
+ end
50
+
51
+ def movie_description_menu(array)
52
+ input = nil
53
+
54
+ while input != "exit"
55
+ puts " "
56
+ puts "Choose the number of the movie you would like more information on, type back to go back to previous menu, or exit: "
57
+ input = gets.strip.downcase
58
+
59
+ if input.to_i > 0
60
+ movie = MarvelMovies::Movie.find_movie(array, input.to_i)
61
+ movie.profile_scrape
62
+ puts "Title: #{movie.title}"
63
+ puts "Release Date: #{movie.release_date}"
64
+ puts "Rating: #{movie.rating}"
65
+ puts "Description: #{movie.description}"
66
+ puts ""
67
+ elsif input == "back"
68
+ call
69
+ elsif input == "exit"
70
+ goodbye
71
+ end
72
+ end
73
+ end
74
+
75
+ end
@@ -0,0 +1,84 @@
1
+ class MarvelMovies::Movie
2
+ attr_accessor :title, :url, :release_date, :rating, :description
3
+
4
+ def self.scrape_movies
5
+ data = Nokogiri::HTML(open("http://marvel.com/movies/all"))
6
+ movie_array = []
7
+
8
+ data.css("div.JCMultiRow div.row-item").collect do |movies|
9
+ movie = self.new
10
+ movie.title = movies.css("div.row-item-text h5 a").text
11
+ movie.release_date = movies.css("div.row-item-text p.media-item-meta").text
12
+ movie.url = "http://marvel.com" + movies.css("div.row-item-text h5 a").attr("href").value
13
+ movie_array << movie
14
+ end
15
+ movie_array.uniq
16
+ end
17
+
18
+ def profile_scrape
19
+ profile_data = Nokogiri::HTML(open(self.url))
20
+
21
+ if profile_data.css("span.block3")[0]
22
+ self.rating = profile_data.css("span.block3").first.text.gsub(" Rating: ", "").strip
23
+ description = profile_data.css("div.featured-item-desc p").last
24
+ else
25
+ self.rating = profile_data.css("div.details p").last.text.strip.gsub("Rating: ", "")
26
+ description = profile_data.css("div#pull-quote h1")
27
+ end
28
+ description.css("a").remove
29
+ self.description = description.text.gsub( /\n|\t|\r|[ ]{2,}/, "" ).strip
30
+ end
31
+
32
+ def self.all
33
+ self.scrape_movies
34
+ end
35
+
36
+ def self.list_all
37
+ self.all.map.with_index(1) do |movie, i|
38
+ puts "#{i}. #{movie.title}"
39
+ end
40
+ end
41
+
42
+ def self.upcoming
43
+ today = Date.today
44
+ movie_list = []
45
+
46
+ self.scrape_movies.map do |movie|
47
+ movie_date = Date.parse(movie.release_date)
48
+ if today < movie_date
49
+ movie_list << movie
50
+ end
51
+ end
52
+ movie_list
53
+ end
54
+
55
+ def self.list_upcoming
56
+ self.upcoming.map.with_index(1) do |movie, i|
57
+ puts "#{i}. #{movie.title}"
58
+ end
59
+ end
60
+
61
+ def self.dvd
62
+ today = Date.today
63
+ movie_list = []
64
+
65
+ self.scrape_movies.map do |movie|
66
+ movie_date = Date.parse(movie.release_date)
67
+ if today >= movie_date
68
+ movie_list << movie
69
+ end
70
+ end
71
+ movie_list
72
+ end
73
+
74
+ def self.list_dvd
75
+ self.dvd.map.with_index(1) do |movie, i|
76
+ puts "#{i}. #{movie.title}"
77
+ end
78
+ end
79
+
80
+ def self.find_movie(array, index)
81
+ array[index-1]
82
+ end
83
+
84
+ end
@@ -0,0 +1,3 @@
1
+ module MarvelMovies
2
+ VERSION = "0.1.3"
3
+ end
@@ -0,0 +1,7 @@
1
+ require 'nokogiri'
2
+ require 'open-uri'
3
+ require 'date'
4
+
5
+ require_relative "./marvel_movies/version"
6
+ require_relative "./marvel_movies/movie"
7
+ require_relative "./marvel_movies/cli"
Binary file
Binary file
Binary file
@@ -0,0 +1,34 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'marvel_movies/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "marvel_movies"
8
+ spec.version = MarvelMovies::VERSION
9
+ spec.authors = ["Shaun McClain"]
10
+ spec.email = ["mcclains2003@gmail.com"]
11
+
12
+ spec.summary = "A Gem that returns all new, current and past Marvel Movies."
13
+ spec.description = "This Gem scrapes movies from the Marvel website and then displays them. You can choose a movie from the list it displays to see more information about it."
14
+ spec.homepage = "https://github.com/mcclains2003/marvel_movies.git"
15
+ spec.license = "MIT"
16
+
17
+ # Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
18
+ # delete this section to allow pushing this gem to any host.
19
+ if spec.respond_to?(:metadata)
20
+ spec.metadata['allowed_push_host'] = "https://rubygems.org"
21
+ else
22
+ raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
23
+ end
24
+
25
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
26
+ spec.bindir = "exe"
27
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
+ spec.require_paths = ["lib"]
29
+
30
+ spec.add_development_dependency "bundler", "~> 1.11"
31
+ spec.add_development_dependency "rake", "~> 10.0"
32
+ spec.add_development_dependency "rspec", "~> 3.0"
33
+ spec.add_runtime_dependency 'nokogiri', '~> 1.6', '>= 1.6.0'
34
+ end
metadata ADDED
@@ -0,0 +1,130 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: marvel_movies
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.3
5
+ platform: ruby
6
+ authors:
7
+ - Shaun McClain
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-04-20 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.11'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.11'
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: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.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.6'
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ version: 1.6.0
65
+ type: :runtime
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.0
75
+ description: This Gem scrapes movies from the Marvel website and then displays them.
76
+ You can choose a movie from the list it displays to see more information about it.
77
+ email:
78
+ - mcclains2003@gmail.com
79
+ executables:
80
+ - marvel_movies
81
+ extensions: []
82
+ extra_rdoc_files: []
83
+ files:
84
+ - ".gitignore"
85
+ - ".rspec"
86
+ - ".travis.yml"
87
+ - CODE_OF_CONDUCT.md
88
+ - Gemfile
89
+ - LICENSE.txt
90
+ - NOTES.md
91
+ - README.md
92
+ - Rakefile
93
+ - bin/console
94
+ - bin/marvel-movies
95
+ - bin/setup
96
+ - exe/marvel_movies
97
+ - lib/marvel_movies.rb
98
+ - lib/marvel_movies/cli.rb
99
+ - lib/marvel_movies/movie.rb
100
+ - lib/marvel_movies/version.rb
101
+ - marvel_movies-0.1.0.gem
102
+ - marvel_movies-0.1.1.gem
103
+ - marvel_movies-0.1.2.gem
104
+ - marvel_movies.gemspec
105
+ homepage: https://github.com/mcclains2003/marvel_movies.git
106
+ licenses:
107
+ - MIT
108
+ metadata:
109
+ allowed_push_host: https://rubygems.org
110
+ post_install_message:
111
+ rdoc_options: []
112
+ require_paths:
113
+ - lib
114
+ required_ruby_version: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - ">="
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
119
+ required_rubygems_version: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ version: '0'
124
+ requirements: []
125
+ rubyforge_project:
126
+ rubygems_version: 2.4.5.1
127
+ signing_key:
128
+ specification_version: 4
129
+ summary: A Gem that returns all new, current and past Marvel Movies.
130
+ test_files: []