namaz 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +64 -17
- data/lib/namaz.rb +57 -3
- data/lib/namaz/version.rb +1 -1
- data/namaz.gemspec +1 -1
- metadata +4 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7b39bf28d699c1998b865cd87b3e6d3c4ea67ba2
|
4
|
+
data.tar.gz: f3a4f0a38adfbf56479dbd898bd0b5d5cbe6ceba
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fdb13b1901f4cd8c936d5be1b9db383e1b3a6695ec3d568bfd03f10c4f6bfc9b271450be33417a1a89a0aa15443e8579c46b96a981540b1105f0ec33ceb0cdc6
|
7
|
+
data.tar.gz: b1283a5803549a5ab9003326134f6d9035b6bedc6eceb859ce1b56a5d01184319c0fd8341a74a43fc70df9186fa19fda9cffc7a5530d55fa28c47e0834fdfbed
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Namaz
|
2
|
-
[namaz](https://aladhan.com/prayer-times-api) API wrapper
|
3
|
-
Namaz is aladhan.com wrapper in ruby to use REST API that is open for public use.
|
2
|
+
[namaz](https://aladhan.com/prayer-times-api) ruby gem is an API wrapper.
|
3
|
+
Namaz is aladhan.com wrapper in ruby to use REST API that is open for public use.
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
@@ -30,6 +30,7 @@ Make sure you require the library, where you want to use it, Or require in `appl
|
|
30
30
|
```ruby
|
31
31
|
require 'namaz'
|
32
32
|
```
|
33
|
+
## Timings
|
33
34
|
|
34
35
|
You can then make requests to the following method.
|
35
36
|
```ruby
|
@@ -40,33 +41,81 @@ Namaz.timings_by_city(city:, country:, method:, options: {})
|
|
40
41
|
```
|
41
42
|
|
42
43
|
### Examples:
|
43
|
-
```ruby
|
44
|
-
# Using Altitudes:
|
45
|
-
Namaz.timings(latitude: 31.5546, longitude: 74.3572, timezonestring: "Asia/Karachi", method: 1, options: {timestamp: Time.now.to_i})
|
46
|
-
# Using City and Country Information:
|
47
|
-
Namaz.timings_by_city(city: 'Karachi', country: 'PK', method: 1, options: {timestamp: Time.now.to_i})
|
48
|
-
```
|
49
44
|
|
50
|
-
##### Example Request Using Altitudes
|
45
|
+
##### Example Request and response Using Altitudes
|
51
46
|
|
52
47
|
```ruby
|
53
48
|
timings = Namaz.timings(latitude: 31.5546, longitude: 74.3572, timezonestring: "Asia/Karachi", method: 1, options: {timestamp: Time.now.to_i})
|
49
|
+
|
50
|
+
#=> #<Hashie::Mash Asr="15:27" Dhuhr="12:16" Fajr="05:19" Imsak="05:09" Isha="19:14" Maghrib="17:53" Midnight="00:17" Sunrise="06:41" Sunset="17:53">
|
51
|
+
|
52
|
+
timings.Fajr
|
53
|
+
#=> "05:19"
|
54
54
|
```
|
55
55
|
##### Example Request Using Country and City Information
|
56
56
|
|
57
57
|
```ruby
|
58
58
|
timings = Namaz.timings_by_city(city: 'Karachi', country: 'PK', method: 1, options: {state: 'Punjab', timestamp: Time.now.to_i})
|
59
|
+
|
60
|
+
#<Hashie::Mash Asr="15:27" Dhuhr="12:16" Fajr="05:19" Imsak="05:09" Isha="19:14" Maghrib="17:53" Midnight="00:17" Sunrise="06:41" Sunset="17:53">
|
61
|
+
|
62
|
+
timings.Fajr
|
63
|
+
#=> "05:19"
|
59
64
|
```
|
60
|
-
|
65
|
+
|
66
|
+
## Calender
|
61
67
|
|
62
68
|
```ruby
|
63
|
-
|
69
|
+
## Using City and Country Information:
|
70
|
+
Namaz.calender_by_city(city:, country:, method:, options: {})
|
71
|
+
## Using City and Country Information:
|
72
|
+
Namaz.calendar(latitude:, longitude:, timezonestring:, method:, options: {})
|
73
|
+
```
|
64
74
|
|
65
|
-
|
66
|
-
|
75
|
+
#### Optional Params
|
76
|
+
`(options: {month: '8', year: '2017', state: 'Punjab' })`
|
77
|
+
- **month** - 1 or 2 digit month. Example: '08' or '8' for August, **DEFAULT is current month**, if not given
|
78
|
+
- **year** - 4 digit year. Example: 2017, **DEFAULT is current year**, if not given
|
79
|
+
|
80
|
+
|
81
|
+
### Examples:
|
82
|
+
|
83
|
+
##### Example Request and response Using Altitudes
|
84
|
+
```ruby
|
85
|
+
calendar = Namaz.calendar(latitude: 31.5546, longitude: 74.3572, timezonestring: "Asia/Karachi", method: 1, options: {month: '02', year: '2017'})
|
86
|
+
|
87
|
+
calendar.first
|
88
|
+
#<Hashie::Mash date=#<Hashie::Mash readable="01 Feb 2017" timestamp="1485921661"> timings=#<Hashie::Mash Asr="15:15 (PKT)" Dhuhr="12:16 (PKT)" Fajr="05:32 (PKT)" Imsak="05:22 (PKT)" Isha="19:00 (PKT)" Maghrib="17:37 (PKT)" Midnight="00:16 (PKT)" Sunrise="06:55 (PKT)" Sunset="17:37 (PKT)">>
|
89
|
+
|
90
|
+
calendar.first.timings
|
91
|
+
#=> #<Hashie::Mash Asr="15:15 (PKT)" Dhuhr="12:16 (PKT)" Fajr="05:32 (PKT)" Imsak="05:22 (PKT)" Isha="19:00 (PKT)" Maghrib="17:37 (PKT)" Midnight="00:16 (PKT)" Sunrise="06:55 (PKT)" Sunset="17:37 (PKT)">
|
92
|
+
|
93
|
+
calendar.first.timings.Asr
|
94
|
+
#=> "15:15 (PKT)"
|
95
|
+
|
96
|
+
calendar.first.date
|
97
|
+
#<Hashie::Mash readable="01 Feb 2017" timestamp="1485921661">
|
98
|
+
```
|
99
|
+
|
100
|
+
##### Example Request Using Country and City Information
|
101
|
+
|
102
|
+
```ruby
|
103
|
+
calendar = Namaz.calender_by_city(city: 'Lahore', country: 'PK', method: 2, options: {month: '03', year: '2017'})
|
104
|
+
|
105
|
+
calendar.first
|
106
|
+
#<Hashie::Mash date=#<Hashie::Mash readable="01 Feb 2017" timestamp="1485921661"> timings=#<Hashie::Mash Asr="15:54 (PKT)" Dhuhr="12:46 (PKT)" Fajr="05:56 (PKT)" Imsak="05:46 (PKT)" Isha="19:35 (PKT)" Maghrib="18:17 (PKT)" Midnight="00:46 (PKT)" Sunrise="07:14 (PKT)" Sunset="18:17 (PKT)">>
|
107
|
+
|
108
|
+
calendar.first.timings
|
109
|
+
#=> #<Hashie::Mash Asr="15:31 (PKT)" Dhuhr="12:15 (PKT)" Fajr="05:23 (PKT)" Imsak="05:13 (PKT)" Isha="19:07 (PKT)" Maghrib="18:01 (PKT)" Midnight="00:15 (PKT)" Sunrise="06:30 (PKT)" Sunset="18:01 (PKT)">
|
110
|
+
|
111
|
+
calendar.first.timings.Asr
|
112
|
+
#=> "15:31 (PKT)"
|
113
|
+
|
114
|
+
calendar.first.date
|
115
|
+
#<Hashie::Mash readable="01 Feb 2017" timestamp="1485921661">
|
67
116
|
```
|
68
117
|
|
69
|
-
|
118
|
+
## General Parameters Description
|
70
119
|
* **timestamp OPTIONAL** - `DEFAULT = Time.now.to_i` a UNIX timestamp (from any time of the day) of the day for which you want the timings. If you don't specify a timestamp, the result will come back for today - today being the date in the Europe/London timezone.
|
71
120
|
|
72
121
|
* **latitude** - the decimal value for the latitude co-ordinate of the location you want the time computed for. Example: 51.75865125
|
@@ -118,15 +167,13 @@ end
|
|
118
167
|
* **0.1.1:** Added new request Using Country and City Information
|
119
168
|
* **0.1.2:** Updated method name for Timings information for city from `timings` to `timings_by_city`
|
120
169
|
|
121
|
-
|
170
|
+
## TODO:
|
122
171
|
Follow the link https://aladhan.com/prayer-times-api and add patch by creating a Pull Rquest, I will merge and publish new version
|
123
172
|
|
124
|
-
* Calendar
|
125
173
|
* Current Time Stamp
|
126
174
|
* Current Time
|
127
175
|
* City Geolocation Info
|
128
176
|
* Address Geolocation Info
|
129
|
-
* Calendar by City
|
130
177
|
* Timings by Address
|
131
178
|
* Calendar by Address
|
132
179
|
|
data/lib/namaz.rb
CHANGED
@@ -26,7 +26,7 @@ module Namaz
|
|
26
26
|
method: method
|
27
27
|
}
|
28
28
|
|
29
|
-
|
29
|
+
namaz_time_response(namaz_url, params)
|
30
30
|
end
|
31
31
|
|
32
32
|
# Retrieve the namaz timings for a given city, country, method.
|
@@ -47,9 +47,57 @@ module Namaz
|
|
47
47
|
method: method
|
48
48
|
}
|
49
49
|
|
50
|
-
|
50
|
+
namaz_time_response(namaz_url, params)
|
51
51
|
end
|
52
52
|
|
53
|
+
# Retrieve the namaz timings for a given latitude, longitude, timezonestring and method.
|
54
|
+
#
|
55
|
+
# @param [Float] latitude.
|
56
|
+
# @param [Float] longitude.
|
57
|
+
# @param [String] timezonestring
|
58
|
+
# @param [Integer] method
|
59
|
+
# @param [Hash] options, year, month, and state are OPTIONAL
|
60
|
+
# year is default to current year, and month is default to current month if not sent in OPTIONAL params
|
61
|
+
def calendar(latitude:, longitude:, timezonestring:, method:, options: {})
|
62
|
+
namaz_url = [DEFAULT_API_URL, 'calendar'].join('/')
|
63
|
+
|
64
|
+
params = {
|
65
|
+
latitude: latitude,
|
66
|
+
longitude: longitude,
|
67
|
+
timezonestring: timezonestring,
|
68
|
+
month: options[:month],
|
69
|
+
year: options[:year],
|
70
|
+
method: method
|
71
|
+
}
|
72
|
+
|
73
|
+
namaz_calender_response(namaz_url, params)
|
74
|
+
end
|
75
|
+
|
76
|
+
|
77
|
+
# Retrieve the calender for a given city, country, method.
|
78
|
+
# By default Retrieve current year, month
|
79
|
+
#
|
80
|
+
# @param [String] city
|
81
|
+
# @param [String] country
|
82
|
+
# @param [Integer] method
|
83
|
+
# @param [Hash] options, year, month, and state are OPTIONAL
|
84
|
+
# year is default to current year, and month is default to current month if not sent in OPTIONAL params
|
85
|
+
def calendar_by_city(city:, country:, method:, options: {})
|
86
|
+
namaz_url = [DEFAULT_API_URL, 'calendarByCity'].join('/')
|
87
|
+
|
88
|
+
params = {
|
89
|
+
city: city,
|
90
|
+
country: country,
|
91
|
+
month: options[:month],
|
92
|
+
year: options[:year],
|
93
|
+
state: options[:state],
|
94
|
+
method: method
|
95
|
+
}
|
96
|
+
|
97
|
+
namaz_calender_response(namaz_url, params)
|
98
|
+
end
|
99
|
+
|
100
|
+
|
53
101
|
# Build or get an HTTP connection object.
|
54
102
|
def connection
|
55
103
|
@connection ||= Faraday.new
|
@@ -68,9 +116,15 @@ module Namaz
|
|
68
116
|
connection.get(path, params)
|
69
117
|
end
|
70
118
|
|
71
|
-
def
|
119
|
+
def namaz_time_response(namaz_url, params)
|
72
120
|
response = connection.get(namaz_url, params)
|
73
121
|
return Hashie::Mash.new(MultiJson.load(response.body)).data.timings if response.success?
|
74
122
|
end
|
123
|
+
|
124
|
+
def namaz_calender_response(namaz_url, params)
|
125
|
+
response = connection.get(namaz_url, params)
|
126
|
+
return Hashie::Mash.new(MultiJson.load(response.body)).data if response.success?
|
127
|
+
end
|
128
|
+
|
75
129
|
end
|
76
130
|
end
|
data/lib/namaz/version.rb
CHANGED
data/namaz.gemspec
CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
|
|
10
10
|
spec.email = ["sohair1991@gmail.com"]
|
11
11
|
|
12
12
|
spec.summary = %q{Returns all prayer times for a specific date}
|
13
|
-
spec.description = %q{Namaz is AlAdhan.com wrapper in ruby to use REST API that is open for public use.
|
13
|
+
spec.description = %q{Namaz gem is AlAdhan.com wrapper in ruby to use REST API that is open for public use.}
|
14
14
|
spec.homepage = "https://github.com/Sohair63/namaz"
|
15
15
|
spec.license = "MIT"
|
16
16
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: namaz
|
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
|
- Sohair Ahmad
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-02-
|
11
|
+
date: 2017-02-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -108,9 +108,8 @@ dependencies:
|
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '3.0'
|
111
|
-
description: Namaz is AlAdhan.com wrapper in ruby to use REST API that is open
|
112
|
-
public use.
|
113
|
-
includes Timings only
|
111
|
+
description: Namaz gem is AlAdhan.com wrapper in ruby to use REST API that is open
|
112
|
+
for public use.
|
114
113
|
email:
|
115
114
|
- sohair1991@gmail.com
|
116
115
|
executables: []
|