pokemoves-cli 1.0.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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: a54c7fcd8cafcd921fca9abbaf22c0d8be9b37df1f3a71022c891f6d4374f564
4
+ data.tar.gz: ad9856dcf0cfc6252d88fe798f0314458feb29ed60acde3a261e0ef1e321b7ca
5
+ SHA512:
6
+ metadata.gz: 85a243fd206dcaff267a8c2caf277d5871818729b18d470c858b847f3a877426a03696b1e1c72c44db041b891dc0d63e65c68ebab479216ac2e1907fb655ebaf
7
+ data.tar.gz: b37d28d2307e83a4585d3802a4aeac1f5d970b48ca5bdd024176e647c5930447df9ae225d9818864524cf841807c928e4714aeec6c7cf769cab4e9436966ab18
@@ -0,0 +1,8 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
@@ -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 'andrew.j.ribas@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,7 @@
1
+ source "https://rubygems.org"
2
+
3
+ gem "httparty"
4
+ gem "pry"
5
+
6
+ # Specify your gem's dependencies in pokemoves-cli.gemspec
7
+ gemspec
@@ -0,0 +1,34 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ pokemoves-cli (1.0.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ coderay (1.1.3)
10
+ httparty (0.18.1)
11
+ mime-types (~> 3.0)
12
+ multi_xml (>= 0.5.2)
13
+ method_source (1.0.0)
14
+ mime-types (3.3.1)
15
+ mime-types-data (~> 3.2015)
16
+ mime-types-data (3.2020.0512)
17
+ multi_xml (0.6.0)
18
+ pry (0.13.1)
19
+ coderay (~> 1.1)
20
+ method_source (~> 1.0)
21
+ rake (12.3.3)
22
+
23
+ PLATFORMS
24
+ ruby
25
+
26
+ DEPENDENCIES
27
+ bundler (~> 2.0)
28
+ httparty
29
+ pokemoves-cli!
30
+ pry
31
+ rake (~> 12.3.3)
32
+
33
+ BUNDLED WITH
34
+ 2.0.1
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2020 'Andrew Ribas'
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.
@@ -0,0 +1,45 @@
1
+ <<<<<<< HEAD
2
+ # Pokemoves-cli
3
+
4
+ Pokemoves allows you to easily check which moves pokemon can learn, as well as which pokemon can learn a specific move. You can also check a move's given type.
5
+
6
+ ## Installation
7
+
8
+ Add this line to your application's Gemfile:
9
+
10
+ ```ruby
11
+ gem 'pokemoves-cli'
12
+ ```
13
+
14
+ And then execute:
15
+
16
+ $ bundle
17
+
18
+ Or install it yourself as:
19
+
20
+ $ gem install pokemoves-cli
21
+
22
+ ## Usage
23
+
24
+ TODO: Write usage instructions here
25
+
26
+ ## Development
27
+
28
+ 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.
29
+
30
+ 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).
31
+
32
+ ## Contributing
33
+
34
+ Bug reports and pull requests are welcome on GitHub at https://github.com/'mystical-process-8698'/pokemoves-cli. 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.
35
+
36
+ ## License
37
+
38
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
39
+
40
+ ## Code of Conduct
41
+
42
+ Everyone interacting in the Pokemoves::Cli project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/'mystical-process-8698'/pokemoves-cli/blob/master/CODE_OF_CONDUCT.md).
43
+ =======
44
+ # pokemoves-cli
45
+ >>>>>>> 499eea398db4987c8fc9f5e83ba535772ecfa094
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+
5
+ # You can add fixtures and/or initialization code here to make experimenting
6
+ # with your gem easier. You can also use a different console, if you like.
7
+
8
+ # (If you use this, don't forget to add pry to your Gemfile!)
9
+ # require "pry"
10
+ # Pry.start
11
+
12
+ require "irb"
13
+ require "./lib/cli.rb"
14
+
15
+ cli = CLI.new
16
+
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,82 @@
1
+ require_relative "pokemon.rb"
2
+ require_relative "move.rb"
3
+
4
+ class CLI
5
+ puts "Welcome to Pokemoves!"
6
+ input = 0
7
+ until input == 3
8
+ puts "Enter 1 to see a list of a pokemon's given moves."
9
+ puts "Enter 2 to see if a certain move is learnable by a pokemon."
10
+ puts "Enter 3 to exit."
11
+ input = gets.to_i
12
+ if input == 1
13
+ puts "Enter the name of a pokemon."
14
+ pokemon_name = gets.chomp
15
+ until Pokemon.find_or_create_by_name(pokemon_name.downcase) != nil
16
+ puts "It doesn't look like we have that pokemon stored."
17
+ puts "Try a different one."
18
+ pokemon_name = gets.chomp
19
+ end
20
+ current_pokemon = Pokemon.find_or_create_by_name(pokemon_name.downcase)
21
+ puts "Press enter to see a list of #{pokemon_name.capitalize}'s moves."
22
+ gets
23
+ counter = 1
24
+ current_pokemon.get_moves.each{|move|
25
+ puts "#{counter}. #{move.split("-").collect{|word| word.capitalize}.join(" ")}"
26
+ counter += 1
27
+ }
28
+ puts "Enter the number of the move you'd like to know the type of."
29
+ puts "To continue to the main menu, enter -1"
30
+ num = gets.to_i
31
+ until num <= 0
32
+ if(num <= current_pokemon.get_moves.size)
33
+ current_move = Move.find_or_create_by_name(current_pokemon.get_moves[num - 1])
34
+ puts "The move #{current_move.name.capitalize} is a #{current_move.type} type move."
35
+ else
36
+ puts "That number is not in the list of moves."
37
+ end
38
+ puts "Enter the number of the move you'd like to know the type of."
39
+ puts "Enter -1 to continue to the main menu."
40
+ num = gets.to_i
41
+ end
42
+
43
+ elsif input == 2
44
+ puts "Enter the name of a move!"
45
+ move_name = gets.chomp
46
+ until Move.find_or_create_by_name(move_name.split(" ").collect{|word| word.downcase}.join("-")) != nil
47
+ puts "It doesn't look like we have that move stored."
48
+ puts "Try a different one."
49
+ move_name = gets.chomp
50
+ end
51
+ current_move = Move.find_or_create_by_name(move_name.split(" ").collect{|word| word.downcase}.join("-"))
52
+ puts "Enter the name of a pokemon to see if they can learn #{current_move.name.split("-").collect{|word| word.capitalize}.join(" ")}"
53
+ pokemon_name = gets.chomp
54
+ until Pokemon.find_or_create_by_name(pokemon_name.downcase) != nil
55
+ puts "It doesn't look like we have that pokemon stored."
56
+ puts "Try a different one."
57
+ pokemon_name = gets.chomp
58
+ end
59
+ until pokemon_name == "exit"
60
+ current_pokemon = Pokemon.find_or_create_by_name(pokemon_name.downcase)
61
+ if current_pokemon.can_learn_move?(current_move.name)
62
+ puts "It looks like #{current_pokemon.name.capitalize} can learn #{current_move.name.split("-").collect{|word| word.capitalize}.join(" ")}."
63
+ else
64
+ puts "It looks like #{current_pokemon.name.capitalize} can't learn #{current_move.name.split("-").collect{|word| word.capitalize}.join(" ")}."
65
+ end
66
+ puts "Enter the name of another pokemon to see if they can learn #{current_move.name.split("-").collect{|word| word.capitalize}.join(" ")}."
67
+ puts "Enter \"exit\" to continue to the main menu."
68
+ pokemon_name = gets.chomp
69
+ until Pokemon.find_or_create_by_name(pokemon_name.downcase) != nil || pokemon_name == "exit"
70
+ puts "It doesn't look like we have that pokemon stored."
71
+ puts "Try a different one, or enter \"exit\" to exit."
72
+ pokemon_name = gets.chomp
73
+ end
74
+ end
75
+
76
+ else
77
+ puts "That isn't a vailid choice." unless input == 3
78
+ end
79
+
80
+ end
81
+
82
+ end
@@ -0,0 +1,25 @@
1
+ require_relative "scraper.rb"
2
+ require_relative "pokemon.rb"
3
+
4
+ class Move
5
+ attr_reader :name, :type
6
+ @@all = []
7
+
8
+ def initialize(name)
9
+ @name = name
10
+ @type = Scraper.get_move_by_name(name)["type"]["name"]
11
+ @@all << self
12
+ end
13
+
14
+ def self.all
15
+ @@all
16
+ end
17
+
18
+ def self.find_or_create_by_name(name)
19
+ if Scraper.moves.include?(name)
20
+ return self.all.detect{|a| a.name == name} if self.all.collect{|a| a.name}.include?(name)
21
+ return Move.new(name)
22
+ end
23
+ return nil
24
+ end
25
+ end
@@ -0,0 +1,33 @@
1
+ require_relative "scraper.rb"
2
+
3
+ class Pokemon
4
+ attr_reader :name, :type
5
+ @@all = []
6
+
7
+ def initialize(name)
8
+ @name = name
9
+ @type = Scraper.get_pokemon_by_name(name)["types"][0]["type"]["name"]
10
+ @@all << self
11
+ end
12
+
13
+ def get_moves
14
+ moves = Scraper.get_pokemon_by_name(@name)["moves"].collect{|move_hash| move_hash["move"]["name"]}
15
+ end
16
+
17
+ def can_learn_move?(move_name)
18
+ self.get_moves.include?(move_name)
19
+ end
20
+
21
+ def self.all
22
+ @@all
23
+ end
24
+
25
+ def self.find_or_create_by_name(name)
26
+ if Scraper.pokemons.include?(name)
27
+ return self.all.detect{|a| a.name == name} if self.all.collect{|a| a.name}.include?(name)
28
+ return Pokemon.new(name)
29
+ end
30
+ return nil
31
+ end
32
+
33
+ end
@@ -0,0 +1,5 @@
1
+ module Pokemoves
2
+ module Cli
3
+ VERSION = "1.0.0"
4
+ end
5
+ end
@@ -0,0 +1,34 @@
1
+ require "httparty"
2
+ require "pry"
3
+
4
+ class Scraper
5
+
6
+ url = "https://pokeapi.co/api/v2/"
7
+ @@pokemons = HTTParty.get(url + "/pokemon?offset=0&limit=964").parsed_response["results"]
8
+ @@moves = HTTParty.get(url + "/move?offset=0&limit=746").parsed_response["results"]
9
+
10
+ def self.get_pokemon_by_name(name)
11
+ @@pokemons.each{|pokemon|
12
+ if pokemon["name"] == name
13
+ return HTTParty.get(pokemon["url"])
14
+ end
15
+ }
16
+ end
17
+
18
+ def self.pokemons
19
+ @@pokemons.collect{|pokemon| pokemon["name"]}
20
+ end
21
+
22
+ def self.get_move_by_name(name)
23
+ @@moves.each{|move|
24
+ if move["name"] == name
25
+ return HTTParty.get(move["url"])
26
+ end
27
+ }
28
+ end
29
+
30
+ def self.moves
31
+ @@moves.collect{|move| move["name"]}
32
+ end
33
+
34
+ end
@@ -0,0 +1,41 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "pokemoves/cli/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "pokemoves-cli"
8
+ spec.version = Pokemoves::Cli::VERSION
9
+ spec.authors = ["'Andrew Ribas'"]
10
+ spec.email = ["'andrew.j.ribas@gmail.com'"]
11
+
12
+ spec.summary = %q{"Accesses pokemon moves"}
13
+ spec.description = %q{"Pokemoves allows you to easily check which moves pokemon can learn, as well as which pokemon can learn a specific move. You can also check a move's given type."}
14
+ spec.homepage = "https://github.com/Directrix777/pokemoves-cli"
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"] = 'http://RubyGems.org'
21
+
22
+ spec.metadata["homepage_uri"] = spec.homepage
23
+ spec.metadata["source_code_uri"] = "https://github.com/Directrix777/pokemoves-cli"
24
+ spec.metadata["changelog_uri"] = "https://github.com/Directrix777/pokemoves-cli/commits/master"
25
+ else
26
+ raise "RubyGems 2.0 or newer is required to protect against " \
27
+ "public gem pushes."
28
+ end
29
+
30
+ # Specify which files should be added to the gem when it is released.
31
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
32
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
33
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
34
+ end
35
+ spec.bindir = "exe"
36
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
37
+ spec.require_paths = ["lib"]
38
+
39
+ spec.add_development_dependency "bundler", "~> 2.0"
40
+ spec.add_development_dependency "rake", "~> 12.3.3"
41
+ end
metadata ADDED
@@ -0,0 +1,91 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pokemoves-cli
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - "'Andrew Ribas'"
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2020-07-31 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: 12.3.3
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 12.3.3
41
+ description: '"Pokemoves allows you to easily check which moves pokemon can learn,
42
+ as well as which pokemon can learn a specific move. You can also check a move''s
43
+ given type."'
44
+ email:
45
+ - "'andrew.j.ribas@gmail.com'"
46
+ executables: []
47
+ extensions: []
48
+ extra_rdoc_files: []
49
+ files:
50
+ - ".gitignore"
51
+ - CODE_OF_CONDUCT.md
52
+ - Gemfile
53
+ - Gemfile.lock
54
+ - LICENSE.txt
55
+ - README.md
56
+ - Rakefile
57
+ - bin/console
58
+ - bin/setup
59
+ - lib/cli.rb
60
+ - lib/move.rb
61
+ - lib/pokemon.rb
62
+ - lib/pokemoves/cli/version.rb
63
+ - lib/scraper.rb
64
+ - pokemoves-cli.gemspec
65
+ homepage: https://github.com/Directrix777/pokemoves-cli
66
+ licenses:
67
+ - MIT
68
+ metadata:
69
+ homepage_uri: https://github.com/Directrix777/pokemoves-cli
70
+ source_code_uri: https://github.com/Directrix777/pokemoves-cli
71
+ changelog_uri: https://github.com/Directrix777/pokemoves-cli/commits/master
72
+ post_install_message:
73
+ rdoc_options: []
74
+ require_paths:
75
+ - lib
76
+ required_ruby_version: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ version: '0'
81
+ required_rubygems_version: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - ">="
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ requirements: []
87
+ rubygems_version: 3.0.3
88
+ signing_key:
89
+ specification_version: 4
90
+ summary: '"Accesses pokemon moves"'
91
+ test_files: []