prayer_time 1.0.1 → 2.0.0
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/README.md +8 -5
- data/lib/prayer_time.rb +5 -2
- data/lib/prayer_time/request.rb +72 -42
- data/lib/prayer_time/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f3d7b39ebc37bc8cccf26c2b73adc9db6ca82c2b
|
4
|
+
data.tar.gz: 4be8afb4b7376fe2815133da624fce43e747473f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 21eef9d4f3620a9dc5f42060ce7c1b7d15b53ab726e5d22eb9d6c71fefe9fd4d23e055df20d026b32b16a91840994849ff6d4d28c640df89d701cb67526cc14b
|
7
|
+
data.tar.gz: ef6dc8092f03b4f08d360d37a0f845fa1ff5a14cb2fb561f50b830bd929543f1c6b2069b52c8b98e1722bdfbd0d141b87e80e6ad22521320de908653a98f7e78
|
data/README.md
CHANGED
@@ -21,6 +21,13 @@ Or install it yourself as:
|
|
21
21
|
## Usage
|
22
22
|
|
23
23
|
```ruby
|
24
|
+
PrayerTime.countries
|
25
|
+
# {"2"=>"TURKIYE",
|
26
|
+
# "33"=>"ABD",
|
27
|
+
# "166"=>"AFGANISTAN",
|
28
|
+
# "13"=>"ALMANYA",
|
29
|
+
# ...
|
30
|
+
|
24
31
|
PrayerTime.cities("TURKIYE")
|
25
32
|
# => [{"Disabled"=>false, "Group"=>nil, "Selected"=>false, "Text"=>"ADANA", "Value"=>"500"},
|
26
33
|
# {"Disabled"=>false, "Group"=>nil, "Selected"=>false, "Text"=>"ADIYAMAN", "Value"=>"501"},
|
@@ -56,15 +63,11 @@ PrayerTime.times("TURKIYE", "SAMSUN", "19 MAYIS")
|
|
56
63
|
```
|
57
64
|
If the country hasn't any town, something like this:
|
58
65
|
```ruby
|
59
|
-
PrayerTime.cities("BOSNA HERSEK")
|
60
|
-
# =>{"Disabled"=>false, "Group"=>nil, "Selected"=>false, "Text"=>"SARAYBOSNA(sarajevo)", "Value"=>"12029"},
|
61
|
-
# {"Disabled"=>false, "Group"=>nil, "Selected"=>false, "Text"=>"SREBRENICA", "Value"=>"12003"},
|
62
|
-
# ...
|
63
66
|
|
64
67
|
PrayerTime.towns("BOSNA HERSEK", "SREBRENICA")
|
65
68
|
# => [ ] // hasn't any town
|
66
69
|
|
67
|
-
PrayerTime.times("BOSNA HERSEK", "SREBRENICA"
|
70
|
+
PrayerTime.times("BOSNA HERSEK", "SREBRENICA")
|
68
71
|
# => {"Imsak"=>"03:11",
|
69
72
|
# "Gunes"=>"05:18",
|
70
73
|
# "Ogle"=>"12:56",
|
data/lib/prayer_time.rb
CHANGED
@@ -2,6 +2,9 @@ require "prayer_time/version"
|
|
2
2
|
require "prayer_time/request"
|
3
3
|
|
4
4
|
module PrayerTime
|
5
|
+
def self.countries
|
6
|
+
self::COUNTRIES
|
7
|
+
end
|
5
8
|
|
6
9
|
def self.cities(country)
|
7
10
|
Request.new.get_cities(country)
|
@@ -11,7 +14,7 @@ module PrayerTime
|
|
11
14
|
Request.new.get_towns(country, city)
|
12
15
|
end
|
13
16
|
|
14
|
-
def self.times(country, city,
|
15
|
-
Request.new.pray_times(country, city,
|
17
|
+
def self.times(country, city, option = {})
|
18
|
+
Request.new.pray_times(country, city, option)
|
16
19
|
end
|
17
20
|
end
|
data/lib/prayer_time/request.rb
CHANGED
@@ -3,66 +3,96 @@ require 'json'
|
|
3
3
|
|
4
4
|
module PrayerTime
|
5
5
|
# Country names and numbers from Presidency of Religious Affairs
|
6
|
-
|
6
|
+
COUNTRIES = { '2' => 'TURKIYE', '33' => 'ABD', '166' => 'AFGANISTAN', '13' => 'ALMANYA', '17' => 'ANDORRA',
|
7
|
+
'140' => 'ANGOLA', '125' => 'ANGUILLA', '90' => 'ANTIGUA VE BARBUDA', '199' => 'ARJANTIN',
|
8
|
+
'25' => 'ARNAVUTLUK', '153' => 'ARUBA', '59' => 'AVUSTRALYA', '35' => 'AVUSTURYA', '5' => 'AZERBAYCAN',
|
9
|
+
'54' => 'BAHAMALAR', '132' => 'BAHREYN', '177' => 'BANGLADES', '188' => 'BARBADOS', '208' => 'BELARUS',
|
10
|
+
'11' => 'BELCIKA', '182' => 'BELIZE', '181' => 'BENIN', '51' => 'BERMUDA', '93' => 'BIRLESIK ARAP EMIRLIGI',
|
11
|
+
'83' => 'BOLIVYA', '9' => 'BOSNA HERSEK', '167' => 'BOTSVANA', '146' => 'BREZILYA', '97' => 'BRUNEI',
|
12
|
+
'44' => 'BULGARISTAN', '91' => 'BURKINA FASO', '154' => 'BURMA (MYANMAR)', '65' => 'BURUNDI', '155' => 'BUTAN',
|
13
|
+
'156' => 'CAD', '43' => 'CECENISTAN', '16' => 'CEK CUMHURIYETI', '86' => 'CEZAYIR', '160' => 'CIBUTI',
|
14
|
+
'61' => 'CIN', '26' => 'DANIMARKA', '180' => 'DEMOKRATIK KONGO CUMHURIYETI', '176' => 'DOGU TIMOR',
|
15
|
+
'123' => 'DOMINIK', '72' => 'DOMINIK CUMHURIYETI', '139' => 'EKVATOR', '63' => 'EKVATOR GINESI',
|
16
|
+
'165' => 'EL SALVADOR', '117' => 'ENDONEZYA', '175' => 'ERITRE', '104' => 'ERMENISTAN', '6' => 'ESTONYA',
|
17
|
+
'95' => 'ETYOPYA', '145' => 'FAS', '197' => 'FIJI', '120' => 'FILDISI SAHILI', '126' => 'FILIPINLER',
|
18
|
+
'204' => 'FILISTIN', '41' => 'FINLANDIYA', '21' => 'FRANSA', '79' => 'GABON', '109' => 'GAMBIYA',
|
19
|
+
'143' => 'GANA', '111' => 'GINE', '58' => 'GRANADA', '48' => 'GRONLAND', '171' => 'GUADELOPE',
|
20
|
+
'169' => 'GUAM ADASI', '99' => 'GUATEMALA', '67' => 'GUNEY AFRIKA', '128' => 'GUNEY KORE', '62' => 'GURCISTAN',
|
21
|
+
'82' => 'GUYANA', '70' => 'HAITI', '187' => 'HINDISTAN', '30' => 'HIRVATISTAN', '4' => 'HOLLANDA',
|
22
|
+
'66' => 'HOLLANDA ANTILLERI', '105' => 'HONDURAS', '113' => 'HONG KONG', '15' => 'INGILTERE', '124' => 'IRAK',
|
23
|
+
'202' => 'IRAN', '32' => 'IRLANDA', '23' => 'ISPANYA', '205' => 'ISRAIL', '12' => 'ISVEC', '49' => 'ISVICRE',
|
24
|
+
'8' => 'ITALYA', '122' => 'IZLANDA', '119' => 'JAMAIKA', '116' => 'JAPONYA', '161' => 'KAMBOCYA',
|
25
|
+
'184' => 'KAMERUN', '52' => 'KANADA', '34' => 'KARADAG', '94' => 'KATAR', '92' => 'KAZAKISTAN', '114' => 'KENYA',
|
26
|
+
'168' => 'KIRGIZISTAN', '57' => 'KOLOMBIYA', '88' => 'KOMORLAR', '18' => 'KOSOVA', '162' => 'KOSTARIKA',
|
27
|
+
'209' => 'KUBA', '206' => 'KUDUS', '133' => 'KUVEYT', '1' => 'KUZEY KIBRIS', '142' => 'KUZEY KORE',
|
28
|
+
'134' => 'LAOS', '174' => 'LESOTO', '20' => 'LETONYA', '73' => 'LIBERYA', '203' => 'LIBYA',
|
29
|
+
'38' => 'LIECHTENSTEIN', '47' => 'LITVANYA', '42' => 'LUBNAN', '31' => 'LUKSEMBURG', '7' => 'MACARISTAN',
|
30
|
+
'98' => 'MADAGASKAR', '100' => 'MAKAO', '28' => 'MAKEDONYA', '55' => 'MALAVI', '103' => 'MALDIVLER',
|
31
|
+
'107' => 'MALEZYA', '152' => 'MALI', '24' => 'MALTA', '87' => 'MARTINIK', '164' => 'MAURITIUS ADASI',
|
32
|
+
'157' => 'MAYOTTE', '53' => 'MEKSIKA', '85' => 'MIKRONEZYA', '189' => 'MISIR', '60' => 'MOGOLISTAN',
|
33
|
+
'46' => 'MOLDAVYA', '3' => 'MONAKO', '147' => 'MONTSERRAT (U.K.)', '106' => 'MORITANYA', '151' => 'MOZAMBIK',
|
34
|
+
'196' => 'NAMBIYA', '76' => 'NEPAL', '84' => 'NIJER', '127' => 'NIJERYA', '141' => 'NIKARAGUA', '178' => 'NIUE',
|
35
|
+
'36' => 'NORVEC', '80' => 'ORTA AFRIKA CUMHURIYETI', '131' => 'OZBEKISTAN', '77' => 'PAKISTAN', '149' => 'PALAU',
|
36
|
+
'89' => 'PANAMA', '185' => 'PAPUA YENI GINE', '194' => 'PARAGUAY', '69' => 'PERU', '183' => 'PITCAIRN ADASI',
|
37
|
+
'39' => 'POLONYA', '45' => 'PORTEKIZ', '68' => 'PORTO RIKO', '112' => 'REUNION', '37' => 'ROMANYA',
|
38
|
+
'81' => 'RUANDA', '207' => 'RUSYA', '198' => 'SAMOA', '102' => 'SENEGAL', '138' => 'SEYSEL ADALARI',
|
39
|
+
'200' => 'SILI', '179' => 'SINGAPUR', '27' => 'SIRBISTAN', '14' => 'SLOVAKYA', '19' => 'SLOVENYA',
|
40
|
+
'150' => 'SOMALI', '74' => 'SRI LANKA', '129' => 'SUDAN', '172' => 'SURINAM', '191' => 'SURIYE',
|
41
|
+
'64' => 'SUUDI ARABISTAN', '163' => 'SVALBARD', '170' => 'SVAZILAND', '101' => 'TACIKISTAN', '110' => 'TANZANYA',
|
42
|
+
'137' => 'TAYLAND', '108' => 'TAYVAN', '71' => 'TOGO', '130' => 'TONGA', '96' => 'TRINIDAT VE TOBAGO',
|
43
|
+
'118' => 'TUNUS', '159' => 'TURKMENISTAN', '75' => 'UGANDA', '40' => 'UKRAYNA', '29' => 'UKRAYNA',
|
44
|
+
'173' => 'UMMAN', '192' => 'URDUN', '201' => 'URUGUAY', '56' => 'VANUATU', '10' => 'VATIKAN',
|
45
|
+
'186' => 'VENEZUELA', '135' => 'VIETNAM', '148' => 'YEMEN', '115' => 'YENI KALEDONYA', '193' => 'YENI ZELLANDA',
|
46
|
+
'144' => 'YESIL BURUN', '22' => 'YUNANISTAN', '158' => 'ZAMBIYA', '136' => 'ZIMBABVE' }
|
7
47
|
|
8
48
|
class Request
|
9
49
|
def initialize
|
10
|
-
@cities_url =
|
11
|
-
@towns_url =
|
12
|
-
@time_url =
|
50
|
+
@cities_url = 'http://www.diyanet.gov.tr/PrayerTime/FillState?countryCode='
|
51
|
+
@towns_url = 'http://www.diyanet.gov.tr/PrayerTime/FillCity?itemId='
|
52
|
+
@time_url = 'http://www.diyanet.gov.tr/PrayerTime/PrayerTimesSet'
|
13
53
|
end
|
14
54
|
|
15
55
|
def get_cities(country)
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
return nil
|
22
|
-
end
|
23
|
-
rescue RestClient::ExceptionWithResponse => err
|
24
|
-
err.response
|
56
|
+
if COUNTRIES.key(country)
|
57
|
+
response = RestClient.get(@cities_url + COUNTRIES.key(country))
|
58
|
+
JSON.parse(response)
|
59
|
+
else
|
60
|
+
return nil
|
25
61
|
end
|
62
|
+
rescue RestClient::ExceptionWithResponse => err
|
63
|
+
err.response
|
26
64
|
end
|
27
65
|
|
28
66
|
def get_towns(country, city)
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
else
|
36
|
-
return nil
|
37
|
-
end
|
38
|
-
else
|
39
|
-
return nil
|
40
|
-
end
|
41
|
-
rescue RestClient::ExceptionWithResponse => err
|
42
|
-
err.response
|
67
|
+
if get_cities(country) || get_cities(country).select { |c| c if c['Text'] == city } != []
|
68
|
+
city_id = get_cities(country).select { |c| c if c['Text'] == city }.first['Value']
|
69
|
+
response = RestClient.get(@towns_url + city_id)
|
70
|
+
JSON.parse(response)
|
71
|
+
else
|
72
|
+
return nil
|
43
73
|
end
|
74
|
+
rescue RestClient::ExceptionWithResponse => err
|
75
|
+
err.response
|
44
76
|
end
|
45
77
|
|
46
78
|
def pray_times(country, city, town)
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
JSON.parse(response)
|
57
|
-
else
|
58
|
-
return nil
|
59
|
-
end
|
79
|
+
if !get_towns(country, city).nil?
|
80
|
+
city_id = get_cities(country).select { |c| c if c['Text'] == city }.first['Value']
|
81
|
+
if get_towns(country, city).select { |t| t if t['Text'] == town } != []
|
82
|
+
town_id = get_towns(country, city).select { |t| t if t['Text'] == town }.first['Value']
|
83
|
+
response = RestClient.post(@time_url, countryName: COUNTRIES.key(country), stateName: city_id, name: town_id)
|
84
|
+
JSON.parse(response)
|
85
|
+
elsif get_towns(country, city).select { |t| t if t['Text'] == town } == []
|
86
|
+
response = RestClient.post(@time_url, countryName: COUNTRIES.key(country), name: city_id)
|
87
|
+
JSON.parse(response)
|
60
88
|
else
|
61
89
|
return nil
|
62
90
|
end
|
63
|
-
|
64
|
-
|
91
|
+
else
|
92
|
+
return nil
|
65
93
|
end
|
94
|
+
rescue RestClient::ExceptionWithResponse => err
|
95
|
+
err.response
|
66
96
|
end
|
67
97
|
end
|
68
98
|
end
|
data/lib/prayer_time/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: prayer_time
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ecmel Kaytazoğlu
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-11-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|