pokemoves-cli 1.0.4 → 1.0.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3ff9fe16835af117f9ead6aea422f04cdb04ba14a92c5fbc0a3d6b2c8dd4b7d0
4
- data.tar.gz: 4741d1944d3542ab9318bbd82feed7f694a793c30401faf6b61d3cab926c580d
3
+ metadata.gz: 239ff9f15288592cb8c55da88f16519de762bb58d617a23ca509f8192fe47971
4
+ data.tar.gz: '0961d2218db011607223d91db4c59436086533d9983d2c6b9539569b62cc433b'
5
5
  SHA512:
6
- metadata.gz: 577cc0cb94d5accf01f8644d3deac01aa62b4831469be09b11079202fc41f33870a82a5646fdeb1798c2067c89bb8f24dbe8f183d643d523b60ab1503d835d94
7
- data.tar.gz: a2492b11125bb33a62e11cb5711844749dfe6ee8fed0fa7b4ab022acf65b39281857c5ddd77a792af6591da4d550c2bf3afe23c45178edf3cbf23ef260ecd6f4
6
+ metadata.gz: 256aaef1df8f5a1be89cb88ac582910c13d51d7daf67f449a7e0e353dacdcfbd9e80e68e81c28c0ce281905cf72a61ecd68bb5a2a62cdadc48ab6a527a68cf44
7
+ data.tar.gz: 4ec41649d6d3a5c0d317b19193e890a81f3ddd493d1261f174a90a30ed88006ab14d155d698bc14441867f1e9d1a4161c30de097b0bcdf58957703b71fd18f5f
data/Gemfile CHANGED
@@ -1,7 +1,6 @@
1
1
  source "https://rubygems.org"
2
2
 
3
3
  gem "httparty"
4
- gem "pry"
5
4
 
6
5
  # Specify your gem's dependencies in pokemoves-cli.gemspec
7
6
  gemspec
@@ -1,23 +1,19 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- pokemoves-cli (1.0.4)
4
+ pokemoves-cli (1.0.9)
5
+ httparty
5
6
 
6
7
  GEM
7
8
  remote: https://rubygems.org/
8
9
  specs:
9
- coderay (1.1.3)
10
10
  httparty (0.18.1)
11
11
  mime-types (~> 3.0)
12
12
  multi_xml (>= 0.5.2)
13
- method_source (1.0.0)
14
13
  mime-types (3.3.1)
15
14
  mime-types-data (~> 3.2015)
16
15
  mime-types-data (3.2020.0512)
17
16
  multi_xml (0.6.0)
18
- pry (0.13.1)
19
- coderay (~> 1.1)
20
- method_source (~> 1.0)
21
17
  rake (12.3.3)
22
18
 
23
19
  PLATFORMS
@@ -27,7 +23,6 @@ DEPENDENCIES
27
23
  bundler (~> 2.0)
28
24
  httparty
29
25
  pokemoves-cli!
30
- pry
31
26
  rake (~> 12.3.3)
32
27
 
33
28
  BUNDLED WITH
data/README.md CHANGED
@@ -1,4 +1,3 @@
1
- <<<<<<< HEAD
2
1
  # Pokemoves-cli
3
2
 
4
3
  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.
@@ -21,7 +20,11 @@ Or install it yourself as:
21
20
 
22
21
  ## Usage
23
22
 
24
- TODO: Write usage instructions here
23
+ Simply enter the command:
24
+
25
+ $ pokemoves
26
+
27
+ Into the terminal to start up the CLI. From there, instructions are provided by the CLI itself.
25
28
 
26
29
  ## Development
27
30
 
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require "pokemoves"
3
+ require_relative "../lib/pokemoves.rb"
4
4
 
5
- cli = Pokemoves::CLI.new
5
+ Pokemoves::CLI.new.run
6
6
 
@@ -2,15 +2,23 @@ require_relative "scraper.rb"
2
2
  require_relative "pokemon.rb"
3
3
 
4
4
  class Move
5
- attr_reader :name, :type
5
+ attr_reader :name, :pretty_name
6
6
  @@all = []
7
7
 
8
8
  def initialize(name)
9
9
  @name = name
10
- @type = Scraper.get_move_by_name(name)["type"]["name"]
10
+ @pretty_name = name.split("-").collect{|word| word.capitalize}.join(" ")
11
+
11
12
  @@all << self
12
13
  end
13
14
 
15
+ def type
16
+ if @type == nil
17
+ @type = Scraper.get_move_by_name(name)["type"]["name"]
18
+ end
19
+ @type
20
+ end
21
+
14
22
  def self.all
15
23
  @@all
16
24
  end
@@ -22,4 +30,8 @@ class Move
22
30
  end
23
31
  return nil
24
32
  end
33
+
34
+ def self.find_or_create_by_pretty_name(pretty_name)
35
+ self.find_or_create_by_name(pretty_name.split(" ").collect{|word| word.downcase}.join("-"))
36
+ end
25
37
  end
@@ -11,11 +11,11 @@ class Pokemon
11
11
  end
12
12
 
13
13
  def get_moves
14
- moves = Scraper.get_pokemon_by_name(@name)["moves"].collect{|move_hash| move_hash["move"]["name"]}
14
+ Scraper.get_pokemon_by_name(@name)["moves"].collect{|move_hash| Move.new(move_hash["move"]["name"])}
15
15
  end
16
16
 
17
- def can_learn_move?(move_name)
18
- self.get_moves.include?(move_name)
17
+ def can_learn_move?(move)
18
+ self.get_moves.collect{|m| m.name}.include?(move.name)
19
19
  end
20
20
 
21
21
  def self.all
@@ -1,85 +1,97 @@
1
1
  require_relative "pokemon.rb"
2
2
  require_relative "move.rb"
3
- require "pokemoves/cli/version"
3
+ #require "pokemoves/cli/version"
4
4
 
5
5
  module Pokemoves
6
6
  class CLI
7
- puts "Welcome to Pokemoves!"
8
- input = 0
9
- until input == 3
10
- puts "Enter 1 to see a list of a pokemon's given moves."
11
- puts "Enter 2 to see if a certain move is learnable by a pokemon."
12
- puts "Enter 3 to exit."
13
- input = gets.to_i
14
- if input == 1
15
- puts "Enter the name of a pokemon."
7
+
8
+ def run
9
+ puts "Welcome to Pokemoves!"
10
+ input = 0
11
+ until input == 3
12
+ puts "Enter 1 to see a list of a pokemon's given moves."
13
+ puts "Enter 2 to see if a certain move is learnable by a pokemon."
14
+ puts "Enter 3 to exit."
15
+ input = gets.to_i
16
+ if input == 1
17
+ get_pokemon_move_list
18
+
19
+ elsif input == 2
20
+ check_learnability_of_move
21
+ else
22
+ puts "That isn't a vailid choice." unless input == 3
23
+ end
24
+
25
+ end
26
+
27
+ end
28
+
29
+ def get_pokemon_move_list
30
+ puts "Enter the name of a pokemon."
31
+ pokemon_name = gets.chomp
32
+ until Pokemon.find_or_create_by_name(pokemon_name.downcase) != nil
33
+ puts "It doesn't look like we have that pokemon stored."
34
+ puts "Try a different one."
16
35
  pokemon_name = gets.chomp
17
- until Pokemon.find_or_create_by_name(pokemon_name.downcase) != nil
18
- puts "It doesn't look like we have that pokemon stored."
19
- puts "Try a different one."
20
- pokemon_name = gets.chomp
36
+ end
37
+ current_pokemon = Pokemon.find_or_create_by_name(pokemon_name.downcase)
38
+ puts "Press enter to see a list of #{pokemon_name.capitalize}'s moves."
39
+ gets
40
+ counter = 1
41
+ current_pokemon.get_moves.each{|move|
42
+ puts "#{counter}. #{move.pretty_name}"
43
+ counter += 1
44
+ }
45
+ puts "Enter the number of the move you'd like to know the type of."
46
+ puts "To continue to the main menu, enter -1"
47
+ num = gets.to_i
48
+ until num <= 0
49
+ if(num <= current_pokemon.get_moves.size)
50
+ current_move = Move.find_or_create_by_name(current_pokemon.get_moves[num - 1].name)
51
+ puts "The move #{current_move.pretty_name} is a #{current_move.type} type move."
52
+ else
53
+ puts "That number is not in the list of moves."
21
54
  end
22
- current_pokemon = Pokemon.find_or_create_by_name(pokemon_name.downcase)
23
- puts "Press enter to see a list of #{pokemon_name.capitalize}'s moves."
24
- gets
25
- counter = 1
26
- current_pokemon.get_moves.each{|move|
27
- puts "#{counter}. #{move.split("-").collect{|word| word.capitalize}.join(" ")}"
28
- counter += 1
29
- }
30
55
  puts "Enter the number of the move you'd like to know the type of."
31
- puts "To continue to the main menu, enter -1"
56
+ puts "Enter -1 to continue to the main menu."
32
57
  num = gets.to_i
33
- until num <= 0
34
- if(num <= current_pokemon.get_moves.size)
35
- current_move = Move.find_or_create_by_name(current_pokemon.get_moves[num - 1])
36
- puts "The move #{current_move.name.capitalize} is a #{current_move.type} type move."
37
- else
38
- puts "That number is not in the list of moves."
39
- end
40
- puts "Enter the number of the move you'd like to know the type of."
41
- puts "Enter -1 to continue to the main menu."
42
- num = gets.to_i
43
- end
58
+ end
59
+ end
44
60
 
45
- elsif input == 2
46
- puts "Enter the name of a move!"
61
+ def check_learnability_of_move
62
+ puts "Enter the name of a move!"
63
+ move_name = gets.chomp
64
+ until Move.find_or_create_by_pretty_name(move_name) != nil
65
+ puts "It doesn't look like we have that move stored."
66
+ puts "Try a different one."
47
67
  move_name = gets.chomp
48
- until Move.find_or_create_by_name(move_name.split(" ").collect{|word| word.downcase}.join("-")) != nil
49
- puts "It doesn't look like we have that move stored."
50
- puts "Try a different one."
51
- move_name = gets.chomp
68
+ end
69
+ current_move = Move.find_or_create_by_pretty_name(move_name)
70
+ puts "Enter the name of a pokemon to see if they can learn #{current_move.pretty_name}"
71
+ pokemon_name = gets.chomp
72
+ until Pokemon.find_or_create_by_name(pokemon_name.downcase) != nil
73
+ puts "It doesn't look like we have that pokemon stored."
74
+ puts "Try a different one."
75
+ pokemon_name = gets.chomp
76
+ end
77
+ until pokemon_name == "exit"
78
+ current_pokemon = Pokemon.find_or_create_by_name(pokemon_name.downcase)
79
+ if current_pokemon.can_learn_move?(current_move)
80
+ puts "It looks like #{current_pokemon.name.capitalize} can learn #{current_move.pretty_name}."
81
+ else
82
+ puts "It looks like #{current_pokemon.name.capitalize} can't learn #{current_move.pretty_name}."
52
83
  end
53
- current_move = Move.find_or_create_by_name(move_name.split(" ").collect{|word| word.downcase}.join("-"))
54
- puts "Enter the name of a pokemon to see if they can learn #{current_move.name.split("-").collect{|word| word.capitalize}.join(" ")}"
84
+ puts "Enter the name of another pokemon to see if they can learn #{current_move.pretty_name}."
85
+ puts "Enter \"exit\" to continue to the main menu."
55
86
  pokemon_name = gets.chomp
56
- until Pokemon.find_or_create_by_name(pokemon_name.downcase) != nil
87
+ until Pokemon.find_or_create_by_name(pokemon_name.downcase) != nil || pokemon_name == "exit"
57
88
  puts "It doesn't look like we have that pokemon stored."
58
- puts "Try a different one."
89
+ puts "Try a different one, or enter \"exit\" to exit."
59
90
  pokemon_name = gets.chomp
60
91
  end
61
- until pokemon_name == "exit"
62
- current_pokemon = Pokemon.find_or_create_by_name(pokemon_name.downcase)
63
- if current_pokemon.can_learn_move?(current_move.name)
64
- puts "It looks like #{current_pokemon.name.capitalize} can learn #{current_move.name.split("-").collect{|word| word.capitalize}.join(" ")}."
65
- else
66
- puts "It looks like #{current_pokemon.name.capitalize} can't learn #{current_move.name.split("-").collect{|word| word.capitalize}.join(" ")}."
67
- end
68
- puts "Enter the name of another pokemon to see if they can learn #{current_move.name.split("-").collect{|word| word.capitalize}.join(" ")}."
69
- puts "Enter \"exit\" to continue to the main menu."
70
- pokemon_name = gets.chomp
71
- until Pokemon.find_or_create_by_name(pokemon_name.downcase) != nil || pokemon_name == "exit"
72
- puts "It doesn't look like we have that pokemon stored."
73
- puts "Try a different one, or enter \"exit\" to exit."
74
- pokemon_name = gets.chomp
75
- end
76
- end
77
- else
78
- puts "That isn't a vailid choice." unless input == 3
79
92
  end
80
-
81
93
  end
82
-
83
- end
94
+
95
+ end
84
96
 
85
- end
97
+ end
@@ -1,5 +1,5 @@
1
1
  module Pokemoves
2
2
  module Cli
3
- VERSION = "1.0.4"
3
+ VERSION = "1.0.9"
4
4
  end
5
5
  end
@@ -1,5 +1,4 @@
1
1
  require "httparty"
2
- require "pry"
3
2
 
4
3
  class Scraper
5
4
 
@@ -38,4 +38,5 @@ Gem::Specification.new do |spec|
38
38
 
39
39
  spec.add_development_dependency "bundler", "~> 2.0"
40
40
  spec.add_development_dependency "rake", "~> 12.3.3"
41
+ spec.add_runtime_dependency "httparty"
41
42
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pokemoves-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - "'Andrew Ribas'"
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-07-31 00:00:00.000000000 Z
11
+ date: 2020-08-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: 12.3.3
41
+ - !ruby/object:Gem::Dependency
42
+ name: httparty
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
41
55
  description: '"Pokemoves allows you to easily check which moves pokemon can learn,
42
56
  as well as which pokemon can learn a specific move. You can also check a move''s
43
57
  given type."'