owmo 2.0.1 → 2.0.3

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
- SHA1:
3
- metadata.gz: 4256e7133f1d73d8d3c4c4c542547eb3be368eee
4
- data.tar.gz: 8184cb85272239ffacc56931eec0c91f8698a135
2
+ SHA256:
3
+ metadata.gz: b7e4b64ccdb32db93f751f28f7c07923244770d68eda25301b1939ac21de38bb
4
+ data.tar.gz: f67520f2b29f4bbf95f0bef27a60827fd1f04906ab2fa72da49a7ebefc834f3f
5
5
  SHA512:
6
- metadata.gz: d6be96efc7ca3e8d335e8161c29478b02d839741b0ede3c350551368a13bed0588272c7cbfcf141fe1623ebb081eb911bf29e129571a2f35dc2df7100044d17d
7
- data.tar.gz: 1907e7585125a51c66a96abfdc173318e7d5e0878c6e3b6a1afd8dc73000a4c294152abe937edd13e50cb2777d9e189e02983db5ae8188f0d034e7dd61045641
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,66 +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
29
  return weather['message'] if weather.is_a? Hash
31
- "None"
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
40
  private
42
41
 
43
- =begin rdoc
44
- Sets the weather variable
45
- =end
46
- def weather=(weather)
47
- @weather = weather if @weather.nil?
48
- end
49
-
50
- =begin rdoc
51
- Attempts to parse the body to JSON. This is so we don't have to continually
52
- parse the raw JSON.
53
- =end
54
- def parse_weather
55
- begin
56
- # Try to parse the response and return a hash
57
- @weather = JSON.parse(self.body)
58
- rescue
59
- # Return the body string if parsing fails (used for html and xml responses)
60
- @weather = self.body
61
- end
62
- end
42
+ # rdoc
43
+ # Sets the weather variable
44
+ def weather=(weather)
45
+ @weather = weather if @weather.nil?
46
+ end
63
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
64
58
  end
65
59
  end
66
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.1"
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,31 +1,26 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'logger'
2
4
  require 'net/http'
3
5
 
4
6
  require 'core_extensions/net/http_response/weather_response'
5
7
 
6
-
7
- =begin rdoc
8
- Include some weather response info into Net::HTTPResponse
9
- =end
8
+ # rdoc
9
+ # Include some weather response info into Net::HTTPResponse
10
10
  Net::HTTPResponse.include CoreExtensions::Net::HTTPResponse::WeatherResponse
11
11
 
12
-
13
12
  module OWMO
14
-
15
- =begin rdoc
16
- A weather class for retrieving current and forecasted weather conditions.
17
- ==== Attributes
18
- * +api_key+ - {OpenWeatherMap.org API key}[http://openweathermap.org/appid]
19
- ==== Examples
20
- api_key = "<My API Key>"
21
- weather = OWMO::Weather.new api_key: api_key
22
- puts weather.get :current, city_name: "London,uk"
23
- =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"
24
21
  class Weather
25
-
26
- =begin rdoc
27
- Weather response error to handle errors received from OpenWeatherMap.orgs API
28
- =end
22
+ # rdoc
23
+ # Weather response error to handle errors received from OpenWeatherMap.orgs API
29
24
  class WeatherResponseError < StandardError
30
25
  def initialize(response)
31
26
  @response = response
@@ -33,62 +28,56 @@ Weather response error to handle errors received from OpenWeatherMap.orgs API
33
28
  end
34
29
  end
35
30
 
36
- =begin rdoc
37
- OpenWeatherMap.Org weather API key
38
- =end
31
+ # rdoc
32
+ # OpenWeatherMap.Org weather API key
39
33
  attr_reader :api_key
40
34
 
41
- =begin rdoc
42
- Access current or forecasted conditions by (required):
43
- =end
44
- Paths = {
35
+ # rdoc
36
+ # Access current or forecasted conditions by (required):
37
+ PATHS = {
45
38
  current: 'weather', # Current weather data
46
39
  group: 'group', # Current weather w/multiple IDs
47
40
  box: 'box/city', # Current weather w/in a rectangle box
48
41
  circle: 'find', # Current weather w/in a circle
49
42
  forecast5: 'forecast', # 5 day / 3 hour forecast
50
43
  forecast16: 'forecast/daily' # 16 day / daily forecast
51
- }
44
+ }.freeze
52
45
 
53
- =begin rdoc
54
- Geocode aliases
55
- =end
56
- Geocode_Aliases = {
46
+ # rdoc
47
+ # Geocode aliases
48
+ GEOCODE_ALIASES = {
57
49
  city_name: :q,
58
50
  city_id: :id,
59
51
  zip_code: :zip,
60
52
  latitude: :lat,
61
53
  longitude: :lon,
62
54
  box: :bbox
63
- }
64
-
65
- =begin rdoc
66
- Either yeild the class, or instanciate it.
67
- ==== Attributes
68
- * +api_key+ - OpenWEatherMap.Org's weather API key
69
- * +**kwargs+ - Any additional paramters
70
- =end
71
- def initialize(api_key, **kwargs)
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)
72
63
  @api_key = api_key
73
64
 
74
- if block_given?
75
- yield self
76
- end
65
+ return unless block_given?
66
+
67
+ yield self
77
68
  end
78
69
 
79
- =begin rdoc
80
- A weather class for retrieving current and forecasted weather conditions.
81
- ==== Attributes
82
- * +path+ - OWMO::Wether.Path parameter
83
- * +query+ - Hash of query options (Geocode, response format, units, etc.)
84
- ==== Examples
85
- api_key = "<My API Key>"
86
- weather = OWMO::Weather.new api_key: api_key
87
- puts weather.get :current, city_name: "London,uk"
88
- =end
89
- public
90
- def get(path, **query)
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"
91
79
 
80
+ def get(path, **query)
92
81
  # Format Geocode info
93
82
  query = alias_geocodes(query)
94
83
 
@@ -96,7 +85,7 @@ A weather class for retrieving current and forecasted weather conditions.
96
85
  query[:APPID] = api_key
97
86
 
98
87
  # Create the uri
99
- uri = format_uri(OWMO::URL, Paths[path], query)
88
+ uri = format_uri(OWMO::URL, PATHS[path], query)
100
89
 
101
90
  # Get the weather data
102
91
  GET(uri)
@@ -104,44 +93,39 @@ A weather class for retrieving current and forecasted weather conditions.
104
93
 
105
94
  private
106
95
 
107
- =begin rdoc
108
- Retruns the geocode keys from specified query.
109
- =end
110
- def query_geocode_keys(**query)
111
- query.keys & Geocode_Aliases.keys
112
- end
113
-
114
- =begin rdoc
115
- Aliases some geocode parameters to the correct ones, for example :city_name is
116
- easier to read than :q
117
- =end
118
- def alias_geocodes(**query)
119
- query_geocode_keys(query).each do |key|
120
- query[Geocode_Aliases[key]] = query.delete(key)
121
- end
122
- query
123
- end
96
+ # rdoc
97
+ # Retruns the geocode keys from specified query.
98
+ def query_geocode_keys(**query)
99
+ query.keys & GEOCODE_ALIASES.keys
100
+ end
124
101
 
125
- =begin rdoc
126
- Formats the url with the given url, path, and query
127
- =end
128
- def format_uri(url, path, query)
129
- URI "#{url}/#{path}?#{URI.encode_www_form(query).gsub('%2C', ',')}"
102
+ # rdoc
103
+ # Aliases some geocode parameters to the correct ones, for example :city_name is
104
+ # easier to read than :q
105
+ def alias_geocodes(**query)
106
+ query_geocode_keys(query).each do |key|
107
+ query[GEOCODE_ALIASES[key]] = query.delete(key)
130
108
  end
109
+ query
110
+ end
131
111
 
132
- =begin rdoc
133
- Sends the GET request to OpenWeatherMap.org
134
- =end
135
- def GET(uri)
136
- response = Net::HTTP.start(uri.hostname, uri.port) do |http|
137
- http.request(Net::HTTP::Get.new(uri))
138
- end
139
-
140
- # Check the response
141
- raise WeatherResponseError.new(response) if response.has_error?
112
+ # rdoc
113
+ # Formats the url with the given url, path, and query
114
+ def format_uri(url, path, query)
115
+ URI "#{url}/#{path}?#{URI.encode_www_form(query).gsub('%2C', ',')}"
116
+ end
142
117
 
143
- response.weather
118
+ # rdoc
119
+ # Sends the GET request to OpenWeatherMap.org
120
+ def GET(uri)
121
+ response = Net::HTTP.start(uri.hostname, uri.port) do |http|
122
+ http.request(Net::HTTP::Get.new(uri))
144
123
  end
145
124
 
125
+ # Check the response
126
+ raise WeatherResponseError, response if response.error?
127
+
128
+ response.weather
129
+ end
146
130
  end
147
131
  end
data/lib/owmo.rb CHANGED
@@ -1,36 +1,33 @@
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
@@ -38,5 +35,4 @@ Yield a weather object for querying weather data
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.1
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-07-10 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.