Skip to content

Commit 150d605

Browse files
committed
Merge pull request #9 from 42races/remove_httparty
Remove httparty gem, use Net:HTTP standard library
2 parents b31505a + 9080af9 commit 150d605

File tree

3 files changed

+8
-18
lines changed

3 files changed

+8
-18
lines changed

lib/open_weather/base.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
require 'httparty'
2-
require 'addressable/uri'
1+
require 'net/http'
2+
require 'json'
33

44
module OpenWeather
55
class Base
@@ -37,16 +37,16 @@ def extract_options!(options)
3737
end
3838

3939
def parse_response
40-
@weather_info = @response
40+
@weather_info = JSON.parse(@response)
4141
@status = @weather_info["cod"]
4242
@message = @weather_info["message"] unless @status
4343
@weather_info
4444
end
4545

4646
def send_request(request)
47-
uri = Addressable::URI.parse(request.url)
48-
uri.query_values = request.options
49-
HTTParty.get(uri.to_s)
47+
uri = URI(request.url)
48+
uri.query = URI.encode_www_form(request.options)
49+
Net::HTTP.get(uri)
5050
end
5151
end
5252
end

open_weather.gemspec

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,5 @@ Gem::Specification.new do |gem|
1414
gem.executables = gem.files.grep(/^bin/).map{ |f| File.basename(f) }
1515
gem.require_paths = ["lib"]
1616
gem.add_development_dependency "rspec"
17-
18-
gem.add_runtime_dependency 'httparty'
19-
gem.add_runtime_dependency 'addressable'
17+
gem.add_runtime_dependency 'json'
2018
end

spec/open_weather/api_spec.rb

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
require 'spec_helper'
22

33
# success response
4-
#
4+
#
55
# {"coord"=>{"lon"=>76.26, "lat"=>9.94},
66
# "sys"=>
77
# {"message"=>0.1938,
@@ -31,14 +31,6 @@
3131
#
3232
# {"message"=>"Error: Not found city", "cod"=>"404"}
3333

34-
describe 'Connection Error' do
35-
it 'return error when the network is unreachable' do
36-
response = OpenWeather::Current.city('Cochin, In')
37-
response['cod'].should eq(200)
38-
end
39-
end
40-
41-
4234
describe 'Open weather Current API' do
4335
context '.city' do
4436
it 'return current weather for cochi' do

0 commit comments

Comments
 (0)