ArseniysWeatherApp 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +21 -0
- data/LICENSE.txt +21 -0
- data/README.md +39 -0
- data/lib/ArseniysWeatherApp.rb +48 -0
- data/lib/ArseniysWeatherApp/version.rb +5 -0
- metadata +66 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 3cbf1f318dd5763110dce0a345e139c73827192731bb3087a8648c16c640301f
|
4
|
+
data.tar.gz: 90781055cf6d34a5231c83113df7436f7bdd9ae1fc68db2b395ca7d45f28a728
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 37d1d54eb12765488ab4116d3e07dc7843383e73939de3d62453da17280c9f7e04be8f42180a794b1187cdbae9d349718e7440e2ed8938a9febb2a8de5fcc945
|
7
|
+
data.tar.gz: 1f55cd0187d370d47b8d3dd2e5ea581e1faf9395033e32dee1365728b4ede3168cc8599820798982359e946cfdb26b93112440a1f8ea478673db9333c61a6ad4
|
data/.gitignore
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
/.bundle/
|
2
|
+
/.yardoc
|
3
|
+
/_yardoc/
|
4
|
+
/coverage/
|
5
|
+
/doc/
|
6
|
+
/pkg/
|
7
|
+
/spec/reports/
|
8
|
+
/tmp/
|
9
|
+
/spec/
|
10
|
+
/bin/
|
11
|
+
/.idea/
|
12
|
+
|
13
|
+
# rspec failure tracking
|
14
|
+
.rspec_status
|
15
|
+
.rspec
|
16
|
+
.rubocop.yml
|
17
|
+
.ruby-version
|
18
|
+
ArseniysWeatherApp.gemspec
|
19
|
+
Gemfile
|
20
|
+
Gemfile.lock
|
21
|
+
Rakefile
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2021 Arseniy Chirkov
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# ArseniysWeatherApp
|
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/ArseniysWeatherApp`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'ArseniysWeatherApp'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle install
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install ArseniysWeatherApp
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
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.
|
30
|
+
|
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 the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/ArseniysWeatherApp.
|
36
|
+
|
37
|
+
## License
|
38
|
+
|
39
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "ArseniysWeatherApp/version"
|
4
|
+
require "faraday"
|
5
|
+
require "json"
|
6
|
+
|
7
|
+
module ArseniysWeatherApp
|
8
|
+
class Error < StandardError; end
|
9
|
+
|
10
|
+
def self.attach_yandex_api
|
11
|
+
url = "https://obscure-temple-73986.herokuapp.com/"
|
12
|
+
response = Faraday.get(url, { "weather" => "yes" })
|
13
|
+
@yandex_api = JSON.parse(response.body)["message"]
|
14
|
+
end
|
15
|
+
|
16
|
+
|
17
|
+
|
18
|
+
def self.spb_weather
|
19
|
+
str = weather_json(location: [60, 30])
|
20
|
+
puts("Today's night average temperature: #{str["forecasts"][0]["parts"]["night"]["temp_avg"]}C")
|
21
|
+
puts("Today's morning average temperature: #{str["forecasts"][0]["parts"]["morning"]["temp_avg"]}C")
|
22
|
+
puts("Today's day average temperature: #{str["forecasts"][0]["parts"]["day"]["temp_avg"]}C")
|
23
|
+
puts("Today's evening average temperature: #{str["forecasts"][0]["parts"]["evening"]["temp_avg"]}C")
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.weather_json(location: [59.9573887, 30.3430287],
|
27
|
+
lang: "ru_RU",
|
28
|
+
forecasts: 7,
|
29
|
+
hours: false,
|
30
|
+
extra: false)
|
31
|
+
url = "https://api.weather.yandex.ru/v2/forecast"
|
32
|
+
params = { "lat" => location[0],
|
33
|
+
"lon" => location[1],
|
34
|
+
"lang" => lang,
|
35
|
+
"limit" => forecasts,
|
36
|
+
"hours" => hours,
|
37
|
+
"extra" => extra }
|
38
|
+
header = { "X-Yandex-API-Key" => @yandex_api }
|
39
|
+
response = Faraday.get(url, params, header)
|
40
|
+
JSON.parse(response.body)
|
41
|
+
end
|
42
|
+
|
43
|
+
# f = File.new("WeatherForecast.json", "w")
|
44
|
+
# f.write(parse.to_json)
|
45
|
+
# f.close
|
46
|
+
# str = JSON.parse(File.read("WeatherForecast.json"))
|
47
|
+
|
48
|
+
end
|
metadata
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ArseniysWeatherApp
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Arseniy Chirkov
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2021-08-11 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: faraday
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.7'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.7'
|
27
|
+
description: |-
|
28
|
+
This gem is searches your location and based on your location
|
29
|
+
tells you what weather is right now
|
30
|
+
email:
|
31
|
+
- supernich19@gmail.com
|
32
|
+
executables: []
|
33
|
+
extensions: []
|
34
|
+
extra_rdoc_files: []
|
35
|
+
files:
|
36
|
+
- ".gitignore"
|
37
|
+
- LICENSE.txt
|
38
|
+
- README.md
|
39
|
+
- lib/ArseniysWeatherApp.rb
|
40
|
+
- lib/ArseniysWeatherApp/version.rb
|
41
|
+
homepage: https://github.com/Supernich/ArseniysWeatherApp
|
42
|
+
licenses:
|
43
|
+
- MIT
|
44
|
+
metadata:
|
45
|
+
homepage_uri: https://github.com/Supernich/ArseniysWeatherApp
|
46
|
+
source_code_uri: https://github.com/Supernich/ArseniysWeatherApp
|
47
|
+
post_install_message:
|
48
|
+
rdoc_options: []
|
49
|
+
require_paths:
|
50
|
+
- lib
|
51
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: 2.5.0
|
56
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '0'
|
61
|
+
requirements: []
|
62
|
+
rubygems_version: 3.2.3
|
63
|
+
signing_key:
|
64
|
+
specification_version: 4
|
65
|
+
summary: Gem to tell what the weather is now
|
66
|
+
test_files: []
|