pokepaste 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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 6d17c57c81b0801cd9628e74eb0a1632fbf0be50fa2a2cec58b3b0bdd10492e4
4
+ data.tar.gz: d6b16c078757ff881a8e87341330f10e8c7ac94c36aac2da960ae53db32882fb
5
+ SHA512:
6
+ metadata.gz: 142c409f1da71ff043710f94f48a03953fdf26682079a7abc54e3f9a6395e1d43b2164156b6c556f8627904e837ebea114304407af8f78d279b68aecf033fd51
7
+ data.tar.gz: b5bd9cb65f42d138aec7b22d8bb496ce8b4980cdda65ae5cff2963357109680a7e156da3040588545aba1e43df723129dc3f48385dbae1ebd08a266b12fe558f
data/LICENSE.md ADDED
@@ -0,0 +1,21 @@
1
+ # MIT License
2
+
3
+ Copyright © 2023 Vinny Diehl
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
9
+ of the Software, and to permit persons to whom the Software is furnished to do
10
+ so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ 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 THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,108 @@
1
+ # PokéPaste Ruby
2
+
3
+ Ruby parser for [PokéPaste](https://pokepast.es/syntax.html), the format used
4
+ by Pokémon Showdown and various teambuilders.
5
+
6
+ ## Installation
7
+
8
+ Install with RubyGems:
9
+
10
+ ```bash
11
+ gem install pokepaste
12
+ ```
13
+
14
+ If using in your application, include in your `Gemfile`:
15
+
16
+ ```ruby
17
+ gem "pokepaste"
18
+ ```
19
+
20
+ or your `.gemspec`:
21
+
22
+ ```ruby
23
+ Gem::Specification.new do |gem|
24
+ # ...
25
+
26
+ gem.add_runtime_dependency "pokepaste"
27
+ end
28
+ ```
29
+
30
+ ## Usage
31
+
32
+ To parse a PokéPaste:
33
+
34
+ ```ruby
35
+ # From a string
36
+ team = PokePaste::parse(str)
37
+
38
+ # From pokepast.es
39
+ team = PokePaste::fetch("https://pokepast.es/5c46f9ec443664cb")
40
+ team = PokePaste::fetch("5c46f9ec443664cb") # full URL optional
41
+ ```
42
+
43
+ Once you have it parsed, you have an instance of `PokePaste::Team`, an
44
+ Enumerable containing an instance of `PokePaste::Pokemon` for each Pokémon on
45
+ the team. You can loop over the team as with any Enumerable, and access the
46
+ data like so:
47
+
48
+ ```ruby
49
+ team.each do |pkmn|
50
+ pkmn.species # required
51
+ pkmn.nickname # default null
52
+ pkmn.gender # default null
53
+ pkmn.item # default null
54
+
55
+ # EVs and IVs are hashes with the stat as the key
56
+ # (:hp, :atk, :def, :spa, :spd, or :spe)
57
+ pkmn.evs[:hp] # default 0
58
+ pkmn.ivs[:spa] # default 31
59
+
60
+ pkmn.shiny? # default is false
61
+ pkmn.ability # default is null
62
+ pkmn.level # default is 50
63
+ pkmn.happiness # default is 255
64
+ pkmn.nature # default is :hardy (neutral nature)
65
+
66
+ # Moves are an array with the names of the moves as strings. If more than
67
+ # one move is specified for a slot, they will be put into an array
68
+ pkmn.moves # default is []
69
+ end
70
+ ```
71
+
72
+ You can edit any of these properties, and process back into PokéPaste format
73
+ with `#to_s`:
74
+
75
+ ```ruby
76
+ paste = team.to_s
77
+ single_pokemon = team[3].to_s
78
+ ```
79
+
80
+ To make a new paste, you can initialize a new `PokePaste::Team` and populate
81
+ it like so:
82
+
83
+ ```ruby
84
+ team = PokePaste::Team.new
85
+
86
+ team << PokePaste::Pokemon.new(
87
+ species: "Bulbasaur",
88
+ nickname: "Bud",
89
+ ivs: {atk: 0},
90
+ moves: %w[Tackle Growl]
91
+ )
92
+
93
+ puts team # prints the paste
94
+ ```
95
+
96
+ And I suppose if you wanted to use this library just to fetch the raw text from
97
+ a paste on [pokepast.es](https://pokepast.es/), you could:
98
+
99
+ ```ruby
100
+ raw_paste = PokePaste.fetch(url_or_id).to_s
101
+ ```
102
+
103
+ ## License
104
+
105
+ This library is released under the MIT license. See the
106
+ [`LICENSE.md`](https://github.com/vinnydiehl/pokepaste-ruby/blob/master/LICENSE.md)
107
+ file included with this code or
108
+ [the official page on OSI](http://opensource.org/licenses/MIT) for more information.
data/Rakefile ADDED
@@ -0,0 +1,16 @@
1
+ require "bundler"
2
+ Bundler::GemHelper.install_tasks
3
+
4
+ require "rspec/core/rake_task"
5
+ RSpec::Core::RakeTask.new :spec
6
+ task test: :spec
7
+
8
+ require "yard"
9
+ YARD::Rake::YardocTask.new do |doc|
10
+ doc.files << "lib/**/*.rb"
11
+ doc.options << ["--title", "PokéPaste Ruby #{File.read 'VERSION'} Documentation"]
12
+ end
13
+ task doc: :yard
14
+
15
+ task dist: :build
16
+ task default: :spec
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0
@@ -0,0 +1,18 @@
1
+ module PokePaste
2
+ class Team
3
+ include Enumerable
4
+ extend Forwardable
5
+ def_delegators :@team, *%i[size length [] empty? last index]
6
+
7
+ def initialize(paste)
8
+ @team = []
9
+ end
10
+
11
+ def each(&block)
12
+ @team.each &block
13
+ end
14
+
15
+ def to_s
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,9 @@
1
+ module PokePaste
2
+ class Pokemon
3
+ def initialize
4
+ end
5
+
6
+ def to_s
7
+ end
8
+ end
9
+ end
data/lib/pokepaste.rb ADDED
@@ -0,0 +1,10 @@
1
+ require "pokepaste/paste"
2
+ require "pokepaste/pokemon"
3
+
4
+ module PokePaste
5
+ def parse(paste)
6
+ end
7
+
8
+ def fetch(str)
9
+ end
10
+ end
data/pokepaste.gemspec ADDED
@@ -0,0 +1,25 @@
1
+ Gem::Specification.new do |gem|
2
+ gem.name = "pokepaste"
3
+ gem.version = File.read "VERSION"
4
+
5
+ gem.author = "Vinny Diehl"
6
+ gem.email = "vinny.diehl@gmail.com"
7
+ gem.homepage = "https://github.com/vinnydiehl/pokepaste-ruby"
8
+
9
+ gem.license = "MIT"
10
+
11
+ gem.summary = "PokéPaste parser for Ruby"
12
+ gem.description = "Parses PokéPastes into an object that you can easily read/manipulate/save."
13
+
14
+ gem.require_paths = %w[lib]
15
+ gem.test_files = Dir["spec/**/*"]
16
+ gem.files = Dir["lib/**/*"] + gem.test_files + %w[
17
+ VERSION Rakefile README.md LICENSE.md pokepaste.gemspec
18
+ ]
19
+
20
+ gem.required_ruby_version = ">= 2.0"
21
+ gem.add_development_dependency "rake", "~> 13.0"
22
+ gem.add_development_dependency "rspec", "~> 3.12"
23
+ gem.add_development_dependency "fuubar", "~> 2.5"
24
+ gem.add_development_dependency "yard", "~> 0.9"
25
+ end
@@ -0,0 +1,22 @@
1
+ # Include all files in spec/support
2
+ Dir[File.expand_path("../support/**/*.rb", __FILE__)].each { |f| require f }
3
+
4
+ RSpec.configure do |config|
5
+ # Fuubar
6
+ config.add_formatter "Fuubar"
7
+ config.fuubar_progress_bar_options = { format: " %c/%C |%b>%i|%e " }
8
+
9
+ # More verbose output if only running one spec
10
+ config.default_formatter = "doc" if config.files_to_run.one?
11
+
12
+ # Print the 10 slowest examples and example groups at the
13
+ # end of the spec run, to help surface which specs are running
14
+ # particularly slow.
15
+ config.profile_examples = 10
16
+
17
+ # Run specs in random order to surface order dependencies. If you find an
18
+ # order dependency and want to debug it, fix the order by providing the seed,
19
+ # which is printed after each run, e.g. --seed 1234
20
+ config.order = :random
21
+ Kernel.srand config.seed
22
+ end
metadata ADDED
@@ -0,0 +1,108 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pokepaste
3
+ version: !ruby/object:Gem::Version
4
+ version: '0.0'
5
+ platform: ruby
6
+ authors:
7
+ - Vinny Diehl
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2023-03-04 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rake
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '13.0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '13.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rspec
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '3.12'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '3.12'
41
+ - !ruby/object:Gem::Dependency
42
+ name: fuubar
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '2.5'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '2.5'
55
+ - !ruby/object:Gem::Dependency
56
+ name: yard
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '0.9'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '0.9'
69
+ description: Parses PokéPastes into an object that you can easily read/manipulate/save.
70
+ email: vinny.diehl@gmail.com
71
+ executables: []
72
+ extensions: []
73
+ extra_rdoc_files: []
74
+ files:
75
+ - LICENSE.md
76
+ - README.md
77
+ - Rakefile
78
+ - VERSION
79
+ - lib/pokepaste.rb
80
+ - lib/pokepaste/paste.rb
81
+ - lib/pokepaste/pokemon.rb
82
+ - pokepaste.gemspec
83
+ - spec/spec_helper.rb
84
+ homepage: https://github.com/vinnydiehl/pokepaste-ruby
85
+ licenses:
86
+ - MIT
87
+ metadata: {}
88
+ post_install_message:
89
+ rdoc_options: []
90
+ require_paths:
91
+ - lib
92
+ required_ruby_version: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '2.0'
97
+ required_rubygems_version: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - ">="
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ requirements: []
103
+ rubygems_version: 3.4.6
104
+ signing_key:
105
+ specification_version: 4
106
+ summary: PokéPaste parser for Ruby
107
+ test_files:
108
+ - spec/spec_helper.rb