owmo 2.0.0 → 2.0.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 84b6f969b10f394d6c8f9c0fda1ac2dbd6929811
4
- data.tar.gz: 0ebeca0df38b5d6104890759bdf756feccf3fd68
2
+ SHA256:
3
+ metadata.gz: b7e4b64ccdb32db93f751f28f7c07923244770d68eda25301b1939ac21de38bb
4
+ data.tar.gz: f67520f2b29f4bbf95f0bef27a60827fd1f04906ab2fa72da49a7ebefc834f3f
5
5
  SHA512:
6
- metadata.gz: 10dcefd739e026f47f6e3b4adfbef8101fbfee1ecf1477b483a5d8b418eb3b04aa4c0591687ccc794446dc100514c7f98d1a8cda64faa57533ac99fbc1a1cc1d
7
- data.tar.gz: 87a157f21b913e319187b28569e058cdd85401217af165ed00e031528f1d53c601c80a2c30dc6e8b8615d80235779623ba690608f5f0f0f274515800f6bb4cee
6
+ metadata.gz: e072a5ccce24a3c24032b5d88141feabe29806e6f1825c21700b751b5a9b91e3f43e9218cbed9bcd0a095b9335115979da775374d7093ec46059a51185cff42a
7
+ data.tar.gz: 1cd83a94eec07bfcb4d9a96d0a087395fea3b7f4a227cc8665bad66175a9fc4738d3c3813c25db1967768db2a7e32d8488fa857282b957cc1b43dc8bf2cb6e39
@@ -0,0 +1,22 @@
1
+ name: Publish Gem
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - "*"
7
+ tags:
8
+ - v*
9
+ jobs:
10
+ build:
11
+ runs-on: ubuntu-latest
12
+
13
+ steps:
14
+ - uses: actions/checkout@v3
15
+
16
+ - name: Release Gem
17
+ if: contains(github.ref, 'refs/tags/v')
18
+ uses: cadwallion/publish-rubygems-action@master
19
+ env:
20
+ GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
21
+ RUBYGEMS_API_KEY: ${{secrets.RUBYGEMS_API_KEY}}
22
+ RELEASE_COMMAND: rake release
@@ -0,0 +1,38 @@
1
+ # This workflow uses actions that are not certified by GitHub.
2
+ # They are provided by a third-party and are governed by
3
+ # separate terms of service, privacy policy, and support
4
+ # documentation.
5
+ # This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
6
+ # For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
7
+
8
+ name: Ruby
9
+
10
+ on:
11
+ push:
12
+ branches: [ "main" ]
13
+ pull_request:
14
+ branches: [ "main" ]
15
+
16
+ permissions:
17
+ contents: read
18
+
19
+ jobs:
20
+ test:
21
+
22
+ runs-on: ubuntu-latest
23
+ strategy:
24
+ matrix:
25
+ ruby-version: ['2.7', '3.0']
26
+
27
+ steps:
28
+ - uses: actions/checkout@v3
29
+ - name: Set up Ruby
30
+ # To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
31
+ # change this to (see https://github.com/ruby/setup-ruby#versioning):
32
+ # uses: ruby/setup-ruby@v1
33
+ uses: ruby/setup-ruby@ee2113536afb7f793eed4ce60e8d3b26db912da4 # v1.127.0
34
+ with:
35
+ ruby-version: ${{ matrix.ruby-version }}
36
+ bundler-cache: true # runs 'bundle install' and caches installed gems automatically
37
+ - name: Run tests
38
+ run: bundle exec rake
data/Gemfile CHANGED
@@ -1,3 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source 'https://rubygems.org'
2
4
 
3
5
  gemspec
6
+
7
+ gem 'simplecov', require: false, group: :test
data/Rakefile CHANGED
@@ -1,6 +1,8 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
1
+ # frozen_string_literal: true
3
2
 
4
- RSpec::Core::RakeTask.new(:spec)
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
5
5
 
6
- task :default => :spec
6
+ RSpec::Core::RakeTask.new :spec
7
+
8
+ task default: :spec
data/bin/console CHANGED
@@ -1,7 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
- require "bundler/setup"
4
- require "owmo"
4
+ require 'bundler/setup'
5
+ require 'owmo'
5
6
 
6
7
  # You can add fixtures and/or initialization code here to make experimenting
7
8
  # with your gem easier. You can also use a different console, if you like.
@@ -10,5 +11,5 @@ require "owmo"
10
11
  # require "pry"
11
12
  # Pry.start
12
13
 
13
- require "irb"
14
+ require 'irb'
14
15
  IRB.start(__FILE__)
data/examples/current.rb CHANGED
@@ -1,13 +1,14 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'owmo'
2
4
 
3
- =begin rdoc
4
- An example on how to get current conditions and use the different parameters.
5
- =end
6
- api_key = ""
5
+ # rdoc
6
+ # An example on how to get current conditions and use the different parameters.
7
+ api_key = ''
7
8
 
8
9
  weather = OWMO::Weather.new api_key
9
10
 
10
11
  # http://openweathermap.org/current#data
11
- current = weather.get :current, city_name: "London,UK"
12
+ current = weather.get :current, city_name: 'London,UK'
12
13
 
13
14
  puts current
@@ -1,7 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'owmo'
2
4
 
3
- api_key = ""
5
+ api_key = ''
4
6
 
5
- OWMO::weather(api_key) do |weather|
7
+ OWMO.weather(api_key) do |weather|
6
8
  puts weather.get :box, bbox: [12, 32, 15, 37, 10].join(',')
7
9
  end
@@ -1,7 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'owmo'
2
4
 
3
- api_key = ""
5
+ api_key = ''
4
6
 
5
- OWMO::weather(api_key) do |weather|
7
+ OWMO.weather(api_key) do |weather|
6
8
  puts weather.get :circle, lat: 55.5, lon: 37.5, cnt: 10
7
9
  end
@@ -1,7 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'owmo'
2
4
 
3
- api_key = ""
5
+ api_key = ''
4
6
 
5
- OWMO::weather(api_key) do |weather|
6
- puts weather.get :group, id: [4850751,4887398,2643743,4164138,5368361].join(',')
7
+ OWMO.weather(api_key) do |weather|
8
+ puts weather.get :group, id: [4_850_751, 4_887_398, 2_643_743, 4_164_138, 5_368_361].join(',')
7
9
  end
@@ -1,14 +1,14 @@
1
- require 'owmo'
1
+ # frozen_string_literal: true
2
2
 
3
+ require 'owmo'
3
4
 
4
- =begin rdoc
5
- An example on how to get the weather forcast and use the different parameters.
6
- =end
7
- api_key = ""
5
+ # rdoc
6
+ # An example on how to get the weather forcast and use the different parameters.
7
+ api_key = ''
8
8
 
9
9
  weather = OWMO::Weather.new api_key
10
10
 
11
11
  # http://openweathermap.org/forecast16
12
- forecast16 = weather.get :forecast16, city_name: "London,UK"
12
+ forecast16 = weather.get :forecast16, city_name: 'London,UK'
13
13
 
14
14
  puts forecast16
@@ -1,14 +1,14 @@
1
- require 'owmo'
1
+ # frozen_string_literal: true
2
2
 
3
+ require 'owmo'
3
4
 
4
- =begin rdoc
5
- An example on how to get the extended forcast and use the different parameters.
6
- =end
7
- api_key = ""
5
+ # rdoc
6
+ # An example on how to get the extended forcast and use the different parameters.
7
+ api_key = ''
8
8
 
9
9
  weather = OWMO::Weather.new api_key
10
10
 
11
11
  # http://openweathermap.org/forecast5
12
- forecast5 = weather.get :forecast5, city_name: "London,UK"
12
+ forecast5 = weather.get :forecast5, city_name: 'London,UK'
13
13
 
14
14
  puts forecast5
@@ -1,11 +1,13 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'owmo'
2
4
 
3
- api_key = ""
5
+ api_key = ''
4
6
 
5
7
  weather = OWMO::Weather.new api_key
6
8
 
7
9
  query = {
8
- city_name: "London,UK", # Geolocation, required
10
+ city_name: 'London,UK', # Geolocation, required
9
11
  mode: 'json', # Return data [json (defaul), xml, html]
10
12
  units: 'imperial', # [imperial, metric, or blank (Default, Kelvin)]
11
13
  lang: 'fr' # Language support
@@ -1,20 +1,22 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'owmo'
2
4
 
3
- api_key = ""
5
+ api_key = ''
4
6
 
5
7
  weather = OWMO::Weather.new api_key
6
8
 
7
9
  # Geocode by City ID
8
- puts weather.get :current, city_id: 5328041
9
- puts weather.get :current, id: 5328041
10
+ puts weather.get :current, city_id: 5_328_041
11
+ puts weather.get :current, id: 5_328_041
10
12
 
11
13
  # Geocode by City Name
12
- puts weather.get :current, city_name: "Beverly Hills"
13
- puts weather.get :current, q: "Beverly Hills"
14
+ puts weather.get :current, city_name: 'Beverly Hills'
15
+ puts weather.get :current, q: 'Beverly Hills'
14
16
 
15
17
  # Geocode by Zip Code
16
- puts weather.get :current, zip: 90210
17
- puts weather.get :current, zip_code: 90210
18
+ puts weather.get :current, zip: 90_210
19
+ puts weather.get :current, zip_code: 90_210
18
20
 
19
21
  # Geocode by Coordinance
20
22
  puts weather.get :current, lon: -118.41, lat: 34.09
@@ -1,15 +1,17 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'owmo'
2
4
 
3
- api_key = ""
5
+ api_key = ''
4
6
 
5
7
  weather = OWMO::Weather.new api_key
6
8
 
7
9
  # Response in JSON format
8
- puts weather.get :current, city_name: "London,UK"
9
- puts weather.get :current, city_name: "London,UK", mode: :json
10
+ puts weather.get :current, city_name: 'London,UK'
11
+ puts weather.get :current, city_name: 'London,UK', mode: :json
10
12
 
11
13
  # Response in XML format
12
- puts weather.get :current, city_name: "London,UK", mode: :xml
14
+ puts weather.get :current, city_name: 'London,UK', mode: :xml
13
15
 
14
16
  # Response in HTML format
15
- puts weather.get :current, city_name: "London,UK", mode: :html
17
+ puts weather.get :current, city_name: 'London,UK', mode: :html
@@ -1,14 +1,16 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'owmo'
2
4
 
3
- api_key = ""
5
+ api_key = ''
4
6
 
5
7
  weather = OWMO::Weather.new api_key
6
8
 
7
9
  # Kelvin
8
- puts weather.get :current, city_name: "London,UK"
10
+ puts weather.get :current, city_name: 'London,UK'
9
11
 
10
12
  # Imperial
11
- puts weather.get :current, city_name: "London,UK", units: :imperial
13
+ puts weather.get :current, city_name: 'London,UK', units: :imperial
12
14
 
13
15
  # Metric
14
- puts weather.get :current, city_name: "London,UK", units: :metric
16
+ puts weather.get :current, city_name: 'London,UK', units: :metric
@@ -1,10 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'owmo'
2
4
  require 'sinatra' # Need to install, not included in gemspec
3
5
  require 'uri'
4
6
 
5
-
6
7
  get '/current/:name' do
7
- api_key = '<API Key>'
8
- weather = OWMO::Weather.new api_key
9
- weather.get :current, city_name: params[:name], mode: :html
8
+ api_key = '<API Key>'
9
+ weather = OWMO::Weather.new api_key
10
+ weather.get :current, city_name: params[:name], mode: :html
10
11
  end
@@ -1,56 +1,60 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'json'
2
4
 
3
5
  module CoreExtensions
4
6
  module Net
5
7
  module HTTPResponse
6
8
  module WeatherResponse
7
-
8
- =begin rdoc
9
- Returns the weather
10
- =end
9
+ # rdoc
10
+ # Returns the weather
11
11
  def weather
12
12
  parse_weather
13
13
  @weather
14
14
  end
15
15
 
16
- =begin rdoc
17
- Returns the response code
18
- =end
16
+ # rdoc
17
+ # Returns the response code
19
18
  def weather_code
20
19
  parse_weather
21
- return (@weather['cod'] || "200").to_i if @weather.is_a? Hash
20
+ return (weather['cod'] || '200').to_i if weather.is_a? Hash
21
+
22
22
  200
23
23
  end
24
24
 
25
- =begin rdoc
26
- Returns the response message
27
- =end
25
+ # rdoc
26
+ # Returns the response message
28
27
  def weather_message
29
28
  parse_weather
30
- return @weather['message'] if @weather.is_a? Hash
31
- "None"
29
+ return weather['message'] if weather.is_a? Hash
30
+
31
+ 'None'
32
32
  end
33
33
 
34
- =begin rdoc
35
- Returns boolean if the response contains an error or not.
36
- =end
37
- def has_error?
34
+ # rdoc
35
+ # Returns boolean if the response contains an error or not.
36
+ def error?
38
37
  weather_code != 200
39
38
  end
40
39
 
41
- =begin rdoc
42
- Attempts to parse the body to JSON. This is so we don't have to continually
43
- parse the raw JSON.
44
- =end
45
40
  private
46
- def parse_weather
47
- begin
48
- @weather = JSON.parse(self.body)
49
- rescue
50
- @weather = self.body
51
- end if @weather.nil?
41
+
42
+ # rdoc
43
+ # Sets the weather variable
44
+ def weather=(weather)
45
+ @weather = weather if @weather.nil?
52
46
  end
53
47
 
48
+ # rdoc
49
+ # Attempts to parse the body to JSON. This is so we don't have to continually
50
+ # parse the raw JSON.
51
+ def parse_weather
52
+ # Try to parse the response and return a hash
53
+ @weather = JSON.parse(body)
54
+ rescue StandardError
55
+ # Return the body string if parsing fails (used for html and xml responses)
56
+ @weather = body
57
+ end
54
58
  end
55
59
  end
56
60
  end
data/lib/owmo/version.rb CHANGED
@@ -1,8 +1,7 @@
1
- module OWMO
2
-
3
- =begin rdoc
4
- Gem Version
5
- =end
6
- VERSION = "2.0.0"
1
+ # frozen_string_literal: true
7
2
 
3
+ module OWMO
4
+ # rdoc
5
+ # Gem Version
6
+ VERSION = '2.0.3'
8
7
  end
data/lib/owmo/weather.rb CHANGED
@@ -1,30 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'logger'
1
4
  require 'net/http'
2
- require 'time'
3
- require 'core_extensions/net/http_response/weather_response'
4
5
 
6
+ require 'core_extensions/net/http_response/weather_response'
5
7
 
6
- =begin rdoc
7
- Include some weather response info into Net::HTTPResponse
8
- =end
8
+ # rdoc
9
+ # Include some weather response info into Net::HTTPResponse
9
10
  Net::HTTPResponse.include CoreExtensions::Net::HTTPResponse::WeatherResponse
10
11
 
11
-
12
12
  module OWMO
13
-
14
- =begin rdoc
15
- A weather class for retrieving current and forecasted weather conditions.
16
- ==== Attributes
17
- * +api_key+ - {OpenWeatherMap.org API key}[http://openweathermap.org/appid]
18
- ==== Examples
19
- api_key = "<My API Key>"
20
- weather = OWMO::Weather.new api_key: api_key
21
- puts weather.get :current, city_name: "London,uk"
22
- =end
13
+ # rdoc
14
+ # A weather class for retrieving current and forecasted weather conditions.
15
+ # ==== Attributes
16
+ # * +api_key+ - {OpenWeatherMap.org API key}[http://openweathermap.org/appid]
17
+ # ==== Examples
18
+ # api_key = "<My API Key>"
19
+ # weather = OWMO::Weather.new api_key: api_key
20
+ # puts weather.get :current, city_name: "London,uk"
23
21
  class Weather
24
-
25
- =begin rdoc
26
- Weather response error to handle errors received from OpenWeatherMap.orgs API
27
- =end
22
+ # rdoc
23
+ # Weather response error to handle errors received from OpenWeatherMap.orgs API
28
24
  class WeatherResponseError < StandardError
29
25
  def initialize(response)
30
26
  @response = response
@@ -32,139 +28,104 @@ Weather response error to handle errors received from OpenWeatherMap.orgs API
32
28
  end
33
29
  end
34
30
 
35
- =begin rdoc
36
- OpenWeatherMap.Org weather API key
37
- =end
31
+ # rdoc
32
+ # OpenWeatherMap.Org weather API key
38
33
  attr_reader :api_key
39
34
 
40
- =begin rdoc
41
- Access current or forecasted conditions by (required):
42
- =end
43
- Paths = {
35
+ # rdoc
36
+ # Access current or forecasted conditions by (required):
37
+ PATHS = {
44
38
  current: 'weather', # Current weather data
45
39
  group: 'group', # Current weather w/multiple IDs
46
40
  box: 'box/city', # Current weather w/in a rectangle box
47
41
  circle: 'find', # Current weather w/in a circle
48
42
  forecast5: 'forecast', # 5 day / 3 hour forecast
49
43
  forecast16: 'forecast/daily' # 16 day / daily forecast
50
- }
44
+ }.freeze
51
45
 
52
- =begin rdoc
53
- Geocode aliases
54
- =end
55
- Geocode_Aliases = {
46
+ # rdoc
47
+ # Geocode aliases
48
+ GEOCODE_ALIASES = {
56
49
  city_name: :q,
57
50
  city_id: :id,
58
51
  zip_code: :zip,
59
52
  latitude: :lat,
60
- longitude: :lon
61
- }
62
-
63
- =begin rdoc
64
- Either yeild the class, or instanciate it.
65
- ==== Attributes
66
- * +api_key+ - OpenWEatherMap.Org's weather API key
67
- * +**kwargs+ - Any additional paramters
68
- =end
69
- def initialize(api_key, **kwargs)
70
- @debug = kwargs[:debug] || FALSE
71
- log "Debug= #{@debug}"
72
-
53
+ longitude: :lon,
54
+ box: :bbox
55
+ }.freeze
56
+
57
+ # rdoc
58
+ # Either yeild the class, or instanciate it.
59
+ # ==== Attributes
60
+ # * +api_key+ - OpenWEatherMap.Org's weather API key
61
+ # * +**kwargs+ - Any additional paramters
62
+ def initialize(api_key, **_kwargs)
73
63
  @api_key = api_key
74
- log "Api Key= #{@api_key}"
75
64
 
76
- log "Args= #{kwargs}"
65
+ return unless block_given?
77
66
 
78
- if block_given?
79
- log "Yielding"
80
- yield self
81
- log "Yield complete."
82
- end
67
+ yield self
83
68
  end
84
69
 
85
- =begin rdoc
86
- A weather class for retrieving current and forecasted weather conditions.
87
- ==== Attributes
88
- * +path+ - OWMO::Wether.Path parameter
89
- * +query+ - Hash of query options (Geocode, response format, units, etc.)
90
- ==== Examples
91
- api_key = "<My API Key>"
92
- weather = OWMO::Weather.new api_key: api_key
93
- puts weather.get :current, city_name: "London,uk"
94
- =end
95
- public
96
- def get(path, **query)
97
- log "Starting request= #{path} -> #{query}"
98
- start = Time.now
70
+ # rdoc
71
+ # A weather class for retrieving current and forecasted weather conditions.
72
+ # ==== Attributes
73
+ # * +path+ - OWMO::Wether.Path parameter
74
+ # * +query+ - Hash of query options (Geocode, response format, units, etc.)
75
+ # ==== Examples
76
+ # api_key = "<My API Key>"
77
+ # weather = OWMO::Weather.new api_key: api_key
78
+ # puts weather.get :current, city_name: "London,uk"
99
79
 
80
+ def get(path, **query)
100
81
  # Format Geocode info
101
82
  query = alias_geocodes(query)
102
83
 
103
84
  # Add the api key
104
- query[:APPID] = @api_key
85
+ query[:APPID] = api_key
105
86
 
106
87
  # Create the uri
107
- uri = format_uri(OWMO::URL, Paths[path], query)
88
+ uri = format_uri(OWMO::URL, PATHS[path], query)
108
89
 
109
90
  # Get the weather data
110
- weather = GET(uri)
91
+ GET(uri)
92
+ end
111
93
 
112
- elapsed_sec = (Time.now - start).round 5
113
- log "Request completed in #{elapsed_sec} seconds."
94
+ private
114
95
 
115
- weather
96
+ # rdoc
97
+ # Retruns the geocode keys from specified query.
98
+ def query_geocode_keys(**query)
99
+ query.keys & GEOCODE_ALIASES.keys
116
100
  end
117
101
 
118
- =begin rdoc
119
- Aliases some geocode parameters to the correct ones, for example :city_name is
120
- easier to read than :q
121
- =end
122
- private
102
+ # rdoc
103
+ # Aliases some geocode parameters to the correct ones, for example :city_name is
104
+ # easier to read than :q
123
105
  def alias_geocodes(**query)
124
- log "Query before= #{query}"
125
-
126
- (query.keys & Geocode_Aliases.keys).each do |key|
127
- query[Geocode_Aliases[key]] = query.delete(key)
106
+ query_geocode_keys(query).each do |key|
107
+ query[GEOCODE_ALIASES[key]] = query.delete(key)
128
108
  end
129
-
130
- log "Query after= #{query}"
131
109
  query
132
110
  end
133
111
 
134
- =begin rdoc
135
- Formats the url with the given url, path, and query
136
- =end
137
- private
112
+ # rdoc
113
+ # Formats the url with the given url, path, and query
138
114
  def format_uri(url, path, query)
139
- uri = URI "#{url}/#{path}?#{URI.encode_www_form(query).gsub('%2C', ',')}"
140
- log "URI= #{uri}"
141
- uri
115
+ URI "#{url}/#{path}?#{URI.encode_www_form(query).gsub('%2C', ',')}"
142
116
  end
143
117
 
144
- =begin rdoc
145
- Sends the GET request to OpenWeatherMap.org
146
- =end
147
- private
118
+ # rdoc
119
+ # Sends the GET request to OpenWeatherMap.org
148
120
  def GET(uri)
149
- log "Starting GET request"
150
121
  response = Net::HTTP.start(uri.hostname, uri.port) do |http|
151
122
  http.request(Net::HTTP::Get.new(uri))
152
123
  end
153
- log "Request returned= #{response.weather_code}: #{response.weather_message}".gsub(/: $/, '')
154
124
 
155
125
  # Check the response
156
- raise WeatherResponseError.new(response) if response.has_error?
126
+ raise WeatherResponseError, response if response.error?
157
127
 
158
128
  response.weather
159
129
  end
160
-
161
- =begin rdoc
162
- Simple log method for debugging purposes
163
- =end
164
- private
165
- def log(msg)
166
- puts "#{DateTime.now} :~> #{msg}" if @debug
167
- end
168
-
169
130
  end
170
131
  end
data/lib/owmo.rb CHANGED
@@ -1,42 +1,38 @@
1
- require "owmo/version"
2
- require "owmo/weather"
1
+ # frozen_string_literal: true
3
2
 
3
+ require 'owmo/version'
4
+ require 'owmo/weather'
4
5
 
5
- =begin rdoc
6
- OMWO = OpenWeatherMap.org client for current and forecasted weather conditions.
7
- =end
6
+ # rdoc
7
+ # OMWO = OpenWeatherMap.org client for current and forecasted weather conditions.
8
8
  module OWMO
9
-
10
- =begin rdoc
11
- Openweathermap.org URL
12
- =end
9
+ # rdoc
10
+ # Openweathermap.org URL
13
11
  URL = 'http://api.openweathermap.org/data/2.5'
14
12
 
15
- =begin rdoc
16
- Yield a weather object for querying weather data
17
- ==== Attributes
18
- * +api_key:+ - {OpenWeatherMap.org API key}[http://openweathermap.org/appid]
19
- ==== Examples
20
- * Single request:
21
- api_key = ''
22
- OWMO::weather(api_key).get :current, city_name: "London,UK"
23
- * Muliple requests:
24
- api_key = ''
25
- OWMO::weather(api_key) do |weather|
26
- puts weather.get :current, city_name: "London,UK"
27
- puts weather.get :forecast5, city_name: "London,UK"
28
- puts weather.get :forecast16, city_name: "London,UK"
29
- end
30
- =end
31
- public
32
- def self.weather(api_key, **params)
33
- Weather.new(api_key, params) do |weather|
13
+ # rdoc
14
+ # Yield a weather object for querying weather data
15
+ # ==== Attributes
16
+ # * +api_key:+ - {OpenWeatherMap.org API key}[http://openweathermap.org/appid]
17
+ # ==== Examples
18
+ # * Single request:
19
+ # api_key = ''
20
+ # OWMO::weather(api_key).get :current, city_name: "London,UK"
21
+ # * Muliple requests:
22
+ # api_key = ''
23
+ # OWMO::weather(api_key) do |weather|
24
+ # puts weather.get :current, city_name: "London,UK"
25
+ # puts weather.get :forecast5, city_name: "London,UK"
26
+ # puts weather.get :forecast16, city_name: "London,UK"
27
+ # end
28
+
29
+ def self.weather(api_key, **kwargs)
30
+ OWMO::Weather.new(api_key, **kwargs) do |weather|
34
31
  if block_given?
35
32
  yield weather
36
33
  else
37
- return weather
34
+ weather
38
35
  end
39
36
  end
40
37
  end
41
-
42
38
  end
data/owmo.gemspec CHANGED
@@ -1,27 +1,30 @@
1
+ # frozen_string_literal: true
1
2
  # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
3
+
4
+ lib = File.expand_path('lib', __dir__)
3
5
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
6
+
4
7
  require 'owmo/version'
5
8
 
6
9
  Gem::Specification.new do |spec|
7
- spec.name = "owmo"
10
+ spec.name = 'owmo'
8
11
  spec.version = OWMO::VERSION
9
- spec.authors = ["Robb"]
10
- spec.email = ["robb.randall@gmail.com"]
12
+ spec.authors = ['Robb Randall']
13
+ spec.email = ['robb.randall@gmail.com']
11
14
 
12
- spec.summary = %q{OpenWeatherMap.org client for current and forecasted weather conditions.}
13
- spec.description = %q{OpenWeatherMap.org client for current and forecasted weather conditions.}
14
- spec.homepage = "https://github.com/robb-randall/owmo"
15
- spec.license = "MIT"
15
+ spec.summary = 'OpenWeatherMap.org client for current and forecasted weather conditions.'
16
+ spec.description = 'OpenWeatherMap.org client for current and forecasted weather conditions.'
17
+ spec.homepage = 'https://github.com/robb-randall/owmo'
18
+ spec.license = 'MIT'
16
19
 
17
20
  spec.files = `git ls-files -z`.split("\x0").reject do |f|
18
21
  f.match(%r{^(test|spec|features)/})
19
22
  end
20
- spec.bindir = "exe"
23
+ spec.bindir = 'exe'
21
24
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
- spec.require_paths = ["lib"]
25
+ spec.require_paths = ['lib']
23
26
 
24
- spec.add_development_dependency "bundler", "~> 1.14"
25
- spec.add_development_dependency "rake", "~> 10.0"
26
- spec.add_development_dependency "rspec", "~> 3.0"
27
+ spec.add_development_dependency 'bundler', '~> 2.x'
28
+ spec.add_development_dependency 'rake', '~> 13.x'
29
+ spec.add_development_dependency 'rspec', '~> 3.x'
27
30
  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.0
4
+ version: 2.0.3
5
5
  platform: ruby
6
6
  authors:
7
- - Robb
7
+ - Robb Randall
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-06-23 00:00:00.000000000 Z
11
+ date: 2022-12-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -16,42 +16,42 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.14'
19
+ version: 2.x
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.14'
26
+ version: 2.x
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '10.0'
33
+ version: 13.x
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '10.0'
40
+ version: 13.x
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '3.0'
47
+ version: 3.x
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '3.0'
54
+ version: 3.x
55
55
  description: OpenWeatherMap.org client for current and forecasted weather conditions.
56
56
  email:
57
57
  - robb.randall@gmail.com
@@ -59,6 +59,8 @@ executables: []
59
59
  extensions: []
60
60
  extra_rdoc_files: []
61
61
  files:
62
+ - ".github/workflows/ruby-publish-gem.yml"
63
+ - ".github/workflows/ruby.yml"
62
64
  - ".gitignore"
63
65
  - ".rspec"
64
66
  - ".travis.yml"
@@ -104,8 +106,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
104
106
  - !ruby/object:Gem::Version
105
107
  version: '0'
106
108
  requirements: []
107
- rubyforge_project:
108
- rubygems_version: 2.4.5.2
109
+ rubygems_version: 3.4.1
109
110
  signing_key:
110
111
  specification_version: 4
111
112
  summary: OpenWeatherMap.org client for current and forecasted weather conditions.