owmo 2.0.4 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f28d1ded9dc4ec39373a376183985f837af3034fc18780defc7bae3158c6fd82
4
- data.tar.gz: 9de5b4bca2d86f98cc4b252b46c7688f74cbbd55d80b52ecb500426909036174
3
+ metadata.gz: fde6157e383b210aee0eb881e5607997e2de408d9fd63f36cfb33b84f221599f
4
+ data.tar.gz: b1e9310c8f042693cc6ff29abebdb6449d111c7281e7605a47fcb6799d0e7bec
5
5
  SHA512:
6
- metadata.gz: e5adf0b05d8cc03aac2363cfec8eadce4390ba84007b7475d40912fce0711808bae275a34a0b7358afa20ae4f996061ccdca4b418eb9c6bf3c294b4b1da89ff1
7
- data.tar.gz: ff5e5372699efc0668f520f30e9df3f2d2b0c00d7cacd954b6a56726835759d85b8df1c30ee1ede3ca1a28bde423f129094664accffb7a239dd91150bf8cb632
6
+ metadata.gz: 92e3df1af5aedba4b8aeeb2724a134e8dfc5ef13d8208420a3ce2a831cf328b51e93b14330c52a9bc725fb834d7eaaa4867ad4ce610472b3f48436d296f0bc10
7
+ data.tar.gz: 8418b07518cebc176310097358f933ccd95269df15c099b017f17c60ea0538afd8d450efbc769208774feb1eea16e3844846ccaf17b36d686695afc55990f38f
data/CONTRIBUTING.MD ADDED
@@ -0,0 +1,10 @@
1
+ ----
2
+ ## Development
3
+
4
+ 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.
5
+
6
+ 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).
7
+
8
+ ## Contributing
9
+
10
+ Bug reports and pull requests are welcome on GitHub at https://github.com/robb-randall/owmo.
data/Gemfile CHANGED
@@ -4,4 +4,5 @@ source 'https://rubygems.org'
4
4
 
5
5
  gemspec
6
6
 
7
+ gem 'rspec'
7
8
  gem 'simplecov', require: false, group: :test
data/README.md CHANGED
@@ -153,18 +153,6 @@ Then navigate to: http://localhost:4567/current/London,UK
153
153
 
154
154
  [Full example](https://github.com/robb-randall/owmo/blob/master/examples/sinatra_example.rb)
155
155
 
156
- ----
157
- ## Development
158
-
159
- 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.
160
-
161
- 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).
162
-
163
- ## Contributing
164
-
165
- Bug reports and pull requests are welcome on GitHub at https://github.com/robb-randall/owmo.
166
-
167
-
168
156
  ## License
169
157
 
170
158
  The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
data/bin/rspec ADDED
@@ -0,0 +1,27 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'rspec' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
12
+
13
+ bundle_binstub = File.expand_path("bundle", __dir__)
14
+
15
+ if File.file?(bundle_binstub)
16
+ if File.read(bundle_binstub, 300).include?("This file was generated by Bundler")
17
+ load(bundle_binstub)
18
+ else
19
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
20
+ Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
21
+ end
22
+ end
23
+
24
+ require "rubygems"
25
+ require "bundler/setup"
26
+
27
+ load Gem.bin_path("rspec-core", "rspec")
data/lib/owmo/version.rb CHANGED
@@ -3,5 +3,5 @@
3
3
  module OWMO
4
4
  # rdoc
5
5
  # Gem Version
6
- VERSION = '2.0.4'
6
+ VERSION = '2.1.0'
7
7
  end
data/lib/owmo/weather.rb CHANGED
@@ -3,11 +3,6 @@
3
3
  require 'logger'
4
4
  require 'net/http'
5
5
 
6
- require 'core_extensions/net/http_response/weather_response'
7
-
8
- # rdoc
9
- # Include some weather response info into Net::HTTPResponse
10
- Net::HTTPResponse.include CoreExtensions::Net::HTTPResponse::WeatherResponse
11
6
 
12
7
  module OWMO
13
8
  # rdoc
@@ -23,8 +18,7 @@ module OWMO
23
18
  # Weather response error to handle errors received from OpenWeatherMap.orgs API
24
19
  class WeatherResponseError < StandardError
25
20
  def initialize(response)
26
- @response = response
27
- super("ERROR #{@response.weather_code}: #{@response.weather_message}")
21
+ super("ERROR #{response[:cod]}: #{response[:message]}")
28
22
  end
29
23
  end
30
24
 
@@ -88,7 +82,11 @@ module OWMO
88
82
  uri = format_uri(OWMO::URL, PATHS[path], query)
89
83
 
90
84
  # Get the weather data
91
- GET(uri)
85
+ weather = http_get(uri)
86
+
87
+ raise WeatherResponseError, weather unless weather.fetch(:cod) == 200
88
+
89
+ weather
92
90
  end
93
91
 
94
92
  private
@@ -117,15 +115,14 @@ module OWMO
117
115
 
118
116
  # rdoc
119
117
  # Sends the GET request to OpenWeatherMap.org
120
- def GET(uri)
118
+ # :nocov:
119
+ def http_get(uri)
121
120
  response = Net::HTTP.start(uri.hostname, uri.port) do |http|
122
121
  http.request(Net::HTTP::Get.new(uri))
123
122
  end
124
123
 
125
- # Check the response
126
- raise WeatherResponseError, response if response.error?
127
-
128
- response.weather
124
+ JSON.parse(response.weather)
129
125
  end
130
126
  end
127
+ # :nocov:
131
128
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: owmo
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.4
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robb Randall
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-12-30 00:00:00.000000000 Z
11
+ date: 2023-01-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -64,12 +64,14 @@ files:
64
64
  - ".gitignore"
65
65
  - ".rspec"
66
66
  - ".travis.yml"
67
+ - CONTRIBUTING.MD
67
68
  - Gemfile
68
69
  - LICENSE.txt
69
70
  - README.md
70
71
  - Rakefile
71
72
  - _config.yml
72
73
  - bin/console
74
+ - bin/rspec
73
75
  - bin/setup
74
76
  - examples/current.rb
75
77
  - examples/current_box.rb