open_weather_client 0.1.1 → 0.1.4

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
2
  SHA256:
3
- metadata.gz: 12179413a7acc81adc794dbce0fb22720169a34c3e010fd22bfb32258c55a818
4
- data.tar.gz: 4ca9bf5b64e2e5a4493084bdb7b91750279f40bd97b49c60c01a9e538b7e7390
3
+ metadata.gz: 17bf8dfad870e88aaf543056800194275c1571aca109a24cc622a22b79b8d045
4
+ data.tar.gz: f3636d87638a6567c008e30ac0cebb557cc0835f3d1c56217a6164b57ac2b1e9
5
5
  SHA512:
6
- metadata.gz: ec49b4f16d5379f1a1f937184028ba6e332c966d6649f683d509132ce832660909b4ee89531675d1b9293dc170dba9228ba0127a69ac45ff54a642ee0d6c563f
7
- data.tar.gz: 3c9aec3ddedd6c6e172a7d673bf8b6230ce1a6fa2dccf2c67b0cc9d0c0ad84eaef2798d1fa2d4387900e06cf2c01cd515cd2f5263b62dc05adfc99dbb9e12d30
6
+ metadata.gz: 0c00a702fbedee69d3860d6dc1c0c99ffaf3dd51be0c0db3dadddf5f7aba2739cc015bb8a0c641f280433754a97a77d0cebd4a40ae355a85a8c6c1e6bdcf187a
7
+ data.tar.gz: 61fc3ea2ef6ed2a72adfa45281ce63169643598cad654b42f74665e415329da934b0dee9b80c8d26ebc7ac7bd581db840b512a3fa86b0cf7bc26ba4434ab818c
@@ -15,21 +15,17 @@ on:
15
15
 
16
16
  jobs:
17
17
  test:
18
-
19
18
  runs-on: ubuntu-latest
20
19
  strategy:
21
20
  matrix:
22
- ruby-version: ['3.0']
21
+ ruby-version: ['3.0', '3.2']
23
22
 
24
23
  steps:
25
- - uses: actions/checkout@v2
24
+ - uses: actions/checkout@v3
26
25
  - name: Set up Ruby
27
- # To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
28
- # change this to (see https://github.com/ruby/setup-ruby#versioning):
29
- # uses: ruby/setup-ruby@v1
30
- uses: ruby/setup-ruby@473e4d8fe5dd94ee328fdfca9f8c9c7afc9dae5e
26
+ uses: ruby/setup-ruby@v1
31
27
  with:
32
28
  ruby-version: ${{ matrix.ruby-version }}
33
- bundler-cache: true # runs 'bundle install' and caches installed gems automatically
34
- - name: Run tests
29
+ bundler-cache: true
30
+ - name: Run the default task
35
31
  run: bundle exec rake
data/.rubocop.yml ADDED
@@ -0,0 +1,10 @@
1
+ AllCops:
2
+ TargetRubyVersion: 3.0
3
+
4
+ Metrics/BlockLength:
5
+ Exclude:
6
+ - spec/**/*
7
+
8
+ Layout/LineLength:
9
+ Exclude:
10
+ - spec/**/*
data/CHANGES.md CHANGED
@@ -1,8 +1,25 @@
1
- # Open Weather Client Changelog
1
+ # OpenWeatherClient Changelog
2
+
3
+ ## [Unreleased]
4
+
5
+ ## 0.1.4
6
+ - Add rubocop rake task
7
+ - Run Github actions for ruby 3.2
8
+ - Change cache key format to `weather:<lat>:<lon>:<time}>` for better compatibility with redis
9
+ - Make `OpenWeatherClient::Caching#cache_key` public
10
+
11
+ ## 0.1.3
12
+ Re-release of 0.1.2 since this version was released from an incorrect branch.
13
+
14
+ ## 0.1.2 [yanked]
15
+ - Enable Rubocop Linter
16
+ - Add caching of requests (#1)
17
+ - Add location quantization (#3)
18
+ - Reset gem before every example in spec (#2)
2
19
 
3
20
  ## 0.1.1
4
21
  - Raise `OpenWeatherClient::AuthenticationError` if the request is not authorized
5
- - - Raise `RangeError` if latitude or longitude is out of the allowed range
22
+ - Raise `RangeError` if latitude or longitude is out of the allowed range
6
23
  - Raise `Faraday::Error` if the request fails otherwise
7
24
 
8
25
  ## 0.1.0
data/Gemfile CHANGED
@@ -1,6 +1,6 @@
1
- source "https://rubygems.org"
1
+ # frozen_string_literal: true
2
2
 
3
- git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
3
+ source 'https://rubygems.org'
4
4
 
5
5
  # Specify your gem's dependencies in open_weather_client.gemspec
6
6
  gemspec
data/README.md CHANGED
@@ -3,7 +3,8 @@
3
3
  [![Gem Version](https://badge.fury.io/rb/open_weather_client.svg)](https://badge.fury.io/rb/open_weather_client)
4
4
  ![RSpec](https://github.com/qurasoft/open_weather_client/actions/workflows/ruby.yml/badge.svg)
5
5
 
6
- Welcome to Open Weather Client. This gem allows you to easily send messages from your ruby project to Microsoft Teams channels.
6
+ Welcome to Open Weather Client.
7
+ This gem allows you to easily request weather information from OpenWeatherMap.
7
8
  It integrates in your rails project, when you are using bundler or even in plain ruby projects.
8
9
 
9
10
  ## Installation
@@ -58,6 +59,51 @@ OpenWeatherClient.configure do |config|
58
59
  end
59
60
  ```
60
61
 
62
+ ### Caching
63
+ By default Open Weather Client does not cache any data and every request will be send to the OpenWeatherMap servers.
64
+
65
+ To speed up requests and reduce the number network requests caching can be enabled.
66
+ When Open Weather Client is reset, the cache is also reset.
67
+ The cache may be accessed directly through the singleton `OpenWeatherClient.cache`.
68
+
69
+ Whether requests are only performed when the requested time is within the last hour.
70
+ If caching is enabled, requests with a time older than one hour might still be answered with a response.
71
+
72
+ ```ruby
73
+ # OpenWeatherClient initializer
74
+ OpenWeatherClient.configure do |config|
75
+ config.caching = OpenWeatherClient::Caching::Memory
76
+ config.max_memory_entries = 100 # Maximum number of entries in memory cache
77
+ end
78
+ ```
79
+
80
+ ### Cache key
81
+ The cache key for a given latitute, longitude and time is calculated by `OpenWeatherClient::Caching#cache_key(lat, lon, time)`.
82
+
83
+ #### Memory Caching
84
+ `OpenWeatherClient` supports simple in memory caching.
85
+ A hash is used to store and look up the cached responses.
86
+
87
+ #### Custom Caching
88
+ To implement custom caching, the interface of `OpenWeatherClient::Caching` is used.
89
+ A custom caching solution must implement its specific `caching_get(key)`, `caching_store(key, data)` and `present?(key)` methods.
90
+
91
+ ### Spatial Quantization
92
+ Since weather is more often than not a wider phenomenon, the high resolution location data, commonly available today may interfere with the performance even when using caching.
93
+ Caching uses the full resolution of the location data.
94
+ By default no quantization is performed.
95
+
96
+ OpenWeatherClient allows defining a quantization function to transform the latitude and longitude data before making requests or hitting the cache.
97
+ The quantization receives latitude and longitude.
98
+ The result is coerced back into latitude and longitude.
99
+
100
+ ```ruby
101
+ # OpenWeatherClient initializer
102
+ OpenWeatherClient.configure do |config|
103
+ config.spatial_quantization = proc { |lat, lon| [lat.round(2), lon.round(2)] }
104
+ end
105
+ ```
106
+
61
107
  ## Development
62
108
 
63
109
  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.
data/Rakefile CHANGED
@@ -1,6 +1,12 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
3
5
 
4
6
  RSpec::Core::RakeTask.new(:spec)
5
7
 
6
- task :default => :spec
8
+ require 'rubocop/rake_task'
9
+
10
+ RuboCop::RakeTask.new
11
+
12
+ task default: %i[spec rubocop]
data/bin/console CHANGED
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
4
  require 'bundler/setup'
4
5
  require 'open_weather_client'
@@ -0,0 +1,49 @@
1
+ # frozen_string_literal: true
2
+
3
+ module OpenWeatherClient
4
+ class Caching
5
+ ##
6
+ # Memory cache of OpenWeatherMap requests
7
+ #
8
+ # The requests are cached in memory up to the number specified in config.max_memory_entries.
9
+ # When the limit is reached the least recently used entry is evicted.
10
+ class Memory < OpenWeatherClient::Caching
11
+ # Memory cache to store a hash of keys and request data
12
+ attr :memory_cache
13
+ # Key registry of the memory cache. The first entry is the key of the least recently accessed data
14
+ attr :memory_keys
15
+
16
+ ##
17
+ # Initialize an empty cache
18
+ def initialize
19
+ super
20
+ @memory_cache = {}
21
+ @memory_keys = []
22
+ end
23
+
24
+ private
25
+
26
+ def caching_get(key)
27
+ @memory_keys.delete(key)
28
+ @memory_keys << key if @memory_cache.key? key
29
+ @memory_cache[key]
30
+ end
31
+
32
+ def caching_store(key, data)
33
+ @memory_cache[key] = data
34
+ @memory_keys.delete(key)
35
+ @memory_keys << key
36
+
37
+ if @memory_keys.count > OpenWeatherClient.configuration.max_memory_entries
38
+ @memory_cache.delete(@memory_keys.shift)
39
+ end
40
+
41
+ data
42
+ end
43
+
44
+ def present?(key)
45
+ @memory_keys.include?(key)
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,90 @@
1
+ # frozen_string_literal: true
2
+
3
+ module OpenWeatherClient
4
+ ##
5
+ # Caching of OpenWeatherMap requests
6
+ #
7
+ # The entries are cached according to latitude, longitude and time of the request.
8
+ # The time is clamped to the current hour
9
+ #
10
+ # This is the caching interface and equals a none cache. Get requests raise an error.
11
+ class Caching
12
+ ##
13
+ # Get an entry out of the cache defined by its +lat+, +lon+ and +time+.
14
+ #
15
+ # @param lat[Float] latitude of the requests location
16
+ # @param lon[Float] longitude of the requests location
17
+ # @param time[Time] time of the request
18
+ #
19
+ # @raise [KeyError] if no entry is present
20
+ # @raise [NotImplementedError] if an unsupported caching method is used
21
+ #
22
+ # @return [Hash] the stored data
23
+ def get(lat:, lon:, time:)
24
+ key = cache_key(lat, lon, time)
25
+ raise KeyError unless present?(key)
26
+
27
+ caching_get(key)
28
+ end
29
+
30
+ ##
31
+ # Store the data by its +lat+, +lon+ and +time+.
32
+ #
33
+ # @param data[Hash] data to be stored, must be able to be formatted and parsed as text
34
+ # @param lat[Float] latitude of the requests location
35
+ # @param lon[Float] longitude of the requests location
36
+ # @param time[Time] time of the request
37
+ #
38
+ # @return [Hash] the input data
39
+ def store(data:, lat:, lon:, time:)
40
+ key = cache_key(lat, lon, time)
41
+
42
+ caching_store(key, data)
43
+
44
+ data
45
+ end
46
+
47
+ ##
48
+ # Calculate the key for storage in the cache
49
+ #
50
+ # @param lat[Float] latitude of the requests location
51
+ # @param lon[Float] longitude of the requests location
52
+ # @param time[Time] time of the request
53
+ def cache_key(lat, lon, time)
54
+ "weather:#{lat}:#{lon}:#{time.strftime('%Y-%m-%dT%H')}"
55
+ end
56
+
57
+ private
58
+
59
+ ##
60
+ # Read an entry out of the memory cache
61
+ #
62
+ # @param key[String] key into the cache. Is stored at the end of the key registry
63
+ #
64
+ # @return [Hash] the stored data
65
+ def caching_get(key)
66
+ raise NotImplementedError
67
+ end
68
+
69
+ ##
70
+ # Store an entry in the memory cache
71
+ #
72
+ # Evicts the entry with the least recent access if the memory cache is full
73
+ #
74
+ # @param _key[String] key into the cache. Is stored at the end of the key registry
75
+ # @param data[Hash] data to be stored, must be able to be formatted and parsed as text
76
+ #
77
+ # @return [Hash] the input data
78
+ def caching_store(_key, data)
79
+ data
80
+ end
81
+
82
+ ##
83
+ # Check whether a key is present in the cache
84
+ #
85
+ # @return always false when the cache method is not supported or caching is not enabled
86
+ def present?(_key)
87
+ false
88
+ end
89
+ end
90
+ end
@@ -1,18 +1,53 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module OpenWeatherClient
4
+ ##
5
+ # Configuratin of OpenWeatherClient
2
6
  class Configuration
3
- attr_accessor :appid, :lang, :units, :url, :user_agent
7
+ # [String] API key to access OpenWeatherMap
8
+ attr_accessor :appid
9
+ # Caching method. One of :none, :memory
10
+ attr_reader :caching
11
+ # [String] Requested language of the result
12
+ attr_accessor :lang
13
+ # [Integer] Maximum allowed number of entries when using caching method :memory
14
+ attr_accessor :max_memory_entries
15
+ # [Proc] Quantization of latitude and longitude
16
+ attr_accessor :spatial_quantization
17
+ # [String] Requested units of the result
18
+ attr_accessor :units
19
+ # [String] Base URL of the requests to OpenWeatherMap
20
+ attr_accessor :url
21
+ # [String] User-Agent of the requests made to OpenWeatherMap
22
+ attr_accessor :user_agent
4
23
 
24
+ ##
25
+ # Initialize a new Configuration with the default settings
5
26
  def initialize
27
+ @caching = OpenWeatherClient::Caching.new
6
28
  @lang = 'de'
29
+ @max_memory_entries = 10_000
7
30
  @units = 'metric'
8
31
  @url = 'https://api.openweathermap.org/data'
9
32
  @user_agent = "Open Weather Client/#{OpenWeatherClient::VERSION}"
10
33
  end
11
34
 
35
+ ##
36
+ # Set the caching method
37
+ #
38
+ # @param cache_class[Class] class definition adhering to the OpenWeatherClient::Caching interface
39
+ def caching=(cache_class)
40
+ @caching = cache_class.new
41
+ end
42
+
43
+ ##
44
+ # Load appid from Rails credentials
45
+ #
46
+ # Load the appid from Rails credentials using the top-level key 'open_weather_client'
47
+ #
48
+ # @raise [RuntimeError] if not using Rails
12
49
  def load_from_rails_credentials
13
- unless defined? Rails
14
- raise RuntimeError, 'This method is only available in Ruby on Rails.'
15
- end
50
+ raise 'This method is only available in Ruby on Rails.' unless defined? Rails
16
51
 
17
52
  settings = Rails.application.credentials.open_weather_client!
18
53
  self.appid = settings[:appid]
@@ -0,0 +1,58 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'faraday'
4
+
5
+ module OpenWeatherClient
6
+ ##
7
+ # Request the weather from OpenWeatherMap
8
+ class Request
9
+ ##
10
+ # Request the current weather
11
+ #
12
+ # @param lat[Float] latitude of the requests location
13
+ # @param lon[Float] longitude of the requests location
14
+ # @param time[Time] time of the request
15
+ #
16
+ # @raise [AuthenticationError] if the request is not authorized, e.g in case the API key is not correct
17
+ # @raise [NotCurrentError] if the requested time is older than 1 hour
18
+ #
19
+ # @return the response body
20
+ def self.get(lat:, lon:, time: Time.now)
21
+ raise OpenWeatherClient::NotCurrentError if time < Time.now - 1 * 60 * 60
22
+
23
+ begin
24
+ response = connection(lat, lon).get('2.5/weather')
25
+ OpenWeatherClient.cache.store(lat: lat, lon: lon, data: response.body, time: time)
26
+ rescue Faraday::UnauthorizedError
27
+ raise OpenWeatherClient::AuthenticationError
28
+ end
29
+ end
30
+
31
+ def self.connection(lat, lon)
32
+ Faraday.new(
33
+ url: OpenWeatherClient.configuration.url,
34
+ params: params(lat, lon),
35
+ headers: headers
36
+ ) do |f|
37
+ f.response :raise_error
38
+ f.response :json
39
+ end
40
+ end
41
+
42
+ def self.headers
43
+ {
44
+ 'User-Agent': OpenWeatherClient.configuration.user_agent
45
+ }
46
+ end
47
+
48
+ def self.params(lat, lon)
49
+ {
50
+ appid: OpenWeatherClient.configuration.appid,
51
+ lat: lat,
52
+ lon: lon,
53
+ lang: OpenWeatherClient.configuration.lang,
54
+ units: OpenWeatherClient.configuration.units
55
+ }
56
+ end
57
+ end
58
+ end
@@ -1,3 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module OpenWeatherClient
2
- VERSION = "0.1.1"
4
+ ##
5
+ # Version of OpenWeatherClient
6
+ VERSION = '0.1.4'
3
7
  end
@@ -1,34 +1,47 @@
1
- require 'faraday'
1
+ # frozen_string_literal: true
2
2
 
3
3
  module OpenWeatherClient
4
+ ##
5
+ # Request weather information from OpenWeatherMap or the cache
4
6
  class Weather
5
- def self.current(lat:, lon:)
7
+ # [Float] latitude of the requested location
8
+ attr_accessor :lat
9
+ # [Float] longitude of the requested location
10
+ attr_accessor :lon
11
+ # [Time] time of the requested weather
12
+ attr_accessor :time
13
+
14
+ ##
15
+ # Initialize a new Weather request
16
+ #
17
+ # @param lat[Float] latitude of the requests location
18
+ # @param lon[Float] longitude of the requests location
19
+ # @param time[Time] time of the request
20
+ #
21
+ # @raise [RangeError] if one +lat+ or +lon+ are out of the expected ranges
22
+ def initialize(lat:, lon:, time: Time.now)
23
+ if OpenWeatherClient.configuration.spatial_quantization.respond_to?(:call)
24
+ lat, lon = OpenWeatherClient.configuration.spatial_quantization.call(lat, lon)
25
+ end
26
+
6
27
  raise RangeError unless (-90..90).member?(lat)
7
28
  raise RangeError unless (-180..180).member?(lon)
8
29
 
9
- connection = Faraday.new(
10
- url: OpenWeatherClient.configuration.url,
11
- params: {
12
- appid: OpenWeatherClient.configuration.appid,
13
- lat: lat,
14
- lon: lon,
15
- lang: OpenWeatherClient.configuration.lang,
16
- units: OpenWeatherClient.configuration.units
17
- },
18
- headers: {
19
- 'User-Agent': OpenWeatherClient.configuration.user_agent
20
- }
21
- ) do |f|
22
- f.response :raise_error
23
- f.response :json
24
- end
30
+ @lat = lat
31
+ @lon = lon
32
+ @time = time
33
+ end
25
34
 
26
- begin
27
- response = connection.get('2.5/weather')
28
- response.body
29
- rescue Faraday::UnauthorizedError
30
- raise OpenWeatherClient::AuthenticationError
31
- end
35
+ ##
36
+ # get the weather according to the specified parameters
37
+ #
38
+ # @raise [AuthenticationError] if the request is not authorized, e.g in case the API key is not correct
39
+ #
40
+ # @return the stored or received data
41
+ def get
42
+ OpenWeatherClient.cache.get(lat: lat, lon: lon, time: time)
43
+ rescue KeyError
44
+ OpenWeatherClient::Request.get(lat: lat, lon: lon)
32
45
  end
33
46
  end
34
47
  end
@@ -1,40 +1,71 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'open_weather_client/caching'
1
4
  require 'open_weather_client/configuration'
5
+ require 'open_weather_client/request'
2
6
  require 'open_weather_client/version'
3
7
  require 'open_weather_client/weather'
4
8
 
9
+ ##
10
+ # Get weather data from OpenWeatherMap
5
11
  module OpenWeatherClient
12
+ # Error during authentication with the OpenWeatherMap servers
6
13
  class AuthenticationError < StandardError; end
7
14
 
15
+ # The rquested time is not current enough for getting weather data from the OpenWeatherMap server
16
+ class NotCurrentError < StandardError; end
17
+
8
18
  class << self
9
- attr_accessor :configuration, :testing
19
+ # Caching singleton to access the cache
20
+ attr_writer :cache
21
+ # Configuration singleton to access the configuration
22
+ attr_writer :configuration
10
23
  end
11
24
 
25
+ ##
26
+ # Get the singleton cache instance
27
+ #
28
+ # @return [Caching] the cache
29
+ def self.cache
30
+ @cache ||= Caching.new
31
+ end
32
+
33
+ ##
34
+ # Get the singleton configuration instance
35
+ #
36
+ # @return [Configuration] the configuration
12
37
  def self.configuration
13
38
  @configuration ||= Configuration.new
14
39
  end
15
40
 
41
+ ##
42
+ # Reset cache and configuration
16
43
  def self.reset
44
+ @cache = Caching.new
17
45
  @configuration = Configuration.new
18
46
  end
19
47
 
48
+ ##
49
+ # Configure OpenWeatherClient
20
50
  def self.configure
21
51
  yield configuration
22
52
  end
23
53
 
54
+ ##
55
+ # Get the project root
24
56
  def self.project_root
25
- if defined?(Rails)
26
- return Rails.root
27
- end
28
-
29
- if defined?(Bundler)
30
- return Bundler.root
31
- end
57
+ return Rails.root if defined?(Rails)
58
+ return Bundler.root if defined?(Bundler)
32
59
 
33
60
  Dir.pwd
34
61
  end
35
62
 
63
+ ##
64
+ # Get the gem root
36
65
  def self.gem_root
37
- spec = Gem::Specification.find_by_name("open_weather_client")
38
- spec.gem_dir rescue project_root
66
+ spec = Gem::Specification.find_by_name('open_weather_client')
67
+ spec.gem_dir
68
+ rescue NoMethodError
69
+ project_root
39
70
  end
40
71
  end
@@ -1,43 +1,38 @@
1
+ # frozen_string_literal: true
1
2
 
2
- lib = File.expand_path("../lib", __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require "open_weather_client/version"
3
+ require_relative 'lib/open_weather_client/version'
5
4
 
6
5
  Gem::Specification.new do |spec|
7
- spec.name = "open_weather_client"
6
+ spec.name = 'open_weather_client'
8
7
  spec.version = OpenWeatherClient::VERSION
9
- spec.authors = ["Lucas Keune"]
10
- spec.email = ["lucas.keune@qurasoft.de"]
8
+ spec.required_ruby_version = '>= 3.0.0'
9
+ spec.authors = ['Lucas Keune']
10
+ spec.email = ['lucas.keune@qurasoft.de']
11
11
 
12
- spec.summary = %q{Access weather data from OpenWeatherMap}
13
- spec.description = %q{}
14
- spec.homepage = "https://github.com/Qurasoft/open_weather_client"
15
- spec.license = "MIT"
12
+ spec.summary = 'Access weather data from OpenWeatherMap'
13
+ spec.description = ''
14
+ spec.homepage = 'https://github.com/Qurasoft/open_weather_client'
15
+ spec.license = 'MIT'
16
16
 
17
- # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
18
- # to allow pushing to a single host or delete this section to allow pushing to any host.
19
- if spec.respond_to?(:metadata)
20
- spec.metadata["homepage_uri"] = spec.homepage
21
- spec.metadata["source_code_uri"] = "https://github.com/Qurasoft/open_weather_client"
22
- spec.metadata["changelog_uri"] = "https://github.com/Qurasoft/open_weather_client/blob/main/CHANGES.md"
23
- else
24
- raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
25
- end
17
+ spec.metadata['homepage_uri'] = spec.homepage
18
+ spec.metadata['source_code_uri'] = 'https://github.com/Qurasoft/open_weather_client'
19
+ spec.metadata['changelog_uri'] = 'https://github.com/Qurasoft/open_weather_client/blob/main/CHANGES.md'
26
20
 
27
21
  # Specify which files should be added to the gem when it is released.
28
22
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
29
- spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
23
+ spec.files = Dir.chdir(__dir__) do
30
24
  `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
31
25
  end
32
- spec.bindir = "exe"
33
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
34
- spec.require_paths = ["lib"]
26
+ spec.bindir = 'bin'
27
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
28
+ spec.require_paths = ['lib']
35
29
 
36
- spec.add_dependency "faraday", ">= 2"
30
+ spec.add_dependency 'faraday', '>= 2'
37
31
 
38
- spec.add_development_dependency "bundler", ">= 1.17"
39
- spec.add_development_dependency "rake", ">= 10.0"
40
- spec.add_development_dependency "rspec", ">= 3.0"
41
- spec.add_development_dependency "webmock"
42
- spec.add_development_dependency "simplecov"
32
+ spec.add_development_dependency 'bundler', '>= 1.17'
33
+ spec.add_development_dependency 'rake', '>= 10.0'
34
+ spec.add_development_dependency 'rspec', '>= 3.0'
35
+ spec.add_development_dependency 'rubocop'
36
+ spec.add_development_dependency 'simplecov'
37
+ spec.add_development_dependency 'webmock'
43
38
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: open_weather_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lucas Keune
8
8
  autorequire:
9
- bindir: exe
9
+ bindir: bin
10
10
  cert_chain: []
11
- date: 2023-01-26 00:00:00.000000000 Z
11
+ date: 2023-02-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -67,7 +67,7 @@ dependencies:
67
67
  - !ruby/object:Gem::Version
68
68
  version: '3.0'
69
69
  - !ruby/object:Gem::Dependency
70
- name: webmock
70
+ name: rubocop
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - ">="
@@ -94,10 +94,27 @@ dependencies:
94
94
  - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: webmock
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
97
111
  description: ''
98
112
  email:
99
113
  - lucas.keune@qurasoft.de
100
- executables: []
114
+ executables:
115
+ - ".gitignore"
116
+ - console
117
+ - setup
101
118
  extensions: []
102
119
  extra_rdoc_files: []
103
120
  files:
@@ -106,6 +123,7 @@ files:
106
123
  - ".github/workflows/ruby.yml"
107
124
  - ".gitignore"
108
125
  - ".rspec"
126
+ - ".rubocop.yml"
109
127
  - ".travis.yml"
110
128
  - CHANGES.md
111
129
  - Gemfile
@@ -116,7 +134,10 @@ files:
116
134
  - bin/console
117
135
  - bin/setup
118
136
  - lib/open_weather_client.rb
137
+ - lib/open_weather_client/caching.rb
138
+ - lib/open_weather_client/caching/memory.rb
119
139
  - lib/open_weather_client/configuration.rb
140
+ - lib/open_weather_client/request.rb
120
141
  - lib/open_weather_client/version.rb
121
142
  - lib/open_weather_client/weather.rb
122
143
  - open_weather_client.gemspec
@@ -135,7 +156,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
135
156
  requirements:
136
157
  - - ">="
137
158
  - !ruby/object:Gem::Version
138
- version: '0'
159
+ version: 3.0.0
139
160
  required_rubygems_version: !ruby/object:Gem::Requirement
140
161
  requirements:
141
162
  - - ">="