whenissunrise 0.0.1 → 0.0.2

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/whenissunrise.rb +41 -2
  3. metadata +18 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d09bb4f4ca0b13d3d8950b53c68b391fa789a753
4
- data.tar.gz: c5b3cf644b17c4cc5c609a82697438ec9c595c43
3
+ metadata.gz: eb0bde437f3bce748b1c648b8b6c6a1e0ff53675
4
+ data.tar.gz: 3e484eb11d558c438f094f006629814d1822ba60
5
5
  SHA512:
6
- metadata.gz: 96973ecda83e4142555cafec80d8041c119f7061416c10d4f1d2b5ad80935f4916fb91d205642a303f98c936fcd8d72bd8dabd636b0ef8968bb1089848ab5f63
7
- data.tar.gz: 219e12596b12f1eb6d4a66ae4fed7efdf4ac72630ef90e62f10dc70b0fdebb08a2c2bf4c53c035fa2361567f2059420068393b92533b9ac478e6a8ce0e54939f
6
+ metadata.gz: 98749bd4670a68a98e0a4e6f2d2d771f8be05b5846add182161f5222f613ae5685b732c120a87c47967d84603f33d7ba05495f8e42b9963fe7635d692f2e76ab
7
+ data.tar.gz: a82f7bef9b3d186e03e9b93c24115e2d1a98821fc6fa444ffed7a50a40a54f69a35932b688e2f499ea96e8a3dc9150a57ebe60e69186aab7aa102d4e1a97b0c6
data/lib/whenissunrise.rb CHANGED
@@ -1,5 +1,44 @@
1
+ # created by Adrian Corcoran - 12/08/2018
2
+ # retrieves the sunrise and sunset times using latitude and longitude
3
+ # service provided by https://sunrise-sunset.org/api
4
+
5
+ require 'httparty'
6
+ require 'json'
7
+
1
8
  class Whenissunrise
2
- def self.hi
3
- puts "Hello Adrian!"
9
+
10
+ def self.sunrise
11
+ puts "-----"
12
+ puts "Time to find out your sunrise!"
13
+ puts "-----"
14
+ puts "You will need a latitude and longitude, which you can get by going to https://maps.google.com and selecting 'What's here?' after right-clicking on the map. If you're really lazy you can use 45.249814 and -75.7700702 for Ottawa or 53.2839064 and -9.0837658 for Galway :)"
15
+ puts "-----"
16
+
17
+ # get data from user
18
+ puts "Enter your latitude"
19
+ lat = gets.chomp
20
+ puts "Enter your longitude"
21
+ long = gets.chomp
22
+
23
+ puts "getting data..."
24
+
25
+ url = "https://api.sunrise-sunset.org"
26
+ date = "today"
27
+
28
+ # do the api call
29
+ data = HTTParty.get("#{url}/json?lat=#{lat}&lng=#{long}&date=#{date}")
30
+
31
+ # format the data
32
+ dataHash = JSON[data.body]['results']
33
+ sunrise = dataHash['sunrise']
34
+ sunset = dataHash['sunset']
35
+
36
+ # display the data
37
+ puts "Sunrise is at #{sunrise}"
38
+ puts "Sunset is at #{sunset}"
39
+
40
+ puts "-----"
41
+ puts "Thank you to https://sunrise-sunset.org for providing the data :)"
4
42
  end
43
+
5
44
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: whenissunrise
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adrian Corcoran
@@ -9,8 +9,23 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
  date: 2018-08-12 00:00:00.000000000 Z
12
- dependencies: []
13
- description: A simple gem to get the local sunrise time using the machines clock
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: httparty
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.16.2
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.16.2
27
+ description: A simple gem to get the local sunrise and sunset time using inputted
28
+ latitude and longitude
14
29
  email: adrian.corcoran@shopify.com
15
30
  executables: []
16
31
  extensions: []