Skip to content
This repository has been archived by the owner on Jul 30, 2022. It is now read-only.

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
gadhagod committed Jan 3, 2021
0 parents commit 7711b40
Show file tree
Hide file tree
Showing 5 changed files with 137 additions and 0 deletions.
56 changes: 56 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
*.gem
*.rbc
/.config
/coverage/
/InstalledFiles
/pkg/
/spec/reports/
/spec/examples.txt
/test/tmp/
/test/version_tmp/
/tmp/

# Used by dotenv library to load environment variables.
# .env

# Ignore Byebug command history file.
.byebug_history

## Specific to RubyMotion:
.dat*
.repl_history
build/
*.bridgesupport
build-iPhoneOS/
build-iPhoneSimulator/

## Specific to RubyMotion (use of CocoaPods):
#
# We recommend against adding the Pods directory to your .gitignore. However
# you should judge for yourself, the pros and cons are mentioned at:
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
#
# vendor/Pods/

## Documentation cache and generated files:
/.yardoc/
/_yardoc/
/doc/
/rdoc/

## Environment normalization:
/.bundle/
/vendor/bundle
/lib/bundler/man/

# for a library or gem, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# Gemfile.lock
# .ruby-version
# .ruby-gemset

# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
.rvmrc

# Used by RuboCop. Remote config files pulled in from inherit_from directive.
# .rubocop-https?--*
7 changes: 7 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Copyright 2021 Aarav Borthakur

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
33 changes: 33 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Hyrule Compendium API Ruby Wrapper

The official Ruby wrapper for the [Hyrule Compendium API](https://github.com/Hyrule-Compendium-API/Hyrule-Compendium-API). \
It's recommended that you read the [API documentation](https://github.com/Hyrule-Compendium-API/Hyrule-Compendium-API/blob/master/README.md) before getting started.

## Installation

gem install Hyrule-Compendium

## Usage

Include the library with `require 'hyrule_compendium'.

#### `get_entry`
**Description**: Get a specific item from the hyrule compendium.
**Parameters**:

* __entry__: Entry name of ID, str or int

**Example**: `Hyrule_Compendium.get_entry 'silver lynel'`

#### `get_category`

**Description**: Get a specific category from the hyrule compendium.
**Parameters**:

* __category__: Name of the cateogry, can be creatures, equipment, materials, monsters, or treasure

**Example**: `Hyrule_Compendium.get_category 'equipment'`

#### `get_all`
**Description**: Get all data.
**Example**: `Hyrule_Compendium.get_all`
12 changes: 12 additions & 0 deletions hyrule_compendium.gemspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Gem::Specification.new do |specs|
specs.name = 'Hyrule-Compendium'
specs.version = '1.0.0'
specs.date = '2021-01-02'
specs.summary = "Hyrule Compendium API"
specs.description = "Ruby wrapper for the Hyrule Compendium API"
specs.authors = ["Aarav Borthakur"]
specs.email = "gadhaguy13@gmail.com"
specs.files = ["lib/hyrule_compendium.rb"]
specs.homepage = "https://github.com/Hyrule-Compendium-API/Hyrule-Compendium-ruby-client"
specs.license = "MIT"
end
29 changes: 29 additions & 0 deletions lib/hyrule_compendium.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
require "json"
require "uri"
require "net/http"

def make_req url
uri = URI url
res = Net::HTTP.start uri.host, uri.port do |http|
req = Net::HTTP::Get.new uri
http.request req
end
return JSON.parse res.body
end

module Hyrule_Compendium

$base = "http://botw-compendium.herokuapp.com/api/v1"

def Hyrule_Compendium.get_entry entry
return make_req("#{$base}/entry/#{entry.to_s.gsub " ", "%20"}")["data"]
end

def Hyrule_Compendium.get_category category
return make_req("#{$base}/category/#{category}")["data"]
end

def Hyrule_Compendium.get_all
return make_req $base
end
end

0 comments on commit 7711b40

Please sign in to comment.