dexter_plusplus 0.2.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: 7b7b041f26e5fe11859df52215b82c45269f685bd2a11d066ca1ac9703fc6a23
4
+ data.tar.gz: 6a6fc27a7190b097cfbcd84d87e8a0cfc2ec7720fab09fb391b793b47cfbede8
5
+ SHA512:
6
+ metadata.gz: 77bbe01b42688a641776c15a928198a84dc6021476d4233546054bbc44e972f0e4e340781b6a28a65337d45f03fcf9976517367af7927e27fac7d397c8892d66
7
+ data.tar.gz: 1e4baa402672bd2717a909109201d766624dbd8b5c89c07adf207e02ecc14f7ffc73e7b6f273fdc1305ca62d57fbb9e6a924b64bff4af40cb61d1369bc018cbc
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
@@ -0,0 +1,6 @@
1
+ ---
2
+ language: ruby
3
+ cache: bundler
4
+ rvm:
5
+ - 2.6.1
6
+ before_install: gem install bundler -v 2.1.4
data/Gemfile ADDED
@@ -0,0 +1,12 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in dexter_plusplus.gemspec
4
+ gemspec
5
+
6
+ gem 'pry'
7
+ gem 'rest-client'
8
+ gem 'json'
9
+ gem 'colorize'
10
+ gem 'tty-prompt'
11
+ gem "rake", "~> 12.0"
12
+ gem "rspec", "~> 3.0"
@@ -0,0 +1,80 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ dexter_plusplus (0.1.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ coderay (1.1.3)
10
+ colorize (0.8.1)
11
+ diff-lcs (1.3)
12
+ domain_name (0.5.20190701)
13
+ unf (>= 0.0.5, < 1.0.0)
14
+ equatable (0.6.1)
15
+ http-accept (1.7.0)
16
+ http-cookie (1.0.3)
17
+ domain_name (~> 0.5)
18
+ json (2.3.0)
19
+ method_source (1.0.0)
20
+ mime-types (3.3.1)
21
+ mime-types-data (~> 3.2015)
22
+ mime-types-data (3.2020.0512)
23
+ necromancer (0.5.1)
24
+ netrc (0.11.0)
25
+ pastel (0.7.4)
26
+ equatable (~> 0.6)
27
+ tty-color (~> 0.5)
28
+ pry (0.13.1)
29
+ coderay (~> 1.1)
30
+ method_source (~> 1.0)
31
+ rake (12.3.3)
32
+ rest-client (2.1.0)
33
+ http-accept (>= 1.7.0, < 2.0)
34
+ http-cookie (>= 1.0.2, < 2.0)
35
+ mime-types (>= 1.16, < 4.0)
36
+ netrc (~> 0.8)
37
+ rspec (3.9.0)
38
+ rspec-core (~> 3.9.0)
39
+ rspec-expectations (~> 3.9.0)
40
+ rspec-mocks (~> 3.9.0)
41
+ rspec-core (3.9.2)
42
+ rspec-support (~> 3.9.3)
43
+ rspec-expectations (3.9.2)
44
+ diff-lcs (>= 1.2.0, < 2.0)
45
+ rspec-support (~> 3.9.0)
46
+ rspec-mocks (3.9.1)
47
+ diff-lcs (>= 1.2.0, < 2.0)
48
+ rspec-support (~> 3.9.0)
49
+ rspec-support (3.9.3)
50
+ tty-color (0.5.1)
51
+ tty-cursor (0.7.1)
52
+ tty-prompt (0.21.0)
53
+ necromancer (~> 0.5.0)
54
+ pastel (~> 0.7.0)
55
+ tty-reader (~> 0.7.0)
56
+ tty-reader (0.7.0)
57
+ tty-cursor (~> 0.7)
58
+ tty-screen (~> 0.7)
59
+ wisper (~> 2.0.0)
60
+ tty-screen (0.8.0)
61
+ unf (0.1.4)
62
+ unf_ext
63
+ unf_ext (0.0.7.7)
64
+ wisper (2.0.1)
65
+
66
+ PLATFORMS
67
+ ruby
68
+
69
+ DEPENDENCIES
70
+ colorize
71
+ dexter_plusplus!
72
+ json
73
+ pry
74
+ rake (~> 12.0)
75
+ rest-client
76
+ rspec (~> 3.0)
77
+ tty-prompt
78
+
79
+ BUNDLED WITH
80
+ 2.1.4
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2020 sean-slaughter
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,129 @@
1
+ Dexter++ : A Ruby CLI PokeDex Gem
2
+ BASE URL: https://pokeapi.co/api/v2/
3
+
4
+ Model classes:
5
+
6
+ Pokemon:
7
+
8
+ Attributes: Name
9
+ Type
10
+ Generation
11
+ Description
12
+ Moves
13
+ Abilities
14
+ Ability:
15
+
16
+ Attributes: Name
17
+ Effect
18
+
19
+ Move:
20
+
21
+ Attributes: Name
22
+ Accuracy
23
+ Power
24
+ PP
25
+ Type
26
+
27
+ Item:
28
+ Attributes: Name
29
+ Effect
30
+
31
+ Service classes:
32
+
33
+ API:
34
+
35
+ Methods:
36
+
37
+ #Pokemon
38
+ get_pokemon_by_name
39
+ get_pokemon_by_type
40
+ get_pokemon_by_generation
41
+ get_pokemon_by_id
42
+
43
+ #Ability
44
+ get_ability_by_name
45
+ get_ability_by_id
46
+
47
+ #Move
48
+ get_move_by_name
49
+ get_move_by_type
50
+ get_move_by_id
51
+
52
+ #Item
53
+ get_item_by_name
54
+ get_item_by_id
55
+
56
+ CLI:
57
+
58
+ Methods:
59
+
60
+ run: runs everything
61
+ greet_user: prints greeting
62
+ main_menu: asks user for input
63
+ load_data: loads data based on user input
64
+ exit: exit program
65
+
66
+
67
+ TODO 6/16:
68
+
69
+ 1. Create findable module and implement in classes
70
+ 2. Keep all class relationships assigned out of that class
71
+ 3. Figure out how to set ability, item and type attributes
72
+ 4. Create API class
73
+ 5. Create CLI class
74
+ 6. Write executable program (bring in ascii art)
75
+
76
+
77
+ TODO 6/18:
78
+
79
+ 1. Finish API class
80
+ 2. Make all objects printable (colorize)
81
+ 3. Start CLI class
82
+ 4. Reduce benchmark time if possible.
83
+ Benchmarks - 26 sec for 20 Pokemon
84
+ - 2:49 for 100 pokemon
85
+
86
+ TODO 6/18 end of day
87
+ 1. Test api methods
88
+ 2. Fix bugs
89
+ 3. Write CLI
90
+ 4. Test everything
91
+ 5. Update github docuementation
92
+ 6. Get to rubygems.org
93
+
94
+ TODO 6/19 end of day
95
+ Add info to types
96
+ Write CLI
97
+ update github doc
98
+ get to rubygems
99
+
100
+
101
+
102
+ BUGS!!!
103
+
104
+
105
+
106
+ -⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨
107
+
108
+
109
+
110
+ ██████╗░███████╗██╗░░██╗████████╗███████╗██████╗░░░░░░░░░░░░░░░
111
+ ██╔══██╗██╔════╝╚██╗██╔╝╚══██╔══╝██╔════╝██╔══██╗░░██╗░░░░██╗░░
112
+ ██║░░██║█████╗░░░╚███╔╝░░░░██║░░░█████╗░░██████╔╝██████╗██████╗
113
+ ██║░░██║██╔══╝░░░██╔██╗░░░░██║░░░██╔══╝░░██╔══██╗╚═██╔═╝╚═██╔═╝
114
+ ██████╔╝███████╗██╔╝╚██╗░░░██║░░░███████╗██║░░██║░░╚═╝░░░░╚═╝░░
115
+ ╚═════╝░╚══════╝╚═╝░░╚═╝░░░╚═╝░░░╚══════╝╚═╝░░╚═╝░░░░░░░░░░░░░░
116
+
117
+
118
+
119
+ 🄰🄽 🄴🄽🄷🄰🄽🄲🄴🄳 🄿🄾🄺🄴🄳🄴🅇 🄱🅈 🅂🄴🄰🄽 🅃🄷🄾🄼🄿🅂🄾🄽
120
+
121
+
122
+ -⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨
123
+
124
+
125
+
126
+
127
+
128
+
129
+
@@ -0,0 +1,40 @@
1
+ # DexterPlusplus
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/dexter_plusplus`. 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 'dexter_plusplus'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle install
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install dexter_plusplus
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]/dexter_plusplus.
36
+
37
+
38
+ ## License
39
+
40
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -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
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "dexter_plusplus"
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__)
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require_relative "../lib/environment"
4
+
5
+ cli = CLI.new
6
+ cli.run
7
+
8
+
9
+
@@ -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,29 @@
1
+ require_relative 'lib/dexter_plusplus/version'
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = "dexter_plusplus"
5
+ spec.version = DexterPlusplus::VERSION
6
+ spec.authors = ["sean-slaughter"]
7
+ spec.email = ["sthompson2822@gmail.com"]
8
+
9
+ spec.summary = %q{A Ruby PokeDex Gem that allows users to explore Pokemon and Items in the Pokemon Universe }
10
+ spec.homepage = "https://github.com/sean-slaughter/dexter-plusplus"
11
+ spec.license = "MIT"
12
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
13
+
14
+
15
+
16
+ spec.metadata["homepage_uri"] = spec.homepage
17
+ spec.metadata["source_code_uri"] = "https://github.com/sean-slaughter/dexter-plusplus"
18
+ spec.metadata["changelog_uri"] = "https://github.com/sean-slaughter/dexter-plusplus"
19
+
20
+ # Specify which files should be added to the gem when it is released.
21
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
22
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
23
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
24
+ end
25
+ spec.executables = ["dexter-plusplus"]
26
+ spec.require_paths = ["lib"]
27
+
28
+
29
+ end
@@ -0,0 +1,61 @@
1
+ module Findable
2
+
3
+ BASE_URL = "https://pokeapi.co/api/v2"
4
+
5
+ def find_or_create_by_name(name)
6
+ url = "#{BASE_URL}/#{self.tag}/#{name}"
7
+ if self.find_by_name(name).nil?
8
+ self.new(name, url)
9
+ else
10
+ self.find_by_name(name)
11
+ end
12
+ end
13
+
14
+ def find_by_name(name)
15
+ self.all.find{|i| i.name == name}
16
+ end
17
+
18
+ def find_by_type(type)
19
+ output = []
20
+ data = JSON.parse(RestClient.get("#{BASE_URL}/type/#{type}/"))
21
+ if self.tag == "pokemon"
22
+ data["#{self.tag}"].each{|i| output << i["#{self.tag}"]["name"]}
23
+ elsif self.tag == "move"
24
+ data["#{self.tag}s"].each{|i| output << i["name"]}
25
+ end
26
+ output
27
+ end
28
+
29
+
30
+ def find_with_offset_and_limit(offset = rand(0...self.limit), limit = 1)
31
+ output = []
32
+ url = "#{BASE_URL}/#{self.tag}?limit=#{limit}&offset=#{offset}"
33
+ data = JSON.parse(RestClient.get(url))
34
+ data["results"].each{|i|output << i["name"].capitalize}
35
+ output
36
+ end
37
+
38
+ def find_list_by_type(type)
39
+ output = []
40
+ url = "#{BASE_URL}/type/#{type}"
41
+ data = JSON.parse(RestClient.get(url))
42
+ if self.tag == "move"
43
+ data["moves"].each{|i| output << i["name"].capitalize}
44
+ else
45
+ data["pokemon"].each{|i| output << i["pokemon"]["name"].capitalize}
46
+ end
47
+ output
48
+ end
49
+
50
+ def find_random
51
+ self.find_or_create_by_name(self.find_with_offset_and_limit()[0].downcase)
52
+ end
53
+
54
+ def find_from_array(array)
55
+ output = []
56
+ array.each do |i|
57
+ output << self.find_or_create_by_name(i["#{self.tag}"]["name"])
58
+ end
59
+ output
60
+ end
61
+ end