open_weather_map_api 0.0.0 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +25 -0
- data/Gemfile +4 -0
- data/README.md +96 -0
- data/lib/open_weather_map_api.rb +0 -1
- data/open_weather_map_api.gemspec +17 -0
- data/spec/open_weather_map_api_spec.rb +33 -0
- data/spec/spec_helper.rb +5 -0
- metadata +40 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 21abdc5c4412ca5a2bc9337986cc3901190bf481447ee7638fc56217ffa7034d
|
4
|
+
data.tar.gz: 5f52798cb8167a16f08501a5ece5b184a089f5a6d0a3af39a5114477d59efa67
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a35352bc9ef0523dac96065bcd33fa9a16610a905d62cdf4542ece8b6babcd3c199a3fbfd526f22decead03e5c22dca22ea1f2d49bf8dc708d61e2c7ceb90b12
|
7
|
+
data.tar.gz: '054388218b580d87c49a7a62da2f6ed1dd65955efb47a05b2051d52d531b1699e57dba3d580705628f373266520fc7b528ae14153ed202883ec8be9b4c4e95f6'
|
data/.gitignore
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
*.bundle
|
19
|
+
*.so
|
20
|
+
*.o
|
21
|
+
*.a
|
22
|
+
mkmf.log
|
23
|
+
.ruby-gemset
|
24
|
+
.ruby-version
|
25
|
+
.env
|
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,96 @@
|
|
1
|
+
# OpenWeatherMapAPI - Ruby API Client
|
2
|
+
|
3
|
+
Get Weather and Forecast for the city you want easily.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'open_weather_map_api'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
```bash
|
16
|
+
$ bundle install
|
17
|
+
```
|
18
|
+
|
19
|
+
## Usage Examples
|
20
|
+
|
21
|
+
**Get weather by city**
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
OpenWeatherMapApi.get_weather(q: 'florianopolis', appid: <APPID>)
|
25
|
+
```
|
26
|
+
|
27
|
+
**Get weather by latitude an longitude**
|
28
|
+
|
29
|
+
```ruby
|
30
|
+
OpenWeatherMapApi.get_weather(lat: '51.5085', lon: '-0.1257', appid: <APPID>)
|
31
|
+
```
|
32
|
+
|
33
|
+
**Get forecast by city**
|
34
|
+
|
35
|
+
```ruby
|
36
|
+
OpenWeatherMapApi.get_forecast(q: 'florianopolis', appid: <APPID>)
|
37
|
+
```
|
38
|
+
|
39
|
+
**Get forecast by latitude an longitude**
|
40
|
+
|
41
|
+
```ruby
|
42
|
+
OpenWeatherMapApi.get_forecast(lat: '51.5085', lon: '-0.1257', appid: <APPID>)
|
43
|
+
```
|
44
|
+
|
45
|
+
**Get weather in Celsius**
|
46
|
+
|
47
|
+
```ruby
|
48
|
+
OpenWeatherMapApi.get_weather(q: 'florianopolis', units: 'metric', appid: <APPID>)
|
49
|
+
```
|
50
|
+
|
51
|
+
**Get weather in Fahrenheit**
|
52
|
+
|
53
|
+
```ruby
|
54
|
+
OpenWeatherMapApi.get_weather(q: 'florianopolis', units: 'imperial', appid: <APPID>)
|
55
|
+
```
|
56
|
+
|
57
|
+
**Get weather response in Portuguese**
|
58
|
+
|
59
|
+
```ruby
|
60
|
+
OpenWeatherMapApi.get_weather(q: 'florianopolis', lang: 'pt_br', appid: <APPID>)
|
61
|
+
```
|
62
|
+
|
63
|
+
**Get weather response format in xml**
|
64
|
+
|
65
|
+
```ruby
|
66
|
+
OpenWeatherMapApi.get_weather(q: 'florianopolis', mode: 'xml', appid: <APPID>)
|
67
|
+
```
|
68
|
+
|
69
|
+
**Get weather response format in html**
|
70
|
+
|
71
|
+
```ruby
|
72
|
+
OpenWeatherMapApi.get_weather(q: 'florianopolis', mode: 'html', appid: <APPID>)
|
73
|
+
```
|
74
|
+
|
75
|
+
## Props
|
76
|
+
|
77
|
+
**Weather**
|
78
|
+
|
79
|
+
| Prop | Type | Default | Note |
|
80
|
+
| ---------------------- | ------------------------------ | ---------- | ------------------------------------------------ |
|
81
|
+
| `lat, lon` | `string` | `required` | Geographical coordinates (latitude, longitude) |
|
82
|
+
| `appid` | `string` | `required` | Your unique API key. [Learn more](https://home.openweathermap.org/api_keys) |
|
83
|
+
| `mode` | `json, xml, html` | `json` | Response format |
|
84
|
+
| `units` | `standard, metric, imperial` | `standard` | Units of measurement: standard: `Kelvin`, metric: `Celsius`, imperial: `Fahrenheit` |
|
85
|
+
| `lang` | `string` | `en` | You can use this parameter to get the output in your language. [Learn more](https://openweathermap.org/current#multi) |
|
86
|
+
|
87
|
+
**Forecast**
|
88
|
+
|
89
|
+
| Prop | Type | Default | Note |
|
90
|
+
| ---------------------- | ------------------------------ | ---------- | ------------------------------------------------ |
|
91
|
+
| `lat, lon` | `string` | `required` | Geographical coordinates (latitude, longitude) |
|
92
|
+
| `appid` | `string` | `required` | Your unique API key. [Learn more](https://home.openweathermap.org/api_keys) |
|
93
|
+
| `mode` | `json, xml, html` | `json` | Response format |
|
94
|
+
| `units` | `standard, metric, imperial` | `standard` | Units of measurement: standard: `Kelvin`, metric: `Celsius`, imperial: `Fahrenheit` |
|
95
|
+
| `lang` | `string` | `en` | You can use this parameter to get the output in your language. [Learn more](https://openweathermap.org/current#multi) |
|
96
|
+
| `cnt` | `string` | `optional` | A number of timestamps, which will be returned in the API response |
|
data/lib/open_weather_map_api.rb
CHANGED
@@ -0,0 +1,17 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = 'open_weather_map_api'
|
3
|
+
s.version = '0.0.3'
|
4
|
+
s.summary = "Implementation of OpenWeatherMap API"
|
5
|
+
s.description = "Get Weather and Forecast for the city you want easily"
|
6
|
+
s.authors = ["Wellington Gomes Graciani"]
|
7
|
+
s.email = 'wellingtongg12@gmail.com'
|
8
|
+
s.files = ["lib/open_weather_map_api.rb"]
|
9
|
+
s.homepage = 'https://github.com/Wellingtongg/open_weather_map_api'
|
10
|
+
s.license = 'MIT'
|
11
|
+
|
12
|
+
s.files = `git ls-files -z`.split("\x0")
|
13
|
+
s.test_files = s.files.grep(%r{^spec/})
|
14
|
+
|
15
|
+
s.add_development_dependency "rspec", "~> 3.10"
|
16
|
+
s.add_development_dependency "dotenv", "~> 2.7.6"
|
17
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
RSpec.describe OpenWeatherMapApi do
|
4
|
+
describe '#OpenWeatherMapService' do
|
5
|
+
it 'get weather by city' do
|
6
|
+
response = OpenWeatherMapApi.get_weather(q: 'florianopolis', appid: ENV['OPEN_WEATHER_MAP_APP_ID'])
|
7
|
+
|
8
|
+
expect(response.class).to eq(Hash)
|
9
|
+
expect(response['name']).to eq('Florianópolis')
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'get weather by latitude an longitude' do
|
13
|
+
response = OpenWeatherMapApi.get_weather(lat: '51.5085', lon: '-0.1257', appid: ENV['OPEN_WEATHER_MAP_APP_ID'])
|
14
|
+
|
15
|
+
expect(response.class).to eq(Hash)
|
16
|
+
expect(response['name']).to eq('London')
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'get forecast by city' do
|
20
|
+
response = OpenWeatherMapApi.get_forecast(q: 'florianopolis', appid: ENV['OPEN_WEATHER_MAP_APP_ID'])
|
21
|
+
|
22
|
+
expect(response.class).to eq(Hash)
|
23
|
+
expect(response['city']['name']).to eq('Florianópolis')
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'get forecast by latitude an longitude' do
|
27
|
+
response = OpenWeatherMapApi.get_forecast(lat: '51.5085', lon: '-0.1257', appid: ENV['OPEN_WEATHER_MAP_APP_ID'])
|
28
|
+
|
29
|
+
expect(response.class).to eq(Hash)
|
30
|
+
expect(response['city']['name']).to eq('London')
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
CHANGED
@@ -1,22 +1,56 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: open_weather_map_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Wellington Gomes Graciani
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-02-
|
12
|
-
dependencies:
|
11
|
+
date: 2022-02-25 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rspec
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '3.10'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '3.10'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: dotenv
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 2.7.6
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 2.7.6
|
13
41
|
description: Get Weather and Forecast for the city you want easily
|
14
42
|
email: wellingtongg12@gmail.com
|
15
43
|
executables: []
|
16
44
|
extensions: []
|
17
45
|
extra_rdoc_files: []
|
18
46
|
files:
|
47
|
+
- ".gitignore"
|
48
|
+
- Gemfile
|
49
|
+
- README.md
|
19
50
|
- lib/open_weather_map_api.rb
|
51
|
+
- open_weather_map_api.gemspec
|
52
|
+
- spec/open_weather_map_api_spec.rb
|
53
|
+
- spec/spec_helper.rb
|
20
54
|
homepage: https://github.com/Wellingtongg/open_weather_map_api
|
21
55
|
licenses:
|
22
56
|
- MIT
|
@@ -40,4 +74,6 @@ rubygems_version: 3.0.3
|
|
40
74
|
signing_key:
|
41
75
|
specification_version: 4
|
42
76
|
summary: Implementation of OpenWeatherMap API
|
43
|
-
test_files:
|
77
|
+
test_files:
|
78
|
+
- spec/open_weather_map_api_spec.rb
|
79
|
+
- spec/spec_helper.rb
|