what_to_watch_today 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: 986fe41d3bdbe05601bc1c38fff981a7e2abe151ff0d2778c79fd944db90362b
4
+ data.tar.gz: b6f0af19435396d145eedd94396a62c06ac611e3c62c75b479f312d5e5e6a6d3
5
+ SHA512:
6
+ metadata.gz: 040cf5e6339e5929301c167666cbc9c2cd38d07c50fc37afb22822bd4c6bd727e54007c89df295b913a121a13ffba5540df697c05ca42d672ba22a77b0f577ed
7
+ data.tar.gz: f6b71f45c149baa2f5e2bea8167aaf0a7020c9a9954dc117910892c1ea36b6c10aa61625465b269c10b573b83aa3a2e4076716c91ea7d779dd1621a95aa95784
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2021-02-09
4
+
5
+ - Initial release
@@ -0,0 +1,84 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
+
7
+ We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8
+
9
+ ## Our Standards
10
+
11
+ Examples of behavior that contributes to a positive environment for our community include:
12
+
13
+ * Demonstrating empathy and kindness toward other people
14
+ * Being respectful of differing opinions, viewpoints, and experiences
15
+ * Giving and gracefully accepting constructive feedback
16
+ * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17
+ * Focusing on what is best not just for us as individuals, but for the overall community
18
+
19
+ Examples of unacceptable behavior include:
20
+
21
+ * The use of sexualized language or imagery, and sexual attention or
22
+ advances of any kind
23
+ * Trolling, insulting or derogatory comments, and personal or political attacks
24
+ * Public or private harassment
25
+ * Publishing others' private information, such as a physical or email
26
+ address, without their explicit permission
27
+ * Other conduct which could reasonably be considered inappropriate in a
28
+ professional setting
29
+
30
+ ## Enforcement Responsibilities
31
+
32
+ Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
33
+
34
+ Community leaders 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, and will communicate reasons for moderation decisions when appropriate.
35
+
36
+ ## Scope
37
+
38
+ This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
39
+
40
+ ## Enforcement
41
+
42
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at jvargas18@ucol.mx. All complaints will be reviewed and investigated promptly and fairly.
43
+
44
+ All community leaders are obligated to respect the privacy and security of the reporter of any incident.
45
+
46
+ ## Enforcement Guidelines
47
+
48
+ Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
49
+
50
+ ### 1. Correction
51
+
52
+ **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
53
+
54
+ **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
55
+
56
+ ### 2. Warning
57
+
58
+ **Community Impact**: A violation through a single incident or series of actions.
59
+
60
+ **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
61
+
62
+ ### 3. Temporary Ban
63
+
64
+ **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
65
+
66
+ **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
67
+
68
+ ### 4. Permanent Ban
69
+
70
+ **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
71
+
72
+ **Consequence**: A permanent ban from any sort of public interaction within the community.
73
+
74
+ ## Attribution
75
+
76
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
77
+ available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
78
+
79
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
80
+
81
+ [homepage]: https://www.contributor-covenant.org
82
+
83
+ For answers to common questions about this code of conduct, see the FAQ at
84
+ https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
data/Gemfile ADDED
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in what_to_watch.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 13.0"
9
+
10
+ gem "rspec", "~> 3.0"
11
+
12
+ gem "rubocop", "~> 1.7"
13
+
14
+ gem 'rest-client', '~> 2.1'
15
+
16
+ gem 'json', '~> 2.5', '>= 2.5.1'
17
+
18
+ gem 'colorize', '~> 0.8.1'
data/Gemfile.lock ADDED
@@ -0,0 +1,77 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ what_to_watch_today (0.1.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ ast (2.4.2)
10
+ colorize (0.8.1)
11
+ diff-lcs (1.4.4)
12
+ domain_name (0.5.20190701)
13
+ unf (>= 0.0.5, < 1.0.0)
14
+ http-accept (1.7.0)
15
+ http-cookie (1.0.3)
16
+ domain_name (~> 0.5)
17
+ json (2.5.1)
18
+ mime-types (3.3.1)
19
+ mime-types-data (~> 3.2015)
20
+ mime-types-data (3.2020.1104)
21
+ netrc (0.11.0)
22
+ parallel (1.20.1)
23
+ parser (3.0.0.0)
24
+ ast (~> 2.4.1)
25
+ rainbow (3.0.0)
26
+ rake (13.0.3)
27
+ regexp_parser (2.0.3)
28
+ rest-client (2.1.0)
29
+ http-accept (>= 1.7.0, < 2.0)
30
+ http-cookie (>= 1.0.2, < 2.0)
31
+ mime-types (>= 1.16, < 4.0)
32
+ netrc (~> 0.8)
33
+ rexml (3.2.4)
34
+ rspec (3.10.0)
35
+ rspec-core (~> 3.10.0)
36
+ rspec-expectations (~> 3.10.0)
37
+ rspec-mocks (~> 3.10.0)
38
+ rspec-core (3.10.1)
39
+ rspec-support (~> 3.10.0)
40
+ rspec-expectations (3.10.1)
41
+ diff-lcs (>= 1.2.0, < 2.0)
42
+ rspec-support (~> 3.10.0)
43
+ rspec-mocks (3.10.2)
44
+ diff-lcs (>= 1.2.0, < 2.0)
45
+ rspec-support (~> 3.10.0)
46
+ rspec-support (3.10.2)
47
+ rubocop (1.9.1)
48
+ parallel (~> 1.10)
49
+ parser (>= 3.0.0.0)
50
+ rainbow (>= 2.2.2, < 4.0)
51
+ regexp_parser (>= 1.8, < 3.0)
52
+ rexml
53
+ rubocop-ast (>= 1.2.0, < 2.0)
54
+ ruby-progressbar (~> 1.7)
55
+ unicode-display_width (>= 1.4.0, < 3.0)
56
+ rubocop-ast (1.4.1)
57
+ parser (>= 2.7.1.5)
58
+ ruby-progressbar (1.11.0)
59
+ unf (0.1.4)
60
+ unf_ext
61
+ unf_ext (0.0.7.7)
62
+ unicode-display_width (2.0.0)
63
+
64
+ PLATFORMS
65
+ x86_64-linux
66
+
67
+ DEPENDENCIES
68
+ colorize (~> 0.8.1)
69
+ json (~> 2.5, >= 2.5.1)
70
+ rake (~> 13.0)
71
+ rest-client (~> 2.1)
72
+ rspec (~> 3.0)
73
+ rubocop (~> 1.7)
74
+ what_to_watch_today!
75
+
76
+ BUNDLED WITH
77
+ 2.2.3
data/INSTALLATION.md ADDED
@@ -0,0 +1,43 @@
1
+ # WhatToWatch
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/what_to_watch`. 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 'what_to_watch'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle install
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install what_to_watch
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 the created tag, 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]/what_to_watch. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/what_to_watch/blob/master/CODE_OF_CONDUCT.md).
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 WhatToWatch project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/what_to_watch/blob/master/CODE_OF_CONDUCT.md).
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2021 Jorge
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,12 @@
1
+ # What to watch 🍿
2
+ ### This gem is going to consume the API from this website https://imdb-api.com
3
+
4
+ ## Requirements
5
+
6
+ - You can write the title of a movie and the gem must give you 5 recomentations based on the genere of the movie you just entered
7
+ - You can write the title of a TV series and the gem must give you 5 recomendations based on the genere of the series you just entered
8
+ - You can write "WhatsOnTheaters" and the gem must give you what is on movie theaters
9
+ - You can write "trailer #{nameOfTheMovie}" and the gem must give you the link to the movie trailer
10
+ - You can write "comingSoon?" and the gem must give you the movies that are about to be released
11
+ - All this Ruby program must be a gem
12
+
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ require "rubocop/rake_task"
9
+
10
+ RuboCop::RakeTask.new
11
+
12
+ task default: %i[spec rubocop]
data/bin/console ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "bundler/setup"
5
+ require "what_to_watch"
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
+ require "irb"
15
+ 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
data/lib/test.rb ADDED
@@ -0,0 +1,4 @@
1
+ require_relative 'what_to_watch'
2
+
3
+ wtw = WhatToWatch.new('k_74et7stl')
4
+ wtw.start
@@ -0,0 +1,74 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'colorize'
4
+ require_relative 'what_to_watch/version'
5
+ require_relative 'what_to_watch/controller'
6
+
7
+ class WhatToWatch
8
+ def initialize(api_key)
9
+ @controller = WhatToWatchController.new(api_key)
10
+ end
11
+
12
+ def start(title = true)
13
+ print_title if title
14
+ print_menu
15
+ evaluate_input(gets.chomp)
16
+ start(false)
17
+ end
18
+
19
+ def print_menu
20
+ puts(<<-MENU)
21
+ Type the #{'name'.yellow} of a serie or movie to get recommendations.
22
+ Type #{'what'.yellow}'#{'s on the theaters'.yellow} to get the movies in the teaters.
23
+ Type #{'trailer + movie name'.yellow} to get the link to the trailer.
24
+ Type #{'coming soon'.yellow} to get upcoming movies.
25
+ Type #{'Q'.red} to quit.
26
+ MENU
27
+ puts
28
+ end
29
+
30
+ def print_title(title = 'W H A T T O W A T C H')
31
+ puts
32
+ puts(" #{title}")
33
+ puts
34
+ end
35
+
36
+ def evaluate_input(input_text)
37
+ delete_menu
38
+ case input_text
39
+ when 'Q'
40
+ exit
41
+ when /^what'*s on the theaters$/
42
+ results = @controller.on_theaters
43
+ print_title("What's on theaters")
44
+ when /^trailer .*/
45
+ input_text.gsub!('trailer', '')
46
+ results = @controller.trailer(input_text)
47
+ print_title("Trailer #{input_text}")
48
+ when /^coming soon$/
49
+ results = @controller.coming_soon
50
+ print_title('Coming soon movies')
51
+ when /[0-9a-zA-Z\s]/
52
+ results = @controller.recommend(input_text)
53
+ print_title("Recommendations")
54
+ else
55
+ results = 'Invalid command.'
56
+ end
57
+ print_result(results)
58
+ end
59
+
60
+ def print_result(results)
61
+ if results.is_a?(String)
62
+ puts(results)
63
+ else
64
+ results.each do |result|
65
+ puts(result['title'])
66
+ end
67
+ end
68
+ puts
69
+ end
70
+
71
+ def delete_menu
72
+ system('clear')
73
+ end
74
+ end
@@ -0,0 +1,23 @@
1
+ require_relative 'imdb_api'
2
+
3
+ class WhatToWatchController
4
+ def initialize(api_key)
5
+ @api = ImdbApi.new(api_key)
6
+ end
7
+
8
+ def on_theaters
9
+ @api.on_theaters
10
+ end
11
+
12
+ def trailer(title)
13
+ @api.trailer(title)
14
+ end
15
+
16
+ def coming_soon
17
+ @api.coming_soon
18
+ end
19
+
20
+ def recommend(title)
21
+ @api.recommendations(title)
22
+ end
23
+ end
@@ -0,0 +1,54 @@
1
+ require 'rest-client'
2
+ require 'json'
3
+
4
+ class ImdbApi
5
+ BASE_URL = 'https://imdb-api.com/en/API/'
6
+
7
+ def initialize(api_key)
8
+ @api_key = api_key
9
+ @options = { method: 'get' }
10
+ end
11
+
12
+ def recommendations(title)
13
+ id = find_id(title)
14
+ results = call('Title', id)
15
+ results['similars'].first(5)
16
+ end
17
+
18
+ def trailer(title)
19
+ id = find_id(title)
20
+ results = call('Trailer', id)
21
+ results['link']
22
+ end
23
+
24
+ def on_theaters
25
+ results = call('InTheaters')
26
+ results['items']
27
+ end
28
+
29
+ def coming_soon
30
+ results = call('ComingSoon')
31
+ results['items']
32
+ end
33
+
34
+ private
35
+
36
+ def call(endpoint, identifier = nil)
37
+ url = create_url(endpoint, identifier)
38
+ response = RestClient::Request.new(
39
+ method: @options[:method],
40
+ url: url
41
+ ).execute
42
+ JSON.parse(response.to_str)
43
+ end
44
+
45
+ def find_id(title)
46
+ id = call('SearchTitle', title)
47
+ id['results'][0]['id']
48
+ end
49
+
50
+ def create_url(endpoint, identifier)
51
+ title = identifier.gsub(' ', '%20') unless identifier.nil?
52
+ "#{BASE_URL}#{endpoint}/#{@api_key}/#{title}"
53
+ end
54
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ class WhatToWatch
4
+ VERSION = "0.1.0"
5
+ end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/what_to_watch/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "what_to_watch_today"
7
+ spec.version = WhatToWatch::VERSION
8
+ spec.authors = ["Jorge"]
9
+ spec.email = ["jvargas18@ucol.mx"]
10
+
11
+ spec.summary = "What to wath is a gem for movies and series recommendations"
12
+ spec.description = "This gem is going to consume the API from this website https://imdb-api.com"
13
+ spec.homepage = "https://github.com/LoginALee/what_to_watch"
14
+ spec.license = "MIT"
15
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.4.0")
16
+
17
+ # Specify which files should be added to the gem when it is released.
18
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
19
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
20
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
21
+ end
22
+ spec.bindir = "exe"
23
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
24
+ spec.require_paths = ["lib"]
25
+
26
+ # Uncomment to register a new dependency of your gem
27
+ # spec.add_dependency "example-gem", "~> 1.0"
28
+
29
+ # For more information and examples about making a new gem, checkout our
30
+ # guide at: https://bundler.io/guides/creating_gem.html
31
+ end
metadata ADDED
@@ -0,0 +1,59 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: what_to_watch_today
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Jorge
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2021-02-11 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: This gem is going to consume the API from this website https://imdb-api.com
14
+ email:
15
+ - jvargas18@ucol.mx
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - CHANGELOG.md
21
+ - CODE_OF_CONDUCT.md
22
+ - Gemfile
23
+ - Gemfile.lock
24
+ - INSTALLATION.md
25
+ - LICENSE.txt
26
+ - README.md
27
+ - Rakefile
28
+ - bin/console
29
+ - bin/setup
30
+ - lib/test.rb
31
+ - lib/what_to_watch.rb
32
+ - lib/what_to_watch/controller.rb
33
+ - lib/what_to_watch/imdb_api.rb
34
+ - lib/what_to_watch/version.rb
35
+ - what_to_watch_today.gemspec
36
+ homepage: https://github.com/LoginALee/what_to_watch
37
+ licenses:
38
+ - MIT
39
+ metadata: {}
40
+ post_install_message:
41
+ rdoc_options: []
42
+ require_paths:
43
+ - lib
44
+ required_ruby_version: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ version: 2.4.0
49
+ required_rubygems_version: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ requirements: []
55
+ rubygems_version: 3.2.3
56
+ signing_key:
57
+ specification_version: 4
58
+ summary: What to wath is a gem for movies and series recommendations
59
+ test_files: []