wettr 0.1.2 → 0.1.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 +4 -4
- data/Gemfile.lock +1 -3
- data/README.md +9 -10
- data/exe/wettr +1 -0
- data/lib/wettr.rb +2 -2
- data/lib/wettr/config.rb +38 -0
- data/lib/wettr/ip_api.rb +0 -1
- data/lib/wettr/version.rb +1 -1
- data/lib/wettr/weather_api.rb +10 -2
- data/wettr.gemspec +0 -4
- metadata +3 -18
- data/.env.production +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d06916e7600ff91c086a3757749b9f7a9c732ab519c0ca34f3694b03a3b9f605
|
4
|
+
data.tar.gz: e695734140df54f1b7b6865a73443302f1a4294d5a02e5a93c343924f372fede
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0ba8cafb6e11c6526f08f08a8a00675af0294b72a8d58bbd1a8b9f132115f7fb734b54e54f1216e44ac8c13ba4c389ac54b231af63e5a640e98943ac7ecc12c7
|
7
|
+
data.tar.gz: 57aa7781a484a0e55e161ce6fa6d9f52756d2272c2887fbc6ff6209fc9d1a0e66bda8da6ad2c27100384bc17d2388c2577ed52552641c2f6ff40330116987e60
|
data/Gemfile.lock
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
wettr (0.1.
|
5
|
-
dotenv (~> 2.1)
|
4
|
+
wettr (0.1.3)
|
6
5
|
httparty (~> 0.18.1)
|
7
6
|
|
8
7
|
GEM
|
@@ -10,7 +9,6 @@ GEM
|
|
10
9
|
specs:
|
11
10
|
coderay (1.1.3)
|
12
11
|
diff-lcs (1.4.4)
|
13
|
-
dotenv (2.7.6)
|
14
12
|
httparty (0.18.1)
|
15
13
|
mime-types (~> 3.0)
|
16
14
|
multi_xml (>= 0.5.2)
|
data/README.md
CHANGED
@@ -8,9 +8,17 @@ wettr can get current weather data using either a zip/postal code or an IP addre
|
|
8
8
|
|
9
9
|
$ gem install wettr
|
10
10
|
|
11
|
+
wettr also requires an API key for OpenWeatherMap's Current Weather API to be located in ~/.wettr.yml.
|
12
|
+
To get a key sign up for an account on [their website](https://home.openweathermap.org/users/sign_up).
|
13
|
+
Once you have a key, create the `.wettr.yml` file in your home directory.
|
14
|
+
Add the following line to the file:
|
15
|
+
```yaml
|
16
|
+
API_KEY: <YOUR_API_KEY_HERE>
|
17
|
+
```
|
18
|
+
|
11
19
|
## Usage
|
12
20
|
|
13
|
-
wettr does not need to be invoked with any parameters to work. Simply type `wettr` and you will get current weather information based on your public IP address.
|
21
|
+
Once installed, wettr does not need to be invoked with any parameters to work. Simply type `wettr` and you will get current weather information based on your public IP address.
|
14
22
|
Below are some examples of the way wettr can be used:
|
15
23
|
```bash
|
16
24
|
wettr
|
@@ -29,15 +37,6 @@ After checking out the repo, run `bin/setup` to install dependencies. Then, run
|
|
29
37
|
|
30
38
|
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).
|
31
39
|
|
32
|
-
wettr requires an API key for OpenWeatherMap's Current Weather API.
|
33
|
-
To get a key sign up for an account on [their website](https://home.openweathermap.org/users/sign_up).
|
34
|
-
Once you have a key, create a `.env` file in the project's root directory.
|
35
|
-
Add the following line to the `.env` file:
|
36
|
-
|
37
|
-
```bash
|
38
|
-
API_KEY=<YOUR_API_KEY_HERE>
|
39
|
-
```
|
40
|
-
|
41
40
|
## Contributing
|
42
41
|
|
43
42
|
Bug reports and pull requests are welcome on GitHub at https://github.com/JWDonovan/wettr. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/JWDonovan/wettr/blob/master/CODE_OF_CONDUCT.md).
|
data/exe/wettr
CHANGED
data/lib/wettr.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
|
-
require "dotenv/load"
|
2
|
-
Dotenv.require_keys("API_KEY")
|
3
1
|
require "httparty"
|
2
|
+
require "yaml"
|
4
3
|
|
5
4
|
module Wettr
|
6
5
|
class Error < StandardError; end
|
7
6
|
end
|
8
7
|
|
8
|
+
require_relative "./wettr/config"
|
9
9
|
require_relative "./wettr/version"
|
10
10
|
require_relative "./wettr/cli"
|
11
11
|
require_relative "./wettr/weather"
|
data/lib/wettr/config.rb
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
class Wettr::Config
|
2
|
+
@@API_KEY = nil
|
3
|
+
@@config_hash = {}
|
4
|
+
|
5
|
+
def self.start
|
6
|
+
self.read_config_file
|
7
|
+
self.set_api_key
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.API_KEY
|
11
|
+
@@API_KEY
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def self.set_api_key
|
17
|
+
if @@config_hash["API_KEY"]
|
18
|
+
@@API_KEY = @@config_hash["API_KEY"]
|
19
|
+
else
|
20
|
+
puts "Cannot find API_KEY in .wettr.yml"
|
21
|
+
puts "An OpenWeatherMap Current Weather API key is required to use wettr"
|
22
|
+
puts "Create an account here to sign up for a key: https://home.openweathermap.org/users/sign_up"
|
23
|
+
puts "See https://github.com/JWDonovan/wettr for more info"
|
24
|
+
exit
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.read_config_file
|
29
|
+
begin
|
30
|
+
@@config_hash = YAML.load(File.read(ENV["HOME"] + "/.wettr.yml")) || {}
|
31
|
+
rescue Errno::ENOENT => exception
|
32
|
+
puts "Cannot find the wettr config file"
|
33
|
+
puts "Please create a .wettr.yml config file in your home directory in order to use wettr"
|
34
|
+
puts "See https://github.com/JWDonovan/wettr for more info"
|
35
|
+
exit
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
data/lib/wettr/ip_api.rb
CHANGED
data/lib/wettr/version.rb
CHANGED
data/lib/wettr/weather_api.rb
CHANGED
@@ -1,9 +1,7 @@
|
|
1
1
|
class Wettr::WeatherAPI
|
2
2
|
include HTTParty
|
3
|
-
# debug_output STDOUT
|
4
3
|
|
5
4
|
base_uri "https://api.openweathermap.org"
|
6
|
-
default_params appid: ENV["API_KEY"], units: "imperial"
|
7
5
|
|
8
6
|
def self.call_with_lat_and_lon(lat:, lon:)
|
9
7
|
@options = { query: { lat: lat, lon: lon } }
|
@@ -18,7 +16,17 @@ class Wettr::WeatherAPI
|
|
18
16
|
private
|
19
17
|
|
20
18
|
def self.call
|
19
|
+
default_params appid: Wettr::Config.API_KEY, units: "imperial"
|
20
|
+
|
21
21
|
response = self.get("/data/2.5/weather", @options)
|
22
|
+
|
23
|
+
if response["cod"] != 200
|
24
|
+
puts "Encountered an error contacting OpenWeatherMap"
|
25
|
+
puts "Returned the following response: #{ response['cod'] }"
|
26
|
+
puts "Message: #{ response['message'] }"
|
27
|
+
exit
|
28
|
+
end
|
29
|
+
|
22
30
|
response
|
23
31
|
end
|
24
32
|
end
|
data/wettr.gemspec
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
lib = File.expand_path("lib", __dir__)
|
2
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
1
|
require_relative "lib/wettr/version"
|
4
2
|
|
5
3
|
Gem::Specification.new do |spec|
|
@@ -23,13 +21,11 @@ Gem::Specification.new do |spec|
|
|
23
21
|
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
24
22
|
end
|
25
23
|
|
26
|
-
spec.files << ".env"
|
27
24
|
spec.bindir = "exe"
|
28
25
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
29
26
|
spec.executables << "wettr"
|
30
27
|
spec.require_paths = ["lib"]
|
31
28
|
|
32
|
-
spec.add_dependency "dotenv", "~> 2.1"
|
33
29
|
spec.add_dependency "httparty", "~> 0.18.1"
|
34
30
|
|
35
31
|
spec.add_development_dependency "rake", "~> 13.0"
|
metadata
CHANGED
@@ -1,29 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wettr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- JWDonovan
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-12-
|
11
|
+
date: 2020-12-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: dotenv
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - "~>"
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '2.1'
|
20
|
-
type: :runtime
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - "~>"
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '2.1'
|
27
13
|
- !ruby/object:Gem::Dependency
|
28
14
|
name: httparty
|
29
15
|
requirement: !ruby/object:Gem::Requirement
|
@@ -88,8 +74,6 @@ executables:
|
|
88
74
|
extensions: []
|
89
75
|
extra_rdoc_files: []
|
90
76
|
files:
|
91
|
-
- ".env"
|
92
|
-
- ".env.production"
|
93
77
|
- ".gitignore"
|
94
78
|
- ".rspec"
|
95
79
|
- ".travis.yml"
|
@@ -106,6 +90,7 @@ files:
|
|
106
90
|
- exe/wettr
|
107
91
|
- lib/wettr.rb
|
108
92
|
- lib/wettr/cli.rb
|
93
|
+
- lib/wettr/config.rb
|
109
94
|
- lib/wettr/ip.rb
|
110
95
|
- lib/wettr/ip_api.rb
|
111
96
|
- lib/wettr/version.rb
|
data/.env.production
DELETED
File without changes
|