Skip to content

Commit

Permalink
feat: return a RapidSchemaParser::Schema instance in clients
Browse files Browse the repository at this point in the history
  • Loading branch information
adamcooke committed Oct 6, 2020
1 parent 1d3ae46 commit 87548c5
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ gem 'rubocop', '0.91.1'

source 'https://rubygems.pkg.github.com/krystal' do
gem 'rapid'
gem 'rapid-schema-parser'
end
4 changes: 3 additions & 1 deletion lib/rapid_api/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

require 'net/http'
require 'json'
require 'rapid_schema_parser'
require 'rapid_api/request_error'
require 'rapid_api/connection_error'

Expand Down Expand Up @@ -35,7 +36,8 @@ def schema?
end

def load_schema_from_api
@schema = make_request(Net::HTTP::Get, 'schema')
body = make_request(Net::HTTP::Get, 'schema')
@schema = RapidSchemaParser::Schema.new(body)
true
end

Expand Down
1 change: 1 addition & 0 deletions rapid_api.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ Gem::Specification.new do |s|
s.authors = ['Adam Cooke']
s.email = ['adam@krystal.uk']
s.add_runtime_dependency 'json'
s.add_runtime_dependency 'rapid-schema-parser'
end
2 changes: 1 addition & 1 deletion spec/specs/lib/rapid_api/client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
context '#load_schema_from_api' do
it 'loads the schema' do
expect(client.load_schema_from_api).to be true
expect(client.schema).to be_a Hash
expect(client.schema).to be_a RapidSchemaParser::Schema
end

it 'marks the schema as loaded' do
Expand Down

0 comments on commit 87548c5

Please # to comment.