weather_gem_kg 0.32.0 → 1.0.1

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: 489ba8d1984c11aaf6337b26df7a2dcda03dabd83002bc5372806e104227894b
4
- data.tar.gz: f39c0ae0d3a142f87a7513262839955379ca8c97a6dd0529cf5813240d1a8af1
3
+ metadata.gz: a95c4c55f26f7f75e7fe956bc5d91d0148849e3df4366d98b5a90ceb1cd45ca1
4
+ data.tar.gz: 7970245200fcfb56dfcaecefb6fbb33ab32f7266f626fda99bb3c69d5e4cbf1e
5
5
  SHA512:
6
- metadata.gz: a5a0ce01ca8f1d35af8a9bd8f327240720c8bdecdf3137501daaa26844ff2878d0423179e6ab8a4b9a423d591538c8700a68533c099a45d5d976428931672a74
7
- data.tar.gz: 3de0ba3d4ffb1ad5bc5ea65ebc6305a7002b7543dacf8f473eb94df5e45c365b5ff76971bf199c5b04298295e3c94cdb7480aa37ac6eac624b74e2eb02f2a1f9
6
+ metadata.gz: 45d9ad7f35f0f21c345d8f12109b9cf177eed2b700236d8fad7b00e86d147c814b1cfd6b7c84d8ed9edac9a8adab9b0b93c85f27cc0eb56b36a1663c80ce7de0
7
+ data.tar.gz: 7432f57f7412c7f1c3b7370556941a3022821c9d1dce641bb7795eda1c38c29409d73390b1e27b5a7f5969d9189bdbe6d4070518ed28771a4efbac43c7308396
@@ -0,0 +1,22 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [master, main]
6
+ pull_request:
7
+
8
+ jobs:
9
+ test:
10
+ runs-on: ubuntu-latest
11
+
12
+ steps:
13
+ - uses: actions/checkout@v4
14
+
15
+ - name: Set up Ruby
16
+ uses: ruby/setup-ruby@v1
17
+ with:
18
+ ruby-version: .ruby-version
19
+ bundler-cache: true
20
+
21
+ - name: Run specs
22
+ run: bundle exec rake
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 4.0.6
data/CHANGELOG.md ADDED
@@ -0,0 +1,33 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project are documented in this file.
4
+
5
+ ## [1.0.0] — 2026-07-21
6
+
7
+ ### Added
8
+
9
+ - `WeatherGemKg.forecast(city:, days:, client:)` public API
10
+ - `WeatherGemKg::ForecastDay` (`date`, `max_temp`, `min_temp`, `condition`)
11
+ - `WeatherGemKg::Client` interface and `WeatherGemKg::Clients::OpenMeteo`
12
+ - Errors: `LocationNotFoundError`, `RequestError`, `InvalidArgumentError`
13
+ - GitHub Actions CI workflow
14
+ - `.ruby-version` pinned to Ruby 4.0.6
15
+ - Rails installer updated for key-free configuration
16
+
17
+ ### Changed
18
+
19
+ - Runtime dependency is `httparty` only (declared in the gemspec)
20
+ - Specs use WebMock stubs (no live HTTP in CI)
21
+ - `required_ruby_version` set to `>= 3.2`
22
+
23
+ ### Removed
24
+
25
+ - Apixu and Dark Sky clients
26
+ - `WeatherGemKg::Generator` and `#generate_me`
27
+ - API key settings (`api_key_apixu`, `api_key_dark`)
28
+ - `geocoder` and `vcr` dependencies
29
+ - Travis CI configuration
30
+
31
+ ## [0.32.0] — prior
32
+
33
+ Initial published line with Apixu and Dark Sky providers.
data/Gemfile CHANGED
@@ -1,6 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source "https://rubygems.org"
2
4
 
3
- # Specify your gem's dependencies in weather_gem_kg.gemspec
4
5
  gemspec
5
- gem "httparty"
6
- gem "geocoder"
data/Gemfile.lock CHANGED
@@ -1,45 +1,57 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- weather_gem_kg (0.31.0)
4
+ weather_gem_kg (1.0.1)
5
+ httparty (~> 0.24)
5
6
 
6
7
  GEM
7
8
  remote: https://rubygems.org/
8
9
  specs:
9
- diff-lcs (1.3)
10
- geocoder (1.5.1)
11
- httparty (0.17.0)
12
- mime-types (~> 3.0)
10
+ addressable (2.9.0)
11
+ public_suffix (>= 2.0.2, < 8.0)
12
+ bigdecimal (4.1.2)
13
+ crack (1.0.1)
14
+ bigdecimal
15
+ rexml
16
+ csv (3.3.5)
17
+ diff-lcs (1.6.2)
18
+ hashdiff (1.2.1)
19
+ httparty (0.24.2)
20
+ csv
21
+ mini_mime (>= 1.0.0)
13
22
  multi_xml (>= 0.5.2)
14
- mime-types (3.2.2)
15
- mime-types-data (~> 3.2015)
16
- mime-types-data (3.2019.0331)
17
- multi_xml (0.6.0)
18
- rake (10.5.0)
19
- rspec (3.8.0)
20
- rspec-core (~> 3.8.0)
21
- rspec-expectations (~> 3.8.0)
22
- rspec-mocks (~> 3.8.0)
23
- rspec-core (3.8.2)
24
- rspec-support (~> 3.8.0)
25
- rspec-expectations (3.8.4)
23
+ mini_mime (1.1.5)
24
+ multi_xml (0.9.1)
25
+ bigdecimal (>= 3.1, < 5)
26
+ public_suffix (7.0.5)
27
+ rake (13.4.2)
28
+ rexml (3.4.4)
29
+ rspec (3.13.2)
30
+ rspec-core (~> 3.13.0)
31
+ rspec-expectations (~> 3.13.0)
32
+ rspec-mocks (~> 3.13.0)
33
+ rspec-core (3.13.6)
34
+ rspec-support (~> 3.13.0)
35
+ rspec-expectations (3.13.5)
26
36
  diff-lcs (>= 1.2.0, < 2.0)
27
- rspec-support (~> 3.8.0)
28
- rspec-mocks (3.8.1)
37
+ rspec-support (~> 3.13.0)
38
+ rspec-mocks (3.13.8)
29
39
  diff-lcs (>= 1.2.0, < 2.0)
30
- rspec-support (~> 3.8.0)
31
- rspec-support (3.8.2)
40
+ rspec-support (~> 3.13.0)
41
+ rspec-support (3.13.7)
42
+ webmock (3.26.2)
43
+ addressable (>= 2.8.0)
44
+ crack (>= 0.3.2)
45
+ hashdiff (>= 0.4.0, < 2.0.0)
32
46
 
33
47
  PLATFORMS
34
48
  ruby
35
49
 
36
50
  DEPENDENCIES
37
- bundler (~> 2.0)
38
- geocoder
39
- httparty
40
- rake (~> 10.0)
51
+ rake (~> 13.0)
41
52
  rspec (~> 3.0)
42
53
  weather_gem_kg!
54
+ webmock (~> 3.0)
43
55
 
44
56
  BUNDLED WITH
45
- 2.0.2
57
+ 4.0.16
data/README.md CHANGED
@@ -1,43 +1,133 @@
1
1
  # WeatherGemKg
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/weather_gem_kg`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ Daily city weather forecasts for Ruby, powered by [Open-Meteo](https://open-meteo.com/).
4
4
 
5
- TODO: Delete this and the text above, and describe your gem
5
+ - **No API key** required
6
+ - Returns structured `ForecastDay` objects (`date`, `max_temp`, `min_temp`, `condition`)
7
+ - Swappable client interface for custom providers
8
+ - Ruby **≥ 3.2**
6
9
 
7
10
  ## Installation
8
11
 
9
- Add this line to your application's Gemfile:
12
+ Add to your Gemfile:
10
13
 
11
14
  ```ruby
12
- gem 'weather_gem_kg'
15
+ gem "weather_gem_kg", "~> 1.0"
13
16
  ```
14
17
 
15
- And then execute:
18
+ Then:
16
19
 
17
- $ bundle
20
+ ```bash
21
+ bundle install
22
+ ```
23
+
24
+ Or install directly:
18
25
 
19
- Or install it yourself as:
26
+ ```bash
27
+ gem install weather_gem_kg
28
+ ```
20
29
 
21
- $ gem install weather_gem_kg
30
+ Pin `~> 1.0` if you previously used `0.x` — **1.0.0 is a breaking release**. See [CHANGELOG.md](CHANGELOG.md).
31
+
32
+ ### Rails
33
+
34
+ ```bash
35
+ rails generate weather_gem_kg:install
36
+ ```
37
+
38
+ This creates `config/initializers/weather_gem_kg.rb`.
22
39
 
23
40
  ## Usage
24
41
 
25
- TODO: Write usage instructions here
42
+ ```ruby
43
+ require "weather_gem_kg"
26
44
 
27
- ## Development
45
+ forecast = WeatherGemKg.forecast(city: "Bishkek", days: 3)
28
46
 
29
- 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.
47
+ forecast.each do |day|
48
+ puts "#{day.date}: #{day.min_temp}–#{day.max_temp}°C, #{day.condition}"
49
+ end
50
+ # => 2026-07-21: 15.2–30.1°C, Clear sky
51
+ ```
30
52
 
31
- 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).
53
+ ### `ForecastDay`
32
54
 
33
- ## Contributing
55
+ | Attribute | Type | Description |
56
+ |-------------|---------|--------------------------|
57
+ | `date` | String | ISO date (`YYYY-MM-DD`) |
58
+ | `max_temp` | Float | Daily high (°C) |
59
+ | `min_temp` | Float | Daily low (°C) |
60
+ | `condition` | String | Human-readable condition |
34
61
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/weather_gem_kg. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
62
+ `days` must be between **1 and 16** (Open-Meteo limit). If omitted, `configuration.default_days` is used (default: `1`).
36
63
 
37
- ## License
64
+ ### Configuration
65
+
66
+ ```ruby
67
+ WeatherGemKg.configure do |config|
68
+ config.default_days = 3
69
+ # config.client = WeatherGemKg::Clients::OpenMeteo.new
70
+ end
71
+ ```
72
+
73
+ No API keys are needed for the default Open-Meteo client.
74
+
75
+ ### Errors
76
+
77
+ ```ruby
78
+ begin
79
+ WeatherGemKg.forecast(city: "Bishkek", days: 3)
80
+ rescue WeatherGemKg::LocationNotFoundError
81
+ # city could not be geocoded
82
+ rescue WeatherGemKg::RequestError
83
+ # HTTP / upstream failure
84
+ rescue WeatherGemKg::InvalidArgumentError
85
+ # blank city or days out of range
86
+ end
87
+ ```
88
+
89
+ All errors inherit from `WeatherGemKg::Error`.
90
+
91
+ ### Custom client
92
+
93
+ Any object that implements `#forecast(city:, days:)` and returns an `Array` of `ForecastDay` can be used:
38
94
 
39
- The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
95
+ ```ruby
96
+ class MyClient < WeatherGemKg::Client
97
+ def forecast(city:, days:)
98
+ # ...
99
+ end
100
+ end
101
+
102
+ WeatherGemKg.forecast(city: "Bishkek", days: 1, client: MyClient.new)
103
+ # or
104
+ WeatherGemKg.configure { |c| c.client = MyClient.new }
105
+ ```
106
+
107
+ ## Development
40
108
 
41
- ## Code of Conduct
109
+ ```bash
110
+ bundle install
111
+ bundle exec rake # run specs
112
+ bin/console # interactive console with the gem loaded
113
+ ```
114
+
115
+ Specs stub HTTP with WebMock — no network required for the test suite.
116
+
117
+ ### Releasing to RubyGems
118
+
119
+ 1. Bump `WeatherGemKg::VERSION` in `lib/weather_gem_kg/version.rb`
120
+ 2. Update [CHANGELOG.md](CHANGELOG.md)
121
+ 3. Commit all changes (the gemspec packs files via `git ls-files`)
122
+ 4. Publish:
123
+
124
+ ```bash
125
+ bundle exec rake release
126
+ # or
127
+ gem build weather_gem_kg.gemspec
128
+ gem push weather_gem_kg-X.Y.Z.gem
129
+ ```
130
+
131
+ ## License
42
132
 
43
- Everyone interacting in the WeatherGemKg project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/weather_gem_kg/blob/master/CODE_OF_CONDUCT.md).
133
+ MIT see [LICENSE.txt](LICENSE.txt).
@@ -1,4 +1,4 @@
1
1
  WeatherGemKg.configure do |config|
2
- # config.api_key_apixu = '123dfafasdfasddf'
3
- # config.api_key_dark = '1asd231sdasffas'
2
+ # config.default_days = 3
3
+ # config.client = WeatherGemKg::Clients::OpenMeteo.new
4
4
  end
@@ -1,13 +1,13 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module WeatherGemKg
2
4
  module Generators
3
5
  class InstallGenerator < Rails::Generators::Base
4
6
  source_root File.expand_path("../../templates", __FILE__)
5
- desc "Creates Jem initializer for your application"
7
+ desc "Creates WeatherGemKg initializer for your application"
6
8
 
7
9
  def copy_initializer
8
10
  template "weather_gem_kg_initializer.rb", "config/initializers/weather_gem_kg.rb"
9
-
10
- puts "Install complete! Truly Outrageous!"
11
11
  end
12
12
  end
13
13
  end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module WeatherGemKg
4
+ # Base contract for weather providers.
5
+ # Implementations must return an Array of ForecastDay.
6
+ class Client
7
+ def forecast(city:, days:)
8
+ raise NotImplementedError, "#{self.class}#forecast must be implemented"
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,103 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "httparty"
4
+ require "weather_gem_kg/client"
5
+ require "weather_gem_kg/errors"
6
+ require "weather_gem_kg/forecast_day"
7
+
8
+ module WeatherGemKg
9
+ module Clients
10
+ class OpenMeteo < Client
11
+ GEOCODING_URL = "https://geocoding-api.open-meteo.com/v1/search"
12
+ FORECAST_URL = "https://api.open-meteo.com/v1/forecast"
13
+
14
+ WEATHER_CODES = {
15
+ 0 => "Clear sky",
16
+ 1 => "Mainly clear",
17
+ 2 => "Partly cloudy",
18
+ 3 => "Overcast",
19
+ 45 => "Fog",
20
+ 48 => "Depositing rime fog",
21
+ 51 => "Light drizzle",
22
+ 53 => "Moderate drizzle",
23
+ 55 => "Dense drizzle",
24
+ 56 => "Light freezing drizzle",
25
+ 57 => "Dense freezing drizzle",
26
+ 61 => "Slight rain",
27
+ 63 => "Moderate rain",
28
+ 65 => "Heavy rain",
29
+ 66 => "Light freezing rain",
30
+ 67 => "Heavy freezing rain",
31
+ 71 => "Slight snow",
32
+ 73 => "Moderate snow",
33
+ 75 => "Heavy snow",
34
+ 77 => "Snow grains",
35
+ 80 => "Slight rain showers",
36
+ 81 => "Moderate rain showers",
37
+ 82 => "Violent rain showers",
38
+ 85 => "Slight snow showers",
39
+ 86 => "Heavy snow showers",
40
+ 95 => "Thunderstorm",
41
+ 96 => "Thunderstorm with slight hail",
42
+ 99 => "Thunderstorm with heavy hail"
43
+ }.freeze
44
+
45
+ def forecast(city:, days:)
46
+ days = Integer(days)
47
+ raise InvalidArgumentError, "days must be between 1 and 16" unless days.between?(1, 16)
48
+
49
+ location = geocode(city)
50
+ payload = fetch_forecast(location.fetch(:latitude), location.fetch(:longitude), days)
51
+ parse_forecast(payload)
52
+ end
53
+
54
+ private
55
+
56
+ def geocode(city)
57
+ response = HTTParty.get(GEOCODING_URL, query: { name: city, count: 1 })
58
+ raise RequestError, "Geocoding failed (HTTP #{response.code})" unless response.success?
59
+
60
+ result = response.parsed_response&.dig("results", 0)
61
+ raise LocationNotFoundError, "No location found for #{city.inspect}" unless result
62
+
63
+ {
64
+ latitude: result.fetch("latitude"),
65
+ longitude: result.fetch("longitude")
66
+ }
67
+ end
68
+
69
+ def fetch_forecast(latitude, longitude, days)
70
+ response = HTTParty.get(
71
+ FORECAST_URL,
72
+ query: {
73
+ latitude: latitude,
74
+ longitude: longitude,
75
+ daily: "weather_code,temperature_2m_max,temperature_2m_min",
76
+ forecast_days: days,
77
+ timezone: "auto"
78
+ }
79
+ )
80
+ raise RequestError, "Forecast request failed (HTTP #{response.code})" unless response.success?
81
+
82
+ response.parsed_response
83
+ end
84
+
85
+ def parse_forecast(payload)
86
+ daily = payload.fetch("daily")
87
+ times = daily.fetch("time")
88
+ max_temps = daily.fetch("temperature_2m_max")
89
+ min_temps = daily.fetch("temperature_2m_min")
90
+ codes = daily.fetch("weather_code")
91
+
92
+ times.each_index.map do |index|
93
+ ForecastDay.new(
94
+ date: times[index],
95
+ max_temp: max_temps[index],
96
+ min_temp: min_temps[index],
97
+ condition: WEATHER_CODES.fetch(codes[index], "Unknown")
98
+ )
99
+ end
100
+ end
101
+ end
102
+ end
103
+ end
@@ -1,26 +1,33 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module WeatherGemKg
2
4
  class << self
3
- attr_accessor :configuration
5
+ attr_writer :configuration
4
6
  end
5
7
 
6
8
  def self.configuration
7
- @configuration ||= Configuration.new
9
+ @configuration ||= Configuration.new
8
10
  end
9
11
 
10
12
  def self.configure
11
13
  yield(configuration) if block_given?
12
14
  end
13
15
 
16
+ def self.reset_configuration!
17
+ @configuration = Configuration.new
18
+ end
19
+
14
20
  class Configuration
15
- attr_accessor :api_key_apixu, :api_key_dark
21
+ attr_writer :client
22
+ attr_accessor :default_days
16
23
 
17
24
  def initialize
18
- @api_key_apixu = nil
19
- @api_key_dark = nil
25
+ @default_days = 1
26
+ @client = nil
27
+ end
28
+
29
+ def client
30
+ @client ||= Clients::OpenMeteo.new
20
31
  end
21
32
  end
22
33
  end
23
- WeatherGemKg.configure do |c| # => MyGem
24
- c.api_key_apixu = '6d79fff9ef764b8c85d61836190907' # => 1
25
- c.api_key_dark = '0a06f48b71537e4e72554c3f8d39d234' # => "some string"
26
- end # => "some string"
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ module WeatherGemKg
4
+ class Error < StandardError; end
5
+ class LocationNotFoundError < Error; end
6
+ class RequestError < Error; end
7
+ class InvalidArgumentError < Error; end
8
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module WeatherGemKg
4
+ ForecastDay = Data.define(:date, :max_temp, :min_temp, :condition)
5
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module WeatherGemKg
2
- VERSION = "0.32.0"
4
+ VERSION = "1.0.1"
3
5
  end
@@ -1,13 +1,17 @@
1
- require "httparty"
1
+ # frozen_string_literal: true
2
+
2
3
  require "weather_gem_kg/version"
3
- require "weather_gem_kg/generator"
4
+ require "weather_gem_kg/errors"
5
+ require "weather_gem_kg/forecast_day"
6
+ require "weather_gem_kg/client"
4
7
  require "weather_gem_kg/config"
8
+ require "weather_gem_kg/clients/open_meteo"
5
9
 
6
10
  module WeatherGemKg
7
- end
11
+ def self.forecast(city:, days: nil, client: nil)
12
+ raise InvalidArgumentError, "city is required" if city.nil? || city.to_s.strip.empty?
8
13
 
9
- # weather1 = WeatherGemKg::Generator.new('Bishkek', 1, WeatherGemKg::Clients::Apixu.new)
10
- # weather1.generate_me
11
- #
12
- # weather2 = WeatherGemKg::Generator.new('Bishkek', 1, WeatherGemKg::Clients::DarkSky.new)
13
- # puts weather2.generate_me
14
+ days ||= configuration.default_days
15
+ (client || configuration.client).forecast(city: city, days: days)
16
+ end
17
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  lib = File.expand_path("lib", __dir__)
2
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
5
  require "weather_gem_kg/version"
@@ -8,27 +10,21 @@ Gem::Specification.new do |spec|
8
10
  spec.authors = ["Edilbek"]
9
11
  spec.email = ["edil.talantbekov@gmail.com"]
10
12
 
11
- spec.summary = %q{Write a short summary, because RubyGems requires one.}
12
- spec.description = %q{Write a longer description or delete this line.}
13
- # spec.homepage = "Put your gem's website or public repo URL here."
13
+ spec.summary = "Daily weather forecasts via Open-Meteo"
14
+ spec.description = "A small Ruby gem that fetches daily city forecasts using the free Open-Meteo API."
14
15
  spec.license = "MIT"
16
+ spec.required_ruby_version = ">= 3.2"
15
17
 
16
- # spec.metadata["allowed_push_host"] = "Set to 'http://mygemserver.com'"
17
-
18
- # spec.metadata["homepage_uri"] = spec.homepage
19
- # spec.metadata["source_code_uri"] = "Put your gem's public repo URL here."
20
- # spec.metadata["changelog_uri"] = "Put your gem's CHANGELOG.md URL here."
21
-
22
- # Specify which files should be added to the gem when it is released.
23
- # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
24
- spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
18
+ spec.files = Dir.chdir(File.expand_path("..", __FILE__)) do
25
19
  `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
26
20
  end
27
21
  spec.bindir = "exe"
28
22
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
29
23
  spec.require_paths = ["lib"]
30
24
 
31
- spec.add_development_dependency "bundler", "~> 2.0"
32
- spec.add_development_dependency "rake", "~> 10.0"
25
+ spec.add_dependency "httparty", "~> 0.24"
26
+
27
+ spec.add_development_dependency "rake", "~> 13.0"
33
28
  spec.add_development_dependency "rspec", "~> 3.0"
29
+ spec.add_development_dependency "webmock", "~> 3.0"
34
30
  end
metadata CHANGED
@@ -1,43 +1,42 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: weather_gem_kg
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.32.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Edilbek
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2019-07-15 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
- name: bundler
13
+ name: httparty
15
14
  requirement: !ruby/object:Gem::Requirement
16
15
  requirements:
17
16
  - - "~>"
18
17
  - !ruby/object:Gem::Version
19
- version: '2.0'
20
- type: :development
18
+ version: '0.24'
19
+ type: :runtime
21
20
  prerelease: false
22
21
  version_requirements: !ruby/object:Gem::Requirement
23
22
  requirements:
24
23
  - - "~>"
25
24
  - !ruby/object:Gem::Version
26
- version: '2.0'
25
+ version: '0.24'
27
26
  - !ruby/object:Gem::Dependency
28
27
  name: rake
29
28
  requirement: !ruby/object:Gem::Requirement
30
29
  requirements:
31
30
  - - "~>"
32
31
  - !ruby/object:Gem::Version
33
- version: '10.0'
32
+ version: '13.0'
34
33
  type: :development
35
34
  prerelease: false
36
35
  version_requirements: !ruby/object:Gem::Requirement
37
36
  requirements:
38
37
  - - "~>"
39
38
  - !ruby/object:Gem::Version
40
- version: '10.0'
39
+ version: '13.0'
41
40
  - !ruby/object:Gem::Dependency
42
41
  name: rspec
43
42
  requirement: !ruby/object:Gem::Requirement
@@ -52,16 +51,33 @@ dependencies:
52
51
  - - "~>"
53
52
  - !ruby/object:Gem::Version
54
53
  version: '3.0'
55
- description: Write a longer description or delete this line.
54
+ - !ruby/object:Gem::Dependency
55
+ name: webmock
56
+ requirement: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: '3.0'
61
+ type: :development
62
+ prerelease: false
63
+ version_requirements: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - "~>"
66
+ - !ruby/object:Gem::Version
67
+ version: '3.0'
68
+ description: A small Ruby gem that fetches daily city forecasts using the free Open-Meteo
69
+ API.
56
70
  email:
57
71
  - edil.talantbekov@gmail.com
58
72
  executables: []
59
73
  extensions: []
60
74
  extra_rdoc_files: []
61
75
  files:
76
+ - ".github/workflows/ci.yml"
62
77
  - ".gitignore"
63
78
  - ".rspec"
64
- - ".travis.yml"
79
+ - ".ruby-version"
80
+ - CHANGELOG.md
65
81
  - CODE_OF_CONDUCT.md
66
82
  - Gemfile
67
83
  - Gemfile.lock
@@ -73,18 +89,16 @@ files:
73
89
  - lib/generators/templates/weather_gem_kg_initializer.rb
74
90
  - lib/generators/weather_gem_kg/install_generator.rb
75
91
  - lib/weather_gem_kg.rb
76
- - lib/weather_gem_kg/clients/apixu.rb
77
- - lib/weather_gem_kg/clients/dark_sky.rb
92
+ - lib/weather_gem_kg/client.rb
93
+ - lib/weather_gem_kg/clients/open_meteo.rb
78
94
  - lib/weather_gem_kg/config.rb
79
- - lib/weather_gem_kg/generator.rb
95
+ - lib/weather_gem_kg/errors.rb
96
+ - lib/weather_gem_kg/forecast_day.rb
80
97
  - lib/weather_gem_kg/version.rb
81
- - weather_gem_kg-0.31.0.gem
82
98
  - weather_gem_kg.gemspec
83
- homepage:
84
99
  licenses:
85
100
  - MIT
86
101
  metadata: {}
87
- post_install_message:
88
102
  rdoc_options: []
89
103
  require_paths:
90
104
  - lib
@@ -92,15 +106,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
92
106
  requirements:
93
107
  - - ">="
94
108
  - !ruby/object:Gem::Version
95
- version: '0'
109
+ version: '3.2'
96
110
  required_rubygems_version: !ruby/object:Gem::Requirement
97
111
  requirements:
98
112
  - - ">="
99
113
  - !ruby/object:Gem::Version
100
114
  version: '0'
101
115
  requirements: []
102
- rubygems_version: 3.0.4
103
- signing_key:
116
+ rubygems_version: 4.0.16
104
117
  specification_version: 4
105
- summary: Write a short summary, because RubyGems requires one.
118
+ summary: Daily weather forecasts via Open-Meteo
106
119
  test_files: []
data/.travis.yml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- sudo: false
3
- language: ruby
4
- cache: bundler
5
- rvm:
6
- - 2.4.1
7
- before_install: gem install bundler -v 2.0.2
@@ -1,30 +0,0 @@
1
- require_relative '../config'
2
-
3
- module WeatherGemKg
4
- module Clients
5
- class Apixu
6
- API_KEY = WeatherGemKg.configuration.api_key_apixu
7
-
8
- def initialize
9
- @base_url = "http://api.apixu.com/v1/forecast.json?key=#{API_KEY}"
10
- end
11
-
12
- def get_weather(city, days)
13
- @data = get_weather_info(city, days)
14
- @data.dig('forecast', 'forecastday').map do |f|
15
- day = f.dig('day')
16
- {
17
- date: Time.at(f['date_epoch']).ctime.slice(0, 10),
18
- max_temp: day['maxtemp_c'],
19
- min_temp: day['mintemp_c'],
20
- condition: day.dig('condition', 'text')
21
- }
22
- end
23
- end
24
-
25
- def get_weather_info(city, days)
26
- HTTParty.get("#{@base_url}&q=#{city}&days=#{days}")
27
- end
28
- end
29
- end
30
- end
@@ -1,37 +0,0 @@
1
- require "geocoder"
2
- require_relative '../config'
3
-
4
- module WeatherGemKg
5
- module Clients
6
- class DarkSky
7
- API_KEY = WeatherGemKg.configuration.api_key_dark
8
-
9
- def initialize
10
- @base_url = "https://api.darksky.net/forecast/#{API_KEY}"
11
- end
12
-
13
- def get_weather(city, days)
14
- @data = get_weather_info(city, days)
15
-
16
- @data.dig("daily", "data")[0...days].map do |f|
17
- {
18
- date: Time.at(f['time']).ctime.slice(0, 10),
19
- max_temp: ((f["temperatureHigh"] - 32) * 5 / 9).round(1),
20
- min_temp: ((f["temperatureLow"] - 32) * 5 / 9).round(1),
21
- condition: f["summary"]
22
- }
23
- end
24
- end
25
-
26
- def get_weather_info(city, days)
27
- coordinates = get_city_coordinates(city)
28
-
29
- HTTParty.get("#{@base_url}/#{coordinates}")
30
- end
31
-
32
- def get_city_coordinates(city)
33
- Geocoder.search("#{city}").first.coordinates.map(&:inspect).join(',')
34
- end
35
- end
36
- end
37
- end
@@ -1,18 +0,0 @@
1
- require "weather_gem_kg/clients/apixu"
2
- require "weather_gem_kg/clients/dark_sky"
3
-
4
- module WeatherGemKg
5
- class Generator
6
- attr_reader :city, :day, :generator
7
-
8
- def initialize(city, day, generator)
9
- @city = city
10
- @day = day
11
- @generator = generator
12
- end
13
-
14
- def generate_me
15
- generator.get_weather(city, day)
16
- end
17
- end
18
- end
Binary file