monster_index 0.1.1
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 +7 -0
- data/.gitignore +36 -0
- data/.rspec +2 -0
- data/.travis.yml +4 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +47 -0
- data/LICENSE.txt +21 -0
- data/NOTES.txt +18 -0
- data/README.md +41 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/monster_index +6 -0
- data/bin/setup +8 -0
- data/d/033OAfadsf +1 -0
- data/lib/monster_index.rb +7 -0
- data/lib/monster_index/cli.rb +43 -0
- data/lib/monster_index/monster.rb +67 -0
- data/lib/monster_index/scraper.rb +83 -0
- data/lib/monster_index/version.rb +3 -0
- data/monster_index.gemspec +34 -0
- metadata +135 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: d3e4dc4a644c14443d132174982910020f4d397d
|
4
|
+
data.tar.gz: 8a33a3083e63f351670ccad55be30db1184531a4
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 835795b7016cf4518036b2b09c6606b5537e596e3d2fbc10c7505d7b3ce2fba370285de08499765dccfb983825c5cc2bfa4843bb36cef85b9b14b0810804eeca
|
7
|
+
data.tar.gz: 5352a3b64e7edcee38c2eb89adad9bcfe35f3b8dba1c10e403798c37b6a10c4c6123bb5bb5ca73b863dfa27dae5720d19e86dd467ab8b6dfd0ec992ce856fa74
|
data/.gitignore
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
/.config
|
4
|
+
/coverage/
|
5
|
+
/InstalledFiles
|
6
|
+
/pkg/
|
7
|
+
/spec/reports/
|
8
|
+
/spec/examples.txt
|
9
|
+
/test/tmp/
|
10
|
+
/test/version_tmp/
|
11
|
+
/tmp/
|
12
|
+
|
13
|
+
## Specific to RubyMotion:
|
14
|
+
.dat*
|
15
|
+
.repl_history
|
16
|
+
build/
|
17
|
+
|
18
|
+
## Documentation cache and generated files:
|
19
|
+
/.yardoc/
|
20
|
+
/_yardoc/
|
21
|
+
/doc/
|
22
|
+
/rdoc/
|
23
|
+
|
24
|
+
## Environment normalization:
|
25
|
+
/.bundle/
|
26
|
+
/vendor/bundle
|
27
|
+
/lib/bundler/man/
|
28
|
+
|
29
|
+
# for a library or gem, you might want to ignore these files since the code is
|
30
|
+
# intended to run in multiple environments; otherwise, check them in:
|
31
|
+
# Gemfile.lock
|
32
|
+
# .ruby-version
|
33
|
+
# .ruby-gemset
|
34
|
+
|
35
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
36
|
+
.rvmrc
|
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
monster_index (0.1.0)
|
5
|
+
nokogiri
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
coderay (1.1.0)
|
11
|
+
diff-lcs (1.2.5)
|
12
|
+
method_source (0.8.2)
|
13
|
+
mini_portile2 (2.0.0)
|
14
|
+
nokogiri (1.6.7.2)
|
15
|
+
mini_portile2 (~> 2.0.0.rc2)
|
16
|
+
pry (0.10.3)
|
17
|
+
coderay (~> 1.1.0)
|
18
|
+
method_source (~> 0.8.1)
|
19
|
+
slop (~> 3.4)
|
20
|
+
rake (10.1.0)
|
21
|
+
rspec (3.4.0)
|
22
|
+
rspec-core (~> 3.4.0)
|
23
|
+
rspec-expectations (~> 3.4.0)
|
24
|
+
rspec-mocks (~> 3.4.0)
|
25
|
+
rspec-core (3.4.1)
|
26
|
+
rspec-support (~> 3.4.0)
|
27
|
+
rspec-expectations (3.4.0)
|
28
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
29
|
+
rspec-support (~> 3.4.0)
|
30
|
+
rspec-mocks (3.4.0)
|
31
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
32
|
+
rspec-support (~> 3.4.0)
|
33
|
+
rspec-support (3.4.1)
|
34
|
+
slop (3.6.0)
|
35
|
+
|
36
|
+
PLATFORMS
|
37
|
+
ruby
|
38
|
+
|
39
|
+
DEPENDENCIES
|
40
|
+
bundler (~> 1.11)
|
41
|
+
monster_index!
|
42
|
+
pry
|
43
|
+
rake (~> 10.0)
|
44
|
+
rspec (~> 3.0)
|
45
|
+
|
46
|
+
BUNDLED WITH
|
47
|
+
1.11.2
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Morgan VanYperen
|
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/NOTES.txt
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
monster_index
|
2
|
+
|
3
|
+
Welcome to monster index. Type list to see them all, type any letter to see the monsters starting with that letter, type the name of a monster to see details, or type exit.
|
4
|
+
|
5
|
+
list
|
6
|
+
list all the monsters in alphabetical order
|
7
|
+
|
8
|
+
|
9
|
+
(a-z)
|
10
|
+
list monsters starting with letter in alphabetical order
|
11
|
+
|
12
|
+
|
13
|
+
name of monster
|
14
|
+
show monster profile (description, stats)
|
15
|
+
|
16
|
+
|
17
|
+
exit
|
18
|
+
seeya next time
|
data/README.md
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
# MonsterIndex
|
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/monster_index`. 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 'monster_index'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install monster_index
|
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]/monster_index.
|
36
|
+
|
37
|
+
|
38
|
+
## License
|
39
|
+
|
40
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
41
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "monster_index"
|
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
|
data/bin/monster_index
ADDED
data/bin/setup
ADDED
data/d/033OAfadsf
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
=> [31m[1;31m"[0m[31mAbout This SiteFrequently Asked QuestionsChanges from the Official d20 SRDOpen Game LicenseBrowser GoodiesDownload The Sited20 Dice Bagd20 Encounter Calculatord20 Monster Filterd20 Spell Filterd20 System InfoOfficial SRDd20 Modern SRDSRD FAQOpen Gaming FoundationAAasimarAbolethAchaieraiAir ElementalAir MephitAllipAndrosphinxAngelAnimated ObjectAnkhegAnnisApeAquatic ElfAraneaArchonArrowhawkAssassin VineAstral DevaAthachAvoralAzerBBabauBaboonBadgerBalorBarbed Devil (Hamatula)BarghestBasiliskBat SwarmBatBear, BlackBear, BrownBear, PolarBearded Devil (Barbazu)BebilithBehirBelkerBisonBlack DragonBlack PuddingBlink DogBlue DragonBoarBodakBone Devil (Osyluth)BralaniBrass DragonBronze DragonBugbearBuletteCCamelCatCauchemarCelestial CreatureCentaurCentipede SwarmChain Devil (Kyton)Chaos BeastCheetahChimeraChokerChuulClay GolemCloakerCloud GiantCockatriceCopper DragonCouatlCriosphinxCrocodile, GiantCrocodileCryohydraDDark NagaDarkmantleDeep DwarfDeep HalflingDeinonychusDelverDemonDerroDestrachanDevilDevourerDigesterDinosaurDire AnimalDire ApeDire BadgerDire BatDire BearDire BoarDire LionDire RatDire SharkDire TigerDire WeaselDire WolfDire WolverineDjinniDog, RidingDogDonkeyDoppelgangerDragon TurtleDragon, TrueDragonneDretchDriderDrowDryadDuergarDust MephitDwarfEEagle, GiantEagleEarth ElementalEarth MephitEfreetiElasmosaurusElementalElephantElfErinyesEthereal FilcherEthereal MarauderEttercapEttinFFiendish CreatureFire ElementalFire GiantFire MephitFlesh GolemForest GnomeFormianFrost GiantFrost WormFungusGGargoyleGelatinous CubeGenieGhaeleGhastGhostGhoulGiant AntGiant BeeGiant Bombardier BeetleGiant Fire BeetleGiant Praying MantisGiant Stag BeetleGiant WaspGiantGibbering MoutherGirallonGlabrezuGnollGnomeGoblinGold DragonGolemGorgonGray ElfGray OozeGray RenderGreen DragonGreen HagGrickGriffonGrigGrimlockGuardian NagaGynosphinxHHagHalf-CelestialHalf-DragonHalf-ElfHalf-FiendHalflingHalf-OrcHarpyHawkHell HoundHellcat (Bezekira)Hellwasp SwarmHezrouHieracosphinxHill GiantHippogriffHobgoblinHomunculusHorned Devil (Cornugon)HorseHound ArchonHowlerHydraHyena I Ice Devil (Gelugon)Ice MephitImpInevitableInvisible StalkerIron GolemJJanniKKapoacinthKoboldKolyarutKrakenKrensharLLacedonLamiaLammasuLantern ArchonLemureLeonalLeopardLichLillendLionLizard, MonitorLizardLizardfolkLocathahLocust SwarmLycanthropeMMagma MephitMagminMalentiManta RayManticoreMarilithMarutMedusaMegaraptorMephitMerfolkMerrowMimicMinotaurMohrgMonkeyMonstrous CentipedeMonstrous ScorpionMonstrous SpiderMountain DwarfMuleMummy LordMummyNNagaNalfeshneeNessian WarhoundNight HagNightcrawlerNightmareNightshadeNightwalkerNightwingNixieNymphOOchre JellyOctopus, GiantOctopusOgre MageOgreOoze MephitOozeOrcOtyughOwl, GiantOwlOwlbearPPegasusPhantom FungusPhase SpiderPhasmPit FiendPixiePlanetarPlanetouchedPony, WarPonyPorpoisePseudodragonPurple WormPyrohydraQQuasitRRakshasaRastRat SwarmRatRavenRavidRazor BoarRed DragonRemorhazRetrieverRhinocerosRocRoperRust MonsterSSahuaginSalamanderSalt MephitSatyrScorpionfolkScragSea CatSea HagShadow MastiffShadowShambling MoundSharkShield GuardianShocker LizardShriekerSilver DragonSkeletonSkumSnakeSolarSpectreSphinxSpider EaterSpider SwarmSpirit NagaSpriteSquid, GiantSquidSteam MephitStirgeStone GiantStone GolemStorm GiantSuccubusSvirfneblinSwarmTTallfellow HalflingTarrasqueTendriculosThoqquaTieflingTigerTitanToadTojanidaTreantTriceratopsTritonTroglodyteTrollTrumpet ArchonTyrannosaurusUUnicornVVampire SpawnVampireVargouilleViolet FungusVrockWWater ElementalWater MephitWater NagaWeaselWerebearWereboarWereratWeretigerWerewolfWhaleWhite DragonWightWild ElfWill-O’-WispWinter WolfWolfWolverineWood ElfWorgWraithWyvernXXillXornYYeth HoundYrthakZZelekhutZombieAbolethAboleth MageAchaieraiAllipAngelAngel, Astral DevaAngel, PlanetarAngel, SolarAnimated ObjectAnkhegAraneaArchonLantern ArchonHound ArchonHound Archon HeroTrumpet ArchonArrowhawkAssassin VineAthachAvoralAzerBarghestGreater BarghestBasiliskAbyssal Greater BasiliskBehirBelkerBlink DogBodakBralaniBugbearBuletteCelestial CreatureCentaurChaos BeastChimeraChokerChuulCloakerCockatriceCouatlDarkmantleDelverDemonBabauBalorBebilithDretchGlabrezuHezrouMarilithNalfeshneeQuasitRetrieverSuccubusVrockDerroDestrachanDevilBarbed Devil (Hamatula)Bearded Devil (Barbazu)Bone Devil (Osyluth)Chain Devil (Kyton)ErinyesHellcat (Bezekira)Horned Devil (Cornugon)Ice Devil (Gelugon)ImpLemurePit FiendDevourerDigesterDinosaurDeinonychusElasmosaurusMegaraptorTriceratopsTyrannosaurusDire AnimalDire ApeDire BadgerDire BatDire BearDire BoarDire LionDire RatDire SharkDire TigerDire WeaselDire WolfDire WolverineDoppelgangerDragon, TrueChromatic DragonsBlack DragonBlue DragonGreen DragonRed DragonWhite DragonMetallic DragonsBrass DragonBronze DragonCopper DragonGold DragonSilver DragonDragon TurtleDragonneDriderDryadDwarfDeep DwarfDuergarMountain DwarfEagle, GiantElementalAir ElementalEarth ElementalFire ElementalWater ElementalElfHalf-ElfAquatic ElfDrowGray ElfWild ElfWood ElfEthereal FilcherEthereal MarauderEttercapEttinFiendish CreatureFormianWorkerWarriorTaskmasterMyrmarchQueenFrost WormFungusShriekerViolet FungusGargoyleKapoacinthGenieDjinniNoble DjinnEfreetiJanniGhaeleGhostGhoulLacedonGhastGiantCloud GiantFire GiantFrost GiantFrost Giant JarlHill GiantStone GiantStone Giant EldersStorm GiantGibbering MoutherGirallonGnollGnomeSvirfneblinForest GnomeGoblinGolemClay GolemFlesh GolemIron GolemStone GolemGreater Stone GolemGorgonGray RenderGrickGriffonGrimlockHagAnnisGreen HagSea HagHalf-CelestialHalf-DragonHalf-FiendHalflingTallfellowDeep HalflingHarpyHarpy ArcherHell HoundNessian WarhoundHippogriffHobgoblinHomunculusHowlerHydraPyrohydraCryohydraInevitableKolyarutMarutZelekhutInvisible StalkerKoboldKrakenKrensharLamiaLammasuGolden ProtectorLeonalLichLillendLizardfolkLocathahLycanthropeWerebearWereboarHill Giant Dire WereboarWereratWeretigerWerewolfWerewolf LordMagminManticoreMedusaMephitAir MephitDust MephitEarth MephitFire MephitIce MephitMagma MephitOoze MephitSalt MephitSteam MephitWater MephitMerfolkMimicMinotaurMohrgMummyMummy LordNagaDark NagaGuardian NagaSpirit NagaWater NagaNight HagNightmareCauchemarNightshadeNightcrawlerNightwalkerNightwingNymphOgreOgre BarbarianMerrowOgre MageOozeBlack PuddingElder Black PuddingGelatinous CubeGray OozeOchre JellyOrcHalf-OrcsOtyughOwl, GiantOwlbearPegasusPhantom FungusPhase SpiderPhasmPlanetouchedAasimarTieflingPseudodragonPurple WormRakshasaRastRavidRazor BoarRemorhazRocRoperRust MonsterSahuaginSahuagin MutantsMalentiSalamanderSatyrScorpionfolkSea CatShadowGreater ShadowShadow MastiffShambling MoundShield GuardianShocker LizardSkeletonSkumSpectreSphinxAndrosphinxCriosphinxGynosphinxHieracosphinxSpider EaterSpriteGrigNixiePixieStirgeSwarmBat SwarmCentipede SwarmHellwasp SwarmLocust SwarmRat SwarmSpider SwarmTarrasqueTendriculosThoqquaTitanTojanidaTreantTritonTroglodyteTrollScragTroll HunterUnicornCelestial ChargerVampireVampire SpawnVargouilleWightWill-O’-WispWinter WolfWorgWraithDread WraithWyvernXillXornYeth HoundYrthakZombieApeBaboonBadgerBatBear, BlackBear, BrownBear, PolarBisonBoarCamelCatCheetahCrocodileCrocodile, GiantDogDog, RidingDonkeyEagleElephantHawkHorseHorse, HeavyHorse, LightWarhorse, HeavyWarhorse, LightHyenaLeopardLionLizardLizard, MonitorManta RayMonkeyMuleOctopusOctopus, GiantOwlPonyPony, WarPorpoiseRatRavenRhinocerosSharkSnakeConstrictor SnakeViper SnakeSquidSquid, GiantTigerToadWeaselWhaleBaleen WhaleCachalot WhaleOrcaWolfWolverineGiant AntGiant BeeGiant Bombardier BeetleGiant Fire BeetleGiant Stag BeetleGiant Praying MantisGiant WaspMonstrous CentipedeMonstrous ScorpionMonstrous SpiderSection 508WAI-AAAValid XHTMLValid CSS[1;31m"[0m[31m[0m
|
@@ -0,0 +1,43 @@
|
|
1
|
+
class MonsterIndex::CLI
|
2
|
+
|
3
|
+
def call
|
4
|
+
start
|
5
|
+
end
|
6
|
+
|
7
|
+
def start
|
8
|
+
puts "Welcome to Monster Index!"
|
9
|
+
puts "Loading monsters..."
|
10
|
+
make_monsters
|
11
|
+
options
|
12
|
+
end
|
13
|
+
|
14
|
+
def make_monsters
|
15
|
+
monster_array = MonsterIndex::Scraper.scrape_index_page
|
16
|
+
MonsterIndex::Monster.create_from_collection(monster_array)
|
17
|
+
end
|
18
|
+
|
19
|
+
def add_attributes_to_monster(monster)
|
20
|
+
attributes_hash = MonsterIndex::Scraper.scrape_monster_page(monster.url)
|
21
|
+
monster.add_monster_attributes(attributes_hash)
|
22
|
+
end
|
23
|
+
|
24
|
+
def options
|
25
|
+
input = ""
|
26
|
+
while input != "exit"
|
27
|
+
puts "Type list to see them all, type any letter to see the monsters starting"
|
28
|
+
puts "with that letter, type the name of a monster to see details, or type exit."
|
29
|
+
puts
|
30
|
+
input = gets.strip
|
31
|
+
if input.downcase == "list"
|
32
|
+
MonsterIndex::Monster.list
|
33
|
+
elsif input.match(/\A[a-zA-Z]\z/)
|
34
|
+
MonsterIndex::Monster.list_some(input)
|
35
|
+
elsif MonsterIndex::Monster.get_names.any? {|name| name == input}
|
36
|
+
monster = MonsterIndex::Monster.get_monster(input)
|
37
|
+
add_attributes_to_monster(monster)
|
38
|
+
MonsterIndex::Monster.view_profile(input)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
class MonsterIndex::Monster
|
2
|
+
attr_accessor :name, :size_type, :hit_dice, :initiative, :speed, :ac, :attack, :alignment, :url
|
3
|
+
|
4
|
+
@@all = []
|
5
|
+
|
6
|
+
def initialize(monster_hash = {})
|
7
|
+
monster_hash.each {|key, value| self.send(("#{key}="), value)}
|
8
|
+
@@all << self
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.create_from_collection(monster_array)
|
12
|
+
monster_array.each do |monster_hash|
|
13
|
+
self.new(monster_hash)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def add_monster_attributes(attributes_hash)
|
18
|
+
attributes_hash.each {|key, value| self.send(("#{key}="), value)}
|
19
|
+
self
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.get_names
|
23
|
+
names = []
|
24
|
+
@@all.each do |monster|
|
25
|
+
names << monster.name
|
26
|
+
end
|
27
|
+
names
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.list
|
31
|
+
@@all.each do |monster|
|
32
|
+
puts "#{monster.name}"
|
33
|
+
end
|
34
|
+
puts
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.list_some(letter)
|
38
|
+
@@all.each do |monster|
|
39
|
+
if monster.name.downcase.match(/\A[#{letter.downcase}]/)
|
40
|
+
puts "#{monster.name}"
|
41
|
+
end
|
42
|
+
end
|
43
|
+
puts
|
44
|
+
end
|
45
|
+
|
46
|
+
def self.view_profile(name)
|
47
|
+
monster = @@all.find {|one| one.name == name}
|
48
|
+
puts "Size/Type: #{monster.size_type}"
|
49
|
+
puts "Hit Dice: #{monster.hit_dice}"
|
50
|
+
puts "Initiative: #{monster.initiative}"
|
51
|
+
puts "Speed: #{monster.speed}"
|
52
|
+
puts "AC: #{monster.ac}"
|
53
|
+
puts "Attack: #{monster.attack}"
|
54
|
+
puts "Alignment: #{monster.alignment}"
|
55
|
+
puts "More info at: #{monster.url}"
|
56
|
+
puts
|
57
|
+
end
|
58
|
+
|
59
|
+
def self.get_monster(name)
|
60
|
+
@@all.find {|one| one.name == name}
|
61
|
+
end
|
62
|
+
|
63
|
+
def self.all
|
64
|
+
@@all
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
class MonsterIndex::Scraper
|
2
|
+
|
3
|
+
def self.scrape_index_page
|
4
|
+
doc = Nokogiri::HTML(open("http://www.d20srd.org/indexes/monsters.htm"))
|
5
|
+
monsters = []
|
6
|
+
doc.search("ul.column li a").each do |monster|
|
7
|
+
monsters << {
|
8
|
+
name: monster.text,
|
9
|
+
url: "http://www.d20srd.org#{monster.attr("href")}"
|
10
|
+
}
|
11
|
+
end
|
12
|
+
monsters.delete_if do |monster|
|
13
|
+
monster[:name] == "Aboleth Mage" ||
|
14
|
+
monster[:name].include?("Archon") ||
|
15
|
+
monster[:name].include?("Angel") ||
|
16
|
+
monster[:name] == "Greater Barghest" ||
|
17
|
+
monster[:name] == "Abyssal Greater Basilisk" ||
|
18
|
+
monster[:url].include?("demon") ||
|
19
|
+
monster[:url].include?("devil") ||
|
20
|
+
monster[:url].include?("dinosaur") ||
|
21
|
+
monster[:name] == "Dire Animal" ||
|
22
|
+
monster[:url].include?("dragon") ||
|
23
|
+
monster[:url].include?("dwarf") ||
|
24
|
+
monster[:url].include?("elemental") ||
|
25
|
+
monster[:url].include?("elf") ||
|
26
|
+
monster[:url].include?("formian") ||
|
27
|
+
monster[:url].include?("fungus") ||
|
28
|
+
monster[:name] == "Kapoacinth" ||
|
29
|
+
monster[:url].include?("genie") ||
|
30
|
+
monster[:url].include?("ghoul") ||
|
31
|
+
monster[:url].include?("giant") ||
|
32
|
+
monster[:url].include?("gnome") ||
|
33
|
+
monster[:url].include?("golem") ||
|
34
|
+
monster[:url].include?("hag") ||
|
35
|
+
monster[:url].include?("halfling") ||
|
36
|
+
monster[:url].include?("harpy") ||
|
37
|
+
monster[:url].include?("hellHound") ||
|
38
|
+
monster[:url].include?("hydra") ||
|
39
|
+
monster[:url].include?("inevitable") ||
|
40
|
+
monster[:url].include?("lammasu") ||
|
41
|
+
monster[:url].include?("lycanthrope") ||
|
42
|
+
monster[:url].include?("mephit") ||
|
43
|
+
monster[:url].include?("mummy") ||
|
44
|
+
monster[:url].include?("naga") ||
|
45
|
+
monster[:url].include?("nightmare") ||
|
46
|
+
monster[:url].include?("nightshade") ||
|
47
|
+
monster[:url].include?("ogre") ||
|
48
|
+
monster[:url].include?("ooze") ||
|
49
|
+
monster[:name].include?("Half") ||
|
50
|
+
monster[:url].include?("planetouched") ||
|
51
|
+
monster[:url].include?("sahuagin") ||
|
52
|
+
monster[:name] == "Shadow" ||
|
53
|
+
monster[:name] == "Greater Shadow" ||
|
54
|
+
monster[:url].include?("sphinx") ||
|
55
|
+
monster[:url].include?("sprite") ||
|
56
|
+
monster[:url].include?("swarm") ||
|
57
|
+
monster[:url].include?("troll") ||
|
58
|
+
monster[:url].include?("unicorn") ||
|
59
|
+
monster[:url].include?("vampire") ||
|
60
|
+
monster[:url].include?("wraith") ||
|
61
|
+
monster[:url].include?("horse") ||
|
62
|
+
monster[:url].include?("snake") ||
|
63
|
+
monster[:url].include?("whale")
|
64
|
+
end
|
65
|
+
monsters
|
66
|
+
end
|
67
|
+
|
68
|
+
def self.scrape_monster_page(monster_url)
|
69
|
+
doc = Nokogiri::HTML(open(monster_url))
|
70
|
+
profile = {
|
71
|
+
size_type: doc.search("table tr td")[0].text,
|
72
|
+
hit_dice: doc.search("table tr td")[1].text,
|
73
|
+
initiative: doc.search("table tr td")[2].text,
|
74
|
+
speed: doc.search("table tr td")[3].text,
|
75
|
+
ac: doc.search("table tr td")[4].text,
|
76
|
+
attack: doc.search("table tr td")[7].text,
|
77
|
+
alignment: doc.search("table tr td")[19].text,
|
78
|
+
}
|
79
|
+
profile
|
80
|
+
end
|
81
|
+
|
82
|
+
end
|
83
|
+
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'monster_index/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "monster_index"
|
8
|
+
spec.version = MonsterIndex::VERSION
|
9
|
+
spec.authors = ["Morgan VanYperen"]
|
10
|
+
spec.email = ["morgvanny@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = "Quick reference for monsters in D&D 3.5 edition."
|
13
|
+
spec.description = %q{See a list of monsters, and important stats on each of them. Scraped from http://www.d20srd.org/}
|
14
|
+
spec.homepage = "https://github.com/morgvanny/monster_index"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
# Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
|
18
|
+
# delete this section to allow pushing this gem to any host.
|
19
|
+
#if spec.respond_to?(:metadata)
|
20
|
+
# spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
|
21
|
+
#else
|
22
|
+
# raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
|
23
|
+
#end
|
24
|
+
|
25
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
26
|
+
spec.executables = ["monster_index"]
|
27
|
+
spec.require_paths = ["lib"]
|
28
|
+
|
29
|
+
spec.add_development_dependency "bundler", "~> 1.11"
|
30
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
31
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
32
|
+
spec.add_development_dependency "pry"
|
33
|
+
spec.add_dependency "nokogiri"
|
34
|
+
end
|
metadata
ADDED
@@ -0,0 +1,135 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: monster_index
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Morgan VanYperen
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-01-24 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: '1.11'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.11'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: pry
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: nokogiri
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
description: See a list of monsters, and important stats on each of them. Scraped
|
84
|
+
from http://www.d20srd.org/
|
85
|
+
email:
|
86
|
+
- morgvanny@gmail.com
|
87
|
+
executables:
|
88
|
+
- monster_index
|
89
|
+
extensions: []
|
90
|
+
extra_rdoc_files: []
|
91
|
+
files:
|
92
|
+
- ".gitignore"
|
93
|
+
- ".rspec"
|
94
|
+
- ".travis.yml"
|
95
|
+
- Gemfile
|
96
|
+
- Gemfile.lock
|
97
|
+
- LICENSE.txt
|
98
|
+
- NOTES.txt
|
99
|
+
- README.md
|
100
|
+
- Rakefile
|
101
|
+
- bin/console
|
102
|
+
- bin/monster_index
|
103
|
+
- bin/setup
|
104
|
+
- "d\eOAfadsf"
|
105
|
+
- lib/monster_index.rb
|
106
|
+
- lib/monster_index/cli.rb
|
107
|
+
- lib/monster_index/monster.rb
|
108
|
+
- lib/monster_index/scraper.rb
|
109
|
+
- lib/monster_index/version.rb
|
110
|
+
- monster_index.gemspec
|
111
|
+
homepage: https://github.com/morgvanny/monster_index
|
112
|
+
licenses:
|
113
|
+
- MIT
|
114
|
+
metadata: {}
|
115
|
+
post_install_message:
|
116
|
+
rdoc_options: []
|
117
|
+
require_paths:
|
118
|
+
- lib
|
119
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
120
|
+
requirements:
|
121
|
+
- - ">="
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: '0'
|
124
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
125
|
+
requirements:
|
126
|
+
- - ">="
|
127
|
+
- !ruby/object:Gem::Version
|
128
|
+
version: '0'
|
129
|
+
requirements: []
|
130
|
+
rubyforge_project:
|
131
|
+
rubygems_version: 2.4.3
|
132
|
+
signing_key:
|
133
|
+
specification_version: 4
|
134
|
+
summary: Quick reference for monsters in D&D 3.5 edition.
|
135
|
+
test_files: []
|