meteorologist 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/lib/meteorologist.rb +43 -0
  3. metadata +44 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: fdc9287bd908e81f0bf5fcc5b216c90e43f1b326
4
+ data.tar.gz: 10a993574f9a18d5393207fcc25a9bc5053ede1a
5
+ SHA512:
6
+ metadata.gz: 4f47dda6f63c8bb7ebc07bd13d8d412f7cd11f107264765c389a994914746a4b2dc5f0cb147743b5ed324a1895a31161084a0822841b0623251ad8a43c824968
7
+ data.tar.gz: 1961e140c85b91708950abe9e93f533b8e636a69cdd1b020dacacf56d3237fa698a00b1f58a3db67a6ee9abd3a021384cc1f8adcbe4dca0f78003862d4c44d1a
@@ -0,0 +1,43 @@
1
+ Dir.glob("./lib/meteorologist/*.rb") { |f| require f }
2
+
3
+ class Meteorologist
4
+ def initialize(location, options = {})
5
+ validate_environment
6
+
7
+ @location = location
8
+ #todo allow forecast at a given time
9
+ #@time = options.fetch(:forecast_time) { Time.now }
10
+ @forecaster_class = options.fetch(:forecaster) { Forecaster }
11
+ @navigator_class = options.fetch(:navigator) { Navigator }
12
+ @units = options.fetch(:units) { 'si' }
13
+ end
14
+
15
+ def forecast
16
+ @forecast ||= @forecaster_class.new(coordinates, units)
17
+ end
18
+
19
+ def moon
20
+ #todo add moon_info service from tarot_backend
21
+ end
22
+
23
+ def location_name
24
+ navigator.location_name
25
+ end
26
+
27
+ private
28
+ attr_reader :location, :units
29
+
30
+ def coordinates
31
+ navigator.coordinates
32
+ end
33
+
34
+ def navigator
35
+ @navigator ||= @navigator_class.new(location)
36
+ end
37
+
38
+ def validate_environment
39
+ p "WARNING: You have not set a cache path" unless ENV['CACHE_PATH']
40
+ raise RuntimeError, "You must set a Darksky API secret" unless ENV['DARKSKYSECRET']
41
+ raise RuntimeError, "You must set a Google API secret" unless ENV['GOOGLEMAPSECRET']
42
+ end
43
+ end
metadata ADDED
@@ -0,0 +1,44 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: meteorologist
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Dax
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-02-18 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Get the weather for a place and time
14
+ email: d.dax@email.com
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - lib/meteorologist.rb
20
+ homepage: http://rubygems.org/gems/meteorologist
21
+ licenses:
22
+ - CC-BY-NC-SA-4.0
23
+ metadata: {}
24
+ post_install_message:
25
+ rdoc_options: []
26
+ require_paths:
27
+ - lib
28
+ required_ruby_version: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ required_rubygems_version: !ruby/object:Gem::Requirement
34
+ requirements:
35
+ - - ">="
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ requirements: []
39
+ rubyforge_project:
40
+ rubygems_version: 2.5.1
41
+ signing_key:
42
+ specification_version: 4
43
+ summary: Get the weather for a place and time
44
+ test_files: []